ubk.erp.webpack 1.2.3 → 1.2.5
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 +6 -15
- package/dist/index.cjs +9 -9
- package/dist/index.js +2040 -2041
- 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"),s=require("antd"),G=require("swr"),_=require("react-hot-toast"),i=require("react"),Je=require("swr/mutation"),X=require("@ant-design/icons"),ae=require("dayjs"),Eo=require("react-dom/server"),ln=require("react-to-print"),Pi=require("react-select"),Ei=require("react-barcode"),Mo=()=>e.jsxs(s.Card,{style:{borderRadius:16},children:[e.jsx(s.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(s.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),de=({width:t,height:n,display:a,justifyContent:r,alignItems:o,flexDirection:l,gap:d,style:c,children:x,...y})=>{const u={width:t,height:n,display:a,justifyContent:r,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:u,...y,children:x})},Me=({variant:t,fontWeight:n,style:a,children:r,...o})=>{const l=n==="bold"?700:n==="light"?300:n;return t==="h1"?e.jsx(s.Typography.Title,{level:1,style:{fontWeight:l,...a},...o,children:r}):t==="h2"?e.jsx(s.Typography.Title,{level:2,style:{fontWeight:l,...a},...o,children:r}):t==="h3"?e.jsx(s.Typography.Title,{level:3,style:{fontWeight:l,...a},...o,children:r}):t==="h4"?e.jsx(s.Typography.Title,{level:4,style:{fontWeight:l,...a},...o,children:r}):t==="h5"?e.jsx(s.Typography.Title,{level:5,style:{fontWeight:l,...a},...o,children:r}):e.jsx(s.Typography.Text,{style:{fontWeight:l,...a},...o,children:r})};function Mi({title:t="",icon:n="",path:a="",onClick:r}){const o=()=>{if(r){r(a);return}typeof window<"u"&&typeof a=="string"&&a.length>0&&window.location.assign(a)};return e.jsxs(s.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(de,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:n,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(de,{style:{padding:"0 12px"},children:e.jsx(s.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(de,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(Me,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function Fi(t,n){return function(){return t.apply(n,arguments)}}const{toString:Fo}=Object.prototype,{getPrototypeOf:Ta}=Object,{iterator:Ra,toStringTag:Ni}=Symbol,Ia=(t=>n=>{const a=Fo.call(n);return t[a]||(t[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),yt=t=>(t=t.toLowerCase(),n=>Ia(n)===t),Da=t=>n=>typeof n===t,{isArray:dn}=Array,sn=Da("undefined");function En(t){return t!==null&&!sn(t)&&t.constructor!==null&&!sn(t.constructor)&&et(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const $i=yt("ArrayBuffer");function No(t){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(t):n=t&&t.buffer&&$i(t.buffer),n}const $o=Da("string"),et=Da("function"),Ui=Da("number"),Mn=t=>t!==null&&typeof t=="object",Uo=t=>t===!0||t===!1,da=t=>{if(Ia(t)!=="object")return!1;const n=Ta(t);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Ni in t)&&!(Ra in t)},Bo=t=>{if(!Mn(t)||En(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Lo=yt("Date"),qo=yt("File"),zo=t=>!!(t&&typeof t.uri<"u"),Yo=t=>t&&typeof t.getParts<"u",Wo=yt("Blob"),Vo=yt("FileList"),Ho=t=>Mn(t)&&et(t.pipe);function Ko(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Vs=Ko(),Hs=typeof Vs.FormData<"u"?Vs.FormData:void 0,Go=t=>{if(!t)return!1;if(Hs&&t instanceof Hs)return!0;const n=Ta(t);if(!n||n===Object.prototype||!et(t.append))return!1;const a=Ia(t);return a==="formdata"||a==="object"&&et(t.toString)&&t.toString()==="[object FormData]"},Jo=yt("URLSearchParams"),[Qo,Xo,Zo,el]=["ReadableStream","Request","Response","Headers"].map(yt),tl=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Fn(t,n,{allOwnKeys:a=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),dn(t))for(r=0,o=t.length;r<o;r++)n.call(null,t[r],r,t);else{if(En(t))return;const l=a?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(r=0;r<d;r++)c=l[r],n.call(null,t[c],c,t)}}function Bi(t,n){if(En(t))return null;n=n.toLowerCase();const a=Object.keys(t);let r=a.length,o;for(;r-- >0;)if(o=a[r],n===o.toLowerCase())return o;return null}const Bt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Li=t=>!sn(t)&&t!==Bt;function js(){const{caseless:t,skipUndefined:n}=Li(this)&&this||{},a={},r=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&Bi(a,l)||l;da(a[d])&&da(o)?a[d]=js(a[d],o):da(o)?a[d]=js({},o):dn(o)?a[d]=o.slice():(!n||!sn(o))&&(a[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&Fn(arguments[o],r);return a}const nl=(t,n,a,{allOwnKeys:r}={})=>(Fn(n,(o,l)=>{a&&et(o)?Object.defineProperty(t,l,{value:Fi(o,a),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),al=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),sl=(t,n,a,r)=>{t.prototype=Object.create(n.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:n.prototype}),a&&Object.assign(t.prototype,a)},rl=(t,n,a,r)=>{let o,l,d;const c={};if(n=n||{},t==null)return n;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!r||r(d,t,n))&&!c[d]&&(n[d]=t[d],c[d]=!0);t=a!==!1&&Ta(t)}while(t&&(!a||a(t,n))&&t!==Object.prototype);return n},il=(t,n,a)=>{t=String(t),(a===void 0||a>t.length)&&(a=t.length),a-=n.length;const r=t.indexOf(n,a);return r!==-1&&r===a},ol=t=>{if(!t)return null;if(dn(t))return t;let n=t.length;if(!Ui(n))return null;const a=new Array(n);for(;n-- >0;)a[n]=t[n];return a},ll=(t=>n=>t&&n instanceof t)(typeof Uint8Array<"u"&&Ta(Uint8Array)),dl=(t,n)=>{const r=(t&&t[Ra]).call(t);let o;for(;(o=r.next())&&!o.done;){const l=o.value;n.call(t,l[0],l[1])}},cl=(t,n)=>{let a;const r=[];for(;(a=t.exec(n))!==null;)r.push(a);return r},ul=yt("HTMLFormElement"),pl=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,r,o){return r.toUpperCase()+o}),Ks=(({hasOwnProperty:t})=>(n,a)=>t.call(n,a))(Object.prototype),ml=yt("RegExp"),qi=(t,n)=>{const a=Object.getOwnPropertyDescriptors(t),r={};Fn(a,(o,l)=>{let d;(d=n(o,l,t))!==!1&&(r[l]=d||o)}),Object.defineProperties(t,r)},yl=t=>{qi(t,(n,a)=>{if(et(t)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const r=t[a];if(et(r)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},fl=(t,n)=>{const a={},r=o=>{o.forEach(l=>{a[l]=!0})};return dn(t)?r(t):r(String(t).split(n)),a},hl=()=>{},gl=(t,n)=>t!=null&&Number.isFinite(t=+t)?t:n;function xl(t){return!!(t&&et(t.append)&&t[Ni]==="FormData"&&t[Ra])}const bl=t=>{const n=new Array(10),a=(r,o)=>{if(Mn(r)){if(n.indexOf(r)>=0)return;if(En(r))return r;if(!("toJSON"in r)){n[o]=r;const l=dn(r)?[]:{};return Fn(r,(d,c)=>{const x=a(d,o+1);!sn(x)&&(l[c]=x)}),n[o]=void 0,l}}return r};return a(t,0)},Sl=yt("AsyncFunction"),jl=t=>t&&(Mn(t)||et(t))&&et(t.then)&&et(t.catch),zi=((t,n)=>t?setImmediate:n?((a,r)=>(Bt.addEventListener("message",({source:o,data:l})=>{o===Bt&&l===a&&r.length&&r.shift()()},!1),o=>{r.push(o),Bt.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",et(Bt.postMessage)),vl=typeof queueMicrotask<"u"?queueMicrotask.bind(Bt):typeof process<"u"&&process.nextTick||zi,_l=t=>t!=null&&et(t[Ra]),K={isArray:dn,isArrayBuffer:$i,isBuffer:En,isFormData:Go,isArrayBufferView:No,isString:$o,isNumber:Ui,isBoolean:Uo,isObject:Mn,isPlainObject:da,isEmptyObject:Bo,isReadableStream:Qo,isRequest:Xo,isResponse:Zo,isHeaders:el,isUndefined:sn,isDate:Lo,isFile:qo,isReactNativeBlob:zo,isReactNative:Yo,isBlob:Wo,isRegExp:ml,isFunction:et,isStream:Ho,isURLSearchParams:Jo,isTypedArray:ll,isFileList:Vo,forEach:Fn,merge:js,extend:nl,trim:tl,stripBOM:al,inherits:sl,toFlatObject:rl,kindOf:Ia,kindOfTest:yt,endsWith:il,toArray:ol,forEachEntry:dl,matchAll:cl,isHTMLForm:ul,hasOwnProperty:Ks,hasOwnProp:Ks,reduceDescriptors:qi,freezeMethods:yl,toObjectSet:fl,toCamelCase:pl,noop:hl,toFiniteNumber:gl,findKey:Bi,global:Bt,isContextDefined:Li,isSpecCompliantForm:xl,toJSONObject:bl,isAsyncFn:Sl,isThenable:jl,setImmediate:zi,asap:vl,isIterable:_l};let _e=class Yi extends Error{static from(n,a,r,o,l,d){const c=new Yi(n.message,a||n.code,r,o,l);return c.cause=n,c.name=n.name,n.status!=null&&c.status==null&&(c.status=n.status),d&&Object.assign(c,d),c}constructor(n,a,r,o,l){super(n),Object.defineProperty(this,"message",{value:n,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,a&&(this.code=a),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:K.toJSONObject(this.config),code:this.code,status:this.status}}};_e.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";_e.ERR_BAD_OPTION="ERR_BAD_OPTION";_e.ECONNABORTED="ECONNABORTED";_e.ETIMEDOUT="ETIMEDOUT";_e.ERR_NETWORK="ERR_NETWORK";_e.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";_e.ERR_DEPRECATED="ERR_DEPRECATED";_e.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";_e.ERR_BAD_REQUEST="ERR_BAD_REQUEST";_e.ERR_CANCELED="ERR_CANCELED";_e.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";_e.ERR_INVALID_URL="ERR_INVALID_URL";_e.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const wl=null;function vs(t){return K.isPlainObject(t)||K.isArray(t)}function Wi(t){return K.endsWith(t,"[]")?t.slice(0,-2):t}function Va(t,n,a){return t?t.concat(n).map(function(o,l){return o=Wi(o),!a&&l?"["+o+"]":o}).join(a?".":""):n}function Cl(t){return K.isArray(t)&&!t.some(vs)}const Al=K.toFlatObject(K,{},null,function(n){return/^is[A-Z]/.test(n)});function ka(t,n,a){if(!K.isObject(t))throw new TypeError("target must be an object");n=n||new FormData,a=K.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,I){return!K.isUndefined(I[g])});const r=a.metaTokens,o=a.visitor||S,l=a.dots,d=a.indexes,c=a.Blob||typeof Blob<"u"&&Blob,x=a.maxDepth===void 0?100:a.maxDepth,y=c&&K.isSpecCompliantForm(n);if(!K.isFunction(o))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(K.isDate(h))return h.toISOString();if(K.isBoolean(h))return h.toString();if(!y&&K.isBlob(h))throw new _e("Blob is not supported. Use a Buffer instead.");return K.isArrayBuffer(h)||K.isTypedArray(h)?y&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function S(h,g,I){let R=h;if(K.isReactNative(n)&&K.isReactNativeBlob(h))return n.append(Va(I,g,l),u(h)),!1;if(h&&!I&&typeof h=="object"){if(K.endsWith(g,"{}"))g=r?g:g.slice(0,-2),h=JSON.stringify(h);else if(K.isArray(h)&&Cl(h)||(K.isFileList(h)||K.endsWith(g,"[]"))&&(R=K.toArray(h)))return g=Wi(g),R.forEach(function(C,f){!(K.isUndefined(C)||C===null)&&n.append(d===!0?Va([g],f,l):d===null?g:g+"[]",u(C))}),!1}return vs(h)?!0:(n.append(Va(I,g,l),u(h)),!1)}const j=[],w=Object.assign(Al,{defaultVisitor:S,convertValue:u,isVisitable:vs});function m(h,g,I=0){if(!K.isUndefined(h)){if(I>x)throw new _e("Object is too deeply nested ("+I+" levels). Max depth: "+x,_e.ERR_FORM_DATA_DEPTH_EXCEEDED);if(j.indexOf(h)!==-1)throw Error("Circular reference detected in "+g.join("."));j.push(h),K.forEach(h,function(D,C){(!(K.isUndefined(D)||D===null)&&o.call(n,D,K.isString(C)?C.trim():C,g,w))===!0&&m(D,g?g.concat(C):[C],I+1)}),j.pop()}}if(!K.isObject(t))throw new TypeError("data must be an object");return m(t),n}function Gs(t){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return n[r]})}function Ts(t,n){this._pairs=[],t&&ka(t,this,n)}const Vi=Ts.prototype;Vi.append=function(n,a){this._pairs.push([n,a])};Vi.toString=function(n){const a=n?function(r){return n.call(this,r,Gs)}:Gs;return this._pairs.map(function(o){return a(o[0])+"="+a(o[1])},"").join("&")};function Tl(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Hi(t,n,a){if(!n)return t;const r=a&&a.encode||Tl,o=K.isFunction(a)?{serialize:a}:a,l=o&&o.serialize;let d;if(l?d=l(n,o):d=K.isURLSearchParams(n)?n.toString():new Ts(n,o).toString(r),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class Js{constructor(){this.handlers=[]}use(n,a,r){return this.handlers.push({fulfilled:n,rejected:a,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){K.forEach(this.handlers,function(r){r!==null&&n(r)})}}const Rs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Rl=typeof URLSearchParams<"u"?URLSearchParams:Ts,Il=typeof FormData<"u"?FormData:null,Dl=typeof Blob<"u"?Blob:null,kl={isBrowser:!0,classes:{URLSearchParams:Rl,FormData:Il,Blob:Dl},protocols:["http","https","file","blob","url","data"]},Is=typeof window<"u"&&typeof document<"u",_s=typeof navigator=="object"&&navigator||void 0,Ol=Is&&(!_s||["ReactNative","NativeScript","NS"].indexOf(_s.product)<0),Pl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",El=Is&&window.location.href||"http://localhost",Ml=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Is,hasStandardBrowserEnv:Ol,hasStandardBrowserWebWorkerEnv:Pl,navigator:_s,origin:El},Symbol.toStringTag,{value:"Module"})),Ke={...Ml,...kl};function Fl(t,n){return ka(t,new Ke.classes.URLSearchParams,{visitor:function(a,r,o,l){return Ke.isNode&&K.isBuffer(a)?(this.append(r,a.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...n})}function Nl(t){return K.matchAll(/\w+|\[(\w*)]/g,t).map(n=>n[0]==="[]"?"":n[1]||n[0])}function $l(t){const n={},a=Object.keys(t);let r;const o=a.length;let l;for(r=0;r<o;r++)l=a[r],n[l]=t[l];return n}function Ki(t){function n(a,r,o,l){let d=a[l++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),x=l>=a.length;return d=!d&&K.isArray(o)?o.length:d,x?(K.hasOwnProp(o,d)?o[d]=K.isArray(o[d])?o[d].concat(r):[o[d],r]:o[d]=r,!c):((!o[d]||!K.isObject(o[d]))&&(o[d]=[]),n(a,r,o[d],l)&&K.isArray(o[d])&&(o[d]=$l(o[d])),!c)}if(K.isFormData(t)&&K.isFunction(t.entries)){const a={};return K.forEachEntry(t,(r,o)=>{n(Nl(r),o,a,0)}),a}return null}const Gt=(t,n)=>t!=null&&K.hasOwnProp(t,n)?t[n]:void 0;function Ul(t,n,a){if(K.isString(t))try{return(n||JSON.parse)(t),K.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(a||JSON.stringify)(t)}const Nn={transitional:Rs,adapter:["xhr","http","fetch"],transformRequest:[function(n,a){const r=a.getContentType()||"",o=r.indexOf("application/json")>-1,l=K.isObject(n);if(l&&K.isHTMLForm(n)&&(n=new FormData(n)),K.isFormData(n))return o?JSON.stringify(Ki(n)):n;if(K.isArrayBuffer(n)||K.isBuffer(n)||K.isStream(n)||K.isFile(n)||K.isBlob(n)||K.isReadableStream(n))return n;if(K.isArrayBufferView(n))return n.buffer;if(K.isURLSearchParams(n))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(l){const x=Gt(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Fl(n,x).toString();if((c=K.isFileList(n))||r.indexOf("multipart/form-data")>-1){const y=Gt(this,"env"),u=y&&y.FormData;return ka(c?{"files[]":n}:n,u&&new u,x)}}return l||o?(a.setContentType("application/json",!1),Ul(n)):n}],transformResponse:[function(n){const a=Gt(this,"transitional")||Nn.transitional,r=a&&a.forcedJSONParsing,o=Gt(this,"responseType"),l=o==="json";if(K.isResponse(n)||K.isReadableStream(n))return n;if(n&&K.isString(n)&&(r&&!o||l)){const c=!(a&&a.silentJSONParsing)&&l;try{return JSON.parse(n,Gt(this,"parseReviver"))}catch(x){if(c)throw x.name==="SyntaxError"?_e.from(x,_e.ERR_BAD_RESPONSE,this,null,Gt(this,"response")):x}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ke.classes.FormData,Blob:Ke.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};K.forEach(["delete","get","head","post","put","patch"],t=>{Nn.headers[t]={}});const Bl=K.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"]),Ll=t=>{const n={};let a,r,o;return t&&t.split(`
|
|
2
|
-
`).forEach(function(d){o=d.indexOf(":"),a=d.substring(0,o).trim().toLowerCase(),r=d.substring(o+1).trim(),!(!a||n[a]&&
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...a){const r=new this(n);return a.forEach(o=>r.set(o)),r}static accessor(n){const r=(this[Qs]=this[Qs]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=mn(d);r[c]||(Kl(o,d),r[c]=!0)}return K.isArray(n)?n.forEach(l):l(n),this}};tt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);K.reduceDescriptors(tt.prototype,({value:t},n)=>{let a=n[0].toUpperCase()+n.slice(1);return{get:()=>t,set(r){this[a]=r}}});K.freezeMethods(tt);function Ka(t,n){const a=this||Nn,r=n||a,o=tt.from(r.headers);let l=r.data;return K.forEach(t,function(c){l=c.call(a,l,o.normalize(),n?n.status:void 0)}),o.normalize(),l}function Gi(t){return!!(t&&t.__CANCEL__)}let $n=class extends _e{constructor(n,a,r){super(n??"canceled",_e.ERR_CANCELED,a,r),this.name="CanceledError",this.__CANCEL__=!0}};function Ji(t,n,a){const r=a.config.validateStatus;!a.status||!r||r(a.status)?t(a):n(new _e("Request failed with status code "+a.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function Gl(t){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return n&&n[1]||""}function Jl(t,n){t=t||10;const a=new Array(t),r=new Array(t);let o=0,l=0,d;return n=n!==void 0?n:1e3,function(x){const y=Date.now(),u=r[l];d||(d=y),a[o]=x,r[o]=y;let S=l,j=0;for(;S!==o;)j+=a[S++],S=S%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),y-d<n)return;const w=u&&y-u;return w?Math.round(j*1e3/w):void 0}}function Ql(t,n){let a=0,r=1e3/n,o,l;const d=(y,u=Date.now())=>{a=u,o=null,l&&(clearTimeout(l),l=null),t(...y)};return[(...y)=>{const u=Date.now(),S=u-a;S>=r?d(y,u):(o=y,l||(l=setTimeout(()=>{l=null,d(o)},r-S)))},()=>o&&d(o)]}const Aa=(t,n,a=3)=>{let r=0;const o=Jl(50,250);return Ql(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,x=c!=null?Math.min(d,c):d,y=Math.max(0,x-r),u=o(y);r=Math.max(r,x);const S={loaded:x,total:c,progress:c?x/c:void 0,bytes:y,rate:u||void 0,estimated:u&&c?(c-x)/u:void 0,event:l,lengthComputable:c!=null,[n?"download":"upload"]:!0};t(S)},a)},Xs=(t,n)=>{const a=t!=null;return[r=>n[0]({lengthComputable:a,total:t,loaded:r}),n[1]]},Zs=t=>(...n)=>K.asap(()=>t(...n)),Xl=Ke.hasStandardBrowserEnv?((t,n)=>a=>(a=new URL(a,Ke.origin),t.protocol===a.protocol&&t.host===a.host&&(n||t.port===a.port)))(new URL(Ke.origin),Ke.navigator&&/(msie|trident)/i.test(Ke.navigator.userAgent)):()=>!0,Zl=Ke.hasStandardBrowserEnv?{write(t,n,a,r,o,l,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(n)}`];K.isNumber(a)&&c.push(`expires=${new Date(a).toUTCString()}`),K.isString(r)&&c.push(`path=${r}`),K.isString(o)&&c.push(`domain=${o}`),l===!0&&c.push("secure"),K.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const n=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return n?decodeURIComponent(n[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function ed(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function td(t,n){return n?t.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):t}function Qi(t,n,a){let r=!ed(n);return t&&(r||a===!1)?td(t,n):n}const er=t=>t instanceof tt?{...t}:t;function Yt(t,n){n=n||{};const a=Object.create(null);Object.defineProperty(a,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(y,u,S,j){return K.isPlainObject(y)&&K.isPlainObject(u)?K.merge.call({caseless:j},y,u):K.isPlainObject(u)?K.merge({},u):K.isArray(u)?u.slice():u}function o(y,u,S,j){if(K.isUndefined(u)){if(!K.isUndefined(y))return r(void 0,y,S,j)}else return r(y,u,S,j)}function l(y,u){if(!K.isUndefined(u))return r(void 0,u)}function d(y,u){if(K.isUndefined(u)){if(!K.isUndefined(y))return r(void 0,y)}else return r(void 0,u)}function c(y,u,S){if(K.hasOwnProp(n,S))return r(y,u);if(K.hasOwnProp(t,S))return r(void 0,y)}const x={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:(y,u,S)=>o(er(y),er(u),S,!0)};return K.forEach(Object.keys({...t,...n}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const S=K.hasOwnProp(x,u)?x[u]:o,j=K.hasOwnProp(t,u)?t[u]:void 0,w=K.hasOwnProp(n,u)?n[u]:void 0,m=S(j,w,u);K.isUndefined(m)&&S!==c||(a[u]=m)}),a}const Xi=t=>{const n=Yt({},t),a=j=>K.hasOwnProp(n,j)?n[j]:void 0,r=a("data");let o=a("withXSRFToken");const l=a("xsrfHeaderName"),d=a("xsrfCookieName");let c=a("headers");const x=a("auth"),y=a("baseURL"),u=a("allowAbsoluteUrls"),S=a("url");if(n.headers=c=tt.from(c),n.url=Hi(Qi(y,S,u),t.params,t.paramsSerializer),x&&c.set("Authorization","Basic "+btoa((x.username||"")+":"+(x.password?unescape(encodeURIComponent(x.password)):""))),K.isFormData(r)){if(Ke.hasStandardBrowserEnv||Ke.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(K.isFunction(r.getHeaders)){const j=r.getHeaders(),w=["content-type","content-length"];Object.entries(j).forEach(([m,h])=>{w.includes(m.toLowerCase())&&c.set(m,h)})}}if(Ke.hasStandardBrowserEnv&&(K.isFunction(o)&&(o=o(n)),o===!0||o==null&&Xl(n.url))){const w=l&&d&&Zl.read(d);w&&c.set(l,w)}return n},nd=typeof XMLHttpRequest<"u",ad=nd&&function(t){return new Promise(function(a,r){const o=Xi(t);let l=o.data;const d=tt.from(o.headers).normalize();let{responseType:c,onUploadProgress:x,onDownloadProgress:y}=o,u,S,j,w,m;function h(){w&&w(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function I(){if(!g)return;const D=tt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),f={data:!c||c==="text"||c==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:D,config:t,request:g};Ji(function(b){a(b),h()},function(b){r(b),h()},f),g=null}"onloadend"in g?g.onloadend=I:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(I)},g.onabort=function(){g&&(r(new _e("Request aborted",_e.ECONNABORTED,t,g)),g=null)},g.onerror=function(C){const f=C&&C.message?C.message:"Network Error",p=new _e(f,_e.ERR_NETWORK,t,g);p.event=C||null,r(p),g=null},g.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const f=o.transitional||Rs;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),r(new _e(C,f.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,t,g)),g=null},l===void 0&&d.setContentType(null),"setRequestHeader"in g&&K.forEach(d.toJSON(),function(C,f){g.setRequestHeader(f,C)}),K.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),c&&c!=="json"&&(g.responseType=o.responseType),y&&([j,m]=Aa(y,!0),g.addEventListener("progress",j)),x&&g.upload&&([S,w]=Aa(x),g.upload.addEventListener("progress",S),g.upload.addEventListener("loadend",w)),(o.cancelToken||o.signal)&&(u=D=>{g&&(r(!D||D.type?new $n(null,t,g):D),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const R=Gl(o.url);if(R&&Ke.protocols.indexOf(R)===-1){r(new _e("Unsupported protocol "+R+":",_e.ERR_BAD_REQUEST,t));return}g.send(l||null)})},sd=(t,n)=>{const{length:a}=t=t?t.filter(Boolean):[];if(n||a){let r=new AbortController,o;const l=function(y){if(!o){o=!0,c();const u=y instanceof Error?y:this.reason;r.abort(u instanceof _e?u:new $n(u instanceof Error?u.message:u))}};let d=n&&setTimeout(()=>{d=null,l(new _e(`timeout of ${n}ms exceeded`,_e.ETIMEDOUT))},n);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(y=>{y.unsubscribe?y.unsubscribe(l):y.removeEventListener("abort",l)}),t=null)};t.forEach(y=>y.addEventListener("abort",l));const{signal:x}=r;return x.unsubscribe=()=>K.asap(c),x}},rd=function*(t,n){let a=t.byteLength;if(a<n){yield t;return}let r=0,o;for(;r<a;)o=r+n,yield t.slice(r,o),r=o},id=async function*(t,n){for await(const a of od(t))yield*rd(a,n)},od=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const n=t.getReader();try{for(;;){const{done:a,value:r}=await n.read();if(a)break;yield r}}finally{await n.cancel()}},tr=(t,n,a,r)=>{const o=id(t,n);let l=0,d,c=x=>{d||(d=!0,r&&r(x))};return new ReadableStream({async pull(x){try{const{done:y,value:u}=await o.next();if(y){c(),x.close();return}let S=u.byteLength;if(a){let j=l+=S;a(j)}x.enqueue(new Uint8Array(u))}catch(y){throw c(y),y}},cancel(x){return c(x),o.return()}},{highWaterMark:2})},nr=64*1024,{isFunction:Wn}=K,ld=(({Request:t,Response:n})=>({Request:t,Response:n}))(K.global),{ReadableStream:ar,TextEncoder:sr}=K.global,rr=(t,...n)=>{try{return!!t(...n)}catch{return!1}},dd=t=>{t=K.merge.call({skipUndefined:!0},ld,t);const{fetch:n,Request:a,Response:r}=t,o=n?Wn(n):typeof fetch=="function",l=Wn(a),d=Wn(r);if(!o)return!1;const c=o&&Wn(ar),x=o&&(typeof sr=="function"?(m=>h=>m.encode(h))(new sr):async m=>new Uint8Array(await new a(m).arrayBuffer())),y=l&&c&&rr(()=>{let m=!1;const h=new a(Ke.origin,{body:new ar,method:"POST",get duplex(){return m=!0,"half"}}),g=h.headers.has("Content-Type");return h.body!=null&&h.body.cancel(),m&&!g}),u=d&&c&&rr(()=>K.isReadableStream(new r("").body)),S={stream:u&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!S[m]&&(S[m]=(h,g)=>{let I=h&&h[m];if(I)return I.call(h);throw new _e(`Response type '${m}' is not supported`,_e.ERR_NOT_SUPPORT,g)})});const j=async m=>{if(m==null)return 0;if(K.isBlob(m))return m.size;if(K.isSpecCompliantForm(m))return(await new a(Ke.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(K.isArrayBufferView(m)||K.isArrayBuffer(m))return m.byteLength;if(K.isURLSearchParams(m)&&(m=m+""),K.isString(m))return(await x(m)).byteLength},w=async(m,h)=>{const g=K.toFiniteNumber(m.getContentLength());return g??j(h)};return async m=>{let{url:h,method:g,data:I,signal:R,cancelToken:D,timeout:C,onDownloadProgress:f,onUploadProgress:p,responseType:b,headers:A,withCredentials:O="same-origin",fetchOptions:L}=Xi(m),U=n||fetch;b=b?(b+"").toLowerCase():"text";let v=sd([R,D&&D.toAbortSignal()],C),M=null;const P=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let N;try{if(p&&y&&g!=="get"&&g!=="head"&&(N=await w(A,I))!==0){let T=new a(h,{method:"POST",body:I,duplex:"half"}),$;if(K.isFormData(I)&&($=T.headers.get("content-type"))&&A.setContentType($),T.body){const[B,Y]=Xs(N,Aa(Zs(p)));I=tr(T.body,nr,B,Y)}}K.isString(O)||(O=O?"include":"omit");const E=l&&"credentials"in a.prototype;if(K.isFormData(I)){const T=A.getContentType();T&&/^multipart\/form-data/i.test(T)&&!/boundary=/i.test(T)&&A.delete("content-type")}const F={...L,signal:v,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:I,duplex:"half",credentials:E?O:void 0};M=l&&new a(h,F);let q=await(l?U(M,L):U(h,F));const z=u&&(b==="stream"||b==="response");if(u&&(f||z&&P)){const T={};["status","statusText","headers"].forEach(ne=>{T[ne]=q[ne]});const $=K.toFiniteNumber(q.headers.get("content-length")),[B,Y]=f&&Xs($,Aa(Zs(f),!0))||[];q=new r(tr(q.body,nr,B,()=>{Y&&Y(),P&&P()}),T)}b=b||"text";let k=await S[K.findKey(S,b)||"text"](q,m);return!z&&P&&P(),await new Promise((T,$)=>{Ji(T,$,{data:k,headers:tt.from(q.headers),status:q.status,statusText:q.statusText,config:m,request:M})})}catch(E){throw P&&P(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,m,M,E&&E.response),{cause:E.cause||E}):_e.from(E,E&&E.code,m,M,E&&E.response)}}},cd=new Map,Zi=t=>{let n=t&&t.env||{};const{fetch:a,Request:r,Response:o}=n,l=[r,o,a];let d=l.length,c=d,x,y,u=cd;for(;c--;)x=l[c],y=u.get(x),y===void 0&&u.set(x,y=c?new Map:dd(n)),u=y;return y};Zi();const Ds={http:wl,xhr:ad,fetch:{get:Zi}};K.forEach(Ds,(t,n)=>{if(t){try{Object.defineProperty(t,"name",{value:n})}catch{}Object.defineProperty(t,"adapterName",{value:n})}});const ir=t=>`- ${t}`,ud=t=>K.isFunction(t)||t===null||t===!1;function pd(t,n){t=K.isArray(t)?t:[t];const{length:a}=t;let r,o;const l={};for(let d=0;d<a;d++){r=t[d];let c;if(o=r,!ud(r)&&(o=Ds[(c=String(r)).toLowerCase()],o===void 0))throw new _e(`Unknown adapter '${c}'`);if(o&&(K.isFunction(o)||(o=o.get(n))))break;l[c||"#"+d]=o}if(!o){const d=Object.entries(l).map(([x,y])=>`adapter ${x} `+(y===!1?"is not supported by the environment":"is not available in the build"));let c=a?d.length>1?`since :
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("antd"),G=require("swr"),_=require("react-hot-toast"),i=require("react"),Je=require("swr/mutation"),X=require("@ant-design/icons"),ae=require("dayjs"),Po=require("react-dom/server"),dn=require("react-to-print"),Pi=require("react-select"),Ei=require("react-barcode"),Eo=()=>e.jsxs(s.Card,{style:{borderRadius:16},children:[e.jsx(s.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(s.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),le=({width:t,height:n,display:a,justifyContent:r,alignItems:o,flexDirection:l,gap:d,style:c,children:x,...y})=>{const u={width:t,height:n,display:a,justifyContent:r,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:u,...y,children:x})},Me=({variant:t,fontWeight:n,style:a,children:r,...o})=>{const l=n==="bold"?700:n==="light"?300:n;return t==="h1"?e.jsx(s.Typography.Title,{level:1,style:{fontWeight:l,...a},...o,children:r}):t==="h2"?e.jsx(s.Typography.Title,{level:2,style:{fontWeight:l,...a},...o,children:r}):t==="h3"?e.jsx(s.Typography.Title,{level:3,style:{fontWeight:l,...a},...o,children:r}):t==="h4"?e.jsx(s.Typography.Title,{level:4,style:{fontWeight:l,...a},...o,children:r}):t==="h5"?e.jsx(s.Typography.Title,{level:5,style:{fontWeight:l,...a},...o,children:r}):e.jsx(s.Typography.Text,{style:{fontWeight:l,...a},...o,children:r})};function Mi({title:t="",icon:n="",path:a="",onClick:r}){const o=()=>{if(r){r(a);return}typeof window<"u"&&typeof a=="string"&&a.length>0&&window.location.assign(a)};return e.jsxs(s.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(le,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:n,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(le,{style:{padding:"0 12px"},children:e.jsx(s.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(le,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(Me,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function Fi(t,n){return function(){return t.apply(n,arguments)}}const{toString:Mo}=Object.prototype,{getPrototypeOf:Ra}=Object,{iterator:Ia,toStringTag:Ni}=Symbol,Da=(t=>n=>{const a=Mo.call(n);return t[a]||(t[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),ft=t=>(t=t.toLowerCase(),n=>Da(n)===t),ka=t=>n=>typeof n===t,{isArray:cn}=Array,rn=ka("undefined");function Mn(t){return t!==null&&!rn(t)&&t.constructor!==null&&!rn(t.constructor)&&tt(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const $i=ft("ArrayBuffer");function Fo(t){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(t):n=t&&t.buffer&&$i(t.buffer),n}const No=ka("string"),tt=ka("function"),Ui=ka("number"),Fn=t=>t!==null&&typeof t=="object",$o=t=>t===!0||t===!1,ca=t=>{if(Da(t)!=="object")return!1;const n=Ra(t);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Ni in t)&&!(Ia in t)},Uo=t=>{if(!Fn(t)||Mn(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Bo=ft("Date"),Lo=ft("File"),qo=t=>!!(t&&typeof t.uri<"u"),zo=t=>t&&typeof t.getParts<"u",Yo=ft("Blob"),Wo=ft("FileList"),Vo=t=>Fn(t)&&tt(t.pipe);function Ho(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Vs=Ho(),Hs=typeof Vs.FormData<"u"?Vs.FormData:void 0,Ko=t=>{if(!t)return!1;if(Hs&&t instanceof Hs)return!0;const n=Ra(t);if(!n||n===Object.prototype||!tt(t.append))return!1;const a=Da(t);return a==="formdata"||a==="object"&&tt(t.toString)&&t.toString()==="[object FormData]"},Go=ft("URLSearchParams"),[Jo,Qo,Xo,Zo]=["ReadableStream","Request","Response","Headers"].map(ft),el=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nn(t,n,{allOwnKeys:a=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),cn(t))for(r=0,o=t.length;r<o;r++)n.call(null,t[r],r,t);else{if(Mn(t))return;const l=a?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(r=0;r<d;r++)c=l[r],n.call(null,t[c],c,t)}}function Bi(t,n){if(Mn(t))return null;n=n.toLowerCase();const a=Object.keys(t);let r=a.length,o;for(;r-- >0;)if(o=a[r],n===o.toLowerCase())return o;return null}const Lt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Li=t=>!rn(t)&&t!==Lt;function js(){const{caseless:t,skipUndefined:n}=Li(this)&&this||{},a={},r=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&Bi(a,l)||l;ca(a[d])&&ca(o)?a[d]=js(a[d],o):ca(o)?a[d]=js({},o):cn(o)?a[d]=o.slice():(!n||!rn(o))&&(a[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&Nn(arguments[o],r);return a}const tl=(t,n,a,{allOwnKeys:r}={})=>(Nn(n,(o,l)=>{a&&tt(o)?Object.defineProperty(t,l,{value:Fi(o,a),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),nl=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),al=(t,n,a,r)=>{t.prototype=Object.create(n.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:n.prototype}),a&&Object.assign(t.prototype,a)},sl=(t,n,a,r)=>{let o,l,d;const c={};if(n=n||{},t==null)return n;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!r||r(d,t,n))&&!c[d]&&(n[d]=t[d],c[d]=!0);t=a!==!1&&Ra(t)}while(t&&(!a||a(t,n))&&t!==Object.prototype);return n},rl=(t,n,a)=>{t=String(t),(a===void 0||a>t.length)&&(a=t.length),a-=n.length;const r=t.indexOf(n,a);return r!==-1&&r===a},il=t=>{if(!t)return null;if(cn(t))return t;let n=t.length;if(!Ui(n))return null;const a=new Array(n);for(;n-- >0;)a[n]=t[n];return a},ol=(t=>n=>t&&n instanceof t)(typeof Uint8Array<"u"&&Ra(Uint8Array)),ll=(t,n)=>{const r=(t&&t[Ia]).call(t);let o;for(;(o=r.next())&&!o.done;){const l=o.value;n.call(t,l[0],l[1])}},dl=(t,n)=>{let a;const r=[];for(;(a=t.exec(n))!==null;)r.push(a);return r},cl=ft("HTMLFormElement"),ul=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,r,o){return r.toUpperCase()+o}),Ks=(({hasOwnProperty:t})=>(n,a)=>t.call(n,a))(Object.prototype),pl=ft("RegExp"),qi=(t,n)=>{const a=Object.getOwnPropertyDescriptors(t),r={};Nn(a,(o,l)=>{let d;(d=n(o,l,t))!==!1&&(r[l]=d||o)}),Object.defineProperties(t,r)},ml=t=>{qi(t,(n,a)=>{if(tt(t)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const r=t[a];if(tt(r)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},yl=(t,n)=>{const a={},r=o=>{o.forEach(l=>{a[l]=!0})};return cn(t)?r(t):r(String(t).split(n)),a},fl=()=>{},hl=(t,n)=>t!=null&&Number.isFinite(t=+t)?t:n;function gl(t){return!!(t&&tt(t.append)&&t[Ni]==="FormData"&&t[Ia])}const xl=t=>{const n=new Array(10),a=(r,o)=>{if(Fn(r)){if(n.indexOf(r)>=0)return;if(Mn(r))return r;if(!("toJSON"in r)){n[o]=r;const l=cn(r)?[]:{};return Nn(r,(d,c)=>{const x=a(d,o+1);!rn(x)&&(l[c]=x)}),n[o]=void 0,l}}return r};return a(t,0)},bl=ft("AsyncFunction"),Sl=t=>t&&(Fn(t)||tt(t))&&tt(t.then)&&tt(t.catch),zi=((t,n)=>t?setImmediate:n?((a,r)=>(Lt.addEventListener("message",({source:o,data:l})=>{o===Lt&&l===a&&r.length&&r.shift()()},!1),o=>{r.push(o),Lt.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",tt(Lt.postMessage)),jl=typeof queueMicrotask<"u"?queueMicrotask.bind(Lt):typeof process<"u"&&process.nextTick||zi,vl=t=>t!=null&&tt(t[Ia]),K={isArray:cn,isArrayBuffer:$i,isBuffer:Mn,isFormData:Ko,isArrayBufferView:Fo,isString:No,isNumber:Ui,isBoolean:$o,isObject:Fn,isPlainObject:ca,isEmptyObject:Uo,isReadableStream:Jo,isRequest:Qo,isResponse:Xo,isHeaders:Zo,isUndefined:rn,isDate:Bo,isFile:Lo,isReactNativeBlob:qo,isReactNative:zo,isBlob:Yo,isRegExp:pl,isFunction:tt,isStream:Vo,isURLSearchParams:Go,isTypedArray:ol,isFileList:Wo,forEach:Nn,merge:js,extend:tl,trim:el,stripBOM:nl,inherits:al,toFlatObject:sl,kindOf:Da,kindOfTest:ft,endsWith:rl,toArray:il,forEachEntry:ll,matchAll:dl,isHTMLForm:cl,hasOwnProperty:Ks,hasOwnProp:Ks,reduceDescriptors:qi,freezeMethods:ml,toObjectSet:yl,toCamelCase:ul,noop:fl,toFiniteNumber:hl,findKey:Bi,global:Lt,isContextDefined:Li,isSpecCompliantForm:gl,toJSONObject:xl,isAsyncFn:bl,isThenable:Sl,setImmediate:zi,asap:jl,isIterable:vl};let _e=class Yi extends Error{static from(n,a,r,o,l,d){const c=new Yi(n.message,a||n.code,r,o,l);return c.cause=n,c.name=n.name,n.status!=null&&c.status==null&&(c.status=n.status),d&&Object.assign(c,d),c}constructor(n,a,r,o,l){super(n),Object.defineProperty(this,"message",{value:n,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,a&&(this.code=a),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:K.toJSONObject(this.config),code:this.code,status:this.status}}};_e.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";_e.ERR_BAD_OPTION="ERR_BAD_OPTION";_e.ECONNABORTED="ECONNABORTED";_e.ETIMEDOUT="ETIMEDOUT";_e.ERR_NETWORK="ERR_NETWORK";_e.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";_e.ERR_DEPRECATED="ERR_DEPRECATED";_e.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";_e.ERR_BAD_REQUEST="ERR_BAD_REQUEST";_e.ERR_CANCELED="ERR_CANCELED";_e.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";_e.ERR_INVALID_URL="ERR_INVALID_URL";_e.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const _l=null;function vs(t){return K.isPlainObject(t)||K.isArray(t)}function Wi(t){return K.endsWith(t,"[]")?t.slice(0,-2):t}function Va(t,n,a){return t?t.concat(n).map(function(o,l){return o=Wi(o),!a&&l?"["+o+"]":o}).join(a?".":""):n}function wl(t){return K.isArray(t)&&!t.some(vs)}const Cl=K.toFlatObject(K,{},null,function(n){return/^is[A-Z]/.test(n)});function Oa(t,n,a){if(!K.isObject(t))throw new TypeError("target must be an object");n=n||new FormData,a=K.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,I){return!K.isUndefined(I[g])});const r=a.metaTokens,o=a.visitor||S,l=a.dots,d=a.indexes,c=a.Blob||typeof Blob<"u"&&Blob,x=a.maxDepth===void 0?100:a.maxDepth,y=c&&K.isSpecCompliantForm(n);if(!K.isFunction(o))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(K.isDate(h))return h.toISOString();if(K.isBoolean(h))return h.toString();if(!y&&K.isBlob(h))throw new _e("Blob is not supported. Use a Buffer instead.");return K.isArrayBuffer(h)||K.isTypedArray(h)?y&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function S(h,g,I){let R=h;if(K.isReactNative(n)&&K.isReactNativeBlob(h))return n.append(Va(I,g,l),u(h)),!1;if(h&&!I&&typeof h=="object"){if(K.endsWith(g,"{}"))g=r?g:g.slice(0,-2),h=JSON.stringify(h);else if(K.isArray(h)&&wl(h)||(K.isFileList(h)||K.endsWith(g,"[]"))&&(R=K.toArray(h)))return g=Wi(g),R.forEach(function(C,f){!(K.isUndefined(C)||C===null)&&n.append(d===!0?Va([g],f,l):d===null?g:g+"[]",u(C))}),!1}return vs(h)?!0:(n.append(Va(I,g,l),u(h)),!1)}const j=[],w=Object.assign(Cl,{defaultVisitor:S,convertValue:u,isVisitable:vs});function m(h,g,I=0){if(!K.isUndefined(h)){if(I>x)throw new _e("Object is too deeply nested ("+I+" levels). Max depth: "+x,_e.ERR_FORM_DATA_DEPTH_EXCEEDED);if(j.indexOf(h)!==-1)throw Error("Circular reference detected in "+g.join("."));j.push(h),K.forEach(h,function(D,C){(!(K.isUndefined(D)||D===null)&&o.call(n,D,K.isString(C)?C.trim():C,g,w))===!0&&m(D,g?g.concat(C):[C],I+1)}),j.pop()}}if(!K.isObject(t))throw new TypeError("data must be an object");return m(t),n}function Gs(t){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return n[r]})}function Ts(t,n){this._pairs=[],t&&Oa(t,this,n)}const Vi=Ts.prototype;Vi.append=function(n,a){this._pairs.push([n,a])};Vi.toString=function(n){const a=n?function(r){return n.call(this,r,Gs)}:Gs;return this._pairs.map(function(o){return a(o[0])+"="+a(o[1])},"").join("&")};function Al(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Hi(t,n,a){if(!n)return t;const r=a&&a.encode||Al,o=K.isFunction(a)?{serialize:a}:a,l=o&&o.serialize;let d;if(l?d=l(n,o):d=K.isURLSearchParams(n)?n.toString():new Ts(n,o).toString(r),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class Js{constructor(){this.handlers=[]}use(n,a,r){return this.handlers.push({fulfilled:n,rejected:a,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){K.forEach(this.handlers,function(r){r!==null&&n(r)})}}const Rs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Tl=typeof URLSearchParams<"u"?URLSearchParams:Ts,Rl=typeof FormData<"u"?FormData:null,Il=typeof Blob<"u"?Blob:null,Dl={isBrowser:!0,classes:{URLSearchParams:Tl,FormData:Rl,Blob:Il},protocols:["http","https","file","blob","url","data"]},Is=typeof window<"u"&&typeof document<"u",_s=typeof navigator=="object"&&navigator||void 0,kl=Is&&(!_s||["ReactNative","NativeScript","NS"].indexOf(_s.product)<0),Ol=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Pl=Is&&window.location.href||"http://localhost",El=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Is,hasStandardBrowserEnv:kl,hasStandardBrowserWebWorkerEnv:Ol,navigator:_s,origin:Pl},Symbol.toStringTag,{value:"Module"})),Ke={...El,...Dl};function Ml(t,n){return Oa(t,new Ke.classes.URLSearchParams,{visitor:function(a,r,o,l){return Ke.isNode&&K.isBuffer(a)?(this.append(r,a.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...n})}function Fl(t){return K.matchAll(/\w+|\[(\w*)]/g,t).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Nl(t){const n={},a=Object.keys(t);let r;const o=a.length;let l;for(r=0;r<o;r++)l=a[r],n[l]=t[l];return n}function Ki(t){function n(a,r,o,l){let d=a[l++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),x=l>=a.length;return d=!d&&K.isArray(o)?o.length:d,x?(K.hasOwnProp(o,d)?o[d]=K.isArray(o[d])?o[d].concat(r):[o[d],r]:o[d]=r,!c):((!o[d]||!K.isObject(o[d]))&&(o[d]=[]),n(a,r,o[d],l)&&K.isArray(o[d])&&(o[d]=Nl(o[d])),!c)}if(K.isFormData(t)&&K.isFunction(t.entries)){const a={};return K.forEachEntry(t,(r,o)=>{n(Fl(r),o,a,0)}),a}return null}const Jt=(t,n)=>t!=null&&K.hasOwnProp(t,n)?t[n]:void 0;function $l(t,n,a){if(K.isString(t))try{return(n||JSON.parse)(t),K.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(a||JSON.stringify)(t)}const $n={transitional:Rs,adapter:["xhr","http","fetch"],transformRequest:[function(n,a){const r=a.getContentType()||"",o=r.indexOf("application/json")>-1,l=K.isObject(n);if(l&&K.isHTMLForm(n)&&(n=new FormData(n)),K.isFormData(n))return o?JSON.stringify(Ki(n)):n;if(K.isArrayBuffer(n)||K.isBuffer(n)||K.isStream(n)||K.isFile(n)||K.isBlob(n)||K.isReadableStream(n))return n;if(K.isArrayBufferView(n))return n.buffer;if(K.isURLSearchParams(n))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(l){const x=Jt(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Ml(n,x).toString();if((c=K.isFileList(n))||r.indexOf("multipart/form-data")>-1){const y=Jt(this,"env"),u=y&&y.FormData;return Oa(c?{"files[]":n}:n,u&&new u,x)}}return l||o?(a.setContentType("application/json",!1),$l(n)):n}],transformResponse:[function(n){const a=Jt(this,"transitional")||$n.transitional,r=a&&a.forcedJSONParsing,o=Jt(this,"responseType"),l=o==="json";if(K.isResponse(n)||K.isReadableStream(n))return n;if(n&&K.isString(n)&&(r&&!o||l)){const c=!(a&&a.silentJSONParsing)&&l;try{return JSON.parse(n,Jt(this,"parseReviver"))}catch(x){if(c)throw x.name==="SyntaxError"?_e.from(x,_e.ERR_BAD_RESPONSE,this,null,Jt(this,"response")):x}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ke.classes.FormData,Blob:Ke.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};K.forEach(["delete","get","head","post","put","patch"],t=>{$n.headers[t]={}});const Ul=K.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"]),Bl=t=>{const n={};let a,r,o;return t&&t.split(`
|
|
2
|
+
`).forEach(function(d){o=d.indexOf(":"),a=d.substring(0,o).trim().toLowerCase(),r=d.substring(o+1).trim(),!(!a||n[a]&&Ul[a])&&(a==="set-cookie"?n[a]?n[a].push(r):n[a]=[r]:n[a]=n[a]?n[a]+", "+r:r)}),n},Qs=Symbol("internals"),Ll=/[^\x09\x20-\x7E\x80-\xFF]/g;function ql(t){let n=0,a=t.length;for(;n<a;){const r=t.charCodeAt(n);if(r!==9&&r!==32)break;n+=1}for(;a>n;){const r=t.charCodeAt(a-1);if(r!==9&&r!==32)break;a-=1}return n===0&&a===t.length?t:t.slice(n,a)}function yn(t){return t&&String(t).trim().toLowerCase()}function zl(t){return ql(t.replace(Ll,""))}function ua(t){return t===!1||t==null?t:K.isArray(t)?t.map(ua):zl(String(t))}function Yl(t){const n=Object.create(null),a=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=a.exec(t);)n[r[1]]=r[2];return n}const Wl=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Ha(t,n,a,r,o){if(K.isFunction(r))return r.call(this,n,a);if(o&&(n=a),!!K.isString(n)){if(K.isString(r))return n.indexOf(r)!==-1;if(K.isRegExp(r))return r.test(n)}}function Vl(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,a,r)=>a.toUpperCase()+r)}function Hl(t,n){const a=K.toCamelCase(" "+n);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+a,{value:function(o,l,d){return this[r].call(this,n,o,l,d)},configurable:!0})})}let nt=class{constructor(n){n&&this.set(n)}set(n,a,r){const o=this;function l(c,x,y){const u=yn(x);if(!u)throw new Error("header name must be a non-empty string");const S=K.findKey(o,u);(!S||o[S]===void 0||y===!0||y===void 0&&o[S]!==!1)&&(o[S||x]=ua(c))}const d=(c,x)=>K.forEach(c,(y,u)=>l(y,u,x));if(K.isPlainObject(n)||n instanceof this.constructor)d(n,a);else if(K.isString(n)&&(n=n.trim())&&!Wl(n))d(Bl(n),a);else if(K.isObject(n)&&K.isIterable(n)){let c={},x,y;for(const u of n){if(!K.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[y=u[0]]=(x=c[y])?K.isArray(x)?[...x,u[1]]:[x,u[1]]:u[1]}d(c,a)}else n!=null&&l(a,n,r);return this}get(n,a){if(n=yn(n),n){const r=K.findKey(this,n);if(r){const o=this[r];if(!a)return o;if(a===!0)return Yl(o);if(K.isFunction(a))return a.call(this,o,r);if(K.isRegExp(a))return a.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,a){if(n=yn(n),n){const r=K.findKey(this,n);return!!(r&&this[r]!==void 0&&(!a||Ha(this,this[r],r,a)))}return!1}delete(n,a){const r=this;let o=!1;function l(d){if(d=yn(d),d){const c=K.findKey(r,d);c&&(!a||Ha(r,r[c],c,a))&&(delete r[c],o=!0)}}return K.isArray(n)?n.forEach(l):l(n),o}clear(n){const a=Object.keys(this);let r=a.length,o=!1;for(;r--;){const l=a[r];(!n||Ha(this,this[l],l,n,!0))&&(delete this[l],o=!0)}return o}normalize(n){const a=this,r={};return K.forEach(this,(o,l)=>{const d=K.findKey(r,l);if(d){a[d]=ua(o),delete a[l];return}const c=n?Vl(l):String(l).trim();c!==l&&delete a[l],a[c]=ua(o),r[c]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const a=Object.create(null);return K.forEach(this,(r,o)=>{r!=null&&r!==!1&&(a[o]=n&&K.isArray(r)?r.join(", "):r)}),a}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,a])=>n+": "+a).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...a){const r=new this(n);return a.forEach(o=>r.set(o)),r}static accessor(n){const r=(this[Qs]=this[Qs]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=yn(d);r[c]||(Hl(o,d),r[c]=!0)}return K.isArray(n)?n.forEach(l):l(n),this}};nt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);K.reduceDescriptors(nt.prototype,({value:t},n)=>{let a=n[0].toUpperCase()+n.slice(1);return{get:()=>t,set(r){this[a]=r}}});K.freezeMethods(nt);function Ka(t,n){const a=this||$n,r=n||a,o=nt.from(r.headers);let l=r.data;return K.forEach(t,function(c){l=c.call(a,l,o.normalize(),n?n.status:void 0)}),o.normalize(),l}function Gi(t){return!!(t&&t.__CANCEL__)}let Un=class extends _e{constructor(n,a,r){super(n??"canceled",_e.ERR_CANCELED,a,r),this.name="CanceledError",this.__CANCEL__=!0}};function Ji(t,n,a){const r=a.config.validateStatus;!a.status||!r||r(a.status)?t(a):n(new _e("Request failed with status code "+a.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function Kl(t){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return n&&n[1]||""}function Gl(t,n){t=t||10;const a=new Array(t),r=new Array(t);let o=0,l=0,d;return n=n!==void 0?n:1e3,function(x){const y=Date.now(),u=r[l];d||(d=y),a[o]=x,r[o]=y;let S=l,j=0;for(;S!==o;)j+=a[S++],S=S%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),y-d<n)return;const w=u&&y-u;return w?Math.round(j*1e3/w):void 0}}function Jl(t,n){let a=0,r=1e3/n,o,l;const d=(y,u=Date.now())=>{a=u,o=null,l&&(clearTimeout(l),l=null),t(...y)};return[(...y)=>{const u=Date.now(),S=u-a;S>=r?d(y,u):(o=y,l||(l=setTimeout(()=>{l=null,d(o)},r-S)))},()=>o&&d(o)]}const Ta=(t,n,a=3)=>{let r=0;const o=Gl(50,250);return Jl(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,x=c!=null?Math.min(d,c):d,y=Math.max(0,x-r),u=o(y);r=Math.max(r,x);const S={loaded:x,total:c,progress:c?x/c:void 0,bytes:y,rate:u||void 0,estimated:u&&c?(c-x)/u:void 0,event:l,lengthComputable:c!=null,[n?"download":"upload"]:!0};t(S)},a)},Xs=(t,n)=>{const a=t!=null;return[r=>n[0]({lengthComputable:a,total:t,loaded:r}),n[1]]},Zs=t=>(...n)=>K.asap(()=>t(...n)),Ql=Ke.hasStandardBrowserEnv?((t,n)=>a=>(a=new URL(a,Ke.origin),t.protocol===a.protocol&&t.host===a.host&&(n||t.port===a.port)))(new URL(Ke.origin),Ke.navigator&&/(msie|trident)/i.test(Ke.navigator.userAgent)):()=>!0,Xl=Ke.hasStandardBrowserEnv?{write(t,n,a,r,o,l,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(n)}`];K.isNumber(a)&&c.push(`expires=${new Date(a).toUTCString()}`),K.isString(r)&&c.push(`path=${r}`),K.isString(o)&&c.push(`domain=${o}`),l===!0&&c.push("secure"),K.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const n=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return n?decodeURIComponent(n[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Zl(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function ed(t,n){return n?t.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):t}function Qi(t,n,a){let r=!Zl(n);return t&&(r||a===!1)?ed(t,n):n}const er=t=>t instanceof nt?{...t}:t;function Wt(t,n){n=n||{};const a=Object.create(null);Object.defineProperty(a,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(y,u,S,j){return K.isPlainObject(y)&&K.isPlainObject(u)?K.merge.call({caseless:j},y,u):K.isPlainObject(u)?K.merge({},u):K.isArray(u)?u.slice():u}function o(y,u,S,j){if(K.isUndefined(u)){if(!K.isUndefined(y))return r(void 0,y,S,j)}else return r(y,u,S,j)}function l(y,u){if(!K.isUndefined(u))return r(void 0,u)}function d(y,u){if(K.isUndefined(u)){if(!K.isUndefined(y))return r(void 0,y)}else return r(void 0,u)}function c(y,u,S){if(K.hasOwnProp(n,S))return r(y,u);if(K.hasOwnProp(t,S))return r(void 0,y)}const x={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:(y,u,S)=>o(er(y),er(u),S,!0)};return K.forEach(Object.keys({...t,...n}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const S=K.hasOwnProp(x,u)?x[u]:o,j=K.hasOwnProp(t,u)?t[u]:void 0,w=K.hasOwnProp(n,u)?n[u]:void 0,m=S(j,w,u);K.isUndefined(m)&&S!==c||(a[u]=m)}),a}const Xi=t=>{const n=Wt({},t),a=j=>K.hasOwnProp(n,j)?n[j]:void 0,r=a("data");let o=a("withXSRFToken");const l=a("xsrfHeaderName"),d=a("xsrfCookieName");let c=a("headers");const x=a("auth"),y=a("baseURL"),u=a("allowAbsoluteUrls"),S=a("url");if(n.headers=c=nt.from(c),n.url=Hi(Qi(y,S,u),t.params,t.paramsSerializer),x&&c.set("Authorization","Basic "+btoa((x.username||"")+":"+(x.password?unescape(encodeURIComponent(x.password)):""))),K.isFormData(r)){if(Ke.hasStandardBrowserEnv||Ke.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(K.isFunction(r.getHeaders)){const j=r.getHeaders(),w=["content-type","content-length"];Object.entries(j).forEach(([m,h])=>{w.includes(m.toLowerCase())&&c.set(m,h)})}}if(Ke.hasStandardBrowserEnv&&(K.isFunction(o)&&(o=o(n)),o===!0||o==null&&Ql(n.url))){const w=l&&d&&Xl.read(d);w&&c.set(l,w)}return n},td=typeof XMLHttpRequest<"u",nd=td&&function(t){return new Promise(function(a,r){const o=Xi(t);let l=o.data;const d=nt.from(o.headers).normalize();let{responseType:c,onUploadProgress:x,onDownloadProgress:y}=o,u,S,j,w,m;function h(){w&&w(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function I(){if(!g)return;const D=nt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),f={data:!c||c==="text"||c==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:D,config:t,request:g};Ji(function(b){a(b),h()},function(b){r(b),h()},f),g=null}"onloadend"in g?g.onloadend=I:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(I)},g.onabort=function(){g&&(r(new _e("Request aborted",_e.ECONNABORTED,t,g)),g=null)},g.onerror=function(C){const f=C&&C.message?C.message:"Network Error",p=new _e(f,_e.ERR_NETWORK,t,g);p.event=C||null,r(p),g=null},g.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const f=o.transitional||Rs;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),r(new _e(C,f.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,t,g)),g=null},l===void 0&&d.setContentType(null),"setRequestHeader"in g&&K.forEach(d.toJSON(),function(C,f){g.setRequestHeader(f,C)}),K.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),c&&c!=="json"&&(g.responseType=o.responseType),y&&([j,m]=Ta(y,!0),g.addEventListener("progress",j)),x&&g.upload&&([S,w]=Ta(x),g.upload.addEventListener("progress",S),g.upload.addEventListener("loadend",w)),(o.cancelToken||o.signal)&&(u=D=>{g&&(r(!D||D.type?new Un(null,t,g):D),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const R=Kl(o.url);if(R&&Ke.protocols.indexOf(R)===-1){r(new _e("Unsupported protocol "+R+":",_e.ERR_BAD_REQUEST,t));return}g.send(l||null)})},ad=(t,n)=>{const{length:a}=t=t?t.filter(Boolean):[];if(n||a){let r=new AbortController,o;const l=function(y){if(!o){o=!0,c();const u=y instanceof Error?y:this.reason;r.abort(u instanceof _e?u:new Un(u instanceof Error?u.message:u))}};let d=n&&setTimeout(()=>{d=null,l(new _e(`timeout of ${n}ms exceeded`,_e.ETIMEDOUT))},n);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(y=>{y.unsubscribe?y.unsubscribe(l):y.removeEventListener("abort",l)}),t=null)};t.forEach(y=>y.addEventListener("abort",l));const{signal:x}=r;return x.unsubscribe=()=>K.asap(c),x}},sd=function*(t,n){let a=t.byteLength;if(a<n){yield t;return}let r=0,o;for(;r<a;)o=r+n,yield t.slice(r,o),r=o},rd=async function*(t,n){for await(const a of id(t))yield*sd(a,n)},id=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const n=t.getReader();try{for(;;){const{done:a,value:r}=await n.read();if(a)break;yield r}}finally{await n.cancel()}},tr=(t,n,a,r)=>{const o=rd(t,n);let l=0,d,c=x=>{d||(d=!0,r&&r(x))};return new ReadableStream({async pull(x){try{const{done:y,value:u}=await o.next();if(y){c(),x.close();return}let S=u.byteLength;if(a){let j=l+=S;a(j)}x.enqueue(new Uint8Array(u))}catch(y){throw c(y),y}},cancel(x){return c(x),o.return()}},{highWaterMark:2})},nr=64*1024,{isFunction:Vn}=K,od=(({Request:t,Response:n})=>({Request:t,Response:n}))(K.global),{ReadableStream:ar,TextEncoder:sr}=K.global,rr=(t,...n)=>{try{return!!t(...n)}catch{return!1}},ld=t=>{t=K.merge.call({skipUndefined:!0},od,t);const{fetch:n,Request:a,Response:r}=t,o=n?Vn(n):typeof fetch=="function",l=Vn(a),d=Vn(r);if(!o)return!1;const c=o&&Vn(ar),x=o&&(typeof sr=="function"?(m=>h=>m.encode(h))(new sr):async m=>new Uint8Array(await new a(m).arrayBuffer())),y=l&&c&&rr(()=>{let m=!1;const h=new a(Ke.origin,{body:new ar,method:"POST",get duplex(){return m=!0,"half"}}),g=h.headers.has("Content-Type");return h.body!=null&&h.body.cancel(),m&&!g}),u=d&&c&&rr(()=>K.isReadableStream(new r("").body)),S={stream:u&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!S[m]&&(S[m]=(h,g)=>{let I=h&&h[m];if(I)return I.call(h);throw new _e(`Response type '${m}' is not supported`,_e.ERR_NOT_SUPPORT,g)})});const j=async m=>{if(m==null)return 0;if(K.isBlob(m))return m.size;if(K.isSpecCompliantForm(m))return(await new a(Ke.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(K.isArrayBufferView(m)||K.isArrayBuffer(m))return m.byteLength;if(K.isURLSearchParams(m)&&(m=m+""),K.isString(m))return(await x(m)).byteLength},w=async(m,h)=>{const g=K.toFiniteNumber(m.getContentLength());return g??j(h)};return async m=>{let{url:h,method:g,data:I,signal:R,cancelToken:D,timeout:C,onDownloadProgress:f,onUploadProgress:p,responseType:b,headers:A,withCredentials:O="same-origin",fetchOptions:L}=Xi(m),U=n||fetch;b=b?(b+"").toLowerCase():"text";let v=ad([R,D&&D.toAbortSignal()],C),M=null;const P=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let N;try{if(p&&y&&g!=="get"&&g!=="head"&&(N=await w(A,I))!==0){let T=new a(h,{method:"POST",body:I,duplex:"half"}),$;if(K.isFormData(I)&&($=T.headers.get("content-type"))&&A.setContentType($),T.body){const[B,Y]=Xs(N,Ta(Zs(p)));I=tr(T.body,nr,B,Y)}}K.isString(O)||(O=O?"include":"omit");const E=l&&"credentials"in a.prototype;if(K.isFormData(I)){const T=A.getContentType();T&&/^multipart\/form-data/i.test(T)&&!/boundary=/i.test(T)&&A.delete("content-type")}const F={...L,signal:v,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:I,duplex:"half",credentials:E?O:void 0};M=l&&new a(h,F);let q=await(l?U(M,L):U(h,F));const z=u&&(b==="stream"||b==="response");if(u&&(f||z&&P)){const T={};["status","statusText","headers"].forEach(ne=>{T[ne]=q[ne]});const $=K.toFiniteNumber(q.headers.get("content-length")),[B,Y]=f&&Xs($,Ta(Zs(f),!0))||[];q=new r(tr(q.body,nr,B,()=>{Y&&Y(),P&&P()}),T)}b=b||"text";let k=await S[K.findKey(S,b)||"text"](q,m);return!z&&P&&P(),await new Promise((T,$)=>{Ji(T,$,{data:k,headers:nt.from(q.headers),status:q.status,statusText:q.statusText,config:m,request:M})})}catch(E){throw P&&P(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,m,M,E&&E.response),{cause:E.cause||E}):_e.from(E,E&&E.code,m,M,E&&E.response)}}},dd=new Map,Zi=t=>{let n=t&&t.env||{};const{fetch:a,Request:r,Response:o}=n,l=[r,o,a];let d=l.length,c=d,x,y,u=dd;for(;c--;)x=l[c],y=u.get(x),y===void 0&&u.set(x,y=c?new Map:ld(n)),u=y;return y};Zi();const Ds={http:_l,xhr:nd,fetch:{get:Zi}};K.forEach(Ds,(t,n)=>{if(t){try{Object.defineProperty(t,"name",{value:n})}catch{}Object.defineProperty(t,"adapterName",{value:n})}});const ir=t=>`- ${t}`,cd=t=>K.isFunction(t)||t===null||t===!1;function ud(t,n){t=K.isArray(t)?t:[t];const{length:a}=t;let r,o;const l={};for(let d=0;d<a;d++){r=t[d];let c;if(o=r,!cd(r)&&(o=Ds[(c=String(r)).toLowerCase()],o===void 0))throw new _e(`Unknown adapter '${c}'`);if(o&&(K.isFunction(o)||(o=o.get(n))))break;l[c||"#"+d]=o}if(!o){const d=Object.entries(l).map(([x,y])=>`adapter ${x} `+(y===!1?"is not supported by the environment":"is not available in the build"));let c=a?d.length>1?`since :
|
|
4
4
|
`+d.map(ir).join(`
|
|
5
|
-
`):" "+ir(d[0]):"as no adapter specified";throw new _e("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o}const eo={getAdapter:
|
|
5
|
+
`):" "+ir(d[0]):"as no adapter specified";throw new _e("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o}const eo={getAdapter:ud,adapters:Ds};function Ga(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Un(null,t)}function or(t){return Ga(t),t.headers=nt.from(t.headers),t.data=Ka.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),eo.getAdapter(t.adapter||$n.adapter,t)(t).then(function(r){return Ga(t),r.data=Ka.call(t,t.transformResponse,r),r.headers=nt.from(r.headers),r},function(r){return Gi(r)||(Ga(t),r&&r.response&&(r.response.data=Ka.call(t,t.transformResponse,r.response),r.response.headers=nt.from(r.response.headers))),Promise.reject(r)})}const to="1.15.2",Pa={};["object","boolean","number","function","string","symbol"].forEach((t,n)=>{Pa[t]=function(r){return typeof r===t||"a"+(n<1?"n ":" ")+t}});const lr={};Pa.transitional=function(n,a,r){function o(l,d){return"[Axios v"+to+"] Transitional option '"+l+"'"+d+(r?". "+r:"")}return(l,d,c)=>{if(n===!1)throw new _e(o(d," has been removed"+(a?" in "+a:"")),_e.ERR_DEPRECATED);return a&&!lr[d]&&(lr[d]=!0,console.warn(o(d," has been deprecated since v"+a+" and will be removed in the near future"))),n?n(l,d,c):!0}};Pa.spelling=function(n){return(a,r)=>(console.warn(`${r} is likely a misspelling of ${n}`),!0)};function pd(t,n,a){if(typeof t!="object")throw new _e("options must be an object",_e.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let o=r.length;for(;o-- >0;){const l=r[o],d=Object.prototype.hasOwnProperty.call(n,l)?n[l]:void 0;if(d){const c=t[l],x=c===void 0||d(c,l,t);if(x!==!0)throw new _e("option "+l+" must be "+x,_e.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new _e("Unknown option "+l,_e.ERR_BAD_OPTION)}}const pa={assertOptions:pd,validators:Pa},ut=pa.validators;let qt=class{constructor(n){this.defaults=n||{},this.interceptors={request:new Js,response:new Js}}async request(n,a){try{return await this._request(n,a)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const l=(()=>{if(!o.stack)return"";const d=o.stack.indexOf(`
|
|
6
6
|
`);return d===-1?"":o.stack.slice(d+1)})();try{if(!r.stack)r.stack=l;else if(l){const d=l.indexOf(`
|
|
7
7
|
`),c=d===-1?-1:l.indexOf(`
|
|
8
8
|
`,d+1),x=c===-1?"":l.slice(c+1);String(r.stack).endsWith(x)||(r.stack+=`
|
|
9
|
-
`+l)}}catch{}}throw r}}_request(n,a){typeof n=="string"?(a=a||{},a.url=n):a=n||{},a=Yt(this.defaults,a);const{transitional:r,paramsSerializer:o,headers:l}=a;r!==void 0&&ua.assertOptions(r,{silentJSONParsing:ct.transitional(ct.boolean),forcedJSONParsing:ct.transitional(ct.boolean),clarifyTimeoutError:ct.transitional(ct.boolean),legacyInterceptorReqResOrdering:ct.transitional(ct.boolean)},!1),o!=null&&(K.isFunction(o)?a.paramsSerializer={serialize:o}:ua.assertOptions(o,{encode:ct.function,serialize:ct.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),ua.assertOptions(a,{baseUrl:ct.spelling("baseURL"),withXsrfToken:ct.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let d=l&&K.merge(l.common,l[a.method]);l&&K.forEach(["delete","get","head","post","put","patch","common"],m=>{delete l[m]}),a.headers=tt.concat(d,l);const c=[];let x=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(a)===!1)return;x=x&&h.synchronous;const g=a.transitional||Rs;g&&g.legacyInterceptorReqResOrdering?c.unshift(h.fulfilled,h.rejected):c.push(h.fulfilled,h.rejected)});const y=[];this.interceptors.response.forEach(function(h){y.push(h.fulfilled,h.rejected)});let u,S=0,j;if(!x){const m=[or.bind(this),void 0];for(m.unshift(...c),m.push(...y),j=m.length,u=Promise.resolve(a);S<j;)u=u.then(m[S++],m[S++]);return u}j=c.length;let w=a;for(;S<j;){const m=c[S++],h=c[S++];try{w=m(w)}catch(g){h.call(this,g);break}}try{u=or.call(this,w)}catch(m){return Promise.reject(m)}for(S=0,j=y.length;S<j;)u=u.then(y[S++],y[S++]);return u}getUri(n){n=Yt(this.defaults,n);const a=Qi(n.baseURL,n.url,n.allowAbsoluteUrls);return Hi(a,n.params,n.paramsSerializer)}};K.forEach(["delete","get","head","options"],function(n){Lt.prototype[n]=function(a,r){return this.request(Yt(r||{},{method:n,url:a,data:(r||{}).data}))}});K.forEach(["post","put","patch"],function(n){function a(r){return function(l,d,c){return this.request(Yt(c||{},{method:n,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Lt.prototype[n]=a(),Lt.prototype[n+"Form"]=a(!0)});let yd=class no{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(l){a=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},n(function(l,d,c){r.reason||(r.reason=new $n(l,d,c),a(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const a=this._listeners.indexOf(n);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){const n=new AbortController,a=r=>{n.abort(r)};return this.subscribe(a),n.signal.unsubscribe=()=>this.unsubscribe(a),n.signal}static source(){let n;return{token:new no(function(o){n=o}),cancel:n}}};function fd(t){return function(a){return t.apply(null,a)}}function hd(t){return K.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,n])=>{ws[n]=t});function ao(t){const n=new Lt(t),a=Fi(Lt.prototype.request,n);return K.extend(a,Lt.prototype,n,{allOwnKeys:!0}),K.extend(a,n,null,{allOwnKeys:!0}),a.create=function(o){return ao(Yt(t,o))},a}const $e=ao(Nn);$e.Axios=Lt;$e.CanceledError=$n;$e.CancelToken=yd;$e.isCancel=Gi;$e.VERSION=to;$e.toFormData=ka;$e.AxiosError=_e;$e.Cancel=$e.CanceledError;$e.all=function(n){return Promise.all(n)};$e.spread=fd;$e.isAxiosError=hd;$e.mergeConfig=Yt;$e.AxiosHeaders=tt;$e.formToJSON=t=>Ki(K.isHTMLForm(t)?new FormData(t):t);$e.getAdapter=eo.getAdapter;$e.HttpStatusCode=ws;$e.default=$e;const{Axios:th,AxiosError:nh,CanceledError:ah,isCancel:sh,CancelToken:rh,VERSION:ih,all:oh,Cancel:lh,isAxiosError:dh,spread:ch,toFormData:uh,AxiosHeaders:ph,HttpStatusCode:mh,formToJSON:yh,getAdapter:fh,mergeConfig:hh}=$e,gd=()=>new Promise(t=>setTimeout(()=>t(),800));let Cs=null;const xd=t=>{Cs=t,xt.defaults.baseURL=ks()},ks=()=>Cs||"https://npmapi.ubkerp.com/",xt=$e.create({baseURL:ks()}),nt=()=>ks(),Ye=async(t,n,a)=>{const r=await xt.post(t,n,{headers:{Authorization:a}});if(console.log("ddddfdfdfd",r.data?.Status),r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},Q=async(t,n)=>{try{let r=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";r=`${t}${l}session_id=1`}return(await xt.get(r,{headers:{Authorization:n}})).data}catch(a){throw a.response?.status===401&&console.error("401 Unauthorized"),a}},bd=async(t,n)=>{const a=await xt.post(t,"",{headers:{Authorization:n}});if(a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},Pa=async(t,n,a)=>{try{const r=await xt.post(t,n,{headers:{Authorization:a,"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}},kn=async(t,n,a)=>{const r=n?.arg;return(await xt.post(t,r,{headers:{Authorization:a}}))?.data},qt=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?";return(await xt.get(t+o,{params:r,headers:{Authorization:a}}))?.data},Sd="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Os=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?",l=await xt.get(t+o,{params:r,headers:{Authorization:a}});if(console.log("ddddfdfdfd",l.data?.Status),l.data?.Status=="Success")return l?.data?.data||l?.data;throw new Error(l.data?.msg)},pt=async(t,n,a)=>(await gd(),(await xt.post(t,n,{headers:{Authorization:a}}))?.data),at=async(t,n,a)=>(await xt.delete(`${t}/${n}`,{headers:{Authorization:a}})).data,jd="api/report/LibraryRenewalReport/renewalHistory",vd="api/report/LibraryRenewalReport/renewalFineReport",_d="api/report/LibraryRenewalReport/currentlyRenewedBooks",wd="api/report/LibraryRenewalReport/upcomingRenewalDue",Cd="api/report/LibraryRenewalReport/overdueRenewalReport",Ad="api/report/LibraryRenewalReport/renewalLimitReport",Td="api/report/LibraryRenewalReport/renewalStatusReport",Rd="api/report/LibraryRenewalReport/studentWiseReport",Id="api/report/LibraryRenewalReport/bookWiseReport",Dd="api/report/LibraryRenewalReport/classWiseReport",kd="api/report/LibraryRenewalReport/staffWiseReport",Od="api/report/LibraryRenewalReport/renewalStatisticsByDate",Pd=({token:t,menu:n})=>{const{isLoading:a,data:r}=G(t?["api/sdk/Menus",t]:null,([l,d])=>bd(l,d)),o=r?.find(l=>l.path===n)?.sub_menu??[];return console.log("menuData",r),e.jsx(s.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(s.Col,{xs:24,md:8,lg:8,children:e.jsx(de,{children:e.jsx(Mi,{icon:`${nt()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function so(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qe={},Ja,dr;function Ed(){return dr||(dr=1,Ja=function t(n,a){if(n===a)return!0;if(n&&a&&typeof n=="object"&&typeof a=="object"){if(n.constructor!==a.constructor)return!1;var r,o,l;if(Array.isArray(n)){if(r=n.length,r!=a.length)return!1;for(o=r;o--!==0;)if(!t(n[o],a[o]))return!1;return!0}if(n.constructor===RegExp)return n.source===a.source&&n.flags===a.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===a.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===a.toString();if(l=Object.keys(n),r=l.length,r!==Object.keys(a).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(a,l[o]))return!1;for(o=r;o--!==0;){var d=l[o];if(!t(n[d],a[d]))return!1}return!0}return n!==n&&a!==a}),Ja}var Vn={exports:{}},Hn={exports:{}},Ie={};var cr;function Md(){if(cr)return Ie;cr=1;var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,a=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,x=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,S=t?Symbol.for("react.suspense"):60113,j=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,h=t?Symbol.for("react.block"):60121,g=t?Symbol.for("react.fundamental"):60117,I=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function D(f){if(typeof f=="object"&&f!==null){var p=f.$$typeof;switch(p){case n:switch(f=f.type,f){case x:case y:case r:case l:case o:case S:return f;default:switch(f=f&&f.$$typeof,f){case c:case u:case m:case w:case d:return f;default:return p}}case a:return p}}}function C(f){return D(f)===y}return Ie.AsyncMode=x,Ie.ConcurrentMode=y,Ie.ContextConsumer=c,Ie.ContextProvider=d,Ie.Element=n,Ie.ForwardRef=u,Ie.Fragment=r,Ie.Lazy=m,Ie.Memo=w,Ie.Portal=a,Ie.Profiler=l,Ie.StrictMode=o,Ie.Suspense=S,Ie.isAsyncMode=function(f){return C(f)||D(f)===x},Ie.isConcurrentMode=C,Ie.isContextConsumer=function(f){return D(f)===c},Ie.isContextProvider=function(f){return D(f)===d},Ie.isElement=function(f){return typeof f=="object"&&f!==null&&f.$$typeof===n},Ie.isForwardRef=function(f){return D(f)===u},Ie.isFragment=function(f){return D(f)===r},Ie.isLazy=function(f){return D(f)===m},Ie.isMemo=function(f){return D(f)===w},Ie.isPortal=function(f){return D(f)===a},Ie.isProfiler=function(f){return D(f)===l},Ie.isStrictMode=function(f){return D(f)===o},Ie.isSuspense=function(f){return D(f)===S},Ie.isValidElementType=function(f){return typeof f=="string"||typeof f=="function"||f===r||f===y||f===l||f===o||f===S||f===j||typeof f=="object"&&f!==null&&(f.$$typeof===m||f.$$typeof===w||f.$$typeof===d||f.$$typeof===c||f.$$typeof===u||f.$$typeof===g||f.$$typeof===I||f.$$typeof===R||f.$$typeof===h)},Ie.typeOf=D,Ie}var De={};var ur;function Fd(){return ur||(ur=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,a=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,x=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,S=t?Symbol.for("react.suspense"):60113,j=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,h=t?Symbol.for("react.block"):60121,g=t?Symbol.for("react.fundamental"):60117,I=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function D(re){return typeof re=="string"||typeof re=="function"||re===r||re===y||re===l||re===o||re===S||re===j||typeof re=="object"&&re!==null&&(re.$$typeof===m||re.$$typeof===w||re.$$typeof===d||re.$$typeof===c||re.$$typeof===u||re.$$typeof===g||re.$$typeof===I||re.$$typeof===R||re.$$typeof===h)}function C(re){if(typeof re=="object"&&re!==null){var ie=re.$$typeof;switch(ie){case n:var V=re.type;switch(V){case x:case y:case r:case l:case o:case S:return V;default:var oe=V&&V.$$typeof;switch(oe){case c:case u:case m:case w:case d:return oe;default:return ie}}case a:return ie}}}var f=x,p=y,b=c,A=d,O=n,L=u,U=r,v=m,M=w,P=a,N=l,E=o,F=S,q=!1;function z(re){return q||(q=!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.")),k(re)||C(re)===x}function k(re){return C(re)===y}function T(re){return C(re)===c}function $(re){return C(re)===d}function B(re){return typeof re=="object"&&re!==null&&re.$$typeof===n}function Y(re){return C(re)===u}function ne(re){return C(re)===r}function H(re){return C(re)===m}function W(re){return C(re)===w}function Z(re){return C(re)===a}function se(re){return C(re)===l}function pe(re){return C(re)===o}function ve(re){return C(re)===S}De.AsyncMode=f,De.ConcurrentMode=p,De.ContextConsumer=b,De.ContextProvider=A,De.Element=O,De.ForwardRef=L,De.Fragment=U,De.Lazy=v,De.Memo=M,De.Portal=P,De.Profiler=N,De.StrictMode=E,De.Suspense=F,De.isAsyncMode=z,De.isConcurrentMode=k,De.isContextConsumer=T,De.isContextProvider=$,De.isElement=B,De.isForwardRef=Y,De.isFragment=ne,De.isLazy=H,De.isMemo=W,De.isPortal=Z,De.isProfiler=se,De.isStrictMode=pe,De.isSuspense=ve,De.isValidElementType=D,De.typeOf=C})()),De}var pr;function ro(){return pr||(pr=1,process.env.NODE_ENV==="production"?Hn.exports=Md():Hn.exports=Fd()),Hn.exports}var Qa,mr;function Nd(){if(mr)return Qa;mr=1;var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=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 x=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(x.join("")!=="0123456789")return!1;var y={};return"abcdefghijklmnopqrst".split("").forEach(function(u){y[u]=u}),Object.keys(Object.assign({},y)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Qa=o()?Object.assign:function(l,d){for(var c,x=r(l),y,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var S in c)n.call(c,S)&&(x[S]=c[S]);if(t){y=t(c);for(var j=0;j<y.length;j++)a.call(c,y[j])&&(x[y[j]]=c[y[j]])}}return x},Qa}var Xa,yr;function Ps(){if(yr)return Xa;yr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Xa=t,Xa}var Za,fr;function io(){return fr||(fr=1,Za=Function.call.bind(Object.prototype.hasOwnProperty)),Za}var es,hr;function $d(){if(hr)return es;hr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=Ps(),a={},r=io();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,x,y){if(process.env.NODE_ENV!=="production"){for(var u in l)if(r(l,u)){var S;try{if(typeof l[u]!="function"){var j=Error((x||"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 j.name="Invariant Violation",j}S=l[u](d,u,x,c,null,n)}catch(m){S=m}if(S&&!(S instanceof Error)&&t((x||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof S+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),S instanceof Error&&!(S.message in a)){a[S.message]=!0;var w=y?y():"";t("Failed "+c+" type: "+S.message+(w??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(a={})},es=o,es}var ts,gr;function Ud(){if(gr)return ts;gr=1;var t=ro(),n=Nd(),a=Ps(),r=io(),o=$d(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var x="Warning: "+c;typeof console<"u"&&console.error(x);try{throw new Error(x)}catch{}});function d(){return null}return ts=function(c,x){var y=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function S(k){var T=k&&(y&&k[y]||k[u]);if(typeof T=="function")return T}var j="<<anonymous>>",w={array:I("array"),bigint:I("bigint"),bool:I("boolean"),func:I("function"),number:I("number"),object:I("object"),string:I("string"),symbol:I("symbol"),any:R(),arrayOf:D,element:C(),elementType:f(),instanceOf:p,node:L(),objectOf:A,oneOf:b,oneOfType:O,shape:v,exact:M};function m(k,T){return k===T?k!==0||1/k===1/T:k!==k&&T!==T}function h(k,T){this.message=k,this.data=T&&typeof T=="object"?T:{},this.stack=""}h.prototype=Error.prototype;function g(k){if(process.env.NODE_ENV!=="production")var T={},$=0;function B(ne,H,W,Z,se,pe,ve){if(Z=Z||j,pe=pe||W,ve!==a){if(x){var re=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 re.name="Invariant Violation",re}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ie=Z+":"+W;!T[ie]&&$<3&&(l("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+Z+"`. 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."),T[ie]=!0,$++)}}return H[W]==null?ne?H[W]===null?new h("The "+se+" `"+pe+"` is marked as required "+("in `"+Z+"`, but its value is `null`.")):new h("The "+se+" `"+pe+"` is marked as required in "+("`"+Z+"`, but its value is `undefined`.")):null:k(H,W,Z,se,pe)}var Y=B.bind(null,!1);return Y.isRequired=B.bind(null,!0),Y}function I(k){function T($,B,Y,ne,H,W){var Z=$[B],se=E(Z);if(se!==k){var pe=F(Z);return new h("Invalid "+ne+" `"+H+"` of type "+("`"+pe+"` supplied to `"+Y+"`, expected ")+("`"+k+"`."),{expectedType:k})}return null}return g(T)}function R(){return g(d)}function D(k){function T($,B,Y,ne,H){if(typeof k!="function")return new h("Property `"+H+"` of component `"+Y+"` has invalid PropType notation inside arrayOf.");var W=$[B];if(!Array.isArray(W)){var Z=E(W);return new h("Invalid "+ne+" `"+H+"` of type "+("`"+Z+"` supplied to `"+Y+"`, expected an array."))}for(var se=0;se<W.length;se++){var pe=k(W,se,Y,ne,H+"["+se+"]",a);if(pe instanceof Error)return pe}return null}return g(T)}function C(){function k(T,$,B,Y,ne){var H=T[$];if(!c(H)){var W=E(H);return new h("Invalid "+Y+" `"+ne+"` of type "+("`"+W+"` supplied to `"+B+"`, expected a single ReactElement."))}return null}return g(k)}function f(){function k(T,$,B,Y,ne){var H=T[$];if(!t.isValidElementType(H)){var W=E(H);return new h("Invalid "+Y+" `"+ne+"` of type "+("`"+W+"` supplied to `"+B+"`, expected a single ReactElement type."))}return null}return g(k)}function p(k){function T($,B,Y,ne,H){if(!($[B]instanceof k)){var W=k.name||j,Z=z($[B]);return new h("Invalid "+ne+" `"+H+"` of type "+("`"+Z+"` supplied to `"+Y+"`, expected ")+("instance of `"+W+"`."))}return null}return g(T)}function b(k){if(!Array.isArray(k))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 T($,B,Y,ne,H){for(var W=$[B],Z=0;Z<k.length;Z++)if(m(W,k[Z]))return null;var se=JSON.stringify(k,function(ve,re){var ie=F(re);return ie==="symbol"?String(re):re});return new h("Invalid "+ne+" `"+H+"` of value `"+String(W)+"` "+("supplied to `"+Y+"`, expected one of "+se+"."))}return g(T)}function A(k){function T($,B,Y,ne,H){if(typeof k!="function")return new h("Property `"+H+"` of component `"+Y+"` has invalid PropType notation inside objectOf.");var W=$[B],Z=E(W);if(Z!=="object")return new h("Invalid "+ne+" `"+H+"` of type "+("`"+Z+"` supplied to `"+Y+"`, expected an object."));for(var se in W)if(r(W,se)){var pe=k(W,se,Y,ne,H+"."+se,a);if(pe instanceof Error)return pe}return null}return g(T)}function O(k){if(!Array.isArray(k))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var T=0;T<k.length;T++){var $=k[T];if(typeof $!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+q($)+" at index "+T+"."),d}function B(Y,ne,H,W,Z){for(var se=[],pe=0;pe<k.length;pe++){var ve=k[pe],re=ve(Y,ne,H,W,Z,a);if(re==null)return null;re.data&&r(re.data,"expectedType")&&se.push(re.data.expectedType)}var ie=se.length>0?", expected one of type ["+se.join(", ")+"]":"";return new h("Invalid "+W+" `"+Z+"` supplied to "+("`"+H+"`"+ie+"."))}return g(B)}function L(){function k(T,$,B,Y,ne){return P(T[$])?null:new h("Invalid "+Y+" `"+ne+"` supplied to "+("`"+B+"`, expected a ReactNode."))}return g(k)}function U(k,T,$,B,Y){return new h((k||"React class")+": "+T+" type `"+$+"."+B+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Y+"`.")}function v(k){function T($,B,Y,ne,H){var W=$[B],Z=E(W);if(Z!=="object")return new h("Invalid "+ne+" `"+H+"` of type `"+Z+"` "+("supplied to `"+Y+"`, expected `object`."));for(var se in k){var pe=k[se];if(typeof pe!="function")return U(Y,ne,H,se,F(pe));var ve=pe(W,se,Y,ne,H+"."+se,a);if(ve)return ve}return null}return g(T)}function M(k){function T($,B,Y,ne,H){var W=$[B],Z=E(W);if(Z!=="object")return new h("Invalid "+ne+" `"+H+"` of type `"+Z+"` "+("supplied to `"+Y+"`, expected `object`."));var se=n({},$[B],k);for(var pe in se){var ve=k[pe];if(r(k,pe)&&typeof ve!="function")return U(Y,ne,H,pe,F(ve));if(!ve)return new h("Invalid "+ne+" `"+H+"` key `"+pe+"` supplied to `"+Y+"`.\nBad object: "+JSON.stringify($[B],null," ")+`
|
|
10
|
-
Valid keys: `+JSON.stringify(Object.keys(k),null," "));var re=ve(W,pe,Y,ne,H+"."+pe,a);if(re)return re}return null}return g(T)}function P(k){switch(typeof k){case"number":case"string":case"undefined":return!0;case"boolean":return!k;case"object":if(Array.isArray(k))return k.every(P);if(k===null||c(k))return!0;var T=S(k);if(T){var $=T.call(k),B;if(T!==k.entries){for(;!(B=$.next()).done;)if(!P(B.value))return!1}else for(;!(B=$.next()).done;){var Y=B.value;if(Y&&!P(Y[1]))return!1}}else return!1;return!0;default:return!1}}function N(k,T){return k==="symbol"?!0:T?T["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&T instanceof Symbol:!1}function E(k){var T=typeof k;return Array.isArray(k)?"array":k instanceof RegExp?"object":N(T,k)?"symbol":T}function F(k){if(typeof k>"u"||k===null)return""+k;var T=E(k);if(T==="object"){if(k instanceof Date)return"date";if(k instanceof RegExp)return"regexp"}return T}function q(k){var T=F(k);switch(T){case"array":case"object":return"an "+T;case"boolean":case"date":case"regexp":return"a "+T;default:return T}}function z(k){return!k.constructor||!k.constructor.name?j:k.constructor.name}return w.checkPropTypes=o,w.resetWarningCache=o.resetWarningCache,w.PropTypes=w,w},ts}var ns,xr;function Bd(){if(xr)return ns;xr=1;var t=Ps();function n(){}function a(){}return a.resetWarningCache=n,ns=function(){function r(d,c,x,y,u,S){if(S!==t){var j=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 j.name="Invariant Violation",j}}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:a,resetWarningCache:n};return l.PropTypes=l,l},ns}var br;function oo(){if(br)return Vn.exports;if(br=1,process.env.NODE_ENV!=="production"){var t=ro(),n=!0;Vn.exports=Ud()(t.isElement,n)}else Vn.exports=Bd()();return Vn.exports}var Sr;function Ld(){if(Sr)return qe;Sr=1;var t=qe&&qe.__extends||(function(){var w=function(m,h){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,I){g.__proto__=I}||function(g,I){for(var R in I)Object.prototype.hasOwnProperty.call(I,R)&&(g[R]=I[R])},w(m,h)};return function(m,h){if(typeof h!="function"&&h!==null)throw new TypeError("Class extends value "+String(h)+" is not a constructor or null");w(m,h);function g(){this.constructor=m}m.prototype=h===null?Object.create(h):(g.prototype=h.prototype,new g)}})(),n=qe&&qe.__assign||function(){return n=Object.assign||function(w){for(var m,h=1,g=arguments.length;h<g;h++){m=arguments[h];for(var I in m)Object.prototype.hasOwnProperty.call(m,I)&&(w[I]=m[I])}return w},n.apply(this,arguments)},a=qe&&qe.__createBinding||(Object.create?(function(w,m,h,g){g===void 0&&(g=h);var I=Object.getOwnPropertyDescriptor(m,h);(!I||("get"in I?!m.__esModule:I.writable||I.configurable))&&(I={enumerable:!0,get:function(){return m[h]}}),Object.defineProperty(w,g,I)}):(function(w,m,h,g){g===void 0&&(g=h),w[g]=m[h]})),r=qe&&qe.__setModuleDefault||(Object.create?(function(w,m){Object.defineProperty(w,"default",{enumerable:!0,value:m})}):function(w,m){w.default=m}),o=qe&&qe.__importStar||function(w){if(w&&w.__esModule)return w;var m={};if(w!=null)for(var h in w)h!=="default"&&Object.prototype.hasOwnProperty.call(w,h)&&a(m,w,h);return r(m,w),m},l=qe&&qe.__rest||function(w,m){var h={};for(var g in w)Object.prototype.hasOwnProperty.call(w,g)&&m.indexOf(g)<0&&(h[g]=w[g]);if(w!=null&&typeof Object.getOwnPropertySymbols=="function")for(var I=0,g=Object.getOwnPropertySymbols(w);I<g.length;I++)m.indexOf(g[I])<0&&Object.prototype.propertyIsEnumerable.call(w,g[I])&&(h[g[I]]=w[g[I]]);return h},d=qe&&qe.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(qe,"__esModule",{value:!0});var c=o(i),x=d(Ed()),y=o(oo());function u(w){return w&&w.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function S(w){var m=document.createTextNode("");w.appendChild(m);var h=document.activeElement===w;if(m!==null&&m.nodeValue!==null&&h){var g=window.getSelection();if(g!==null){var I=document.createRange();I.setStart(m,m.nodeValue.length),I.collapse(!0),g.removeAllRanges(),g.addRange(I)}w instanceof HTMLElement&&w.focus()}}var j=(function(w){t(m,w);function m(){var h=w!==null&&w.apply(this,arguments)||this;return h.lastHtml=h.props.html,h.el=typeof h.props.innerRef=="function"?{current:null}:c.createRef(),h.getEl=function(){return(h.props.innerRef&&typeof h.props.innerRef!="function"?h.props.innerRef:h.el).current},h.emitChange=function(g){var I=h.getEl();if(I){var R=I.innerHTML;if(h.props.onChange&&R!==h.lastHtml){var D=Object.assign({},g,{target:{value:R}});h.props.onChange(D)}h.lastHtml=R}},h}return m.prototype.render=function(){var h=this,g=this.props,I=g.tagName,R=g.html,D=g.innerRef,C=l(g,["tagName","html","innerRef"]);return c.createElement(I||"div",n(n({},C),{ref:typeof D=="function"?function(f){D(f),h.el.current=f}:D||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)},m.prototype.shouldComponentUpdate=function(h){var g=this.props,I=this.getEl();return!I||u(h.html)!==u(I.innerHTML)?!0:g.disabled!==h.disabled||g.tagName!==h.tagName||g.className!==h.className||g.innerRef!==h.innerRef||g.placeholder!==h.placeholder||!(0,x.default)(g.style,h.style)},m.prototype.componentDidUpdate=function(){var h=this.getEl();h&&(this.props.html!==h.innerHTML&&(h.innerHTML=this.props.html),this.lastHtml=this.props.html,S(h))},m.propTypes={html:y.string.isRequired,onChange:y.func,disabled:y.bool,tagName:y.string,className:y.string,style:y.object,innerRef:y.oneOfType([y.object,y.func])},m})(c.Component);return qe.default=j,qe}var qd=Ld();const lo=so(qd),zd={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Yd={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"},J=i.forwardRef(({style:t,onFocus:n,onBlur:a,...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:zd,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:o,onFocus:c=>{d(!0),n?.(c)},onBlur:c=>{d(!1),a?.(c)},style:{...Yd,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),jr=[{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 Es(t){const n=ae().year(),a=[];for(let r=n;r>=n-t;r--)a.push({label:String(r),value:r});return a}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 Ms(t){const n=ae().year(),a=ae().month();return t<n?jr:jr.slice(0,a+1)}function vr(t,n){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:n});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:n});default:return e.jsx("span",{className:"monthlyLabel",children:n})}}function Wd(){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 co=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(s.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(s.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(s.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""}},ht=t=>{const n=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[n?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var yn={},fn={},it={},hn={},Jt={},_r;function Vd(){if(_r)return Jt;_r=1;var t=Jt&&Jt.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Jt,"__esModule",{value:!0});const n=t(i),a=Eo,r=["string","number","boolean"];function o({header:l,body:d}){const c=n.default.createElement("tr",null,l.map(y=>n.default.createElement("th",{key:y},y))),x=d.map((y,u)=>Array.isArray(y)?n.default.createElement("tr",{key:u},y.map((S,j)=>n.default.createElement("th",{key:j}," ",S," "))):y!==null&&typeof y=="object"?n.default.createElement("tr",{key:u},Object.entries(y).map(([S,j],w)=>typeof j=="object"?(console.error(`typeof ${S} is incorrect, only accept ${r.join(", ")} `),n.default.createElement("th",{key:w})):n.default.createElement("th",{key:w},n.default.createElement(n.default.Fragment,null,j)))):(console.error(`
|
|
9
|
+
`+l)}}catch{}}throw r}}_request(n,a){typeof n=="string"?(a=a||{},a.url=n):a=n||{},a=Wt(this.defaults,a);const{transitional:r,paramsSerializer:o,headers:l}=a;r!==void 0&&pa.assertOptions(r,{silentJSONParsing:ut.transitional(ut.boolean),forcedJSONParsing:ut.transitional(ut.boolean),clarifyTimeoutError:ut.transitional(ut.boolean),legacyInterceptorReqResOrdering:ut.transitional(ut.boolean)},!1),o!=null&&(K.isFunction(o)?a.paramsSerializer={serialize:o}:pa.assertOptions(o,{encode:ut.function,serialize:ut.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),pa.assertOptions(a,{baseUrl:ut.spelling("baseURL"),withXsrfToken:ut.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let d=l&&K.merge(l.common,l[a.method]);l&&K.forEach(["delete","get","head","post","put","patch","common"],m=>{delete l[m]}),a.headers=nt.concat(d,l);const c=[];let x=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(a)===!1)return;x=x&&h.synchronous;const g=a.transitional||Rs;g&&g.legacyInterceptorReqResOrdering?c.unshift(h.fulfilled,h.rejected):c.push(h.fulfilled,h.rejected)});const y=[];this.interceptors.response.forEach(function(h){y.push(h.fulfilled,h.rejected)});let u,S=0,j;if(!x){const m=[or.bind(this),void 0];for(m.unshift(...c),m.push(...y),j=m.length,u=Promise.resolve(a);S<j;)u=u.then(m[S++],m[S++]);return u}j=c.length;let w=a;for(;S<j;){const m=c[S++],h=c[S++];try{w=m(w)}catch(g){h.call(this,g);break}}try{u=or.call(this,w)}catch(m){return Promise.reject(m)}for(S=0,j=y.length;S<j;)u=u.then(y[S++],y[S++]);return u}getUri(n){n=Wt(this.defaults,n);const a=Qi(n.baseURL,n.url,n.allowAbsoluteUrls);return Hi(a,n.params,n.paramsSerializer)}};K.forEach(["delete","get","head","options"],function(n){qt.prototype[n]=function(a,r){return this.request(Wt(r||{},{method:n,url:a,data:(r||{}).data}))}});K.forEach(["post","put","patch"],function(n){function a(r){return function(l,d,c){return this.request(Wt(c||{},{method:n,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}qt.prototype[n]=a(),qt.prototype[n+"Form"]=a(!0)});let md=class no{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(l){a=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},n(function(l,d,c){r.reason||(r.reason=new Un(l,d,c),a(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const a=this._listeners.indexOf(n);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){const n=new AbortController,a=r=>{n.abort(r)};return this.subscribe(a),n.signal.unsubscribe=()=>this.unsubscribe(a),n.signal}static source(){let n;return{token:new no(function(o){n=o}),cancel:n}}};function yd(t){return function(a){return t.apply(null,a)}}function fd(t){return K.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,n])=>{ws[n]=t});function ao(t){const n=new qt(t),a=Fi(qt.prototype.request,n);return K.extend(a,qt.prototype,n,{allOwnKeys:!0}),K.extend(a,n,null,{allOwnKeys:!0}),a.create=function(o){return ao(Wt(t,o))},a}const Ne=ao($n);Ne.Axios=qt;Ne.CanceledError=Un;Ne.CancelToken=md;Ne.isCancel=Gi;Ne.VERSION=to;Ne.toFormData=Oa;Ne.AxiosError=_e;Ne.Cancel=Ne.CanceledError;Ne.all=function(n){return Promise.all(n)};Ne.spread=yd;Ne.isAxiosError=fd;Ne.mergeConfig=Wt;Ne.AxiosHeaders=nt;Ne.formToJSON=t=>Ki(K.isHTMLForm(t)?new FormData(t):t);Ne.getAdapter=eo.getAdapter;Ne.HttpStatusCode=ws;Ne.default=Ne;const{Axios:eh,AxiosError:th,CanceledError:nh,isCancel:ah,CancelToken:sh,VERSION:rh,all:ih,Cancel:oh,isAxiosError:lh,spread:dh,toFormData:ch,AxiosHeaders:uh,HttpStatusCode:ph,formToJSON:mh,getAdapter:yh,mergeConfig:fh}=Ne,hd=()=>new Promise(t=>setTimeout(()=>t(),800));let Cs=null;const gd=t=>{Cs=t,bt.defaults.baseURL=ks()},ks=()=>Cs||"https://npmapi.ubkerp.com/",bt=Ne.create({baseURL:ks()}),at=()=>ks(),Ye=async(t,n,a)=>{const r=await bt.post(t,n,{headers:{Authorization:a}});if(console.log("ddddfdfdfd",r.data?.Status),r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},Q=async(t,n)=>{try{let r=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";r=`${t}${l}session_id=1`}return(await bt.get(r,{headers:{Authorization:n}})).data}catch(a){throw a.response?.status===401&&console.error("401 Unauthorized"),a}},xd=async(t,n)=>{const a=await bt.post(t,"",{headers:{Authorization:n}});if(a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},Ea=async(t,n,a)=>{try{const r=await bt.post(t,n,{headers:{Authorization:a,"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}},On=async(t,n,a)=>{const r=n?.arg;return(await bt.post(t,r,{headers:{Authorization:a}}))?.data},zt=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?";return(await bt.get(t+o,{params:r,headers:{Authorization:a}}))?.data},bd="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Os=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?",l=await bt.get(t+o,{params:r,headers:{Authorization:a}});if(console.log("ddddfdfdfd",l.data?.Status),l.data?.Status=="Success")return l?.data?.data||l?.data;throw new Error(l.data?.msg)},mt=async(t,n,a)=>(await hd(),(await bt.post(t,n,{headers:{Authorization:a}}))?.data),st=async(t,n,a)=>(await bt.delete(`${t}/${n}`,{headers:{Authorization:a}})).data,Sd="api/report/LibraryRenewalReport/renewalHistory",jd="api/report/LibraryRenewalReport/renewalFineReport",vd="api/report/LibraryRenewalReport/currentlyRenewedBooks",_d="api/report/LibraryRenewalReport/upcomingRenewalDue",wd="api/report/LibraryRenewalReport/overdueRenewalReport",Cd="api/report/LibraryRenewalReport/renewalLimitReport",Ad="api/report/LibraryRenewalReport/renewalStatusReport",Td="api/report/LibraryRenewalReport/studentWiseReport",Rd="api/report/LibraryRenewalReport/bookWiseReport",Id="api/report/LibraryRenewalReport/classWiseReport",Dd="api/report/LibraryRenewalReport/staffWiseReport",kd="api/report/LibraryRenewalReport/renewalStatisticsByDate",Od=({token:t,menu:n})=>{const{isLoading:a,data:r}=G(t?["api/sdk/Menus",t]:null,([l,d])=>xd(l,d)),o=r?.find(l=>l.path===n)?.sub_menu??[];return console.log("menuData",r),e.jsx(s.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(s.Col,{xs:24,md:8,lg:8,children:e.jsx(le,{children:e.jsx(Mi,{icon:`${at()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function so(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qe={},Ja,dr;function Pd(){return dr||(dr=1,Ja=function t(n,a){if(n===a)return!0;if(n&&a&&typeof n=="object"&&typeof a=="object"){if(n.constructor!==a.constructor)return!1;var r,o,l;if(Array.isArray(n)){if(r=n.length,r!=a.length)return!1;for(o=r;o--!==0;)if(!t(n[o],a[o]))return!1;return!0}if(n.constructor===RegExp)return n.source===a.source&&n.flags===a.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===a.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===a.toString();if(l=Object.keys(n),r=l.length,r!==Object.keys(a).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(a,l[o]))return!1;for(o=r;o--!==0;){var d=l[o];if(!t(n[d],a[d]))return!1}return!0}return n!==n&&a!==a}),Ja}var Hn={exports:{}},Kn={exports:{}},Ie={};var cr;function Ed(){if(cr)return Ie;cr=1;var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,a=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,x=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,S=t?Symbol.for("react.suspense"):60113,j=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,h=t?Symbol.for("react.block"):60121,g=t?Symbol.for("react.fundamental"):60117,I=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function D(f){if(typeof f=="object"&&f!==null){var p=f.$$typeof;switch(p){case n:switch(f=f.type,f){case x:case y:case r:case l:case o:case S:return f;default:switch(f=f&&f.$$typeof,f){case c:case u:case m:case w:case d:return f;default:return p}}case a:return p}}}function C(f){return D(f)===y}return Ie.AsyncMode=x,Ie.ConcurrentMode=y,Ie.ContextConsumer=c,Ie.ContextProvider=d,Ie.Element=n,Ie.ForwardRef=u,Ie.Fragment=r,Ie.Lazy=m,Ie.Memo=w,Ie.Portal=a,Ie.Profiler=l,Ie.StrictMode=o,Ie.Suspense=S,Ie.isAsyncMode=function(f){return C(f)||D(f)===x},Ie.isConcurrentMode=C,Ie.isContextConsumer=function(f){return D(f)===c},Ie.isContextProvider=function(f){return D(f)===d},Ie.isElement=function(f){return typeof f=="object"&&f!==null&&f.$$typeof===n},Ie.isForwardRef=function(f){return D(f)===u},Ie.isFragment=function(f){return D(f)===r},Ie.isLazy=function(f){return D(f)===m},Ie.isMemo=function(f){return D(f)===w},Ie.isPortal=function(f){return D(f)===a},Ie.isProfiler=function(f){return D(f)===l},Ie.isStrictMode=function(f){return D(f)===o},Ie.isSuspense=function(f){return D(f)===S},Ie.isValidElementType=function(f){return typeof f=="string"||typeof f=="function"||f===r||f===y||f===l||f===o||f===S||f===j||typeof f=="object"&&f!==null&&(f.$$typeof===m||f.$$typeof===w||f.$$typeof===d||f.$$typeof===c||f.$$typeof===u||f.$$typeof===g||f.$$typeof===I||f.$$typeof===R||f.$$typeof===h)},Ie.typeOf=D,Ie}var De={};var ur;function Md(){return ur||(ur=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,a=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,x=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,S=t?Symbol.for("react.suspense"):60113,j=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,h=t?Symbol.for("react.block"):60121,g=t?Symbol.for("react.fundamental"):60117,I=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function D(re){return typeof re=="string"||typeof re=="function"||re===r||re===y||re===l||re===o||re===S||re===j||typeof re=="object"&&re!==null&&(re.$$typeof===m||re.$$typeof===w||re.$$typeof===d||re.$$typeof===c||re.$$typeof===u||re.$$typeof===g||re.$$typeof===I||re.$$typeof===R||re.$$typeof===h)}function C(re){if(typeof re=="object"&&re!==null){var ie=re.$$typeof;switch(ie){case n:var V=re.type;switch(V){case x:case y:case r:case l:case o:case S:return V;default:var oe=V&&V.$$typeof;switch(oe){case c:case u:case m:case w:case d:return oe;default:return ie}}case a:return ie}}}var f=x,p=y,b=c,A=d,O=n,L=u,U=r,v=m,M=w,P=a,N=l,E=o,F=S,q=!1;function z(re){return q||(q=!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.")),k(re)||C(re)===x}function k(re){return C(re)===y}function T(re){return C(re)===c}function $(re){return C(re)===d}function B(re){return typeof re=="object"&&re!==null&&re.$$typeof===n}function Y(re){return C(re)===u}function ne(re){return C(re)===r}function H(re){return C(re)===m}function W(re){return C(re)===w}function Z(re){return C(re)===a}function se(re){return C(re)===l}function pe(re){return C(re)===o}function ve(re){return C(re)===S}De.AsyncMode=f,De.ConcurrentMode=p,De.ContextConsumer=b,De.ContextProvider=A,De.Element=O,De.ForwardRef=L,De.Fragment=U,De.Lazy=v,De.Memo=M,De.Portal=P,De.Profiler=N,De.StrictMode=E,De.Suspense=F,De.isAsyncMode=z,De.isConcurrentMode=k,De.isContextConsumer=T,De.isContextProvider=$,De.isElement=B,De.isForwardRef=Y,De.isFragment=ne,De.isLazy=H,De.isMemo=W,De.isPortal=Z,De.isProfiler=se,De.isStrictMode=pe,De.isSuspense=ve,De.isValidElementType=D,De.typeOf=C})()),De}var pr;function ro(){return pr||(pr=1,process.env.NODE_ENV==="production"?Kn.exports=Ed():Kn.exports=Md()),Kn.exports}var Qa,mr;function Fd(){if(mr)return Qa;mr=1;var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=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 x=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(x.join("")!=="0123456789")return!1;var y={};return"abcdefghijklmnopqrst".split("").forEach(function(u){y[u]=u}),Object.keys(Object.assign({},y)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Qa=o()?Object.assign:function(l,d){for(var c,x=r(l),y,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var S in c)n.call(c,S)&&(x[S]=c[S]);if(t){y=t(c);for(var j=0;j<y.length;j++)a.call(c,y[j])&&(x[y[j]]=c[y[j]])}}return x},Qa}var Xa,yr;function Ps(){if(yr)return Xa;yr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Xa=t,Xa}var Za,fr;function io(){return fr||(fr=1,Za=Function.call.bind(Object.prototype.hasOwnProperty)),Za}var es,hr;function Nd(){if(hr)return es;hr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=Ps(),a={},r=io();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,x,y){if(process.env.NODE_ENV!=="production"){for(var u in l)if(r(l,u)){var S;try{if(typeof l[u]!="function"){var j=Error((x||"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 j.name="Invariant Violation",j}S=l[u](d,u,x,c,null,n)}catch(m){S=m}if(S&&!(S instanceof Error)&&t((x||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof S+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),S instanceof Error&&!(S.message in a)){a[S.message]=!0;var w=y?y():"";t("Failed "+c+" type: "+S.message+(w??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(a={})},es=o,es}var ts,gr;function $d(){if(gr)return ts;gr=1;var t=ro(),n=Fd(),a=Ps(),r=io(),o=Nd(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var x="Warning: "+c;typeof console<"u"&&console.error(x);try{throw new Error(x)}catch{}});function d(){return null}return ts=function(c,x){var y=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function S(k){var T=k&&(y&&k[y]||k[u]);if(typeof T=="function")return T}var j="<<anonymous>>",w={array:I("array"),bigint:I("bigint"),bool:I("boolean"),func:I("function"),number:I("number"),object:I("object"),string:I("string"),symbol:I("symbol"),any:R(),arrayOf:D,element:C(),elementType:f(),instanceOf:p,node:L(),objectOf:A,oneOf:b,oneOfType:O,shape:v,exact:M};function m(k,T){return k===T?k!==0||1/k===1/T:k!==k&&T!==T}function h(k,T){this.message=k,this.data=T&&typeof T=="object"?T:{},this.stack=""}h.prototype=Error.prototype;function g(k){if(process.env.NODE_ENV!=="production")var T={},$=0;function B(ne,H,W,Z,se,pe,ve){if(Z=Z||j,pe=pe||W,ve!==a){if(x){var re=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 re.name="Invariant Violation",re}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ie=Z+":"+W;!T[ie]&&$<3&&(l("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+Z+"`. 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."),T[ie]=!0,$++)}}return H[W]==null?ne?H[W]===null?new h("The "+se+" `"+pe+"` is marked as required "+("in `"+Z+"`, but its value is `null`.")):new h("The "+se+" `"+pe+"` is marked as required in "+("`"+Z+"`, but its value is `undefined`.")):null:k(H,W,Z,se,pe)}var Y=B.bind(null,!1);return Y.isRequired=B.bind(null,!0),Y}function I(k){function T($,B,Y,ne,H,W){var Z=$[B],se=E(Z);if(se!==k){var pe=F(Z);return new h("Invalid "+ne+" `"+H+"` of type "+("`"+pe+"` supplied to `"+Y+"`, expected ")+("`"+k+"`."),{expectedType:k})}return null}return g(T)}function R(){return g(d)}function D(k){function T($,B,Y,ne,H){if(typeof k!="function")return new h("Property `"+H+"` of component `"+Y+"` has invalid PropType notation inside arrayOf.");var W=$[B];if(!Array.isArray(W)){var Z=E(W);return new h("Invalid "+ne+" `"+H+"` of type "+("`"+Z+"` supplied to `"+Y+"`, expected an array."))}for(var se=0;se<W.length;se++){var pe=k(W,se,Y,ne,H+"["+se+"]",a);if(pe instanceof Error)return pe}return null}return g(T)}function C(){function k(T,$,B,Y,ne){var H=T[$];if(!c(H)){var W=E(H);return new h("Invalid "+Y+" `"+ne+"` of type "+("`"+W+"` supplied to `"+B+"`, expected a single ReactElement."))}return null}return g(k)}function f(){function k(T,$,B,Y,ne){var H=T[$];if(!t.isValidElementType(H)){var W=E(H);return new h("Invalid "+Y+" `"+ne+"` of type "+("`"+W+"` supplied to `"+B+"`, expected a single ReactElement type."))}return null}return g(k)}function p(k){function T($,B,Y,ne,H){if(!($[B]instanceof k)){var W=k.name||j,Z=z($[B]);return new h("Invalid "+ne+" `"+H+"` of type "+("`"+Z+"` supplied to `"+Y+"`, expected ")+("instance of `"+W+"`."))}return null}return g(T)}function b(k){if(!Array.isArray(k))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 T($,B,Y,ne,H){for(var W=$[B],Z=0;Z<k.length;Z++)if(m(W,k[Z]))return null;var se=JSON.stringify(k,function(ve,re){var ie=F(re);return ie==="symbol"?String(re):re});return new h("Invalid "+ne+" `"+H+"` of value `"+String(W)+"` "+("supplied to `"+Y+"`, expected one of "+se+"."))}return g(T)}function A(k){function T($,B,Y,ne,H){if(typeof k!="function")return new h("Property `"+H+"` of component `"+Y+"` has invalid PropType notation inside objectOf.");var W=$[B],Z=E(W);if(Z!=="object")return new h("Invalid "+ne+" `"+H+"` of type "+("`"+Z+"` supplied to `"+Y+"`, expected an object."));for(var se in W)if(r(W,se)){var pe=k(W,se,Y,ne,H+"."+se,a);if(pe instanceof Error)return pe}return null}return g(T)}function O(k){if(!Array.isArray(k))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var T=0;T<k.length;T++){var $=k[T];if(typeof $!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+q($)+" at index "+T+"."),d}function B(Y,ne,H,W,Z){for(var se=[],pe=0;pe<k.length;pe++){var ve=k[pe],re=ve(Y,ne,H,W,Z,a);if(re==null)return null;re.data&&r(re.data,"expectedType")&&se.push(re.data.expectedType)}var ie=se.length>0?", expected one of type ["+se.join(", ")+"]":"";return new h("Invalid "+W+" `"+Z+"` supplied to "+("`"+H+"`"+ie+"."))}return g(B)}function L(){function k(T,$,B,Y,ne){return P(T[$])?null:new h("Invalid "+Y+" `"+ne+"` supplied to "+("`"+B+"`, expected a ReactNode."))}return g(k)}function U(k,T,$,B,Y){return new h((k||"React class")+": "+T+" type `"+$+"."+B+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Y+"`.")}function v(k){function T($,B,Y,ne,H){var W=$[B],Z=E(W);if(Z!=="object")return new h("Invalid "+ne+" `"+H+"` of type `"+Z+"` "+("supplied to `"+Y+"`, expected `object`."));for(var se in k){var pe=k[se];if(typeof pe!="function")return U(Y,ne,H,se,F(pe));var ve=pe(W,se,Y,ne,H+"."+se,a);if(ve)return ve}return null}return g(T)}function M(k){function T($,B,Y,ne,H){var W=$[B],Z=E(W);if(Z!=="object")return new h("Invalid "+ne+" `"+H+"` of type `"+Z+"` "+("supplied to `"+Y+"`, expected `object`."));var se=n({},$[B],k);for(var pe in se){var ve=k[pe];if(r(k,pe)&&typeof ve!="function")return U(Y,ne,H,pe,F(ve));if(!ve)return new h("Invalid "+ne+" `"+H+"` key `"+pe+"` supplied to `"+Y+"`.\nBad object: "+JSON.stringify($[B],null," ")+`
|
|
10
|
+
Valid keys: `+JSON.stringify(Object.keys(k),null," "));var re=ve(W,pe,Y,ne,H+"."+pe,a);if(re)return re}return null}return g(T)}function P(k){switch(typeof k){case"number":case"string":case"undefined":return!0;case"boolean":return!k;case"object":if(Array.isArray(k))return k.every(P);if(k===null||c(k))return!0;var T=S(k);if(T){var $=T.call(k),B;if(T!==k.entries){for(;!(B=$.next()).done;)if(!P(B.value))return!1}else for(;!(B=$.next()).done;){var Y=B.value;if(Y&&!P(Y[1]))return!1}}else return!1;return!0;default:return!1}}function N(k,T){return k==="symbol"?!0:T?T["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&T instanceof Symbol:!1}function E(k){var T=typeof k;return Array.isArray(k)?"array":k instanceof RegExp?"object":N(T,k)?"symbol":T}function F(k){if(typeof k>"u"||k===null)return""+k;var T=E(k);if(T==="object"){if(k instanceof Date)return"date";if(k instanceof RegExp)return"regexp"}return T}function q(k){var T=F(k);switch(T){case"array":case"object":return"an "+T;case"boolean":case"date":case"regexp":return"a "+T;default:return T}}function z(k){return!k.constructor||!k.constructor.name?j:k.constructor.name}return w.checkPropTypes=o,w.resetWarningCache=o.resetWarningCache,w.PropTypes=w,w},ts}var ns,xr;function Ud(){if(xr)return ns;xr=1;var t=Ps();function n(){}function a(){}return a.resetWarningCache=n,ns=function(){function r(d,c,x,y,u,S){if(S!==t){var j=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 j.name="Invariant Violation",j}}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:a,resetWarningCache:n};return l.PropTypes=l,l},ns}var br;function oo(){if(br)return Hn.exports;if(br=1,process.env.NODE_ENV!=="production"){var t=ro(),n=!0;Hn.exports=$d()(t.isElement,n)}else Hn.exports=Ud()();return Hn.exports}var Sr;function Bd(){if(Sr)return qe;Sr=1;var t=qe&&qe.__extends||(function(){var w=function(m,h){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,I){g.__proto__=I}||function(g,I){for(var R in I)Object.prototype.hasOwnProperty.call(I,R)&&(g[R]=I[R])},w(m,h)};return function(m,h){if(typeof h!="function"&&h!==null)throw new TypeError("Class extends value "+String(h)+" is not a constructor or null");w(m,h);function g(){this.constructor=m}m.prototype=h===null?Object.create(h):(g.prototype=h.prototype,new g)}})(),n=qe&&qe.__assign||function(){return n=Object.assign||function(w){for(var m,h=1,g=arguments.length;h<g;h++){m=arguments[h];for(var I in m)Object.prototype.hasOwnProperty.call(m,I)&&(w[I]=m[I])}return w},n.apply(this,arguments)},a=qe&&qe.__createBinding||(Object.create?(function(w,m,h,g){g===void 0&&(g=h);var I=Object.getOwnPropertyDescriptor(m,h);(!I||("get"in I?!m.__esModule:I.writable||I.configurable))&&(I={enumerable:!0,get:function(){return m[h]}}),Object.defineProperty(w,g,I)}):(function(w,m,h,g){g===void 0&&(g=h),w[g]=m[h]})),r=qe&&qe.__setModuleDefault||(Object.create?(function(w,m){Object.defineProperty(w,"default",{enumerable:!0,value:m})}):function(w,m){w.default=m}),o=qe&&qe.__importStar||function(w){if(w&&w.__esModule)return w;var m={};if(w!=null)for(var h in w)h!=="default"&&Object.prototype.hasOwnProperty.call(w,h)&&a(m,w,h);return r(m,w),m},l=qe&&qe.__rest||function(w,m){var h={};for(var g in w)Object.prototype.hasOwnProperty.call(w,g)&&m.indexOf(g)<0&&(h[g]=w[g]);if(w!=null&&typeof Object.getOwnPropertySymbols=="function")for(var I=0,g=Object.getOwnPropertySymbols(w);I<g.length;I++)m.indexOf(g[I])<0&&Object.prototype.propertyIsEnumerable.call(w,g[I])&&(h[g[I]]=w[g[I]]);return h},d=qe&&qe.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(qe,"__esModule",{value:!0});var c=o(i),x=d(Pd()),y=o(oo());function u(w){return w&&w.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function S(w){var m=document.createTextNode("");w.appendChild(m);var h=document.activeElement===w;if(m!==null&&m.nodeValue!==null&&h){var g=window.getSelection();if(g!==null){var I=document.createRange();I.setStart(m,m.nodeValue.length),I.collapse(!0),g.removeAllRanges(),g.addRange(I)}w instanceof HTMLElement&&w.focus()}}var j=(function(w){t(m,w);function m(){var h=w!==null&&w.apply(this,arguments)||this;return h.lastHtml=h.props.html,h.el=typeof h.props.innerRef=="function"?{current:null}:c.createRef(),h.getEl=function(){return(h.props.innerRef&&typeof h.props.innerRef!="function"?h.props.innerRef:h.el).current},h.emitChange=function(g){var I=h.getEl();if(I){var R=I.innerHTML;if(h.props.onChange&&R!==h.lastHtml){var D=Object.assign({},g,{target:{value:R}});h.props.onChange(D)}h.lastHtml=R}},h}return m.prototype.render=function(){var h=this,g=this.props,I=g.tagName,R=g.html,D=g.innerRef,C=l(g,["tagName","html","innerRef"]);return c.createElement(I||"div",n(n({},C),{ref:typeof D=="function"?function(f){D(f),h.el.current=f}:D||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)},m.prototype.shouldComponentUpdate=function(h){var g=this.props,I=this.getEl();return!I||u(h.html)!==u(I.innerHTML)?!0:g.disabled!==h.disabled||g.tagName!==h.tagName||g.className!==h.className||g.innerRef!==h.innerRef||g.placeholder!==h.placeholder||!(0,x.default)(g.style,h.style)},m.prototype.componentDidUpdate=function(){var h=this.getEl();h&&(this.props.html!==h.innerHTML&&(h.innerHTML=this.props.html),this.lastHtml=this.props.html,S(h))},m.propTypes={html:y.string.isRequired,onChange:y.func,disabled:y.bool,tagName:y.string,className:y.string,style:y.object,innerRef:y.oneOfType([y.object,y.func])},m})(c.Component);return qe.default=j,qe}var Ld=Bd();const lo=so(Ld),qd={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},zd={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"},J=i.forwardRef(({style:t,onFocus:n,onBlur:a,...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:qd,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:o,onFocus:c=>{d(!0),n?.(c)},onBlur:c=>{d(!1),a?.(c)},style:{...zd,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),jr=[{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 Es(t){const n=ae().year(),a=[];for(let r=n;r>=n-t;r--)a.push({label:String(r),value:r});return a}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 Ms(t){const n=ae().year(),a=ae().month();return t<n?jr:jr.slice(0,a+1)}function vr(t,n){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:n});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:n});default:return e.jsx("span",{className:"monthlyLabel",children:n})}}function Yd(){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 co=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(s.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(s.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(s.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""}},gt=t=>{const n=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[n?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var fn={},hn={},ot={},gn={},Qt={},_r;function Wd(){if(_r)return Qt;_r=1;var t=Qt&&Qt.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Qt,"__esModule",{value:!0});const n=t(i),a=Po,r=["string","number","boolean"];function o({header:l,body:d}){const c=n.default.createElement("tr",null,l.map(y=>n.default.createElement("th",{key:y},y))),x=d.map((y,u)=>Array.isArray(y)?n.default.createElement("tr",{key:u},y.map((S,j)=>n.default.createElement("th",{key:j}," ",S," "))):y!==null&&typeof y=="object"?n.default.createElement("tr",{key:u},Object.entries(y).map(([S,j],w)=>typeof j=="object"?(console.error(`typeof ${S} is incorrect, only accept ${r.join(", ")} `),n.default.createElement("th",{key:w})):n.default.createElement("th",{key:w},n.default.createElement(n.default.Fragment,null,j)))):(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,a.renderToString)(n.default.createElement("table",null,n.default.createElement("tbody",null,c,x)))}return Jt.default=o,Jt}var wr;function Hd(){return wr||(wr=1,(function(t){var n=hn&&hn.__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 a(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=a;function r(l,d){return l.replace(/{(\w+)}/g,(c,x)=>d[x])}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=Vd();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return n(o).default}})})(hn)),hn}var Cr;function uo(){if(Cr)return it;Cr=1;var t=it&&it.__createBinding||(Object.create?(function(y,u,S,j){j===void 0&&(j=S);var w=Object.getOwnPropertyDescriptor(u,S);(!w||("get"in w?!u.__esModule:w.writable||w.configurable))&&(w={enumerable:!0,get:function(){return u[S]}}),Object.defineProperty(y,j,w)}):(function(y,u,S,j){j===void 0&&(j=S),y[j]=u[S]})),n=it&&it.__setModuleDefault||(Object.create?(function(y,u){Object.defineProperty(y,"default",{enumerable:!0,value:u})}):function(y,u){y.default=u}),a=it&&it.__importStar||function(y){if(y&&y.__esModule)return y;var u={};if(y!=null)for(var S in y)S!=="default"&&Object.prototype.hasOwnProperty.call(y,S)&&t(u,y,S);return n(u,y),u};Object.defineProperty(it,"__esModule",{value:!0}),it.downloadExcel=it.excel=void 0;const r=a(Hd());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(y,u){const S=window.document.createElement("a");return S.href=r.uri+r.base64(r.format(r.template,u)),S.download=y,document.body.appendChild(S),S.click(),document.body.removeChild(S),!0}function d(y,u){if(y)return y.cloneNode(!0).outerHTML;if(u)return r.createTable(u);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:y,sheet:u,tablePayload:S},j){if(!o())return!1;const w=d(j,S);return l(y,{worksheet:u||"Worksheet",table:w})}it.downloadExcel=c;function x({currentTableRef:y,filename:u,sheet:S}){function j(){if(!o())return!1;const w=d(y),m=`${u}.xls`;return l(m,{worksheet:S||"Worksheet",table:w})}return{onDownload:j}}return it.excel=x,it}var Ar;function Kd(){if(Ar)return fn;Ar=1,Object.defineProperty(fn,"__esModule",{value:!0}),fn.useDownloadExcel=void 0;const t=i,n=uo();function a({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,n.excel)(d),[d])}return fn.useDownloadExcel=a,fn}var Tr;function Gd(){return Tr||(Tr=1,(function(t){var n=yn&&yn.__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 a=n(i),r=Kd();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const o=uo();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:x,children:y})=>{const{onDownload:u}=(0,r.useDownloadExcel)({currentTableRef:d,filename:c,sheet:x});return a.default.createElement("span",{onClick:u},y)};t.DownloadTableExcel=l})(yn)),yn}var po=Gd();const cn=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:n}=t.data;t?.tableRef;const a=new Date().getTime(),r=ln.useReactToPrint({content:()=>n.current});return e.jsx(e.Fragment,{children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(s.Row,{gutter:8,children:[e.jsx(s.Col,{children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:e.jsx(po.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:n.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},wt=t=>{const{tableRef:n}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},Jd=i.createContext(),Qd=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Le=t=>{const{columns:n,action:a,DrawerUpdate:r,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:x,open:y,ActionView:u,viewDetails:S,myType:j,type:w,urlkey:m,columnstype:h,rowSelection:g}=t.data,I=Qd(),[R,D]=i.useState(!1),[C,f]=i.useState(null),[p,b]=i.useState("false"),[A,O]=i.useState(!1),[L,U]=i.useState(!1),[v,M]=i.useState(),[P,N]=i.useState(""),E=()=>D(!1),F=te=>{b(te),D(!0)},[q,z]=i.useState(),[k,T]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),$=i.useRef(null),B=(te,me)=>{t.parentCallback?.(te,me),T({rowsPerPage:me,page:te})},Y=(te,me)=>{f(me),O(!0),M(te)},ne=(te,me)=>{f(me),U(!0),M(te)},H=t?.data?.onNavigate??t?.onNavigate,W=(te,me)=>{if(typeof H=="function"){H(te,me);return}typeof window<"u"&&typeof te=="string"&&te.length>0&&window.location.assign(te)},Z=te=>{if(w==="staff"){W(`/HumanResourceDashboard/StaffFullInformation?id=${te.fk_staffID}`,te);return}W(`/StudentInformation/StudentFullInformation?id=${te.id}`,te)},se=(te,me)=>{z(te),r?.(me)},pe=async(te,me,he,Te)=>{r?.(!0),he!==""&&((await Te({id:te,admission_no:me,ec_no:he}))?.Status==="Success"?s.message.success("Ec No updated successfully"):s.message.error("Failed to Update Ec No."))},ve=()=>e.jsx(Jd.Provider,{value:q,children:o}),{trigger:re}=Je("branchapi/staff/updateStaffPassword",kn),{trigger:ie}=Je("branchapi/Student/updateEcNo",kn),{trigger:V}=Je(m,(te,me)=>kn("student/studentDetails/editStudentLogInCredential",me)),oe=async te=>{te.preventDefault(),O(!1);try{(await re({staff_id:v,new_passwod:te.target.password.value}))?.Status==="Success"?s.message.success("Password updated successfully"):s.message.error("Failed to update password")}catch{s.message.error("Failed to update password")}},Ce=async te=>{te.preventDefault(),U(!1);try{(await V({edit_id:C?.edit_id,new_passwod:te.target.password.value,username:te.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?s.message.success("Password updated successfully"):s.message.error("Failed to update password")}catch(me){s.message.error(me?.response?.data?.msg??"Failed to update password")}},Oe=(Array.isArray(n)?n:[]).some(te=>te?.fixed==="left"),Pe=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:h==="antd"&&Oe?"left":void 0,sorter:(te,me)=>(te.__serialNumber??0)-(me.__serialNumber??0),render:te=>te},...h==="antd"?n:(Array.isArray(n)?n:[]).map(te=>({title:te.name,dataIndex:te.selector,key:te.selector,sorter:te.sorter||(te.sortable?(me,he)=>{const Te=me[te.selector]??"",Re=he[te.selector]??"";return typeof Te=="number"&&typeof Re=="number"?Te-Re:String(Te).localeCompare(String(Re))}:!1),render:(me,he)=>{switch(te.selector){case"my_staff":return he.staff_id!=="0"?he.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(s.Image,{width:50,src:`undefined/branch/gallery/${he.gallery_cat_logo}`});case"file01":return he.documents?e.jsx("div",{onClick:()=>F(`undefined/branch/frontoffice/${he.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 ht(me);case"full_name":return e.jsx("span",{onClick:()=>Z(he),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:me||`${he.firstname} ${he.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 he?.current_status==="Active"?e.jsx(s.Progress,{percent:he.steps==="1"?30:he.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:he?.current_status});case"Password":return e.jsx("span",{onClick:()=>Y(he.id,he),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>ne(he.id,he),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(s.Tag,{onClick:()=>S?.(he.id),color:me==="paid"?"#66aa18":me==="partially_paid"?"#ff5722":"#DC143C",children:me==="paid"?"Paid":me==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return Wd().find(Te=>Te.value===me)?.label;case"status":return e.jsx("span",{onClick:()=>S?.(he?.fk_staffID,he?.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:[he.is_theory==="yes"&&"Theory, ",he.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(lo,{html:he.ec_no,onBlur:Te=>pe(he.id,he.admission_no,Te.target.innerHTML,ie)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(s.Button,{type:"primary",icon:e.jsx(X.SendOutlined,{}),size:"small",onClick:()=>se(he.id,!0,te.name),children:te.name});case"Button":return e.jsx(s.Tag,{color:"cyan",onClick:()=>S?.(he),children:te.name});default:return me}}})),...a?[{title:"Action",key:"action",render:(te,me)=>{const he=me?.current_status==="Promoted",Te=()=>{if(j=="sameAddUpdate"){se(me,!0);return}if(j?.type==="examEdit"){j.editFunc(me.id);return}se(me.id||me,!0)},Re=()=>{if(j==="student_result"){S?.(me);return}if(j==="student"){S?.(me.id,me.class_id);return}S?.(me.id)},ft=()=>{x?.(me?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[u?.[0]?.status&&e.jsx(s.Button,{icon:e.jsx(X.EditOutlined,{}),size:"small",disabled:he,onClick:Te}),u?.[1]?.status&&e.jsx(s.Button,{icon:e.jsx(X.DeleteOutlined,{}),size:"small",danger:!0,disabled:he,onClick:ft}),u?.[2]?.status&&e.jsx(s.Button,{icon:e.jsx(X.EyeOutlined,{}),size:"small",onClick:Re})]})}}]:[]],Ne=i.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Ee=i.useMemo(()=>{const te=P.trim().toLowerCase();return te?Ne.filter(me=>Object.values(me??{}).some(he=>String(he??"").toLowerCase().includes(te))):Ne},[Ne,P]),Ve=!!t.parentCallback,He=P?Ee.length:l?.pagination?.total_rows??Ee.length,Be=(k.page-1)*k.rowsPerPage,We=Ve?Ee:Ee.slice(Be,Be+k.rowsPerPage),rt=i.useMemo(()=>(We??[]).map((te,me)=>({...te??{},__serialNumber:Be+me+1})),[Be,We]),fe=He===0?0:Math.min(Be+1,He),xe=He===0?0:Math.min(Be+We.length,He);let ge;return d?ge=e.jsx("p",{children:"Loading..."}):c?ge=e.jsx("p",{children:c.message}):We.length?ge=e.jsx(s.Table,{dataSource:rt,columns:Pe,size:"small",bordered:!0,pagination:!1,rowSelection:g,rowKey:(te,me)=>te?.id??te?._id??me,scroll:{x:"max-content"}}):ge=e.jsx(s.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(s.Drawer,{open:y,placement:"right",onClose:()=>r?.(!1),width:720,children:ve()}),e.jsx(s.Modal,{title:"Update Password",open:A,onCancel:()=>O(!1),footer:null,children:e.jsx("form",{onSubmit:oe,children:e.jsxs(de,{children:[e.jsx(de,{style:{marginBottom:12},children:e.jsx(J,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(de,{style:{marginTop:16},children:e.jsx(s.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(s.Modal,{title:" Update Credential",open:L,onCancel:()=>U(!1),footer:null,children:e.jsx("form",{onSubmit:Ce,children:e.jsxs(de,{children:[e.jsx(de,{style:{marginBottom:12},children:e.jsx(J,{type:"text",label:"User Name",name:"username",required:"required",value:C?.username?C?.username:"",onChange:te=>f({...C,username:te.target.value})})}),e.jsx(de,{style:{marginBottom:12},children:e.jsx(J,{label:"Password",name:"password",required:"required",value:C?.password?C?.password:"",onChange:te=>f({...C,password:te.target.value})})}),e.jsx(de,{style:{marginTop:16},children:e.jsx(s.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(s.Modal,{open:R,onCancel:E,footer:null,centered:!0,width:"80%",className:I.modal,children:e.jsxs("div",{style:{position:"relative"},className:I.img,children:[e.jsx(s.Image,{src:p,alt:"",style:{width:"100%"},preview:!1}),e.jsx(s.Button,{type:"text",icon:e.jsx(X.CloseOutlined,{}),onClick:E,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(s.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
|
|
16
|
+
`),null));return(0,a.renderToString)(n.default.createElement("table",null,n.default.createElement("tbody",null,c,x)))}return Qt.default=o,Qt}var wr;function Vd(){return wr||(wr=1,(function(t){var n=gn&&gn.__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 a(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=a;function r(l,d){return l.replace(/{(\w+)}/g,(c,x)=>d[x])}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=Wd();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return n(o).default}})})(gn)),gn}var Cr;function uo(){if(Cr)return ot;Cr=1;var t=ot&&ot.__createBinding||(Object.create?(function(y,u,S,j){j===void 0&&(j=S);var w=Object.getOwnPropertyDescriptor(u,S);(!w||("get"in w?!u.__esModule:w.writable||w.configurable))&&(w={enumerable:!0,get:function(){return u[S]}}),Object.defineProperty(y,j,w)}):(function(y,u,S,j){j===void 0&&(j=S),y[j]=u[S]})),n=ot&&ot.__setModuleDefault||(Object.create?(function(y,u){Object.defineProperty(y,"default",{enumerable:!0,value:u})}):function(y,u){y.default=u}),a=ot&&ot.__importStar||function(y){if(y&&y.__esModule)return y;var u={};if(y!=null)for(var S in y)S!=="default"&&Object.prototype.hasOwnProperty.call(y,S)&&t(u,y,S);return n(u,y),u};Object.defineProperty(ot,"__esModule",{value:!0}),ot.downloadExcel=ot.excel=void 0;const r=a(Vd());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(y,u){const S=window.document.createElement("a");return S.href=r.uri+r.base64(r.format(r.template,u)),S.download=y,document.body.appendChild(S),S.click(),document.body.removeChild(S),!0}function d(y,u){if(y)return y.cloneNode(!0).outerHTML;if(u)return r.createTable(u);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:y,sheet:u,tablePayload:S},j){if(!o())return!1;const w=d(j,S);return l(y,{worksheet:u||"Worksheet",table:w})}ot.downloadExcel=c;function x({currentTableRef:y,filename:u,sheet:S}){function j(){if(!o())return!1;const w=d(y),m=`${u}.xls`;return l(m,{worksheet:S||"Worksheet",table:w})}return{onDownload:j}}return ot.excel=x,ot}var Ar;function Hd(){if(Ar)return hn;Ar=1,Object.defineProperty(hn,"__esModule",{value:!0}),hn.useDownloadExcel=void 0;const t=i,n=uo();function a({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,n.excel)(d),[d])}return hn.useDownloadExcel=a,hn}var Tr;function Kd(){return Tr||(Tr=1,(function(t){var n=fn&&fn.__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 a=n(i),r=Hd();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const o=uo();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:x,children:y})=>{const{onDownload:u}=(0,r.useDownloadExcel)({currentTableRef:d,filename:c,sheet:x});return a.default.createElement("span",{onClick:u},y)};t.DownloadTableExcel=l})(fn)),fn}var po=Kd();const un=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:n}=t.data;t?.tableRef;const a=new Date().getTime(),r=dn.useReactToPrint({content:()=>n.current});return e.jsx(e.Fragment,{children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(s.Row,{gutter:8,children:[e.jsx(s.Col,{children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:e.jsx(po.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:n.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},Ct=t=>{const{tableRef:n}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},Gd=i.createContext(),Jd=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Le=t=>{const{columns:n,action:a,DrawerUpdate:r,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:x,open:y,ActionView:u,viewDetails:S,myType:j,type:w,urlkey:m,columnstype:h,rowSelection:g}=t.data,I=Jd(),[R,D]=i.useState(!1),[C,f]=i.useState(null),[p,b]=i.useState("false"),[A,O]=i.useState(!1),[L,U]=i.useState(!1),[v,M]=i.useState(),[P,N]=i.useState(""),E=()=>D(!1),F=te=>{b(te),D(!0)},[q,z]=i.useState(),[k,T]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),$=i.useRef(null),B=(te,me)=>{t.parentCallback?.(te,me),T({rowsPerPage:me,page:te})},Y=(te,me)=>{f(me),O(!0),M(te)},ne=(te,me)=>{f(me),U(!0),M(te)},H=t?.data?.onNavigate??t?.onNavigate,W=(te,me)=>{if(typeof H=="function"){H(te,me);return}typeof window<"u"&&typeof te=="string"&&te.length>0&&window.location.assign(te)},Z=te=>{if(w==="staff"){W(`/HumanResourceDashboard/StaffFullInformation?id=${te.fk_staffID}`,te);return}W(`/StudentInformation/StudentFullInformation?id=${te.id}`,te)},se=(te,me)=>{z(te),r?.(me)},pe=async(te,me,he,Te)=>{r?.(!0),he!==""&&((await Te({id:te,admission_no:me,ec_no:he}))?.Status==="Success"?s.message.success("Ec No updated successfully"):s.message.error("Failed to Update Ec No."))},ve=()=>e.jsx(Gd.Provider,{value:q,children:o}),{trigger:re}=Je("branchapi/staff/updateStaffPassword",On),{trigger:ie}=Je("branchapi/Student/updateEcNo",On),{trigger:V}=Je(m,(te,me)=>On("student/studentDetails/editStudentLogInCredential",me)),oe=async te=>{te.preventDefault(),O(!1);try{(await re({staff_id:v,new_passwod:te.target.password.value}))?.Status==="Success"?s.message.success("Password updated successfully"):s.message.error("Failed to update password")}catch{s.message.error("Failed to update password")}},Ce=async te=>{te.preventDefault(),U(!1);try{(await V({edit_id:C?.edit_id,new_passwod:te.target.password.value,username:te.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?s.message.success("Password updated successfully"):s.message.error("Failed to update password")}catch(me){s.message.error(me?.response?.data?.msg??"Failed to update password")}},Oe=(Array.isArray(n)?n:[]).some(te=>te?.fixed==="left"),Pe=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:h==="antd"&&Oe?"left":void 0,sorter:(te,me)=>(te.__serialNumber??0)-(me.__serialNumber??0),render:te=>te},...h==="antd"?n:(Array.isArray(n)?n:[]).map(te=>({title:te.name,dataIndex:te.selector,key:te.selector,sorter:te.sorter||(te.sortable?(me,he)=>{const Te=me[te.selector]??"",Re=he[te.selector]??"";return typeof Te=="number"&&typeof Re=="number"?Te-Re:String(Te).localeCompare(String(Re))}:!1),render:(me,he)=>{switch(te.selector){case"my_staff":return he.staff_id!=="0"?he.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(s.Image,{width:50,src:`undefined/branch/gallery/${he.gallery_cat_logo}`});case"file01":return he.documents?e.jsx("div",{onClick:()=>F(`undefined/branch/frontoffice/${he.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 gt(me);case"full_name":return e.jsx("span",{onClick:()=>Z(he),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:me||`${he.firstname} ${he.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 he?.current_status==="Active"?e.jsx(s.Progress,{percent:he.steps==="1"?30:he.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:he?.current_status});case"Password":return e.jsx("span",{onClick:()=>Y(he.id,he),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>ne(he.id,he),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(s.Tag,{onClick:()=>S?.(he.id),color:me==="paid"?"#66aa18":me==="partially_paid"?"#ff5722":"#DC143C",children:me==="paid"?"Paid":me==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return Yd().find(Te=>Te.value===me)?.label;case"status":return e.jsx("span",{onClick:()=>S?.(he?.fk_staffID,he?.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:[he.is_theory==="yes"&&"Theory, ",he.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(lo,{html:he.ec_no,onBlur:Te=>pe(he.id,he.admission_no,Te.target.innerHTML,ie)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(s.Button,{type:"primary",icon:e.jsx(X.SendOutlined,{}),size:"small",onClick:()=>se(he.id,!0,te.name),children:te.name});case"Button":return e.jsx(s.Tag,{color:"cyan",onClick:()=>S?.(he),children:te.name});default:return me}}})),...a?[{title:"Action",key:"action",render:(te,me)=>{const he=me?.current_status==="Promoted",Te=()=>{if(j=="sameAddUpdate"){se(me,!0);return}if(j?.type==="examEdit"){j.editFunc(me.id);return}se(me.id||me,!0)},Re=()=>{if(j==="student_result"){S?.(me);return}if(j==="student"){S?.(me.id,me.class_id);return}S?.(me.id)},ht=()=>{x?.(me?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[u?.[0]?.status&&e.jsx(s.Button,{icon:e.jsx(X.EditOutlined,{}),size:"small",disabled:he,onClick:Te}),u?.[1]?.status&&e.jsx(s.Button,{icon:e.jsx(X.DeleteOutlined,{}),size:"small",danger:!0,disabled:he,onClick:ht}),u?.[2]?.status&&e.jsx(s.Button,{icon:e.jsx(X.EyeOutlined,{}),size:"small",onClick:Re})]})}}]:[]],Fe=i.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Ee=i.useMemo(()=>{const te=P.trim().toLowerCase();return te?Fe.filter(me=>Object.values(me??{}).some(he=>String(he??"").toLowerCase().includes(te))):Fe},[Fe,P]),Ve=!!t.parentCallback,He=P?Ee.length:l?.pagination?.total_rows??Ee.length,Ue=(k.page-1)*k.rowsPerPage,We=Ve?Ee:Ee.slice(Ue,Ue+k.rowsPerPage),it=i.useMemo(()=>(We??[]).map((te,me)=>({...te??{},__serialNumber:Ue+me+1})),[Ue,We]),ye=He===0?0:Math.min(Ue+1,He),xe=He===0?0:Math.min(Ue+We.length,He);let ge;return d?ge=e.jsx("p",{children:"Loading..."}):c?ge=e.jsx("p",{children:c.message}):We.length?ge=e.jsx(s.Table,{dataSource:it,columns:Pe,size:"small",bordered:!0,pagination:!1,rowSelection:g,rowKey:(te,me)=>te?.id??te?._id??me,scroll:{x:"max-content"}}):ge=e.jsx(s.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(s.Drawer,{open:y,placement:"right",onClose:()=>r?.(!1),width:720,children:ve()}),e.jsx(s.Modal,{title:"Update Password",open:A,onCancel:()=>O(!1),footer:null,children:e.jsx("form",{onSubmit:oe,children:e.jsxs(le,{children:[e.jsx(le,{style:{marginBottom:12},children:e.jsx(J,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(le,{style:{marginTop:16},children:e.jsx(s.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(s.Modal,{title:" Update Credential",open:L,onCancel:()=>U(!1),footer:null,children:e.jsx("form",{onSubmit:Ce,children:e.jsxs(le,{children:[e.jsx(le,{style:{marginBottom:12},children:e.jsx(J,{type:"text",label:"User Name",name:"username",required:"required",value:C?.username?C?.username:"",onChange:te=>f({...C,username:te.target.value})})}),e.jsx(le,{style:{marginBottom:12},children:e.jsx(J,{label:"Password",name:"password",required:"required",value:C?.password?C?.password:"",onChange:te=>f({...C,password:te.target.value})})}),e.jsx(le,{style:{marginTop:16},children:e.jsx(s.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(s.Modal,{open:R,onCancel:E,footer:null,centered:!0,width:"80%",className:I.modal,children:e.jsxs("div",{style:{position:"relative"},className:I.img,children:[e.jsx(s.Image,{src:p,alt:"",style:{width:"100%"},preview:!1}),e.jsx(s.Button,{type:"text",icon:e.jsx(X.CloseOutlined,{}),onClick:E,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(s.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(k),null," "));var re=ve(W,pe,Y,ne,H+".
|
|
|
56
56
|
.ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
|
|
57
57
|
color: #8f99ff;
|
|
58
58
|
}
|
|
59
|
-
`}),e.jsx(de,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(cn,{data:{tableRef:$}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:$,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(s.Select,{size:"small",value:k.rowsPerPage,onChange:te=>B(1,te),options:[10,25,50,100].map(te=>({label:te,value:te})),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(s.Input,{size:"small",allowClear:!0,value:P,onChange:te=>{N(te.target.value),T(me=>({...me,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(X.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(wt,{})}),ge]}),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 ${xe} of ${He} entries`}),e.jsx(s.Pagination,{current:k.page,pageSize:k.rowsPerPage,total:He||0,showSizeChanger:!1,onChange:B})]})]})]})},Xd=({token:t,type:n})=>{const[a,r]=i.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${a.page}&per_page=${a.rowsPerPage}`,{isLoading:c,data:x,error:y}=G(t?[d,t]:null,([R,D])=>Q(R,D)),[u,S]=i.useState(!1),j=(R,D)=>{r({page:R,rowsPerPage:parseInt(D)})},w=async R=>{},m=R=>{console.log("dsdsdsdsd",R),S(R)},h=()=>{},g=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],I=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(R,D)=>R.name.localeCompare(D.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(R,D)=>(R.contact||"").localeCompare(D.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(R,D)=>(R.description||"").localeCompare(D.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(R,D)=>(R.source_name||"").localeCompare(D.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(R,D)=>new Date(R.date)-new Date(D.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(R,D)=>new Date(R.follow_up_date)-new Date(D.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Le,{parentCallback:j,data:{newData:x,columns:I,action:!0,Loading:c,error:y,open:u,viewDetails:h,deleteTodoMutation:w,DrawerUpdate:m,ActionView:g}})})},Zd={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"},ce=i.forwardRef(({error:t,success:n,disabled:a,style:r,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:a,style:{...Zd,opacity:a?.7:1,cursor:a?"not-allowed":"pointer",...r||{}}})})),lt=({id:t,funcName:n,disabled:a=!1})=>{const r="Data",[o,l]=i.useState(!1),d=()=>{l(!0),n(t),s.message.success(`${r} deleted successfully!`)},c=()=>{s.message.info(`Deletion of ${r} cancelled`)};return e.jsx(s.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:a||o,children:e.jsx(s.Button,{danger:!0,disabled:a,loading:o,icon:e.jsx(X.DeleteOutlined,{}),size:"small"})})},st=t=>({optimisticData:n=>[...n.data,t],populateCache:(n,a)=>[...a.data,n]}),Qe=t=>({optimisticData:n=>n.data.filter(a=>a.id!==t),populateCache:(n,a)=>a.data.filter(r=>r.id!==t)}),Rr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function ec({token:t}){const[n,a]=i.useState({pagination:{current:1,pageSize:10}}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/routeTableList?page=${n.pagination.current}&per_page=${n.pagination.pageSize}`,x="api/branchapi/Transport/addroute",y="api/branchapi/Transport/editroute",u="api/branchapi/Transport/deleteroute",{isLoading:S,data:j,error:w,mutate:m}=G(t?[c,t]:null,([A,O])=>Q(A,O)),h=async(A,O)=>{try{await m(Ye(A,O,t),st(O)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},g=A=>{A.preventDefault();const O=new FormData(A.target);h(x,O),A.target.reset()},I=(A,O)=>{a(L=>({...L,pagination:{current:A,pageSize:parseInt(O,10)}}))},R=async A=>{try{await m(at(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)},C=async A=>{try{await pt(y,A,t),await m(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},f=async A=>{A.preventDefault();const O=new FormData(A.target);O.append("id",l?.id),C(O)},p=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(A,O)=>A.name.localeCompare(O.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(A,O)=>A.fare-O.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,O)=>A.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(A,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(O),style:{padding:2}}),e.jsx(lt,{id:O?.id,funcName:R})]})}],b=l?.route_title?`Edit ${l.route_title}`:"Edit Route";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:b,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:f,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"title",label:"Title",defaultValue:l?.route_title||"",required:"required"}),e.jsx(J,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:l?.fare||"",required:"required"}),e.jsx(J,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(J,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Rr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Route"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"}),e.jsx(J,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"}),e.jsx(J,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:Rr,children:"Cancel"})]})]})})})]})}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route List"})}),e.jsx(de,{children:e.jsx(Le,{parentCallback:I,data:{newData:j,columns:p,columnstype:"antd",action:!1,Loading:S,error:w,deleteTodoMutation:R}})})]})})]})})]})}const Ir={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function tc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${n.page}&per_page=${n.rowsPerPage}`,x="api/branchapi/Transport/addvehicles",y="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:S,data:j,error:w,mutate:m}=G(t?[c,t]:null,([A,O])=>Q(A,O)),h=async(A,O)=>{try{await m(Ye(A,O,t),st(O)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},g=A=>{A.preventDefault();const O=new FormData(A.target);h(x,O),A.target.reset()},I=async A=>{try{await m(at(u,A,t),Qe(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},R=A=>{d(A),o(!0)},D=async A=>{try{await pt(y,A,t),await m(),_.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 O=new FormData(A.target);O.append("id",l?.id),D(O)},f=(A,O)=>{a({page:A,rowsPerPage:parseInt(O,10)})},p=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(A,O)=>A.vehicle_no.localeCompare(O.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(A,O)=>A.vehicle_model.localeCompare(O.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(A,O)=>A.seating_capacity-O.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(A,O)=>A.manufacture_year-O.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(A,O)=>A.gps_url.localeCompare(O.gps_url)},render:(A,O)=>e.jsx("span",{title:O?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:O?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,O)=>A.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(A,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>R(O),style:{padding:2}}),e.jsx(lt,{id:O?.id,funcName:I})]})}],b=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:b,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(J,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(J,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(J,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(J,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(J,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(J,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Ir,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(J,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(J,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(J,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(J,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(J,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:Ir,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(de,{children:e.jsx(Le,{parentCallback:f,data:{newData:j,columns:p,columnstype:"antd",action:!1,Loading:S,error:w,deleteTodoMutation:I}})})]})})]})})]})}var nc=oo();const as=so(nc),mo=()=>{};class Fs extends i.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=n=>{this.selectRef=n};componentDidUpdate(n){n.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(n,a)=>{this.props.onChange(n,a),this.setState({value:n})};getValue=()=>{const{value:n}=this.state;return n?Array.isArray(n)?n.length?"valid":"":typeof n=="object"?n.value||"":n:""};render(){const{SelectComponent:n,required:a,...r}=this.props;console.log("sdsdsfsdddddddd",{...r});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(n,{...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:mo,onFocus:()=>this.selectRef.focus(),required:a})]})}}Fs.defaultProps={onChange:mo};Fs.protoTypes={selectComponent:as.func.isRequired,onChange:as.func,required:as.bool};const ac={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},sc={menuPortal:t=>({...t,zIndex:9999}),control:(t,n)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${n.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${n.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,n)=>({...t,padding:"0 0 0 8px",color:n.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,n)=>({...t,fontSize:"14px",backgroundColor:n.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},yo=t=>e.jsx(Pi.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),rc=t=>e.jsx(Fs,{...t,SelectComponent:Pi,components:{Input:yo},options:t.options}),ee=i.forwardRef(({...t},n)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:ac,children:t?.label}),e.jsx(rc,{components:{Input:yo},menuPortalTarget:document.body,styles:sc,className:"input-cont",...t,ref:n})]})),ic={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Dr=({dataIndex:t,title:n,record:a,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function oc({token:t}){const[n,a]=i.useState(!1),[r,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,x]=i.useState([]),y="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",S="api/branchapi/Transport/getchechkedVehicleData",j="api/branchapi/Transport/assignedVehicleTable",w="api/branchapi/transport/assignvehicle",m="api/branchapi/Transport/deleteassignvehicle",h=l?`${S}?route_id=${l}`:null,{isLoading:g,data:I,mutate:R}=G(t?[`${j}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([T,$])=>Q(T,$)),{data:D}=G(t&&y?[y,t]:null,([T,$])=>Q(T,$)),{data:C}=G(t&&u?[u,t]:null,([T,$])=>Q(T,$)),f=t&&h?[h,t]:null,{isLoading:p,data:b}=G(f,([T,$])=>Q(T,$)),{Status:A="Failed",pagination:{total_rows:O=0}={}}=I||{},{data:L=[]}=A==="Success"?I:{},U=i.useMemo(()=>{const T=D?.data??D??[];return Array.isArray(T)?T:[]},[D]),v=i.useMemo(()=>{const T=C?.data??C??[];return(Array.isArray(T)?T:[]).map(B=>{if(B==null)return null;if(typeof B=="string"||typeof B=="number")return{label:String(B),value:B};const Y=B.value??B.vehicle_id??B.id??B.vehicleID,ne=B.label??B.vehicle_name??B.vehicle_no??B.vehicle_number??B.name??String(Y??"");return Y==null||ne===""?null:{label:String(ne),value:Y}}).filter(Boolean)},[C]),M=i.useMemo(()=>{const T=b?.data??b??[];return(Array.isArray(T)?T:[]).map(B=>B?.value??B?.vehicle_id??B?.id??B).filter(B=>B!=null)},[b]);i.useEffect(()=>{x(M)},[M,n]);const P=async(T,$,B)=>{try{await R(Ye(T,$,t),st($)),h&&G.mutate(f),a(Y=>!Y),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(Y){_.error(Y?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},N=T=>{T.preventDefault();const $=new FormData;$.append("route_id",l??""),c.length?c.forEach(B=>$.append("vehicle_ids[]",B)):$.append("vehicle_ids[]",""),P(w,$)},E=T=>{o($=>({...$,pagination:{current:T,pageSize:$.pagination.pageSize}}))},F=async T=>{try{await R(at(m,T,t),Qe(T)),h&&G.mutate(f),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},q=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(T,$,B)=>e.jsx(e.Fragment,{children:$.children.map((Y,ne,H)=>e.jsx("span",{children:`${Y.vehicle_name} ${ne+1===H.length?"":","}`},`${ne}vehicle001`))})},{title:"Action",render:(T,$,B)=>e.jsx(e.Fragment,{children:e.jsx(lt,{id:$?.route_id,funcName:F})})}],z=T=>{const $=["route_id","index"];for(let B=0;B<$.length;B++)if(T[$[B]])return T[$[B]]},k=T=>{const{children:$=[]}=T||{},B=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:Y=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:Y=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:Y=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:Y=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:Y=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:Y=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:Y=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(s.Table,{components:{body:{cell:Dr}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:B,rowKey:Y=>z(Y)+"cell01",dataSource:$,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:T=>{d(T?.value??null),a($=>!$)}})}),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(s.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:v,value:c,onChange:T=>x(T),disabled:!l||p})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),x([]),a(T=>!T)},style:ic,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(de,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:Dr}},columns:q,bordered:!0,rowKey:T=>z(T),dataSource:Array.isArray(L)?L:[],loading:g,expandable:{expandedRowRender:k,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:O,showSizeChanger:!0,onChange:E,onShowSizeChange:(T,$)=>{o(B=>({...B,pagination:{current:1,pageSize:$}}))},showTotal:(T,$)=>`${$[0]}-${$[1]} of ${T} items`}})})]})})]})})]})}const lc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},dc={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},cc=(t,n,a)=>n?t>ae(a).endOf("day")||t<ae(n).endOf("day"):!1,gt=i.forwardRef(function(n,a){const{...r}=n;return e.jsxs("div",{className:"form-group",children:[r.Desplay&&e.jsx("label",{className:`labelfont ${r.classnme?r.classnme:""}`,style:lc,children:r.Desplay}),e.jsx(s.DatePicker,{...r,style:{...dc,...r.style||{}},className:"form-group",disabledDate:o=>cc(o,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:a})]})}),kr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ss=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Qt=(t,n,a)=>{if(n==null||n==="")return null;const r=t.find(o=>String(o.value)===String(n));return r||(a?{label:String(a),value:n}:{label:String(n),value:n})},uc=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},pc=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(a=>a!=null&&a!==""&&String(a).toLowerCase()!=="null"&&String(a).toLowerCase()!=="undefined").join(", ");const n=String(t).trim();return!n||n.toLowerCase()==="null"||n.toLowerCase()==="undefined"?"":n};function mc({token:t,assignmentId:n,studentName:a,onClose:r,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",x="api/branchapi/Transport/getvehicleListByRouteIdwithCount",y="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[S,j]=i.useState(null),[w,m]=i.useState(null),[h,g]=i.useState(null),[I,R]=i.useState(ae()),[D,C]=i.useState(""),[f,p]=i.useState(0),[b,A]=i.useState(0),{data:O,isLoading:L}=G(t&&n?[`${l}?id=${n}`,t]:null,([V,oe])=>Q(V,oe)),U=i.useMemo(()=>{if(!O||O?.Status&&O.Status!=="Success")return null;const V=O?.data??O;return Array.isArray(V)?V[0]??null:V},[O]);i.useEffect(()=>{const V=U?.fk_route_id??U?.route_id;V!=null&&j(V),U?.vehicle_id!=null&&m(U.vehicle_id),U?.stop_id!=null&&g(U.stop_id),R(U?.start_date?ae(U.start_date):ae()),C(pc(U?.service_push))},[U]);const v=t&&S?`${x}?route_id=${S}`:null,M=t&&S?`${u}?id=${S}`:null,P=t&&S?`${y}?route_id=${S}`:null,{data:N}=G(t&&c?[c,t]:null,([V,oe])=>Q(V,oe)),{data:E,isLoading:F}=G(v?[v,t]:null,([V,oe])=>Q(V,oe)),{data:q,isLoading:z}=G(P?[P,t]:null,([V,oe])=>Q(V,oe)),{data:k}=G(M?[M,t]:null,([V,oe])=>Q(V,oe)),T=i.useMemo(()=>ss(N),[N]),$=i.useMemo(()=>ss(E),[E]),B=i.useMemo(()=>ss(q),[q]),Y=O?.data[0]?.rootCost,ne=uc(),H=a||[U?.firstname,U?.lastname].filter(Boolean).join(" ")||"",W=(V,oe)=>{switch(oe){case"route_id":j(V?.value??null),m(null),g(null),p(Ce=>Ce+1),A(Ce=>Ce+1);break;case"vehicle_id":m(V?.value??null),g(null),A(Ce=>Ce+1);break;case"stop_id":g(V?.value??null);break}},Z=async V=>{if(V.preventDefault(),!S||!w||!h){_.error("Please select Route, Vehicle and Stop",{duration:1200});return}const oe=new FormData;oe.append("id",String(n)),oe.append("student_id",String(U?.fk_student_id??U?.student_id??"")),oe.append("fk_route_id",String(S)),oe.append("vehicle_id",String(w)),oe.append("stop_id",String(h)),oe.append("rootCost",String(Y??"")),oe.append("start_date",I?.isValid?.()?I.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),oe.append("puse_service",String(D??""));try{await pt(d,oe,t),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),r?.()}catch(Ce){_.error(Ce?.message??"Failed to update the item.",{duration:1e3})}};if(L||!(U&&!L&&(!S||!F&&!z)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(s.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(s.Button,{type:"text",onClick:r,style:kr,children:"Close"})]});const pe=U.fk_route_id??U.route_id,ve=Qt(T,pe,U.route_title),re=Qt($,U.vehicle_id,U.vehicle_name??U.vehicle_no),ie=Qt(B,U.stop_id,U.stop_name??U.stoppage_name);return e.jsx("form",{onSubmit:Z,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"title",label:"Student",defaultValue:H,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:U.fk_student_id??U.student_id??""}),e.jsx(ee,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:Qt(T,S,ve?.label)??null,onChange:V=>W(V,"route_id")}),e.jsx(ee,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Qt($,w,re?.label)??null,onChange:V=>W(V,"vehicle_id")},`edit-vehicle-${f}`),e.jsx(ee,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Qt(B,h,ie?.label)??null,onChange:V=>W(V,"stop_id")},`edit-stop-${b}`),e.jsx(J,{type:"text",label:"Route Cost",value:Y!=null?`${ne}${Y}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:Y??""}),e.jsx(gt,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:I,onChange:V=>R(V)}),e.jsx(J,{type:"text",label:"Pause Service",value:D,onChange:V=>C(V?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:r,style:kr,children:"Cancel"})]})]})},`edit-${n}-${f}`)}const Or={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},yc=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[]},gn=t=>yc(t),fc=t=>t||"",hc=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},gc=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},xc=(t,n)=>{const a=n||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",o=encodeURIComponent(String(r));if(a.includes("{id}"))return a.replaceAll("{id}",o);if(a.includes(":id"))return a.replace(":id",o);try{const d=new URL(a,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(r)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=a.includes("?")?"&":"?";return`${a}${l}id=${o}`};function bc({token:t,editType:n,onNavigate:a,editPagePath:r}){const l=gc(n)==="drawer",d="api/branchapi/academy/classdropdownlist",c="api/branchapi/academy/sectionoftheClass",x="api/branchapi/Transport/routeStudentList",y="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleListByRouteIdwithCount",S="api/branchapi/Transport/getStoppageDropdown",j="api/branchapi/Transport/routeShowdata",w="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",[h,g]=i.useState(null),[I,R]=i.useState(!1),[D,C]=i.useState(!1),[f,p]=i.useState(null),[b,A]=i.useState(null),[O,L]=i.useState(null),[U,v]=i.useState(null),[M,P]=i.useState(!1),[N,E]=i.useState(!1),[F,q]=i.useState({page:1,rowsPerPage:50}),[z,k]=i.useState(null),[T,$]=i.useState(!1),[B,Y]=i.useState(null),[ne,H]=i.useState(null),[W,Z]=i.useState(null),[se,pe]=i.useState(null),[ve,re]=i.useState(null),[ie,V]=i.useState(null),[oe,Ce]=i.useState(null),[Oe,Pe]=i.useState(ae()),[Ne,Ee]=i.useState(""),Ve=(ye,be)=>{const Fe=ye?.value??null;switch(be){case"class_id":Z(Fe),pe(null),k(Fe?`${c}?class_id=${encodeURIComponent(String(Fe))}`:null),R(jt=>!jt);break;case"route_id":re(Fe),V(null),Ce(null),H(Fe),A(Fe?`${u}?route_id=${encodeURIComponent(String(Fe))}`:null),L(Fe?`${j}?id=${encodeURIComponent(String(Fe))}`:null),v(null),P(jt=>!jt),E(jt=>!jt);break;case"vehicle_id":V(Fe),Ce(null),v(ve?`${S}?route_id=${encodeURIComponent(String(ve))}`:null),E(jt=>!jt);break;case"stop_id":Ce(Fe);break}},He=ye=>{if(l){p(ye),C(!0);return}const be=xc(ye,r);if(typeof a=="function"){a(be,ye);return}typeof window<"u"&&be&&window.location.assign(be)},Be=()=>{C(!1),p(null)},We=f?`Edit — ${f.firstname??""} ${f.lastname??""}`.trim():"Edit Student Transport",{data:rt}=G(t&&d?[d,t]:null,([ye,be])=>Q(ye,be)),{data:fe}=G(t&&z?[z,t]:null,([ye,be])=>Q(ye,be)),{data:xe}=G(t&&b?[b,t]:null,([ye,be])=>Q(ye,be)),{data:ge}=G(t&&U?[U,t]:null,([ye,be])=>Q(ye,be)),{data:te}=G(t&&O?[O,t]:null,([ye,be])=>Q(ye,be)),{data:me}=G(t&&y?[y,t]:null,([ye,be])=>Q(ye,be)),he=t&&h?`${h}&page=${F.page}&per_page=${F.rowsPerPage}`:null,{isLoading:Te,error:Re,data:ft,mutate:At}=G(he?[he,t]:null,([ye,be])=>Q(ye,be)),Tt=i.useMemo(()=>gn(rt),[rt]),Vt=i.useMemo(()=>gn(fe),[fe]),Ht=i.useMemo(()=>gn(xe),[xe]),Kt=i.useMemo(()=>gn(ge),[ge]),ue=i.useMemo(()=>gn(me),[me]),Se=te?.data?.[0]?.fare??te?.data?.fare??te?.fare??te?.data?.data?.[0]?.fare??te?.data?.data?.fare;console.log("aaaaaaaaaaaa",te),i.useEffect(()=>{Se==null||Se===""||Ee(String(Se))},[Se]);const Ge=async ye=>{try{await At(at(m,ye,t),Qe(ye)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},St=[{title:"Route Status",key:"route_status",render:(ye,be)=>be.fk_route_id?e.jsx("span",{children:be.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(ye,be)=>fc(be.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:(ye,be)=>`${be.firstname} ${be.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(ye,be)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:be.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(lt,{id:be?.id,funcName:Ge}),e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>He(be),style:{padding:2}})]}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.PlusOutlined,{}),onClick:()=>Ya(be.student_id),style:{padding:2}})})}],La=async(ye,be)=>{try{await At(Ye(ye,be,t),st(be)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),$(!1),je()}catch{_.error("Failed to add the new item.",{duration:1e3})}},qa=ye=>{if(ye.preventDefault(),!W||!se){_.error("Please select Class and Section",{duration:1200});return}g(`${x}?cID=${encodeURIComponent(String(W))}&sID=${encodeURIComponent(String(se))}`),q(be=>({...be,page:1}))},za=(ye,be)=>{q({page:ye,rowsPerPage:parseInt(be,10)})},Ya=ye=>{Y(ye),$(!0)},le=ye=>{if(ye.preventDefault(),!B){_.error("Student is required",{duration:1200});return}if(!ve||!ie||!oe){_.error("Please select Route, Vehicle and Stop",{duration:1300});return}const be=new FormData;be.append("student_id",String(B)),be.append("fk_route_id",String(ve)),be.append("vehicle_id",String(ie)),be.append("stop_id",String(oe)),be.append("start_date",Oe?.isValid?.()?Oe.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),be.append("rootCost",String(Ne??"")),La(w,be)},je=()=>{$(!1),A(null),L(null),v(null),H(null),re(null),V(null),Ce(null),Pe(ae()),Ee(""),P(ye=>!ye),E(ye=>!ye)},ke=hc();return e.jsxs("div",{children:[l&&e.jsx(s.Drawer,{open:D,title:We,placement:"right",width:420,destroyOnClose:!0,onClose:Be,children:f?.id&&e.jsx(mc,{token:t,assignmentId:f.id,studentName:`${f.firstname??""} ${f.lastname??""}`.trim(),onClose:Be,onSuccess:()=>At()})}),e.jsx(s.Modal,{open:T,title:"Assign Student to Transport",onCancel:je,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:le,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[e.jsx(ee,{options:ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:ue.find(ye=>String(ye.value)===String(ve))??null,onChange:ye=>Ve(ye,"route_id")}),e.jsx(ee,{options:Ht,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Ht.find(ye=>String(ye.value)===String(ie))??null,onChange:ye=>Ve(ye,"vehicle_id")},`vehicle001${M}`),e.jsx(ee,{options:Kt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Kt.find(ye=>String(ye.value)===String(oe))??null,onChange:ye=>Ve(ye,"stop_id")},`stop001${N}`),e.jsx(gt,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Oe,onChange:ye=>Pe(ye)}),e.jsx(J,{type:"text",name:"rootCost",label:"Route Cost",value:Ne,onChange:ye=>Ee(ye?.target?.value??"")}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:String(Ne??"").trim()?`${ke}${Ne} — Assign`:"Assign",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:je,style:Or,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Search Students"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:qa,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:Tt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:ye=>Ve(ye,"class_id"),required:!0,allowSelectAll:!1,value:Tt.find(ye=>String(ye.value)===String(W))??null}),e.jsx(ee,{options:Vt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:Vt.find(ye=>String(ye.value)===String(se))??null,onChange:ye=>pe(ye?.value??null)},`section1${I}`),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Search",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{g(null),k(null),Z(null),pe(null),R(ye=>!ye)},style:Or,children:"Cancel"})]})]})})})]}),h&&e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Student List"})}),e.jsx(de,{children:e.jsx(Le,{parentCallback:za,data:{newData:ft,columns:St,columnstype:"antd",action:!1,Loading:Te,error:Re,deleteTodoMutation:Ge,pageController:F}})})]})})]})})]})}const Pr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Kn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Sc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[y,u]=i.useState(""),[S,j]=i.useState(""),[w,m]=i.useState(!1),h=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,g="api/branchapi/Transport/add_driver",I="api/branchapi/Transport/edit_driver",R="api/branchapi/Transport/deletedriver",D="api/branchapi/staff/uploadDocuments",C=i.useMemo(()=>String(D).startsWith("http")?D:`${nt()??""}${String(D).replace(/^\/+/,"")}`,[D]),f=nt()??"",{isLoading:p,data:b,error:A,mutate:O}=G(t?[h,t]:null,([z,k])=>Q(z,k)),L=async(z,k)=>{try{await Ye(z,k,t),await O(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),x("")}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},U=z=>{z.preventDefault();const k=new FormData(z.target);L(g,k),z.target.reset()},v=async z=>{try{await O(at(R,z,t),Qe(z)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},M=z=>{d(z),x(z?.image??""),o(!0)},P=async z=>{try{await pt(I,z,t),await O(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(k){_.error(k?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},N=z=>{z.preventDefault();const k=new FormData(z.target);k.append("id",l?.id??""),P(k)},E=(z,k)=>{a({page:z,rowsPerPage:parseInt(k,10)})},F=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(z,k)=>String(z?.name??"").localeCompare(String(k?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(z,k)=>String(z?.Driver_licence??"").localeCompare(String(k?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(z,k)=>Number(z?.contact_number??0)-Number(k?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(z,k)=>String(z?.address??"").localeCompare(String(k?.address??""))}},{title:"Image",key:"image",width:100,render:(z,k)=>{const T=k?.image?`${f}staff/document/${k.image}`:"";return T?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(s.Image,{width:80,src:T,preview:{visible:!1,onVisibleChange:()=>{m(!0),u(T),j(k?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(z,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>M(k),style:{padding:2}}),e.jsx(lt,{id:k?.id,funcName:v})]})}],q=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:q,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(J,{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:Kn,children:"Address"}),e.jsx(s.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:Kn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const k=z?.file?.response,T=k?.data??k?.filename??k?.file??k?.path??"";T&&x(String(T))},children:e.jsx(s.Button,{icon:e.jsx(X.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(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Pr,children:"Cancel"})]})]})})}),e.jsx(s.Modal,{zIndex:9999,open:w,title:S,footer:null,onCancel:()=>m(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:y})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(de,{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(J,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(J,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(J,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Kn,children:"Address"}),e.jsx(s.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:Kn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const k=z?.file?.response,T=k?.data??k?.filename??k?.file??k?.path??"";T&&x(String(T))},children:e.jsx(s.Button,{icon:e.jsx(X.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(ce,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>x(""),style:Pr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(de,{children:e.jsx(Le,{parentCallback:E,data:{newData:b,columns:F,columnstype:"antd",action:!1,Loading:p,error:A,deleteTodoMutation:v}})})]})})]})})]})}const Er={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Xt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Gn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Mr=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],Jn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function jc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,x]=i.useState(null),[y,u]=i.useState(null),[S,j]=i.useState(null),[w,m]=i.useState(null),[h,g]=i.useState(ae()),[I,R]=i.useState(ae()),[D,C]=i.useState("pick"),[f,p]=i.useState(!1),[b,A]=i.useState(null),[O,L]=i.useState(null),[U,v]=i.useState(!1),[M,P]=i.useState(null),[N,E]=i.useState(null),[F,q]=i.useState(null),[z,k]=i.useState(null),[T,$]=i.useState(ae()),[B,Y]=i.useState(ae()),[ne,H]=i.useState("pick"),W=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,Z="api/branchapi/Transport/assignRouteTime",se="api/branchapi/Transport/editAssignRouteTime",pe="api/branchapi/Transport/deleteAssignRouteTime",ve="api/branchapi/Transport/driverDropdown",re="api/branchapi/transport/routeTimetableShowdata",ie="api/branchapi/Transport/getrouteDropdown",V="api/branchapi/Transport/getvehicleDropdown",{isLoading:oe,data:Ce,error:Oe,mutate:Pe}=G(t?[W,t]:null,([ue,Se])=>Q(ue,Se)),{data:Ne}=G(t&&ie?[ie,t]:null,([ue,Se])=>Q(ue,Se)),{data:Ee}=G(t&&ve?[ve,t]:null,([ue,Se])=>Q(ue,Se)),Ve=i.useMemo(()=>c?`${V}?route_id=${c}`:null,[c,V]),{data:He}=G(t&&Ve?[Ve,t]:null,([ue,Se])=>Q(ue,Se)),Be=i.useMemo(()=>Jn(Ne),[Ne]),We=i.useMemo(()=>Jn(Ee),[Ee]),rt=i.useMemo(()=>Jn(He),[He]),fe=(ue,Se)=>{a({page:ue,rowsPerPage:parseInt(Se,10)})},xe=async ue=>{ue.preventDefault();const Se=new FormData(ue.target);Se.set("route_id",y?.value??c??""),Se.set("driver_id",S?.value??""),Se.set("vehicle_id",w?.value??""),Se.set("start_time",h?h.format("h:mm a"):""),Se.set("drop_time",I?I.format("h:mm a"):""),Se.set("type",D);try{await Ye(Z,Se,t),await Pe(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),ue.target.reset(),x(null),u(null),j(null),m(null),d(Ge=>!Ge),g(ae()),R(ae()),C("pick"),o(Ge=>!Ge)}catch(Ge){_.error(Ge?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},ge=async ue=>{try{await at(pe,ue,t),await Pe(),_.success("Success! Deleted item.",{duration:1e3})}catch(Se){_.error(Se?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},te=ue=>{A(ue),p(!0);const Se=ue?.id??ue?.route_time_id??ue?.routeId??null;L(Se);const Ge=ue?.route_id??ue?.routeId??ue?.fk_route_id;P(Ge??null),E(Be.find(St=>St?.value===(Ge??ue?.route_id))??null),q(We.find(St=>St?.value===(ue?.driver_id??ue?.driverId))??null),k(null),v(St=>!St),$(ue?.start_time?ae(ue.start_time,["h:mm a","HH:mm"]):ae()),Y(ue?.drop_time?ae(ue.drop_time,["h:mm a","HH:mm"]):ae()),H(ue?.type??"pick")},me=i.useMemo(()=>{if(!O)return null;const ue=String(re).includes("?")?"&":"?";return`${re}${ue}id=${encodeURIComponent(String(O))}`},[O,re]),{data:he,isLoading:Te}=G(t&&me?[me,t]:null,([ue,Se])=>Q(ue,Se)),Re=i.useMemo(()=>{const ue=he?.data??he;return Array.isArray(ue)?ue[0]??null:Array.isArray(ue?.data)?ue.data[0]??null:ue??null},[he]),ft=i.useMemo(()=>M?`${V}?route_id=${M}`:null,[M,V]),{data:At}=G(t&&ft?[ft,t]:null,([ue,Se])=>Q(ue,Se)),Tt=i.useMemo(()=>Jn(At),[At]);i.useEffect(()=>{if(!Re)return;const ue=Re?.route_id??Re?.fk_route_id??Re?.routeId;P(ue??null),E(Be.find(Se=>Se?.value===ue)??null),q(We.find(Se=>Se?.value===Re?.driver_id)??null),k(null),$(Re?.start_time?ae(Re.start_time,["h:mm a","HH:mm"]):ae()),Y(Re?.drop_time?ae(Re.drop_time,["h:mm a","HH:mm"]):ae()),H(Re?.type??"pick"),v(Se=>!Se)},[We,Re,Be]),i.useEffect(()=>{if(!Re)return;const ue=Re?.vehicle_id??Re?.vehicleId;ue&&k(Tt.find(Se=>Se?.value===ue)??null)},[Re,Tt]);const Vt=async ue=>{if(ue.preventDefault(),!O)return;const Se=new FormData(ue.target);Se.set("id",String(O)),Se.set("route_id",N?.value??M??""),Se.set("driver_id",F?.value??""),Se.set("vehicle_id",z?.value??""),Se.set("start_time",T?T.format("h:mm a"):""),Se.set("drop_time",B?B.format("h:mm a"):""),Se.set("type",ne);try{await pt(se,Se,t),await Pe(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),p(!1),A(null)}catch(Ge){_.error(Ge?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Ht=[{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:(ue,Se)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>te(Se),style:{padding:2}}),e.jsx(lt,{id:Se?.id??Se?.routeId??Se?.route_time_id,funcName:ge})]})}],Kt=b?.route_title?`Edit ${b.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:f,title:Kt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{p(!1),A(null),L(null),P(null),E(null),q(null),k(null)},children:e.jsx("form",{onSubmit:Vt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Te?.6:1},children:[e.jsx(ee,{options:Be,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:N,onChange:ue=>{P(ue?.value??null),E(ue??null),k(null),v(Se=>!Se)}}),e.jsx(ee,{options:We,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:F,onChange:ue=>q(ue??null)}),e.jsx(ee,{options:Tt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:z,onChange:ue=>k(ue??null)},`edit-vehicle-${U}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Start Time"}),e.jsx(s.TimePicker,{value:T,onChange:ue=>$(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:B,onChange:ue=>Y(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Mr,optionType:"button",buttonStyle:"solid",value:ne,onChange:ue=>H(ue.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{p(!1),A(null)},style:Er,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:xe,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:Be,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:y,onChange:ue=>{x(ue?.value??null),u(ue??null),m(null),d(Se=>!Se)},allowSelectAll:!1,required:!0}),e.jsx(ee,{options:We,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:S,onChange:ue=>j(ue??null),allowSelectAll:!1,required:!0}),e.jsx(ee,{options:rt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:w,onChange:ue=>m(ue??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Start Time"}),e.jsx(s.TimePicker,{value:h,onChange:ue=>g(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:I,onChange:ue=>R(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Mr,optionType:"button",buttonStyle:"solid",value:D,onChange:ue=>C(ue.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>{x(null),u(null),j(null),m(null),d(ue=>!ue),g(ae()),R(ae()),C("pick"),o(ue=>!ue)},style:Er,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(de,{children:e.jsx(Le,{parentCallback:fe,data:{newData:Ce,columns:Ht,columnstype:"antd",action:!1,Loading:oe,error:Oe,deleteTodoMutation:ge}})})]})})]})})]})}const vc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Fr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Nr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},$r=({dataIndex:t,title:n,record:a,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let Ur=2;function _c({token:t}){const[n,a]=i.useState([]),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:y,data:u,mutate:S}=G(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([P,N])=>Q(P,N)),{Status:j="Failed",pagination:{total_rows:w=0}={}}=u||{},{data:m=[]}=j==="Success"?u:{},{data:h}=G(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([P,N])=>Q(P,N)),g=i.useMemo(()=>{const P=h?.data??h??[];if(Array.isArray(P))return P;if(P&&typeof P=="object"){if(Array.isArray(P?.data))return P.data;if(Array.isArray(P?.data?.data))return P.data.data}return[]},[h]),{data:I}=G(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([P,N])=>Q(P,N)),{Status:R="Failed"}=I||{},D=async(P,N)=>{try{await S(Ye(P,N,t),st(N)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},C=P=>P?typeof P=="string"?P:P?.isValid?.()?P.format("h:mm a"):"":"",f=(P,N=[])=>{const E=(Array.isArray(P)?P:[]).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)})),F=E.filter(z=>z?.id!=null&&String(z.id).trim()!==""),q=E.filter(z=>!(z?.id!=null&&String(z.id).trim()!==""));return{route_id:r??"",edit_stoppage:F,add_stoppage:q,delete_stoppage:Array.isArray(N)?N:[]}},p=P=>{P.preventDefault();const N="/api/branchapi/transport/addstoppageToRoute",E=f(n,l);D(N,E)},b=()=>{a(P=>[...Array.isArray(P)?P:[],{idKey:Ur++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}])},A=P=>{if(n.length===1)return;const N=n[P];N?.id!=null&&String(N.id).trim()!==""&&!N?.idKey&&d(E=>{const F=Array.isArray(E)?E:[];return F.some(z=>String(z)===String(N.id))?F:[...F,N.id]}),a(E=>{const F=[...E];return F.splice(P,1),F})},O=P=>{x(N=>({...N,pagination:{current:P,pageSize:N.pagination.pageSize}}))},L=async P=>{const N="/api/branchapi/Transport/deletevehicle";try{await S(at(N,P,t),Qe(P)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(R==="Success"){const P=Array.isArray(I?.data)?I.data:[];P.length>0?(a(P),d([])):r&&(a([{idKey:Ur++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}]),d([]))}},[R,I,r]);const U=P=>{const{children:N=[]}=P||{},E=[{title:"Stop Name",dataIndex:"stop_name",onCell:F=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:F=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:F=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(s.Table,{components:{body:{cell:$r}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:E,rowKey:F=>v(F)+"cell01",dataSource:N,pagination:!1})})})},v=P=>{const N=["id","index"];for(let E=0;E<N.length;E++)if(P[N[E]])return P[N[E]]},M=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(P,N,E)=>e.jsx(e.Fragment,{children:(Array.isArray(N.children)?N.children:[]).map((F,q,z)=>e.jsx("span",{children:`${F.stop_name} ${q+1===z.length?"":","}`},`${q}vehicle001`))})},{title:"Action",render:(P,N,E)=>e.jsx(e.Fragment,{children:e.jsx(lt,{id:N?.route_id,funcName:L})})}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(de,{pt:5,pb:1,children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(de,{px:3,pb:2,children:e.jsxs("form",{onSubmit:p,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(ee,{options:g,value:g.find(P=>String(P.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:P=>{o(P?.value??null),a([]),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:b,children:e.jsx(X.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(ce,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),a([]),d([])},style:vc,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((P,N)=>{const E=P.pickup_time?ae(P.pickup_time,"h:mm a"):null,F=P.drop_time?ae(P.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(J,{value:P.stop_name??"",type:"text",name:`stoppage[${N}][name]`,label:"Place Name*",required:"required",onChange:q=>{const z=q?.target?.value??"";a(k=>{const T=[...k];return T[N]={...T[N]??{},stop_name:z},T})}}),P?.id!=null&&String(P.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${N}][id]`,value:String(P.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Fr,children:"Pick Time"}),e.jsx(s.TimePicker,{value:E,use12Hours:!0,format:"h:mm a",name:`stoppage[${N}][pickTime]`,allowClear:!1,style:Nr,onChange:q=>{const z=q?q.format("h:mm a"):"";a(k=>{const T=[...k];return T[N]={...T[N]??{},pickup_time:z},T})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Fr,children:"Drop Time"}),e.jsx(s.TimePicker,{value:F,use12Hours:!0,format:"h:mm a",name:`stoppage[${N}][drop_time]`,allowClear:!1,style:Nr,onChange:q=>{const z=q?q.format("h:mm a"):"";a(k=>{const T=[...k];return T[N]={...T[N]??{},drop_time:z},T})}})]}),e.jsx("div",{style:{marginBottom:8},children:n.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>A(N),children:e.jsx(X.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},P.idKey?P.idKey+"exp":P.id+"exp")})})]})}),e.jsx(de,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(de,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:$r}},columns:M,bordered:!0,size:"small",rowKey:P=>v(P),dataSource:m,loading:y,expandable:{expandedRowRender:U,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:w,showSizeChanger:!0,onChange:O,onShowSizeChange:(P,N)=>{x(E=>({...E,pagination:{current:1,pageSize:N}}))},showTotal:(P,N)=>`${N[0]}-${N[1]} of ${P} items`}})})]})]})}const wc=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`};function Cc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState(null),[o,l]=i.useState(null),[d,c]=i.useState(null),[x,y]=i.useState(null),[u,S]=i.useState(null),[j,w]=i.useState(null),[m,h]=i.useState(null),g="api/branchapi/library/bookCategorydropdown",I="api/branchapi/academy/classdropdownlist",R="api/branchapi/Academy/getClassSubjectdropdown",D="api/branchapi/library/addBook",C="api/branchapi/library/uploadcsv",{data:f}=G(n?[g,n]:null,([v,M])=>Q(v,M)),{data:p}=G(n&&I?[I,n]:null,([v,M])=>Q(v,M)),{data:b}=G(n&&R?[R,n]:null,([v,M])=>Q(v,M)),A=i.useMemo(()=>wc(nt(),C),[C]),O=async v=>{v.preventDefault();const M=new FormData(v.target);M.set("cat_id",u?.value??""),M.set("class_id",j?.value??""),M.set("subject_id",m?.value??"");try{await Ye(D,M,n),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),v.target.reset(),S(null),w(null),h(null)}catch(P){_.error(P?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},L=async v=>{if(v.preventDefault(),!a){_.error("Please select a CSV file.",{duration:1e3});return}const M=new FormData;M.append("file",a),M.append("cat_id",o?.value??""),M.append("class_id",d?.value??""),M.append("subject_id",x?.value??"");try{const P=await $e.post(A,M,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});P?.data?.Status==="Failed"?_.error(String(P?.data?.msg??"Upload failed."),{duration:1e3}):(_.success(String(P?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),r(null),v.target.reset(),l(null),c(null),y(null))}catch(P){_.error(P?.response?.data?.msg??"Upload failed.",{duration:1e3})}},U=()=>{fetch("/books.csv").then(v=>{v.blob().then(M=>{const P=window.URL.createObjectURL(M);let N=document.createElement("a");N.href=P,N.download="/books.csv",N.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(s.Button,{type:"link",icon:e.jsx(X.DownloadOutlined,{}),onClick:U,children:"Download Sample"}),children:[e.jsx(s.Divider,{children:"Information"}),e.jsx(s.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:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:v=>l(v??null)}),e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:v=>c(v??null)}),e.jsx(ee,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:x,onChange:v=>y(v??null)}),e.jsx(J,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:v=>r(v.target.files?.[0]??null),required:!0}),e.jsx(ce,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(J,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(J,{type:"text",label:"Publication",name:"publisher"}),e.jsx(J,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(J,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(J,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(J,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:v=>S(v??null)}),e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:j,onChange:v=>w(v??null)}),e.jsx(ee,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:m,onChange:v=>h(v??null)}),e.jsx(ce,{type:"submit",value:"Save",color:"primary"})]})})})]})}const rs={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},is=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Ac({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:a,onChange:(Z,se)=>{r(Z),l(se)}},x=ln.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),y=()=>{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}x?.()}},[u,S]=i.useState(!1),[j,w]=i.useState(null),[m,h]=i.useState(null),[g,I]=i.useState(null),[R,D]=i.useState(null),[C,f]=i.useState({page:1,rowsPerPage:10}),p=(Z,se)=>{f({page:Z,rowsPerPage:parseInt(se,10)})},b="api/branchapi/library/booktable",A="api/branchapi/library/deletebooks",O="api/branchapi/library/editbook",L=`${b}?page=${C.page}&per_page=${C.rowsPerPage}`,{isLoading:U,error:v,data:M,mutate:P}=G(n?[L,n]:null,([Z,se])=>Q(Z,se)),N="api/branchapi/library/bookCategorydropdown",E="api/branchapi/academy/classdropdownlist",F="api/branchapi/Academy/getClassSubjectdropdown",{data:q}=G(n?[N,n]:null,([Z,se])=>Q(Z,se)),{data:z}=G(n&&E?[E,n]:null,([Z,se])=>Q(Z,se)),{data:k}=G(n&&F?[F,n]:null,([Z,se])=>Q(Z,se)),T=i.useMemo(()=>is(q),[q]),$=i.useMemo(()=>is(z),[z]),B=i.useMemo(()=>is(k),[k]),Y=async Z=>{try{await at(A,Z,n),await P(),_.success("Success! Deleted item.",{duration:1e3})}catch(se){_.error(se?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ne=Z=>{w(Z??null);const se=Z?.cat_id??Z?.fk_cat_id??Z?.category_id,pe=Z?.class_id??Z?.fk_class_id,ve=Z?.subject_id??Z?.fk_subject_id;h(T.find(re=>re?.value===se)??null),I($.find(re=>re?.value===pe)??null),D(B.find(re=>re?.value===ve)??null),S(!0)},H=async Z=>{Z.preventDefault();const se=j?.id??j?.book_id??j?._id;if(!se)return;const pe=new FormData(Z.target);pe.set("id",String(se)),pe.set("cat_id",m?.value??""),pe.set("class_id",g?.value??""),pe.set("subject_id",R?.value??"");try{await pt(O,pe,n),await P(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),S(!1),w(null)}catch(ve){_.error(ve?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},W=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:(Z,se)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>ne(se),style:{padding:2}}),e.jsx(s.Button,{type:"text",size:"small",danger:!0,onClick:()=>Y(se?.id??se?.book_id??se?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[T,$,Y,B]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:u,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{S(!1),w(null)},children:e.jsx("form",{onSubmit:H,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(J,{label:"Book Name",name:"title",defaultValue:j?.book_title??"",required:!0}),e.jsx(J,{label:"Author",name:"author",defaultValue:j?.author??"",required:!0}),e.jsx(J,{label:"Publication",name:"publish",defaultValue:j?.publish??""}),e.jsx(J,{label:"Qty",name:"quantity",type:"number",defaultValue:j?.quantity??""}),e.jsx(J,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:j?.perunitcost??""}),e.jsx(J,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:j?.fine_amount??""}),e.jsx(J,{label:"Barcode",name:"barcode",defaultValue:j?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:rs,children:"Category"}),e.jsx(ee,{options:T,value:m,onChange:Z=>h(Z??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:rs,children:"Class"}),e.jsx(ee,{options:$,value:g,onChange:Z=>I(Z??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:rs,children:"Subject"}),e.jsx(ee,{options:B,value:R,onChange:Z=>D(Z??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{S(!1),w(null)},children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(s.Button,{type:"primary",onClick:y,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Le,{parentCallback:p,data:{newData:M,columns:W,columnstype:"antd",action:!1,Loading:U,error:v,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((Z,se)=>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:Z.book_title}),e.jsx(Ei,{value:Z.barcode?String(Z.barcode):String(Z.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},se))})})})]})}const Tc=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`},Rt=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Qn=t=>ae(t).add(1,"month").format("YYYY-MM-DD");function Rc({token:t,onReturn:n}){const a=t??localStorage.getItem("authToken")??"",[r,o]=i.useState("issue"),l=r==="return",[d,c]=i.useState(!1),[x,y]=i.useState(!1),[u,S]=i.useState(null),[j,w]=i.useState([]),[m,h]=i.useState([]),[g,I]=i.useState([]),[R,D]=i.useState(0),[C,f]=i.useState(!1),[p,b]=i.useState(null),[A,O]=i.useState(null),[L,U]=i.useState(null),[v,M]=i.useState(!1),[P,N]=i.useState("Cash"),[E,F]=i.useState(""),[q,z]=i.useState(""),[k,T]=i.useState(0),[$,B]=i.useState("NO_FINE"),Y=i.useRef(null),[ne]=s.Form.useForm(),[H]=s.Form.useForm(),W="api/branchapi/library/bookCategorydropdown",Z="api/branchapi/academy/classdropdownlist",se="api/branchapi/Academy/getClassSubjectdropdown",{data:pe}=G(a?[W,a]:null,([le,je])=>Q(le,je)),{data:ve}=G(a&&Z?[Z,a]:null,([le,je])=>Q(le,je)),{data:re}=G(a&&se?[se,a]:null,([le,je])=>Q(le,je)),ie=i.useMemo(()=>Rt(pe),[pe]),V=i.useMemo(()=>Rt(ve),[ve]),oe=i.useMemo(()=>Rt(re),[re]),Ce="api/branchapi/library/studentsearchByNameID",Oe="api/branchapi/library/booksearchBybookname",Pe="api/branchapi/library/issuedBookList",Ne="api/branchapi/library/issueLibrarybook",Ee="api/branchapi/library/returnedLibrarybook",{trigger:Ve,data:He}=Je(Ce,(le,je)=>qt(le,je,a)),{trigger:Be,data:We}=Je(Oe,(le,je)=>qt(le,je,a)),{trigger:rt,data:fe}=Je(Pe,(le,je)=>qt(le,je,a)),{trigger:xe}=Je(l?Ee:Ne,(le,je)=>Pa(le,je,a)),ge=i.useMemo(()=>Rt(He),[He]),te=i.useMemo(()=>Rt(We),[We]),me=i.useMemo(()=>Rt(fe),[fe]),he=le=>{const je=Qn(ae());w(ke=>ke.some(ye=>String(ye?.id)===String(le?.id))?ke:[...ke,{...le,return_date:le?.return_date?le.return_date:je}])},Te=()=>!u||!g.length?[]:(JSON.parse(localStorage.getItem("genrall_settings")??"null"),g.map(le=>({studentId:u?.student_id,fromDate:le?.return_date,toDate:le?.issue_date,customField1:le?.book_issues_id,description:`${le?.book_title}-${le?.author}`,amount:Number(le?.totalfine??0)}))),Re=le=>{w(je=>je.filter(ke=>String(ke?.id)!==String(le)))},ft=async le=>{if(a){if(!le){S(null);return}d||await Ve({id:le})}},At=async({search:le})=>{if(!a||!d)return;const je=await Ve({id:le}),ke=Rt(je);ke.length===1&&(S(ke[0]),await rt({id:ke[0]?.student_id}),ne.resetFields())},Tt=async(le,je)=>{S(je??null),w([]),h([]),I([]),D(0),B("NO_FINE"),T(0),je?.student_id&&await rt({id:je.student_id}),ne.resetFields()},Vt=async le=>{a&&le&&(x||await Be({book:le}))},Ht=async({search_book:le})=>{if(!a||!x)return;const je=await Be({book:le,catID:p?.value??"",sID:L?.value??"",cID:A?.value??""}),ke=Rt(je);ke.length&&(he(ke[0]),H.resetFields())},Kt=(le,je)=>{he(je),H.resetFields()},ue=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!j.length){_.error("Select at least one book.",{duration:1e3});return}const le=await xe({member_id:u.member_id,fine:!1,books:j});le?.Status==="Success"&&(_.success(String(le?.msg??"Success"),{duration:1e3}),w([]),S(null),h([]),I([]),D(0))},Se=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!g.length){_.error("Select at least one book to return.",{duration:1e3});return}if(Number(R)>0){B("FINE_PAID"),M(!0);return}const le=await xe({member_id:u.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(g)});le?.Status==="Success"?(_.success(String(le?.msg??"Success"),{duration:1e3}),h([]),I([]),D(0),await rt({id:u?.student_id})):_.error(String(le?.msg??"Failed"),{duration:1e3})},Ge=async()=>{if(!u?.member_id)return;const le=Math.max(0,Number(R)-Number(k||0)),je={member_id:u.member_id,collection_type:$,amount:$==="FINE_PAID"?le:0,payment_type:P,notes:E,attchement:q,discount:k||0,books:JSON.stringify(g)},ke=await xe(je);M(!1),ke?.Status==="Success"?(_.success(String(ke?.msg??"Success"),{duration:1e3}),h([]),I([]),D(0),T(0),F(""),z(""),B("NO_FINE"),await rt({id:u?.student_id})):_.error(String(ke?.msg??"Failed"),{duration:1e3})},St=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!g.length){_.error("Select at least one book to return.",{duration:1e3});return}n(Te())},La=i.useMemo(()=>Tc(nt(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),qa=[{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:(le,je)=>e.jsx(gt,{defaultValue:ae(je?.return_date||ae().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(ke,ye)=>{w(be=>be.map(Fe=>String(Fe?.id)===String(je?.id)?{...Fe,return_date:ye}:Fe))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(le,je)=>e.jsx(s.Button,{type:"text",danger:!0,onClick:()=>Re(je?.id),children:"Remove"})}],za={selectedRowKeys:m,onChange:(le,je)=>{h(le),I(je);const ke=(je??[]).reduce((ye,be)=>ye+Number(be?.totalfine??0),0);D(ke)},onSelect:(le,je,ke)=>{if(je){const ye=ke.map(be=>({...be,return_date:be?.return_date?be.return_date:Qn(be?.issue_date||ae())}));I(ye)}},onSelectAll:(le,je)=>{if(le){const ke=je.map(ye=>({...ye,return_date:ye?.return_date?ye.return_date:Qn(ye?.issue_date||ae())}));I(ke)}}},Ya=[{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:(le,je)=>{const ye=g.find(Fe=>String(Fe?.id)===String(je?.id))?.return_date||je?.return_date,be=Qn(je?.issue_date||ae());return e.jsx(gt,{defaultValue:ae(ye||be),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(Fe,jt)=>{I(Po=>Po.map(Wa=>String(Wa?.id)===String(je?.id)?{...Wa,return_date:jt}:Wa))}})}},{title:"Days",key:"days",width:100,render:(le,je)=>{const ye=g.find(Fe=>String(Fe?.id)===String(je?.id))?.return_date||je?.return_date,be=je?.issue_date;if(be&&ye){const Fe=ae(ye).diff(ae(be),"day");return Fe>=0?Fe: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:le=>e.jsxs("span",{children:["₹ ",le]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:v,onCancel:()=>M(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(s.Radio.Group,{value:P,onChange:le=>N(le.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(s.Input.TextArea,{rows:3,value:E,onChange:le=>F(le.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(s.Upload,{action:La,headers:{Authorization:a},maxCount:1,onChange:le=>{if(le.file.status==="done"){const je=le.file.response?.data??le.file.response?.file??"";z(String(je??""))}},children:e.jsx(s.Button,{icon:e.jsx(X.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(s.Input,{type:"number",value:k,onChange:le=>T(le.target.value),placeholder:"0"})]}),e.jsxs(s.Button,{type:"primary",onClick:Ge,children:["Collect ₹",Math.max(0,Number(R)-Number(k||0))]}),e.jsx(s.Button,{onClick:()=>M(!1),children:"Cancel"})]})}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:10,children:e.jsx(s.Radio.Group,{value:r,onChange:le=>{const je=le.target.value;o(je),w([]),h([]),I([]),D(0),B("NO_FINE"),T(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(s.Col,{xs:24,md:14,children:e.jsx(s.Form,{form:ne,onFinish:At,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search",label:"Search Student",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:d?e.jsx(s.Input,{autoFocus:!0,addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:d,onChange:le=>c(le.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{options:ge,onSelect:Tt,onSearch:ft,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:d,onChange:le=>c(le.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),u?e.jsxs(e.Fragment,{children:[e.jsx(s.Divider,{}),e.jsxs(s.Row,{gutter:[12,12],children:[e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Name:"})," ",u?.value??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Card No:"})," ",u?.library_card_no??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Member ID:"})," ",u?.member_id??""]})]})]}):null,e.jsx(s.Divider,{}),l?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(s.Table,{dataSource:me,columns:Ya,rowSelection:za,pagination:!1,rowKey:le=>le?.id??le?.issue_id??le?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(s.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(s.Typography.Text,{strong:!0,children:["Total Fine: ₹",R]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(s.Button,{type:"primary",onClick:Se,disabled:!g.length,children:R>0?`Pay Now ₹ ${Math.max(0,Number(R)-Number(k||0))}`:"Return Selected"}),R>0?e.jsx(s.Button,{onClick:St,disabled:!g.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:18,children:e.jsx(s.Form,{form:H,onFinish:Ht,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:x?e.jsx(s.Input,{autoFocus:!0,disabled:!u,addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:x,onChange:le=>y(le.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{disabled:!u,options:te,onSelect:Kt,onSearch:Vt,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:x,onChange:le=>y(le.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(s.Button,{style:{width:"100%"},icon:e.jsx(X.FilterOutlined,{}),onClick:()=>f(!0),children:"Filter"})})]}),e.jsx(s.Drawer,{open:C,onClose:()=>f(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{label:"Category",options:ie,value:p,onChange:le=>b(le??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(ee,{label:"Class",options:V,value:A,onChange:le=>O(le??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(ee,{label:"Subjects",options:oe,value:L,onChange:le=>U(le??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(s.Button,{type:"primary",onClick:()=>f(!1),children:"Apply"})]})}),e.jsx(s.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(s.Table,{dataSource:j,columns:qa,pagination:!1,rowKey:le=>le?.id??le?.book_id??le?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"button",value:"Issue",onClick:ue})})]})]}),e.jsx("div",{ref:Y,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}const Br=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Ic({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,c]=i.useState(null),[x,y]=i.useState(!1),[u,S]=i.useState(!1),[j,w]=i.useState(null),[m,h]=i.useState(!1),g="api/branchapi/academy/classdropdownlist",I="api/branchapi/academy/sectionoftheClass",R="api/branchapi/library/studenttableForLibrary",D="api/branchapi/library/addmembershipforStudent",C="api/branchapi/library/removemembershipforStudent",f=i.useMemo(()=>{if(!o?.value)return null;const k=I.includes("?")?"&":"?";return`${I}${k}class_id=${encodeURIComponent(String(o.value))}`},[I,o?.value]),p=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const k=R.includes("?")?"&":"?";return`${R}${k}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${a.page}&per_page=${a.rowsPerPage}`},[a.page,a.rowsPerPage,o?.value,d?.value,R]),{data:b}=G(n&&g?[g,n]:null,([k,T])=>Q(k,T)),{data:A}=G(n&&f?[f,n]:null,([k,T])=>Q(k,T)),{isLoading:O,error:L,data:U,mutate:v}=G(n&&p?[p,n]:null,([k,T])=>Q(k,T)),M=i.useMemo(()=>Br(b),[b]),P=i.useMemo(()=>Br(A),[A]),N=(k,T)=>{r({page:k,rowsPerPage:parseInt(T,10)})},E=k=>{const T=k?.id??k?.student_id??k?.member_id;w(T??null),S(!0),h($=>!$)},F=async k=>{if(k.preventDefault(),!j)return;const T=new FormData(k.target);T.set("id",String(j));try{await Ye(D,T,n),_.success("Success! Added member.",{duration:1e3,icon:"🎉"}),S(!1),w(null),await v()}catch($){_.error($?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},q=async k=>{try{await at(C,k,n),_.success("Success! Removed member.",{duration:1e3}),await v()}catch(T){_.error(T?.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:(k,T)=>(console.log("data______________",T),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:T?.library_card_no==null?e.jsx(s.Button,{type:"primary",size:"small",icon:e.jsx(X.UserAddOutlined,{}),onClick:()=>E(T)}):e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{}),onClick:()=>q(T?.id??T?.student_id??T?.member_id)})}))}],[q]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:u,title:"Add Member",onCancel:()=>{S(!1),w(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(J,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Add",color:"primary"})})]})},`add-${m}`)}),e.jsx(s.Card,{title:e.jsx(s.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(ee,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:k=>{l(k??null),c(null),y(T=>!T)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:k=>c(k??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${x}`),e.jsx(ce,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){_.error("Select class and section.",{duration:1e3});return}r(k=>({...k,page:1}))}})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Le,{parentCallback:N,data:{newData:U,columns:z,columnstype:"antd",action:!1,Loading:O,error:L}})})]})}function Dc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState({page:1,rowsPerPage:10}),[o]=s.Form.useForm(),[l]=s.Form.useForm(),[d,c]=i.useState(!1),[x,y]=i.useState(null),u="api/branchapi/library/BookCategorytable",S="api/branchapi/library/addBookCategory",j="api/branchapi/library/editBookCategory",w="api/branchapi/library/deleteBookCategory",m=i.useMemo(()=>{const L=u.includes("?")?"&":"?";return`${u}${L}page=${a.page}&per_page=${a.rowsPerPage}`},[u,a.page,a.rowsPerPage]),{isLoading:h,error:g,data:I,mutate:R}=G(n&&m?[m,n]:null,([L,U])=>Q(L,U)),D=(L,U)=>{r({page:L,rowsPerPage:parseInt(U,10)})},C=async L=>{const U=new FormData;U.set("title",L?.title??"");try{await Ye(S,U,n),_.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await R()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to add category.",{duration:1e3})}},f=L=>{y(L??null),l.setFieldsValue({title:L?.name??""}),c(!0)},p=()=>{c(!1),y(null),l.resetFields()},b=async L=>{const U=x?.id??x?.category_id??x?.cat_id;if(!U){_.error("Missing category id.",{duration:1e3});return}const v=new FormData;v.set("id",String(U)),v.set("title",L?.title??"");try{await pt(j,v,n),_.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),p(),await R()}catch(M){_.error(M?.response?.data?.msg??M?.message??"Failed to update category.",{duration:1e3})}},A=async L=>{const U=L?.id??L?.category_id??L?.cat_id;if(!U){_.error("Missing category id.",{duration:1e3});return}try{await at(w,U,n),_.success("Success! Deleted category.",{duration:1e3}),await R()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to delete category.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(L,U)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>f(U)}),e.jsx(s.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>A(U),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[A]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:d,title:"Edit Category",onCancel:p,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:l,layout:"vertical",onFinish:b,children:[e.jsx(s.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(s.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:p,children:"Cancel"}),e.jsx(ce,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,lg:8,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:C,children:[e.jsx(s.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(s.Input,{placeholder:"Enter category name"})}),e.jsx(ce,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(s.Col,{xs:24,lg:16,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Le,{parentCallback:D,data:{newData:I,columns:O,columnstype:"antd",action:!1,Loading:h,error:g}})})})]})]})}const os=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function kc({token:t}){const[n,a]=i.useState([ae().format("YYYY-MM-DD"),ae().format("YYYY-MM-DD")]),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,x]=i.useState(null),[y,u]=i.useState(!1),[S,j]=i.useState(!1),w="api/branchapi/academy/classdropdownlist",m="api/branchapi/academy/sectionoftheClass",h="api/branchapi/library/memberDropdown",g="api/report/libraryReport/libraryReport",I=i.useMemo(()=>{if(!r?.value)return null;const E=m.includes("?")?"&":"?";return`${m}${E}class_id=${encodeURIComponent(String(r.value))}`},[m,r?.value]),R=i.useMemo(()=>{if(!r?.value)return null;const E=h.includes("?")?"&":"?",F=`${h}${E}class=${encodeURIComponent(String(r.value))}`;return l?.value?`${F}§ion=${encodeURIComponent(String(l.value))}`:F},[h,r?.value,l?.value]),{isLoading:D,error:C,data:f,mutate:p}=G(t&&w?[w,t]:null,([E,F])=>Q(E,F)),{data:b}=G(t&&I?[I,t]:null,([E,F])=>Q(E,F)),{data:A}=G(t&&R?[R,t]:null,([E,F])=>Q(E,F)),O=i.useMemo(()=>os(f),[f]),L=i.useMemo(()=>os(b),[b]),U=i.useMemo(()=>os(A),[A]),{trigger:v,data:M}=Je(g,(E,F)=>Os(E,F,t));i.useEffect(()=>{(async()=>{j(!0);try{await v({duration:n})}finally{j(!1)}})()},[]);const P=async()=>{j(!0);try{await v({duration:n,class:r?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{j(!1)}},N=[{title:"Name",dataIndex:"full_name",render:(E,F)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(E,F)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(E,F)=>e.jsxs(s.Typography.Text,{style:{fontSize:12},children:[F?.class??"","(",F?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(E,F)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.book_title??""})},{title:"Issue Date",key:"date",render:(E,F,q)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.issue_date??""})},{title:"Due Return Date",key:"date",render:(E,F,q)=>e.jsx(s.Tag,{color:"orange",children:F?.return_date??""})},{title:"Return Date",key:"date",render:(E,F,q)=>F?.retured_by_user?e.jsx(s.Tag,{color:"green",children:F?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(E,F,q)=>String(F?.is_returned??"")==="1"?e.jsx(s.Tag,{color:"green",children:"Return"}):e.jsx(s.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(E,F,q)=>{const z=F?.late_fine?Number(F.late_fine):0;return z?e.jsx(s.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:z}):null}}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(s.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(s.DatePicker.RangePicker,{style:{width:"100%"},value:[ae(n[0],"YYYY-MM-DD"),ae(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(E,F)=>{Array.isArray(F)&&F.length===2&&a([F[0],F[1]])}})]})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:E=>{o(E??null),d(null),x(null),u(F=>!F)},allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:E=>{d(E??null),x(null)},allowSelectAll:!1},`section1${y}`)}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:E=>x(E??null),allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:1,children:e.jsx(s.Button,{type:"primary",icon:e.jsx(X.SearchOutlined,{}),onClick:P,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(s.Table,{columns:N,pagination:!1,dataSource:Array.isArray(M?.data)?M.data:[],size:"small",rowKey:(E,F)=>E?.id??E?.issue_id??E?.fees_receipt_id??F,loading:S,scroll:{x:"max-content"},summary:E=>{const F=E.reduce((z,k)=>z+Number(k?.late_fine??0),0),q=E.reduce((z,k)=>z+Number(k?.is_returned??0),0);return e.jsxs(s.Table.Summary.Row,{children:[e.jsx(s.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",E.length]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(E.length-q)]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",q]})}),e.jsx(s.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",F.toLocaleString("en-IN")]})})]})}})})]})]})}const Lr=[{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"}],qr=[{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 Oc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState("renewalHistory"),[o,l]=i.useState("This Month"),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(7),[j,w]=i.useState(1),[m,h]=i.useState(20),[g,I]=i.useState(""),[R,D]=i.useState("DESC"),C=i.useRef(null),f=F=>{const q=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(a)&&(q.set("date_range",o),o==="Custom"&&d&&x&&(q.set("from_date",d),q.set("to_date",x))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(a)&&(q.set("page",String(j)),q.set("per_page",String(m))),a==="upcomingRenewalDue"&&q.set("days_ahead",String(u)),g&&q.set("sort_by",g),R&&q.set("sort_dir",R),`${F}?${q.toString()}`},p=i.useMemo(()=>{switch(a){case"renewalHistory":return f(jd);case"renewalFineReport":return f(vd);case"currentlyRenewedBooks":return f(_d);case"upcomingRenewalDue":return f(wd);case"overdueRenewalReport":return f(Cd);case"renewalLimitReport":return f(Ad);case"renewalStatusReport":return f(Td);case"studentWiseReport":return f(Rd);case"bookWiseReport":return f(Id);case"classWiseReport":return f(Dd);case"staffWiseReport":return f(kd);case"renewalStatisticsByDate":return f(Od);default:return null}},[a,o,d,x,u,j,m]),{data:b,isLoading:A}=G(n?[p,n]:null,([F,q])=>Q(F,q)),O=b?.data||{},L=O?.rows||[],U=O?.pagination||{},v=F=>{r(F),w(1),h(20)},M=()=>{w(1)},P=()=>{switch(a){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:F=>e.jsx(s.Tag,{color:F==="renewed"?"green":"red",children:F})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:F=>F??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:F=>F??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:F=>F??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:F=>F?e.jsx(s.Tag,{color:F==="paid"?"green":F==="partial"?"orange":"red",children:F}):"-"}];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:F=>F??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:F=>F??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:F=>F??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:F=>F??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:F=>e.jsx(s.Tag,{color:F?"green":"red",children:F?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:F=>Array.isArray(F)?F.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[]}},N=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(a),E=i.useMemo(()=>P(),[a]);return e.jsx(de,{pt:5,pb:1,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(de,{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(de,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],mb:3,children:[N&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(ee,{options:Lr,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:Lr.find(F=>F.value===o)||null,onChange:F=>l(F?.value||"This Month")})}),o==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(gt,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:F=>c(F?F.format("YYYY-MM-DD"):"")})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(gt,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:F=>y(F?F.format("YYYY-MM-DD"):"")})})]})]}),a==="upcomingRenewalDue"&&e.jsx(s.Col,{xs:24,md:6,children:e.jsx(ee,{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:F=>S(F?.value||7)})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(de,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ce,{type:"button",value:"Search",color:"primary",onClick:M})})})]}),e.jsx(s.Tabs,{activeKey:a,onChange:v,items:qr})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(de,{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(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:qr.find(F=>F.key===a)?.label||"Report"})}),e.jsxs(de,{p:3,children:[e.jsx(cn,{data:{tableRef:C}}),A?e.jsx(de,{py:8,textAlign:"center",children:e.jsx(s.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(s.Table,{size:"small",dataSource:L,columns:E,loading:A,pagination:!1,bordered:!0,rowKey:F=>F.renewal_id||F.id||JSON.stringify(F),ref:C}),L.length>0&&e.jsx(s.Pagination,{current:j,pageSize:m,total:U.total_rows||L.length,onChange:(F,q)=>{w(F),h(q)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const Ea=t=>t??localStorage.getItem("authToken")??"",Pc=(t,n)=>{const a=String(t??""),r=String(n);return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},Ue={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"}},Ec=()=>Pc(nt(),Ue.upload),Mc=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Ea(r))},Un=async(t,n,a)=>Ye(t,n,Ea(a)),un=async(t,n,a)=>pt(t,n,Ea(a)),Bn=async(t,n,a)=>at(t,n,Ea(a)),Fc=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",rn=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:Ec(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Fc(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},pa=Ue.vendor,Ln=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>Mc({baseUrl:l,page:d,perPage:c},x)),Nc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:pa.list,page:n,perPage:a,token:t}),$c={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},zr=[{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 Uc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:y,error:u,data:S,mutate:j}=Nc({token:t,page:n.page,perPage:n.rowsPerPage}),w=async C=>{try{await j(Un(pa.add,C,t),st(C)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(f){_.error(f?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},m=C=>{C.preventDefault();const f=new FormData(C.target);c&&f.set("image",c),w(f),C.target.reset(),x("")},h=(C,f)=>{a({page:C,rowsPerPage:parseInt(f,10)})},g=async C=>{try{await j(Bn(pa.remove,C,t),Qe(C)),_.success("Success! Deleted item.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},I=C=>{d(C),o(!0),x("")},R=async C=>{C.preventDefault();const f=new FormData(C.target);f.set("id",String(l?.id??"")),c&&f.set("image",c);try{await un(pa.edit,f,t),await j(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(p){_.error(p?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=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,f)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>I(f),style:{padding:2}}),e.jsx(lt,{id:f?.id,funcName:g})]})}],[g]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[zr.map(C=>e.jsx(J,{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(rn,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:$c,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(de,{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:[zr.map(C=>e.jsx(J,{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(rn,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(de,{pt:3,children:e.jsx(Le,{parentCallback:h,data:{newData:S,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})]})]})}const Bc=({token:t})=>e.jsx(Uc,{token:t}),Lc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},qc={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"},kt=({style:t,onFocus:n,onBlur:a,...r})=>{const[o,l]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:Lc,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{l(!0),n?.(d)},onBlur:d=>{l(!1),a?.(d)},style:{...qc,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},ma=Ue.product,Yr=Ue.vendor.dropdown,Wr=Ue.category.dropdown,zc=Ue.subCategory.dropdown,Vr=Ue.unit.dropdown,fo=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:ma.list,page:n,perPage:a,token:t}),Yc=({token:t})=>G(t&&Yr?[Yr,t]:null,([a,r])=>Q(a,r)),Wc=({token:t})=>G(t&&Wr?[Wr,t]:null,([a,r])=>Q(a,r)),Vc=({token:t})=>G(t&&Vr?[Vr,t]:null,([a,r])=>Q(a,r)),Hc=({token:t,categoryId:n})=>{const a=t&&n?`${zc}?category_id=${encodeURIComponent(String(n))}`:null;return G(a?[a,t]:null,([o,l])=>Q(o,l))},Xn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Kc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Gc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[y,u]=i.useState(""),[S,j]=i.useState(""),[w,m]=i.useState(""),[h,g]=i.useState(""),{isLoading:I,error:R,data:D,mutate:C}=fo({token:t,page:n.page,perPage:n.rowsPerPage}),{data:f}=Yc({token:t}),{data:p}=Wc({token:t}),{data:b}=Vc({token:t}),{data:A}=Hc({token:t,categoryId:y}),O=i.useMemo(()=>Xn(f),[f]),L=i.useMemo(()=>Xn(p),[p]),U=i.useMemo(()=>Xn(b),[b]),v=i.useMemo(()=>Xn(A),[A]),M=async k=>{try{await C(Un(ma.add,k,t),st(k)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},P=k=>{k.preventDefault();const T=new FormData(k.target);y&&T.set("fk_categoryID",String(y)),S&&T.set("fk_sub_categoryID",String(S)),w&&T.set("vendor_id",String(w)),h&&T.set("unit",String(h)),c&&T.set("image",c),M(T),k.target.reset(),x(""),u(""),j(""),m(""),g("")},N=(k,T)=>{a({page:k,rowsPerPage:parseInt(T,10)})},E=async k=>{try{await C(Bn(ma.remove,k,t),Qe(k)),_.success("Success! Deleted item.",{duration:1e3})}catch(T){_.error(T?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},F=k=>{d(k),o(!0),x(""),u(k?.fk_categoryID??k?.category_id??""),j(k?.fk_sub_categoryID??k?.sub_category_id??""),m(k?.vendor_id??""),g(k?.unit??k?.unit_id??"")},q=async k=>{k.preventDefault();const T=new FormData(k.target);T.set("id",String(l?.id??"")),y&&T.set("fk_categoryID",String(y)),S&&T.set("fk_sub_categoryID",String(S)),w&&T.set("vendor_id",String(w)),h&&T.set("unit",String(h)),c&&T.set("image",c);try{await un(ma.edit,T,t),await C(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch($){_.error($?.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:(k,T)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>F(T),style:{padding:2}}),e.jsx(lt,{id:T?.id,funcName:E})]})}],[E]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(J,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:k=>{const T=k?.value??"";u(T),j("")},defaultValue:y?L.find(k=>String(k?.value)===String(y)):null}),e.jsx(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:k=>j(k?.value??""),defaultValue:S?v.find(k=>String(k?.value)===String(S)):null}),e.jsx(J,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:k=>g(k?.value??""),defaultValue:h?U.find(k=>String(k?.value)===String(h)):null}),e.jsx(J,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(J,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(ee,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:k=>m(k?.value??""),defaultValue:w?O.find(k=>String(k?.value)===String(w)):null}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(kt,{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(rn,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Kc,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(J,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:k=>{const T=k?.value??"";u(T),j("")}}),e.jsx(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:k=>j(k?.value??"")},`subcat_${y}`),e.jsx(J,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:k=>g(k?.value??"")}),e.jsx(J,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(J,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(ee,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:k=>m(k?.value??"")}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(kt,{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(rn,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(de,{pt:3,children:e.jsx(Le,{parentCallback:N,data:{newData:D,columns:z,columnstype:"antd",action:!1,Loading:I,error:R}})})]})]})]})}const Jc=({token:t})=>e.jsx(Gc,{token:t}),ya=Ue.category,Qc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:ya.list,page:n,perPage:a,token:t}),Xc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Zc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:y,mutate:u}=Qc({token:t,page:n.page,perPage:n.rowsPerPage}),S=async R=>{try{await u(Un(ya.add,R,t),st(R)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=R=>{R.preventDefault();const D=new FormData(R.target);S(D),R.target.reset()},w=(R,D)=>{a({page:R,rowsPerPage:parseInt(D,10)})},m=async R=>{try{await u(Bn(ya.remove,R,t),Qe(R)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},h=R=>{d(R),o(!0)},g=async R=>{R.preventDefault();const D=new FormData(R.target);D.set("id",String(l?.id??""));try{await un(ya.edit,D,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})}},I=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(D),style:{padding:2}}),e.jsx(lt,{id:D?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.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:g,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Xc,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(de,{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(J,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(de,{pt:3,children:e.jsx(Le,{parentCallback:w,data:{newData:y,columns:I,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const eu=({token:t})=>e.jsx(Zc,{token:t}),fa=Ue.subCategory,Hr=Ue.category.dropdown,tu=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:fa.list,page:n,perPage:a,token:t}),nu=({token:t})=>G(t&&Hr?[Hr,t]:null,([a,r])=>Q(a,r)),au=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},su={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function ru({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:y,error:u,data:S,mutate:j}=tu({token:t,page:n.page,perPage:n.rowsPerPage}),{data:w}=nu({token:t}),m=i.useMemo(()=>au(w),[w]),h=async p=>{try{await j(Un(fa.add,p,t),st(p)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(b){_.error(b?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},g=p=>{p.preventDefault();const b=new FormData(p.target);b.set("status","active"),b.set("img",c||""),h(b),p.target.reset(),x("")},I=(p,b)=>{a({page:p,rowsPerPage:parseInt(b,10)})},R=async p=>{try{await j(Bn(fa.remove,p,t),Qe(p)),_.success("Success! Deleted item.",{duration:1e3})}catch(b){_.error(b?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=p=>{d(p),o(!0)},C=async p=>{p.preventDefault();const b=new FormData(p.target);b.set("id",String(l?.id??"")),c&&b.set("img",c);try{await un(fa.edit,b,t),await j(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(A){_.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},f=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(p,b)=>String(p?.name??"").localeCompare(String(b?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(p,b)=>String(p?.description??"").localeCompare(String(b?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(p,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(b),style:{padding:2}}),e.jsx(lt,{id:b?.id,funcName:R})]})}],[R]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?m.find(p=>String(p?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{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(rn,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:su,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(J,{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(rn,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(de,{pt:3,children:e.jsx(Le,{parentCallback:I,data:{newData:S,columns:f,columnstype:"antd",action:!1,Loading:y,error:u}})})]})]})]})}const iu=({token:t})=>e.jsx(ru,{token:t}),ls=Ue.product,ou=Ue.academy.classes,lu=Ue.academy.sections,du=Ue.student.dropdown;function xn(t){const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]}function Zn(t,n){const a=Math.trunc(Number(t)||1),r=Math.max(1,a);return!Number.isFinite(Number(n))||Number(n)<=0?r:Math.min(r,Math.trunc(Number(n)))}function Xe(t){return String(t??"")}function cu({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,x]=i.useState(!1),[y,u]=i.useState(""),[S,j]=i.useState([]),[w,m]=i.useState({}),[h,g]=i.useState({}),[I,R]=i.useState(!1),[D,C]=i.useState(""),[f,p]=i.useState(0),[b,A]=i.useState(""),[O,L]=i.useState(ae()),[U,v]=i.useState([]),M={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},P=!!(n&&r&&l),{data:N}=G(t?[ou,t]:null,([fe,xe])=>Q(fe,xe)),E=i.useMemo(()=>xn(N),[N]),F=t&&n?`${lu}?class_id=${encodeURIComponent(String(n))}`:null,{data:q}=G(F?[F,t]:null,([fe,xe])=>Q(fe,xe)),z=i.useMemo(()=>xn(q),[q]),k=t&&n&&r?`${du}?class=${encodeURIComponent(String(n))}§ion=${encodeURIComponent(String(r))}`:null,{data:T}=G(k?[k,t]:null,([fe,xe])=>Q(fe,xe)),$=i.useMemo(()=>xn(T),[T]),B=P?`${ls.list}?page=1&per_page=10000`:null,{data:Y,isLoading:ne}=G(t&&B?[B,t]:null,([fe,xe])=>Q(fe,xe),{revalidateOnFocus:!1}),H=i.useMemo(()=>xn(Y),[Y]),W=i.useMemo(()=>{const fe=new Map;return(Array.isArray(H)?H:[]).forEach(xe=>{fe.set(Xe(xe?.id),xe)}),fe},[H]),Z=i.useMemo(()=>{const fe=Object.entries(h||{});return fe.length===0?[]:fe.map(([xe,ge])=>{const te=W.get(Xe(xe));return te?{id:te?.id,name:te?.name,barcode:te?.barcode,stock:Number(te?.quantity||0),price:Number(te?.price||0),quantity:Zn(ge,Number(te?.quantity||0))}:null}).filter(Boolean)},[h,W]),se=i.useMemo(()=>new Set(Z.map(fe=>Xe(fe?.id))),[Z]),pe=i.useMemo(()=>(Array.isArray(Z)?Z:[]).reduce((xe,ge)=>xe+Number(ge?.price||0)*Number(ge?.quantity||1),0),[Z]),ve=i.useMemo(()=>{const fe=Number(f||0);return!Number.isFinite(fe)||fe<=0?0:Math.min(fe,pe)},[f,pe]),re=i.useMemo(()=>Math.max(0,pe-ve),[ve,pe]),ie=i.useMemo(()=>(Array.isArray(H)?H:[]).slice(0,30).map(fe=>({value:Xe(fe?.id),label:`${fe?.name??""}${fe?.barcode?` • ${fe.barcode}`:""}${fe?.quantity!==void 0&&fe?.quantity!==null?` • Stock: ${fe.quantity}`:""}`,product:fe})),[H]),{trigger:V}=Je(t&&P?ls.search:null,(fe,{arg:xe})=>qt(fe,{arg:xe},t));i.useEffect(()=>{if(!P){j([]);return}const fe=String(y||"").trim();if(fe.length<2){j(ie);return}let xe=!0;const ge=setTimeout(async()=>{let te=[];try{if(V){const he=await V({search:fe});te=xn(he)}}catch{te=[]}if(!Array.isArray(te)||te.length===0){const he=fe.toLowerCase();te=(Array.isArray(H)?H:[]).filter(Te=>{const Re=String(Te?.name??"").toLowerCase(),ft=String(Te?.barcode??"").toLowerCase();return Re.includes(he)||ft.includes(he)}).slice(0,30)}const me=te.slice(0,30).map(he=>({value:Xe(he?.id),label:`${he?.name??""}${he?.barcode?` • ${he.barcode}`:""}${he?.quantity!==void 0&&he?.quantity!==null?` • Stock: ${he.quantity}`:""}`,product:he}));xe&&j(me)},250);return()=>{xe=!1,clearTimeout(ge)}},[ie,P,V,H,y]),i.useEffect(()=>{g({}),m({}),u(""),j([]),R(!1),C(""),p(0),A(""),L(ae()),v([])},[n,r,l]);const oe=i.useCallback((fe,xe=1)=>{const ge=fe?.id;if(!ge)return;const te=Number(fe?.quantity||0);if(te<=0){_.error("Out of stock.",{duration:1e3});return}const me=Zn(xe,te);g(he=>{const Te=he||{};return Object.prototype.hasOwnProperty.call(Te,Xe(ge))?(_.error("Product already added.",{duration:1e3}),Te):{...Te,[Xe(ge)]:me}})},[g]),Ce=i.useCallback((fe,xe,ge)=>{g(te=>{const me=te||{},he=Xe(fe);return Object.prototype.hasOwnProperty.call(me,he)?{...me,[he]:Zn(xe,ge)}:me})},[]),Oe=i.useCallback(fe=>{g(xe=>{const ge=xe||{},te=Xe(fe);if(!Object.prototype.hasOwnProperty.call(ge,te))return ge;const me={...ge};return delete me[te],me})},[]),Pe=i.useCallback((fe,xe,ge)=>{m(te=>({...te||{},[Xe(fe)]:Zn(xe,ge)}))},[]),Ne=i.useCallback((fe,xe)=>{xe?.product&&oe(xe.product,1),u(""),j(ie)},[oe,ie]),Ee=i.useCallback(fe=>{if(fe.key!=="Enter")return;fe.preventDefault();const xe=Array.isArray(S)&&S.length>0?S[0]:null;if(xe?.product){oe(xe.product,1),u(""),j(ie);return}const ge=String(y||"").trim().toLowerCase();if(ge.length===0)return;const te=(Array.isArray(H)?H:[]).find(me=>{const he=String(me?.name??"").toLowerCase(),Te=String(me?.barcode??"").toLowerCase();return he.includes(ge)||Te.includes(ge)});te&&(oe(te,1),u(""),j(ie))},[oe,ie,H,S,y]),Ve=()=>{if(!t){_.error("Missing token.",{duration:1e3});return}if(!n){_.error("Select class.",{duration:1e3});return}if(!r){_.error("Select section.",{duration:1e3});return}if(!l){_.error("Select student.",{duration:1e3});return}if(!Z||Z.length===0){_.error("Add at least one product.",{duration:1e3});return}R(!0)},{trigger:He,isMutating:Be}=Je(t?ls.sellProduct:null,(fe,{arg:xe})=>Pa(fe,{arg:xe},t)),We=async()=>{if(!D){_.error("Select payment type.",{duration:1e3});return}const fe=(Array.isArray(Z)?Z:[]).map(ge=>({id:ge?.id,quantity:Number(ge?.quantity||1),price:Number(ge?.price||0),total_price:Number(ge?.total_price||0),fk_vendor_id:ge?.fk_vendor_id||"",fk_categoryID:ge?.fk_categoryID||"",name:ge?.name||"",class_id:ge?.class_id||"",fk_sub_categoryID:ge?.fk_sub_categoryID||"",description:ge?.description||"",min_quantity:Number(ge?.min_quantity||0),storecategory:Number(ge?.storecategory||0),barcode:ge?.barcode||""})),xe={amount:pe,class:n,section:r,student_id:l,payment_type:D,discount:ve,notes:b||"",receipt_date:O?ae(O).format("YYYY-MM-DD"):"",product:JSON.stringify(fe),total_payable_amount:pe,attchement:U[0]?.originFileObj||""};try{const te=Array.isArray(U)&&U.length>0&&U[0]?.originFileObj?(()=>{const he=new FormData;return Object.entries(xe).forEach(([Te,Re])=>{if(Te==="products"){he.append("product",JSON.stringify(Re));return}he.append(Te,String(Re??""))}),he.append("attachment",U[0].originFileObj),he})():xe,me=await He(te);me?.Status==="Success"?(_.success("Success! Product sold.",{duration:1e3}),R(!1),g({}),m({}),u(""),j(ie),C(""),p(0),A(""),L(ae()),v([])):_.error(me?.msg??"Failed to submit.",{duration:1e3})}catch{_.error("Failed to submit.",{duration:1e3})}},rt=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:(fe,xe)=>{const ge=Xe(xe?.id),te=Number(xe?.quantity||0),me=se.has(ge),he=(me?h?.[ge]:w?.[ge])??1;return e.jsx(s.InputNumber,{min:1,max:Number.isFinite(te)&&te>0?te:void 0,value:he,onChange:Te=>{me?Ce(ge,Te,te):Pe(ge,Te,te)},disabled:te<=0})}},{title:"Amount",key:"amount",width:140,render:(fe,xe)=>{const ge=Xe(xe?.id),te=(se.has(ge)?h?.[ge]:w?.[ge])??1;return Number(xe?.price||0)*Number(te||1)}},{title:"Action",key:"action",width:120,render:(fe,xe)=>{const ge=Xe(xe?.id),te=Number(xe?.quantity||0),me=se.has(ge),he=(me?h?.[ge]:w?.[ge])??1;return me?e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(X.DeleteOutlined,{}),onClick:()=>Oe(ge),style:{padding:2}}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.PlusOutlined,{}),disabled:te<=0,onClick:()=>oe(xe,he),style:{padding:2}})}}],[oe,se,h,w,Oe,Pe,Ce]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(de,{pt:5,pb:2,children:[e.jsxs(de,{style:{padding:"12px 16px"},children:[e.jsx(de,{children:"Sell Product"}),e.jsx(s.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(ee,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:fe=>{const xe=fe?.value??"";a(xe),o(""),d(""),x(ge=>!ge)}}),e.jsx(ee,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:fe=>{const xe=fe?.value??"";o(xe),d("")}},`section_${c}`),e.jsx(ee,{options:$,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(s.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(de,{style:{marginTop:12},children:"Product Section"}),e.jsx(s.AutoComplete,{value:y,options:S,onSearch:u,onFocus:()=>{P&&String(y||"").trim().length<2&&j(ie)},onSelect:Ne,disabled:!P,children:e.jsx(s.Input,{placeholder:"Search by product name or barcode",onKeyDown:Ee,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",ht(pe)]})]}),e.jsx(s.Table,{rowKey:fe=>Xe(fe?.id),columns:rt,dataSource:H,loading:ne,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:Z.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:ht(pe)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(ce,{type:"button",value:"Submit",disabled:!P||Z.length===0,onClick:Ve,style:{flex:1,minWidth:140}}),e.jsx(s.Button,{type:"text",style:M,onClick:()=>{g({}),m({}),u(""),j(ie)},disabled:Z.length===0,children:"Clear"})]})]})]})})]}),e.jsx(s.Modal,{open:I,title:"Payment",onCancel:()=>R(!1),onOk:We,confirmLoading:Be,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(s.Select,{value:D||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(s.DatePicker,{value:O,onChange:fe=>L(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(s.InputNumber,{min:0,max:pe,value:f,onChange:fe=>p(Number(fe||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(s.Upload,{fileList:U,beforeUpload:()=>!1,onChange:({fileList:fe})=>v((fe||[]).slice(-1)),maxCount:1,children:e.jsx(s.Button,{icon:e.jsx(X.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(s.Input.TextArea,{value:b,onChange:fe=>A(fe.target.value),rows:3})]}),e.jsx(s.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:ht(pe)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:ht(ve)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:ht(re)})]})]})})]})})]})}const uu=({token:t})=>e.jsx(cu,{token:t}),ha=Ue.unit,pu=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:ha.list,page:n,perPage:a,token:t}),mu={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function yu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:y,mutate:u}=pu({token:t,page:n.page,perPage:n.rowsPerPage}),S=async R=>{try{await u(Un(ha.add,R,t),st(R)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=R=>{R.preventDefault();const D=new FormData(R.target);S(D),R.target.reset()},w=(R,D)=>{a({page:R,rowsPerPage:parseInt(D,10)})},m=async R=>{try{await u(Bn(ha.remove,R,t),Qe(R)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},h=R=>{d(R),o(!0)},g=async R=>{R.preventDefault();const D=new FormData(R.target);D.set("id",String(l?.id??""));try{await un(ha.edit,D,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})}},I=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(D),style:{padding:2}}),e.jsx(lt,{id:D?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.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:g,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:mu,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(de,{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(J,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(de,{pt:3,children:e.jsx(Le,{parentCallback:w,data:{newData:y,columns:I,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const fu=({token:t})=>e.jsx(yu,{token:t}),hu=Ue.product.sellReports,gu=Ue.academy.classes,xu=Ue.academy.sections,bu=Ue.student.dropdown,Kr=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Su({token:t}){const n=i.useRef(null),[a,r]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(!1),j=v=>{const M=v?.data?.data??v?.data??v??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},{data:w}=G(t?[gu,t]:null,([v,M])=>Q(v,M)),m=i.useMemo(()=>j(w),[w]),h=t&&o?`${xu}?class_id=${encodeURIComponent(String(o))}`:null,{data:g}=G(h?[h,t]:null,([v,M])=>Q(v,M)),I=i.useMemo(()=>j(g),[g]),R=t&&o&&d?`${bu}?class=${encodeURIComponent(String(o))}§ion=${encodeURIComponent(String(d))}`:null,{data:D}=G(R?[R,t]:null,([v,M])=>Q(v,M)),C=i.useMemo(()=>j(D),[D]),{trigger:f,isMutating:p,data:b}=Je(hu,(v,{arg:M})=>Os(v,{arg:M},t));i.useEffect(()=>{const M=new Date().toISOString().slice(0,10);f({duration:[M,M]})},[f]);const A=i.useMemo(()=>{const v=b?.data??b??[];return Array.isArray(v)?v:[]},[b]),O=v=>{const M=Array.isArray(v?.product_details)?v.product_details:[];return M.length===0?null:e.jsx(s.Table,{size:"small",bordered:!0,pagination:!1,rowKey:P=>`${v?.receipt_id??"r"}_${P?.product_name??P?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:P=>Kr(P)}],dataSource:M})},L=[{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:v=>Kr(v)}],U=async()=>{if(!a||a.length!==2)return;const[v,M]=a;await f({duration:[v.format("YYYY-MM-DD"),M.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:x||""})};return e.jsx("div",{children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,lg:8,children:e.jsx(s.Card,{title:e.jsx(s.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(s.DatePicker.RangePicker,{value:a,onChange:r,style:{width:"100%"}})]}),e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:v=>{const M=v?.value??"";l(M),c(""),y(""),S(P=>!P)}}),e.jsx(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:v=>{const M=v?.value??"";c(M),y("")}},`section_${u}`),e.jsx(ee,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:v=>y(v?.value??"")}),e.jsx(ce,{type:"button",value:p?"Searching...":"Search",disabled:p,onClick:U,style:{width:"100%"}})]})})}),e.jsx(s.Col,{xs:24,lg:16,children:e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(cn,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(wt,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:p,rowKey:v=>String(v?.receipt_id??v?.receipt_no??Math.random()),columns:L,expandable:{expandedRowRender:O},dataSource:A,pagination:{pageSize:20}})]})})})]})})}const ju=({token:t})=>e.jsx(Su,{token:t}),vu=Ue.product;function _u({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState([]),[l,d]=i.useState([]),[c,x]=i.useState(!1),[y,u]=i.useState(!1),[S,j]=i.useState(null),[w,m]=i.useState(0),[h,g]=i.useState(null),[I,R]=i.useState(""),D=i.useRef(null),C=ln.useReactToPrint({contentRef:D,documentTitle:"Stock Barcodes"}),{isLoading:f,error:p,data:b,mutate:A}=fo({token:t,page:n.page,perPage:n.rowsPerPage}),O=(N,E)=>{a({page:N,rowsPerPage:parseInt(E,10)})},L={selectedRowKeys:r,onChange:(N,E)=>{o(N),d(E)}},U=N=>{j(N),m(Number(N?.quantity??0)),g(null),R(""),x(!0)},v=()=>{x(!1),j(null),m(0),g(null),R("")},M=async()=>{if(!S?.id)return;u(!0);const N=new FormData;N.append("product_id",String(S.id)),N.append("qty",String(w??0)),h&&N.append("tran_date",h.format("YYYY-MM-DD")),I&&N.append("remarks",I);try{const E=await un(vu.addStock,N,t);E?.Status==="Success"?(_.success("Success! Updated quantity.",{duration:1e3}),v(),await A()):_.error(E?.msg??"Failed to update quantity.",{duration:1e3})}catch{_.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},P=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:(N,E)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(s.Button,{size:"small",onClick:()=>U(E),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:S?.name?`Update Stock: ${S.name}`:"Update Stock",open:c,onCancel:v,onOk:M,okButtonProps:{loading:y},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(s.InputNumber,{min:0,style:{width:"100%"},value:w,onChange:N=>m(N??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{style:{width:"100%"},value:h,onChange:g})]}),e.jsx(kt,{label:"Remarks",name:"remarks",rows:3,value:I,onChange:N=>R(N.target.value)})]})}),e.jsxs(de,{pt:5,pb:2,children:[e.jsxs(de,{children:["Manage Stock",e.jsx(ce,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>C?.(),style:{minWidth:170}})]}),e.jsx(de,{style:{padding:"12px 16px"},children:e.jsx(s.Card,{style:{borderRadius:16},children:e.jsx(Le,{parentCallback:O,data:{newData:b,columns:P,columnstype:"antd",action:!1,Loading:f,error:p,rowSelection:L}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:D,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map(N=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:N?.name??""}),e.jsx(Ei,{value:String(N?.barcode??N?.id??""),height:50,width:1.6,displayValue:!0})]},N?.id??N?.barcode??N?.name))})})})]})}const wu=({token:t})=>e.jsx(_u,{token:t}),Cu=Ue.report.stock,Au=Ue.product.dropdown,Tu=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Ru({token:t}){const n=i.useRef(null),[a,r]=i.useState(null),[o,l]=i.useState(""),{data:d}=G(t?[Au,t]:null,([m,h])=>Q(m,h)),c=i.useMemo(()=>Tu(d),[d]),{trigger:x,isMutating:y,data:u}=Je(Cu,(m,{arg:h})=>Os(m,{arg:h},t));i.useEffect(()=>{const h=new Date().toISOString().slice(0,10);x({duration:[h,h]})},[x]);const S=i.useMemo(()=>{const m=u?.data??u??[];return(Array.isArray(m)?m:[]).flatMap(g=>(Array.isArray(g?.ledger)?g.ledger:[]).map((I,R)=>({key:`${g.product_id??g.product_name??"p"}-${R}`,date:I?.date,product:g?.product_name,opening:I?.opening,inward:I?.inward,outward:I?.outward,closing:I?.closing})))},[u]),j=[{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:m=>e.jsx("span",{style:{color:Number(m)<0?"red":"green"},children:m})}],w=async()=>{if(!a||a.length!==2)return;const[m,h]=a;await x({duration:[m.format("YYYY-MM-DD"),h.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(s.Card,{title:e.jsx(s.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(s.DatePicker.RangePicker,{value:a,onChange:r}),e.jsxs("select",{value:o,onChange:m=>l(m.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(m=>e.jsx("option",{value:String(m?.value??""),children:String(m?.label??"")},String(m?.value??m?.id??m?.label)))]}),e.jsx(s.Button,{type:"primary",onClick:w,loading:y,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(cn,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(wt,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:y,rowKey:"key",columns:j,dataSource:S,pagination:{pageSize:50}})]})]})}const Iu=({token:t})=>e.jsx(Ru,{token:t}),Gr=[{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"}],vt={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},Jr=[{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"}],Qr=[{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 Du(){const[t,n]=i.useState("dashboard"),[a,r]=i.useState("This Month"),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(1),[u,S]=i.useState(10),[j,w]=i.useState(""),m=i.useRef(null),h=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),g=i.useMemo(()=>{if(!j.trim())return Jr;const f=j.toLowerCase();return Jr.filter(p=>Object.values(p).some(b=>String(b??"").toLowerCase().includes(f)))},[j]),I=i.useMemo(()=>{const f=(x-1)*u;return g.slice(f,f+u)},[g,x,u]),R=()=>{y(1)},D=()=>{const f=[{title:"Total Packages",value:vt.total_packages,icon:e.jsx(X.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:vt.total_downloads.toLocaleString(),icon:e.jsx(X.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:vt.active_packages,icon:e.jsx(X.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:vt.deprecated_packages,icon:e.jsx(X.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:vt.pending_approval,icon:e.jsx(X.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:vt.published_this_month,icon:e.jsx(X.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:vt.published_this_week,icon:e.jsx(X.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:vt.packages_needing_update,icon:e.jsx(X.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:vt.packages_with_issues,icon:e.jsx(X.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(s.Row,{gutter:[16,16],children:f.map((p,b)=>e.jsx(s.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(s.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${p.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(de,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${p.color}15`,color:p.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:p.icon}),e.jsxs(de,{children:[e.jsx(s.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:p.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:p.value})]})]})},b))})},C=()=>{const f=[{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:p=>{let b="default";return p==="published"?b="green":p==="draft"?b="orange":p==="deprecated"?b="red":p==="pending"&&(b="blue"),e.jsx(s.Tag,{color:b,children:p.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:(p,b)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:f};return e.jsx(de,{pt:5,pb:1,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(de,{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(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(de,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],mb:3,children:[h&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(ee,{options:Gr,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:Gr.find(f=>f.value===a)||null,onChange:f=>r(f?.value||"This Month")})}),a==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(gt,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:f=>l(f?f.format("YYYY-MM-DD"):"")})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(gt,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:f=>c(f?f.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(de,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(ce,{type:"button",value:"Search",color:"primary",onClick:R})})})]}),e.jsx(s.Tabs,{activeKey:t,onChange:n,items:Qr})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(de,{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(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:Qr.find(f=>f.key===t)?.label||"Report"})}),e.jsxs(de,{p:3,children:[t!=="dashboard"&&e.jsx(cn,{data:{tableRef:m}}),t==="dashboard"?D():e.jsx(s.Table,{size:"small",dataSource:I,columns:C(),loading:!1,pagination:!1,bordered:!0,rowKey:f=>f.npm_id||f.package_name||Math.random(),ref:m}),t!=="dashboard"&&g.length>0&&e.jsx(s.Pagination,{current:x,pageSize:u,total:g.length,onChange:(f,p)=>{y(f),S(p)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const Ma=t=>t??localStorage.getItem("authToken")??"",Ns=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},Ae={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"}},ho=()=>Ns(nt(),Ae.upload),ku=()=>Ns(nt(),Ae.staff.uploadProfile),Ou=()=>Ns(nt(),Ae.staff.uploadDocuments),Pu=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Ma(r))},bt=async(t,n,a)=>Ye(t,n,Ma(a)),Ft=async(t,n,a)=>pt(t,n,Ma(a)),qn=async(t,n,a)=>at(t,n,Ma(a)),zt=Ae.staff,Eu=Ae.master.shift.dropdown,Mu=Ae.master.department.dropdown,Fu=Ae.master.designation.dropdown,Nu=Ae.roleDropdown,ea=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},$u=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",bn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Xr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Uu({token:t,mode:n,staffId:a,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,x]=i.useState(r?.roleValue??null),[y,u]=i.useState(r?.departmentValue??null),[S,j]=i.useState(r?.designationValue??null),[w,m]=i.useState(r?.genderValue??null),[h,g]=i.useState(r?.shiftValue??(d?[]:null)),[I,R]=i.useState(r?.dob?ae(r.dob):null),[D,C]=i.useState(r?.doj?ae(r.doj):null),[f,p]=i.useState(r?.file??""),{data:b}=G(t?[Eu,t]:null,([q,z])=>Q(q,z)),{data:A}=G(t?[Mu,t]:null,([q,z])=>Q(q,z)),{data:O}=G(t?[Fu,t]:null,([q,z])=>Q(q,z)),{data:L}=G(t?[Nu,t]:null,([q,z])=>Q(q,z)),{data:U}=G(t?[zt.lastEmpNo,t]:null,([q,z])=>Q(q,z)),v=i.useMemo(()=>ea(b),[b]),M=i.useMemo(()=>ea(A),[A]),P=i.useMemo(()=>ea(O),[O]),N=i.useMemo(()=>ea(L),[L]),E=i.useMemo(()=>{const q=U?.data?.emp_number??U?.emp_number??U?.data??"";return String(q??"")},[U]),F=async q=>{q.preventDefault();const z=new FormData(q.target);z.set("role",c?.value??c??""),z.set("department",y?.value??y??""),z.set("designation",S?.value??S??""),z.set("gender",w?.value??w??""),z.set("dob",I?I.format("YYYY-MM-DD"):""),z.set("doj",D?D.format("YYYY-MM-DD"):""),d?(z.delete("shift_id"),(Array.isArray(h)?h:[]).forEach(T=>{z.append("shift_id[]",T?.value??T??"")})):z.set("shift_id",h?.value??h??""),f&&z.set("file",f);try{const k=n==="edit"&&a,T=k?zt.editBasic:zt.addBasic;k&&z.set("staff_id",String(a));const $=k?await Ft(T,z,t):await bt(T,z,t),B=$?.ID??$?.id??a??null;_.success("Success!",{duration:1e3}),o?.({staffId:B,basic:{roleValue:c,departmentValue:y,designationValue:S,genderValue:w,shiftValue:h,dob:I,doj:D,file:f}})}catch(k){_.error(k?.response?.data?.msg??k?.message??"Failed.",{duration:1e3})}};return 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.jsx(J,{type:"number",name:"emp_number",label:"EMP No",defaultValue:r?.emp_number??E,required:!0}),e.jsx(J,{type:"text",name:"f_name",label:"First Name",defaultValue:r?.f_name??"",required:!0}),e.jsx(J,{type:"text",name:"l_name",label:"Last Name",defaultValue:r?.l_name??"",required:!0}),e.jsx(J,{type:"text",name:"pan_no",label:"PAN",defaultValue:r?.pan_no??""}),e.jsx(J,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??""}),e.jsx(ee,{label:"Role",options:N,value:c,onChange:q=>x(q??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Department",options:M,value:y,onChange:q=>u(q??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Designation",options:P,value:S,onChange:q=>j(q??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:w,onChange:q=>m(q??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"email",label:"Email",defaultValue:r?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:bn,children:"DOB"}),e.jsx(s.DatePicker,{value:I,onChange:q=>R(q),style:Xr,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:bn,children:"DOJ"}),e.jsx(s.DatePicker,{value:D,onChange:q=>C(q),style:Xr,placeholder:"Select DOJ"})]}),e.jsx(J,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:r?.bloodGroup??""}),e.jsx(J,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0}),e.jsx(J,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:bn,children:"Shift"}),e.jsx(ee,{options:v,value:h,onChange:q=>g(q??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:bn,children:"Profile Picture"}),e.jsx(s.Upload,{maxCount:1,action:ku(),headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status==="done"){const z=$u(q?.file?.response);z&&p(z)}q?.file?.status==="removed"&&p("")},children:e.jsx(s.Button,{type:"link",style:{paddingLeft:0},children:f?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:bn,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(ce,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const ta={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Zr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Bu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ei=t=>{if(!t)return null;const n=ae(t);return n.isValid()?n:null};function Lu({token:t,mode:n,staffId:a,initialRows:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(m=>({name:m?.name??"",from:ei(m?.from),to:ei(m?.to),image:m?.image??""}))),x=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),y=(w,m)=>{c(h=>h.map((g,I)=>I===w?{...g,...m}:g))},u=()=>c(w=>[...w,{name:"",from:null,to:null,image:""}]),S=w=>c(m=>m.length<=1?m:m.filter((h,g)=>g!==w)),j=async w=>{if(w.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const m=new FormData;m.append("staff_id",String(a)),d.forEach((h,g)=>{m.append(`experience[${g}][name]`,String(h?.name??"")),m.append(`experience[${g}][from]`,h?.from?h.from.format("YYYY-MM-DD"):""),m.append(`experience[${g}][to]`,h?.to?h.to.format("YYYY-MM-DD"):""),m.append(`experience[${g}][image]`,String(h?.image??""))});try{const h=n==="edit",g=h?zt.editExperience:zt.addExperience,I=h?await Ft(g,m,t):await bt(g,m,t);_.success("Success!",{duration:1e3}),o?.({experience:d,result:I})}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((w,m)=>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:ta,children:"Name"}),e.jsx("input",{value:w.name,onChange:h=>y(m,{name:h.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:ta,children:"From"}),e.jsx(s.DatePicker,{value:w.from,onChange:h=>y(m,{from:h}),style:Zr})]}),e.jsxs("div",{children:[e.jsx("div",{style:ta,children:"To"}),e.jsx(s.DatePicker,{value:w.to,onChange:h=>y(m,{to:h}),style:Zr})]}),e.jsxs("div",{children:[e.jsx("div",{style:ta,children:"Document"}),e.jsx(s.Upload,{maxCount:1,action:Ou(),headers:x,onChange:h=>{if(h?.file?.status==="done"){const g=Bu(h?.file?.response);g&&y(m,{image:g})}h?.file?.status==="removed"&&y(m,{image:""})},children:e.jsx(s.Button,{icon:e.jsx(X.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(s.Button,{type:"text",icon:e.jsx(X.DeleteOutlined,{}),danger:!0,onClick:()=>S(m),disabled:d.length<=1})})]},`exp-${m}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(s.Button,{icon:e.jsx(X.PlusOutlined,{}),onClick:u,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(s.Button,{onClick:l,children:"Back"}),e.jsx(ce,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const ti=(t,n=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const a=n.length?n:["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 a){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[]},Sn=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function qu({token:t,mode:n,staffId:a,initialValues:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(r?.type??"Permanent"),[x,y]=i.useState(r?.salary_type??Sn[0]?.value),[u,S]=i.useState(Number(r?.amount??0)),[j,w]=i.useState(Number(r?.basic_pay)),[m,h]=i.useState(r?.declarationPERyear??""),{data:g}=G(t?[Sd,t]:null,([p,b])=>Q(p,b),{revalidateOnFocus:!1}),I=i.useMemo(()=>ti(g,["allowances","Allowances"]),[g]),R=i.useMemo(()=>ti(g,["dedection","Dedection","deductions","Deductions"]),[g]),D=i.useMemo(()=>{const p=Number(j||0),b=(Array.isArray(I)?I:[]).map(v=>{const M=v?.amount_type??v?.amountType??v?.type??"",P=Number(v?.Amount??v?.amount??0),E=String(M).trim().toLowerCase()==="flat"?P:Number(p)/100*Number(P||0);return{...v,value:Number.isFinite(E)?E:0}}),A=(Array.isArray(R)?R:[]).map(v=>{const M=v?.amount_type??v?.amountType??v?.type??"",P=Number(v?.Amount??v?.amount??0),E=String(M).trim().toLowerCase()==="flat"?P:Number(p)/100*Number(P||0);return{...v,value:Number.isFinite(E)?E:0}}),O=b.reduce((v,M)=>v+Number(M?.value||0),0),L=A.reduce((v,M)=>v+Number(M?.value||0),0),U=Math.max(0,Number(p)+O-L);return{allowances:b,deductions:A,netAmount:U}},[I,R,j]),C=async p=>{if(p.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const b=new FormData;b.append("staff_id",String(a)),b.append("type",d),d==="Nonpermanent"?(b.append("salary_type",x??""),b.append("amount",String(u||"")),b.append("Allowances",JSON.stringify([])),b.append("Dedection",JSON.stringify([]))):(b.append("basic_pay",String(j||"")),b.append("declarationPERyear",String(m??"")),b.append("Allowances",JSON.stringify(D.allowances||[])),b.append("Dedection",JSON.stringify(D.deductions||[])),b.append("amount",String(D.netAmount||0)));try{const A=n==="edit",O=A?zt.editPayroll:zt.addPayroll,L=A?await Ft(O,b,t):await bt(O,b,t);o?.({payroll:{staffType:d,salaryType:x,amount:u,basicPay:j,declaration:m},result:L})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed.",{duration:1e3})}},f=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(p,b)=>`${b?.Amount??""} / ${b?.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(ee,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:p=>c(p?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(ee,{label:"Type",options:Sn,value:Sn.find(p=>p.value===x)??Sn[0],onChange:p=>y(p?.value??Sn[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"number",label:"Amount",value:u,onChange:p=>S(Number(p.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{type:"number",label:"Basic Pay",value:j,onChange:p=>w(Number(p.target.value||0)),required:!0}),e.jsx(J,{type:"text",label:"IT Declarations/Year",value:m,onChange:p=>h(p.target.value)}),e.jsx(J,{type:"number",label:"Net Amount",value:D.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(p,b)=>`${p?.title??"a"}-${b}`,columns:f,dataSource:D.allowances,pagination:!1})}),e.jsx(s.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(p,b)=>`${p?.title??"d"}-${b}`,columns:f,dataSource:D.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(ce,{type:"submit",value:"Finish",color:"primary"})})]})})}const zu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Yu({token:t,mode:n="add",staffId:a,onFinished:r}){const[o,l]=i.useState(0),[d,c]=i.useState(a??null),[x,y]=i.useState(null),[u,S]=i.useState(null),[j,w]=i.useState(null),m=n==="edit"?a??d:null,h=i.useMemo(()=>m?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),g=i.useMemo(()=>m?`${Ae.staff.experienceById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),I=i.useMemo(()=>m?`${Ae.staff.payrollById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),{data:R}=G(t&&h?[h,t]:null,([O,L])=>Q(O,L)),{data:D}=G(t&&g?[g,t]:null,([O,L])=>Q(O,L)),{data:C}=G(t&&I?[I,t]:null,([O,L])=>Q(O,L)),f=i.useMemo(()=>{const O=zu(R)[0]??R?.data??R??null;return O?{emp_number:O?.emp_number??O?.empNo??"",f_name:O?.f_name??O?.firstname??O?.first_name??"",l_name:O?.l_name??O?.lastname??O?.last_name??"",pan_no:O?.pan_no??"",adhar_no:O?.adhar_no??"",email:O?.email??"",dob:O?.dob??"",doj:O?.doj??"",bloodGroup:O?.bloodGroup??O?.blood_group??"",contact_no:O?.contact_no??O?.phone??"",education:O?.education??"",address:O?.address??"",file:O?.file??O?.profile_picture??""}:null},[R]),p=i.useMemo(()=>{const O=D?.data??D??null;return(Array.isArray(O?.experience)?O.experience:Array.isArray(O)?O:[]).map(U=>({name:U?.name??"",from:U?.from??"",to:U?.to??"",image:U?.image??""}))},[D]),b=i.useMemo(()=>{const O=C?.data??C??null;return O?{type:O?.type??"Permanent",salary_type:O?.salary_type??"",amount:O?.amount??"",basic_pay:O?.basic_pay??"",declarationPERyear:O?.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(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:n==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(s.Steps,{current:o,items:A}),o===0&&e.jsx(Uu,{token:t,mode:n,staffId:m,initialValues:f,onSubmitted:({staffId:O})=>{O&&c(O),l(1)}}),o===1&&e.jsx(Lu,{token:t,mode:n,staffId:m??d,initialRows:p,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(qu,{token:t,mode:n,staffId:m??d,initialValues:b,onBack:()=>l(1),onSubmitted:()=>{_.success("Completed.",{duration:1e3}),r?.({staffId:m??d}),l(0),n!=="edit"&&(c(null),y(null),S(null),w(null))}})]})})]})}function Wu({token:t}){return e.jsx(Yu,{token:t,mode:"add"})}const Vu=({token:t})=>e.jsx(Wu,{token:t}),na=Ae.staff,Hu=Ae.roleDropdown,Ku=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Gu=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Ju({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(""),[l,d]=i.useState(""),{data:c}=G(t?[Hu,t]:null,([I,R])=>Q(I,R)),x=i.useMemo(()=>Ku(c),[c]),y=i.useMemo(()=>{const I=n.page,R=n.rowsPerPage,D=r&&!l?`${na.searchByRole}?role_id=${encodeURIComponent(String(r))}`:l?`${na.searchByKeywords}?key=${encodeURIComponent(String(l))}`:na.list,C=D.includes("?")?"&":"?";return`${D}${C}page=${encodeURIComponent(String(I))}&per_page=${encodeURIComponent(String(R))}`},[n.page,n.rowsPerPage,l,r]),{isLoading:u,error:S,data:j,mutate:w}=G(t?[y,t]:null,([I,R])=>Q(I,R)),m=i.useMemo(()=>Gu(j),[j]),h=async I=>{const R=I?.id??I?.fk_staffID??I?.staff_id;if(R)try{await qn(na.deactivate,R,t),_.success("Success! Staff deactivated.",{duration:1e3}),await w()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to deactivate staff.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(I,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:(I,R)=>e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(X.DeleteOutlined,{}),onClick:()=>h(R),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(s.Card,{title:e.jsx(s.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(ee,{options:[{value:"",label:"All Roles"},...x],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:I=>{o(I?.value??""),a(R=>({...R,page:1}))}}),e.jsx(J,{type:"text",label:"Keyword",value:l,onChange:I=>d(I.target.value),placeholder:"Search by keywords"}),e.jsx(ce,{type:"button",value:"Refresh",onClick:()=>w()})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:u,rowKey:I=>String(I?.id??I?.fk_staffID??I?.staff_id??Math.random()),columns:g,dataSource:m,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(I,R)=>a({page:I,rowsPerPage:R}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const Qu=({token:t})=>e.jsx(Ju,{token:t}),Xu=Ae.attendance,Zu=Ae.roleDropdown,ni=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},aa={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ai={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function ep({token:t,open:n,onClose:a,roleId:r,onSaved:o}){const[l,d]=i.useState(null),[c,x]=i.useState(""),[y,u]=i.useState(ae()),[S,j]=i.useState(ae()),[w,m]=i.useState(ae()),h=i.useMemo(()=>r?`${Ae.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:g}=G(t&&h?[h,t]:null,([p,b])=>Q(p,b)),I=i.useMemo(()=>ni(g),[g]),{trigger:R,data:D}=Je(t?Ae.attendance.staffShiftByStaffId:null,(p,{arg:b})=>qt(p,{arg:b},t)),C=i.useMemo(()=>ni(D),[D]),f=async()=>{if(!l?.value){_.error("Select staff.",{duration:1e3});return}if(!c){_.error("Select shift.",{duration:1e3});return}const p=new FormData;p.set("staffID",String(l.value)),p.set("shift_id",String(c)),p.set("attendance_date",y?y.format("YYYY-MM-DD"):""),p.set("intime",S?S.format("h:mm a"):""),p.set("outime",w?w.format("h:mm a"):"");try{await bt(Ae.attendance.manualAttendance,p,t),_.success("Success!",{duration:1e3}),o?.(),a?.(),d(null),x(""),u(ae()),j(ae()),m(ae())}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed.",{duration:1e3})}};return e.jsx(s.Modal,{open:n,onCancel:a,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(s.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{label:"Staff",options:I,value:l,onChange:async p=>{if(d(p??null),x(""),p?.value&&R)try{await R({staff_id:p.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:aa,children:"Shift"}),e.jsx(s.Radio.Group,{value:c,onChange:p=>x(p.target.value),style:{display:"grid",gap:8},children:C.map(p=>e.jsx(s.Radio,{value:p?.value,children:p?.label??p?.name??p?.title??String(p?.value??"")},String(p?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:aa,children:"Date"}),e.jsx(s.DatePicker,{value:y,onChange:p=>p&&u(p),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:aa,children:"Start Time"}),e.jsx(s.TimePicker,{value:S,onChange:p=>p&&j(p),use12Hours:!0,format:"h:mm a",style:ai})]}),e.jsxs("div",{children:[e.jsx("div",{style:aa,children:"End Time"}),e.jsx(s.TimePicker,{value:w,onChange:p=>p&&m(p),use12Hours:!0,format:"h:mm a",style:ai})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(s.Button,{onClick:a,children:"Cancel"}),e.jsx(ce,{type:"button",value:"Save",color:"primary",onClick:f})]})]})})})}const tp=({tableRef:t,excelDisabled:n})=>{const a=new Date().getTime(),r=ln.useReactToPrint({content:()=>t?.current});return e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(s.Row,{gutter:8,children:[e.jsx(s.Col,{children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:n?e.jsx(s.Button,{type:"text",icon:e.jsx(X.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>_.error("You must save attendance before download",{duration:2e3})}):e.jsx(po.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:t?.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},np=(t,n)=>{const a=t?.data?.data??t?.data??t??null;return a?n==="student"?Array.isArray(a?.student)?a.student:[]:Array.isArray(a?.staff)?a.staff:[]:[]},ap=t=>{const n=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,a=Number(n);return Number.isFinite(a)&&a>=0?a:0},sp=(t,n)=>{const a=t?.data?.data??t?.data??t??null;return a?n==="student"?{sunday:String(a?.sunday??"").toLowerCase()==="yes",holiday:String(a?.holiday??"").toLowerCase()==="yes"}:{sunday:!!a?.sunday,holiday:!!a?.holiday}:{sunday:!1,holiday:!1}};function rp({token:t,url:n,columns:a,reload:r,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:x="staff"}){const y=i.useRef(null),[u,S]=i.useState({page:0,rowsPerPage:10}),[j,w]=i.useState(!1),[m,h]=i.useState(!1),[g,I]=i.useState(null),[R,D]=i.useState([]),[C,f]=i.useState({sunday:!1,holiday:!1}),[p,b]=i.useState(!0);i.useEffect(()=>{S(U=>({...U,page:0}))},[n]),i.useEffect(()=>{let U=!0;return(async()=>{if(!(!t||!n)){w(!0);try{const M=String(n).includes("?")?"&":"?",P=`${n}${M}page=${u.page+1}&per_page=${u.rowsPerPage}`,N=await Q(P,t);if(!U)return;I(N),N?.Status==="Success"?(d?.(!1),D(np(N,x)),f(sp(N,x))):(d?.(!0),D([]),f({sunday:!1,holiday:!1}))}catch{if(!U)return;d?.(!0),D([])}finally{U&&w(!1)}}})(),()=>{U=!1}},[u.page,u.rowsPerPage,r,d,t,x,n]);const A=i.useMemo(()=>ap(g),[g]);i.useEffect(()=>{const U=(Array.isArray(R)?R:[]).find(v=>v?.attendence_type_id===null);b(!!U)},[R]);const O=async()=>{if(t){h(!0);try{if(x==="staff"){const U=(Array.isArray(R)?R:[]).map(v=>({staff_id:v?.staff_id,attendence_type_id:v?.attendence_type_id?v.attendence_type_id:"1",in_time:v?.intime,out_time:v?.outtime,date:c}));await bt(Ae.attendance.addAttendanceToStaffByBranch,U,t),_.success("Attendance saved successfully",{duration:2e3}),o?.(v=>!v)}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{h(!1)}}},L=i.useMemo(()=>(Array.isArray(a)?a:[]).map(v=>v?.selector==="attendence_type_id"?{title:v?.name??"Attendance",dataIndex:v.selector,key:v.selector,render:M=>M==null||M===""?e.jsx(s.Tag,{color:"orange",children:"Not Set"}):String(M)==="1"?e.jsx(s.Tag,{color:"green",children:"Present"}):String(M)==="4"?e.jsx(s.Tag,{color:"red",children:"Absent"}):String(M)==="3"?e.jsx(s.Tag,{color:"orange",children:"Late"}):e.jsx(s.Tag,{children:String(M)})}:v?.selector==="snum"?{title:v?.name??"Sl",key:v.selector,render:(M,P,N)=>N+1}:{title:v?.name??v?.selector,dataIndex:v?.selector,key:v?.selector}),[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{children:[e.jsx(tp,{tableRef:y,excelDisabled:p}),e.jsx(s.Modal,{open:m,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(s.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:y,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(U,v)=>String(U?.id??U?.staff_id??v),columns:L,dataSource:R,loading:j,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:A,showSizeChanger:!0,onChange:(U,v)=>S({page:U-1,rowsPerPage:v})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:O,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const ip=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},op={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function lp({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(ae().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,x]=i.useState(null),[y,u]=i.useState(!1),[S,j]=i.useState(!0),[w,m]=i.useState(!1),h=i.useRef(null),{data:g}=G(t?[Zu,t]:null,([D,C])=>Q(D,C)),I=i.useMemo(()=>ip(g),[g]),R=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(s.Card,{title:e.jsx(s.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(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:D=>a(D?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{defaultValue:ae(),onChange:D=>D&&o(D.format("YYYY-MM-DD")),style:op,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!r||(x(`${Xu.staffListForAttendance}?role=${encodeURIComponent(String(n))}&date=${encodeURIComponent(String(r))}`),d(D=>!D))}})})]})}),e.jsxs(s.Card,{title:e.jsx(s.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(s.Button,{size:"small",type:y?"primary":"default",onClick:()=>u(D=>!D),children:y?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"default",disabled:S,onClick:()=>m(!0),children:"Give Attendance"})]}),c?e.jsx(rp,{token:t,url:c,columns:R,reload:l,setReload:d,saveBtnRef:h,setSaveBtnDisabled:j,date:r,type:"staff",holidayChecked:y}):null]}),e.jsx(ep,{token:t,open:w,onClose:()=>m(!1),roleId:n,onSaved:()=>d(D=>!D)})]})}const dp=({token:t})=>e.jsx(lp,{token:t}),si=Ae.attendanceReport.monthlyStaffReport,cp=Ae.roleDropdown,up=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function pp({token:t}){const n=i.useRef(null),[a,r]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),x=i.useMemo(()=>Es(5),[]),{data:y}=G(t?[cp,t]:null,([U,v])=>Q(U,v)),u=i.useMemo(()=>up(y),[y]),[S,j]=i.useState([]),[w,m]=i.useState(1),[h,g]=i.useState(!1),[I,R]=i.useState(!1),[D,C]=i.useState(null),f=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:p}=Je(t&&si?`${si}?page=${w}&per_page=3`:null,(U,{arg:v})=>qt(U,{arg:v},t),{onSuccess:U=>{g(!1);const v=Array.isArray(U)?U:[];v.length>0&&j(M=>[...M||[],...v]),v.length>1?m(M=>M+1):R(!1)},onError:()=>{g(!1),R(!1)}});i.useEffect(()=>{I&&p&&D&&p(D)},[I,w,D,p]);const b=i.useMemo(()=>{const U=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(v,M)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:M?.full_name??""})}];return Array.isArray(S)&&S.length>0&&((S[0]?.monthly_data??[]).forEach((M,P)=>{U.push({title:P+1,align:"center",key:String(P+1),render:(N,E)=>{const F=E?.monthly_data?.[P]?.[0]?.data?.[0]??{},q=F?.intime??"",z=F?.outtime??"",k=F?.attendance_type??"";return e.jsx(s.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",q]}),e.jsxs("div",{children:["Out Time ",z]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:ze(k)})})}})}),U.push({title:"Total",key:"Total",render:(M,P)=>{const N=P?.monthly_data??[],E=N.filter(q=>q?.[0]?.data?.[0]?.attendance_type==="A").length,F=N.filter(q=>q?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",E," P : ",F]})})}})),U},[S]),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")}],[]),O=i.useMemo(()=>d.month?o.find(U=>U?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),L=async U=>{if(U.preventDefault(),!d.role||!d.year||!d.month)return;m(1),g(!0),j([]);const v={session:f,year:d.year,month:d.month,day:"01",role:d.role};C(v),R(!0),await p?.(v)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{className:"d-print-none",title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),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(ee,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:U=>c(v=>({...v,role:U?.value??"",rolllabel:U?.label??""}))}),e.jsx(ee,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:U=>{const v=Ms(U?.value);l(v),r(M=>!M),c(M=>({...M,year:U?.label??""}))}}),e.jsx(ee,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:U=>c(v=>({...v,month:U?.value??""}))},`month-${a}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(wt,{})}),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:O})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(cn,{data:{tableRef:n}})})]}),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(s.Skeleton,{active:!0,loading:h,paragraph:{rows:10},children:e.jsx(s.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:b,dataSource:S,pagination:!1,scroll:{x:"max-content"},rowKey:(U,v)=>String(U?.staff_id??U?.id??v)})})]})})]})}const mp=({token:t})=>e.jsx(pp,{token:t}),ri=Ae.payroll,yp=Ae.roleDropdown,fp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},hp=t=>t?.data?.data??t?.data??t??[];function gp({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:a}){const[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,x]=i.useState([]),[y,u]=i.useState({role:"",roleLabel:"",year:"",month:""}),[S,j]=i.useState(null),w=b=>{if(!b)return;if(typeof a=="function"){a(b);return}const A=`${n}?id=${encodeURIComponent(String(b))}`;typeof window<"u"&&window?.location&&(window.location.href=A)},{data:m}=G(t?[yp,t]:null,([b,A])=>Q(b,A)),h=i.useMemo(()=>fp(m),[m]),g=i.useMemo(()=>Es(5),[]),{isLoading:I,error:R,data:D}=G(t&&S?[S,t]:null,([b,A])=>Q(b,A)),C=i.useMemo(()=>{const b=hp(D);return Array.isArray(b)?b:[]},[D]),f=i.useMemo(()=>{const b=D?.pagination?.total_rows??D?.data?.pagination?.total_rows??D?.total??D?.total_rows,A=Number(b);return Number.isFinite(A)&&A>=0?A:C.length},[D,C.length]),p=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(b,A,O)=>O+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:(b,A)=>{const O=A?.id??A?.staff_id??A?.staffId;return e.jsx(s.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{w(O)},children:co(A?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:b=>{if(b.preventDefault(),!y.role||!y.year||!y.month)return;const A=`${ri.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`;j(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(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:b=>u(A=>({...A,role:b?.value??"",roleLabel:b?.label??""}))}),e.jsx(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:b=>{const A=Ms(b?.value);x(A),d(O=>!O),u(O=>({...O,year:b?.label??"",month:""}))}}),e.jsx(ee,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:b=>u(A=>({...A,month:b?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Search",color:"primary",onClick:()=>o(b=>({...b,page:1}))})})]})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:I,rowKey:(b,A)=>String(b?.id??b?.staff_id??A),columns:p,dataSource:C,pagination:{current:r.page,pageSize:r.rowsPerPage,total:f,showSizeChanger:!0,onChange:(b,A)=>{o({page:b,rowsPerPage:A}),!(!y.role||!y.year||!y.month)&&j(`${ri.payrollByRole}?page=${encodeURIComponent(String(b))}&per_page=${encodeURIComponent(String(A))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`)}},scroll:{x:"max-content"}})]})})}const xp=({token:t})=>e.jsx(gp,{token:t}),go=Ae.leave,pn=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>Pu({baseUrl:l,page:d,perPage:c},x)),bp=({token:t,page:n=1,perPage:a=10})=>pn({token:t,baseUrl:go.requestTable,page:n,perPage:a}),Sp=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},jp=(t,n)=>{const a=new FormData;return Object.entries(t??{}).forEach(([r,o])=>{o!=null&&a.append(r,String(o))}),a.set("status",n),a};function vp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:o,data:l,mutate:d}=bp({token:t,page:n.page,perPage:n.rowsPerPage}),c=i.useMemo(()=>Sp(l),[l]),x=async(u,S)=>{try{const j=jp(u,S),w=await Ft(go.approveRequest,j,t);w?.Status==="Success"?_.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):_.error(w?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to update request.",{duration:1e3})}},y=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,S)=>S?.full_name??S?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,S)=>S?.leave_from??S?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,S)=>S?.leave_to??S?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,S)=>S?.leavetype??S?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,S)=>S?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,S)=>S?.employee_remark??S?.reason??""},{title:"View",key:"document_file",width:140,render:(u,S)=>{const j=S?.document_file;return j?e.jsx(s.Button,{size:"small",onClick:()=>window.open(j,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,S)=>{const j=String(S?.status??"").toLowerCase();return j==="approved"?e.jsx(s.Tag,{color:"green",children:"Approved"}):j==="declined"?e.jsx(s.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(s.Button,{type:"text",size:"small",onClick:()=>x(S,"approved"),icon:e.jsx(X.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(s.Button,{type:"text",size:"small",onClick:()=>x(S,"declined"),icon:e.jsx(X.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:r,rowKey:(u,S)=>String(u?.id??u?.leave_id??S),columns:y,dataSource:c,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(u,S)=>a({page:u,rowsPerPage:S}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const _p=({token:t})=>e.jsx(vp,{token:t}),wp=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Cp=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:ho(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=wp(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},xo=Ae.leave,Ap=Ae.master.leaveType.dropdown,Tp=({token:t,page:n=1,perPage:a=10})=>pn({token:t,baseUrl:xo.table,page:n,perPage:a}),Rp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ds={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ip({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c]=s.Form.useForm(),{isLoading:x,error:y,data:u,mutate:S}=Tp({token:t,page:n.page,perPage:n.rowsPerPage}),{data:j}=G(t?[Ap,t]:null,([C,f])=>Q(C,f)),w=i.useMemo(()=>Rp(j),[j]),m=(C,f)=>a({page:C,rowsPerPage:parseInt(f,10)}),h=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:ae()}),o(!0)},g=()=>{o(!1),d(""),c.resetFields()},I=async C=>{const f=new FormData;f.set("apply_date",C?.apply_date?C.apply_date.format("YYYY-MM-DD"):""),f.set("leave_type",C?.leave_type?.value??C?.leave_type??""),f.set("from_date",C?.from_date?C.from_date.format("YYYY-MM-DD"):""),f.set("to_date",C?.to_date?C.to_date.format("YYYY-MM-DD"):""),f.set("reason",C?.reason??""),l&&f.set("file",l);try{await bt(xo.apply,f,t),_.success("Success! Leave request submitted.",{duration:1e3}),g(),await S()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to submit leave request.",{duration:1e3})}},R=i.useMemo(()=>{const C=u?.data??u??[];return Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[]},[u]),D=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(C,f)=>f?.leavetype??f?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(C,f)=>f?.date??f?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(C,f)=>f?.leave_from??f?.from_date??""},{title:"To",key:"leave_to",width:130,render:(C,f)=>f?.leave_to??f?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(C,f)=>f?.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(s.Modal,{open:r,title:"Add Leave Request",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:c,layout:"vertical",onFinish:I,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.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(s.DatePicker,{style:ds})]})}),e.jsx(s.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(ee,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsx(s.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(s.DatePicker,{style:ds})]})}),e.jsx(s.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(s.DatePicker,{style:ds})]})}),e.jsx(s.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(J,{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(Cp,{token:t,value:l,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(ce,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(ce,{type:"button",value:"Add Leave Request",onClick:h})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:x,rowKey:(C,f)=>String(C?.id??C?.leave_id??f),columns:D,dataSource:R,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(C,f)=>m(C,f),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Dp=({token:t})=>e.jsx(Ip,{token:t}),ga=Ae.master.leaveType,kp=({token:t,page:n=1,perPage:a=10})=>pn({token:t,baseUrl:ga.table,page:n,perPage:a});function Op({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:y,error:u,data:S,mutate:j}=kp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,f)=>{a({page:C,rowsPerPage:parseInt(f,10)})},m=async C=>{const f=new FormData;f.set("title",C?.title??"");try{await j(bt(ga.add,f,t),st(f)),_.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add leave type.",{duration:1e3})}},h=C=>{x(C??null),o.setFieldsValue({title:C?.leave_type_name??C?.name??""}),d(!0)},g=()=>{d(!1),x(null),o.resetFields()},I=async C=>{const f=c?.id??c?.leave_type_id;if(!f){_.error("Missing leave type id.",{duration:1e3});return}const p=new FormData;p.set("id",String(f)),p.set("title",C?.title??"");try{await Ft(ga.edit,p,t),await j(),_.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),g()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to update leave type.",{duration:1e3})}},R=async C=>{const f=C?.id??C?.leave_type_id;if(f)try{await j(qn(ga.remove,f,t),Qe(f)),_.success("Success! Deleted leave type.",{duration:1e3})}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete leave type.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,f)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(f)}),e.jsx(s.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>R(f),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Leave Type",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(ce,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(ce,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:S,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const Pp=({token:t})=>e.jsx(Op,{token:t}),xa=Ae.master.department,Ep=({token:t,page:n=1,perPage:a=10})=>pn({token:t,baseUrl:xa.table,page:n,perPage:a});function Mp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:y,error:u,data:S,mutate:j}=Ep({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,f)=>{a({page:C,rowsPerPage:parseInt(f,10)})},m=async C=>{const f=new FormData;f.set("title",C?.title??"");try{await j(bt(xa.add,f,t),st(f)),_.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add department.",{duration:1e3})}},h=C=>{x(C??null),o.setFieldsValue({title:C?.department_name??C?.name??""}),d(!0)},g=()=>{d(!1),x(null),o.resetFields()},I=async C=>{const f=c?.id??c?.department_id;if(!f){_.error("Missing department id.",{duration:1e3});return}const p=new FormData;p.set("id",String(f)),p.set("title",C?.title??"");try{await Ft(xa.edit,p,t),await j(),_.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),g()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to update department.",{duration:1e3})}},R=async C=>{const f=C?.id??C?.department_id;if(f)try{await j(qn(xa.remove,f,t),Qe(f)),_.success("Success! Deleted department.",{duration:1e3})}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete department.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,f)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(f)}),e.jsx(s.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>R(f),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Department",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(ce,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(ce,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:S,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const Fp=({token:t})=>e.jsx(Mp,{token:t}),ba=Ae.master.designation,Np=({token:t,page:n=1,perPage:a=10})=>pn({token:t,baseUrl:ba.table,page:n,perPage:a});function $p({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:y,error:u,data:S,mutate:j}=Np({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,f)=>{a({page:C,rowsPerPage:parseInt(f,10)})},m=async C=>{const f=new FormData;f.set("title",C?.title??"");try{await j(bt(ba.add,f,t),st(f)),_.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add designation.",{duration:1e3})}},h=C=>{x(C??null),o.setFieldsValue({title:C?.designation??""}),d(!0)},g=()=>{d(!1),x(null),o.resetFields()},I=async C=>{const f=c?.id??c?.designation_id;if(!f){_.error("Missing designation id.",{duration:1e3});return}const p=new FormData;p.set("id",String(f)),p.set("title",C?.title??"");try{await Ft(ba.edit,p,t),await j(),_.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),g()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to update designation.",{duration:1e3})}},R=async C=>{const f=C?.id??C?.designation_id;if(f)try{await j(qn(ba.remove,f,t),Qe(f)),_.success("Success! Deleted designation.",{duration:1e3})}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete designation.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,f)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(f)}),e.jsx(s.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>R(f),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Designation",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(ce,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(ce,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:S,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const Up=({token:t})=>e.jsx($p,{token:t}),Sa=Ae.master.shift,Bp=({token:t,page:n=1,perPage:a=10})=>pn({token:t,baseUrl:Sa.table,page:n,perPage:a}),Ze="hh:mm A",Zt=t=>{const n=String(t??"");if(!n)return null;const a=ae(n,[Ze,"HH:mm","HH:mm:ss"],!0);return a.isValid()?a:null},en=t=>t?t.format(Ze):"",ut={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Lp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:y,error:u,data:S,mutate:j}=Bp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(p,b)=>{a({page:p,rowsPerPage:parseInt(b,10)})},m=(p,b)=>{const A=new FormData;return b&&A.set("id",String(b)),A.set("name",p?.name??""),A.set("start_time",en(p?.start_time)),A.set("end_time",en(p?.end_time)),A.set("shift_start_from",en(p?.shift_start_from)),A.set("shift_start_to",en(p?.shift_start_to)),A.set("shift_end_from",en(p?.shift_end_from)),A.set("shift_end_to",en(p?.shift_end_to)),A},h=async p=>{try{const b=m(p);await j(bt(Sa.add,b,t),st(b)),_.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to add shift.",{duration:1e3})}},g=p=>{x(p??null),o.setFieldsValue({name:p?.shift_name??p?.name??"",start_time:Zt(p?.start_time),end_time:Zt(p?.end_time),shift_start_from:Zt(p?.shift_start_from),shift_start_to:Zt(p?.shift_start_to),shift_end_from:Zt(p?.shift_end_from),shift_end_to:Zt(p?.shift_end_to)}),d(!0)},I=()=>{d(!1),x(null),o.resetFields()},R=async p=>{const b=c?.id??c?.shift_id;if(!b){_.error("Missing shift id.",{duration:1e3});return}try{const A=m(p,b);await Ft(Sa.edit,A,t),await j(),_.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),I()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update shift.",{duration:1e3})}},D=async p=>{const b=p?.id??p?.shift_id;if(b)try{await j(qn(Sa.remove,b,t),Qe(b)),_.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:(p,b)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>g(b)}),e.jsx(s.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>D(b),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]),f=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Shift",onCancel:I,footer:null,destroyOnClose:!0,children:e.jsxs(s.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(s.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(s.Form.Item,{name:"start_time",label:"Start Time",rules:f,children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:f,children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:I,children:"Cancel"}),e.jsx(ce,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(s.Form,{form:r,layout:"vertical",onFinish:h,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(s.Form.Item,{name:"start_time",label:"Start Time",rules:f,children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:f,children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ut})}),e.jsx(ce,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:S,columns:C,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const qp=({token:t})=>e.jsx(Lp,{token:t}),ii=Ae.attendance;function zp({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((n,a)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:n?.shift_name??""},`${a}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((n,a)=>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"})]},`${a}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((n,a)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${n?.name??""} ${n?.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:n?.attendance_data?(n.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:n?.attendance_data?(n.attendance_data?.[r?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${a}`))]},`${a}row`))})]})}):null}const Yp=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Wp=t=>{const n=String(t??"").toLowerCase();return n==="present"?e.jsx(s.Tag,{color:"green",children:"Present"}):n==="absent"?e.jsx(s.Tag,{color:"red",children:"Absent"}):n==="leave"?e.jsx(s.Tag,{color:"orange",children:"Leave"}):e.jsx(s.Tag,{children:t??""})};function Vp({token:t}){const[n,a]=i.useState(ae()),[r,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${r?ii.dailyAttendanceMultipleShift:ii.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,r,l]),{isLoading:x,error:y,data:u}=G(t?[c,t]:null,([h,g])=>Q(h,g)),S=i.useMemo(()=>Yp(u),[u]),j=i.useMemo(()=>r?u?.data?.data??u?.data??u??null:null,[u,r]),w=ln.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),m=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(h,g,I)=>I+1},{title:"Name",key:"name",render:(h,g)=>`${g?.name??""} ${g?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(h,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[Wp(g?.attendance),g?.late_time?e.jsx(s.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(h,g)=>g?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(h,g)=>g?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(h,g)=>g?.late_time?e.jsx(s.Tag,{color:"red",children:g.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.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(s.DatePicker,{value:n,onChange:h=>h&&a(h),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(s.Switch,{checked:r,onChange:o})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"button",value:"Search",onClick:()=>d(h=>h+1)})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(X.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(wt,{})}),r?e.jsx(zp,{data:j}):e.jsx(s.Table,{bordered:!0,size:"small",loading:x,rowKey:(h,g)=>String(h?.id??h?.staff_id??g),columns:m,dataSource:S,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const Hp=({token:t})=>e.jsx(Vp,{token:t}),oi=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Kp=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 Gp({token:t,staffId:n}){const[a,r]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[x,y]=i.useState(""),[u,S]=i.useState(""),j=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),w=O=>{const L=Number(O??0),U=Number.isFinite(L)?L.toLocaleString("en-IN"):"0";return`${j?`${j} `:""}${U}`},m=i.useMemo(()=>n?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),h=i.useMemo(()=>n?`${Ae.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:g}=G(t&&m?[m,t]:null,([O,L])=>Q(O,L)),{data:I,isLoading:R,mutate:D}=G(t&&h?[h,t]:null,([O,L])=>Q(O,L)),C=i.useMemo(()=>oi(g)[0]??g?.data??g??null,[g]),f=i.useMemo(()=>oi(I),[I]),p=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:(O,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(O,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(O,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(O,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(O,L)=>e.jsx("div",{style:{cursor:L?.status==="due"?"pointer":"default"},onClick:()=>{L?.status==="due"&&(l(L),r(!0))},children:co(L?.status)})}],[]),b=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 O={...o,staff_id:n,payment_type:d?.value??"",notes:x,attchement:u};try{await Ye(Ae.payroll.generatePayslip,{arg:O},t),_.success("Success!",{duration:1e3}),r(!1),l(null),y(""),S(""),await D()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.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(s.Table,{bordered:!0,size:"small",loading:R,rowKey:(O,L)=>String(O?.id??`${O?.month}-${L}`),columns:p,dataSource:f,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(s.Modal,{open:a,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(ee,{label:"Pay",options:b,value:d,onChange:O=>c(O??b[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(s.Input.TextArea,{rows:4,placeholder:"Note",value:x,onChange:O=>y(O.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(s.Upload,{maxCount:1,action:ho(),headers:t?{Authorization:t}:void 0,onChange:O=>{if(O?.file?.status==="done"){const L=Kp(O?.file?.response);L&&S(L)}O?.file?.status==="removed"&&S("")},children:e.jsx(s.Button,{icon:e.jsx(X.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(s.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(ce,{type:"button",value:o?.Total_Payable_Amount?`Pay ${w(o.Total_Payable_Amount)}`:"Pay",onClick:A})]})]})})]})}function Jp({token:t,staffId:n}){const a=i.useMemo(()=>{if(n!=null&&String(n).trim()!=="")return n;if(typeof window>"u")return null;const r=new URLSearchParams(window.location.search).get("id");return r||null},[n]);return a?e.jsx(Gp,{token:t,staffId:a}):e.jsx(s.Card,{title:e.jsx(s.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 Nt({onAdd:t,onExport:n,onPrint:a,onDownload:r,onFilter:o,onRefresh:l,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(X.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(X.FileExcelOutlined,{}),onClick:n},{key:"print",title:"Print",icon:e.jsx(X.PrinterOutlined,{}),onClick:a},{key:"download",title:"Download",icon:e.jsx(X.DownloadOutlined,{}),onClick:r},{key:"filter",title:"Filter",icon:e.jsx(X.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(X.ReloadOutlined,{}),onClick:l}],[t,n,a,r,o,l]),x=i.useMemo(()=>{const y=Array.isArray(d)&&d.length?new Set(d):null;return y?c.filter(u=>y.has(u.key)):c},[c,d]);return e.jsx(s.Space,{size:8,children:x.map(y=>e.jsx(s.Tooltip,{title:y.title,children:e.jsx(s.Button,{type:"text",icon:y.icon,onClick:y.onClick,disabled:!y.onClick})},y.key))})}const $s=t=>t??localStorage.getItem("authToken")??"",_t={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"}},Ot=async(t,n)=>Q(t,$s(n)),Qp=async(t,n,a)=>Ye(t,n,$s(a)),Xp=async(t,n,a)=>kn(t,{arg:n},$s(a)),On=(t,n)=>{const a=new URLSearchParams;Object.entries(n??{}).forEach(([o,l])=>{l==null||l===""||a.set(o,String(l))});const r=t.includes("?")?"&":"?";return`${t}${r}${a.toString()}`},li=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},Zp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},bo=(t,n)=>{const a=t?.data?.data??t?.data??t??{},r=n?a?.[n]:a;return Array.isArray(r)?r:Array.isArray(a?.student)?a.student:Array.isArray(a?.staff)?a.staff:Array.isArray(a?.data)?a.data:[]},em=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],tm=t=>{const n={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(a=>{if(Array.isArray(a?.monthly_data)||Array.isArray(a?.month_data)){em(a).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")&&(n.present+=1),(d==="A"||d==="4")&&(n.absent+=1),(d==="L"||d==="3")&&(n.late+=1),(d==="LEAVE"||d==="2")&&(n.leave+=1)});return}const r=String(a?.attendance_type??a?.attendence_type_id??"").toUpperCase();(r==="P"||r==="1")&&(n.present+=1),(r==="A"||r==="4")&&(n.absent+=1),(r==="L"||r==="3")&&(n.late+=1),(r==="LEAVE"||r==="2")&&(n.leave+=1)}),n},Us=(t,n)=>{const{data:a,isLoading:r,error:o}=G(n&&t?[t,n]:null,([l,d])=>Ot(l,d));return{isLoading:r,error:o,data:a,options:i.useMemo(()=>Zp(a),[a])}},Fa=t=>Us(_t.dropdowns.classes,t),Na=(t,n)=>{const a=t?`${_t.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return Us(a,n)},nm=t=>Us(_t.dropdowns.sessions,t),Bs=t=>{const n=String(t??"").toUpperCase();return ze(n==="1"||n==="P"||n==="PRESENT"?"P":n==="4"||n==="A"||n==="ABSENT"?"A":n==="3"||n==="L"||n==="LATE"?"L":n==="2"||n==="LEAVE"?"LEAVE":n==="W"?"W":n==="H"?"H":n||"-")},So=(t,n,a)=>{const r=new Blob([t],{type:n}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.download=a,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},di=t=>String(t??"").replace(/"/g,'""'),am=({rows:t,columns:n,fileName:a})=>{const r=Array.isArray(n)?n:[],o=Array.isArray(t)?t:[],l=r.map(c=>`"${di(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,x)=>r.map(y=>{const u=y?.dataIndex??y?.selector??y?.key,S=u==="sl"?x+1:c?.[u];return`"${di(S)}"`}).join(",")).join(`
|
|
59
|
+
`}),e.jsx(le,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(un,{data:{tableRef:$}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:$,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(s.Select,{size:"small",value:k.rowsPerPage,onChange:te=>B(1,te),options:[10,25,50,100].map(te=>({label:te,value:te})),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(s.Input,{size:"small",allowClear:!0,value:P,onChange:te=>{N(te.target.value),T(me=>({...me,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(X.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(Ct,{})}),ge]}),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 ${ye} to ${xe} of ${He} entries`}),e.jsx(s.Pagination,{current:k.page,pageSize:k.rowsPerPage,total:He||0,showSizeChanger:!1,onChange:B})]})]})]})},Qd=({token:t,type:n})=>{const[a,r]=i.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${a.page}&per_page=${a.rowsPerPage}`,{isLoading:c,data:x,error:y}=G(t?[d,t]:null,([R,D])=>Q(R,D)),[u,S]=i.useState(!1),j=(R,D)=>{r({page:R,rowsPerPage:parseInt(D)})},w=async R=>{},m=R=>{console.log("dsdsdsdsd",R),S(R)},h=()=>{},g=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],I=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(R,D)=>R.name.localeCompare(D.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(R,D)=>(R.contact||"").localeCompare(D.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(R,D)=>(R.description||"").localeCompare(D.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(R,D)=>(R.source_name||"").localeCompare(D.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(R,D)=>new Date(R.date)-new Date(D.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(R,D)=>new Date(R.follow_up_date)-new Date(D.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Le,{parentCallback:j,data:{newData:x,columns:I,action:!0,Loading:c,error:y,open:u,viewDetails:h,deleteTodoMutation:w,DrawerUpdate:m,ActionView:g}})})},Xd={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"},de=i.forwardRef(({error:t,success:n,disabled:a,style:r,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:a,style:{...Xd,opacity:a?.7:1,cursor:a?"not-allowed":"pointer",...r||{}}})})),dt=({id:t,funcName:n,disabled:a=!1})=>{const r="Data",[o,l]=i.useState(!1),d=()=>{l(!0),n(t),s.message.success(`${r} deleted successfully!`)},c=()=>{s.message.info(`Deletion of ${r} cancelled`)};return e.jsx(s.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:a||o,children:e.jsx(s.Button,{danger:!0,disabled:a,loading:o,icon:e.jsx(X.DeleteOutlined,{}),size:"small"})})},rt=t=>({optimisticData:n=>[...n.data,t],populateCache:(n,a)=>[...a.data,n]}),Qe=t=>({optimisticData:n=>n.data.filter(a=>a.id!==t),populateCache:(n,a)=>a.data.filter(r=>r.id!==t)}),Rr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Zd({token:t}){const[n,a]=i.useState({pagination:{current:1,pageSize:10}}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/routeTableList?page=${n.pagination.current}&per_page=${n.pagination.pageSize}`,x="api/branchapi/Transport/addroute",y="api/branchapi/Transport/editroute",u="api/branchapi/Transport/deleteroute",{isLoading:S,data:j,error:w,mutate:m}=G(t?[c,t]:null,([A,O])=>Q(A,O)),h=async(A,O)=>{try{await m(Ye(A,O,t),rt(O)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},g=A=>{A.preventDefault();const O=new FormData(A.target);h(x,O),A.target.reset()},I=(A,O)=>{a(L=>({...L,pagination:{current:A,pageSize:parseInt(O,10)}}))},R=async A=>{try{await m(st(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)},C=async A=>{try{await mt(y,A,t),await m(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},f=async A=>{A.preventDefault();const O=new FormData(A.target);O.append("id",l?.id),C(O)},p=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(A,O)=>A.name.localeCompare(O.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(A,O)=>A.fare-O.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,O)=>A.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(A,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(O),style:{padding:2}}),e.jsx(dt,{id:O?.id,funcName:R})]})}],b=l?.route_title?`Edit ${l.route_title}`:"Edit Route";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:b,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:f,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"title",label:"Title",defaultValue:l?.route_title||"",required:"required"}),e.jsx(J,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:l?.fare||"",required:"required"}),e.jsx(J,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(J,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Rr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Route"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"}),e.jsx(J,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"}),e.jsx(J,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:Rr,children:"Cancel"})]})]})})})]})}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:I,data:{newData:j,columns:p,columnstype:"antd",action:!1,Loading:S,error:w,deleteTodoMutation:R}})})]})})]})})]})}const Ir={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function ec({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${n.page}&per_page=${n.rowsPerPage}`,x="api/branchapi/Transport/addvehicles",y="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:S,data:j,error:w,mutate:m}=G(t?[c,t]:null,([A,O])=>Q(A,O)),h=async(A,O)=>{try{await m(Ye(A,O,t),rt(O)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},g=A=>{A.preventDefault();const O=new FormData(A.target);h(x,O),A.target.reset()},I=async A=>{try{await m(st(u,A,t),Qe(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},R=A=>{d(A),o(!0)},D=async A=>{try{await mt(y,A,t),await m(),_.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 O=new FormData(A.target);O.append("id",l?.id),D(O)},f=(A,O)=>{a({page:A,rowsPerPage:parseInt(O,10)})},p=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(A,O)=>A.vehicle_no.localeCompare(O.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(A,O)=>A.vehicle_model.localeCompare(O.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(A,O)=>A.seating_capacity-O.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(A,O)=>A.manufacture_year-O.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(A,O)=>A.gps_url.localeCompare(O.gps_url)},render:(A,O)=>e.jsx("span",{title:O?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:O?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,O)=>A.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(A,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>R(O),style:{padding:2}}),e.jsx(dt,{id:O?.id,funcName:I})]})}],b=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:b,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(J,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(J,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(J,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(J,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(J,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(J,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Ir,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(J,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(J,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(J,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(J,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(J,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:Ir,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:f,data:{newData:j,columns:p,columnstype:"antd",action:!1,Loading:S,error:w,deleteTodoMutation:I}})})]})})]})})]})}var tc=oo();const as=so(tc),mo=()=>{};class Fs extends i.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=n=>{this.selectRef=n};componentDidUpdate(n){n.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(n,a)=>{this.props.onChange(n,a),this.setState({value:n})};getValue=()=>{const{value:n}=this.state;return n?Array.isArray(n)?n.length?"valid":"":typeof n=="object"?n.value||"":n:""};render(){const{SelectComponent:n,required:a,...r}=this.props;console.log("sdsdsfsdddddddd",{...r});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(n,{...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:mo,onFocus:()=>this.selectRef.focus(),required:a})]})}}Fs.defaultProps={onChange:mo};Fs.protoTypes={selectComponent:as.func.isRequired,onChange:as.func,required:as.bool};const nc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ac={menuPortal:t=>({...t,zIndex:9999}),control:(t,n)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${n.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${n.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,n)=>({...t,padding:"0 0 0 8px",color:n.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,n)=>({...t,fontSize:"14px",backgroundColor:n.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},yo=t=>e.jsx(Pi.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),sc=t=>e.jsx(Fs,{...t,SelectComponent:Pi,components:{Input:yo},options:t.options}),ee=i.forwardRef(({...t},n)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:nc,children:t?.label}),e.jsx(sc,{components:{Input:yo},menuPortalTarget:document.body,styles:ac,className:"input-cont",...t,ref:n})]})),rc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Dr=({dataIndex:t,title:n,record:a,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function ic({token:t}){const[n,a]=i.useState(!1),[r,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,x]=i.useState([]),y="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",S="api/branchapi/Transport/getchechkedVehicleData",j="api/branchapi/Transport/assignedVehicleTable",w="api/branchapi/transport/assignvehicle",m="api/branchapi/Transport/deleteassignvehicle",h=l?`${S}?route_id=${l}`:null,{isLoading:g,data:I,mutate:R}=G(t?[`${j}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([T,$])=>Q(T,$)),{data:D}=G(t&&y?[y,t]:null,([T,$])=>Q(T,$)),{data:C}=G(t&&u?[u,t]:null,([T,$])=>Q(T,$)),f=t&&h?[h,t]:null,{isLoading:p,data:b}=G(f,([T,$])=>Q(T,$)),{Status:A="Failed",pagination:{total_rows:O=0}={}}=I||{},{data:L=[]}=A==="Success"?I:{},U=i.useMemo(()=>{const T=D?.data??D??[];return Array.isArray(T)?T:[]},[D]),v=i.useMemo(()=>{const T=C?.data??C??[];return(Array.isArray(T)?T:[]).map(B=>{if(B==null)return null;if(typeof B=="string"||typeof B=="number")return{label:String(B),value:B};const Y=B.value??B.vehicle_id??B.id??B.vehicleID,ne=B.label??B.vehicle_name??B.vehicle_no??B.vehicle_number??B.name??String(Y??"");return Y==null||ne===""?null:{label:String(ne),value:Y}}).filter(Boolean)},[C]),M=i.useMemo(()=>{const T=b?.data??b??[];return(Array.isArray(T)?T:[]).map(B=>B?.value??B?.vehicle_id??B?.id??B).filter(B=>B!=null)},[b]);i.useEffect(()=>{x(M)},[M,n]);const P=async(T,$,B)=>{try{await R(Ye(T,$,t),rt($)),h&&G.mutate(f),a(Y=>!Y),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(Y){_.error(Y?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},N=T=>{T.preventDefault();const $=new FormData;$.append("route_id",l??""),c.length?c.forEach(B=>$.append("vehicle_ids[]",B)):$.append("vehicle_ids[]",""),P(w,$)},E=T=>{o($=>({...$,pagination:{current:T,pageSize:$.pagination.pageSize}}))},F=async T=>{try{await R(st(m,T,t),Qe(T)),h&&G.mutate(f),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},q=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(T,$,B)=>e.jsx(e.Fragment,{children:$.children.map((Y,ne,H)=>e.jsx("span",{children:`${Y.vehicle_name} ${ne+1===H.length?"":","}`},`${ne}vehicle001`))})},{title:"Action",render:(T,$,B)=>e.jsx(e.Fragment,{children:e.jsx(dt,{id:$?.route_id,funcName:F})})}],z=T=>{const $=["route_id","index"];for(let B=0;B<$.length;B++)if(T[$[B]])return T[$[B]]},k=T=>{const{children:$=[]}=T||{},B=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:Y=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:Y=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:Y=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:Y=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:Y=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:Y=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:Y=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(s.Table,{components:{body:{cell:Dr}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:B,rowKey:Y=>z(Y)+"cell01",dataSource:$,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:T=>{d(T?.value??null),a($=>!$)}})}),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(s.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:v,value:c,onChange:T=>x(T),disabled:!l||p})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),x([]),a(T=>!T)},style:rc,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(le,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:Dr}},columns:q,bordered:!0,rowKey:T=>z(T),dataSource:Array.isArray(L)?L:[],loading:g,expandable:{expandedRowRender:k,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:O,showSizeChanger:!0,onChange:E,onShowSizeChange:(T,$)=>{o(B=>({...B,pagination:{current:1,pageSize:$}}))},showTotal:(T,$)=>`${$[0]}-${$[1]} of ${T} items`}})})]})})]})})]})}const oc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},lc={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},dc=(t,n,a)=>n?t>ae(a).endOf("day")||t<ae(n).endOf("day"):!1,xt=i.forwardRef(function(n,a){const{...r}=n;return e.jsxs("div",{className:"form-group",children:[r.Desplay&&e.jsx("label",{className:`labelfont ${r.classnme?r.classnme:""}`,style:oc,children:r.Desplay}),e.jsx(s.DatePicker,{...r,style:{...lc,...r.style||{}},className:"form-group",disabledDate:o=>dc(o,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:a})]})}),kr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ss=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Xt=(t,n,a)=>{if(n==null||n==="")return null;const r=t.find(o=>String(o.value)===String(n));return r||(a?{label:String(a),value:n}:{label:String(n),value:n})},cc=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},uc=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(a=>a!=null&&a!==""&&String(a).toLowerCase()!=="null"&&String(a).toLowerCase()!=="undefined").join(", ");const n=String(t).trim();return!n||n.toLowerCase()==="null"||n.toLowerCase()==="undefined"?"":n};function pc({token:t,assignmentId:n,studentName:a,onClose:r,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",x="api/branchapi/Transport/getvehicleListByRouteIdwithCount",y="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[S,j]=i.useState(null),[w,m]=i.useState(null),[h,g]=i.useState(null),[I,R]=i.useState(ae()),[D,C]=i.useState(""),[f,p]=i.useState(0),[b,A]=i.useState(0),{data:O,isLoading:L}=G(t&&n?[`${l}?id=${n}`,t]:null,([V,oe])=>Q(V,oe)),U=i.useMemo(()=>{if(!O||O?.Status&&O.Status!=="Success")return null;const V=O?.data??O;return Array.isArray(V)?V[0]??null:V},[O]);i.useEffect(()=>{const V=U?.fk_route_id??U?.route_id;V!=null&&j(V),U?.vehicle_id!=null&&m(U.vehicle_id),U?.stop_id!=null&&g(U.stop_id),R(U?.start_date?ae(U.start_date):ae()),C(uc(U?.service_push))},[U]);const v=t&&S?`${x}?route_id=${S}`:null,M=t&&S?`${u}?id=${S}`:null,P=t&&S?`${y}?route_id=${S}`:null,{data:N}=G(t&&c?[c,t]:null,([V,oe])=>Q(V,oe)),{data:E,isLoading:F}=G(v?[v,t]:null,([V,oe])=>Q(V,oe)),{data:q,isLoading:z}=G(P?[P,t]:null,([V,oe])=>Q(V,oe)),{data:k}=G(M?[M,t]:null,([V,oe])=>Q(V,oe)),T=i.useMemo(()=>ss(N),[N]),$=i.useMemo(()=>ss(E),[E]),B=i.useMemo(()=>ss(q),[q]),Y=O?.data[0]?.rootCost,ne=cc(),H=a||[U?.firstname,U?.lastname].filter(Boolean).join(" ")||"",W=(V,oe)=>{switch(oe){case"route_id":j(V?.value??null),m(null),g(null),p(Ce=>Ce+1),A(Ce=>Ce+1);break;case"vehicle_id":m(V?.value??null),g(null),A(Ce=>Ce+1);break;case"stop_id":g(V?.value??null);break}},Z=async V=>{if(V.preventDefault(),!S||!w||!h){_.error("Please select Route, Vehicle and Stop",{duration:1200});return}const oe=new FormData;oe.append("id",String(n)),oe.append("student_id",String(U?.fk_student_id??U?.student_id??"")),oe.append("fk_route_id",String(S)),oe.append("vehicle_id",String(w)),oe.append("stop_id",String(h)),oe.append("rootCost",String(Y??"")),oe.append("start_date",I?.isValid?.()?I.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),oe.append("puse_service",String(D??""));try{await mt(d,oe,t),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),r?.()}catch(Ce){_.error(Ce?.message??"Failed to update the item.",{duration:1e3})}};if(L||!(U&&!L&&(!S||!F&&!z)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(s.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(s.Button,{type:"text",onClick:r,style:kr,children:"Close"})]});const pe=U.fk_route_id??U.route_id,ve=Xt(T,pe,U.route_title),re=Xt($,U.vehicle_id,U.vehicle_name??U.vehicle_no),ie=Xt(B,U.stop_id,U.stop_name??U.stoppage_name);return e.jsx("form",{onSubmit:Z,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"title",label:"Student",defaultValue:H,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:U.fk_student_id??U.student_id??""}),e.jsx(ee,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:Xt(T,S,ve?.label)??null,onChange:V=>W(V,"route_id")}),e.jsx(ee,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Xt($,w,re?.label)??null,onChange:V=>W(V,"vehicle_id")},`edit-vehicle-${f}`),e.jsx(ee,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Xt(B,h,ie?.label)??null,onChange:V=>W(V,"stop_id")},`edit-stop-${b}`),e.jsx(J,{type:"text",label:"Route Cost",value:Y!=null?`${ne}${Y}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:Y??""}),e.jsx(xt,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:I,onChange:V=>R(V)}),e.jsx(J,{type:"text",label:"Pause Service",value:D,onChange:V=>C(V?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:r,style:kr,children:"Cancel"})]})]})},`edit-${n}-${f}`)}const Or={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},mc=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[]},xn=t=>mc(t),yc=t=>t||"",fc=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},hc=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},gc=(t,n)=>{const a=n||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",o=encodeURIComponent(String(r));if(a.includes("{id}"))return a.replaceAll("{id}",o);if(a.includes(":id"))return a.replace(":id",o);try{const d=new URL(a,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(r)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=a.includes("?")?"&":"?";return`${a}${l}id=${o}`};function xc({token:t,editType:n,onNavigate:a,editPagePath:r}){const l=hc(n)==="drawer",d="api/branchapi/academy/classdropdownlist",c="api/branchapi/academy/sectionoftheClass",x="api/branchapi/Transport/routeStudentList",y="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleListByRouteIdwithCount",S="api/branchapi/Transport/getStoppageDropdown",j="api/branchapi/Transport/routeShowdata",w="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",[h,g]=i.useState(null),[I,R]=i.useState(!1),[D,C]=i.useState(!1),[f,p]=i.useState(null),[b,A]=i.useState(null),[O,L]=i.useState(null),[U,v]=i.useState(null),[M,P]=i.useState(!1),[N,E]=i.useState(!1),[F,q]=i.useState({page:1,rowsPerPage:50}),[z,k]=i.useState(null),[T,$]=i.useState(!1),[B,Y]=i.useState(null),[ne,H]=i.useState(null),[W,Z]=i.useState(null),[se,pe]=i.useState(null),[ve,re]=i.useState(null),[ie,V]=i.useState(null),[oe,Ce]=i.useState(null),[Oe,Pe]=i.useState(ae()),[Fe,Ee]=i.useState(""),Ve=(fe,be)=>{const Xe=fe?.value??null;switch(be){case"class_id":Z(Xe),pe(null),k(Xe?`${c}?class_id=${encodeURIComponent(String(Xe))}`:null),R(vt=>!vt);break;case"route_id":re(Xe),V(null),Ce(null),H(Xe),A(Xe?`${u}?route_id=${encodeURIComponent(String(Xe))}`:null),L(Xe?`${j}?id=${encodeURIComponent(String(Xe))}`:null),v(null),P(vt=>!vt),E(vt=>!vt);break;case"vehicle_id":V(Xe),Ce(null),v(ve?`${S}?route_id=${encodeURIComponent(String(ve))}`:null),E(vt=>!vt);break;case"stop_id":Ce(Xe);break}},He=fe=>{if(l){p(fe),C(!0);return}const be=gc(fe,r);if(typeof a=="function"){a(be,fe);return}typeof window<"u"&&be&&window.location.assign(be)},Ue=()=>{C(!1),p(null)},We=f?`Edit — ${f.firstname??""} ${f.lastname??""}`.trim():"Edit Student Transport",{data:it}=G(t&&d?[d,t]:null,([fe,be])=>Q(fe,be)),{data:ye}=G(t&&z?[z,t]:null,([fe,be])=>Q(fe,be)),{data:xe}=G(t&&b?[b,t]:null,([fe,be])=>Q(fe,be)),{data:ge}=G(t&&U?[U,t]:null,([fe,be])=>Q(fe,be)),{data:te}=G(t&&O?[O,t]:null,([fe,be])=>Q(fe,be)),{data:me}=G(t&&y?[y,t]:null,([fe,be])=>Q(fe,be)),he=t&&h?`${h}&page=${F.page}&per_page=${F.rowsPerPage}`:null,{isLoading:Te,error:Re,data:ht,mutate:Tt}=G(he?[he,t]:null,([fe,be])=>Q(fe,be)),Rt=i.useMemo(()=>xn(it),[it]),Ht=i.useMemo(()=>xn(ye),[ye]),Kt=i.useMemo(()=>xn(xe),[xe]),Gt=i.useMemo(()=>xn(ge),[ge]),ue=i.useMemo(()=>xn(me),[me]),Se=te?.data?.[0]?.fare??te?.data?.fare??te?.fare??te?.data?.data?.[0]?.fare??te?.data?.data?.fare;console.log("aaaaaaaaaaaa",te),i.useEffect(()=>{Se==null||Se===""||Ee(String(Se))},[Se]);const Ge=async fe=>{try{await Tt(st(m,fe,t),Qe(fe)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},jt=[{title:"Route Status",key:"route_status",render:(fe,be)=>be.fk_route_id?e.jsx("span",{children:be.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(fe,be)=>yc(be.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:(fe,be)=>`${be.firstname} ${be.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(fe,be)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:be.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(dt,{id:be?.id,funcName:Ge}),e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>He(be),style:{padding:2}})]}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.PlusOutlined,{}),onClick:()=>ce(be.student_id),style:{padding:2}})})}],qa=async(fe,be)=>{try{await Tt(Ye(fe,be,t),rt(be)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),$(!1),ke()}catch{_.error("Failed to add the new item.",{duration:1e3})}},za=fe=>{if(fe.preventDefault(),!W||!se){_.error("Please select Class and Section",{duration:1200});return}g(`${x}?cID=${encodeURIComponent(String(W))}&sID=${encodeURIComponent(String(se))}`),q(be=>({...be,page:1}))},Ya=(fe,be)=>{q({page:fe,rowsPerPage:parseInt(be,10)})},ce=fe=>{Y(fe),$(!0)},je=fe=>{if(fe.preventDefault(),!B){_.error("Student is required",{duration:1200});return}if(!ve||!ie||!oe){_.error("Please select Route, Vehicle and Stop",{duration:1300});return}const be=new FormData;be.append("student_id",String(B)),be.append("fk_route_id",String(ve)),be.append("vehicle_id",String(ie)),be.append("stop_id",String(oe)),be.append("start_date",Oe?.isValid?.()?Oe.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),be.append("rootCost",String(Fe??"")),qa(w,be)},ke=()=>{$(!1),A(null),L(null),v(null),H(null),re(null),V(null),Ce(null),Pe(ae()),Ee(""),P(fe=>!fe),E(fe=>!fe)},Be=fc();return e.jsxs("div",{children:[l&&e.jsx(s.Drawer,{open:D,title:We,placement:"right",width:420,destroyOnClose:!0,onClose:Ue,children:f?.id&&e.jsx(pc,{token:t,assignmentId:f.id,studentName:`${f.firstname??""} ${f.lastname??""}`.trim(),onClose:Ue,onSuccess:()=>Tt()})}),e.jsx(s.Modal,{open:T,title:"Assign Student to Transport",onCancel:ke,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:je,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[e.jsx(ee,{options:ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:ue.find(fe=>String(fe.value)===String(ve))??null,onChange:fe=>Ve(fe,"route_id")}),e.jsx(ee,{options:Kt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Kt.find(fe=>String(fe.value)===String(ie))??null,onChange:fe=>Ve(fe,"vehicle_id")},`vehicle001${M}`),e.jsx(ee,{options:Gt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Gt.find(fe=>String(fe.value)===String(oe))??null,onChange:fe=>Ve(fe,"stop_id")},`stop001${N}`),e.jsx(xt,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Oe,onChange:fe=>Pe(fe)}),e.jsx(J,{type:"text",name:"rootCost",label:"Route Cost",value:Fe,onChange:fe=>Ee(fe?.target?.value??"")}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:String(Fe??"").trim()?`${Be}${Fe} — Assign`:"Assign",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:ke,style:Or,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Search Students"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:za,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:Rt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:fe=>Ve(fe,"class_id"),required:!0,allowSelectAll:!1,value:Rt.find(fe=>String(fe.value)===String(W))??null}),e.jsx(ee,{options:Ht,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:Ht.find(fe=>String(fe.value)===String(se))??null,onChange:fe=>pe(fe?.value??null)},`section1${I}`),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Search",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{g(null),k(null),Z(null),pe(null),R(fe=>!fe)},style:Or,children:"Cancel"})]})]})})})]}),h&&e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Student List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:Ya,data:{newData:ht,columns:jt,columnstype:"antd",action:!1,Loading:Te,error:Re,deleteTodoMutation:Ge,pageController:F}})})]})})]})})]})}const Pr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Gn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function bc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[y,u]=i.useState(""),[S,j]=i.useState(""),[w,m]=i.useState(!1),h=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,g="api/branchapi/Transport/add_driver",I="api/branchapi/Transport/edit_driver",R="api/branchapi/Transport/deletedriver",D="api/branchapi/staff/uploadDocuments",C=i.useMemo(()=>String(D).startsWith("http")?D:`${at()??""}${String(D).replace(/^\/+/,"")}`,[D]),f=at()??"",{isLoading:p,data:b,error:A,mutate:O}=G(t?[h,t]:null,([z,k])=>Q(z,k)),L=async(z,k)=>{try{await Ye(z,k,t),await O(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),x("")}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},U=z=>{z.preventDefault();const k=new FormData(z.target);L(g,k),z.target.reset()},v=async z=>{try{await O(st(R,z,t),Qe(z)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},M=z=>{d(z),x(z?.image??""),o(!0)},P=async z=>{try{await mt(I,z,t),await O(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(k){_.error(k?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},N=z=>{z.preventDefault();const k=new FormData(z.target);k.append("id",l?.id??""),P(k)},E=(z,k)=>{a({page:z,rowsPerPage:parseInt(k,10)})},F=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(z,k)=>String(z?.name??"").localeCompare(String(k?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(z,k)=>String(z?.Driver_licence??"").localeCompare(String(k?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(z,k)=>Number(z?.contact_number??0)-Number(k?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(z,k)=>String(z?.address??"").localeCompare(String(k?.address??""))}},{title:"Image",key:"image",width:100,render:(z,k)=>{const T=k?.image?`${f}staff/document/${k.image}`:"";return T?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(s.Image,{width:80,src:T,preview:{visible:!1,onVisibleChange:()=>{m(!0),u(T),j(k?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(z,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>M(k),style:{padding:2}}),e.jsx(dt,{id:k?.id,funcName:v})]})}],q=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:q,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(J,{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:Gn,children:"Address"}),e.jsx(s.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:Gn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const k=z?.file?.response,T=k?.data??k?.filename??k?.file??k?.path??"";T&&x(String(T))},children:e.jsx(s.Button,{icon:e.jsx(X.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(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Pr,children:"Cancel"})]})]})})}),e.jsx(s.Modal,{zIndex:9999,open:w,title:S,footer:null,onCancel:()=>m(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:y})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(le,{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(J,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(J,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(J,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Gn,children:"Address"}),e.jsx(s.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:Gn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const k=z?.file?.response,T=k?.data??k?.filename??k?.file??k?.path??"";T&&x(String(T))},children:e.jsx(s.Button,{icon:e.jsx(X.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(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>x(""),style:Pr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:E,data:{newData:b,columns:F,columnstype:"antd",action:!1,Loading:p,error:A,deleteTodoMutation:v}})})]})})]})})]})}const Er={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Zt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Jn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Mr=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],Qn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Sc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,x]=i.useState(null),[y,u]=i.useState(null),[S,j]=i.useState(null),[w,m]=i.useState(null),[h,g]=i.useState(ae()),[I,R]=i.useState(ae()),[D,C]=i.useState("pick"),[f,p]=i.useState(!1),[b,A]=i.useState(null),[O,L]=i.useState(null),[U,v]=i.useState(!1),[M,P]=i.useState(null),[N,E]=i.useState(null),[F,q]=i.useState(null),[z,k]=i.useState(null),[T,$]=i.useState(ae()),[B,Y]=i.useState(ae()),[ne,H]=i.useState("pick"),W=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,Z="api/branchapi/Transport/assignRouteTime",se="api/branchapi/Transport/editAssignRouteTime",pe="api/branchapi/Transport/deleteAssignRouteTime",ve="api/branchapi/Transport/driverDropdown",re="api/branchapi/transport/routeTimetableShowdata",ie="api/branchapi/Transport/getrouteDropdown",V="api/branchapi/Transport/getvehicleDropdown",{isLoading:oe,data:Ce,error:Oe,mutate:Pe}=G(t?[W,t]:null,([ue,Se])=>Q(ue,Se)),{data:Fe}=G(t&&ie?[ie,t]:null,([ue,Se])=>Q(ue,Se)),{data:Ee}=G(t&&ve?[ve,t]:null,([ue,Se])=>Q(ue,Se)),Ve=i.useMemo(()=>c?`${V}?route_id=${c}`:null,[c,V]),{data:He}=G(t&&Ve?[Ve,t]:null,([ue,Se])=>Q(ue,Se)),Ue=i.useMemo(()=>Qn(Fe),[Fe]),We=i.useMemo(()=>Qn(Ee),[Ee]),it=i.useMemo(()=>Qn(He),[He]),ye=(ue,Se)=>{a({page:ue,rowsPerPage:parseInt(Se,10)})},xe=async ue=>{ue.preventDefault();const Se=new FormData(ue.target);Se.set("route_id",y?.value??c??""),Se.set("driver_id",S?.value??""),Se.set("vehicle_id",w?.value??""),Se.set("start_time",h?h.format("h:mm a"):""),Se.set("drop_time",I?I.format("h:mm a"):""),Se.set("type",D);try{await Ye(Z,Se,t),await Pe(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),ue.target.reset(),x(null),u(null),j(null),m(null),d(Ge=>!Ge),g(ae()),R(ae()),C("pick"),o(Ge=>!Ge)}catch(Ge){_.error(Ge?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},ge=async ue=>{try{await st(pe,ue,t),await Pe(),_.success("Success! Deleted item.",{duration:1e3})}catch(Se){_.error(Se?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},te=ue=>{A(ue),p(!0);const Se=ue?.id??ue?.route_time_id??ue?.routeId??null;L(Se);const Ge=ue?.route_id??ue?.routeId??ue?.fk_route_id;P(Ge??null),E(Ue.find(jt=>jt?.value===(Ge??ue?.route_id))??null),q(We.find(jt=>jt?.value===(ue?.driver_id??ue?.driverId))??null),k(null),v(jt=>!jt),$(ue?.start_time?ae(ue.start_time,["h:mm a","HH:mm"]):ae()),Y(ue?.drop_time?ae(ue.drop_time,["h:mm a","HH:mm"]):ae()),H(ue?.type??"pick")},me=i.useMemo(()=>{if(!O)return null;const ue=String(re).includes("?")?"&":"?";return`${re}${ue}id=${encodeURIComponent(String(O))}`},[O,re]),{data:he,isLoading:Te}=G(t&&me?[me,t]:null,([ue,Se])=>Q(ue,Se)),Re=i.useMemo(()=>{const ue=he?.data??he;return Array.isArray(ue)?ue[0]??null:Array.isArray(ue?.data)?ue.data[0]??null:ue??null},[he]),ht=i.useMemo(()=>M?`${V}?route_id=${M}`:null,[M,V]),{data:Tt}=G(t&&ht?[ht,t]:null,([ue,Se])=>Q(ue,Se)),Rt=i.useMemo(()=>Qn(Tt),[Tt]);i.useEffect(()=>{if(!Re)return;const ue=Re?.route_id??Re?.fk_route_id??Re?.routeId;P(ue??null),E(Ue.find(Se=>Se?.value===ue)??null),q(We.find(Se=>Se?.value===Re?.driver_id)??null),k(null),$(Re?.start_time?ae(Re.start_time,["h:mm a","HH:mm"]):ae()),Y(Re?.drop_time?ae(Re.drop_time,["h:mm a","HH:mm"]):ae()),H(Re?.type??"pick"),v(Se=>!Se)},[We,Re,Ue]),i.useEffect(()=>{if(!Re)return;const ue=Re?.vehicle_id??Re?.vehicleId;ue&&k(Rt.find(Se=>Se?.value===ue)??null)},[Re,Rt]);const Ht=async ue=>{if(ue.preventDefault(),!O)return;const Se=new FormData(ue.target);Se.set("id",String(O)),Se.set("route_id",N?.value??M??""),Se.set("driver_id",F?.value??""),Se.set("vehicle_id",z?.value??""),Se.set("start_time",T?T.format("h:mm a"):""),Se.set("drop_time",B?B.format("h:mm a"):""),Se.set("type",ne);try{await mt(se,Se,t),await Pe(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),p(!1),A(null)}catch(Ge){_.error(Ge?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Kt=[{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:(ue,Se)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>te(Se),style:{padding:2}}),e.jsx(dt,{id:Se?.id??Se?.routeId??Se?.route_time_id,funcName:ge})]})}],Gt=b?.route_title?`Edit ${b.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:f,title:Gt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{p(!1),A(null),L(null),P(null),E(null),q(null),k(null)},children:e.jsx("form",{onSubmit:Ht,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Te?.6:1},children:[e.jsx(ee,{options:Ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:N,onChange:ue=>{P(ue?.value??null),E(ue??null),k(null),v(Se=>!Se)}}),e.jsx(ee,{options:We,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:F,onChange:ue=>q(ue??null)}),e.jsx(ee,{options:Rt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:z,onChange:ue=>k(ue??null)},`edit-vehicle-${U}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Zt,children:"Start Time"}),e.jsx(s.TimePicker,{value:T,onChange:ue=>$(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Jn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Zt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:B,onChange:ue=>Y(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Jn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Zt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Mr,optionType:"button",buttonStyle:"solid",value:ne,onChange:ue=>H(ue.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{p(!1),A(null)},style:Er,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:xe,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:Ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:y,onChange:ue=>{x(ue?.value??null),u(ue??null),m(null),d(Se=>!Se)},allowSelectAll:!1,required:!0}),e.jsx(ee,{options:We,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:S,onChange:ue=>j(ue??null),allowSelectAll:!1,required:!0}),e.jsx(ee,{options:it,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:w,onChange:ue=>m(ue??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Zt,children:"Start Time"}),e.jsx(s.TimePicker,{value:h,onChange:ue=>g(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Jn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Zt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:I,onChange:ue=>R(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Jn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Zt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Mr,optionType:"button",buttonStyle:"solid",value:D,onChange:ue=>C(ue.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>{x(null),u(null),j(null),m(null),d(ue=>!ue),g(ae()),R(ae()),C("pick"),o(ue=>!ue)},style:Er,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:ye,data:{newData:Ce,columns:Kt,columnstype:"antd",action:!1,Loading:oe,error:Oe,deleteTodoMutation:ge}})})]})})]})})]})}const jc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Fr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Nr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},$r=({dataIndex:t,title:n,record:a,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let Ur=2;function vc({token:t}){const[n,a]=i.useState([]),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:y,data:u,mutate:S}=G(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([P,N])=>Q(P,N)),{Status:j="Failed",pagination:{total_rows:w=0}={}}=u||{},{data:m=[]}=j==="Success"?u:{},{data:h}=G(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([P,N])=>Q(P,N)),g=i.useMemo(()=>{const P=h?.data??h??[];if(Array.isArray(P))return P;if(P&&typeof P=="object"){if(Array.isArray(P?.data))return P.data;if(Array.isArray(P?.data?.data))return P.data.data}return[]},[h]),{data:I}=G(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([P,N])=>Q(P,N)),{Status:R="Failed"}=I||{},D=async(P,N)=>{try{await S(Ye(P,N,t),rt(N)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},C=P=>P?typeof P=="string"?P:P?.isValid?.()?P.format("h:mm a"):"":"",f=(P,N=[])=>{const E=(Array.isArray(P)?P:[]).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)})),F=E.filter(z=>z?.id!=null&&String(z.id).trim()!==""),q=E.filter(z=>!(z?.id!=null&&String(z.id).trim()!==""));return{route_id:r??"",edit_stoppage:F,add_stoppage:q,delete_stoppage:Array.isArray(N)?N:[]}},p=P=>{P.preventDefault();const N="/api/branchapi/transport/addstoppageToRoute",E=f(n,l);D(N,E)},b=()=>{a(P=>[...Array.isArray(P)?P:[],{idKey:Ur++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}])},A=P=>{if(n.length===1)return;const N=n[P];N?.id!=null&&String(N.id).trim()!==""&&!N?.idKey&&d(E=>{const F=Array.isArray(E)?E:[];return F.some(z=>String(z)===String(N.id))?F:[...F,N.id]}),a(E=>{const F=[...E];return F.splice(P,1),F})},O=P=>{x(N=>({...N,pagination:{current:P,pageSize:N.pagination.pageSize}}))},L=async P=>{const N="/api/branchapi/Transport/deletevehicle";try{await S(st(N,P,t),Qe(P)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(R==="Success"){const P=Array.isArray(I?.data)?I.data:[];P.length>0?(a(P),d([])):r&&(a([{idKey:Ur++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}]),d([]))}},[R,I,r]);const U=P=>{const{children:N=[]}=P||{},E=[{title:"Stop Name",dataIndex:"stop_name",onCell:F=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:F=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:F=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(s.Table,{components:{body:{cell:$r}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:E,rowKey:F=>v(F)+"cell01",dataSource:N,pagination:!1})})})},v=P=>{const N=["id","index"];for(let E=0;E<N.length;E++)if(P[N[E]])return P[N[E]]},M=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(P,N,E)=>e.jsx(e.Fragment,{children:(Array.isArray(N.children)?N.children:[]).map((F,q,z)=>e.jsx("span",{children:`${F.stop_name} ${q+1===z.length?"":","}`},`${q}vehicle001`))})},{title:"Action",render:(P,N,E)=>e.jsx(e.Fragment,{children:e.jsx(dt,{id:N?.route_id,funcName:L})})}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(le,{pt:5,pb:1,children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(le,{px:3,pb:2,children:e.jsxs("form",{onSubmit:p,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(ee,{options:g,value:g.find(P=>String(P.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:P=>{o(P?.value??null),a([]),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:b,children:e.jsx(X.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(de,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),a([]),d([])},style:jc,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((P,N)=>{const E=P.pickup_time?ae(P.pickup_time,"h:mm a"):null,F=P.drop_time?ae(P.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(J,{value:P.stop_name??"",type:"text",name:`stoppage[${N}][name]`,label:"Place Name*",required:"required",onChange:q=>{const z=q?.target?.value??"";a(k=>{const T=[...k];return T[N]={...T[N]??{},stop_name:z},T})}}),P?.id!=null&&String(P.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${N}][id]`,value:String(P.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Fr,children:"Pick Time"}),e.jsx(s.TimePicker,{value:E,use12Hours:!0,format:"h:mm a",name:`stoppage[${N}][pickTime]`,allowClear:!1,style:Nr,onChange:q=>{const z=q?q.format("h:mm a"):"";a(k=>{const T=[...k];return T[N]={...T[N]??{},pickup_time:z},T})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Fr,children:"Drop Time"}),e.jsx(s.TimePicker,{value:F,use12Hours:!0,format:"h:mm a",name:`stoppage[${N}][drop_time]`,allowClear:!1,style:Nr,onChange:q=>{const z=q?q.format("h:mm a"):"";a(k=>{const T=[...k];return T[N]={...T[N]??{},drop_time:z},T})}})]}),e.jsx("div",{style:{marginBottom:8},children:n.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>A(N),children:e.jsx(X.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},P.idKey?P.idKey+"exp":P.id+"exp")})})]})}),e.jsx(le,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(le,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:$r}},columns:M,bordered:!0,size:"small",rowKey:P=>v(P),dataSource:m,loading:y,expandable:{expandedRowRender:U,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:w,showSizeChanger:!0,onChange:O,onShowSizeChange:(P,N)=>{x(E=>({...E,pagination:{current:1,pageSize:N}}))},showTotal:(P,N)=>`${N[0]}-${N[1]} of ${P} items`}})})]})]})}const _c=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`};function wc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState(null),[o,l]=i.useState(null),[d,c]=i.useState(null),[x,y]=i.useState(null),[u,S]=i.useState(null),[j,w]=i.useState(null),[m,h]=i.useState(null),g="api/branchapi/library/bookCategorydropdown",I="api/branchapi/academy/classdropdownlist",R="api/branchapi/Academy/getClassSubjectdropdown",D="api/branchapi/library/addBook",C="api/branchapi/library/uploadcsv",{data:f}=G(n?[g,n]:null,([v,M])=>Q(v,M)),{data:p}=G(n&&I?[I,n]:null,([v,M])=>Q(v,M)),{data:b}=G(n&&R?[R,n]:null,([v,M])=>Q(v,M)),A=i.useMemo(()=>_c(at(),C),[C]),O=async v=>{v.preventDefault();const M=new FormData(v.target);M.set("cat_id",u?.value??""),M.set("class_id",j?.value??""),M.set("subject_id",m?.value??"");try{await Ye(D,M,n),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),v.target.reset(),S(null),w(null),h(null)}catch(P){_.error(P?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},L=async v=>{if(v.preventDefault(),!a){_.error("Please select a CSV file.",{duration:1e3});return}const M=new FormData;M.append("file",a),M.append("cat_id",o?.value??""),M.append("class_id",d?.value??""),M.append("subject_id",x?.value??"");try{const P=await Ne.post(A,M,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});P?.data?.Status==="Failed"?_.error(String(P?.data?.msg??"Upload failed."),{duration:1e3}):(_.success(String(P?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),r(null),v.target.reset(),l(null),c(null),y(null))}catch(P){_.error(P?.response?.data?.msg??"Upload failed.",{duration:1e3})}},U=()=>{fetch("/books.csv").then(v=>{v.blob().then(M=>{const P=window.URL.createObjectURL(M);let N=document.createElement("a");N.href=P,N.download="/books.csv",N.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(s.Button,{type:"link",icon:e.jsx(X.DownloadOutlined,{}),onClick:U,children:"Download Sample"}),children:[e.jsx(s.Divider,{children:"Information"}),e.jsx(s.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:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:v=>l(v??null)}),e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:v=>c(v??null)}),e.jsx(ee,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:x,onChange:v=>y(v??null)}),e.jsx(J,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:v=>r(v.target.files?.[0]??null),required:!0}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(J,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(J,{type:"text",label:"Publication",name:"publisher"}),e.jsx(J,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(J,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(J,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(J,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:v=>S(v??null)}),e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:j,onChange:v=>w(v??null)}),e.jsx(ee,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:m,onChange:v=>h(v??null)}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})})]})}const rs={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},is=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Cc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:a,onChange:(Z,se)=>{r(Z),l(se)}},x=dn.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),y=()=>{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}x?.()}},[u,S]=i.useState(!1),[j,w]=i.useState(null),[m,h]=i.useState(null),[g,I]=i.useState(null),[R,D]=i.useState(null),[C,f]=i.useState({page:1,rowsPerPage:10}),p=(Z,se)=>{f({page:Z,rowsPerPage:parseInt(se,10)})},b="api/branchapi/library/booktable",A="api/branchapi/library/deletebooks",O="api/branchapi/library/editbook",L=`${b}?page=${C.page}&per_page=${C.rowsPerPage}`,{isLoading:U,error:v,data:M,mutate:P}=G(n?[L,n]:null,([Z,se])=>Q(Z,se)),N="api/branchapi/library/bookCategorydropdown",E="api/branchapi/academy/classdropdownlist",F="api/branchapi/Academy/getClassSubjectdropdown",{data:q}=G(n?[N,n]:null,([Z,se])=>Q(Z,se)),{data:z}=G(n&&E?[E,n]:null,([Z,se])=>Q(Z,se)),{data:k}=G(n&&F?[F,n]:null,([Z,se])=>Q(Z,se)),T=i.useMemo(()=>is(q),[q]),$=i.useMemo(()=>is(z),[z]),B=i.useMemo(()=>is(k),[k]),Y=async Z=>{try{await st(A,Z,n),await P(),_.success("Success! Deleted item.",{duration:1e3})}catch(se){_.error(se?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ne=Z=>{w(Z??null);const se=Z?.cat_id??Z?.fk_cat_id??Z?.category_id,pe=Z?.class_id??Z?.fk_class_id,ve=Z?.subject_id??Z?.fk_subject_id;h(T.find(re=>re?.value===se)??null),I($.find(re=>re?.value===pe)??null),D(B.find(re=>re?.value===ve)??null),S(!0)},H=async Z=>{Z.preventDefault();const se=j?.id??j?.book_id??j?._id;if(!se)return;const pe=new FormData(Z.target);pe.set("id",String(se)),pe.set("cat_id",m?.value??""),pe.set("class_id",g?.value??""),pe.set("subject_id",R?.value??"");try{await mt(O,pe,n),await P(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),S(!1),w(null)}catch(ve){_.error(ve?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},W=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:(Z,se)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>ne(se),style:{padding:2}}),e.jsx(s.Button,{type:"text",size:"small",danger:!0,onClick:()=>Y(se?.id??se?.book_id??se?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[T,$,Y,B]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:u,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{S(!1),w(null)},children:e.jsx("form",{onSubmit:H,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(J,{label:"Book Name",name:"title",defaultValue:j?.book_title??"",required:!0}),e.jsx(J,{label:"Author",name:"author",defaultValue:j?.author??"",required:!0}),e.jsx(J,{label:"Publication",name:"publish",defaultValue:j?.publish??""}),e.jsx(J,{label:"Qty",name:"quantity",type:"number",defaultValue:j?.quantity??""}),e.jsx(J,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:j?.perunitcost??""}),e.jsx(J,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:j?.fine_amount??""}),e.jsx(J,{label:"Barcode",name:"barcode",defaultValue:j?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:rs,children:"Category"}),e.jsx(ee,{options:T,value:m,onChange:Z=>h(Z??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:rs,children:"Class"}),e.jsx(ee,{options:$,value:g,onChange:Z=>I(Z??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:rs,children:"Subject"}),e.jsx(ee,{options:B,value:R,onChange:Z=>D(Z??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{S(!1),w(null)},children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(s.Button,{type:"primary",onClick:y,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Le,{parentCallback:p,data:{newData:M,columns:W,columnstype:"antd",action:!1,Loading:U,error:v,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((Z,se)=>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:Z.book_title}),e.jsx(Ei,{value:Z.barcode?String(Z.barcode):String(Z.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},se))})})})]})}const Ac=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`},It=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Xn=t=>ae(t).add(1,"month").format("YYYY-MM-DD");function Tc({token:t,onReturn:n}){const a=t??localStorage.getItem("authToken")??"",[r,o]=i.useState("issue"),l=r==="return",[d,c]=i.useState(!1),[x,y]=i.useState(!1),[u,S]=i.useState(null),[j,w]=i.useState([]),[m,h]=i.useState([]),[g,I]=i.useState([]),[R,D]=i.useState(0),[C,f]=i.useState(!1),[p,b]=i.useState(null),[A,O]=i.useState(null),[L,U]=i.useState(null),[v,M]=i.useState(!1),[P,N]=i.useState("Cash"),[E,F]=i.useState(""),[q,z]=i.useState(""),[k,T]=i.useState(0),[$,B]=i.useState("NO_FINE"),Y=i.useRef(null),[ne]=s.Form.useForm(),[H]=s.Form.useForm(),W="api/branchapi/library/bookCategorydropdown",Z="api/branchapi/academy/classdropdownlist",se="api/branchapi/Academy/getClassSubjectdropdown",{data:pe}=G(a?[W,a]:null,([ce,je])=>Q(ce,je)),{data:ve}=G(a&&Z?[Z,a]:null,([ce,je])=>Q(ce,je)),{data:re}=G(a&&se?[se,a]:null,([ce,je])=>Q(ce,je)),ie=i.useMemo(()=>It(pe),[pe]),V=i.useMemo(()=>It(ve),[ve]),oe=i.useMemo(()=>It(re),[re]),Ce="api/branchapi/library/studentsearchByNameID",Oe="api/branchapi/library/booksearchBybookname",Pe="api/branchapi/library/issuedBookList",Fe="api/branchapi/library/issueLibrarybook",Ee="api/branchapi/library/returnedLibrarybook",{trigger:Ve,data:He}=Je(Ce,(ce,je)=>zt(ce,je,a)),{trigger:Ue,data:We}=Je(Oe,(ce,je)=>zt(ce,je,a)),{trigger:it,data:ye}=Je(Pe,(ce,je)=>zt(ce,je,a)),{trigger:xe}=Je(l?Ee:Fe,(ce,je)=>Ea(ce,je,a)),ge=i.useMemo(()=>It(He),[He]),te=i.useMemo(()=>It(We),[We]),me=i.useMemo(()=>It(ye),[ye]),he=ce=>{const je=Xn(ae());w(ke=>ke.some(Be=>String(Be?.id)===String(ce?.id))?ke:[...ke,{...ce,return_date:ce?.return_date?ce.return_date:je}])},Te=ce=>{w(je=>je.filter(ke=>String(ke?.id)!==String(ce)))},Re=async ce=>{if(a){if(!ce){S(null);return}d||await Ve({id:ce})}},ht=async({search:ce})=>{if(!a||!d)return;const je=await Ve({id:ce}),ke=It(je);ke.length===1&&(S(ke[0]),await it({id:ke[0]?.student_id}),ne.resetFields())},Tt=async(ce,je)=>{S(je??null),w([]),h([]),I([]),D(0),B("NO_FINE"),T(0),je?.student_id&&await it({id:je.student_id}),ne.resetFields()},Rt=async ce=>{a&&ce&&(x||await Ue({book:ce}))},Ht=async({search_book:ce})=>{if(!a||!x)return;const je=await Ue({book:ce,catID:p?.value??"",sID:L?.value??"",cID:A?.value??""}),ke=It(je);ke.length&&(he(ke[0]),H.resetFields())},Kt=(ce,je)=>{he(je),H.resetFields()},Gt=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!j.length){_.error("Select at least one book.",{duration:1e3});return}const ce=await xe({member_id:u.member_id,fine:!1,books:j});ce?.Status==="Success"&&(_.success(String(ce?.msg??"Success"),{duration:1e3}),w([]),S(null),h([]),I([]),D(0))},ue=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!g.length){_.error("Select at least one book to return.",{duration:1e3});return}if(Number(R)>0){B("FINE_PAID"),M(!0);return}const ce=await xe({member_id:u.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(g)});ce?.Status==="Success"?(_.success(String(ce?.msg??"Success"),{duration:1e3}),h([]),I([]),D(0),await it({id:u?.student_id})):_.error(String(ce?.msg??"Failed"),{duration:1e3})},Se=async()=>{if(!u?.member_id)return;const ce=Math.max(0,Number(R)-Number(k||0)),je={member_id:u.member_id,collection_type:$,amount:$==="FINE_PAID"?ce:0,payment_type:P,notes:E,attchement:q,discount:k||0,books:JSON.stringify(g)},ke=await xe(je);M(!1),ke?.Status==="Success"?(_.success(String(ke?.msg??"Success"),{duration:1e3}),h([]),I([]),D(0),T(0),F(""),z(""),B("NO_FINE"),await it({id:u?.student_id})):_.error(String(ke?.msg??"Failed"),{duration:1e3})},Ge=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!g.length){_.error("Select at least one book to return.",{duration:1e3});return}const ce={member_id:u.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(g)};n(ce)},jt=i.useMemo(()=>Ac(at(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),qa=[{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:(ce,je)=>e.jsx(xt,{defaultValue:ae(je?.return_date||ae().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(ke,Be)=>{w(fe=>fe.map(be=>String(be?.id)===String(je?.id)?{...be,return_date:Be}:be))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(ce,je)=>e.jsx(s.Button,{type:"text",danger:!0,onClick:()=>Te(je?.id),children:"Remove"})}],za={selectedRowKeys:m,onChange:(ce,je)=>{h(ce),I(je);const ke=(je??[]).reduce((Be,fe)=>Be+Number(fe?.totalfine??0),0);D(ke)},onSelect:(ce,je,ke)=>{if(je){const Be=ke.map(fe=>({...fe,return_date:fe?.return_date?fe.return_date:Xn(fe?.issue_date||ae())}));I(Be)}},onSelectAll:(ce,je)=>{if(ce){const ke=je.map(Be=>({...Be,return_date:Be?.return_date?Be.return_date:Xn(Be?.issue_date||ae())}));I(ke)}}},Ya=[{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:(ce,je)=>{const Be=g.find(be=>String(be?.id)===String(je?.id))?.return_date||je?.return_date,fe=Xn(je?.issue_date||ae());return e.jsx(xt,{defaultValue:ae(Be||fe),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(be,Xe)=>{I(vt=>vt.map(Wa=>String(Wa?.id)===String(je?.id)?{...Wa,return_date:Xe}:Wa))}})}},{title:"Days",key:"days",width:100,render:(ce,je)=>{const Be=g.find(be=>String(be?.id)===String(je?.id))?.return_date||je?.return_date,fe=je?.issue_date;if(fe&&Be){const be=ae(Be).diff(ae(fe),"day");return be>=0?be: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:ce=>e.jsxs("span",{children:["₹ ",ce]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:v,onCancel:()=>M(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(s.Radio.Group,{value:P,onChange:ce=>N(ce.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(s.Input.TextArea,{rows:3,value:E,onChange:ce=>F(ce.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(s.Upload,{action:jt,headers:{Authorization:a},maxCount:1,onChange:ce=>{if(ce.file.status==="done"){const je=ce.file.response?.data??ce.file.response?.file??"";z(String(je??""))}},children:e.jsx(s.Button,{icon:e.jsx(X.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(s.Input,{type:"number",value:k,onChange:ce=>T(ce.target.value),placeholder:"0"})]}),e.jsxs(s.Button,{type:"primary",onClick:Se,children:["Collect ₹",Math.max(0,Number(R)-Number(k||0))]}),e.jsx(s.Button,{onClick:()=>M(!1),children:"Cancel"})]})}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:10,children:e.jsx(s.Radio.Group,{value:r,onChange:ce=>{const je=ce.target.value;o(je),w([]),h([]),I([]),D(0),B("NO_FINE"),T(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(s.Col,{xs:24,md:14,children:e.jsx(s.Form,{form:ne,onFinish:ht,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search",label:"Search Student",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:d?e.jsx(s.Input,{autoFocus:!0,addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:d,onChange:ce=>c(ce.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{options:ge,onSelect:Tt,onSearch:Re,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:d,onChange:ce=>c(ce.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),u?e.jsxs(e.Fragment,{children:[e.jsx(s.Divider,{}),e.jsxs(s.Row,{gutter:[12,12],children:[e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Name:"})," ",u?.value??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Card No:"})," ",u?.library_card_no??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Member ID:"})," ",u?.member_id??""]})]})]}):null,e.jsx(s.Divider,{}),l?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(s.Table,{dataSource:me,columns:Ya,rowSelection:za,pagination:!1,rowKey:ce=>ce?.id??ce?.issue_id??ce?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(s.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(s.Typography.Text,{strong:!0,children:["Total Fine: ₹",R]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(s.Button,{type:"primary",onClick:ue,disabled:!g.length,children:R>0?`Pay Now ₹ ${Math.max(0,Number(R)-Number(k||0))}`:"Return Selected"}),R>0?e.jsx(s.Button,{onClick:Ge,disabled:!g.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:18,children:e.jsx(s.Form,{form:H,onFinish:Ht,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:x?e.jsx(s.Input,{autoFocus:!0,disabled:!u,addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:x,onChange:ce=>y(ce.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{disabled:!u,options:te,onSelect:Kt,onSearch:Rt,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:x,onChange:ce=>y(ce.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(s.Button,{style:{width:"100%"},icon:e.jsx(X.FilterOutlined,{}),onClick:()=>f(!0),children:"Filter"})})]}),e.jsx(s.Drawer,{open:C,onClose:()=>f(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{label:"Category",options:ie,value:p,onChange:ce=>b(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(ee,{label:"Class",options:V,value:A,onChange:ce=>O(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(ee,{label:"Subjects",options:oe,value:L,onChange:ce=>U(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(s.Button,{type:"primary",onClick:()=>f(!1),children:"Apply"})]})}),e.jsx(s.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(s.Table,{dataSource:j,columns:qa,pagination:!1,rowKey:ce=>ce?.id??ce?.book_id??ce?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Issue",onClick:Gt})})]})]}),e.jsx("div",{ref:Y,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}const Br=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Rc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,c]=i.useState(null),[x,y]=i.useState(!1),[u,S]=i.useState(!1),[j,w]=i.useState(null),[m,h]=i.useState(!1),g="api/branchapi/academy/classdropdownlist",I="api/branchapi/academy/sectionoftheClass",R="api/branchapi/library/studenttableForLibrary",D="api/branchapi/library/addmembershipforStudent",C="api/branchapi/library/removemembershipforStudent",f=i.useMemo(()=>{if(!o?.value)return null;const k=I.includes("?")?"&":"?";return`${I}${k}class_id=${encodeURIComponent(String(o.value))}`},[I,o?.value]),p=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const k=R.includes("?")?"&":"?";return`${R}${k}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${a.page}&per_page=${a.rowsPerPage}`},[a.page,a.rowsPerPage,o?.value,d?.value,R]),{data:b}=G(n&&g?[g,n]:null,([k,T])=>Q(k,T)),{data:A}=G(n&&f?[f,n]:null,([k,T])=>Q(k,T)),{isLoading:O,error:L,data:U,mutate:v}=G(n&&p?[p,n]:null,([k,T])=>Q(k,T)),M=i.useMemo(()=>Br(b),[b]),P=i.useMemo(()=>Br(A),[A]),N=(k,T)=>{r({page:k,rowsPerPage:parseInt(T,10)})},E=k=>{const T=k?.id??k?.student_id??k?.member_id;w(T??null),S(!0),h($=>!$)},F=async k=>{if(k.preventDefault(),!j)return;const T=new FormData(k.target);T.set("id",String(j));try{await Ye(D,T,n),_.success("Success! Added member.",{duration:1e3,icon:"🎉"}),S(!1),w(null),await v()}catch($){_.error($?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},q=async k=>{try{await st(C,k,n),_.success("Success! Removed member.",{duration:1e3}),await v()}catch(T){_.error(T?.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:(k,T)=>(console.log("data______________",T),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:T?.library_card_no==null?e.jsx(s.Button,{type:"primary",size:"small",icon:e.jsx(X.UserAddOutlined,{}),onClick:()=>E(T)}):e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{}),onClick:()=>q(T?.id??T?.student_id??T?.member_id)})}))}],[q]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:u,title:"Add Member",onCancel:()=>{S(!1),w(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(J,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Add",color:"primary"})})]})},`add-${m}`)}),e.jsx(s.Card,{title:e.jsx(s.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(ee,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:k=>{l(k??null),c(null),y(T=>!T)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:k=>c(k??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${x}`),e.jsx(de,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){_.error("Select class and section.",{duration:1e3});return}r(k=>({...k,page:1}))}})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Le,{parentCallback:N,data:{newData:U,columns:z,columnstype:"antd",action:!1,Loading:O,error:L}})})]})}function Ic({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState({page:1,rowsPerPage:10}),[o]=s.Form.useForm(),[l]=s.Form.useForm(),[d,c]=i.useState(!1),[x,y]=i.useState(null),u="api/branchapi/library/BookCategorytable",S="api/branchapi/library/addBookCategory",j="api/branchapi/library/editBookCategory",w="api/branchapi/library/deleteBookCategory",m=i.useMemo(()=>{const L=u.includes("?")?"&":"?";return`${u}${L}page=${a.page}&per_page=${a.rowsPerPage}`},[u,a.page,a.rowsPerPage]),{isLoading:h,error:g,data:I,mutate:R}=G(n&&m?[m,n]:null,([L,U])=>Q(L,U)),D=(L,U)=>{r({page:L,rowsPerPage:parseInt(U,10)})},C=async L=>{const U=new FormData;U.set("title",L?.title??"");try{await Ye(S,U,n),_.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await R()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to add category.",{duration:1e3})}},f=L=>{y(L??null),l.setFieldsValue({title:L?.name??""}),c(!0)},p=()=>{c(!1),y(null),l.resetFields()},b=async L=>{const U=x?.id??x?.category_id??x?.cat_id;if(!U){_.error("Missing category id.",{duration:1e3});return}const v=new FormData;v.set("id",String(U)),v.set("title",L?.title??"");try{await mt(j,v,n),_.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),p(),await R()}catch(M){_.error(M?.response?.data?.msg??M?.message??"Failed to update category.",{duration:1e3})}},A=async L=>{const U=L?.id??L?.category_id??L?.cat_id;if(!U){_.error("Missing category id.",{duration:1e3});return}try{await st(w,U,n),_.success("Success! Deleted category.",{duration:1e3}),await R()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to delete category.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(L,U)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>f(U)}),e.jsx(s.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>A(U),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[A]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:d,title:"Edit Category",onCancel:p,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:l,layout:"vertical",onFinish:b,children:[e.jsx(s.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(s.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:p,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,lg:8,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:C,children:[e.jsx(s.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(s.Input,{placeholder:"Enter category name"})}),e.jsx(de,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(s.Col,{xs:24,lg:16,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Le,{parentCallback:D,data:{newData:I,columns:O,columnstype:"antd",action:!1,Loading:h,error:g}})})})]})]})}const os=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Dc({token:t}){const[n,a]=i.useState([ae().format("YYYY-MM-DD"),ae().format("YYYY-MM-DD")]),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,x]=i.useState(null),[y,u]=i.useState(!1),[S,j]=i.useState(!1),w="api/branchapi/academy/classdropdownlist",m="api/branchapi/academy/sectionoftheClass",h="api/branchapi/library/memberDropdown",g="api/report/libraryReport/libraryReport",I=i.useMemo(()=>{if(!r?.value)return null;const E=m.includes("?")?"&":"?";return`${m}${E}class_id=${encodeURIComponent(String(r.value))}`},[m,r?.value]),R=i.useMemo(()=>{if(!r?.value)return null;const E=h.includes("?")?"&":"?",F=`${h}${E}class=${encodeURIComponent(String(r.value))}`;return l?.value?`${F}§ion=${encodeURIComponent(String(l.value))}`:F},[h,r?.value,l?.value]),{isLoading:D,error:C,data:f,mutate:p}=G(t&&w?[w,t]:null,([E,F])=>Q(E,F)),{data:b}=G(t&&I?[I,t]:null,([E,F])=>Q(E,F)),{data:A}=G(t&&R?[R,t]:null,([E,F])=>Q(E,F)),O=i.useMemo(()=>os(f),[f]),L=i.useMemo(()=>os(b),[b]),U=i.useMemo(()=>os(A),[A]),{trigger:v,data:M}=Je(g,(E,F)=>Os(E,F,t));i.useEffect(()=>{(async()=>{j(!0);try{await v({duration:n})}finally{j(!1)}})()},[]);const P=async()=>{j(!0);try{await v({duration:n,class:r?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{j(!1)}},N=[{title:"Name",dataIndex:"full_name",render:(E,F)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(E,F)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(E,F)=>e.jsxs(s.Typography.Text,{style:{fontSize:12},children:[F?.class??"","(",F?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(E,F)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.book_title??""})},{title:"Issue Date",key:"date",render:(E,F,q)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.issue_date??""})},{title:"Due Return Date",key:"date",render:(E,F,q)=>e.jsx(s.Tag,{color:"orange",children:F?.return_date??""})},{title:"Return Date",key:"date",render:(E,F,q)=>F?.retured_by_user?e.jsx(s.Tag,{color:"green",children:F?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(E,F,q)=>String(F?.is_returned??"")==="1"?e.jsx(s.Tag,{color:"green",children:"Return"}):e.jsx(s.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(E,F,q)=>{const z=F?.late_fine?Number(F.late_fine):0;return z?e.jsx(s.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:z}):null}}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(s.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(s.DatePicker.RangePicker,{style:{width:"100%"},value:[ae(n[0],"YYYY-MM-DD"),ae(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(E,F)=>{Array.isArray(F)&&F.length===2&&a([F[0],F[1]])}})]})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:E=>{o(E??null),d(null),x(null),u(F=>!F)},allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:E=>{d(E??null),x(null)},allowSelectAll:!1},`section1${y}`)}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:E=>x(E??null),allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:1,children:e.jsx(s.Button,{type:"primary",icon:e.jsx(X.SearchOutlined,{}),onClick:P,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(s.Table,{columns:N,pagination:!1,dataSource:Array.isArray(M?.data)?M.data:[],size:"small",rowKey:(E,F)=>E?.id??E?.issue_id??E?.fees_receipt_id??F,loading:S,scroll:{x:"max-content"},summary:E=>{const F=E.reduce((z,k)=>z+Number(k?.late_fine??0),0),q=E.reduce((z,k)=>z+Number(k?.is_returned??0),0);return e.jsxs(s.Table.Summary.Row,{children:[e.jsx(s.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",E.length]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(E.length-q)]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",q]})}),e.jsx(s.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",F.toLocaleString("en-IN")]})})]})}})})]})]})}const Lr=[{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"}],qr=[{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 kc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState("renewalHistory"),[o,l]=i.useState("This Month"),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(7),[j,w]=i.useState(1),[m,h]=i.useState(20),[g,I]=i.useState(""),[R,D]=i.useState("DESC"),C=i.useRef(null),f=F=>{const q=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(a)&&(q.set("date_range",o),o==="Custom"&&d&&x&&(q.set("from_date",d),q.set("to_date",x))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(a)&&(q.set("page",String(j)),q.set("per_page",String(m))),a==="upcomingRenewalDue"&&q.set("days_ahead",String(u)),g&&q.set("sort_by",g),R&&q.set("sort_dir",R),`${F}?${q.toString()}`},p=i.useMemo(()=>{switch(a){case"renewalHistory":return f(Sd);case"renewalFineReport":return f(jd);case"currentlyRenewedBooks":return f(vd);case"upcomingRenewalDue":return f(_d);case"overdueRenewalReport":return f(wd);case"renewalLimitReport":return f(Cd);case"renewalStatusReport":return f(Ad);case"studentWiseReport":return f(Td);case"bookWiseReport":return f(Rd);case"classWiseReport":return f(Id);case"staffWiseReport":return f(Dd);case"renewalStatisticsByDate":return f(kd);default:return null}},[a,o,d,x,u,j,m]),{data:b,isLoading:A}=G(n?[p,n]:null,([F,q])=>Q(F,q)),O=b?.data||{},L=O?.rows||[],U=O?.pagination||{},v=F=>{r(F),w(1),h(20)},M=()=>{w(1)},P=()=>{switch(a){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:F=>e.jsx(s.Tag,{color:F==="renewed"?"green":"red",children:F})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:F=>F??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:F=>F??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:F=>F??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:F=>F?e.jsx(s.Tag,{color:F==="paid"?"green":F==="partial"?"orange":"red",children:F}):"-"}];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:F=>F??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:F=>F??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:F=>F??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:F=>F??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:F=>e.jsx(s.Tag,{color:F?"green":"red",children:F?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:F=>Array.isArray(F)?F.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[]}},N=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(a),E=i.useMemo(()=>P(),[a]);return e.jsx(le,{pt:5,pb:1,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(le,{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(le,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],mb:3,children:[N&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(ee,{options:Lr,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:Lr.find(F=>F.value===o)||null,onChange:F=>l(F?.value||"This Month")})}),o==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(xt,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:F=>c(F?F.format("YYYY-MM-DD"):"")})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(xt,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:F=>y(F?F.format("YYYY-MM-DD"):"")})})]})]}),a==="upcomingRenewalDue"&&e.jsx(s.Col,{xs:24,md:6,children:e.jsx(ee,{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:F=>S(F?.value||7)})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(le,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:M})})})]}),e.jsx(s.Tabs,{activeKey:a,onChange:v,items:qr})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(le,{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(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:qr.find(F=>F.key===a)?.label||"Report"})}),e.jsxs(le,{p:3,children:[e.jsx(un,{data:{tableRef:C}}),A?e.jsx(le,{py:8,textAlign:"center",children:e.jsx(s.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(s.Table,{size:"small",dataSource:L,columns:E,loading:A,pagination:!1,bordered:!0,rowKey:F=>F.renewal_id||F.id||JSON.stringify(F),ref:C}),L.length>0&&e.jsx(s.Pagination,{current:j,pageSize:m,total:U.total_rows||L.length,onChange:(F,q)=>{w(F),h(q)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const Ma=t=>t??localStorage.getItem("authToken")??"",Oc=(t,n)=>{const a=String(t??""),r=String(n);return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},$e={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"}},Pc=()=>Oc(at(),$e.upload),Ec=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Ma(r))},Bn=async(t,n,a)=>Ye(t,n,Ma(a)),pn=async(t,n,a)=>mt(t,n,Ma(a)),Ln=async(t,n,a)=>st(t,n,Ma(a)),Mc=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",on=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:Pc(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Mc(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},ma=$e.vendor,qn=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>Ec({baseUrl:l,page:d,perPage:c},x)),Fc=({token:t,page:n=1,perPage:a=10})=>qn({baseUrl:ma.list,page:n,perPage:a,token:t}),Nc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},zr=[{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 $c({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:y,error:u,data:S,mutate:j}=Fc({token:t,page:n.page,perPage:n.rowsPerPage}),w=async C=>{try{await j(Bn(ma.add,C,t),rt(C)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(f){_.error(f?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},m=C=>{C.preventDefault();const f=new FormData(C.target);c&&f.set("image",c),w(f),C.target.reset(),x("")},h=(C,f)=>{a({page:C,rowsPerPage:parseInt(f,10)})},g=async C=>{try{await j(Ln(ma.remove,C,t),Qe(C)),_.success("Success! Deleted item.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},I=C=>{d(C),o(!0),x("")},R=async C=>{C.preventDefault();const f=new FormData(C.target);f.set("id",String(l?.id??"")),c&&f.set("image",c);try{await pn(ma.edit,f,t),await j(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(p){_.error(p?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=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,f)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>I(f),style:{padding:2}}),e.jsx(dt,{id:f?.id,funcName:g})]})}],[g]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[zr.map(C=>e.jsx(J,{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(on,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Nc,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(le,{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:[zr.map(C=>e.jsx(J,{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(on,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:h,data:{newData:S,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})]})]})}const Uc=({token:t})=>e.jsx($c,{token:t}),Bc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Lc={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"},Ot=({style:t,onFocus:n,onBlur:a,...r})=>{const[o,l]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:Bc,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{l(!0),n?.(d)},onBlur:d=>{l(!1),a?.(d)},style:{...Lc,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},ya=$e.product,Yr=$e.vendor.dropdown,Wr=$e.category.dropdown,qc=$e.subCategory.dropdown,Vr=$e.unit.dropdown,fo=({token:t,page:n=1,perPage:a=10})=>qn({baseUrl:ya.list,page:n,perPage:a,token:t}),zc=({token:t})=>G(t&&Yr?[Yr,t]:null,([a,r])=>Q(a,r)),Yc=({token:t})=>G(t&&Wr?[Wr,t]:null,([a,r])=>Q(a,r)),Wc=({token:t})=>G(t&&Vr?[Vr,t]:null,([a,r])=>Q(a,r)),Vc=({token:t,categoryId:n})=>{const a=t&&n?`${qc}?category_id=${encodeURIComponent(String(n))}`:null;return G(a?[a,t]:null,([o,l])=>Q(o,l))},Zn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Hc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Kc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[y,u]=i.useState(""),[S,j]=i.useState(""),[w,m]=i.useState(""),[h,g]=i.useState(""),{isLoading:I,error:R,data:D,mutate:C}=fo({token:t,page:n.page,perPage:n.rowsPerPage}),{data:f}=zc({token:t}),{data:p}=Yc({token:t}),{data:b}=Wc({token:t}),{data:A}=Vc({token:t,categoryId:y}),O=i.useMemo(()=>Zn(f),[f]),L=i.useMemo(()=>Zn(p),[p]),U=i.useMemo(()=>Zn(b),[b]),v=i.useMemo(()=>Zn(A),[A]),M=async k=>{try{await C(Bn(ya.add,k,t),rt(k)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},P=k=>{k.preventDefault();const T=new FormData(k.target);y&&T.set("fk_categoryID",String(y)),S&&T.set("fk_sub_categoryID",String(S)),w&&T.set("vendor_id",String(w)),h&&T.set("unit",String(h)),c&&T.set("image",c),M(T),k.target.reset(),x(""),u(""),j(""),m(""),g("")},N=(k,T)=>{a({page:k,rowsPerPage:parseInt(T,10)})},E=async k=>{try{await C(Ln(ya.remove,k,t),Qe(k)),_.success("Success! Deleted item.",{duration:1e3})}catch(T){_.error(T?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},F=k=>{d(k),o(!0),x(""),u(k?.fk_categoryID??k?.category_id??""),j(k?.fk_sub_categoryID??k?.sub_category_id??""),m(k?.vendor_id??""),g(k?.unit??k?.unit_id??"")},q=async k=>{k.preventDefault();const T=new FormData(k.target);T.set("id",String(l?.id??"")),y&&T.set("fk_categoryID",String(y)),S&&T.set("fk_sub_categoryID",String(S)),w&&T.set("vendor_id",String(w)),h&&T.set("unit",String(h)),c&&T.set("image",c);try{await pn(ya.edit,T,t),await C(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch($){_.error($?.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:(k,T)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>F(T),style:{padding:2}}),e.jsx(dt,{id:T?.id,funcName:E})]})}],[E]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(J,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:k=>{const T=k?.value??"";u(T),j("")},defaultValue:y?L.find(k=>String(k?.value)===String(y)):null}),e.jsx(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:k=>j(k?.value??""),defaultValue:S?v.find(k=>String(k?.value)===String(S)):null}),e.jsx(J,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:k=>g(k?.value??""),defaultValue:h?U.find(k=>String(k?.value)===String(h)):null}),e.jsx(J,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(J,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(ee,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:k=>m(k?.value??""),defaultValue:w?O.find(k=>String(k?.value)===String(w)):null}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(Ot,{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(on,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Hc,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(J,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:k=>{const T=k?.value??"";u(T),j("")}}),e.jsx(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:k=>j(k?.value??"")},`subcat_${y}`),e.jsx(J,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:k=>g(k?.value??"")}),e.jsx(J,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(J,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(ee,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:k=>m(k?.value??"")}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(Ot,{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(on,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:N,data:{newData:D,columns:z,columnstype:"antd",action:!1,Loading:I,error:R}})})]})]})]})}const Gc=({token:t})=>e.jsx(Kc,{token:t}),fa=$e.category,Jc=({token:t,page:n=1,perPage:a=10})=>qn({baseUrl:fa.list,page:n,perPage:a,token:t}),Qc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Xc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:y,mutate:u}=Jc({token:t,page:n.page,perPage:n.rowsPerPage}),S=async R=>{try{await u(Bn(fa.add,R,t),rt(R)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=R=>{R.preventDefault();const D=new FormData(R.target);S(D),R.target.reset()},w=(R,D)=>{a({page:R,rowsPerPage:parseInt(D,10)})},m=async R=>{try{await u(Ln(fa.remove,R,t),Qe(R)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},h=R=>{d(R),o(!0)},g=async R=>{R.preventDefault();const D=new FormData(R.target);D.set("id",String(l?.id??""));try{await pn(fa.edit,D,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})}},I=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(D),style:{padding:2}}),e.jsx(dt,{id:D?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.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:g,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Qc,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(le,{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(J,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:w,data:{newData:y,columns:I,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const Zc=({token:t})=>e.jsx(Xc,{token:t}),ha=$e.subCategory,Hr=$e.category.dropdown,eu=({token:t,page:n=1,perPage:a=10})=>qn({baseUrl:ha.list,page:n,perPage:a,token:t}),tu=({token:t})=>G(t&&Hr?[Hr,t]:null,([a,r])=>Q(a,r)),nu=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},au={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function su({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:y,error:u,data:S,mutate:j}=eu({token:t,page:n.page,perPage:n.rowsPerPage}),{data:w}=tu({token:t}),m=i.useMemo(()=>nu(w),[w]),h=async p=>{try{await j(Bn(ha.add,p,t),rt(p)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(b){_.error(b?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},g=p=>{p.preventDefault();const b=new FormData(p.target);b.set("status","active"),b.set("img",c||""),h(b),p.target.reset(),x("")},I=(p,b)=>{a({page:p,rowsPerPage:parseInt(b,10)})},R=async p=>{try{await j(Ln(ha.remove,p,t),Qe(p)),_.success("Success! Deleted item.",{duration:1e3})}catch(b){_.error(b?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=p=>{d(p),o(!0)},C=async p=>{p.preventDefault();const b=new FormData(p.target);b.set("id",String(l?.id??"")),c&&b.set("img",c);try{await pn(ha.edit,b,t),await j(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(A){_.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},f=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(p,b)=>String(p?.name??"").localeCompare(String(b?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(p,b)=>String(p?.description??"").localeCompare(String(b?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(p,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(b),style:{padding:2}}),e.jsx(dt,{id:b?.id,funcName:R})]})}],[R]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?m.find(p=>String(p?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{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(on,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:au,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(J,{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(on,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:I,data:{newData:S,columns:f,columnstype:"antd",action:!1,Loading:y,error:u}})})]})]})]})}const ru=({token:t})=>e.jsx(su,{token:t}),ls=$e.product,iu=$e.academy.classes,ou=$e.academy.sections,lu=$e.student.dropdown;function bn(t){const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]}function ea(t,n){const a=Math.trunc(Number(t)||1),r=Math.max(1,a);return!Number.isFinite(Number(n))||Number(n)<=0?r:Math.min(r,Math.trunc(Number(n)))}function Ze(t){return String(t??"")}function du({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,x]=i.useState(!1),[y,u]=i.useState(""),[S,j]=i.useState([]),[w,m]=i.useState({}),[h,g]=i.useState({}),[I,R]=i.useState(!1),[D,C]=i.useState(""),[f,p]=i.useState(0),[b,A]=i.useState(""),[O,L]=i.useState(ae()),[U,v]=i.useState([]),M={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},P=!!(n&&r&&l),{data:N}=G(t?[iu,t]:null,([ye,xe])=>Q(ye,xe)),E=i.useMemo(()=>bn(N),[N]),F=t&&n?`${ou}?class_id=${encodeURIComponent(String(n))}`:null,{data:q}=G(F?[F,t]:null,([ye,xe])=>Q(ye,xe)),z=i.useMemo(()=>bn(q),[q]),k=t&&n&&r?`${lu}?class=${encodeURIComponent(String(n))}§ion=${encodeURIComponent(String(r))}`:null,{data:T}=G(k?[k,t]:null,([ye,xe])=>Q(ye,xe)),$=i.useMemo(()=>bn(T),[T]),B=P?`${ls.list}?page=1&per_page=10000`:null,{data:Y,isLoading:ne}=G(t&&B?[B,t]:null,([ye,xe])=>Q(ye,xe),{revalidateOnFocus:!1}),H=i.useMemo(()=>bn(Y),[Y]),W=i.useMemo(()=>{const ye=new Map;return(Array.isArray(H)?H:[]).forEach(xe=>{ye.set(Ze(xe?.id),xe)}),ye},[H]),Z=i.useMemo(()=>{const ye=Object.entries(h||{});return ye.length===0?[]:ye.map(([xe,ge])=>{const te=W.get(Ze(xe));return te?{id:te?.id,name:te?.name,barcode:te?.barcode,stock:Number(te?.quantity||0),price:Number(te?.price||0),quantity:ea(ge,Number(te?.quantity||0))}:null}).filter(Boolean)},[h,W]),se=i.useMemo(()=>new Set(Z.map(ye=>Ze(ye?.id))),[Z]),pe=i.useMemo(()=>(Array.isArray(Z)?Z:[]).reduce((xe,ge)=>xe+Number(ge?.price||0)*Number(ge?.quantity||1),0),[Z]),ve=i.useMemo(()=>{const ye=Number(f||0);return!Number.isFinite(ye)||ye<=0?0:Math.min(ye,pe)},[f,pe]),re=i.useMemo(()=>Math.max(0,pe-ve),[ve,pe]),ie=i.useMemo(()=>(Array.isArray(H)?H:[]).slice(0,30).map(ye=>({value:Ze(ye?.id),label:`${ye?.name??""}${ye?.barcode?` • ${ye.barcode}`:""}${ye?.quantity!==void 0&&ye?.quantity!==null?` • Stock: ${ye.quantity}`:""}`,product:ye})),[H]),{trigger:V}=Je(t&&P?ls.search:null,(ye,{arg:xe})=>zt(ye,{arg:xe},t));i.useEffect(()=>{if(!P){j([]);return}const ye=String(y||"").trim();if(ye.length<2){j(ie);return}let xe=!0;const ge=setTimeout(async()=>{let te=[];try{if(V){const he=await V({search:ye});te=bn(he)}}catch{te=[]}if(!Array.isArray(te)||te.length===0){const he=ye.toLowerCase();te=(Array.isArray(H)?H:[]).filter(Te=>{const Re=String(Te?.name??"").toLowerCase(),ht=String(Te?.barcode??"").toLowerCase();return Re.includes(he)||ht.includes(he)}).slice(0,30)}const me=te.slice(0,30).map(he=>({value:Ze(he?.id),label:`${he?.name??""}${he?.barcode?` • ${he.barcode}`:""}${he?.quantity!==void 0&&he?.quantity!==null?` • Stock: ${he.quantity}`:""}`,product:he}));xe&&j(me)},250);return()=>{xe=!1,clearTimeout(ge)}},[ie,P,V,H,y]),i.useEffect(()=>{g({}),m({}),u(""),j([]),R(!1),C(""),p(0),A(""),L(ae()),v([])},[n,r,l]);const oe=i.useCallback((ye,xe=1)=>{const ge=ye?.id;if(!ge)return;const te=Number(ye?.quantity||0);if(te<=0){_.error("Out of stock.",{duration:1e3});return}const me=ea(xe,te);g(he=>{const Te=he||{};return Object.prototype.hasOwnProperty.call(Te,Ze(ge))?(_.error("Product already added.",{duration:1e3}),Te):{...Te,[Ze(ge)]:me}})},[g]),Ce=i.useCallback((ye,xe,ge)=>{g(te=>{const me=te||{},he=Ze(ye);return Object.prototype.hasOwnProperty.call(me,he)?{...me,[he]:ea(xe,ge)}:me})},[]),Oe=i.useCallback(ye=>{g(xe=>{const ge=xe||{},te=Ze(ye);if(!Object.prototype.hasOwnProperty.call(ge,te))return ge;const me={...ge};return delete me[te],me})},[]),Pe=i.useCallback((ye,xe,ge)=>{m(te=>({...te||{},[Ze(ye)]:ea(xe,ge)}))},[]),Fe=i.useCallback((ye,xe)=>{xe?.product&&oe(xe.product,1),u(""),j(ie)},[oe,ie]),Ee=i.useCallback(ye=>{if(ye.key!=="Enter")return;ye.preventDefault();const xe=Array.isArray(S)&&S.length>0?S[0]:null;if(xe?.product){oe(xe.product,1),u(""),j(ie);return}const ge=String(y||"").trim().toLowerCase();if(ge.length===0)return;const te=(Array.isArray(H)?H:[]).find(me=>{const he=String(me?.name??"").toLowerCase(),Te=String(me?.barcode??"").toLowerCase();return he.includes(ge)||Te.includes(ge)});te&&(oe(te,1),u(""),j(ie))},[oe,ie,H,S,y]),Ve=()=>{if(!t){_.error("Missing token.",{duration:1e3});return}if(!n){_.error("Select class.",{duration:1e3});return}if(!r){_.error("Select section.",{duration:1e3});return}if(!l){_.error("Select student.",{duration:1e3});return}if(!Z||Z.length===0){_.error("Add at least one product.",{duration:1e3});return}R(!0)},{trigger:He,isMutating:Ue}=Je(t?ls.sellProduct:null,(ye,{arg:xe})=>Ea(ye,{arg:xe},t)),We=async()=>{if(!D){_.error("Select payment type.",{duration:1e3});return}const ye=(Array.isArray(Z)?Z:[]).map(ge=>({id:ge?.id,quantity:Number(ge?.quantity||1),price:Number(ge?.price||0),total_price:Number(ge?.total_price||0),fk_vendor_id:ge?.fk_vendor_id||"",fk_categoryID:ge?.fk_categoryID||"",name:ge?.name||"",class_id:ge?.class_id||"",fk_sub_categoryID:ge?.fk_sub_categoryID||"",description:ge?.description||"",min_quantity:Number(ge?.min_quantity||0),storecategory:Number(ge?.storecategory||0),barcode:ge?.barcode||""})),xe={amount:pe,class:n,section:r,student_id:l,payment_type:D,discount:ve,notes:b||"",receipt_date:O?ae(O).format("YYYY-MM-DD"):"",product:JSON.stringify(ye),total_payable_amount:pe,attchement:U[0]?.originFileObj||""};try{const te=Array.isArray(U)&&U.length>0&&U[0]?.originFileObj?(()=>{const he=new FormData;return Object.entries(xe).forEach(([Te,Re])=>{if(Te==="products"){he.append("product",JSON.stringify(Re));return}he.append(Te,String(Re??""))}),he.append("attachment",U[0].originFileObj),he})():xe,me=await He(te);me?.Status==="Success"?(_.success("Success! Product sold.",{duration:1e3}),R(!1),g({}),m({}),u(""),j(ie),C(""),p(0),A(""),L(ae()),v([])):_.error(me?.msg??"Failed to submit.",{duration:1e3})}catch{_.error("Failed to submit.",{duration:1e3})}},it=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:(ye,xe)=>{const ge=Ze(xe?.id),te=Number(xe?.quantity||0),me=se.has(ge),he=(me?h?.[ge]:w?.[ge])??1;return e.jsx(s.InputNumber,{min:1,max:Number.isFinite(te)&&te>0?te:void 0,value:he,onChange:Te=>{me?Ce(ge,Te,te):Pe(ge,Te,te)},disabled:te<=0})}},{title:"Amount",key:"amount",width:140,render:(ye,xe)=>{const ge=Ze(xe?.id),te=(se.has(ge)?h?.[ge]:w?.[ge])??1;return Number(xe?.price||0)*Number(te||1)}},{title:"Action",key:"action",width:120,render:(ye,xe)=>{const ge=Ze(xe?.id),te=Number(xe?.quantity||0),me=se.has(ge),he=(me?h?.[ge]:w?.[ge])??1;return me?e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(X.DeleteOutlined,{}),onClick:()=>Oe(ge),style:{padding:2}}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.PlusOutlined,{}),disabled:te<=0,onClick:()=>oe(xe,he),style:{padding:2}})}}],[oe,se,h,w,Oe,Pe,Ce]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(le,{pt:5,pb:2,children:[e.jsxs(le,{style:{padding:"12px 16px"},children:[e.jsx(le,{children:"Sell Product"}),e.jsx(s.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(ee,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:ye=>{const xe=ye?.value??"";a(xe),o(""),d(""),x(ge=>!ge)}}),e.jsx(ee,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:ye=>{const xe=ye?.value??"";o(xe),d("")}},`section_${c}`),e.jsx(ee,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:ye=>d(ye?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(s.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(le,{style:{marginTop:12},children:"Product Section"}),e.jsx(s.AutoComplete,{value:y,options:S,onSearch:u,onFocus:()=>{P&&String(y||"").trim().length<2&&j(ie)},onSelect:Fe,disabled:!P,children:e.jsx(s.Input,{placeholder:"Search by product name or barcode",onKeyDown:Ee,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",gt(pe)]})]}),e.jsx(s.Table,{rowKey:ye=>Ze(ye?.id),columns:it,dataSource:H,loading:ne,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:Z.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:gt(pe)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(de,{type:"button",value:"Submit",disabled:!P||Z.length===0,onClick:Ve,style:{flex:1,minWidth:140}}),e.jsx(s.Button,{type:"text",style:M,onClick:()=>{g({}),m({}),u(""),j(ie)},disabled:Z.length===0,children:"Clear"})]})]})]})})]}),e.jsx(s.Modal,{open:I,title:"Payment",onCancel:()=>R(!1),onOk:We,confirmLoading:Ue,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(s.Select,{value:D||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(s.DatePicker,{value:O,onChange:ye=>L(ye),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(s.InputNumber,{min:0,max:pe,value:f,onChange:ye=>p(Number(ye||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(s.Upload,{fileList:U,beforeUpload:()=>!1,onChange:({fileList:ye})=>v((ye||[]).slice(-1)),maxCount:1,children:e.jsx(s.Button,{icon:e.jsx(X.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(s.Input.TextArea,{value:b,onChange:ye=>A(ye.target.value),rows:3})]}),e.jsx(s.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:gt(pe)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:gt(ve)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:gt(re)})]})]})})]})})]})}const cu=({token:t})=>e.jsx(du,{token:t}),ga=$e.unit,uu=({token:t,page:n=1,perPage:a=10})=>qn({baseUrl:ga.list,page:n,perPage:a,token:t}),pu={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function mu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:y,mutate:u}=uu({token:t,page:n.page,perPage:n.rowsPerPage}),S=async R=>{try{await u(Bn(ga.add,R,t),rt(R)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=R=>{R.preventDefault();const D=new FormData(R.target);S(D),R.target.reset()},w=(R,D)=>{a({page:R,rowsPerPage:parseInt(D,10)})},m=async R=>{try{await u(Ln(ga.remove,R,t),Qe(R)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},h=R=>{d(R),o(!0)},g=async R=>{R.preventDefault();const D=new FormData(R.target);D.set("id",String(l?.id??""));try{await pn(ga.edit,D,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})}},I=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(D),style:{padding:2}}),e.jsx(dt,{id:D?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.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:g,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:pu,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(le,{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(J,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:w,data:{newData:y,columns:I,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const yu=({token:t})=>e.jsx(mu,{token:t}),fu=$e.product.sellReports,hu=$e.academy.classes,gu=$e.academy.sections,xu=$e.student.dropdown,Kr=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function bu({token:t}){const n=i.useRef(null),[a,r]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(!1),j=v=>{const M=v?.data?.data??v?.data??v??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},{data:w}=G(t?[hu,t]:null,([v,M])=>Q(v,M)),m=i.useMemo(()=>j(w),[w]),h=t&&o?`${gu}?class_id=${encodeURIComponent(String(o))}`:null,{data:g}=G(h?[h,t]:null,([v,M])=>Q(v,M)),I=i.useMemo(()=>j(g),[g]),R=t&&o&&d?`${xu}?class=${encodeURIComponent(String(o))}§ion=${encodeURIComponent(String(d))}`:null,{data:D}=G(R?[R,t]:null,([v,M])=>Q(v,M)),C=i.useMemo(()=>j(D),[D]),{trigger:f,isMutating:p,data:b}=Je(fu,(v,{arg:M})=>Os(v,{arg:M},t));i.useEffect(()=>{const M=new Date().toISOString().slice(0,10);f({duration:[M,M]})},[f]);const A=i.useMemo(()=>{const v=b?.data??b??[];return Array.isArray(v)?v:[]},[b]),O=v=>{const M=Array.isArray(v?.product_details)?v.product_details:[];return M.length===0?null:e.jsx(s.Table,{size:"small",bordered:!0,pagination:!1,rowKey:P=>`${v?.receipt_id??"r"}_${P?.product_name??P?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:P=>Kr(P)}],dataSource:M})},L=[{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:v=>Kr(v)}],U=async()=>{if(!a||a.length!==2)return;const[v,M]=a;await f({duration:[v.format("YYYY-MM-DD"),M.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:x||""})};return e.jsx("div",{children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,lg:8,children:e.jsx(s.Card,{title:e.jsx(s.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(s.DatePicker.RangePicker,{value:a,onChange:r,style:{width:"100%"}})]}),e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:v=>{const M=v?.value??"";l(M),c(""),y(""),S(P=>!P)}}),e.jsx(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:v=>{const M=v?.value??"";c(M),y("")}},`section_${u}`),e.jsx(ee,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:v=>y(v?.value??"")}),e.jsx(de,{type:"button",value:p?"Searching...":"Search",disabled:p,onClick:U,style:{width:"100%"}})]})})}),e.jsx(s.Col,{xs:24,lg:16,children:e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(un,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ct,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:p,rowKey:v=>String(v?.receipt_id??v?.receipt_no??Math.random()),columns:L,expandable:{expandedRowRender:O},dataSource:A,pagination:{pageSize:20}})]})})})]})})}const Su=({token:t})=>e.jsx(bu,{token:t}),ju=$e.product;function vu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState([]),[l,d]=i.useState([]),[c,x]=i.useState(!1),[y,u]=i.useState(!1),[S,j]=i.useState(null),[w,m]=i.useState(0),[h,g]=i.useState(null),[I,R]=i.useState(""),D=i.useRef(null),C=dn.useReactToPrint({contentRef:D,documentTitle:"Stock Barcodes"}),{isLoading:f,error:p,data:b,mutate:A}=fo({token:t,page:n.page,perPage:n.rowsPerPage}),O=(N,E)=>{a({page:N,rowsPerPage:parseInt(E,10)})},L={selectedRowKeys:r,onChange:(N,E)=>{o(N),d(E)}},U=N=>{j(N),m(Number(N?.quantity??0)),g(null),R(""),x(!0)},v=()=>{x(!1),j(null),m(0),g(null),R("")},M=async()=>{if(!S?.id)return;u(!0);const N=new FormData;N.append("product_id",String(S.id)),N.append("qty",String(w??0)),h&&N.append("tran_date",h.format("YYYY-MM-DD")),I&&N.append("remarks",I);try{const E=await pn(ju.addStock,N,t);E?.Status==="Success"?(_.success("Success! Updated quantity.",{duration:1e3}),v(),await A()):_.error(E?.msg??"Failed to update quantity.",{duration:1e3})}catch{_.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},P=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:(N,E)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(s.Button,{size:"small",onClick:()=>U(E),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:S?.name?`Update Stock: ${S.name}`:"Update Stock",open:c,onCancel:v,onOk:M,okButtonProps:{loading:y},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(s.InputNumber,{min:0,style:{width:"100%"},value:w,onChange:N=>m(N??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{style:{width:"100%"},value:h,onChange:g})]}),e.jsx(Ot,{label:"Remarks",name:"remarks",rows:3,value:I,onChange:N=>R(N.target.value)})]})}),e.jsxs(le,{pt:5,pb:2,children:[e.jsxs(le,{children:["Manage Stock",e.jsx(de,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>C?.(),style:{minWidth:170}})]}),e.jsx(le,{style:{padding:"12px 16px"},children:e.jsx(s.Card,{style:{borderRadius:16},children:e.jsx(Le,{parentCallback:O,data:{newData:b,columns:P,columnstype:"antd",action:!1,Loading:f,error:p,rowSelection:L}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:D,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map(N=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:N?.name??""}),e.jsx(Ei,{value:String(N?.barcode??N?.id??""),height:50,width:1.6,displayValue:!0})]},N?.id??N?.barcode??N?.name))})})})]})}const _u=({token:t})=>e.jsx(vu,{token:t}),wu=$e.report.stock,Cu=$e.product.dropdown,Au=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Tu({token:t}){const n=i.useRef(null),[a,r]=i.useState(null),[o,l]=i.useState(""),{data:d}=G(t?[Cu,t]:null,([m,h])=>Q(m,h)),c=i.useMemo(()=>Au(d),[d]),{trigger:x,isMutating:y,data:u}=Je(wu,(m,{arg:h})=>Os(m,{arg:h},t));i.useEffect(()=>{const h=new Date().toISOString().slice(0,10);x({duration:[h,h]})},[x]);const S=i.useMemo(()=>{const m=u?.data??u??[];return(Array.isArray(m)?m:[]).flatMap(g=>(Array.isArray(g?.ledger)?g.ledger:[]).map((I,R)=>({key:`${g.product_id??g.product_name??"p"}-${R}`,date:I?.date,product:g?.product_name,opening:I?.opening,inward:I?.inward,outward:I?.outward,closing:I?.closing})))},[u]),j=[{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:m=>e.jsx("span",{style:{color:Number(m)<0?"red":"green"},children:m})}],w=async()=>{if(!a||a.length!==2)return;const[m,h]=a;await x({duration:[m.format("YYYY-MM-DD"),h.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(s.Card,{title:e.jsx(s.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(s.DatePicker.RangePicker,{value:a,onChange:r}),e.jsxs("select",{value:o,onChange:m=>l(m.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(m=>e.jsx("option",{value:String(m?.value??""),children:String(m?.label??"")},String(m?.value??m?.id??m?.label)))]}),e.jsx(s.Button,{type:"primary",onClick:w,loading:y,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(un,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ct,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:y,rowKey:"key",columns:j,dataSource:S,pagination:{pageSize:50}})]})]})}const Ru=({token:t})=>e.jsx(Tu,{token:t}),Gr=[{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"}],_t={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},Jr=[{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"}],Qr=[{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 Iu(){const[t,n]=i.useState("dashboard"),[a,r]=i.useState("This Month"),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(1),[u,S]=i.useState(10),[j,w]=i.useState(""),m=i.useRef(null),h=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),g=i.useMemo(()=>{if(!j.trim())return Jr;const f=j.toLowerCase();return Jr.filter(p=>Object.values(p).some(b=>String(b??"").toLowerCase().includes(f)))},[j]),I=i.useMemo(()=>{const f=(x-1)*u;return g.slice(f,f+u)},[g,x,u]),R=()=>{y(1)},D=()=>{const f=[{title:"Total Packages",value:_t.total_packages,icon:e.jsx(X.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:_t.total_downloads.toLocaleString(),icon:e.jsx(X.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:_t.active_packages,icon:e.jsx(X.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:_t.deprecated_packages,icon:e.jsx(X.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:_t.pending_approval,icon:e.jsx(X.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:_t.published_this_month,icon:e.jsx(X.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:_t.published_this_week,icon:e.jsx(X.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:_t.packages_needing_update,icon:e.jsx(X.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:_t.packages_with_issues,icon:e.jsx(X.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(s.Row,{gutter:[16,16],children:f.map((p,b)=>e.jsx(s.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(s.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${p.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(le,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${p.color}15`,color:p.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:p.icon}),e.jsxs(le,{children:[e.jsx(s.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:p.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:p.value})]})]})},b))})},C=()=>{const f=[{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:p=>{let b="default";return p==="published"?b="green":p==="draft"?b="orange":p==="deprecated"?b="red":p==="pending"&&(b="blue"),e.jsx(s.Tag,{color:b,children:p.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:(p,b)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:f};return e.jsx(le,{pt:5,pb:1,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(le,{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(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(le,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],mb:3,children:[h&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(ee,{options:Gr,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:Gr.find(f=>f.value===a)||null,onChange:f=>r(f?.value||"This Month")})}),a==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(xt,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:f=>l(f?f.format("YYYY-MM-DD"):"")})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(xt,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:f=>c(f?f.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(le,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:R})})})]}),e.jsx(s.Tabs,{activeKey:t,onChange:n,items:Qr})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(le,{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(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:Qr.find(f=>f.key===t)?.label||"Report"})}),e.jsxs(le,{p:3,children:[t!=="dashboard"&&e.jsx(un,{data:{tableRef:m}}),t==="dashboard"?D():e.jsx(s.Table,{size:"small",dataSource:I,columns:C(),loading:!1,pagination:!1,bordered:!0,rowKey:f=>f.npm_id||f.package_name||Math.random(),ref:m}),t!=="dashboard"&&g.length>0&&e.jsx(s.Pagination,{current:x,pageSize:u,total:g.length,onChange:(f,p)=>{y(f),S(p)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const Fa=t=>t??localStorage.getItem("authToken")??"",Ns=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},Ae={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"}},ho=()=>Ns(at(),Ae.upload),Du=()=>Ns(at(),Ae.staff.uploadProfile),ku=()=>Ns(at(),Ae.staff.uploadDocuments),Ou=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Fa(r))},St=async(t,n,a)=>Ye(t,n,Fa(a)),Nt=async(t,n,a)=>mt(t,n,Fa(a)),zn=async(t,n,a)=>st(t,n,Fa(a)),Yt=Ae.staff,Pu=Ae.master.shift.dropdown,Eu=Ae.master.department.dropdown,Mu=Ae.master.designation.dropdown,Fu=Ae.roleDropdown,ta=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Nu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Sn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Xr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function $u({token:t,mode:n,staffId:a,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,x]=i.useState(r?.roleValue??null),[y,u]=i.useState(r?.departmentValue??null),[S,j]=i.useState(r?.designationValue??null),[w,m]=i.useState(r?.genderValue??null),[h,g]=i.useState(r?.shiftValue??(d?[]:null)),[I,R]=i.useState(r?.dob?ae(r.dob):null),[D,C]=i.useState(r?.doj?ae(r.doj):null),[f,p]=i.useState(r?.file??""),{data:b}=G(t?[Pu,t]:null,([q,z])=>Q(q,z)),{data:A}=G(t?[Eu,t]:null,([q,z])=>Q(q,z)),{data:O}=G(t?[Mu,t]:null,([q,z])=>Q(q,z)),{data:L}=G(t?[Fu,t]:null,([q,z])=>Q(q,z)),{data:U}=G(t?[Yt.lastEmpNo,t]:null,([q,z])=>Q(q,z)),v=i.useMemo(()=>ta(b),[b]),M=i.useMemo(()=>ta(A),[A]),P=i.useMemo(()=>ta(O),[O]),N=i.useMemo(()=>ta(L),[L]),E=i.useMemo(()=>{const q=U?.data?.emp_number??U?.emp_number??U?.data??"";return String(q??"")},[U]),F=async q=>{q.preventDefault();const z=new FormData(q.target);z.set("role",c?.value??c??""),z.set("department",y?.value??y??""),z.set("designation",S?.value??S??""),z.set("gender",w?.value??w??""),z.set("dob",I?I.format("YYYY-MM-DD"):""),z.set("doj",D?D.format("YYYY-MM-DD"):""),d?(z.delete("shift_id"),(Array.isArray(h)?h:[]).forEach(T=>{z.append("shift_id[]",T?.value??T??"")})):z.set("shift_id",h?.value??h??""),f&&z.set("file",f);try{const k=n==="edit"&&a,T=k?Yt.editBasic:Yt.addBasic;k&&z.set("staff_id",String(a));const $=k?await Nt(T,z,t):await St(T,z,t),B=$?.ID??$?.id??a??null;_.success("Success!",{duration:1e3}),o?.({staffId:B,basic:{roleValue:c,departmentValue:y,designationValue:S,genderValue:w,shiftValue:h,dob:I,doj:D,file:f}})}catch(k){_.error(k?.response?.data?.msg??k?.message??"Failed.",{duration:1e3})}};return 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.jsx(J,{type:"number",name:"emp_number",label:"EMP No",defaultValue:r?.emp_number??E,required:!0}),e.jsx(J,{type:"text",name:"f_name",label:"First Name",defaultValue:r?.f_name??"",required:!0}),e.jsx(J,{type:"text",name:"l_name",label:"Last Name",defaultValue:r?.l_name??"",required:!0}),e.jsx(J,{type:"text",name:"pan_no",label:"PAN",defaultValue:r?.pan_no??""}),e.jsx(J,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??""}),e.jsx(ee,{label:"Role",options:N,value:c,onChange:q=>x(q??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Department",options:M,value:y,onChange:q=>u(q??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Designation",options:P,value:S,onChange:q=>j(q??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:w,onChange:q=>m(q??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"email",label:"Email",defaultValue:r?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:Sn,children:"DOB"}),e.jsx(s.DatePicker,{value:I,onChange:q=>R(q),style:Xr,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:Sn,children:"DOJ"}),e.jsx(s.DatePicker,{value:D,onChange:q=>C(q),style:Xr,placeholder:"Select DOJ"})]}),e.jsx(J,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:r?.bloodGroup??""}),e.jsx(J,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0}),e.jsx(J,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:Sn,children:"Shift"}),e.jsx(ee,{options:v,value:h,onChange:q=>g(q??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:Sn,children:"Profile Picture"}),e.jsx(s.Upload,{maxCount:1,action:Du(),headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status==="done"){const z=Nu(q?.file?.response);z&&p(z)}q?.file?.status==="removed"&&p("")},children:e.jsx(s.Button,{type:"link",style:{paddingLeft:0},children:f?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:Sn,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(de,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const na={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Zr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Uu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ei=t=>{if(!t)return null;const n=ae(t);return n.isValid()?n:null};function Bu({token:t,mode:n,staffId:a,initialRows:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(m=>({name:m?.name??"",from:ei(m?.from),to:ei(m?.to),image:m?.image??""}))),x=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),y=(w,m)=>{c(h=>h.map((g,I)=>I===w?{...g,...m}:g))},u=()=>c(w=>[...w,{name:"",from:null,to:null,image:""}]),S=w=>c(m=>m.length<=1?m:m.filter((h,g)=>g!==w)),j=async w=>{if(w.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const m=new FormData;m.append("staff_id",String(a)),d.forEach((h,g)=>{m.append(`experience[${g}][name]`,String(h?.name??"")),m.append(`experience[${g}][from]`,h?.from?h.from.format("YYYY-MM-DD"):""),m.append(`experience[${g}][to]`,h?.to?h.to.format("YYYY-MM-DD"):""),m.append(`experience[${g}][image]`,String(h?.image??""))});try{const h=n==="edit",g=h?Yt.editExperience:Yt.addExperience,I=h?await Nt(g,m,t):await St(g,m,t);_.success("Success!",{duration:1e3}),o?.({experience:d,result:I})}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((w,m)=>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:na,children:"Name"}),e.jsx("input",{value:w.name,onChange:h=>y(m,{name:h.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:na,children:"From"}),e.jsx(s.DatePicker,{value:w.from,onChange:h=>y(m,{from:h}),style:Zr})]}),e.jsxs("div",{children:[e.jsx("div",{style:na,children:"To"}),e.jsx(s.DatePicker,{value:w.to,onChange:h=>y(m,{to:h}),style:Zr})]}),e.jsxs("div",{children:[e.jsx("div",{style:na,children:"Document"}),e.jsx(s.Upload,{maxCount:1,action:ku(),headers:x,onChange:h=>{if(h?.file?.status==="done"){const g=Uu(h?.file?.response);g&&y(m,{image:g})}h?.file?.status==="removed"&&y(m,{image:""})},children:e.jsx(s.Button,{icon:e.jsx(X.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(s.Button,{type:"text",icon:e.jsx(X.DeleteOutlined,{}),danger:!0,onClick:()=>S(m),disabled:d.length<=1})})]},`exp-${m}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(s.Button,{icon:e.jsx(X.PlusOutlined,{}),onClick:u,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(s.Button,{onClick:l,children:"Back"}),e.jsx(de,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const ti=(t,n=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const a=n.length?n:["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 a){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[]},jn=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function Lu({token:t,mode:n,staffId:a,initialValues:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(r?.type??"Permanent"),[x,y]=i.useState(r?.salary_type??jn[0]?.value),[u,S]=i.useState(Number(r?.amount??0)),[j,w]=i.useState(Number(r?.basic_pay)),[m,h]=i.useState(r?.declarationPERyear??""),{data:g}=G(t?[bd,t]:null,([p,b])=>Q(p,b),{revalidateOnFocus:!1}),I=i.useMemo(()=>ti(g,["allowances","Allowances"]),[g]),R=i.useMemo(()=>ti(g,["dedection","Dedection","deductions","Deductions"]),[g]),D=i.useMemo(()=>{const p=Number(j||0),b=(Array.isArray(I)?I:[]).map(v=>{const M=v?.amount_type??v?.amountType??v?.type??"",P=Number(v?.Amount??v?.amount??0),E=String(M).trim().toLowerCase()==="flat"?P:Number(p)/100*Number(P||0);return{...v,value:Number.isFinite(E)?E:0}}),A=(Array.isArray(R)?R:[]).map(v=>{const M=v?.amount_type??v?.amountType??v?.type??"",P=Number(v?.Amount??v?.amount??0),E=String(M).trim().toLowerCase()==="flat"?P:Number(p)/100*Number(P||0);return{...v,value:Number.isFinite(E)?E:0}}),O=b.reduce((v,M)=>v+Number(M?.value||0),0),L=A.reduce((v,M)=>v+Number(M?.value||0),0),U=Math.max(0,Number(p)+O-L);return{allowances:b,deductions:A,netAmount:U}},[I,R,j]),C=async p=>{if(p.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const b=new FormData;b.append("staff_id",String(a)),b.append("type",d),d==="Nonpermanent"?(b.append("salary_type",x??""),b.append("amount",String(u||"")),b.append("Allowances",JSON.stringify([])),b.append("Dedection",JSON.stringify([]))):(b.append("basic_pay",String(j||"")),b.append("declarationPERyear",String(m??"")),b.append("Allowances",JSON.stringify(D.allowances||[])),b.append("Dedection",JSON.stringify(D.deductions||[])),b.append("amount",String(D.netAmount||0)));try{const A=n==="edit",O=A?Yt.editPayroll:Yt.addPayroll,L=A?await Nt(O,b,t):await St(O,b,t);o?.({payroll:{staffType:d,salaryType:x,amount:u,basicPay:j,declaration:m},result:L})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed.",{duration:1e3})}},f=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(p,b)=>`${b?.Amount??""} / ${b?.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(ee,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:p=>c(p?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(ee,{label:"Type",options:jn,value:jn.find(p=>p.value===x)??jn[0],onChange:p=>y(p?.value??jn[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"number",label:"Amount",value:u,onChange:p=>S(Number(p.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{type:"number",label:"Basic Pay",value:j,onChange:p=>w(Number(p.target.value||0)),required:!0}),e.jsx(J,{type:"text",label:"IT Declarations/Year",value:m,onChange:p=>h(p.target.value)}),e.jsx(J,{type:"number",label:"Net Amount",value:D.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(p,b)=>`${p?.title??"a"}-${b}`,columns:f,dataSource:D.allowances,pagination:!1})}),e.jsx(s.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(p,b)=>`${p?.title??"d"}-${b}`,columns:f,dataSource:D.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(de,{type:"submit",value:"Finish",color:"primary"})})]})})}const qu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function zu({token:t,mode:n="add",staffId:a,onFinished:r}){const[o,l]=i.useState(0),[d,c]=i.useState(a??null),[x,y]=i.useState(null),[u,S]=i.useState(null),[j,w]=i.useState(null),m=n==="edit"?a??d:null,h=i.useMemo(()=>m?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),g=i.useMemo(()=>m?`${Ae.staff.experienceById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),I=i.useMemo(()=>m?`${Ae.staff.payrollById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),{data:R}=G(t&&h?[h,t]:null,([O,L])=>Q(O,L)),{data:D}=G(t&&g?[g,t]:null,([O,L])=>Q(O,L)),{data:C}=G(t&&I?[I,t]:null,([O,L])=>Q(O,L)),f=i.useMemo(()=>{const O=qu(R)[0]??R?.data??R??null;return O?{emp_number:O?.emp_number??O?.empNo??"",f_name:O?.f_name??O?.firstname??O?.first_name??"",l_name:O?.l_name??O?.lastname??O?.last_name??"",pan_no:O?.pan_no??"",adhar_no:O?.adhar_no??"",email:O?.email??"",dob:O?.dob??"",doj:O?.doj??"",bloodGroup:O?.bloodGroup??O?.blood_group??"",contact_no:O?.contact_no??O?.phone??"",education:O?.education??"",address:O?.address??"",file:O?.file??O?.profile_picture??""}:null},[R]),p=i.useMemo(()=>{const O=D?.data??D??null;return(Array.isArray(O?.experience)?O.experience:Array.isArray(O)?O:[]).map(U=>({name:U?.name??"",from:U?.from??"",to:U?.to??"",image:U?.image??""}))},[D]),b=i.useMemo(()=>{const O=C?.data??C??null;return O?{type:O?.type??"Permanent",salary_type:O?.salary_type??"",amount:O?.amount??"",basic_pay:O?.basic_pay??"",declarationPERyear:O?.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(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:n==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(s.Steps,{current:o,items:A}),o===0&&e.jsx($u,{token:t,mode:n,staffId:m,initialValues:f,onSubmitted:({staffId:O})=>{O&&c(O),l(1)}}),o===1&&e.jsx(Bu,{token:t,mode:n,staffId:m??d,initialRows:p,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(Lu,{token:t,mode:n,staffId:m??d,initialValues:b,onBack:()=>l(1),onSubmitted:()=>{_.success("Completed.",{duration:1e3}),r?.({staffId:m??d}),l(0),n!=="edit"&&(c(null),y(null),S(null),w(null))}})]})})]})}function Yu({token:t}){return e.jsx(zu,{token:t,mode:"add"})}const Wu=({token:t})=>e.jsx(Yu,{token:t}),aa=Ae.staff,Vu=Ae.roleDropdown,Hu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Ku=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Gu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(""),[l,d]=i.useState(""),{data:c}=G(t?[Vu,t]:null,([I,R])=>Q(I,R)),x=i.useMemo(()=>Hu(c),[c]),y=i.useMemo(()=>{const I=n.page,R=n.rowsPerPage,D=r&&!l?`${aa.searchByRole}?role_id=${encodeURIComponent(String(r))}`:l?`${aa.searchByKeywords}?key=${encodeURIComponent(String(l))}`:aa.list,C=D.includes("?")?"&":"?";return`${D}${C}page=${encodeURIComponent(String(I))}&per_page=${encodeURIComponent(String(R))}`},[n.page,n.rowsPerPage,l,r]),{isLoading:u,error:S,data:j,mutate:w}=G(t?[y,t]:null,([I,R])=>Q(I,R)),m=i.useMemo(()=>Ku(j),[j]),h=async I=>{const R=I?.id??I?.fk_staffID??I?.staff_id;if(R)try{await zn(aa.deactivate,R,t),_.success("Success! Staff deactivated.",{duration:1e3}),await w()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to deactivate staff.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(I,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:(I,R)=>e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(X.DeleteOutlined,{}),onClick:()=>h(R),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(s.Card,{title:e.jsx(s.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(ee,{options:[{value:"",label:"All Roles"},...x],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:I=>{o(I?.value??""),a(R=>({...R,page:1}))}}),e.jsx(J,{type:"text",label:"Keyword",value:l,onChange:I=>d(I.target.value),placeholder:"Search by keywords"}),e.jsx(de,{type:"button",value:"Refresh",onClick:()=>w()})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:u,rowKey:I=>String(I?.id??I?.fk_staffID??I?.staff_id??Math.random()),columns:g,dataSource:m,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(I,R)=>a({page:I,rowsPerPage:R}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const Ju=({token:t})=>e.jsx(Gu,{token:t}),Qu=Ae.attendance,Xu=Ae.roleDropdown,ni=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},sa={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ai={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Zu({token:t,open:n,onClose:a,roleId:r,onSaved:o}){const[l,d]=i.useState(null),[c,x]=i.useState(""),[y,u]=i.useState(ae()),[S,j]=i.useState(ae()),[w,m]=i.useState(ae()),h=i.useMemo(()=>r?`${Ae.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:g}=G(t&&h?[h,t]:null,([p,b])=>Q(p,b)),I=i.useMemo(()=>ni(g),[g]),{trigger:R,data:D}=Je(t?Ae.attendance.staffShiftByStaffId:null,(p,{arg:b})=>zt(p,{arg:b},t)),C=i.useMemo(()=>ni(D),[D]),f=async()=>{if(!l?.value){_.error("Select staff.",{duration:1e3});return}if(!c){_.error("Select shift.",{duration:1e3});return}const p=new FormData;p.set("staffID",String(l.value)),p.set("shift_id",String(c)),p.set("attendance_date",y?y.format("YYYY-MM-DD"):""),p.set("intime",S?S.format("h:mm a"):""),p.set("outime",w?w.format("h:mm a"):"");try{await St(Ae.attendance.manualAttendance,p,t),_.success("Success!",{duration:1e3}),o?.(),a?.(),d(null),x(""),u(ae()),j(ae()),m(ae())}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed.",{duration:1e3})}};return e.jsx(s.Modal,{open:n,onCancel:a,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(s.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{label:"Staff",options:I,value:l,onChange:async p=>{if(d(p??null),x(""),p?.value&&R)try{await R({staff_id:p.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:sa,children:"Shift"}),e.jsx(s.Radio.Group,{value:c,onChange:p=>x(p.target.value),style:{display:"grid",gap:8},children:C.map(p=>e.jsx(s.Radio,{value:p?.value,children:p?.label??p?.name??p?.title??String(p?.value??"")},String(p?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:sa,children:"Date"}),e.jsx(s.DatePicker,{value:y,onChange:p=>p&&u(p),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:sa,children:"Start Time"}),e.jsx(s.TimePicker,{value:S,onChange:p=>p&&j(p),use12Hours:!0,format:"h:mm a",style:ai})]}),e.jsxs("div",{children:[e.jsx("div",{style:sa,children:"End Time"}),e.jsx(s.TimePicker,{value:w,onChange:p=>p&&m(p),use12Hours:!0,format:"h:mm a",style:ai})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(s.Button,{onClick:a,children:"Cancel"}),e.jsx(de,{type:"button",value:"Save",color:"primary",onClick:f})]})]})})})}const ep=({tableRef:t,excelDisabled:n})=>{const a=new Date().getTime(),r=dn.useReactToPrint({content:()=>t?.current});return e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(s.Row,{gutter:8,children:[e.jsx(s.Col,{children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:n?e.jsx(s.Button,{type:"text",icon:e.jsx(X.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>_.error("You must save attendance before download",{duration:2e3})}):e.jsx(po.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:t?.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},tp=(t,n)=>{const a=t?.data?.data??t?.data??t??null;return a?n==="student"?Array.isArray(a?.student)?a.student:[]:Array.isArray(a?.staff)?a.staff:[]:[]},np=t=>{const n=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,a=Number(n);return Number.isFinite(a)&&a>=0?a:0},ap=(t,n)=>{const a=t?.data?.data??t?.data??t??null;return a?n==="student"?{sunday:String(a?.sunday??"").toLowerCase()==="yes",holiday:String(a?.holiday??"").toLowerCase()==="yes"}:{sunday:!!a?.sunday,holiday:!!a?.holiday}:{sunday:!1,holiday:!1}};function sp({token:t,url:n,columns:a,reload:r,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:x="staff"}){const y=i.useRef(null),[u,S]=i.useState({page:0,rowsPerPage:10}),[j,w]=i.useState(!1),[m,h]=i.useState(!1),[g,I]=i.useState(null),[R,D]=i.useState([]),[C,f]=i.useState({sunday:!1,holiday:!1}),[p,b]=i.useState(!0);i.useEffect(()=>{S(U=>({...U,page:0}))},[n]),i.useEffect(()=>{let U=!0;return(async()=>{if(!(!t||!n)){w(!0);try{const M=String(n).includes("?")?"&":"?",P=`${n}${M}page=${u.page+1}&per_page=${u.rowsPerPage}`,N=await Q(P,t);if(!U)return;I(N),N?.Status==="Success"?(d?.(!1),D(tp(N,x)),f(ap(N,x))):(d?.(!0),D([]),f({sunday:!1,holiday:!1}))}catch{if(!U)return;d?.(!0),D([])}finally{U&&w(!1)}}})(),()=>{U=!1}},[u.page,u.rowsPerPage,r,d,t,x,n]);const A=i.useMemo(()=>np(g),[g]);i.useEffect(()=>{const U=(Array.isArray(R)?R:[]).find(v=>v?.attendence_type_id===null);b(!!U)},[R]);const O=async()=>{if(t){h(!0);try{if(x==="staff"){const U=(Array.isArray(R)?R:[]).map(v=>({staff_id:v?.staff_id,attendence_type_id:v?.attendence_type_id?v.attendence_type_id:"1",in_time:v?.intime,out_time:v?.outtime,date:c}));await St(Ae.attendance.addAttendanceToStaffByBranch,U,t),_.success("Attendance saved successfully",{duration:2e3}),o?.(v=>!v)}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{h(!1)}}},L=i.useMemo(()=>(Array.isArray(a)?a:[]).map(v=>v?.selector==="attendence_type_id"?{title:v?.name??"Attendance",dataIndex:v.selector,key:v.selector,render:M=>M==null||M===""?e.jsx(s.Tag,{color:"orange",children:"Not Set"}):String(M)==="1"?e.jsx(s.Tag,{color:"green",children:"Present"}):String(M)==="4"?e.jsx(s.Tag,{color:"red",children:"Absent"}):String(M)==="3"?e.jsx(s.Tag,{color:"orange",children:"Late"}):e.jsx(s.Tag,{children:String(M)})}:v?.selector==="snum"?{title:v?.name??"Sl",key:v.selector,render:(M,P,N)=>N+1}:{title:v?.name??v?.selector,dataIndex:v?.selector,key:v?.selector}),[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{children:[e.jsx(ep,{tableRef:y,excelDisabled:p}),e.jsx(s.Modal,{open:m,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(s.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:y,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(U,v)=>String(U?.id??U?.staff_id??v),columns:L,dataSource:R,loading:j,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:A,showSizeChanger:!0,onChange:(U,v)=>S({page:U-1,rowsPerPage:v})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:O,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const rp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ip={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function op({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(ae().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,x]=i.useState(null),[y,u]=i.useState(!1),[S,j]=i.useState(!0),[w,m]=i.useState(!1),h=i.useRef(null),{data:g}=G(t?[Xu,t]:null,([D,C])=>Q(D,C)),I=i.useMemo(()=>rp(g),[g]),R=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(s.Card,{title:e.jsx(s.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(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:D=>a(D?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{defaultValue:ae(),onChange:D=>D&&o(D.format("YYYY-MM-DD")),style:ip,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!r||(x(`${Qu.staffListForAttendance}?role=${encodeURIComponent(String(n))}&date=${encodeURIComponent(String(r))}`),d(D=>!D))}})})]})}),e.jsxs(s.Card,{title:e.jsx(s.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(s.Button,{size:"small",type:y?"primary":"default",onClick:()=>u(D=>!D),children:y?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"default",disabled:S,onClick:()=>m(!0),children:"Give Attendance"})]}),c?e.jsx(sp,{token:t,url:c,columns:R,reload:l,setReload:d,saveBtnRef:h,setSaveBtnDisabled:j,date:r,type:"staff",holidayChecked:y}):null]}),e.jsx(Zu,{token:t,open:w,onClose:()=>m(!1),roleId:n,onSaved:()=>d(D=>!D)})]})}const lp=({token:t})=>e.jsx(op,{token:t}),si=Ae.attendanceReport.monthlyStaffReport,dp=Ae.roleDropdown,cp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function up({token:t}){const n=i.useRef(null),[a,r]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),x=i.useMemo(()=>Es(5),[]),{data:y}=G(t?[dp,t]:null,([U,v])=>Q(U,v)),u=i.useMemo(()=>cp(y),[y]),[S,j]=i.useState([]),[w,m]=i.useState(1),[h,g]=i.useState(!1),[I,R]=i.useState(!1),[D,C]=i.useState(null),f=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:p}=Je(t&&si?`${si}?page=${w}&per_page=3`:null,(U,{arg:v})=>zt(U,{arg:v},t),{onSuccess:U=>{g(!1);const v=Array.isArray(U)?U:[];v.length>0&&j(M=>[...M||[],...v]),v.length>1?m(M=>M+1):R(!1)},onError:()=>{g(!1),R(!1)}});i.useEffect(()=>{I&&p&&D&&p(D)},[I,w,D,p]);const b=i.useMemo(()=>{const U=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(v,M)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:M?.full_name??""})}];return Array.isArray(S)&&S.length>0&&((S[0]?.monthly_data??[]).forEach((M,P)=>{U.push({title:P+1,align:"center",key:String(P+1),render:(N,E)=>{const F=E?.monthly_data?.[P]?.[0]?.data?.[0]??{},q=F?.intime??"",z=F?.outtime??"",k=F?.attendance_type??"";return e.jsx(s.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",q]}),e.jsxs("div",{children:["Out Time ",z]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:ze(k)})})}})}),U.push({title:"Total",key:"Total",render:(M,P)=>{const N=P?.monthly_data??[],E=N.filter(q=>q?.[0]?.data?.[0]?.attendance_type==="A").length,F=N.filter(q=>q?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",E," P : ",F]})})}})),U},[S]),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")}],[]),O=i.useMemo(()=>d.month?o.find(U=>U?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),L=async U=>{if(U.preventDefault(),!d.role||!d.year||!d.month)return;m(1),g(!0),j([]);const v={session:f,year:d.year,month:d.month,day:"01",role:d.role};C(v),R(!0),await p?.(v)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{className:"d-print-none",title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),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(ee,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:U=>c(v=>({...v,role:U?.value??"",rolllabel:U?.label??""}))}),e.jsx(ee,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:U=>{const v=Ms(U?.value);l(v),r(M=>!M),c(M=>({...M,year:U?.label??""}))}}),e.jsx(ee,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:U=>c(v=>({...v,month:U?.value??""}))},`month-${a}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ct,{})}),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:O})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(un,{data:{tableRef:n}})})]}),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(s.Skeleton,{active:!0,loading:h,paragraph:{rows:10},children:e.jsx(s.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:b,dataSource:S,pagination:!1,scroll:{x:"max-content"},rowKey:(U,v)=>String(U?.staff_id??U?.id??v)})})]})})]})}const pp=({token:t})=>e.jsx(up,{token:t}),ri=Ae.payroll,mp=Ae.roleDropdown,yp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},fp=t=>t?.data?.data??t?.data??t??[];function hp({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:a}){const[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,x]=i.useState([]),[y,u]=i.useState({role:"",roleLabel:"",year:"",month:""}),[S,j]=i.useState(null),w=b=>{if(!b)return;if(typeof a=="function"){a(b);return}const A=`${n}?id=${encodeURIComponent(String(b))}`;typeof window<"u"&&window?.location&&(window.location.href=A)},{data:m}=G(t?[mp,t]:null,([b,A])=>Q(b,A)),h=i.useMemo(()=>yp(m),[m]),g=i.useMemo(()=>Es(5),[]),{isLoading:I,error:R,data:D}=G(t&&S?[S,t]:null,([b,A])=>Q(b,A)),C=i.useMemo(()=>{const b=fp(D);return Array.isArray(b)?b:[]},[D]),f=i.useMemo(()=>{const b=D?.pagination?.total_rows??D?.data?.pagination?.total_rows??D?.total??D?.total_rows,A=Number(b);return Number.isFinite(A)&&A>=0?A:C.length},[D,C.length]),p=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(b,A,O)=>O+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:(b,A)=>{const O=A?.id??A?.staff_id??A?.staffId;return e.jsx(s.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{w(O)},children:co(A?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:b=>{if(b.preventDefault(),!y.role||!y.year||!y.month)return;const A=`${ri.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`;j(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(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:b=>u(A=>({...A,role:b?.value??"",roleLabel:b?.label??""}))}),e.jsx(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:b=>{const A=Ms(b?.value);x(A),d(O=>!O),u(O=>({...O,year:b?.label??"",month:""}))}}),e.jsx(ee,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:b=>u(A=>({...A,month:b?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary",onClick:()=>o(b=>({...b,page:1}))})})]})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:I,rowKey:(b,A)=>String(b?.id??b?.staff_id??A),columns:p,dataSource:C,pagination:{current:r.page,pageSize:r.rowsPerPage,total:f,showSizeChanger:!0,onChange:(b,A)=>{o({page:b,rowsPerPage:A}),!(!y.role||!y.year||!y.month)&&j(`${ri.payrollByRole}?page=${encodeURIComponent(String(b))}&per_page=${encodeURIComponent(String(A))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`)}},scroll:{x:"max-content"}})]})})}const gp=({token:t})=>e.jsx(hp,{token:t}),go=Ae.leave,mn=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>Ou({baseUrl:l,page:d,perPage:c},x)),xp=({token:t,page:n=1,perPage:a=10})=>mn({token:t,baseUrl:go.requestTable,page:n,perPage:a}),bp=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Sp=(t,n)=>{const a=new FormData;return Object.entries(t??{}).forEach(([r,o])=>{o!=null&&a.append(r,String(o))}),a.set("status",n),a};function jp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:o,data:l,mutate:d}=xp({token:t,page:n.page,perPage:n.rowsPerPage}),c=i.useMemo(()=>bp(l),[l]),x=async(u,S)=>{try{const j=Sp(u,S),w=await Nt(go.approveRequest,j,t);w?.Status==="Success"?_.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):_.error(w?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to update request.",{duration:1e3})}},y=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,S)=>S?.full_name??S?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,S)=>S?.leave_from??S?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,S)=>S?.leave_to??S?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,S)=>S?.leavetype??S?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,S)=>S?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,S)=>S?.employee_remark??S?.reason??""},{title:"View",key:"document_file",width:140,render:(u,S)=>{const j=S?.document_file;return j?e.jsx(s.Button,{size:"small",onClick:()=>window.open(j,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,S)=>{const j=String(S?.status??"").toLowerCase();return j==="approved"?e.jsx(s.Tag,{color:"green",children:"Approved"}):j==="declined"?e.jsx(s.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(s.Button,{type:"text",size:"small",onClick:()=>x(S,"approved"),icon:e.jsx(X.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(s.Button,{type:"text",size:"small",onClick:()=>x(S,"declined"),icon:e.jsx(X.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:r,rowKey:(u,S)=>String(u?.id??u?.leave_id??S),columns:y,dataSource:c,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(u,S)=>a({page:u,rowsPerPage:S}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const vp=({token:t})=>e.jsx(jp,{token:t}),_p=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",wp=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:ho(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=_p(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},xo=Ae.leave,Cp=Ae.master.leaveType.dropdown,Ap=({token:t,page:n=1,perPage:a=10})=>mn({token:t,baseUrl:xo.table,page:n,perPage:a}),Tp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ds={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Rp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c]=s.Form.useForm(),{isLoading:x,error:y,data:u,mutate:S}=Ap({token:t,page:n.page,perPage:n.rowsPerPage}),{data:j}=G(t?[Cp,t]:null,([C,f])=>Q(C,f)),w=i.useMemo(()=>Tp(j),[j]),m=(C,f)=>a({page:C,rowsPerPage:parseInt(f,10)}),h=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:ae()}),o(!0)},g=()=>{o(!1),d(""),c.resetFields()},I=async C=>{const f=new FormData;f.set("apply_date",C?.apply_date?C.apply_date.format("YYYY-MM-DD"):""),f.set("leave_type",C?.leave_type?.value??C?.leave_type??""),f.set("from_date",C?.from_date?C.from_date.format("YYYY-MM-DD"):""),f.set("to_date",C?.to_date?C.to_date.format("YYYY-MM-DD"):""),f.set("reason",C?.reason??""),l&&f.set("file",l);try{await St(xo.apply,f,t),_.success("Success! Leave request submitted.",{duration:1e3}),g(),await S()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to submit leave request.",{duration:1e3})}},R=i.useMemo(()=>{const C=u?.data??u??[];return Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[]},[u]),D=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(C,f)=>f?.leavetype??f?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(C,f)=>f?.date??f?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(C,f)=>f?.leave_from??f?.from_date??""},{title:"To",key:"leave_to",width:130,render:(C,f)=>f?.leave_to??f?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(C,f)=>f?.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(s.Modal,{open:r,title:"Add Leave Request",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:c,layout:"vertical",onFinish:I,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.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(s.DatePicker,{style:ds})]})}),e.jsx(s.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(ee,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsx(s.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(s.DatePicker,{style:ds})]})}),e.jsx(s.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(s.DatePicker,{style:ds})]})}),e.jsx(s.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(J,{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(wp,{token:t,value:l,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(de,{type:"button",value:"Add Leave Request",onClick:h})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:x,rowKey:(C,f)=>String(C?.id??C?.leave_id??f),columns:D,dataSource:R,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(C,f)=>m(C,f),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Ip=({token:t})=>e.jsx(Rp,{token:t}),xa=Ae.master.leaveType,Dp=({token:t,page:n=1,perPage:a=10})=>mn({token:t,baseUrl:xa.table,page:n,perPage:a});function kp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:y,error:u,data:S,mutate:j}=Dp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,f)=>{a({page:C,rowsPerPage:parseInt(f,10)})},m=async C=>{const f=new FormData;f.set("title",C?.title??"");try{await j(St(xa.add,f,t),rt(f)),_.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add leave type.",{duration:1e3})}},h=C=>{x(C??null),o.setFieldsValue({title:C?.leave_type_name??C?.name??""}),d(!0)},g=()=>{d(!1),x(null),o.resetFields()},I=async C=>{const f=c?.id??c?.leave_type_id;if(!f){_.error("Missing leave type id.",{duration:1e3});return}const p=new FormData;p.set("id",String(f)),p.set("title",C?.title??"");try{await Nt(xa.edit,p,t),await j(),_.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),g()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to update leave type.",{duration:1e3})}},R=async C=>{const f=C?.id??C?.leave_type_id;if(f)try{await j(zn(xa.remove,f,t),Qe(f)),_.success("Success! Deleted leave type.",{duration:1e3})}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete leave type.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,f)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(f)}),e.jsx(s.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>R(f),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Leave Type",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:S,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const Op=({token:t})=>e.jsx(kp,{token:t}),ba=Ae.master.department,Pp=({token:t,page:n=1,perPage:a=10})=>mn({token:t,baseUrl:ba.table,page:n,perPage:a});function Ep({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:y,error:u,data:S,mutate:j}=Pp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,f)=>{a({page:C,rowsPerPage:parseInt(f,10)})},m=async C=>{const f=new FormData;f.set("title",C?.title??"");try{await j(St(ba.add,f,t),rt(f)),_.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add department.",{duration:1e3})}},h=C=>{x(C??null),o.setFieldsValue({title:C?.department_name??C?.name??""}),d(!0)},g=()=>{d(!1),x(null),o.resetFields()},I=async C=>{const f=c?.id??c?.department_id;if(!f){_.error("Missing department id.",{duration:1e3});return}const p=new FormData;p.set("id",String(f)),p.set("title",C?.title??"");try{await Nt(ba.edit,p,t),await j(),_.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),g()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to update department.",{duration:1e3})}},R=async C=>{const f=C?.id??C?.department_id;if(f)try{await j(zn(ba.remove,f,t),Qe(f)),_.success("Success! Deleted department.",{duration:1e3})}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete department.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,f)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(f)}),e.jsx(s.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>R(f),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Department",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:S,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const Mp=({token:t})=>e.jsx(Ep,{token:t}),Sa=Ae.master.designation,Fp=({token:t,page:n=1,perPage:a=10})=>mn({token:t,baseUrl:Sa.table,page:n,perPage:a});function Np({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:y,error:u,data:S,mutate:j}=Fp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,f)=>{a({page:C,rowsPerPage:parseInt(f,10)})},m=async C=>{const f=new FormData;f.set("title",C?.title??"");try{await j(St(Sa.add,f,t),rt(f)),_.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add designation.",{duration:1e3})}},h=C=>{x(C??null),o.setFieldsValue({title:C?.designation??""}),d(!0)},g=()=>{d(!1),x(null),o.resetFields()},I=async C=>{const f=c?.id??c?.designation_id;if(!f){_.error("Missing designation id.",{duration:1e3});return}const p=new FormData;p.set("id",String(f)),p.set("title",C?.title??"");try{await Nt(Sa.edit,p,t),await j(),_.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),g()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to update designation.",{duration:1e3})}},R=async C=>{const f=C?.id??C?.designation_id;if(f)try{await j(zn(Sa.remove,f,t),Qe(f)),_.success("Success! Deleted designation.",{duration:1e3})}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete designation.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,f)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(f)}),e.jsx(s.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>R(f),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Designation",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:S,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const $p=({token:t})=>e.jsx(Np,{token:t}),ja=Ae.master.shift,Up=({token:t,page:n=1,perPage:a=10})=>mn({token:t,baseUrl:ja.table,page:n,perPage:a}),et="hh:mm A",en=t=>{const n=String(t??"");if(!n)return null;const a=ae(n,[et,"HH:mm","HH:mm:ss"],!0);return a.isValid()?a:null},tn=t=>t?t.format(et):"",pt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Bp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:y,error:u,data:S,mutate:j}=Up({token:t,page:n.page,perPage:n.rowsPerPage}),w=(p,b)=>{a({page:p,rowsPerPage:parseInt(b,10)})},m=(p,b)=>{const A=new FormData;return b&&A.set("id",String(b)),A.set("name",p?.name??""),A.set("start_time",tn(p?.start_time)),A.set("end_time",tn(p?.end_time)),A.set("shift_start_from",tn(p?.shift_start_from)),A.set("shift_start_to",tn(p?.shift_start_to)),A.set("shift_end_from",tn(p?.shift_end_from)),A.set("shift_end_to",tn(p?.shift_end_to)),A},h=async p=>{try{const b=m(p);await j(St(ja.add,b,t),rt(b)),_.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to add shift.",{duration:1e3})}},g=p=>{x(p??null),o.setFieldsValue({name:p?.shift_name??p?.name??"",start_time:en(p?.start_time),end_time:en(p?.end_time),shift_start_from:en(p?.shift_start_from),shift_start_to:en(p?.shift_start_to),shift_end_from:en(p?.shift_end_from),shift_end_to:en(p?.shift_end_to)}),d(!0)},I=()=>{d(!1),x(null),o.resetFields()},R=async p=>{const b=c?.id??c?.shift_id;if(!b){_.error("Missing shift id.",{duration:1e3});return}try{const A=m(p,b);await Nt(ja.edit,A,t),await j(),_.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),I()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update shift.",{duration:1e3})}},D=async p=>{const b=p?.id??p?.shift_id;if(b)try{await j(zn(ja.remove,b,t),Qe(b)),_.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:(p,b)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>g(b)}),e.jsx(s.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>D(b),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]),f=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Shift",onCancel:I,footer:null,destroyOnClose:!0,children:e.jsxs(s.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(s.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(s.Form.Item,{name:"start_time",label:"Start Time",rules:f,children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:f,children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:I,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(s.Form,{form:r,layout:"vertical",onFinish:h,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(s.Form.Item,{name:"start_time",label:"Start Time",rules:f,children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:f,children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:et,use12Hours:!0,style:pt})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:S,columns:C,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const Lp=({token:t})=>e.jsx(Bp,{token:t}),ii=Ae.attendance;function qp({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((n,a)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:n?.shift_name??""},`${a}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((n,a)=>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"})]},`${a}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((n,a)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${n?.name??""} ${n?.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:n?.attendance_data?(n.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:n?.attendance_data?(n.attendance_data?.[r?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${a}`))]},`${a}row`))})]})}):null}const zp=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Yp=t=>{const n=String(t??"").toLowerCase();return n==="present"?e.jsx(s.Tag,{color:"green",children:"Present"}):n==="absent"?e.jsx(s.Tag,{color:"red",children:"Absent"}):n==="leave"?e.jsx(s.Tag,{color:"orange",children:"Leave"}):e.jsx(s.Tag,{children:t??""})};function Wp({token:t}){const[n,a]=i.useState(ae()),[r,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${r?ii.dailyAttendanceMultipleShift:ii.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,r,l]),{isLoading:x,error:y,data:u}=G(t?[c,t]:null,([h,g])=>Q(h,g)),S=i.useMemo(()=>zp(u),[u]),j=i.useMemo(()=>r?u?.data?.data??u?.data??u??null:null,[u,r]),w=dn.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),m=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(h,g,I)=>I+1},{title:"Name",key:"name",render:(h,g)=>`${g?.name??""} ${g?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(h,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[Yp(g?.attendance),g?.late_time?e.jsx(s.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(h,g)=>g?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(h,g)=>g?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(h,g)=>g?.late_time?e.jsx(s.Tag,{color:"red",children:g.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.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(s.DatePicker,{value:n,onChange:h=>h&&a(h),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(s.Switch,{checked:r,onChange:o})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",onClick:()=>d(h=>h+1)})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(X.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(Ct,{})}),r?e.jsx(qp,{data:j}):e.jsx(s.Table,{bordered:!0,size:"small",loading:x,rowKey:(h,g)=>String(h?.id??h?.staff_id??g),columns:m,dataSource:S,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const Vp=({token:t})=>e.jsx(Wp,{token:t}),oi=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Hp=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 Kp({token:t,staffId:n}){const[a,r]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[x,y]=i.useState(""),[u,S]=i.useState(""),j=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),w=O=>{const L=Number(O??0),U=Number.isFinite(L)?L.toLocaleString("en-IN"):"0";return`${j?`${j} `:""}${U}`},m=i.useMemo(()=>n?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),h=i.useMemo(()=>n?`${Ae.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:g}=G(t&&m?[m,t]:null,([O,L])=>Q(O,L)),{data:I,isLoading:R,mutate:D}=G(t&&h?[h,t]:null,([O,L])=>Q(O,L)),C=i.useMemo(()=>oi(g)[0]??g?.data??g??null,[g]),f=i.useMemo(()=>oi(I),[I]),p=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:(O,L)=>e.jsx("div",{style:{fontSize:11},children:gt(L?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(O,L)=>e.jsx("div",{style:{fontSize:11},children:gt(L?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(O,L)=>e.jsx("div",{style:{fontSize:11},children:gt(L?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(O,L)=>e.jsx("div",{style:{fontSize:11},children:gt(L?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(O,L)=>e.jsx("div",{style:{cursor:L?.status==="due"?"pointer":"default"},onClick:()=>{L?.status==="due"&&(l(L),r(!0))},children:co(L?.status)})}],[]),b=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 O={...o,staff_id:n,payment_type:d?.value??"",notes:x,attchement:u};try{await Ye(Ae.payroll.generatePayslip,{arg:O},t),_.success("Success!",{duration:1e3}),r(!1),l(null),y(""),S(""),await D()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.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(s.Table,{bordered:!0,size:"small",loading:R,rowKey:(O,L)=>String(O?.id??`${O?.month}-${L}`),columns:p,dataSource:f,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(s.Modal,{open:a,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(ee,{label:"Pay",options:b,value:d,onChange:O=>c(O??b[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(s.Input.TextArea,{rows:4,placeholder:"Note",value:x,onChange:O=>y(O.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(s.Upload,{maxCount:1,action:ho(),headers:t?{Authorization:t}:void 0,onChange:O=>{if(O?.file?.status==="done"){const L=Hp(O?.file?.response);L&&S(L)}O?.file?.status==="removed"&&S("")},children:e.jsx(s.Button,{icon:e.jsx(X.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(s.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(de,{type:"button",value:o?.Total_Payable_Amount?`Pay ${w(o.Total_Payable_Amount)}`:"Pay",onClick:A})]})]})})]})}function Gp({token:t,staffId:n}){const a=i.useMemo(()=>{if(n!=null&&String(n).trim()!=="")return n;if(typeof window>"u")return null;const r=new URLSearchParams(window.location.search).get("id");return r||null},[n]);return a?e.jsx(Kp,{token:t,staffId:a}):e.jsx(s.Card,{title:e.jsx(s.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 $t({onAdd:t,onExport:n,onPrint:a,onDownload:r,onFilter:o,onRefresh:l,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(X.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(X.FileExcelOutlined,{}),onClick:n},{key:"print",title:"Print",icon:e.jsx(X.PrinterOutlined,{}),onClick:a},{key:"download",title:"Download",icon:e.jsx(X.DownloadOutlined,{}),onClick:r},{key:"filter",title:"Filter",icon:e.jsx(X.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(X.ReloadOutlined,{}),onClick:l}],[t,n,a,r,o,l]),x=i.useMemo(()=>{const y=Array.isArray(d)&&d.length?new Set(d):null;return y?c.filter(u=>y.has(u.key)):c},[c,d]);return e.jsx(s.Space,{size:8,children:x.map(y=>e.jsx(s.Tooltip,{title:y.title,children:e.jsx(s.Button,{type:"text",icon:y.icon,onClick:y.onClick,disabled:!y.onClick})},y.key))})}const $s=t=>t??localStorage.getItem("authToken")??"",wt={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"}},Pt=async(t,n)=>Q(t,$s(n)),Jp=async(t,n,a)=>Ye(t,n,$s(a)),Qp=async(t,n,a)=>On(t,{arg:n},$s(a)),Pn=(t,n)=>{const a=new URLSearchParams;Object.entries(n??{}).forEach(([o,l])=>{l==null||l===""||a.set(o,String(l))});const r=t.includes("?")?"&":"?";return`${t}${r}${a.toString()}`},li=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},Xp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},bo=(t,n)=>{const a=t?.data?.data??t?.data??t??{},r=n?a?.[n]:a;return Array.isArray(r)?r:Array.isArray(a?.student)?a.student:Array.isArray(a?.staff)?a.staff:Array.isArray(a?.data)?a.data:[]},Zp=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],em=t=>{const n={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(a=>{if(Array.isArray(a?.monthly_data)||Array.isArray(a?.month_data)){Zp(a).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")&&(n.present+=1),(d==="A"||d==="4")&&(n.absent+=1),(d==="L"||d==="3")&&(n.late+=1),(d==="LEAVE"||d==="2")&&(n.leave+=1)});return}const r=String(a?.attendance_type??a?.attendence_type_id??"").toUpperCase();(r==="P"||r==="1")&&(n.present+=1),(r==="A"||r==="4")&&(n.absent+=1),(r==="L"||r==="3")&&(n.late+=1),(r==="LEAVE"||r==="2")&&(n.leave+=1)}),n},Us=(t,n)=>{const{data:a,isLoading:r,error:o}=G(n&&t?[t,n]:null,([l,d])=>Pt(l,d));return{isLoading:r,error:o,data:a,options:i.useMemo(()=>Xp(a),[a])}},Na=t=>Us(wt.dropdowns.classes,t),$a=(t,n)=>{const a=t?`${wt.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return Us(a,n)},tm=t=>Us(wt.dropdowns.sessions,t),Bs=t=>{const n=String(t??"").toUpperCase();return ze(n==="1"||n==="P"||n==="PRESENT"?"P":n==="4"||n==="A"||n==="ABSENT"?"A":n==="3"||n==="L"||n==="LATE"?"L":n==="2"||n==="LEAVE"?"LEAVE":n==="W"?"W":n==="H"?"H":n||"-")},So=(t,n,a)=>{const r=new Blob([t],{type:n}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.download=a,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},di=t=>String(t??"").replace(/"/g,'""'),nm=({rows:t,columns:n,fileName:a})=>{const r=Array.isArray(n)?n:[],o=Array.isArray(t)?t:[],l=r.map(c=>`"${di(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,x)=>r.map(y=>{const u=y?.dataIndex??y?.selector??y?.key,S=u==="sl"?x+1:c?.[u];return`"${di(S)}"`}).join(",")).join(`
|
|
60
60
|
`);So([l,d].filter(Boolean).join(`
|
|
61
|
-
`),"text/csv;charset=utf-8;",a)},sm=({value:t,fileName:n})=>{So(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",n)};function jo({summary:t}){const n=[{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:n.map(a=>e.jsxs(s.Card,{size:"small",styles:{body:{padding:16}},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:8},children:a.label}),e.jsx("div",{style:{fontSize:24,fontWeight:700,color:a.color},children:t?.[a.key]??0})]},a.key))})}function on({summary:t,title:n="Attendance Overview"}){const a=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(...a.map(o=>o.value),1);return e.jsx(s.Card,{size:"small",title:n,children:e.jsx("div",{style:{display:"grid",gap:12},children:a.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 rm(){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(s.Space,{wrap:!0,size:[12,8],children:t.map(n=>e.jsxs(s.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:n.label}),n.node]},n.label))})}function Pt({items:t}){const n=Array.isArray(t)?t.filter(a=>a?.value):[];return n.length?e.jsx(s.Space,{wrap:!0,size:[8,8],children:n.map(a=>e.jsxs(s.Tag,{color:"blue",children:[a.label,": ",a.value]},a.label))}):null}function $a({title:t,subtitle:n,printRef:a,exportRows:r,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:x,chartContent:y,reportTitle:u,reportExtra:S,children:j,fileBaseName:w="attendance"}){const m=ln.useReactToPrint({content:()=>a?.current});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsxs("div",{children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:t}),n?e.jsx(s.Typography.Text,{type:"secondary",style:{display:"block",marginTop:4},children:n}):null]}),extra:e.jsx(Nt,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>am({rows:r,columns:o,fileName:`${w}.csv`}),onPrint:m,onDownload:()=>sm({value:r,fileName:`${w}.json`}),onRefresh:l}),children:c}),e.jsx(jo,{summary:x}),y===!1?null:y||e.jsx(on,{summary:x}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:u}),extra:S,children:j})]})}const im=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function om({rows:t,loading:n,sunday:a,holiday:r,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(y,u)=>{const S=(Array.isArray(t)?t:[]).map((j,w)=>(j?.student_session_id??j?.student_id??j?.id??w)===y?{...j,...u}:j);l?.(S)},x=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(y,u,S)=>S+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:(y,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(y,u,S)=>{const j=u?.student_session_id??u?.student_id??u?.id??S;return e.jsx(s.Select,{size:"small",style:{width:"100%"},options:im,value:String(y??"1"),onChange:w=>c(j,{attendence_type_id:w})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:y=>y?ae(y).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:(y,u)=>e.jsx(s.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(X.ClockCircleOutlined,{}),onClick:()=>d?.(u),children:"E.L"})}],[d,t]);return a?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(s.Table,{bordered:!0,size:"small",rowKey:(y,u)=>String(y?.student_session_id??y?.student_id??y?.id??u),columns:x,dataSource:Array.isArray(t)?t:[],loading:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function lm({rows:t,loading:n,sunday:a,holiday:r,holidayTitle:o}){const l=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,x)=>x+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=>Bs(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 a?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(s.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:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function dm({data:t,loading:n,onViewStudent:a}){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),x=i.useMemo(()=>{const y=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,S)=>e.jsx(s.Button,{type:"link",style:{padding:0},onClick:()=>a?.(S),children:S?.student_name??S?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{y.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(S,j)=>{const m=j?.[`${j?.student_id}_${o.indexOf(j)}`]?.[u]??{},h=m?.attendance_date,g=l.find(I=>I?.date===h);return d.includes(h)?vr("sunday","W"):g?vr("holiday","H"):Bs(m?.attendence_type_id)}})}),y.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,S)=>{let j=0,w=0,m=0;return[...new Array(c).keys()].forEach(h=>{const g=S?.[`${S?.student_id}_${o.indexOf(S)}`]?.[h]??{},I=String(g?.attendence_type_id??"");I==="1"&&(j+=1),I==="4"&&(w+=1),I==="3"&&(m+=1)}),e.jsxs("span",{children:["P: ",j," A: ",w," L: ",m]})}}),y},[l,a,o,d,c]);return e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(y,u)=>String(y?.student_id??u),columns:x,dataSource:o,loading:n,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(s.Empty,{description:"No monthly report found"})}})}function cm({open:t,onClose:n,loading:a,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,x)=>Bs(x?.attendence_type_id??x?.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(s.Modal,{open:t,onCancel:n,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(c,x)=>String(c?.attendance_date??x),columns:d,dataSource:l,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function um({open:t,onClose:n,onSubmit:a,loading:r}){const[o,l]=s.Modal.useModal(),[d,c]=i.useState(null),[x,y]=i.useState(""),u=async()=>{if(!d){await o.warning({title:"Select time"});return}await a?.({outtime:d.format("h:mm a"),message:x}),c(null),y("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(s.Modal,{title:"Emergency Leave",open:t,onCancel:n,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(s.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(s.Input.TextArea,{rows:4,value:x,onChange:S=>y(S.target.value)})]})]})})]})}const vo=t=>tm(t),ci=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n.reduce((a,r)=>({present:a.present+Number(r?.present??r?.Present??r?.total_present??0),absent:a.absent+Number(r?.absent??r?.Absent??r?.total_absent??0),late:a.late+Number(r?.late??r?.Late??0),leave:a.leave+Number(r?.leave??r?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(n?.present??n?.Present??n?.total_present??0),absent:Number(n?.absent??n?.Absent??n?.total_absent??0),late:Number(n?.late??n?.Late??0),leave:Number(n?.leave??n?.Leave??0)}};function pm({token:t}){const{data:n}=G(t?[_t.dashboard.monthlyGraph,t]:null,([l,d])=>Ot(l,d)),{data:a}=G(t?[_t.dashboard.weeklyGraph,t]:null,([l,d])=>Ot(l,d)),r=i.useMemo(()=>ci(n),[n]),o=i.useMemo(()=>ci(a),[a]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(s.Card,{children:[e.jsx(s.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(s.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(jo,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(on,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(on,{summary:o,title:"Weekly Attendance Chart"})]})]})}const cs=_t.studentAttendance,mm={width:"100%",height:40};function ym({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(""),[m,h]=i.useState(ae()),[g,I]=i.useState(0),[R,D]=i.useState([]),[C,f]=i.useState(!1),[p,b]=i.useState(null),[A,O]=i.useState(!1),[L,U]=i.useState(!1),v=Fa(t),M=Na(a,t),P=i.useMemo(()=>!a||!d||g===0?null:On(cs.list,{cID:a,sID:d,batch_id:u,date:m.format("YYYY-MM-DD")}),[u,a,m,g,d]),{data:N,isLoading:E,mutate:F}=G(t&&P?[P,t]:null,([W,Z])=>Ot(W,Z));i.useEffect(()=>{D(bo(N,"student"))},[N]);const q=N?.data?.data??N?.data??N??{},z=!!q?.sunday,k=!!q?.holiday?.holiday,T=q?.holiday?.title??"",$=i.useMemo(()=>vo(R),[R]),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"}],[]),Y=async()=>{if(R.length)try{U(!0),await Qp(cs.save,{attendenceData:R,date:m.format("YYYY-MM-DD"),holiday:C?"YES":"NO"},t),_.success("Student attendance saved."),F?.()}catch(W){_.error(W?.message??"Failed to save attendance.")}finally{U(!1)}},ne=async({outtime:W,message:Z})=>{if(p?.attendence_id)try{O(!0),await Xp(cs.emergencyLeave,{outtime:W,message:Z,id:p.attendence_id},t),_.success("Emergency leave updated."),b(null),F?.()}catch(se){_.error(se?.message??"Failed to update emergency leave.")}finally{O(!1)}},H=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(ee,{options:v.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:W=>{r(W?.value??""),l(W?.label??""),c(""),y(""),S(""),w("")},required:!0}),e.jsx(ee,{options:M.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:W=>{c(W?.value??""),y(W?.label??""),S(""),w("")},required:!0},`section-${a}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{value:m,onChange:W=>W&&h(W),style:mm,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"button",value:"Search",color:"primary",onClick:()=>I(W=>W+1)})})]}),e.jsx(Pt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:m.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{}),e.jsx($a,{title:"Student Attendance",printRef:n,exportRows:R,exportColumns:B,onRefresh:()=>F?.(),filterSection:H,summary:$,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{size:"small",type:C?"primary":"default",onClick:()=>f(W=>!W),children:C?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"primary",onClick:Y,loading:L,disabled:!R.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(wt,{}),e.jsx(s.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(s.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Pt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:m.format("DD-MM-YYYY")}]})})]}),e.jsx(om,{rows:R,loading:E,sunday:z,holiday:k,holidayTitle:T,onChangeRows:D,onEmergency:b})]})}),e.jsx(um,{open:!!p,onClose:()=>b(null),onSubmit:ne,loading:A})]})}const fm=_t.dailyAttendance,hm={width:"100%",height:40};function gm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(ae()),[m,h]=i.useState(0),g=Fa(t),I=Na(a,t),R=i.useMemo(()=>!a||!d||m===0?null:On(fm.list,{cID:a,sID:d,batch_id:u,date:j.format("YYYY-MM-DD")}),[u,a,j,m,d]),{data:D,isLoading:C,mutate:f}=G(t&&R?[R,t]:null,([P,N])=>Ot(P,N)),p=i.useMemo(()=>bo(D,"student"),[D]),b=D?.data?.data??D?.data??D??{},A=!!b?.sunday,O=!!b?.holiday?.holiday,L=b?.holiday?.title??"",U=i.useMemo(()=>vo(p),[p]),v=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"}],[]),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(ee,{options:g.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:P=>{r(P?.value??""),l(P?.label??""),c(""),y(""),S(""),setBatchLabel("")},required:!0}),e.jsx(ee,{options:I.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:P=>{c(P?.value??""),y(P?.label??""),S(""),setBatchLabel("")},required:!0},`section-${a}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{value:j,onChange:P=>P&&w(P),style:hm,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"button",value:"Search",color:"primary",onClick:()=>h(P=>P+1)})})]}),e.jsx(Pt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:j.format("DD-MM-YYYY")}]})]});return e.jsx($a,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:n,exportRows:p,exportColumns:v,onRefresh:()=>f?.(),filterSection:M,summary:U,chartContent:e.jsx(on,{summary:U,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(wt,{}),e.jsx(Pt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:j.format("DD-MM-YYYY")}]})]}),e.jsx(lm,{rows:p,loading:C,sunday:A,holiday:O,holidayTitle:L})]})})}const ui=_t.monthlyReport,xm=t=>{const n=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],a=Number(t?.totalDaysMonth??0),r={present:0,absent:0,late:0,leave:0};return n.forEach((o,l)=>{[...new Array(a).keys()].forEach(d=>{const c=o?.[`${o?.student_id}_${l}`]?.[d]??{},x=String(c?.attendence_type_id??"");x==="1"&&(r.present+=1),x==="4"&&(r.absent+=1),x==="3"&&(r.late+=1),x==="2"&&(r.leave+=1)})}),r},bm=t=>{const n=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],a=Number(t?.totalDaysMonth??0);return n.map((r,o)=>{let l=0,d=0,c=0;return[...new Array(a).keys()].forEach(x=>{const y=r?.[`${r?.student_id}_${o}`]?.[x]??{},u=String(y?.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 Sm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(""),[m,h]=i.useState(String(new Date().getFullYear())),[g,I]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[R,D]=i.useState(0),[C,f]=i.useState(null),p=Fa(t),b=Na(a,t),A=i.useMemo(()=>Ms(Number(m)),[m]),O=i.useMemo(()=>Es(10),[]),L=i.useMemo(()=>!a||!d||!m||!g||R===0?null:On(ui.table,{session:li(),class_id:a,section_id:d,year:m,month:g,batch_id:u}),[u,a,g,R,d,m]),{data:U,isLoading:v,mutate:M}=G(t&&L?[L,t]:null,([$,B])=>Ot($,B)),P=U?.data?.data??U?.data??U??{},N=i.useMemo(()=>xm(P),[P]),E=i.useMemo(()=>bm(P),[P]),F=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"}],[]),q=i.useMemo(()=>C?.student_id?On(ui.byStudent,{student_id:C.student_id,month:g,year:m,session:li()}):null,[g,C,m]),{data:z,isLoading:k}=G(t&&q?[q,t]:null,([$,B])=>Ot($,B)),T=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(ee,{options:p.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{r($?.value??""),l($?.label??""),c(""),y(""),S(""),w("")},required:!0}),e.jsx(ee,{options:b.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{c($?.value??""),y($?.label??""),S(""),w("")},required:!0},`section-${a}`),e.jsx(ee,{options:O,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:O.find($=>String($?.value)===String(m))??null,onChange:$=>h(String($?.value??"")),required:!0}),e.jsx(ee,{options:A,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:A.find($=>String($?.value)===String(g))??null,onChange:$=>I(String($?.value??"").padStart(2,"0")),required:!0},`month-${m}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"button",value:"Search",color:"primary",onClick:()=>D($=>$+1)})})]}),e.jsx(Pt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Month",value:A.find($=>String($?.value)===String(g))?.label??g},{label:"Year",value:m}]}),e.jsx(rm,{})]});return e.jsxs(e.Fragment,{children:[e.jsx($a,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:n,exportRows:E,exportColumns:F,onRefresh:()=>M?.(),filterSection:T,summary:N,chartContent:e.jsx(on,{summary:N,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(wt,{}),e.jsx(Pt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Month",value:A.find($=>String($?.value)===String(g))?.label??g},{label:"Year",value:m}]})]}),e.jsx(dm,{data:P,loading:v,onViewStudent:f})]})}),e.jsx(cm,{open:!!C,onClose:()=>f(null),loading:k,data:z,studentName:C?.student_name??C?.full_name})]})}const jm=_t.yearlyReport,vm=t=>{const n=t?.data?.data??t?.data??t??{};return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:Array.isArray(n?.students)?n.students:Array.isArray(n?.report)?n.report:[]},_m=t=>(Array.isArray(t)?t:[]).reduce((n,a)=>({present:n.present+Number(a?.singleStudentPresentData??a?.present??0),absent:n.absent+Number(a?.singleStudentAbsentData??a?.absent??0),late:n.late+Number(a?.late??0),leave:n.leave+Number(a?.leave??0)}),{present:0,absent:0,late:0,leave:0});function wm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(""),[m,h]=i.useState(""),[g,I]=i.useState(""),[R,D]=i.useState(0),C=Fa(t),f=Na(a,t),p=nm(t),b=i.useMemo(()=>!a||!d||R===0?null:On(jm.table,{class_id:a,section_id:d,session_id:u,batch_id:m}),[m,a,R,d,u]),{data:A,isLoading:O,mutate:L}=G(t&&b?[b,t]:null,([E,F])=>Ot(E,F)),U=i.useMemo(()=>vm(A),[A]),v=i.useMemo(()=>_m(U),[U]),M=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),P=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(E,F,q)=>q+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}],[]),N=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(ee,{options:C.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{r(E?.value??""),l(E?.label??""),c(""),y(""),h(""),I("")},required:!0}),e.jsx(ee,{options:f.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{c(E?.value??""),y(E?.label??""),h(""),I("")},required:!0},`section-${a}`),e.jsx(ee,{options:p.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{S(E?.value??""),w(E?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"button",value:"Search",color:"primary",onClick:()=>D(E=>E+1)})})]}),e.jsx(Pt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Session",value:j}]})]});return e.jsx($a,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:n,exportRows:U,exportColumns:M,onRefresh:()=>L?.(),filterSection:N,summary:v,chartContent:e.jsx(on,{summary:v,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(wt,{}),e.jsx(Pt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Session",value:j}]})]}),e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(E,F)=>String(E?.student_id??E?.id??F),columns:P,dataSource:U,loading:O,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}function Cm(){return null}const Ua=t=>t??localStorage.getItem("authToken")??"",Am=(t,n)=>{const a=String(t??""),r=String(n);return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},_o=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",we={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"}},Tm=()=>Am(nt(),we.uploadNotes),Rm=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Ua(r))},mt=async(t,n,a,{includeSession:r=!1}={})=>{const o=n instanceof FormData?n:new FormData;return r&&!o.has("session_id")&&o.append("session_id",_o()),Ye(t,o,Ua(a))},Et=async(t,n,a,{includeSession:r=!1}={})=>{const o=n instanceof FormData?n:new FormData;return r&&!o.has("session_id")&&o.append("session_id",_o()),pt(t,o,Ua(a))},Mt=async(t,n,a)=>at(t,n,Ua(a)),ja=we.master.sections,zn=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>Rm({baseUrl:l,page:d,perPage:c},x)),Im=({token:t,page:n=1,perPage:a=10})=>zn({token:t,baseUrl:ja.table,page:n,perPage:a}),Dm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function km({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),{data:x,isLoading:y,mutate:u}=Im({token:t,page:n.page,perPage:n.perPage}),S=i.useMemo(()=>Dm(x),[x]),j=i.useMemo(()=>x?.pagination?.total_rows??x?.pagination?.total??S.length??0,[x,S]),w=async R=>{R.preventDefault();const D=new FormData(R.target);try{await mt(ja.add,D,t),_.success("Success! Added new item.",{duration:1e3}),R.target.reset(),u()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},m=async R=>{try{await Mt(ja.remove,R,t),_.success("Success! Deleted item.",{duration:1e3}),u()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to delete the item.",{duration:1500})}},h=R=>{d(R),o(!0),c.setFieldsValue({section:R?.section??""})},g=async R=>{const D=new FormData;D.append("id",String(l?.id??"")),D.append("section",R.section??"");try{await Et(ja.edit,D,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})}},I=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(R,D)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(D)}),e.jsx(s.Popconfirm,{title:"Delete this section?",onConfirm:()=>m(D?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Section",open:r,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(s.Form,{form:c,layout:"vertical",onFinish:g,children:[e.jsx(s.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(s.Input,{placeholder:"Section Name"})}),e.jsxs(s.Space,{children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.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(J,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(ce,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(s.Space,{}),children:e.jsx(s.Table,{rowKey:R=>R.id,columns:I,dataSource:S,loading:y,pagination:{current:n.page,pageSize:n.perPage,total:j,showSizeChanger:!0,onChange:(R,D)=>a({page:R,perPage:D})}})})]})}function Om({token:t}){return e.jsx(km,{token:t})}const Tn=we.master.classes,Pm=({token:t,page:n=1,perPage:a=10})=>zn({token:t,baseUrl:Tn.table,page:n,perPage:a}),Em=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Mm=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function Fm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[x]=s.Form.useForm(),{data:y}=G(t?[we.master.sections.list,t]:null,([A,O])=>Q(A,O)),u=i.useMemo(()=>Mm(y),[y]),S=i.useMemo(()=>u.map(A=>({label:A.label??A.section??String(A.value??""),value:String(A.value??A.id??"")})),[u]),{data:j,isLoading:w,mutate:m}=Pm({token:t,page:n.page,perPage:n.perPage}),h=i.useMemo(()=>Em(j),[j]),g=i.useMemo(()=>j?.pagination?.total_rows??j?.pagination?.total??h.length??0,[j,h]),{data:I}=G(t&&l?[`${Tn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([A,O])=>Q(A,O)),R=i.useMemo(()=>{const A=I?.data??I;return Array.isArray(A)?A:Array.isArray(A?.data)?A.data:A?[A]:[]},[I]),D=A=>{const O=A?.id??A?.class_id;O&&(d(O),o(!0))};i.useEffect(()=>{if(!r||!R.length)return;const A=R[0],O=R.map(v=>v?.section_id??v?.fk_sectionId??v?.sectionId??v?.section).filter(v=>v!=null&&String(v).trim()!=="").map(v=>String(v)),L=Array.isArray(A?.section_ids)?A.section_ids.map(v=>String(v)):typeof A?.section_ids=="string"?A.section_ids.split(",").map(v=>v.trim()).filter(Boolean):Array.isArray(A?.section)?A.section.map(v=>String(v)):[],U=O.length?O:L;x.setFieldsValue({name:A?.class??A?.name??"",section:U})},[r,R,x]);const C=async A=>{const O=new FormData;O.append("name",A.name??""),(A.section??[]).forEach(L=>O.append("section[]",String(L)));try{await mt(Tn.add,O,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),m()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},f=async A=>{const O=new FormData;O.append("id",String(l??"")),O.append("name",A.name??""),(A.section??[]).forEach(L=>O.append("section[]",String(L)));try{await Et(Tn.edit,O,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),m()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to update the item.",{duration:1500})}},p=async A=>{try{await Mt(Tn.remove,A,t),_.success("Success! Deleted item.",{duration:1e3}),m()}catch(O){_.error(O?.response?.data?.msg??O?.message??"Failed to delete the item.",{duration:1500})}},b=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(A,O)=>A??O?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:A=>A??""},{title:"Actions",key:"actions",width:120,render:(A,O)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(O)}),e.jsx(s.Popconfirm,{title:"Delete this class?",onConfirm:()=>p(O?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Class",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(s.Form,{form:x,layout:"vertical",onFinish:f,children:[e.jsx(s.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(s.Input,{placeholder:"Class"})}),e.jsx(s.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(s.Checkbox.Group,{options:S})}),e.jsxs(s.Space,{children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(s.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(s.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(s.Input,{placeholder:"Class"})}),e.jsx(s.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(s.Checkbox.Group,{options:S})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(s.Table,{rowKey:A=>A.id,columns:b,dataSource:h,loading:w,pagination:{current:n.page,pageSize:n.perPage,total:g,showSizeChanger:!0,onChange:(A,O)=>a({page:A,perPage:O})}})})]})}function Nm({token:t}){return e.jsx(Fm,{token:t})}const Rn=we.master.subjects,$m=({token:t,page:n=1,perPage:a=10})=>zn({token:t,baseUrl:Rn.table,page:n,perPage:a}),Um=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},pi=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],mi=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function Bm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[x]=s.Form.useForm(),{data:y,isLoading:u,mutate:S}=$m({token:t,page:n.page,perPage:n.perPage}),j=i.useMemo(()=>Um(y),[y]),w=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??j.length??0,[y,j]),{data:m}=G(t&&l?[`${Rn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,p])=>Q(f,p)),h=i.useMemo(()=>{const f=m?.data??m;return Array.isArray(f)?f[0]:f??null},[m]);i.useEffect(()=>{r&&h&&x.setFieldsValue({name:h?.name??"",subject_type:h?.subject_type??h?.type??"",type:"",subject_types:Array.isArray(h?.subject_types)?h.subject_types:typeof h?.subject_types=="string"?h.subject_types.split(",").map(f=>f.trim()).filter(Boolean):[],code:h?.code??""})},[r,h,x]);const g=async f=>{const p=f?.type??f?.subject_type??"",b={name:f?.name??"",subject_type:p,type:p,subject_types:Array.isArray(f?.subject_types)?f.subject_types:[],code:f?.code??""};try{await Ye(Rn.add,b,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),S()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},I=async f=>{const p=new FormData,b=f?.type??f?.subject_type??"";p.append("id",String(l??"")),p.append("name",f.name??""),p.append("subject_type",f.subject_type??""),p.append("subject_type",b),p.append("type",b),p.append("code",f.code??"");try{await Et(Rn.edit,p,t),_.success("Success! Updated item.",{duration:1e3}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),S()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},R=async f=>{try{await Mt(Rn.remove,f,t),_.success("Success! Deleted item.",{duration:1e3}),S()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete the item.",{duration:1500})}},D=f=>{const p=f?.id;p&&(d(p),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:(f,p)=>{const b=[],A=p?.subject_types;Array.isArray(A)?A.forEach(M=>{const P=String(M??"").trim();P&&b.push(P)}):typeof A=="string"&&A.split(",").map(M=>M.trim()).filter(Boolean).forEach(M=>b.push(M));const O=["yes","1","true"].includes(String(p?.is_practical??"").toLowerCase()),L=["yes","1","true"].includes(String(p?.is_theory??"").toLowerCase());O&&b.push("Practical"),L&&b.push("Theory");const U=b.map(M=>String(M??"").trim()).filter(Boolean).map(M=>M.toLowerCase()==="practical"?"Practical":M.toLowerCase()==="theory"?"Theory":M),v=Array.from(new Set(U));return v.length?v.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(f,p)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(p)}),e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>R(p?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Subject",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(s.Form,{form:x,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(J,{placeholder:"Subject Name"})}),e.jsx(s.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(s.Radio.Group,{options:mi})}),e.jsx(s.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(s.Checkbox.Group,{options:pi})}),e.jsx(s.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(J,{placeholder:"Subject Code"})}),e.jsxs(s.Space,{children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(J,{placeholder:"Subject Name"})}),e.jsx(s.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(s.Radio.Group,{options:mi})}),e.jsx(s.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(s.Checkbox.Group,{options:pi})}),e.jsx(s.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(J,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(s.Table,{rowKey:f=>f.id,columns:C,dataSource:j,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:w,showSizeChanger:!0,onChange:(f,p)=>a({page:f,perPage:p})}})})]})}function Lm({token:t}){return e.jsx(Bm,{token:t})}const In=we.master.holidays,qm=({token:t,page:n=1,perPage:a=10})=>zn({token:t,baseUrl:In.table,page:n,perPage:a}),zm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},sa={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ym({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[x]=s.Form.useForm(),{data:y,isLoading:u,mutate:S}=qm({token:t,page:n.page,perPage:n.perPage}),j=i.useMemo(()=>zm(y),[y]),w=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??j.length??0,[y,j]),{data:m}=G(t&&l?[`${In.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,p])=>Q(f,p)),h=i.useMemo(()=>{const f=m?.data??m;return Array.isArray(f)?f[0]:f??null},[m]);i.useEffect(()=>{r&&h&&x.setFieldsValue({title:h?.holiday_title??"",description:h?.holiday_description??"",from:h?.start_date?ae(h.start_date):null,to:h?.end_date?ae(h.end_date):null})},[r,h,x]);const g=async f=>{const p=new FormData;p.append("title",f.title??""),p.append("description",f.description??""),p.append("from",f.from?ae(f.from).format("YYYY-MM-DD"):""),p.append("to",f.to?ae(f.to).format("YYYY-MM-DD"):"");try{await mt(In.add,p,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),S()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to add the new item.",{duration:1500})}},I=async f=>{const p=new FormData;p.append("id",String(l??"")),p.append("title",f.title??""),p.append("description",f.description??""),p.append("from",f.from?ae(f.from).format("YYYY-MM-DD"):""),p.append("to",f.to?ae(f.to).format("YYYY-MM-DD"):"");try{await Et(In.edit,p,t,{includeSession:!0}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),S()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to update the item.",{duration:1500})}},R=async f=>{try{await Mt(In.remove,f,t),_.success("Success! Deleted item.",{duration:1e3}),S()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete the item.",{duration:1500})}},D=f=>{const p=f?.id;p&&(d(p),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:(f,p)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(p)}),e.jsx(s.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>R(p?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Holiday",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(s.Form,{form:x,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(J,{placeholder:"Holiday Title"})}),e.jsx(s.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(J,{placeholder:"Holiday Description"})}),e.jsx(s.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:sa})}),e.jsx(s.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:sa})}),e.jsxs(s.Space,{children:[e.jsx(ce,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(J,{placeholder:"Holiday Title"})}),e.jsx(s.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(kt,{placeholder:"Holiday Description"})}),e.jsx(s.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:sa})}),e.jsx(s.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:sa})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(s.Table,{rowKey:f=>f.id,columns:C,dataSource:j,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:w,showSizeChanger:!0,onChange:(f,p)=>a({page:f,perPage:p})}})})]})}function Wm({token:t}){return e.jsx(Ym,{token:t})}const va=we.assignSubjects,Vm=({token:t,page:n=1,perPage:a=50})=>zn({token:t,baseUrl:va.list,page:n,perPage:a}),yi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Hm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Km({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState(!1),[y,u]=i.useState(!1),[S,j]=i.useState(null),[w,m]=i.useState([]),{data:h}=G(t?[we.master.classes.dropdown,t]:null,([P,N])=>Q(P,N)),{data:g}=G(t?[we.master.subjects.dropdown,t]:null,([P,N])=>Q(P,N)),I=i.useMemo(()=>yi(h),[h]),R=i.useMemo(()=>yi(g),[g]),D=i.useMemo(()=>R.map(P=>({label:P.label??P.subject??String(P.value??""),value:P.value??P.id})),[R]),{data:C,isLoading:f,mutate:p}=Vm({token:t,page:n.page,perPage:n.perPage}),b=i.useMemo(()=>Hm(C),[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??b.length??0,[C,b]),{data:O}=G(t&&S?[`${va.editByClass}?class_id=${encodeURIComponent(String(S))}`,t]:null,([P,N])=>Q(P,N));i.useEffect(()=>{if(!y)return;const P=O?.data??O,N=Array.isArray(P)?P:Array.isArray(P?.data)?P.data:[];m(N.map(E=>E.subject_id).filter(Boolean))},[y,O]);const L=async P=>{if(P.preventDefault(),!r?.value){_.error("Please select class",{duration:1200});return}if(!l.length){_.error("Please select subjects",{duration:1200});return}const N=new FormData;N.append("class_id",String(r.value)),l.forEach(E=>N.append("subject[]",String(E)));try{x(!0),await Et(va.assign,N,t),_.success("Success! Updated item.",{duration:1e3}),o(null),d([]),p()}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to update the item.",{duration:1500})}finally{x(!1)}},U=P=>{P&&(j(P),u(!0))},v=async()=>{if(!S)return;if(!w.length){_.error("Please select subjects",{duration:1200});return}const P=new FormData;P.append("class_id",String(S)),w.forEach(N=>P.append("subject[]",String(N)));try{await Et(va.update,P,t),_.success("Success! Updated item.",{duration:1e3}),u(!1),j(null),p()}catch(N){_.error(N?.response?.data?.msg??N?.message??"Failed to update the item.",{duration:1500})}},M=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(P,N)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(N?.subject_name??P??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(P,N)=>e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>U(N?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Assigned Subjects",open:y,onClose:()=>{u(!1),j(null)},width:520,extra:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>u(!1),children:"Cancel"}),e.jsx(s.Button,{type:"primary",onClick:v,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:I.find(P=>String(P.value)===String(S))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(s.Checkbox.Group,{options:D,value:w,onChange:m})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),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(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:P=>o(P??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(s.Checkbox.Group,{options:D,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(s.Table,{rowKey:P=>P.id,columns:M,dataSource:b,loading:f,pagination:{current:n.page,pageSize:n.perPage,total:A,showSizeChanger:!0,onChange:(P,N)=>a({page:P,perPage:N})}})})]})}function Gm({token:t}){return e.jsx(Km,{token:t})}const tn=we.assignByClass,wo=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[]},jn=t=>wo(t),Jm=t=>wo(t),vn=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Qm({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,x]=i.useState("No"),[y,u]=i.useState([]),[S,j]=i.useState([]),[w,m]=i.useState(null),[h,g]=i.useState(null),[I,R]=i.useState(!1),[D,C]=i.useState(""),{data:f}=G(t?[tn.teacherDropdown,t]:null,([ie,V])=>Q(ie,V)),{data:p}=G(t?[we.master.classes.dropdown,t]:null,([ie,V])=>Q(ie,V)),{data:b}=G(t&&h?[h,t]:null,([ie,V])=>Q(ie,V)),{data:A}=G(t&&w?[w,t]:null,([ie,V])=>Q(ie,V)),O=i.useMemo(()=>jn(f),[f]),L=i.useMemo(()=>jn(p),[p]),U=i.useMemo(()=>jn(b),[b]),v=i.useMemo(()=>jn(A),[A]),{data:M}=G(t&&n&&r&&l?[`${tn.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(n))}&class_id=${encodeURIComponent(String(r))}§ion_id=${encodeURIComponent(String(l))}`,t]:null,([ie,V])=>Q(ie,V)),P=M?.data??M??null;i.useEffect(()=>{P&&(u(Array.isArray(P?.subject_ids)?P.subject_ids:[]),x(P?.isClassTeacher||"No"),j([]))},[P]);const{data:N}=G(t?[tn.classWithSection,t]:null,([ie,V])=>Q(ie,V)),E=i.useMemo(()=>jn(N),[N]),[F,q]=i.useState(null),[z,k]=i.useState({page:1,perPage:25});i.useEffect(()=>{F||E?.[0]&&q(`${E[0].class_id}val${E[0].section_id}`)},[E,F]);const T=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),$=i.useMemo(()=>{if(!F)return null;const[ie,V]=String(F).split("val");if(!ie||!V)return null;const oe=z.page??1,Ce=z.perPage??25;return`${tn.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(oe))}&per_page=${encodeURIComponent(String(Ce))}&session_id=${encodeURIComponent(String(T))}&class_id=${encodeURIComponent(String(ie))}§ion_id=${encodeURIComponent(String(V))}`},[F,z.page,z.perPage,T]),{data:B,isLoading:Y,mutate:ne}=G(t&&$?[$,t]:null,([ie,V])=>Q(ie,V),{revalidateOnFocus:!1}),H=i.useMemo(()=>Jm(B),[B]),W=i.useMemo(()=>{const ie=B?.pagination??B?.data?.pagination??B?.data?.data?.pagination;return ie?.total_rows??ie?.total??H.length??0},[B,H]),Z=async ie=>{if(ie.preventDefault(),C(""),!n||!r||!l){_.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(y)||y.length===0){C("error"),_.error("Please Select Subject",{duration:1200});return}const V=new FormData;V.append("teacher_id",String(n)),V.append("class_id",String(r)),V.append("section_id",String(l)),V.append("isClassTeacher",String(c??"No")),vn(y).forEach(oe=>V.append("subject_ids[]",String(oe))),vn(S).forEach(oe=>V.append("delete_subject[]",String(oe)));try{await mt(tn.assignClassToTeacher,V,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),C(""),ne()}catch(oe){_.error(oe?.response?.data?.msg??oe?.message??"Failed to add the new item.",{duration:1500})}},se=async ie=>{try{await Mt(tn.deleteTeacherSub,ie,t),_.success("Success! Deleted item.",{duration:1e3}),ne()}catch(V){_.error(V?.response?.data?.msg??V?.message??"Failed to delete the item.",{duration:1500})}},pe=ie=>{const V=Array.isArray(ie?.child)?ie.child:[],oe=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Ce,Oe)=>e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>se(Oe?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(s.Table,{columns:oe,bordered:!0,size:"small",dataSource:V,pagination:!1,rowKey:Ce=>Ce.id})})},ve=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(ie,V)=>e.jsxs("div",{children:[V.teacher_name,V.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],re=i.useMemo(()=>(E??[]).map(ie=>({label:ie.label??`${ie.class_name??""} ${ie.section_name??""}`.trim(),key:`${ie.class_id}val${ie.section_id}`,children:e.jsx(s.Table,{size:"small",columns:ve,bordered:!0,dataSource:Array.isArray(H)?H:[],loading:Y,rowKey:V=>V.id,expandable:{expandedRowRender:pe},pagination:{current:z.page,pageSize:z.perPage,total:W,showSizeChanger:!0,onChange:(V,oe)=>k({page:V,perPage:oe})}})})),[E,z.page,z.perPage,H,Y,W]);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(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:Z,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:O.find(ie=>String(ie.value)===String(n))??null,onChange:ie=>a(ie?.value??null)}),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:L.find(ie=>String(ie.value)===String(r))??null,onChange:ie=>{const V=ie?.value??null;o(V),d(null),m(V?`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(V))}`:null),g(V?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(V))}`:null),R(oe=>!oe)}}),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:U.find(ie=>String(ie.value)===String(l))??null,onChange:ie=>d(ie?.value??null)},`section_${I}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const ie=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(ee,{style:{width:"100%"},options:ie,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:ie.find(V=>String(V.value)===String(c??"No"))??ie[1],onChange:V=>x(V?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(ee,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:v,value:(v??[]).filter(ie=>vn(y).some(V=>String(V)===String(ie.value))),onChange:(ie,V)=>{const Ce=(Array.isArray(ie)?ie:[]).map(Ee=>Ee?.value).filter(Ee=>Ee!=null&&Ee!=="");u(Ce);const Oe=Array.isArray(P?.subject_ids)?P.subject_ids.map(String):[],Pe=V?.removedValue?.value,Ne=V?.option?.value;(V?.action==="remove-value"||V?.action==="pop-value")&&Pe!=null&&Oe.includes(String(Pe))&&j(Ee=>Array.from(new Set([...vn(Ee).map(String),String(Pe)]))),V?.action==="select-option"&&Ne!=null&&Oe.includes(String(Ne))&&j(Ee=>vn(Ee).filter(Ve=>String(Ve)!==String(Ne)))}},`subjects_${I}`),D?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(ce,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(s.Tabs,{activeKey:F??void 0,onChange:ie=>{q(ie),k(V=>({...V,page:1}))},items:re,type:"card",size:"small"})})]})]})}function Xm({token:t}){return e.jsx(Qm,{token:t})}const _n=we.timeGroup,Zm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},It={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function ra(t){if(!t)return null;const n=ae(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return n.isValid()?n:null}function Dt(t){return t?ae(t).format("h:mm a"):""}function ey({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[x]=s.Form.useForm(),y=`${_n.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:u,isLoading:S,mutate:j}=G(t?[y,t]:null,([p,b])=>Q(p,b)),w=i.useMemo(()=>Zm(u),[u]),m=i.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??w.length??0,[u,w]),{data:h}=G(t&&l?[`${_n.show}?id=${encodeURIComponent(String(l))}`,t]:null,([p,b])=>Q(p,b)),g=i.useMemo(()=>{const p=h?.data??h;return Array.isArray(p)?p[0]:p??null},[h]);i.useEffect(()=>{r&&g&&x.setFieldsValue({title:g?.title??"",start_time_from:ra(g?.start_time_from),start_time_to:ra(g?.start_time_to),end_time_from:ra(g?.end_time_from),end_time_to:ra(g?.end_time_to)})},[r,g,x]);const I=async p=>{const b=new FormData;b.append("title",p.title??""),b.append("start_time_from",Dt(p.start_time_from)),b.append("start_time_to",Dt(p.start_time_to)),b.append("end_time_from",Dt(p.end_time_from)),b.append("end_time_to",Dt(p.end_time_to));try{await mt(_n.add,b,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),j()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},R=async p=>{const b=new FormData;b.append("id",String(l??"")),b.append("title",p.title??""),b.append("start_time_from",Dt(p.start_time_from)),b.append("start_time_to",Dt(p.start_time_to)),b.append("end_time_from",Dt(p.end_time_from)),b.append("end_time_to",Dt(p.end_time_to));try{await Et(_n.edit,b,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),j()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},D=async p=>{try{await Mt(_n.remove,p,t),_.success("Success! Deleted item.",{duration:1e3}),j()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to delete the item.",{duration:1500})}},C=p=>{p?.id&&(d(p.id),o(!0))},f=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:(p,b)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>C(b)}),e.jsx(s.Popconfirm,{title:"Delete this time group?",onConfirm:()=>D(b?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Time Group",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(s.Form,{form:x,layout:"vertical",onFinish:R,children:[e.jsx(s.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:It})}),e.jsx(s.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:It})}),e.jsx(s.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:It})}),e.jsx(s.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:It})}),e.jsxs(s.Space,{children:[e.jsx(ce,{type:"submit",value:"Submit",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:I,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:It})}),e.jsx(s.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:It})}),e.jsx(s.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:It})}),e.jsx(s.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:It})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(s.Table,{rowKey:p=>p.id,columns:f,dataSource:w,loading:S,pagination:{current:n.page,pageSize:n.perPage,total:m,showSizeChanger:!0,onChange:(p,b)=>a({page:p,perPage:b})}})})]})}function ty({token:t}){return e.jsx(ey,{token:t})}const wn=we.assignTimeGroup,ny=we.timeGroup.dropdown,ay=we.master.classes.dropdown,fi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],sy=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function ry({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState(""),[y,u]=i.useState(""),[S,j]=i.useState(null),[w,m]=i.useState(!1),[h,g]=i.useState(!1),[I,R]=i.useState(null),[D,C]=i.useState([]),[f,p]=i.useState(""),[b,A]=i.useState(""),{data:O}=G(t?[ny,t]:null,([H,W])=>Q(H,W)),{data:L}=G(t?[ay,t]:null,([H,W])=>Q(H,W)),U=i.useMemo(()=>fi(O?.data??O),[O]),v=i.useMemo(()=>fi(L),[L]),{data:M}=G(t&&S?[S,t]:null,([H,W])=>Q(H,W));i.useEffect(()=>{const H=Array.isArray(M?.data)?M.data.map(W=>W.fk_classId):[];H.length&&d(H)},[M]);const P=`${wn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:N,isLoading:E,mutate:F}=G(t?[P,t]:null,([H,W])=>Q(H,W)),q=i.useMemo(()=>sy(N),[N]),z=i.useMemo(()=>N?.pagination?.total_rows??N?.pagination?.total??q.length??0,[N,q]),{data:k}=G(t&&I?[`${wn.show}?id=${encodeURIComponent(String(I))}`,t]:null,([H,W])=>Q(H,W)),T=k?.data??k??null;i.useEffect(()=>{if(!h||!T)return;const H=Array.isArray(T?.class_ids)?T.class_ids:[];C(H);const W=Array.isArray(U)?U.find(Z=>String(Z.value)===String(T?.timegroup_id)):null;W&&A(`${W.start_time_from} -> ${W.end_time_from}`)},[h,T,U]);const $=async H=>{if(H.preventDefault(),x(""),!r?.value){_.error("Select Time Group",{duration:1200});return}if(!l.length){x("error"),_.error("Please Select Classes",{duration:1200});return}const W=new FormData;W.append("timegroup_id",String(r.value)),l.forEach(Z=>W.append("class_ids[]",String(Z)));try{await mt(wn.assign,W,t),_.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),F()}catch(Z){_.error(Z?.response?.data?.msg??Z?.message??"Failed to add the new item.",{duration:1500})}},B=async()=>{if(p(""),!I)return;if(!D.length){p("error"),_.error("Please Select Classes",{duration:1200});return}const H=new FormData;H.append("id",String(I)),H.append("timegroup_id",String(T?.timegroup_id??"")),D.forEach(W=>H.append("class_ids[]",String(W)));try{await Et(wn.assign,H,t),_.success("Success! Updated item.",{duration:1e3}),g(!1),R(null),F()}catch(W){_.error(W?.response?.data?.msg??W?.message??"Failed to update the item.",{duration:1500})}},Y=H=>{H&&(R(H),g(!0))},ne=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:(H,W)=>W?.class_names?e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>Y(W?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Assigned Time Group",open:h,onClose:()=>{g(!1),R(null)},width:520,extra:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>g(!1),children:"Cancel"}),e.jsx(s.Button,{type:"primary",onClick:B,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:U.find(H=>String(H.value)===String(T?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:b}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(s.Select,{mode:"multiple",style:{width:"100%"},status:f,value:D,placeholder:"Select Classes",onChange:H=>C(H),options:Array.isArray(v)?v:[]})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:$,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(ee,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:H=>{o(H??null),d([]),x(""),H?.value?(j(`${wn.classIdByTimeGroup}?id=${encodeURIComponent(String(H.value))}`),u(`${H.start_time_from} -> ${H.end_time_from}`)):(j(null),u("")),m(W=>!W)}}),e.jsx("div",{style:{marginTop:6},children:y})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(ee,{mode:"multiple",style:{width:"100%"},status:c,value:l,placeholder:"Select Classes",onChange:H=>d(H),options:Array.isArray(v)?v:[]},`class_${w}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(s.Table,{rowKey:H=>H.id,columns:ne,dataSource:q,loading:E,pagination:{current:n.page,pageSize:n.perPage,total:z,showSizeChanger:!0,onChange:(H,W)=>a({page:H,perPage:W})}})})]})}function iy({token:t}){return e.jsx(ry,{token:t})}const As=we.promoteStudents,oy=({token:t})=>G(t?[As.sessionDropdown,t]:null,([n,a])=>Q(n,a)),ia=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[]},ly=(t,n)=>{const a=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,r=a?.total_rows??a?.total??a?.totalItems;return Number.isFinite(Number(r))?Number(r):n};function dy({token:t}){const[n]=s.Form.useForm(),[a,r]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[x,y]=i.useState(!1),[u,S]=i.useState([]),j=i.useMemo(()=>new Set(u),[u]),[w,m]=i.useState({}),[h,g]=i.useState({}),{data:I}=G(t?[we.master.classes.dropdown,t]:null,([B,Y])=>Q(B,Y)),R=i.useMemo(()=>ia(I),[I]),D=i.useMemo(()=>o.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:C}=G(t&&D?[D,t]:null,([B,Y])=>Q(B,Y)),f=i.useMemo(()=>ia(C),[C]),p=i.useMemo(()=>d.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:b}=G(t&&p?[p,t]:null,([B,Y])=>Q(B,Y),{revalidateOnFocus:!1}),A=i.useMemo(()=>ia(b),[b]),{data:O}=oy({token:t}),L=i.useMemo(()=>ia(O),[O]),{trigger:U,data:v,isMutating:M}=Je(t?As.searchByClassSection:null,(B,{arg:Y})=>qt(B,{arg:Y},t)),P=i.useMemo(()=>{const B=v?.data?.data??v?.data??v??[];return Array.isArray(B)?B:Array.isArray(B?.data)?B.data:[]},[v]),N=i.useMemo(()=>ly(v,P.length??0),[v,P.length]),E=i.useMemo(()=>{const B=new Map;return(Array.isArray(P)?P:[]).forEach(Y=>{Y?.id!==void 0&&Y?.id!==null&&B.set(String(Y.id),Y)}),B},[P]),F=i.useCallback((B,Y)=>{const ne=String(B);g(H=>({...H,[ne]:{...H?.[ne]??{},...Y}}))},[]),q=i.useCallback((B,Y)=>{const ne=String(B),H=Y==="Leave";m(W=>({...W,[ne]:H}))},[]),z=B=>{const Y=B?.class_id?.value??B?.class_id??null,ne=B?.section_id?.value??B?.section_id??null;if(!Y||!ne){_.error("Please select Class and Section",{duration:1200});return}r(H=>({...H,page:1})),l({classId:Y,sectionId:ne}),S([]),m({}),g({})},k=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 B=u.map(W=>String(W)).map(W=>{const Z=E.get(W)??{},se=!!w?.[W],pe=h?.[W]??{},ve=String(pe.current_result??"Pass");if(se){const V=String(pe.leave_date??"");return{student_id:W,current_result:ve,next_session_status:"Leave",leave_date:V}}const re=String(pe.roll_no??Z?.roll_no??""),ie=String(pe.section_id??"");return{student_id:W,roll_no:re,section_id:ie,current_result:ve,next_session_status:"Continue"}});if(B.some(W=>W?.next_session_status==="Leave"&&!String(W?.leave_date??"").trim())){_.error("Leave date is required for Leave students.",{duration:1500});return}if(B.some(W=>W?.next_session_status==="Continue"&&!String(W?.section_id??"").trim())){_.error("Section is required for Continue students.",{duration:1500});return}const H={class_id:String(d.classId),session_id:String(d.sessionId),students:B};try{const W=await pt(As.promote,H,t);if(W?.Status&&String(W.Status)!=="success")throw new Error(W?.msg||"Failed to update");_.success("Success! Updated.",{duration:1e3});const Z=Number(W?.success_count??0)+Number(W?.leave_count??0),se=a.page===Math.ceil((Number(N)||0)/a.perPage||1),pe=Z>0&&Z===P.length&&P.length===u.length,ve=se&&pe&&a.page>1?a.page-1:a.page;r(re=>({...re,page:ve})),U?.({cID:o.classId,sID:o.sectionId,page:ve,per_page:a.perPage}),S([]),m({}),g({})}catch(W){_.error(W?.response?.data?.msg??W?.message??"Failed to update",{duration:1500})}},T=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:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=!!w?.[ne],se=(h?.[ne]??{}).roll_no??(W?"":Y?.roll_no??"");return e.jsx(s.Input,{value:H?se:Y?.roll_no,style:H?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!H||W,onChange:pe=>F(ne,{roll_no:pe.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(B,Y)=>`${Y?.firstname??""} ${Y?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=!!w?.[ne],se=(h?.[ne]??{}).section_id??"",pe=Array.isArray(A)?A:[];return e.jsx(s.Select,{options:pe,placeholder:H&&!W?"Select Section":"Section",disabled:!H||W,value:H&&!W&&se||void 0,style:{width:"100%"},onChange:ve=>F(ne,{section_id:ve})},`section_${ne}_${x}_${W?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=h?.[ne]??{},Z=String(W.current_result??"Pass");return e.jsxs(s.Radio.Group,{value:Z,disabled:!H,buttonStyle:"solid",onChange:se=>F(ne,{current_result:se.target.value}),children:[e.jsx(s.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(s.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=!!w?.[ne],Z=h?.[ne]??{},se=String(Z.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(s.Radio.Group,{value:W?"Leave":"Continue",disabled:!H,buttonStyle:"solid",onChange:pe=>q(ne,pe.target.value),children:[e.jsx(s.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(s.Radio.Button,{value:"Leave",children:"Leave"})]}),H&&W&&e.jsx(s.DatePicker,{style:{width:"100%"},value:se?ae(se):null,onChange:pe=>F(ne,{leave_date:pe?pe.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[q,w,h,j,x,A,F]),$=i.useMemo(()=>({selectedRowKeys:u,onChange:B=>S((Array.isArray(B)?B:[]).map(Y=>String(Y)))}),[u]);return i.useEffect(()=>{!o.classId||!o.sectionId||U&&U({cID:o.classId,sID:o.sectionId,page:a.page,per_page:a.perPage})},[a.page,a.perPage,U,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(s.Form,{form:n,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(s.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:B=>B,children:e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{const Y=B?.value??null;n.setFieldValue("section_id",null),l({classId:Y,sectionId:null})}})}),e.jsx(s.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:B=>B,children:e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Nt,{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(s.Typography.Text,{children:["Selected: ",u.length]}),e.jsx(s.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(ee,{label:"Session",options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:L.find(B=>String(B.value)===String(d.sessionId))??null,onChange:B=>c(Y=>({...Y,sessionId:B?.value??null}))}),e.jsx(ee,{label:"Class",options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(B=>String(B.value)===String(d.classId))??null,onChange:B=>{const Y=B?.value??null;c(ne=>({...ne,classId:Y})),y(ne=>!ne)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"button",value:"Save",color:"primary",onClick:k})})]}),e.jsx(s.Table,{rowKey:B=>String(B.id),rowSelection:$,columns:T,dataSource:P,loading:M,pagination:{current:a.page,pageSize:a.perPage,total:N,showSizeChanger:!0,onChange:(B,Y)=>{r({page:B,perPage:Y}),S([]),m({}),g({})}}})]})})]})}function cy({token:t}){return e.jsx(dy,{token:t})}const nn=we.coscholastic,uy=({token:t})=>G(t?[nn.table,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),py=({token:t})=>G(t?[nn.categoryDropdown,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),hi=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 my({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(null),[l,d]=i.useState(null),c=i.useRef(null),{data:x}=G(t?[we.master.classes.dropdown,t]:null,([b,A])=>Q(b,A)),y=i.useMemo(()=>hi(x),[x]),{data:u,isLoading:S,mutate:j}=uy({token:t}),w=i.useMemo(()=>{const b=u?.data?.data??u?.data??u??[];return Array.isArray(b)?b:Array.isArray(b?.data)?b.data:[]},[u]),{data:m,mutate:h}=py({token:t}),g=i.useMemo(()=>hi(m),[m]),I=i.useMemo(()=>(Array.isArray(g)?g:[]).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[g]),R=async()=>{const b=String(n??"").trim();if(!b){_.error("Please enter category title",{duration:1200});return}try{await Ye(nn.addCategory,{title:b},t),_.success("Success! Added category.",{duration:1e3}),a(""),h()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add category",{duration:1500})}},D=async b=>{try{await Mt(nn.deleteCategory,b,t),_.success("Success! Deleted category.",{duration:1e3}),h()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete category",{duration:1500})}},C=async b=>{if(b.preventDefault(),!r){_.error("Please select Category",{duration:1200});return}if(!l){_.error("Please select Class",{duration:1200});return}if(!b?.target?.skill?.value){_.error("Please enter Skill Name",{duration:1200});return}const O=new FormData(b.target);O.append("scholastic_catid",String(r)),O.append("class_id",String(l));try{await mt(nn.addSkill,O,t),_.success("Success! Added new item.",{duration:1e3}),b.target.reset(),d(null),j()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},f=async b=>{try{await Mt(nn.deleteSkill,b,t),_.success("Success! Deleted item.",{duration:1e3}),j()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete the item.",{duration:1500})}},p=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:(b,A)=>e.jsx(s.Popconfirm,{title:"Delete this skill?",onConfirm:()=>f(A?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.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(ee,{style:{width:"100%"},value:I.find(b=>String(b.value)===String(r))??null,placeholder:"Select Category",onChange:b=>o(b?.value??null),options:I}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(J,{placeholder:"New category",ref:c,value:n,onChange:b=>a(b.target.value)}),e.jsx(s.Button,{type:"text",icon:e.jsx(X.PlusOutlined,{}),onClick:R}),e.jsx(s.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{r&&(D(r),o(null))},children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{}),disabled:!r})})]})]}),e.jsx(ee,{label:"Class",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:y.find(b=>String(b.value)===String(l))??null,onChange:b=>d(b?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(J,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Nt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:b=>b.id,columns:p,dataSource:w,loading:S,pagination:!1})})]})}function yy({token:t}){return e.jsx(my,{token:t})}const fy=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Co=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:Tm(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=fy(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},gi=we.notes,hy=({token:t,url:n})=>G(t&&n?[n,t]:null,([a,r])=>Q(a,r),{revalidateOnFocus:!1}),oa=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[]},gy=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r};function xy({token:t}){const[n]=s.Form.useForm(),[a]=s.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null,sectionId:null}),[c,x]=i.useState(!1),[y,u]=i.useState(""),{data:S}=G(t?[we.master.classes.dropdown,t]:null,([$,B])=>Q($,B)),j=i.useMemo(()=>oa(S),[S]),w=i.useMemo(()=>l.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:m}=G(t&&w?[w,t]:null,([$,B])=>Q($,B)),h=i.useMemo(()=>oa(m),[m]),g=i.useMemo(()=>!l.classId||!l.sectionId?null:`${gi.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:I,isLoading:R,mutate:D}=hy({token:t,url:g}),C=i.useMemo(()=>{const $=I?.data?.data??I?.data??I??[];return Array.isArray($)?$:Array.isArray($?.data)?$.data:[]},[I]),f=i.useMemo(()=>I?.pagination?.total_rows??I?.pagination?.total??C.length??0,[I,C.length]),[p,b]=i.useState(null),[A,O]=i.useState(null),[L,U]=i.useState(null),[v,M]=i.useState(!1),{data:P}=G(t&&L?[L,t]:null,([$,B])=>Q($,B),{revalidateOnFocus:!1}),N=i.useMemo(()=>oa(P),[P]),{data:E}=G(t&&A?[A,t]:null,([$,B])=>Q($,B)),F=i.useMemo(()=>oa(E),[E]),q=$=>{const B=$?.class_id?.value??null,Y=$?.section_id?.value??null;!B||!Y||(o(ne=>({...ne,page:1})),d({classId:B,sectionId:Y}))},z=()=>{u(""),x(!0),b(null),O(null),U(null),M($=>!$),a.resetFields()},k=async $=>{const B=$?.class_id?.value??null,Y=$?.section_id?.value??null,ne=$?.sub_id?.value??null,H=$?.status?.value??"publish",W=$?.title??"",Z=$?.remark??"";if(!B||!Y||!ne||!W||!Z||!y){_.error("Please fill all fields",{duration:1200});return}const se=new FormData;se.append("class_id",String(B)),se.append("section_id",String(Y)),se.append("sub_id",String(ne)),se.append("title",String(W)),se.append("remark",String(Z)),se.append("status",String(H)),se.append("file",String(y));try{await mt(gi.add,se,t),_.success("Success! Added new item.",{duration:1e3}),x(!1),D()}catch(pe){_.error(pe?.response?.data?.msg??pe?.message??"Failed to add the new item.",{duration:1500})}},T=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)=>{const Y=String(B?.status??"").toLowerCase();return e.jsx(s.Tag,{color:Y==="publish"?"green":"red",children:B?.status??"-"})}},{title:"File",key:"file",align:"center",render:($,B)=>{const Y=B?.file;if(!Y)return"-";const ne=gy(nt(),`/student/note/${Y}`);return e.jsx("a",{href:ne,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(s.Modal,{title:"Add Note",open:c,onCancel:()=>x(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(s.Form,{form:a,layout:"vertical",onFinish:k,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const B=$?.value??null;b(B),a.setFieldValue("section_id",null),a.setFieldValue("sub_id",null),U(B?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(B))}`:null),O(B?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(B))}`:null),M(Y=>!Y)}},`class_${v}`)}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${v}_${p??"none"}`)}),e.jsx(s.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${v}_${A??"none"}`)}),e.jsx(s.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(J,{placeholder:"Remark"})}),e.jsx(s.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:$=>$,children:e.jsx(ee,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(s.Form.Item,{label:"File",required:!0,children:e.jsx(Co,{token:t,value:y,onChange:u})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ce,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>x(!1),children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Nt,{actions:["add","export","print","download","filter"],onAdd:z,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:n,layout:"vertical",onFinish:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const B=$?.value??null;n.setFieldValue("section_id",null),d({classId:B,sectionId:null})}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(s.Table,{rowKey:$=>$.id,columns:T,dataSource:C,loading:R,pagination:{current:r.page,pageSize:r.perPage,total:f,showSizeChanger:!0,onChange:($,B)=>o({page:$,perPage:B})}})})]})}function by({token:t}){return e.jsx(xy,{token:t})}const Sy=({token:t})=>G(t?[we.promoteStudents.sessionDropdown,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),xi=we.transferCertificate,us=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[]},jy={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},vy=(t,n)=>t.inputtype==="Select"?null:t.inputtype==="date"?ae():"",bi=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}],Si=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 _y({token:t,transferCertificateViewPath:n="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:a}){const[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState({page:1,perPage:10}),[c,x]=i.useState({classId:null,sectionId:null,sessionId:null}),[y,u]=i.useState(null),[S,j]=i.useState(!1),{data:w}=G(t?[we.master.classes.dropdown,t]:null,([T,$])=>Q(T,$)),m=i.useMemo(()=>us(w),[w]),{data:h}=G(t&&y?[y,t]:null,([T,$])=>Q(T,$)),g=i.useMemo(()=>us(h),[h]),{data:I}=Sy({token:t}),R=i.useMemo(()=>us(I),[I]),D=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${xi.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:f,mutate:p}=G(t&&D?[D,t]:null,([T,$])=>Q(T,$),{revalidateOnFocus:!1,onSuccess:T=>{const $=T?.data?.data??T?.data??[];Array.isArray($)&&$[0]?.transefer_certificate_id&&P(String($[0].transefer_certificate_id))}}),b=i.useMemo(()=>{const T=C?.data?.data??C?.data??C??[];return Array.isArray(T)?T:Array.isArray(T?.data)?T.data:[]},[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??b.length??0,[C,b.length]),[O,L]=i.useState(!1),[U,v]=i.useState(null),[M,P]=i.useState("1"),N=T=>{v(T);const $=M==="1"?bi(T):Si(T),B={};$.forEach(Y=>{B[Y.name]=Y.value??vy(Y)}),o.setFieldsValue(B),L(!0)},E=async T=>{if(!T)return;if(typeof a=="function")return a(T);const $=`${n}?id=${encodeURIComponent(String(T))}`;window.location.href=$},F=T=>{const $=T?.class_id?.value??null,B=T?.section_id?.value??null,Y=T?.session_id?.value??null;if(!$||!B||!Y){_.error("Please select Class, Section and Session",{duration:1200});return}d(ne=>({...ne,page:1})),x({classId:$,sectionId:B,sessionId:Y})},q=async T=>{const $=new FormData;Object.entries(T??{}).forEach(([B,Y])=>{if(Y!=null){if(ae.isDayjs(Y)){$.append(B,Y.format("YYYY-MM-DD"));return}$.append(B,String(Y))}});try{await mt(xi.addData,$,t),_.success("Success! Added new item.",{duration:1e3}),L(!1),v(null),p()}catch(B){_.error(B?.response?.data?.msg??B?.message??"Failed to add the new item.",{duration:1500})}},z=i.useMemo(()=>M==="1"?bi(U):Si(U),[M,U]),k=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:(T,$)=>e.jsx(s.Button,{type:"text",icon:$?.transfer_certificate_data==="not_present"?e.jsx(X.EyeOutlined,{}):e.jsx(X.CheckOutlined,{}),onClick:()=>{$?.transfer_certificate_data==="not_present"?N($?.id):E($?.id)}})}],[M]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:"Transfer Certificate",open:O,onCancel:()=>L(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:q,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:z.map(T=>T.inputtype==="hidden"?e.jsx(s.Form.Item,{name:T.name,initialValue:T.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},T.name):T.inputtype==="date"?e.jsx(s.Form.Item,{label:T.label,name:T.name,children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:jy})},T.name):T.inputtype==="radio"?e.jsx(s.Form.Item,{label:T.label,name:T.name,children:e.jsx(s.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},T.name):T.inputtype==="Select"?e.jsx(s.Form.Item,{label:T.label,name:T.name,getValueFromEvent:$=>$,children:e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},T.name):e.jsx(s.Form.Item,{label:T.label,name:T.name,children:e.jsx(J,{placeholder:T.label})},T.name))}),e.jsxs(s.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(ce,{type:"submit",value:"Submit",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>L(!1),children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(s.Form,{form:r,layout:"vertical",onFinish:F,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:T=>T,children:e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:T=>{const $=T?.value??null;u($?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String($))}`:null),j(B=>!B),r.setFieldValue("section_id",null)}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:T=>T,children:e.jsx(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${S}`)}),e.jsx(s.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:T=>T,children:e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Nt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:T=>T.id,columns:k,dataSource:b,loading:f,pagination:{current:l.page,pageSize:l.perPage,total:A,showSizeChanger:!0,onChange:(T,$)=>d({page:T,perPage:$})}})})]})}function wy({token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a}){return e.jsx(_y,{token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a})}const Cy=({token:t,url:n})=>G(t&&n?[n,t]:null,([a,r])=>Q(a,r),{revalidateOnFocus:!1}),ps=we.syllabus,ji=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[]},Ay=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r};function Ty({token:t}){const[n]=s.Form.useForm(),[a]=s.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null}),[c,x]=i.useState(!1),[y,u]=i.useState(null),[S,j]=i.useState(""),{data:w}=G(t?[we.master.classes.dropdown,t]:null,([E,F])=>Q(E,F)),m=i.useMemo(()=>ji(w),[w]),h=i.useMemo(()=>l.classId?`${ps.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:g,isLoading:I,mutate:R}=Cy({token:t,url:h}),D=i.useMemo(()=>{const E=g?.data?.data??g?.data??g??[];return Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[]},[g]),C=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??D.length??0,[g,D.length]),[f,p]=i.useState(null),[b,A]=i.useState(!1),{data:O}=G(t&&f?[f,t]:null,([E,F])=>Q(E,F),{revalidateOnFocus:!1}),L=i.useMemo(()=>ji(O),[O]),U=E=>{const F=E?.class_id?.value??null;F&&(o(q=>({...q,page:1})),d({classId:F}))},v=()=>{u(null),j(""),p(null),A(E=>!E),a.resetFields(),x(!0)},M=E=>{u(E),j(E?.attchement??"");const F=E?.class_id;p(F?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(F))}`:null),A(q=>!q),a.setFieldsValue({class_id:m.find(q=>String(q.value)===String(F))??null,sub_id:L.find(q=>String(q.value)===String(E?.sub_id??E?.subject_id))??(E?.sub_id||E?.subject_id?{label:E?.subject_title??"Subject",value:E?.sub_id??E?.subject_id}:null),title:E?.title??"",description:E?.description??""}),x(!0)},P=async E=>{const F=E?.class_id?.value??null,q=E?.sub_id?.value??null,z=E?.title??"",k=E?.description??"";if(!F||!q||!z||!k||!S){_.error("Please fill all fields",{duration:1200});return}const T=new FormData;T.append("class_id",String(F)),T.append("sub_id",String(q)),T.append("title",String(z)),T.append("description",String(k)),T.append("file",String(S));try{y?.id?(T.append("id",String(y.id)),await mt(ps.edit,T,t),_.success("Success! Updated item.",{duration:1e3})):(await mt(ps.add,T,t),_.success("Success! Added new item.",{duration:1e3})),x(!1),u(null),R()}catch($){_.error($?.response?.data?.msg??$?.message??"Failed to save",{duration:1500})}},N=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:(E,F)=>{const q=F?.attchement;if(!q)return"-";const z=Ay(nt(),`uploads/student/note/${q}`);return e.jsx("a",{href:z,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(E,F)=>e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>M(F)})}],[L,m]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:y?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{x(!1),u(null),j("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(s.Form,{form:a,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(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{const F=E?.value??null;a.setFieldValue("sub_id",null),p(F?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(F))}`:null),A(q=>!q)}},`class_${y?.id??"add"}_${b}`)}),e.jsx(s.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${y?.id??"add"}_${b}_${f??"none"}`)}),e.jsx(s.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(kt,{placeholder:"Description"})}),e.jsx(s.Form.Item,{label:"File",required:!0,children:e.jsx(Co,{token:t,value:S,onChange:j})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ce,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>x(!1),children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Nt,{actions:["add","export","print","download","filter"],onAdd:v,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:n,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(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(s.Table,{rowKey:E=>E.id,columns:N,dataSource:D,loading:I,pagination:{current:r.page,pageSize:r.perPage,total:C,showSizeChanger:!0,onChange:(E,F)=>o({page:E,perPage:F})}})})]})}function Ry({token:t}){return e.jsx(Ty,{token:t})}const Ba=we.timetable,vi=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[]},_i=t=>{if(!t)return"";const n=ae(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},Iy=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let a=0;for(let o=0;o<n.length;o+=1)a=(a*31+n.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[a%r.length]},wi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Dy=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"};function ky({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[y,u]=i.useState(""),{data:S}=G(t?[we.master.classes.dropdown,t]:null,([p,b])=>Q(p,b)),j=i.useMemo(()=>vi(S),[S]),{data:w}=G(t&&n?[n,t]:null,([p,b])=>Q(p,b)),m=i.useMemo(()=>vi(w),[w]),{data:h,isLoading:g}=G(t&&l?[l,t]:null,([p,b])=>Q(p,b),{revalidateOnFocus:!1}),I=i.useMemo(()=>h?.days??h?.data?.days??h?.data?.data?.days??{},[h]),{dataSource:R,daySpanByFirstKey:D}=i.useMemo(()=>{const p=Object.entries(I||{}).slice().sort((O,L)=>wi.indexOf(String(O[0]).toLowerCase())-wi.indexOf(String(L[0]).toLowerCase())),b=new Map,A=[];for(const[O,L]of p){const U=(Array.isArray(L)?L:[]).slice().sort((M,P)=>Number(M?.order_no||0)-Number(P?.order_no||0)),v=U.length;for(let M=0;M<v;M+=1){const P=U[M],N=P?.id||`${O}-${P?.order_no}-${M}`;M===0&&b.set(N,v),A.push({key:N,_dayKey:O,...P})}}return{dataSource:A,daySpanByFirstKey:b}},[I]),C=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(p,b)=>{const A=D.get(b.key);return A===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(X.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Dy(p)})]}),props:{rowSpan:A}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:p=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:p})},{title:"Time",key:"time",width:180,render:(p,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[_i(b?.time_from)," - ",_i(b?.time_to)]})]})},{title:"Subject",key:"subject",render:(p,b)=>{if(String(b?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const O=b?.subject_name||"-";return e.jsx(s.Tag,{color:Iy(O),style:{fontWeight:500},children:O})}},{title:"Teacher",key:"teacher",render:(p,b)=>{const A=String(b?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:A?"-":b?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(p,b)=>{const A=String(b?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:A?"-":b?.room_no||"-"})]})}}],[D]),f=p=>{p.preventDefault();const b=p.target.class_id?.value,A=p.target.section_id?.value;if(!b||!A)return;const O=j.find(M=>String(M.value)===String(b)),L=m.find(M=>String(M.value)===String(A));x(O?.label||""),u(L?.label||"");const v=`${Ba.byClassSection}/${b}/section/${A}`;d(v)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Nt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),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.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:p=>{a(`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(p?.value??""))}`),o(b=>!b)}}),e.jsx(ee,{options:m,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(ce,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:c||y?`Timetable: ${c} ${y}`:"Timetable"}),children:e.jsx(s.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:R,columns:C,rowKey:"key",loading:g,scroll:{x:"max-content"}})})]})}const Oy=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[]},Ci=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Py=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"},Ai=t=>{if(!t)return"";const n=ae(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},Ey=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let a=0;for(let o=0;o<n.length;o+=1)a=(a*31+n.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[a%r.length]};function My({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(null),{data:l}=G(t?[we.assignByClass.teacherDropdown,t]:null,([w,m])=>Q(w,m)),d=i.useMemo(()=>Oy(l),[l]),{data:c,isLoading:x}=G(t&&r?[r,t]:null,([w,m])=>Q(w,m),{revalidateOnFocus:!1}),{dataSource:y,daySpanByFirstKey:u}=i.useMemo(()=>{const m=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((R,D)=>{const C=Ci.indexOf(String(R?.day_name||"").toLowerCase()),f=Ci.indexOf(String(D?.day_name||"").toLowerCase());if(C!==f)return C-f;const p=Number(R?.order_no||0),b=Number(D?.order_no||0);return p!==b?p-b:String(R?.time_from||"").localeCompare(String(D?.time_from||""))}),h=new Map,g=[];let I=0;for(;I<m.length;){const R=String(m[I]?.day_name||"").toLowerCase();let D=I;for(;D<m.length&&String(m[D]?.day_name||"").toLowerCase()===R;)D+=1;const C=D-I;for(let f=I;f<D;f+=1){const p=m[f],b=p?.id||`${R}-${p?.order_no}-${f}`;f===I&&h.set(b,C),g.push({key:b,_dayKey:R,...p})}I=D}return{dataSource:g,daySpanByFirstKey:h}},[c]),S=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(w,m)=>{const h=u.get(m.key);return h===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(X.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Py(w)})]}),props:{rowSpan:h}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:w=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:w})},{title:"Time",key:"time",width:180,render:(w,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[Ai(m?.time_from)," - ",Ai(m?.time_to)]})]})},{title:"Subject",key:"subject",render:(w,m)=>{if(String(m?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const g=m?.subject_name||"-";return e.jsx(s.Tag,{color:Ey(g),style:{fontWeight:500},children:g})}},{title:"Class",key:"class",width:160,render:(w,m)=>e.jsxs(s.Tag,{color:"purple",style:{fontWeight:500},children:[m?.class_name||m?.class_id||"-"," ",m?.section_name?`(${m.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(w,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:m?.room_no||"-"})]})}],[u]),j=w=>{w.preventDefault();const m=w.target.teacher_id?.value;if(!m)return;a(m);const g=`${Ba.teacherTimetable}${encodeURIComponent(String(m))}`;o(g)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Nt,{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(ee,{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(ce,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(s.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:y,columns:S,rowKey:"key",loading:x,scroll:{x:"max-content"}})})]})}function Ti(t){if(!t)return null;const n=String(t).trim().replaceAll(".",":");if(!n)return null;const a=n.toLowerCase(),r=a.includes("am")||a.includes("pm");let o=0,l=0,d=0;if(r){const x=a.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!x)return null;o=Number.parseInt(x[1],10),l=Number.parseInt(x[2],10),d=Number.parseInt(x[3]||"0",10);const y=x[4].toLowerCase();y==="pm"&&o<12&&(o+=12),y==="am"&&o===12&&(o=0)}else{const c=n.split(":").map(x=>x.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 Cn(t,n){const a=Number.parseInt(n,10);return!Number.isFinite(a)||a<=0||!t||!t.isValid?.()?null:t.add(a,"minute")}const _a=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[]},Dn={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},Fy=t=>{const n=Dn[String(t)];return n?n.charAt(0).toUpperCase()+n.slice(1):String(t)},Ny=({token:t,classId:n,sectionId:a,subjectId:r,value:o,onChange:l,disabled:d})=>{const c=t&&n&&a&&r?`${Ba.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(n))}§ion_id=${encodeURIComponent(String(a))}`:null,{data:x,isLoading:y}=G(c?[c,t]:null,([S,j])=>Q(S,j),{revalidateOnFocus:!1}),u=i.useMemo(()=>_a(x?.data??x).map(j=>({value:j?.value??j?.id,label:j?.label??j?.name??j?.teacher_name??""})),[x]);return e.jsx(s.Select,{placeholder:d?"-":"Select Teacher",loading:y,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:S=>l?.(S),showSearch:!0,optionFilterProp:"label"})};function $y({token:t}){const[n]=s.Form.useForm(),[a,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:[]}),[x,y]=i.useState(!1),u=i.useMemo(()=>t?we.master.classes.dropdown:null,[t]),{data:S}=G(u?[u,t]:null,([v,M])=>Q(v,M)),j=i.useMemo(()=>_a(S).map(v=>({value:v?.value??v?.id,label:v?.label??v?.title??""})),[S]),w=i.useMemo(()=>!t||!a.classId?null:`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:m}=G(w?[w,t]:null,([v,M])=>Q(v,M)),h=i.useMemo(()=>_a(m).map(v=>({value:v?.value??v?.id,label:v?.label??v?.title??""})),[m]),g=i.useMemo(()=>!t||!a.classId?null:`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:I}=G(g?[g,t]:null,([v,M])=>Q(v,M)),R=i.useMemo(()=>_a(I).map(v=>({value:v?.value??v?.id,label:v?.label??v?.title??""})),[I]),D=i.useMemo(()=>Array.isArray(d?.[a.dayKey])?d[a.dayKey]:[],[a.dayKey,d]),C=i.useCallback((v,M,P)=>{c(N=>{const E={...N},F=Array.isArray(E[v])?E[v].slice():[];return F[M]={...F[M]??{},...P},E[v]=F,E})},[]),f=i.useCallback((v,M)=>{c(P=>{const N={...P},E=Array.isArray(N[v])?N[v].slice():[];return E.splice(M,1),N[v]=E.map((F,q)=>({...F,order_no:q+1})),N})},[]),p=i.useCallback(v=>{c(M=>{const P={...M},N=Array.isArray(P[v])?P[v].slice():[];let E=null,F=null;const q=N[N.length-1];if(q?.time_to){const z=Ti(q.time_to),k=Number.parseInt(o.interval,10)||0,T=Number.parseInt(o.duration,10)||0,$=Cn(z,k),B=T>0?Cn($,T):null;E=$?.isValid?.()?$.format("HH:mm:ss"):null,F=B?.isValid?.()?B.format("HH:mm:ss"):null}return N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:E,time_to:F,is_break:!1}),P[v]=N,P})},[o.duration,o.interval,o.roomNo]),b=i.useCallback(()=>{const v=o.startTime,M=o.endTime,P=Number.parseInt(o.duration,10),N=Number.parseInt(o.interval,10);if(!v||!v.isValid?.()){_.error("Start time is required",{duration:1500});return}if(!M||!M.isValid?.()){_.error("End time is required",{duration:1500});return}if(!M.isAfter(v)){_.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(P)||P<=0){_.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(N)||N<0){_.error("Interval must be 0 or more",{duration:1500});return}const E=()=>{const F=[];let q=v;for(let z=0;z<50;z+=1){const k=Cn(q,P);if(!k||!k.isValid?.()||k.isAfter(M))break;F.push({order_no:F.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:q.format("HH:mm:ss"),time_to:k.format("HH:mm:ss"),is_break:!1});const T=Cn(k,N);if(!T||!T.isValid?.()||T.isAfter(M)||T.isSame(M))break;q=T}if(o.tiffinEnabled){const z=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),k=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),T=Math.min(z,F.length);if(T>0&&k>0){const $=F[T-1],B=$?.time_to?Ti($.time_to):null,Y=B?Cn(B,k):null;B?.isValid?.()&&Y?.isValid?.()&&!Y.isAfter(M)&&F.splice(T,0,{order_no:T+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:B.format("HH:mm:ss"),time_to:Y.format("HH:mm:ss"),is_break:!0})}}return F.map((z,k)=>({...z,order_no:k+1}))};c(F=>{const q={...F};return Object.keys(Dn).forEach(z=>{a.daysEnabled?.[z]&&(q[z]=E())}),q}),_.success("Generated schedule",{duration:1e3})},[o,a.daysEnabled]),A=i.useCallback(()=>{const v=localStorage.getItem("genrall_settings"),P=(v?JSON.parse(v):{})?.session_id??"1",N=a.classId,E=a.sectionId,F=Object.keys(Dn).map(q=>{const z=(Array.isArray(d?.[q])?d[q]:[]).map((k,T)=>({order_no:T+1,subject_id:k?.is_break?0:k?.subject_id??null,teacher_id:k?.is_break?0:k?.teacher_id??null,room_no:k?.room_no??"",time_from:k?.time_from??null,time_to:k?.time_to??null,is_break:k?.is_break?1:0}));return{day:Dn[q],class_id:N,section_id:E,session_id:P,args:z}});return{class_id:N,section_id:E,session_id:P,days:F}},[a.classId,a.sectionId,d]),O=i.useCallback(async()=>{if(!a.classId||!a.sectionId){_.error("Please select Class and Section",{duration:1500});return}const v=A(),M=Array.isArray(v?.days)?v.days:[];if(!M.some(E=>Array.isArray(E?.args)&&E.args.length>0)){_.error("No timetable rows to submit",{duration:1500});return}const N=E=>{const F=E?.is_break;return F===1||F==="1"||F===!0?!0:String(F??"").toLowerCase()==="true"};M.some(E=>(Array.isArray(E?.args)?E.args:[]).some(F=>String(F?.time_from??"").trim()&&String(F?.time_to??"").trim()?N(F)?!1:!String(F?.subject_id??"").trim()||!String(F?.teacher_id??"").trim():!0)),y(!0);try{const E=Ba.save,F=E==="api/timetable/save"?"timetable/save":null,q=async T=>{const $=await Pa(T,v,t);if($&&typeof $=="object")return $;throw new Error("No response from server")};let z;try{z=await q(E)}catch{z=await q(F)}const k=String(z?.msg??"");if(String(z?.Status)==="Success"){if(Array.isArray(z?.data)&&z.data.length===0&&k){_.error(k,{duration:3e3});return}_.success(k||"Weekly Time Table added successfully!",{duration:1200});return}_.error(k||"Failed to add time table",{duration:3e3})}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to add time table",{duration:3e3})}finally{y(!1)}},[A,a.classId,a.sectionId,t]),L=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:v=>v?ae(v,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:v=>v?ae(v,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(v,M,P)=>e.jsx(s.Switch,{checked:!!M?.is_break,onChange:N=>{C(a.dayKey,P,{is_break:N,subject_id:N?"":M?.subject_id??"",teacher_id:N?"":M?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(v,M,P)=>e.jsx(s.Select,{placeholder:M?.is_break?"-":"Select Subject",disabled:!!M?.is_break,style:{width:"100%"},options:R,value:M?.subject_id?String(M.subject_id):void 0,onChange:N=>C(a.dayKey,P,{subject_id:N,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(v,M,P)=>e.jsx(Ny,{token:t,classId:a.classId,sectionId:a.sectionId,subjectId:M?.subject_id,disabled:!!M?.is_break||!M?.subject_id,value:M?.teacher_id,onChange:N=>C(a.dayKey,P,{teacher_id:N})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(v,M,P)=>e.jsx(s.Input,{value:M?.room_no??"",onChange:N=>C(a.dayKey,P,{room_no:N.target.value})})},{title:"Action",key:"action",width:90,render:(v,M,P)=>e.jsx(s.Popconfirm,{title:"Delete this row?",onConfirm:()=>f(a.dayKey,P),children:e.jsx(s.Button,{danger:!0,type:"text",children:"Delete"})})}],[a.classId,a.dayKey,a.sectionId,f,R,t,C]),U=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(s.Form,{form:n,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(s.Form.Item,{label:"Class",required:!0,children:e.jsx(s.Select,{placeholder:"Select Class",options:j,value:a.classId?String(a.classId):void 0,onChange:v=>{r(M=>({...M,classId:v,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(s.Form.Item,{label:"Section",required:!0,children:e.jsx(s.Select,{placeholder:"Select Section",options:h,value:a.sectionId?String(a.sectionId):void 0,onChange:v=>r(M=>({...M,sectionId:v})),disabled:!a.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(s.Form.Item,{label:"Start Time",required:!0,children:e.jsx(s.TimePicker,{value:o.startTime,onChange:v=>l(M=>({...M,startTime:v})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"End Time",required:!0,children:e.jsx(s.TimePicker,{value:o.endTime,onChange:v=>l(M=>({...M,endTime:v})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(s.InputNumber,{min:1,value:o.duration,onChange:v=>l(M=>({...M,duration:v})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Interval (min)",children:e.jsx(s.InputNumber,{min:0,value:o.interval,onChange:v=>l(M=>({...M,interval:v})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Room No",children:e.jsx(s.Input,{value:o.roomNo,onChange:v=>l(M=>({...M,roomNo:v.target.value}))})}),e.jsx(s.Form.Item,{label:"Tiffin Break",children:e.jsxs(s.Space,{children:[e.jsx(s.Switch,{checked:o.tiffinEnabled,onChange:v=>l(M=>({...M,tiffinEnabled:v}))}),e.jsx(s.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(s.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(s.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:v=>l(M=>({...M,tiffinAfterPeriod:v})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(s.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(s.InputNumber,{min:1,value:o.tiffinDuration,onChange:v=>l(M=>({...M,tiffinDuration:v})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(s.Button,{onClick:b,children:"Generate"}),e.jsx(s.Button,{type:"primary",loading:x,onClick:O,children:"Save"})]})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(s.Space,{children:[e.jsx(s.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(s.Select,{style:{width:160},value:a.dayKey,onChange:v=>r(M=>({...M,dayKey:v})),options:Object.keys(Dn).map(v=>({value:String(v),label:Fy(v)}))}),e.jsx(s.Button,{onClick:()=>p(a.dayKey),children:"Add Row"})]}),children:e.jsx(s.Table,{rowKey:(v,M)=>`${a.dayKey}_${M}`,columns:L,dataSource:D,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(s.Tabs,{type:"card",items:[{key:"create",label:"Create",children:U},{key:"routine",label:"Routine",children:e.jsx(ky,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(My,{token:t})}]})]})}function Uy({token:t}){return e.jsx($y,{token:t})}function By(){return null}const Wt=t=>t??localStorage.getItem("authToken")??"",Ls=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},ot={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"}},qs=t=>Ls(nt(),t),Ly=()=>Ls(nt(),"uploads"),Ao=t=>Ls(Ly(),t),qy=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Wt(r))},zy=async(t,n)=>Q(t,Wt(n)),Yn=async(t,n,a)=>Ye(t,n,Wt(a)),To=async(t,n,a)=>pt(t,n,Wt(a)),zs=async(t,n,a)=>at(t,n,Wt(a)),Yy=async(t,n,a)=>Pa(t,{arg:n},Wt(a)),Ro=async(t,n,a)=>kn(t,{arg:n},Wt(a)),Io=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>qy({baseUrl:l,page:d,perPage:c},x)),dt=({url:t,token:n})=>G(n&&t?[t,n]:null,([r,o])=>zy(r,o)),Wy={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function Vy({value:t,onChange:n,placeholder:a}){const[r,o]=i.useState(t??""),l=i.useMemo(()=>typeof t=="string"?t:r,[r,t]);return e.jsx("div",{style:Wy,children:e.jsx(lo,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),n?.(c)},style:{outline:"none",minHeight:280},placeholder:a})})}function $t({title:t,actions:n,children:a,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:a})}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 Ys({token:t,title:n,fetchUrl:a,saveUrl:r,fieldName:o,initialHtmlFieldName:l}){const d=i.useRef(null),c=dt({url:a,token:t}),y=i.useMemo(()=>Hy(c.data),[c.data])?.[l??o]??"",[u,S]=i.useState("");i.useEffect(()=>{S(typeof y=="string"?y:"")},[y]);const j=()=>S(typeof y=="string"?y:""),w=()=>{const g=new Blob([String(u??"")],{type:"text/html"}),I=URL.createObjectURL(g),R=document.createElement("a");R.href=I,R.download=`${String(n??"legal").toLowerCase().replaceAll(" ","-")}.html`,R.click(),URL.revokeObjectURL(I)},m=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:j},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:w,disabled:!u}],[u,y]),h=async g=>{g.preventDefault();try{(await Ro(r,{[o]:u??""},t))?.Status==="Success"?_.success("Updated successfully.",{duration:1e3}):_.success("Updated.",{duration:1e3}),c.mutate?.()}catch(I){_.error(I?.response?.data?.msg??I?.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($t,{title:n,actions:m,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:h,children:[e.jsx(Vy,{value:u,onChange:S,placeholder:`Enter ${n} content...`}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Update"})})]})})})]})}const Ky=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 an({token:t,value:n,onChange:a,action:r,accept:o,maxCount:l=1,previewUrl:d}){const c=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),x=i.useMemo(()=>n?d||(Gy(n)?n:""):"",[d,n]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[x?e.jsx("img",{src:x,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(s.Upload,{maxCount:l,action:r,accept:o,headers:c,onChange:y=>{if(y?.file?.status==="removed"&&a?.(""),y?.file?.status==="done"){const u=Ky(y?.file?.response);u&&a?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})]})}const Ct=ot.organization,Do=()=>qs(Ct.uploadLogo),ms=()=>qs(Ct.uploadSignature),Jy=()=>qs(Ct.uploadFirebaseJson),Qy=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:[]:[],Xy=({token:t})=>dt({url:Ct.get,token:t}),Zy=({token:t})=>dt({url:Ct.currencyDropdown,token:t}),ef=({token:t})=>dt({url:Ct.countryCodeDropdown,token:t}),tf=({token:t})=>dt({url:Ct.timezoneDropdown,token:t}),nf=({token:t})=>dt({url:Ct.boardsDropdown,token:t}),la=t=>Qy(t?.data),Ri={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},af=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),Ii=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],Di=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],sf=t=>{const n=t?.data;return Array.isArray(n?.data)?n.data[0]??null:Array.isArray(n)?n[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},rf=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,of=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function lf({token:t}){const n=i.useRef(null),a=Xy({token:t}),r=Zy({token:t}),o=ef({token:t}),l=tf({token:t}),d=nf({token:t}),c=i.useMemo(()=>sf(a.data),[a.data]),x=i.useMemo(()=>rf(a.data),[a.data]),y=i.useMemo(()=>of(a.data),[a.data]),u=i.useMemo(()=>la(r),[r.data]),S=i.useMemo(()=>la(o),[o.data]),j=i.useMemo(()=>la(l),[l.data]),w=i.useMemo(()=>la(d),[d.data]),[m,h]=i.useState(null),[g,I]=i.useState(null),[R,D]=i.useState(null),[C,f]=i.useState(null),[p,b]=i.useState([]),[A,O]=i.useState("No"),[L,U]=i.useState("yes"),[v,M]=i.useState("no"),[P,N]=i.useState("Yes"),[E,F]=i.useState(""),[q,z]=i.useState(""),[k,T]=i.useState(null),[$,B]=i.useState(null),[Y,ne]=i.useState(null),[H,W]=i.useState(null),Z=()=>{const V=(()=>{try{const oe=c?.weekly_off;if(!oe)return[];const Ce=Array.isArray(oe)?oe:JSON.parse(oe);return Array.isArray(Ce)?Ce.filter(Boolean).map(Oe=>({value:Oe,label:Oe})):[]}catch{return[]}})();b(V),h(u.find(oe=>oe?.value===c?.currency)??null),I(S.find(oe=>oe?.value===c?.country_code)??null),D(j.find(oe=>oe?.value===c?.time_zone)??null),f(w.find(oe=>oe?.value===c?.affliated_board_id)??null),F(c?.logo??""),z(c?.json_file??""),O(c?.attendance_salary_calculation??"No"),U(c?.salary_period??"yes"),M(c?.multiple_shift??"no"),N(c?.readmission_charges??"Yes"),T(x?.in_from?ae(x.in_from,"h:mm A"):null),B(x?.in_to?ae(x.in_to,"h:mm A"):null),ne(x?.out_from?ae(x.out_from,"h:mm A"):null),W(x?.out_to?ae(x.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&Z()},[c,u,S,j,w]);const se=()=>{n.current?.reset?.(),Z()},pe=()=>{const V=new FormData(n.current??void 0),oe=Object.fromEntries(V.entries());oe.weekly_off_day=p.map(Ne=>Ne?.value).filter(Boolean);const Ce=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),Oe=URL.createObjectURL(Ce),Pe=document.createElement("a");Pe.href=Oe,Pe.download="organization-setting.json",Pe.click(),URL.revokeObjectURL(Oe)},ve=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:se},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:pe,disabled:!c}],[c,p]),re=async V=>{V.preventDefault();try{const oe=new FormData(V.target);oe.set("currency",m?.value??""),oe.set("code",g?.value??""),oe.set("time_zone",R?.value??""),oe.set("affliated_board_id",C?.value??""),oe.set("board_name",C?.label??""),oe.set("attendance_salary_calculation",A),oe.set("salary_period",L),oe.set("multiple_shift",v),oe.set("readmission_charges",P),p.forEach(Pe=>{Pe?.value&&oe.append("weekly_off_day[]",Pe.value)}),oe.set("logo",E??""),oe.set("json_file",q??""),oe.set("server_key",y?.server_key??""),oe.set("in_time_start",k?ae(k).format("h:mm A"):""),oe.set("in_time_end",$?ae($).format("h:mm A"):""),oe.set("out_time_start",Y?ae(Y).format("h:mm A"):""),oe.set("out_time_end",H?ae(H).format("h:mm A"):""),await Yn(Ct.save,oe,t);const Oe={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:E||c?.logo||"",affliated_board_id:C?.value??c?.affliated_board_id??"",board_name:C?.label??c?.board_name??"",multiple_shift:v??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(Oe)),_.success("Organization settings saved.",{duration:1e3}),a.mutate?.()}catch(oe){_.error(oe?.response?.data?.msg??oe?.message??"Failed to save settings.",{duration:1500})}},ie=A==="Yes";return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx($t,{title:"Organization",actions:ve,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:n,onSubmit:re,children:[e.jsxs("div",{style:Ri,children:[e.jsx(J,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"Currency*",options:u,value:m,onChange:V=>h(V)}),e.jsx("input",{type:"hidden",name:"currency",value:m?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Default Country Code*",options:S,value:g,onChange:V=>I(V)}),e.jsx("input",{type:"hidden",name:"code",value:g?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Time Zone*",options:j,value:R,onChange:V=>D(V)}),e.jsx("input",{type:"hidden",name:"time_zone",value:R?.value??""})]}),e.jsx(J,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(J,{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(s.Radio.Group,{options:Ii,optionType:"button",buttonStyle:"solid",value:P,onChange:V=>N(V.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:P})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Weekly off Day",options:af,isMulti:!0,value:p,onChange:V=>b(V??[])}),p.map(V=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:V.value},V.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:k,onChange:V=>T(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:k?ae(k).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(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:$,onChange:V=>B(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:$?ae($).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(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:Y,onChange:V=>ne(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:Y?ae(Y).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(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:H,onChange:V=>W(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",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:"Salary Period"}),e.jsx(s.Radio.Group,{options:Di,optionType:"button",buttonStyle:"solid",value:L,onChange:V=>U(V.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:L})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(s.Radio.Group,{options:Ii,optionType:"button",buttonStyle:"solid",value:A,onChange:V=>O(V.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(s.Radio.Group,{options:Di,optionType:"button",buttonStyle:"solid",value:v,onChange:V=>M(V.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:v})]}),ie?e.jsx(J,{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(s.Divider,{}),e.jsxs("div",{style:Ri,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(an,{token:t,action:Do(),value:E,accept:"image/*",onChange:V=>F(V)}),e.jsx("input",{type:"hidden",name:"logo",value:E??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Select Affiliated Board",options:w,value:C,onChange:V=>f(V)}),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(kt,{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(an,{token:t,action:Jy(),value:q,accept:".json",onChange:V=>z(V)}),e.jsx("input",{type:"hidden",name:"json_file",value:q??""})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function df({token:t}){return e.jsx(lf,{token:t})}const wa=ot.academicYear,cf=({token:t,page:n=1,perPage:a=10})=>Io({baseUrl:wa.table,token:t,page:n,perPage:a}),uf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},pf=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:[],mf=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function yf({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(()=>{const p=ae(),b=ae().add(1,"year");return`${p.format("YYYY")}-${b.format("YYYY")}`}),[c,x]=i.useState(ae()),[y,u]=i.useState(ae().add(1,"year")),{isLoading:S,data:j,mutate:w}=cf({token:t,page:n.page,perPage:n.rowsPerPage}),m=i.useMemo(()=>pf(j),[j]),h=i.useMemo(()=>mf(j,m.length),[j,m.length]),g=async()=>{if(!l){_.error("Session name is required.");return}if(y&&c&&ae(y).isBefore(c)){_.error("End date must be after start date.");return}try{const p=new FormData;p.set("name",l),p.set("start_date",c?ae(c).format("YYYY-MM-DD"):""),p.set("end_date",y?ae(y).format("YYYY-MM-DD"):""),await Yn(wa.add,p,t),_.success("Academic year added.",{duration:1e3}),o(!1),w?.()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add academic year.",{duration:1500})}},I=async p=>{try{const b=new FormData;b.set("session",String(p)),await To(wa.setActive,b,t);const A=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...A,session_id:String(p)})),_.success("Academic year activated.",{duration:1e3}),w?.()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to activate academic year.",{duration:1500})}},R=async p=>{try{await w(zs(wa.remove,p,t)),_.success("Academic year deleted.",{duration:1e3})}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to delete academic year.",{duration:1500})}},D=()=>{const p=new Blob([JSON.stringify(m,null,2)],{type:"application/json"}),b=URL.createObjectURL(p),A=document.createElement("a");A.href=b,A.download="academic-years.json",A.click(),URL.revokeObjectURL(b)},C=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(X.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:()=>w?.()},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:D,disabled:m.length===0}],[m.length,w]),f=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:(p,b)=>{const A=b.status==="Active";return e.jsxs("span",{children:[e.jsx(s.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."):I(b.id)},okText:"Yes",cancelText:"No",children:e.jsx(s.Switch,{checked:A})}),A&&e.jsx(s.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(p,b)=>e.jsx(s.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>R(b.id),okText:"Yes",cancelText:"No",children:e.jsx(s.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,m.length]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx($t,{title:"Academic Year",actions:C,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(s.Table,{rowKey:"id",dataSource:m,columns:f,loading:S,pagination:{current:n.page,pageSize:n.rowsPerPage,total:h,showSizeChanger:!0,onChange:(p,b)=>a({page:p,rowsPerPage:Number(b)})}})})}),e.jsx(s.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:uf,children:[e.jsx(J,{label:"Session Name*",value:l,onChange:p=>d(p.target.value)}),e.jsxs("div",{children:[e.jsx(gt,{Desplay:"Start Date*",value:c,onChange:p=>x(p),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?ae(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(gt,{Desplay:"End Date*",value:y,onChange:p=>u(p),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:y?ae(y).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ce,{value:"Submit",type:"button",onClick:g}),e.jsx(s.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function ff({token:t}){return e.jsx(yf,{token:t})}const ko=ot.feeReceiptSetting,hf=({token:t})=>dt({url:ko.get,token:t}),ys={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},gf=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 xf({token:t}){const n=i.useRef(null),a=hf({token:t}),r=i.useMemo(()=>gf(a.data),[a.data]),[o,l]=i.useState(""),[d,c]=i.useState(!1),[x,y]=i.useState(!1),[u,S]=i.useState(!1),[j,w]=i.useState("0"),[m,h]=i.useState("0"),[g,I]=i.useState("0"),[R,D]=i.useState(!1),[C,f]=i.useState(!1),[p,b]=i.useState(""),[A,O]=i.useState(!1),L=()=>{l(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),y(String(r?.address??"0")==="1"),S(String(r?.gardian_name??"0")==="1"),w(String(r?.authorized_signatory??"0")),h(String(r?.parent_signatory??"0")),I(String(r?.dynamic_qr_code_device??"0")),D(String(r?.sequence_payment??"0")==="1"),f(String(r?.previois_fees??"0")==="1"),b(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&L()},[r]);const U=()=>{n.current?.reset?.(),L()},v=()=>{const N={number_of_receipt:o,rollnumber:d?1:0,address:x?1:0,gardianname:u?1:0,authorizedsignatory:j,parentsignatory:m,dynamic_qr_code_device:g,sequence_payment:R?1:0,previois_fees:C?1:0,upfront_payment_months:p},E=new Blob([JSON.stringify(N,null,2)],{type:"application/json"}),F=URL.createObjectURL(E),q=document.createElement("a");q.href=F,q.download="fee-receipt-setting.json",q.click(),URL.revokeObjectURL(F)},M=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:U},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:v,disabled:!r}],[r,o,d,x,u,j,m,g,R,C,p]),P=async N=>{N.preventDefault(),O(!0);try{const E=new FormData;E.set("number_of_receipt",String(o??"")),E.set("rollnumber",d?"1":"0"),E.set("address",x?"1":"0"),E.set("gardianname",u?"1":"0"),E.set("authorizedsignatory",String(j??"0")),E.set("parentsignatory",String(m??"0")),E.set("dynamic_qr_code_device",String(g??"0")),E.set("sequence_payment",R?"1":"0"),E.set("previois_fees",C?"1":"0"),E.set("upfront_payment_months",String(p??"")),await Yn(ko.save,E,t),_.success("Fee receipt settings updated.",{duration:1e3}),a.mutate?.()}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to update settings.",{duration:1500})}finally{O(!1)}};return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx($t,{title:"Fee Receipt Setting",actions:M,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:n,onSubmit:P,children:[e.jsxs("div",{style:ys,children:[e.jsx(J,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:N=>l(N.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(s.Checkbox,{checked:d,onChange:N=>c(N.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(s.Checkbox,{checked:x,onChange:N=>y(N.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(s.Checkbox,{checked:u,onChange:N=>S(N.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:ys,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(s.Radio.Group,{value:j,onChange:N=>w(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.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(s.Radio.Group,{value:m,onChange:N=>h(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.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(s.Radio.Group,{value:g,onChange:N=>I(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:ys,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(s.Checkbox,{checked:R,onChange:N=>D(N.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(s.Checkbox,{checked:C,onChange:N=>f(N.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(J,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:p,onChange:N=>b(N.target.value)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:A?"Updating...":"Done",disabled:A})})]})})})]})}function bf({token:t}){return e.jsx(xf,{token:t})}const Pn=ot.marksheetSetting,Sf=({token:t})=>dt({url:Pn.templateTypes,token:t}),jf=({token:t})=>dt({url:Pn.classDropdown,token:t}),vf=({token:t})=>dt({url:Pn.assignedTable,token:t}),_f={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},ki=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:[]:[],wf=Array.from({length:12},(t,n)=>({value:String(n+1),label:`Design ${n+1}`})),Cf=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function Af({token:t}){const n=i.useRef(null),a=Sf({token:t}),r=jf({token:t}),o=vf({token:t}),l=i.useMemo(()=>ki(a.data),[a.data]),d=i.useMemo(()=>ki(r.data),[r.data]),c=i.useMemo(()=>Cf(o.data),[o.data]),[x,y]=i.useState(null),[u,S]=i.useState(null),[j,w]=i.useState([]),m=()=>{n.current?.reset?.(),y(null),S(null),w([])},h=()=>{const C=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),f=URL.createObjectURL(C),p=document.createElement("a");p.href=f,p.download="marksheet-templates.json",p.click(),URL.revokeObjectURL(f)},g=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:m},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:h,disabled:c.length===0}],[c.length]),I=async C=>{if(C.preventDefault(),!x?.value){_.error("Select marksheet type.",{duration:1200});return}if(!u?.value){_.error("Select design.",{duration:1200});return}if(!j?.length){_.error("Select at least one class.",{duration:1200});return}try{const f=new FormData;f.set("temp_id",String(x.value)),f.set("ui_id",String(u.value)),j.forEach(p=>f.append("class_id[]",String(p))),await Yn(Pn.assign,f,t),_.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),m()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to assign template.",{duration:1500})}},R=async C=>{try{await zs(Pn.remove,C,t),_.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to remove template.",{duration:1500})}},D=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,f)=>e.jsx(lt,{id:f?.id,funcName:R})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx($t,{title:"Marksheet Setting",actions:g,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:n,onSubmit:I,children:[e.jsxs("div",{style:_f,children:[e.jsxs("div",{children:[e.jsx(ee,{label:"Select Marksheet Type",options:l,value:x,onChange:C=>y(C)}),e.jsx("input",{type:"hidden",name:"temp_id",value:x?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Select Design",options:wf,value:u,onChange:C=>S(C)}),e.jsx("input",{type:"hidden",name:"ui_id",value:u?.value??""})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(s.Checkbox.Group,{options:d,value:j,onChange:C=>w(C)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save"})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(s.Table,{size:"small",rowKey:"id",columns:D,dataSource:c,pagination:!1})})]})})]})}function Tf({token:t}){return e.jsx(Af,{token:t})}const fs={fetch:`${ot.legalPages.get}?page_name=terms`,save:ot.legalPages.termsSave,fieldName:"terms_data"};function Rf({token:t}){return e.jsx(Ys,{token:t,title:"Terms",fetchUrl:fs.fetch,saveUrl:fs.save,fieldName:fs.fieldName})}function If({token:t}){return e.jsx(Rf,{token:t})}const hs={fetch:`${ot.legalPages.get}?page_name=privacy`,save:ot.legalPages.privacySave,fieldName:"privacy_data"};function Df({token:t}){return e.jsx(Ys,{token:t,title:"Privacy",fetchUrl:hs.fetch,saveUrl:hs.save,fieldName:hs.fieldName})}function kf({token:t}){return e.jsx(Df,{token:t})}const gs={fetch:`${ot.legalPages.get}?page_name=about_us`,save:ot.legalPages.aboutSave,fieldName:"about_data"};function Of({token:t}){return e.jsx(Ys,{token:t,title:"About",fetchUrl:gs.fetch,saveUrl:gs.save,fieldName:gs.fieldName})}function Pf({token:t}){return e.jsx(Of,{token:t})}const Ws=ot.feesInfo,Ef=({token:t})=>dt({url:Ws.get,token:t}),Mf=({token:t})=>dt({url:Ws.statesDropdown,token:t}),xs={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Ff=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,Nf=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],$f=t=>t?Ao(`branch/logo/${t}`):"",bs=t=>t?Ao(`branch/signature/${t}`):"";function Uf({token:t}){const n=i.useRef(null),a=Ef({token:t}),r=Mf({token:t}),o=i.useMemo(()=>Ff(a.data),[a.data]),l=i.useMemo(()=>Nf(r.data),[r.data]),[d,c]=i.useState(null),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(""),[m,h]=i.useState(""),g=p=>{const b=new FormData(p),A=Object.fromEntries(b.entries());return A.state_id=d?.value??"",A.fees_receipt_logo=x,A.manager_signature=u,A.principal_signature=j,A.stamp=m,A},I=()=>{c(l.find(p=>String(p?.value)===String(o?.state_id??""))??null),y(o?.fees_receipt_logo??""),S(o?.manager_signature??""),w(o?.principal_signature??""),h(o?.stamp??"")};i.useEffect(()=>{o&&I()},[o,l]);const R=()=>{n.current?.reset?.(),I()},D=()=>{const p=g(n.current),b=new Blob([JSON.stringify(p,null,2)],{type:"application/json"}),A=URL.createObjectURL(b),O=document.createElement("a");O.href=A,O.download="fees-info.json",O.click(),URL.revokeObjectURL(A)},C=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:R},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:D,disabled:!o}],[o,d,x,u,j,m]),f=async p=>{p.preventDefault();try{const b=g(p.target);await Yy(Ws.save,b,t),_.success("Fees info saved.",{duration:1e3}),a.mutate?.()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to save fees info.",{duration:1500})}};return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx($t,{title:"Fees Info",actions:C,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:n,onSubmit:f,children:[e.jsxs("div",{style:xs,children:[e.jsx(J,{name:"Bussiness_name",label:"Business Name*",defaultValue:o?.name??"",required:!0}),e.jsx(J,{name:"cin",label:"Sub Heading",defaultValue:o?.cin??""}),e.jsx(J,{name:"school_no",type:"number",label:"School Number",defaultValue:o?.school_no??""}),e.jsx(J,{name:"website",label:"Website",defaultValue:o?.website??""}),e.jsx(J,{name:"school_Code",label:"School Code",defaultValue:o?.school_Code??""}),e.jsx(J,{name:"offical_number",label:"Official Number",defaultValue:o?.offical_number??""}),e.jsx(J,{name:"email_id",label:"Email",defaultValue:o?.email_id??""}),e.jsx(J,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:o?.receipt_prefix??""}),e.jsx(J,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:o?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"State",options:l,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(J,{name:"affiliation_no",label:"Affiliation Number",defaultValue:o?.affiliation_no??""}),e.jsx(J,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:o?.affiliation_desc??""}),e.jsx(J,{name:"udise_code",label:"UDISE Code",defaultValue:o?.udise_code??""}),e.jsx(J,{name:"color_code",label:"Primary Color",defaultValue:o?.color_code??""}),e.jsx(J,{name:"fontcolor_code",label:"Font Color",defaultValue:o?.fontcolor_code??""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:xs,children:[e.jsx(kt,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(kt,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:xs,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(an,{token:t,action:Do(),value:x,previewUrl:$f(x),accept:"image/*",onChange:y}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:x})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(an,{token:t,action:ms(),value:u,previewUrl:bs(u),accept:"image/*",onChange:S}),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(an,{token:t,action:ms(),value:j,previewUrl:bs(j),accept:"image/*",onChange:w}),e.jsx("input",{type:"hidden",name:"principal_signature",value:j})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(an,{token:t,action:ms(),value:m,previewUrl:bs(m),accept:"image/*",onChange:h}),e.jsx("input",{type:"hidden",name:"stamp",value:m})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save"})})]})})})]})}function Bf({token:t}){return e.jsx(Uf,{token:t})}const Ca=ot.payrollSettings,Lf=({token:t,page:n=1,perPage:a=10})=>Io({baseUrl:Ca.table,token:t,page:n,perPage:a}),qf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},An=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],Ss=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],zf=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Yf=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function Wf({token:t}){const n=i.useRef(null),a=i.useRef(null),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,x]=i.useState(null),[y,u]=i.useState(An[0]),[S,j]=i.useState(null),[w,m]=i.useState(null),[h,g]=i.useState(null),I=Lf({token:t,page:r.page,perPage:r.rowsPerPage}),R=i.useMemo(()=>zf(I.data),[I.data]),D=i.useMemo(()=>Yf(I.data,R.length),[I.data,R.length]),C=async U=>{U.preventDefault();try{const v=new FormData(U.target);v.set("type",y?.value??""),v.set("amount_type",S?.value??""),await Yn(Ca.add,v,t),_.success("Payroll setting added.",{duration:1e3}),I.mutate?.(),U.target.reset(),j(null),u(An[0])}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to add payroll setting.",{duration:1500})}},f=U=>{x(U),m(An.find(v=>v.value===U?.type)??null),g(Ss.find(v=>v.value===U?.amount_type)??null),d(!0)},p=async U=>{U.preventDefault();try{const v=new FormData(U.target);v.set("id",String(c?.id??"")),v.set("type",w?.value??""),v.set("amount_type",h?.value??""),await To(Ca.edit,v,t),_.success("Payroll setting updated.",{duration:1e3}),d(!1),I.mutate?.()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to update payroll setting.",{duration:1500})}},b=async U=>{try{await zs(Ca.remove,U,t),_.success("Payroll setting deleted.",{duration:1e3}),I.mutate?.()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to delete payroll setting.",{duration:1500})}},A=()=>{const U=new Blob([JSON.stringify(R,null,2)],{type:"application/json"}),v=URL.createObjectURL(U),M=document.createElement("a");M.href=v,M.download="payroll-settings.json",M.click(),URL.revokeObjectURL(v)},O=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(X.PlusOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:()=>I.mutate?.()},{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:A,disabled:R.length===0}],[R.length]),L=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,v)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>f(v)}),e.jsx(s.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>b(v.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx($t,{title:"Payroll Settings",actions:O,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:n,onSubmit:C,children:[e.jsxs("div",{style:qf,children:[e.jsx(J,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(ee,{label:"Type",options:An,value:y,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:y?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:Ss,value:S,onChange:j}),e.jsx("input",{type:"hidden",name:"amount_type",value:S?.value??""})]}),e.jsx(J,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(ce,{type:"submit",value:"Submit"})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(s.Table,{rowKey:"id",columns:L,dataSource:R,loading:I.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:D,showSizeChanger:!0,onChange:(U,v)=>o({page:U,rowsPerPage:Number(v)})}})})]})}),e.jsx(s.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:a,onSubmit:p,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"Type",options:An,value:w,onChange:m}),e.jsx("input",{type:"hidden",name:"type",value:w?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:Ss,value:h,onChange:g}),e.jsx("input",{type:"hidden",name:"amount_type",value:h?.value??""})]}),e.jsx(J,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Update"})})]})})})]})}function Vf({token:t}){return e.jsx(Wf,{token:t})}const Oo=ot.paymentGateway,Hf=({token:t})=>dt({url:Oo.get,token:t}),Kf=[{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"]}],Ut={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}},Oi=t=>{const n=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!n?.data)return Ut;try{const a=JSON.parse(n.data||"{}"),r=a?.data&&typeof a.data=="object"?a.data:a;return{Razorpay:{...Ut.Razorpay,...r?.Razorpay??{}},PhonePe:{...Ut.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...Ut.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...Ut.SabPaisa,...r?.SabPaisa??{}}}}catch{return Ut}};function Gf({token:t}){const n=i.useRef(null),a=Hf({token:t}),[r,o]=i.useState(Ut);i.useEffect(()=>{a.data&&o(Oi(a.data))},[a.data]);const l=(u,S,j)=>{o(w=>({...w,[u]:{...w[u],[S]:j}}))},d=()=>o(Oi(a.data)),c=()=>{const u=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),S=URL.createObjectURL(u),j=document.createElement("a");j.href=S,j.download="payment-gateway-settings.json",j.click(),URL.revokeObjectURL(S)},x=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:c}],[r,a.data]),y=async u=>{u.preventDefault();try{await Ro(Oo.save,{data:r},t),_.success("Payment gateway settings saved.",{duration:1e3}),a.mutate?.()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to save gateway settings.",{duration:1500})}};return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx($t,{title:"Payment Gateway",actions:x,children:e.jsxs("form",{ref:n,onSubmit:y,style:{display:"grid",gap:20},children:[Kf.map(u=>{const S=r[u.id]??{};return e.jsx(s.Card,{title:e.jsx(s.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(s.Switch,{checked:!!S.isActive,onChange:j=>l(u.id,"isActive",j)})]}),e.jsx(s.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:u.fields.map(j=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:j}),e.jsx(s.Input,{value:S[j]??"",type:j.toLowerCase().includes("secret")||j.toLowerCase().includes("password")?"password":"text",onChange:w=>l(u.id,j,w.target.value)})]},j))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ce,{type:"submit",value:"Save"})})]})})]})}function Jf({token:t}){return e.jsx(Gf,{token:t})}const Qf=({routes:t=[],onNavigate:n})=>e.jsx(s.Row,{gutter:[16,16],children:t.map((a,r)=>e.jsx(s.Col,{xs:24,md:8,lg:8,children:e.jsx(de,{children:e.jsx(Mi,{icon:a?.icon??"",title:a?.title??"",path:a?.path??"",onClick:n})})},`${r}route001`))});exports.About=Pf;exports.AcademicYear=ff;exports.Academics=Cm;exports.AddBook=Cc;exports.AddDriver=Sc;exports.AddStaff=Vu;exports.AdmissionEnquiry=Xd;exports.ApplyLeave=Dp;exports.AprroveLeaveRequest=_p;exports.AssignByClass=Xm;exports.AssignStudentToTransport=bc;exports.AssignSubjects=Gm;exports.AssignTimeGroup=iy;exports.AssignVehicles=oc;exports.AttendanceDashboard=pm;exports.BookList=Ac;exports.BuySellProduct=uu;exports.Category=eu;exports.Class=Nm;exports.CoScholasticArea=yy;exports.CreateTimeGroup=ty;exports.DailyAttendance=gm;exports.Department=Fp;exports.Designation=Up;exports.ErpDashboard=Mo;exports.FeeReceiptSetting=bf;exports.FeesInfo=Bf;exports.GeneralSetting=By;exports.Holidays=Wm;exports.IssueReturn=Rc;exports.LeaveType=Pp;exports.LibraryAssignStudent=Ic;exports.LibraryCategory=Dc;exports.LibraryRenewalReport=Oc;exports.LibraryReport=kc;exports.ManageStock=wu;exports.MarksheetSetting=Tf;exports.MenuSubmenu=Pd;exports.MonthlyReport=Sm;exports.Notes=by;exports.NpmReport=Du;exports.Organization=df;exports.PaymentGateway=Jf;exports.Payroll=xp;exports.PayrollReceiptDetails=Jp;exports.PayrollSettings=Vf;exports.Privacy=kf;exports.Products=Jc;exports.PromoteStudents=cy;exports.RoutePage=Qf;exports.RouteTimeTable=jc;exports.Sections=Om;exports.SellReports=ju;exports.Shift=qp;exports.StaffAttendance=dp;exports.StaffAttendanceReport=mp;exports.StaffDailyAttendance=Hp;exports.StaffDirectory=Qu;exports.StockReport=Iu;exports.Stoppage=_c;exports.StudentAttendance=ym;exports.SubCategory=iu;exports.Subjects=Lm;exports.Syllabus=Ry;exports.Terms=If;exports.TimeTable=Uy;exports.TransferCertificate=wy;exports.TransportRoutes=ec;exports.TransportVehicles=tc;exports.Unit=fu;exports.Vendor=Bc;exports.YearlyReport=wm;exports.setBaseUrl=xd;
|
|
61
|
+
`),"text/csv;charset=utf-8;",a)},am=({value:t,fileName:n})=>{So(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",n)};function jo({summary:t}){const n=[{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:n.map(a=>e.jsxs(s.Card,{size:"small",styles:{body:{padding:16}},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:8},children:a.label}),e.jsx("div",{style:{fontSize:24,fontWeight:700,color:a.color},children:t?.[a.key]??0})]},a.key))})}function ln({summary:t,title:n="Attendance Overview"}){const a=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(...a.map(o=>o.value),1);return e.jsx(s.Card,{size:"small",title:n,children:e.jsx("div",{style:{display:"grid",gap:12},children:a.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 sm(){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(s.Space,{wrap:!0,size:[12,8],children:t.map(n=>e.jsxs(s.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:n.label}),n.node]},n.label))})}function Et({items:t}){const n=Array.isArray(t)?t.filter(a=>a?.value):[];return n.length?e.jsx(s.Space,{wrap:!0,size:[8,8],children:n.map(a=>e.jsxs(s.Tag,{color:"blue",children:[a.label,": ",a.value]},a.label))}):null}function Ua({title:t,subtitle:n,printRef:a,exportRows:r,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:x,chartContent:y,reportTitle:u,reportExtra:S,children:j,fileBaseName:w="attendance"}){const m=dn.useReactToPrint({content:()=>a?.current});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsxs("div",{children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:t}),n?e.jsx(s.Typography.Text,{type:"secondary",style:{display:"block",marginTop:4},children:n}):null]}),extra:e.jsx($t,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>nm({rows:r,columns:o,fileName:`${w}.csv`}),onPrint:m,onDownload:()=>am({value:r,fileName:`${w}.json`}),onRefresh:l}),children:c}),e.jsx(jo,{summary:x}),y===!1?null:y||e.jsx(ln,{summary:x}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:u}),extra:S,children:j})]})}const rm=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function im({rows:t,loading:n,sunday:a,holiday:r,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(y,u)=>{const S=(Array.isArray(t)?t:[]).map((j,w)=>(j?.student_session_id??j?.student_id??j?.id??w)===y?{...j,...u}:j);l?.(S)},x=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(y,u,S)=>S+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:(y,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(y,u,S)=>{const j=u?.student_session_id??u?.student_id??u?.id??S;return e.jsx(s.Select,{size:"small",style:{width:"100%"},options:rm,value:String(y??"1"),onChange:w=>c(j,{attendence_type_id:w})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:y=>y?ae(y).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:(y,u)=>e.jsx(s.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(X.ClockCircleOutlined,{}),onClick:()=>d?.(u),children:"E.L"})}],[d,t]);return a?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(s.Table,{bordered:!0,size:"small",rowKey:(y,u)=>String(y?.student_session_id??y?.student_id??y?.id??u),columns:x,dataSource:Array.isArray(t)?t:[],loading:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function om({rows:t,loading:n,sunday:a,holiday:r,holidayTitle:o}){const l=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,x)=>x+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=>Bs(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 a?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(s.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:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function lm({data:t,loading:n,onViewStudent:a}){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),x=i.useMemo(()=>{const y=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,S)=>e.jsx(s.Button,{type:"link",style:{padding:0},onClick:()=>a?.(S),children:S?.student_name??S?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{y.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(S,j)=>{const m=j?.[`${j?.student_id}_${o.indexOf(j)}`]?.[u]??{},h=m?.attendance_date,g=l.find(I=>I?.date===h);return d.includes(h)?vr("sunday","W"):g?vr("holiday","H"):Bs(m?.attendence_type_id)}})}),y.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,S)=>{let j=0,w=0,m=0;return[...new Array(c).keys()].forEach(h=>{const g=S?.[`${S?.student_id}_${o.indexOf(S)}`]?.[h]??{},I=String(g?.attendence_type_id??"");I==="1"&&(j+=1),I==="4"&&(w+=1),I==="3"&&(m+=1)}),e.jsxs("span",{children:["P: ",j," A: ",w," L: ",m]})}}),y},[l,a,o,d,c]);return e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(y,u)=>String(y?.student_id??u),columns:x,dataSource:o,loading:n,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(s.Empty,{description:"No monthly report found"})}})}function dm({open:t,onClose:n,loading:a,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,x)=>Bs(x?.attendence_type_id??x?.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(s.Modal,{open:t,onCancel:n,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(c,x)=>String(c?.attendance_date??x),columns:d,dataSource:l,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function cm({open:t,onClose:n,onSubmit:a,loading:r}){const[o,l]=s.Modal.useModal(),[d,c]=i.useState(null),[x,y]=i.useState(""),u=async()=>{if(!d){await o.warning({title:"Select time"});return}await a?.({outtime:d.format("h:mm a"),message:x}),c(null),y("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(s.Modal,{title:"Emergency Leave",open:t,onCancel:n,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(s.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(s.Input.TextArea,{rows:4,value:x,onChange:S=>y(S.target.value)})]})]})})]})}const vo=t=>em(t),ci=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n.reduce((a,r)=>({present:a.present+Number(r?.present??r?.Present??r?.total_present??0),absent:a.absent+Number(r?.absent??r?.Absent??r?.total_absent??0),late:a.late+Number(r?.late??r?.Late??0),leave:a.leave+Number(r?.leave??r?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(n?.present??n?.Present??n?.total_present??0),absent:Number(n?.absent??n?.Absent??n?.total_absent??0),late:Number(n?.late??n?.Late??0),leave:Number(n?.leave??n?.Leave??0)}};function um({token:t}){const{data:n}=G(t?[wt.dashboard.monthlyGraph,t]:null,([l,d])=>Pt(l,d)),{data:a}=G(t?[wt.dashboard.weeklyGraph,t]:null,([l,d])=>Pt(l,d)),r=i.useMemo(()=>ci(n),[n]),o=i.useMemo(()=>ci(a),[a]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(s.Card,{children:[e.jsx(s.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(s.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(jo,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(ln,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(ln,{summary:o,title:"Weekly Attendance Chart"})]})]})}const cs=wt.studentAttendance,pm={width:"100%",height:40};function mm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(""),[m,h]=i.useState(ae()),[g,I]=i.useState(0),[R,D]=i.useState([]),[C,f]=i.useState(!1),[p,b]=i.useState(null),[A,O]=i.useState(!1),[L,U]=i.useState(!1),v=Na(t),M=$a(a,t),P=i.useMemo(()=>!a||!d||g===0?null:Pn(cs.list,{cID:a,sID:d,batch_id:u,date:m.format("YYYY-MM-DD")}),[u,a,m,g,d]),{data:N,isLoading:E,mutate:F}=G(t&&P?[P,t]:null,([W,Z])=>Pt(W,Z));i.useEffect(()=>{D(bo(N,"student"))},[N]);const q=N?.data?.data??N?.data??N??{},z=!!q?.sunday,k=!!q?.holiday?.holiday,T=q?.holiday?.title??"",$=i.useMemo(()=>vo(R),[R]),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"}],[]),Y=async()=>{if(R.length)try{U(!0),await Jp(cs.save,{attendenceData:R,date:m.format("YYYY-MM-DD"),holiday:C?"YES":"NO"},t),_.success("Student attendance saved."),F?.()}catch(W){_.error(W?.message??"Failed to save attendance.")}finally{U(!1)}},ne=async({outtime:W,message:Z})=>{if(p?.attendence_id)try{O(!0),await Qp(cs.emergencyLeave,{outtime:W,message:Z,id:p.attendence_id},t),_.success("Emergency leave updated."),b(null),F?.()}catch(se){_.error(se?.message??"Failed to update emergency leave.")}finally{O(!1)}},H=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(ee,{options:v.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:W=>{r(W?.value??""),l(W?.label??""),c(""),y(""),S(""),w("")},required:!0}),e.jsx(ee,{options:M.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:W=>{c(W?.value??""),y(W?.label??""),S(""),w("")},required:!0},`section-${a}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{value:m,onChange:W=>W&&h(W),style:pm,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>I(W=>W+1)})})]}),e.jsx(Et,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:m.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{}),e.jsx(Ua,{title:"Student Attendance",printRef:n,exportRows:R,exportColumns:B,onRefresh:()=>F?.(),filterSection:H,summary:$,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{size:"small",type:C?"primary":"default",onClick:()=>f(W=>!W),children:C?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"primary",onClick:Y,loading:L,disabled:!R.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ct,{}),e.jsx(s.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(s.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Et,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:m.format("DD-MM-YYYY")}]})})]}),e.jsx(im,{rows:R,loading:E,sunday:z,holiday:k,holidayTitle:T,onChangeRows:D,onEmergency:b})]})}),e.jsx(cm,{open:!!p,onClose:()=>b(null),onSubmit:ne,loading:A})]})}const ym=wt.dailyAttendance,fm={width:"100%",height:40};function hm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(ae()),[m,h]=i.useState(0),g=Na(t),I=$a(a,t),R=i.useMemo(()=>!a||!d||m===0?null:Pn(ym.list,{cID:a,sID:d,batch_id:u,date:j.format("YYYY-MM-DD")}),[u,a,j,m,d]),{data:D,isLoading:C,mutate:f}=G(t&&R?[R,t]:null,([P,N])=>Pt(P,N)),p=i.useMemo(()=>bo(D,"student"),[D]),b=D?.data?.data??D?.data??D??{},A=!!b?.sunday,O=!!b?.holiday?.holiday,L=b?.holiday?.title??"",U=i.useMemo(()=>vo(p),[p]),v=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"}],[]),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(ee,{options:g.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:P=>{r(P?.value??""),l(P?.label??""),c(""),y(""),S(""),setBatchLabel("")},required:!0}),e.jsx(ee,{options:I.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:P=>{c(P?.value??""),y(P?.label??""),S(""),setBatchLabel("")},required:!0},`section-${a}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{value:j,onChange:P=>P&&w(P),style:fm,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>h(P=>P+1)})})]}),e.jsx(Et,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:j.format("DD-MM-YYYY")}]})]});return e.jsx(Ua,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:n,exportRows:p,exportColumns:v,onRefresh:()=>f?.(),filterSection:M,summary:U,chartContent:e.jsx(ln,{summary:U,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ct,{}),e.jsx(Et,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:j.format("DD-MM-YYYY")}]})]}),e.jsx(om,{rows:p,loading:C,sunday:A,holiday:O,holidayTitle:L})]})})}const ui=wt.monthlyReport,gm=t=>{const n=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],a=Number(t?.totalDaysMonth??0),r={present:0,absent:0,late:0,leave:0};return n.forEach((o,l)=>{[...new Array(a).keys()].forEach(d=>{const c=o?.[`${o?.student_id}_${l}`]?.[d]??{},x=String(c?.attendence_type_id??"");x==="1"&&(r.present+=1),x==="4"&&(r.absent+=1),x==="3"&&(r.late+=1),x==="2"&&(r.leave+=1)})}),r},xm=t=>{const n=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],a=Number(t?.totalDaysMonth??0);return n.map((r,o)=>{let l=0,d=0,c=0;return[...new Array(a).keys()].forEach(x=>{const y=r?.[`${r?.student_id}_${o}`]?.[x]??{},u=String(y?.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 bm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(""),[m,h]=i.useState(String(new Date().getFullYear())),[g,I]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[R,D]=i.useState(0),[C,f]=i.useState(null),p=Na(t),b=$a(a,t),A=i.useMemo(()=>Ms(Number(m)),[m]),O=i.useMemo(()=>Es(10),[]),L=i.useMemo(()=>!a||!d||!m||!g||R===0?null:Pn(ui.table,{session:li(),class_id:a,section_id:d,year:m,month:g,batch_id:u}),[u,a,g,R,d,m]),{data:U,isLoading:v,mutate:M}=G(t&&L?[L,t]:null,([$,B])=>Pt($,B)),P=U?.data?.data??U?.data??U??{},N=i.useMemo(()=>gm(P),[P]),E=i.useMemo(()=>xm(P),[P]),F=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"}],[]),q=i.useMemo(()=>C?.student_id?Pn(ui.byStudent,{student_id:C.student_id,month:g,year:m,session:li()}):null,[g,C,m]),{data:z,isLoading:k}=G(t&&q?[q,t]:null,([$,B])=>Pt($,B)),T=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(ee,{options:p.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{r($?.value??""),l($?.label??""),c(""),y(""),S(""),w("")},required:!0}),e.jsx(ee,{options:b.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{c($?.value??""),y($?.label??""),S(""),w("")},required:!0},`section-${a}`),e.jsx(ee,{options:O,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:O.find($=>String($?.value)===String(m))??null,onChange:$=>h(String($?.value??"")),required:!0}),e.jsx(ee,{options:A,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:A.find($=>String($?.value)===String(g))??null,onChange:$=>I(String($?.value??"").padStart(2,"0")),required:!0},`month-${m}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>D($=>$+1)})})]}),e.jsx(Et,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Month",value:A.find($=>String($?.value)===String(g))?.label??g},{label:"Year",value:m}]}),e.jsx(sm,{})]});return e.jsxs(e.Fragment,{children:[e.jsx(Ua,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:n,exportRows:E,exportColumns:F,onRefresh:()=>M?.(),filterSection:T,summary:N,chartContent:e.jsx(ln,{summary:N,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ct,{}),e.jsx(Et,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Month",value:A.find($=>String($?.value)===String(g))?.label??g},{label:"Year",value:m}]})]}),e.jsx(lm,{data:P,loading:v,onViewStudent:f})]})}),e.jsx(dm,{open:!!C,onClose:()=>f(null),loading:k,data:z,studentName:C?.student_name??C?.full_name})]})}const Sm=wt.yearlyReport,jm=t=>{const n=t?.data?.data??t?.data??t??{};return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:Array.isArray(n?.students)?n.students:Array.isArray(n?.report)?n.report:[]},vm=t=>(Array.isArray(t)?t:[]).reduce((n,a)=>({present:n.present+Number(a?.singleStudentPresentData??a?.present??0),absent:n.absent+Number(a?.singleStudentAbsentData??a?.absent??0),late:n.late+Number(a?.late??0),leave:n.leave+Number(a?.leave??0)}),{present:0,absent:0,late:0,leave:0});function _m({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(""),[m,h]=i.useState(""),[g,I]=i.useState(""),[R,D]=i.useState(0),C=Na(t),f=$a(a,t),p=tm(t),b=i.useMemo(()=>!a||!d||R===0?null:Pn(Sm.table,{class_id:a,section_id:d,session_id:u,batch_id:m}),[m,a,R,d,u]),{data:A,isLoading:O,mutate:L}=G(t&&b?[b,t]:null,([E,F])=>Pt(E,F)),U=i.useMemo(()=>jm(A),[A]),v=i.useMemo(()=>vm(U),[U]),M=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),P=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(E,F,q)=>q+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}],[]),N=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(ee,{options:C.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{r(E?.value??""),l(E?.label??""),c(""),y(""),h(""),I("")},required:!0}),e.jsx(ee,{options:f.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{c(E?.value??""),y(E?.label??""),h(""),I("")},required:!0},`section-${a}`),e.jsx(ee,{options:p.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{S(E?.value??""),w(E?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>D(E=>E+1)})})]}),e.jsx(Et,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Session",value:j}]})]});return e.jsx(Ua,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:n,exportRows:U,exportColumns:M,onRefresh:()=>L?.(),filterSection:N,summary:v,chartContent:e.jsx(ln,{summary:v,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ct,{}),e.jsx(Et,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Session",value:j}]})]}),e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(E,F)=>String(E?.student_id??E?.id??F),columns:P,dataSource:U,loading:O,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}function wm(){return null}const Ba=t=>t??localStorage.getItem("authToken")??"",Cm=(t,n)=>{const a=String(t??""),r=String(n);return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},_o=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",we={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"}},Am=()=>Cm(at(),we.uploadNotes),Tm=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Ba(r))},yt=async(t,n,a,{includeSession:r=!1}={})=>{const o=n instanceof FormData?n:new FormData;return r&&!o.has("session_id")&&o.append("session_id",_o()),Ye(t,o,Ba(a))},Mt=async(t,n,a,{includeSession:r=!1}={})=>{const o=n instanceof FormData?n:new FormData;return r&&!o.has("session_id")&&o.append("session_id",_o()),mt(t,o,Ba(a))},Ft=async(t,n,a)=>st(t,n,Ba(a)),va=we.master.sections,Yn=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>Tm({baseUrl:l,page:d,perPage:c},x)),Rm=({token:t,page:n=1,perPage:a=10})=>Yn({token:t,baseUrl:va.table,page:n,perPage:a}),Im=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Dm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),{data:x,isLoading:y,mutate:u}=Rm({token:t,page:n.page,perPage:n.perPage}),S=i.useMemo(()=>Im(x),[x]),j=i.useMemo(()=>x?.pagination?.total_rows??x?.pagination?.total??S.length??0,[x,S]),w=async R=>{R.preventDefault();const D=new FormData(R.target);try{await yt(va.add,D,t),_.success("Success! Added new item.",{duration:1e3}),R.target.reset(),u()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},m=async R=>{try{await Ft(va.remove,R,t),_.success("Success! Deleted item.",{duration:1e3}),u()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to delete the item.",{duration:1500})}},h=R=>{d(R),o(!0),c.setFieldsValue({section:R?.section??""})},g=async R=>{const D=new FormData;D.append("id",String(l?.id??"")),D.append("section",R.section??"");try{await Mt(va.edit,D,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})}},I=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(R,D)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(D)}),e.jsx(s.Popconfirm,{title:"Delete this section?",onConfirm:()=>m(D?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Section",open:r,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(s.Form,{form:c,layout:"vertical",onFinish:g,children:[e.jsx(s.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(s.Input,{placeholder:"Section Name"})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.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(J,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(de,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(s.Space,{}),children:e.jsx(s.Table,{rowKey:R=>R.id,columns:I,dataSource:S,loading:y,pagination:{current:n.page,pageSize:n.perPage,total:j,showSizeChanger:!0,onChange:(R,D)=>a({page:R,perPage:D})}})})]})}function km({token:t}){return e.jsx(Dm,{token:t})}const Rn=we.master.classes,Om=({token:t,page:n=1,perPage:a=10})=>Yn({token:t,baseUrl:Rn.table,page:n,perPage:a}),Pm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Em=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function Mm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[x]=s.Form.useForm(),{data:y}=G(t?[we.master.sections.list,t]:null,([A,O])=>Q(A,O)),u=i.useMemo(()=>Em(y),[y]),S=i.useMemo(()=>u.map(A=>({label:A.label??A.section??String(A.value??""),value:String(A.value??A.id??"")})),[u]),{data:j,isLoading:w,mutate:m}=Om({token:t,page:n.page,perPage:n.perPage}),h=i.useMemo(()=>Pm(j),[j]),g=i.useMemo(()=>j?.pagination?.total_rows??j?.pagination?.total??h.length??0,[j,h]),{data:I}=G(t&&l?[`${Rn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([A,O])=>Q(A,O)),R=i.useMemo(()=>{const A=I?.data??I;return Array.isArray(A)?A:Array.isArray(A?.data)?A.data:A?[A]:[]},[I]),D=A=>{const O=A?.id??A?.class_id;O&&(d(O),o(!0))};i.useEffect(()=>{if(!r||!R.length)return;const A=R[0],O=R.map(v=>v?.section_id??v?.fk_sectionId??v?.sectionId??v?.section).filter(v=>v!=null&&String(v).trim()!=="").map(v=>String(v)),L=Array.isArray(A?.section_ids)?A.section_ids.map(v=>String(v)):typeof A?.section_ids=="string"?A.section_ids.split(",").map(v=>v.trim()).filter(Boolean):Array.isArray(A?.section)?A.section.map(v=>String(v)):[],U=O.length?O:L;x.setFieldsValue({name:A?.class??A?.name??"",section:U})},[r,R,x]);const C=async A=>{const O=new FormData;O.append("name",A.name??""),(A.section??[]).forEach(L=>O.append("section[]",String(L)));try{await yt(Rn.add,O,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),m()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},f=async A=>{const O=new FormData;O.append("id",String(l??"")),O.append("name",A.name??""),(A.section??[]).forEach(L=>O.append("section[]",String(L)));try{await Mt(Rn.edit,O,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),m()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to update the item.",{duration:1500})}},p=async A=>{try{await Ft(Rn.remove,A,t),_.success("Success! Deleted item.",{duration:1e3}),m()}catch(O){_.error(O?.response?.data?.msg??O?.message??"Failed to delete the item.",{duration:1500})}},b=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(A,O)=>A??O?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:A=>A??""},{title:"Actions",key:"actions",width:120,render:(A,O)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(O)}),e.jsx(s.Popconfirm,{title:"Delete this class?",onConfirm:()=>p(O?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Class",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(s.Form,{form:x,layout:"vertical",onFinish:f,children:[e.jsx(s.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(s.Input,{placeholder:"Class"})}),e.jsx(s.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(s.Checkbox.Group,{options:S})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(s.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(s.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(s.Input,{placeholder:"Class"})}),e.jsx(s.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(s.Checkbox.Group,{options:S})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(s.Table,{rowKey:A=>A.id,columns:b,dataSource:h,loading:w,pagination:{current:n.page,pageSize:n.perPage,total:g,showSizeChanger:!0,onChange:(A,O)=>a({page:A,perPage:O})}})})]})}function Fm({token:t}){return e.jsx(Mm,{token:t})}const In=we.master.subjects,Nm=({token:t,page:n=1,perPage:a=10})=>Yn({token:t,baseUrl:In.table,page:n,perPage:a}),$m=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},pi=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],mi=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function Um({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[x]=s.Form.useForm(),{data:y,isLoading:u,mutate:S}=Nm({token:t,page:n.page,perPage:n.perPage}),j=i.useMemo(()=>$m(y),[y]),w=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??j.length??0,[y,j]),{data:m}=G(t&&l?[`${In.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,p])=>Q(f,p)),h=i.useMemo(()=>{const f=m?.data??m;return Array.isArray(f)?f[0]:f??null},[m]);i.useEffect(()=>{r&&h&&x.setFieldsValue({name:h?.name??"",subject_type:h?.subject_type??h?.type??"",type:"",subject_types:Array.isArray(h?.subject_types)?h.subject_types:typeof h?.subject_types=="string"?h.subject_types.split(",").map(f=>f.trim()).filter(Boolean):[],code:h?.code??""})},[r,h,x]);const g=async f=>{const p=f?.type??f?.subject_type??"",b={name:f?.name??"",subject_type:p,type:p,subject_types:Array.isArray(f?.subject_types)?f.subject_types:[],code:f?.code??""};try{await Ye(In.add,b,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),S()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},I=async f=>{const p=new FormData,b=f?.type??f?.subject_type??"";p.append("id",String(l??"")),p.append("name",f.name??""),p.append("subject_type",f.subject_type??""),p.append("subject_type",b),p.append("type",b),p.append("code",f.code??"");try{await Mt(In.edit,p,t),_.success("Success! Updated item.",{duration:1e3}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),S()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},R=async f=>{try{await Ft(In.remove,f,t),_.success("Success! Deleted item.",{duration:1e3}),S()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete the item.",{duration:1500})}},D=f=>{const p=f?.id;p&&(d(p),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:(f,p)=>{const b=[],A=p?.subject_types;Array.isArray(A)?A.forEach(M=>{const P=String(M??"").trim();P&&b.push(P)}):typeof A=="string"&&A.split(",").map(M=>M.trim()).filter(Boolean).forEach(M=>b.push(M));const O=["yes","1","true"].includes(String(p?.is_practical??"").toLowerCase()),L=["yes","1","true"].includes(String(p?.is_theory??"").toLowerCase());O&&b.push("Practical"),L&&b.push("Theory");const U=b.map(M=>String(M??"").trim()).filter(Boolean).map(M=>M.toLowerCase()==="practical"?"Practical":M.toLowerCase()==="theory"?"Theory":M),v=Array.from(new Set(U));return v.length?v.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(f,p)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(p)}),e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>R(p?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Subject",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(s.Form,{form:x,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(J,{placeholder:"Subject Name"})}),e.jsx(s.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(s.Radio.Group,{options:mi})}),e.jsx(s.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(s.Checkbox.Group,{options:pi})}),e.jsx(s.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(J,{placeholder:"Subject Code"})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(J,{placeholder:"Subject Name"})}),e.jsx(s.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(s.Radio.Group,{options:mi})}),e.jsx(s.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(s.Checkbox.Group,{options:pi})}),e.jsx(s.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(J,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(s.Table,{rowKey:f=>f.id,columns:C,dataSource:j,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:w,showSizeChanger:!0,onChange:(f,p)=>a({page:f,perPage:p})}})})]})}function Bm({token:t}){return e.jsx(Um,{token:t})}const Dn=we.master.holidays,Lm=({token:t,page:n=1,perPage:a=10})=>Yn({token:t,baseUrl:Dn.table,page:n,perPage:a}),qm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ra={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function zm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[x]=s.Form.useForm(),{data:y,isLoading:u,mutate:S}=Lm({token:t,page:n.page,perPage:n.perPage}),j=i.useMemo(()=>qm(y),[y]),w=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??j.length??0,[y,j]),{data:m}=G(t&&l?[`${Dn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,p])=>Q(f,p)),h=i.useMemo(()=>{const f=m?.data??m;return Array.isArray(f)?f[0]:f??null},[m]);i.useEffect(()=>{r&&h&&x.setFieldsValue({title:h?.holiday_title??"",description:h?.holiday_description??"",from:h?.start_date?ae(h.start_date):null,to:h?.end_date?ae(h.end_date):null})},[r,h,x]);const g=async f=>{const p=new FormData;p.append("title",f.title??""),p.append("description",f.description??""),p.append("from",f.from?ae(f.from).format("YYYY-MM-DD"):""),p.append("to",f.to?ae(f.to).format("YYYY-MM-DD"):"");try{await yt(Dn.add,p,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),S()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to add the new item.",{duration:1500})}},I=async f=>{const p=new FormData;p.append("id",String(l??"")),p.append("title",f.title??""),p.append("description",f.description??""),p.append("from",f.from?ae(f.from).format("YYYY-MM-DD"):""),p.append("to",f.to?ae(f.to).format("YYYY-MM-DD"):"");try{await Mt(Dn.edit,p,t,{includeSession:!0}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),S()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to update the item.",{duration:1500})}},R=async f=>{try{await Ft(Dn.remove,f,t),_.success("Success! Deleted item.",{duration:1e3}),S()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete the item.",{duration:1500})}},D=f=>{const p=f?.id;p&&(d(p),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:(f,p)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(p)}),e.jsx(s.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>R(p?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Holiday",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(s.Form,{form:x,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(J,{placeholder:"Holiday Title"})}),e.jsx(s.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(J,{placeholder:"Holiday Description"})}),e.jsx(s.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:ra})}),e.jsx(s.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:ra})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(J,{placeholder:"Holiday Title"})}),e.jsx(s.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(Ot,{placeholder:"Holiday Description"})}),e.jsx(s.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:ra})}),e.jsx(s.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:ra})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(s.Table,{rowKey:f=>f.id,columns:C,dataSource:j,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:w,showSizeChanger:!0,onChange:(f,p)=>a({page:f,perPage:p})}})})]})}function Ym({token:t}){return e.jsx(zm,{token:t})}const _a=we.assignSubjects,Wm=({token:t,page:n=1,perPage:a=50})=>Yn({token:t,baseUrl:_a.list,page:n,perPage:a}),yi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Vm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Hm({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState(!1),[y,u]=i.useState(!1),[S,j]=i.useState(null),[w,m]=i.useState([]),{data:h}=G(t?[we.master.classes.dropdown,t]:null,([P,N])=>Q(P,N)),{data:g}=G(t?[we.master.subjects.dropdown,t]:null,([P,N])=>Q(P,N)),I=i.useMemo(()=>yi(h),[h]),R=i.useMemo(()=>yi(g),[g]),D=i.useMemo(()=>R.map(P=>({label:P.label??P.subject??String(P.value??""),value:P.value??P.id})),[R]),{data:C,isLoading:f,mutate:p}=Wm({token:t,page:n.page,perPage:n.perPage}),b=i.useMemo(()=>Vm(C),[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??b.length??0,[C,b]),{data:O}=G(t&&S?[`${_a.editByClass}?class_id=${encodeURIComponent(String(S))}`,t]:null,([P,N])=>Q(P,N));i.useEffect(()=>{if(!y)return;const P=O?.data??O,N=Array.isArray(P)?P:Array.isArray(P?.data)?P.data:[];m(N.map(E=>E.subject_id).filter(Boolean))},[y,O]);const L=async P=>{if(P.preventDefault(),!r?.value){_.error("Please select class",{duration:1200});return}if(!l.length){_.error("Please select subjects",{duration:1200});return}const N=new FormData;N.append("class_id",String(r.value)),l.forEach(E=>N.append("subject[]",String(E)));try{x(!0),await Mt(_a.assign,N,t),_.success("Success! Updated item.",{duration:1e3}),o(null),d([]),p()}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to update the item.",{duration:1500})}finally{x(!1)}},U=P=>{P&&(j(P),u(!0))},v=async()=>{if(!S)return;if(!w.length){_.error("Please select subjects",{duration:1200});return}const P=new FormData;P.append("class_id",String(S)),w.forEach(N=>P.append("subject[]",String(N)));try{await Mt(_a.update,P,t),_.success("Success! Updated item.",{duration:1e3}),u(!1),j(null),p()}catch(N){_.error(N?.response?.data?.msg??N?.message??"Failed to update the item.",{duration:1500})}},M=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(P,N)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(N?.subject_name??P??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(P,N)=>e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>U(N?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Assigned Subjects",open:y,onClose:()=>{u(!1),j(null)},width:520,extra:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>u(!1),children:"Cancel"}),e.jsx(s.Button,{type:"primary",onClick:v,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:I.find(P=>String(P.value)===String(S))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(s.Checkbox.Group,{options:D,value:w,onChange:m})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),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(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:P=>o(P??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(s.Checkbox.Group,{options:D,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(s.Table,{rowKey:P=>P.id,columns:M,dataSource:b,loading:f,pagination:{current:n.page,pageSize:n.perPage,total:A,showSizeChanger:!0,onChange:(P,N)=>a({page:P,perPage:N})}})})]})}function Km({token:t}){return e.jsx(Hm,{token:t})}const nn=we.assignByClass,wo=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[]},vn=t=>wo(t),Gm=t=>wo(t),_n=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Jm({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,x]=i.useState("No"),[y,u]=i.useState([]),[S,j]=i.useState([]),[w,m]=i.useState(null),[h,g]=i.useState(null),[I,R]=i.useState(!1),[D,C]=i.useState(""),{data:f}=G(t?[nn.teacherDropdown,t]:null,([ie,V])=>Q(ie,V)),{data:p}=G(t?[we.master.classes.dropdown,t]:null,([ie,V])=>Q(ie,V)),{data:b}=G(t&&h?[h,t]:null,([ie,V])=>Q(ie,V)),{data:A}=G(t&&w?[w,t]:null,([ie,V])=>Q(ie,V)),O=i.useMemo(()=>vn(f),[f]),L=i.useMemo(()=>vn(p),[p]),U=i.useMemo(()=>vn(b),[b]),v=i.useMemo(()=>vn(A),[A]),{data:M}=G(t&&n&&r&&l?[`${nn.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(n))}&class_id=${encodeURIComponent(String(r))}§ion_id=${encodeURIComponent(String(l))}`,t]:null,([ie,V])=>Q(ie,V)),P=M?.data??M??null;i.useEffect(()=>{P&&(u(Array.isArray(P?.subject_ids)?P.subject_ids:[]),x(P?.isClassTeacher||"No"),j([]))},[P]);const{data:N}=G(t?[nn.classWithSection,t]:null,([ie,V])=>Q(ie,V)),E=i.useMemo(()=>vn(N),[N]),[F,q]=i.useState(null),[z,k]=i.useState({page:1,perPage:25});i.useEffect(()=>{F||E?.[0]&&q(`${E[0].class_id}val${E[0].section_id}`)},[E,F]);const T=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),$=i.useMemo(()=>{if(!F)return null;const[ie,V]=String(F).split("val");if(!ie||!V)return null;const oe=z.page??1,Ce=z.perPage??25;return`${nn.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(oe))}&per_page=${encodeURIComponent(String(Ce))}&session_id=${encodeURIComponent(String(T))}&class_id=${encodeURIComponent(String(ie))}§ion_id=${encodeURIComponent(String(V))}`},[F,z.page,z.perPage,T]),{data:B,isLoading:Y,mutate:ne}=G(t&&$?[$,t]:null,([ie,V])=>Q(ie,V),{revalidateOnFocus:!1}),H=i.useMemo(()=>Gm(B),[B]),W=i.useMemo(()=>{const ie=B?.pagination??B?.data?.pagination??B?.data?.data?.pagination;return ie?.total_rows??ie?.total??H.length??0},[B,H]),Z=async ie=>{if(ie.preventDefault(),C(""),!n||!r||!l){_.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(y)||y.length===0){C("error"),_.error("Please Select Subject",{duration:1200});return}const V=new FormData;V.append("teacher_id",String(n)),V.append("class_id",String(r)),V.append("section_id",String(l)),V.append("isClassTeacher",String(c??"No")),_n(y).forEach(oe=>V.append("subject_ids[]",String(oe))),_n(S).forEach(oe=>V.append("delete_subject[]",String(oe)));try{await yt(nn.assignClassToTeacher,V,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),C(""),ne()}catch(oe){_.error(oe?.response?.data?.msg??oe?.message??"Failed to add the new item.",{duration:1500})}},se=async ie=>{try{await Ft(nn.deleteTeacherSub,ie,t),_.success("Success! Deleted item.",{duration:1e3}),ne()}catch(V){_.error(V?.response?.data?.msg??V?.message??"Failed to delete the item.",{duration:1500})}},pe=ie=>{const V=Array.isArray(ie?.child)?ie.child:[],oe=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Ce,Oe)=>e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>se(Oe?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(s.Table,{columns:oe,bordered:!0,size:"small",dataSource:V,pagination:!1,rowKey:Ce=>Ce.id})})},ve=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(ie,V)=>e.jsxs("div",{children:[V.teacher_name,V.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],re=i.useMemo(()=>(E??[]).map(ie=>({label:ie.label??`${ie.class_name??""} ${ie.section_name??""}`.trim(),key:`${ie.class_id}val${ie.section_id}`,children:e.jsx(s.Table,{size:"small",columns:ve,bordered:!0,dataSource:Array.isArray(H)?H:[],loading:Y,rowKey:V=>V.id,expandable:{expandedRowRender:pe},pagination:{current:z.page,pageSize:z.perPage,total:W,showSizeChanger:!0,onChange:(V,oe)=>k({page:V,perPage:oe})}})})),[E,z.page,z.perPage,H,Y,W]);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(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:Z,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:O.find(ie=>String(ie.value)===String(n))??null,onChange:ie=>a(ie?.value??null)}),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:L.find(ie=>String(ie.value)===String(r))??null,onChange:ie=>{const V=ie?.value??null;o(V),d(null),m(V?`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(V))}`:null),g(V?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(V))}`:null),R(oe=>!oe)}}),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:U.find(ie=>String(ie.value)===String(l))??null,onChange:ie=>d(ie?.value??null)},`section_${I}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const ie=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(ee,{style:{width:"100%"},options:ie,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:ie.find(V=>String(V.value)===String(c??"No"))??ie[1],onChange:V=>x(V?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(ee,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:v,value:(v??[]).filter(ie=>_n(y).some(V=>String(V)===String(ie.value))),onChange:(ie,V)=>{const Ce=(Array.isArray(ie)?ie:[]).map(Ee=>Ee?.value).filter(Ee=>Ee!=null&&Ee!=="");u(Ce);const Oe=Array.isArray(P?.subject_ids)?P.subject_ids.map(String):[],Pe=V?.removedValue?.value,Fe=V?.option?.value;(V?.action==="remove-value"||V?.action==="pop-value")&&Pe!=null&&Oe.includes(String(Pe))&&j(Ee=>Array.from(new Set([..._n(Ee).map(String),String(Pe)]))),V?.action==="select-option"&&Fe!=null&&Oe.includes(String(Fe))&&j(Ee=>_n(Ee).filter(Ve=>String(Ve)!==String(Fe)))}},`subjects_${I}`),D?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(de,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(s.Tabs,{activeKey:F??void 0,onChange:ie=>{q(ie),k(V=>({...V,page:1}))},items:re,type:"card",size:"small"})})]})]})}function Qm({token:t}){return e.jsx(Jm,{token:t})}const wn=we.timeGroup,Xm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Dt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function ia(t){if(!t)return null;const n=ae(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return n.isValid()?n:null}function kt(t){return t?ae(t).format("h:mm a"):""}function Zm({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[x]=s.Form.useForm(),y=`${wn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:u,isLoading:S,mutate:j}=G(t?[y,t]:null,([p,b])=>Q(p,b)),w=i.useMemo(()=>Xm(u),[u]),m=i.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??w.length??0,[u,w]),{data:h}=G(t&&l?[`${wn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([p,b])=>Q(p,b)),g=i.useMemo(()=>{const p=h?.data??h;return Array.isArray(p)?p[0]:p??null},[h]);i.useEffect(()=>{r&&g&&x.setFieldsValue({title:g?.title??"",start_time_from:ia(g?.start_time_from),start_time_to:ia(g?.start_time_to),end_time_from:ia(g?.end_time_from),end_time_to:ia(g?.end_time_to)})},[r,g,x]);const I=async p=>{const b=new FormData;b.append("title",p.title??""),b.append("start_time_from",kt(p.start_time_from)),b.append("start_time_to",kt(p.start_time_to)),b.append("end_time_from",kt(p.end_time_from)),b.append("end_time_to",kt(p.end_time_to));try{await yt(wn.add,b,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),j()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},R=async p=>{const b=new FormData;b.append("id",String(l??"")),b.append("title",p.title??""),b.append("start_time_from",kt(p.start_time_from)),b.append("start_time_to",kt(p.start_time_to)),b.append("end_time_from",kt(p.end_time_from)),b.append("end_time_to",kt(p.end_time_to));try{await Mt(wn.edit,b,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),j()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},D=async p=>{try{await Ft(wn.remove,p,t),_.success("Success! Deleted item.",{duration:1e3}),j()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to delete the item.",{duration:1500})}},C=p=>{p?.id&&(d(p.id),o(!0))},f=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:(p,b)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>C(b)}),e.jsx(s.Popconfirm,{title:"Delete this time group?",onConfirm:()=>D(b?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Time Group",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(s.Form,{form:x,layout:"vertical",onFinish:R,children:[e.jsx(s.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Dt})}),e.jsx(s.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Dt})}),e.jsx(s.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Dt})}),e.jsx(s.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Dt})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Submit",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:I,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Dt})}),e.jsx(s.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Dt})}),e.jsx(s.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Dt})}),e.jsx(s.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Dt})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(s.Table,{rowKey:p=>p.id,columns:f,dataSource:w,loading:S,pagination:{current:n.page,pageSize:n.perPage,total:m,showSizeChanger:!0,onChange:(p,b)=>a({page:p,perPage:b})}})})]})}function ey({token:t}){return e.jsx(Zm,{token:t})}const Cn=we.assignTimeGroup,ty=we.timeGroup.dropdown,ny=we.master.classes.dropdown,fi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],ay=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function sy({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState(""),[y,u]=i.useState(""),[S,j]=i.useState(null),[w,m]=i.useState(!1),[h,g]=i.useState(!1),[I,R]=i.useState(null),[D,C]=i.useState([]),[f,p]=i.useState(""),[b,A]=i.useState(""),{data:O}=G(t?[ty,t]:null,([H,W])=>Q(H,W)),{data:L}=G(t?[ny,t]:null,([H,W])=>Q(H,W)),U=i.useMemo(()=>fi(O?.data??O),[O]),v=i.useMemo(()=>fi(L),[L]),{data:M}=G(t&&S?[S,t]:null,([H,W])=>Q(H,W));i.useEffect(()=>{const H=Array.isArray(M?.data)?M.data.map(W=>W.fk_classId):[];H.length&&d(H)},[M]);const P=`${Cn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:N,isLoading:E,mutate:F}=G(t?[P,t]:null,([H,W])=>Q(H,W)),q=i.useMemo(()=>ay(N),[N]),z=i.useMemo(()=>N?.pagination?.total_rows??N?.pagination?.total??q.length??0,[N,q]),{data:k}=G(t&&I?[`${Cn.show}?id=${encodeURIComponent(String(I))}`,t]:null,([H,W])=>Q(H,W)),T=k?.data??k??null;i.useEffect(()=>{if(!h||!T)return;const H=Array.isArray(T?.class_ids)?T.class_ids:[];C(H);const W=Array.isArray(U)?U.find(Z=>String(Z.value)===String(T?.timegroup_id)):null;W&&A(`${W.start_time_from} -> ${W.end_time_from}`)},[h,T,U]);const $=async H=>{if(H.preventDefault(),x(""),!r?.value){_.error("Select Time Group",{duration:1200});return}if(!l.length){x("error"),_.error("Please Select Classes",{duration:1200});return}const W=new FormData;W.append("timegroup_id",String(r.value)),l.forEach(Z=>W.append("class_ids[]",String(Z)));try{await yt(Cn.assign,W,t),_.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),F()}catch(Z){_.error(Z?.response?.data?.msg??Z?.message??"Failed to add the new item.",{duration:1500})}},B=async()=>{if(p(""),!I)return;if(!D.length){p("error"),_.error("Please Select Classes",{duration:1200});return}const H=new FormData;H.append("id",String(I)),H.append("timegroup_id",String(T?.timegroup_id??"")),D.forEach(W=>H.append("class_ids[]",String(W)));try{await Mt(Cn.assign,H,t),_.success("Success! Updated item.",{duration:1e3}),g(!1),R(null),F()}catch(W){_.error(W?.response?.data?.msg??W?.message??"Failed to update the item.",{duration:1500})}},Y=H=>{H&&(R(H),g(!0))},ne=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:(H,W)=>W?.class_names?e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>Y(W?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Assigned Time Group",open:h,onClose:()=>{g(!1),R(null)},width:520,extra:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>g(!1),children:"Cancel"}),e.jsx(s.Button,{type:"primary",onClick:B,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:U.find(H=>String(H.value)===String(T?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:b}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(s.Select,{mode:"multiple",style:{width:"100%"},status:f,value:D,placeholder:"Select Classes",onChange:H=>C(H),options:Array.isArray(v)?v:[]})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:$,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(ee,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:H=>{o(H??null),d([]),x(""),H?.value?(j(`${Cn.classIdByTimeGroup}?id=${encodeURIComponent(String(H.value))}`),u(`${H.start_time_from} -> ${H.end_time_from}`)):(j(null),u("")),m(W=>!W)}}),e.jsx("div",{style:{marginTop:6},children:y})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(ee,{mode:"multiple",style:{width:"100%"},status:c,value:l,placeholder:"Select Classes",onChange:H=>d(H),options:Array.isArray(v)?v:[]},`class_${w}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(s.Table,{rowKey:H=>H.id,columns:ne,dataSource:q,loading:E,pagination:{current:n.page,pageSize:n.perPage,total:z,showSizeChanger:!0,onChange:(H,W)=>a({page:H,perPage:W})}})})]})}function ry({token:t}){return e.jsx(sy,{token:t})}const As=we.promoteStudents,iy=({token:t})=>G(t?[As.sessionDropdown,t]:null,([n,a])=>Q(n,a)),oa=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[]},oy=(t,n)=>{const a=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,r=a?.total_rows??a?.total??a?.totalItems;return Number.isFinite(Number(r))?Number(r):n};function ly({token:t}){const[n]=s.Form.useForm(),[a,r]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[x,y]=i.useState(!1),[u,S]=i.useState([]),j=i.useMemo(()=>new Set(u),[u]),[w,m]=i.useState({}),[h,g]=i.useState({}),{data:I}=G(t?[we.master.classes.dropdown,t]:null,([B,Y])=>Q(B,Y)),R=i.useMemo(()=>oa(I),[I]),D=i.useMemo(()=>o.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:C}=G(t&&D?[D,t]:null,([B,Y])=>Q(B,Y)),f=i.useMemo(()=>oa(C),[C]),p=i.useMemo(()=>d.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:b}=G(t&&p?[p,t]:null,([B,Y])=>Q(B,Y),{revalidateOnFocus:!1}),A=i.useMemo(()=>oa(b),[b]),{data:O}=iy({token:t}),L=i.useMemo(()=>oa(O),[O]),{trigger:U,data:v,isMutating:M}=Je(t?As.searchByClassSection:null,(B,{arg:Y})=>zt(B,{arg:Y},t)),P=i.useMemo(()=>{const B=v?.data?.data??v?.data??v??[];return Array.isArray(B)?B:Array.isArray(B?.data)?B.data:[]},[v]),N=i.useMemo(()=>oy(v,P.length??0),[v,P.length]),E=i.useMemo(()=>{const B=new Map;return(Array.isArray(P)?P:[]).forEach(Y=>{Y?.id!==void 0&&Y?.id!==null&&B.set(String(Y.id),Y)}),B},[P]),F=i.useCallback((B,Y)=>{const ne=String(B);g(H=>({...H,[ne]:{...H?.[ne]??{},...Y}}))},[]),q=i.useCallback((B,Y)=>{const ne=String(B),H=Y==="Leave";m(W=>({...W,[ne]:H}))},[]),z=B=>{const Y=B?.class_id?.value??B?.class_id??null,ne=B?.section_id?.value??B?.section_id??null;if(!Y||!ne){_.error("Please select Class and Section",{duration:1200});return}r(H=>({...H,page:1})),l({classId:Y,sectionId:ne}),S([]),m({}),g({})},k=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 B=u.map(W=>String(W)).map(W=>{const Z=E.get(W)??{},se=!!w?.[W],pe=h?.[W]??{},ve=String(pe.current_result??"Pass");if(se){const V=String(pe.leave_date??"");return{student_id:W,current_result:ve,next_session_status:"Leave",leave_date:V}}const re=String(pe.roll_no??Z?.roll_no??""),ie=String(pe.section_id??"");return{student_id:W,roll_no:re,section_id:ie,current_result:ve,next_session_status:"Continue"}});if(B.some(W=>W?.next_session_status==="Leave"&&!String(W?.leave_date??"").trim())){_.error("Leave date is required for Leave students.",{duration:1500});return}if(B.some(W=>W?.next_session_status==="Continue"&&!String(W?.section_id??"").trim())){_.error("Section is required for Continue students.",{duration:1500});return}const H={class_id:String(d.classId),session_id:String(d.sessionId),students:B};try{const W=await mt(As.promote,H,t);if(W?.Status&&String(W.Status)!=="success")throw new Error(W?.msg||"Failed to update");_.success("Success! Updated.",{duration:1e3});const Z=Number(W?.success_count??0)+Number(W?.leave_count??0),se=a.page===Math.ceil((Number(N)||0)/a.perPage||1),pe=Z>0&&Z===P.length&&P.length===u.length,ve=se&&pe&&a.page>1?a.page-1:a.page;r(re=>({...re,page:ve})),U?.({cID:o.classId,sID:o.sectionId,page:ve,per_page:a.perPage}),S([]),m({}),g({})}catch(W){_.error(W?.response?.data?.msg??W?.message??"Failed to update",{duration:1500})}},T=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:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=!!w?.[ne],se=(h?.[ne]??{}).roll_no??(W?"":Y?.roll_no??"");return e.jsx(s.Input,{value:H?se:Y?.roll_no,style:H?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!H||W,onChange:pe=>F(ne,{roll_no:pe.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(B,Y)=>`${Y?.firstname??""} ${Y?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=!!w?.[ne],se=(h?.[ne]??{}).section_id??"",pe=Array.isArray(A)?A:[];return e.jsx(s.Select,{options:pe,placeholder:H&&!W?"Select Section":"Section",disabled:!H||W,value:H&&!W&&se||void 0,style:{width:"100%"},onChange:ve=>F(ne,{section_id:ve})},`section_${ne}_${x}_${W?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=h?.[ne]??{},Z=String(W.current_result??"Pass");return e.jsxs(s.Radio.Group,{value:Z,disabled:!H,buttonStyle:"solid",onChange:se=>F(ne,{current_result:se.target.value}),children:[e.jsx(s.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(s.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=!!w?.[ne],Z=h?.[ne]??{},se=String(Z.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(s.Radio.Group,{value:W?"Leave":"Continue",disabled:!H,buttonStyle:"solid",onChange:pe=>q(ne,pe.target.value),children:[e.jsx(s.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(s.Radio.Button,{value:"Leave",children:"Leave"})]}),H&&W&&e.jsx(s.DatePicker,{style:{width:"100%"},value:se?ae(se):null,onChange:pe=>F(ne,{leave_date:pe?pe.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[q,w,h,j,x,A,F]),$=i.useMemo(()=>({selectedRowKeys:u,onChange:B=>S((Array.isArray(B)?B:[]).map(Y=>String(Y)))}),[u]);return i.useEffect(()=>{!o.classId||!o.sectionId||U&&U({cID:o.classId,sID:o.sectionId,page:a.page,per_page:a.perPage})},[a.page,a.perPage,U,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(s.Form,{form:n,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(s.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:B=>B,children:e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{const Y=B?.value??null;n.setFieldValue("section_id",null),l({classId:Y,sectionId:null})}})}),e.jsx(s.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:B=>B,children:e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx($t,{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(s.Typography.Text,{children:["Selected: ",u.length]}),e.jsx(s.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(ee,{label:"Session",options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:L.find(B=>String(B.value)===String(d.sessionId))??null,onChange:B=>c(Y=>({...Y,sessionId:B?.value??null}))}),e.jsx(ee,{label:"Class",options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(B=>String(B.value)===String(d.classId))??null,onChange:B=>{const Y=B?.value??null;c(ne=>({...ne,classId:Y})),y(ne=>!ne)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Save",color:"primary",onClick:k})})]}),e.jsx(s.Table,{rowKey:B=>String(B.id),rowSelection:$,columns:T,dataSource:P,loading:M,pagination:{current:a.page,pageSize:a.perPage,total:N,showSizeChanger:!0,onChange:(B,Y)=>{r({page:B,perPage:Y}),S([]),m({}),g({})}}})]})})]})}function dy({token:t}){return e.jsx(ly,{token:t})}const an=we.coscholastic,cy=({token:t})=>G(t?[an.table,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),uy=({token:t})=>G(t?[an.categoryDropdown,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),hi=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 py({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(null),[l,d]=i.useState(null),c=i.useRef(null),{data:x}=G(t?[we.master.classes.dropdown,t]:null,([b,A])=>Q(b,A)),y=i.useMemo(()=>hi(x),[x]),{data:u,isLoading:S,mutate:j}=cy({token:t}),w=i.useMemo(()=>{const b=u?.data?.data??u?.data??u??[];return Array.isArray(b)?b:Array.isArray(b?.data)?b.data:[]},[u]),{data:m,mutate:h}=uy({token:t}),g=i.useMemo(()=>hi(m),[m]),I=i.useMemo(()=>(Array.isArray(g)?g:[]).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[g]),R=async()=>{const b=String(n??"").trim();if(!b){_.error("Please enter category title",{duration:1200});return}try{await Ye(an.addCategory,{title:b},t),_.success("Success! Added category.",{duration:1e3}),a(""),h()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add category",{duration:1500})}},D=async b=>{try{await Ft(an.deleteCategory,b,t),_.success("Success! Deleted category.",{duration:1e3}),h()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete category",{duration:1500})}},C=async b=>{if(b.preventDefault(),!r){_.error("Please select Category",{duration:1200});return}if(!l){_.error("Please select Class",{duration:1200});return}if(!b?.target?.skill?.value){_.error("Please enter Skill Name",{duration:1200});return}const O=new FormData(b.target);O.append("scholastic_catid",String(r)),O.append("class_id",String(l));try{await yt(an.addSkill,O,t),_.success("Success! Added new item.",{duration:1e3}),b.target.reset(),d(null),j()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},f=async b=>{try{await Ft(an.deleteSkill,b,t),_.success("Success! Deleted item.",{duration:1e3}),j()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete the item.",{duration:1500})}},p=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:(b,A)=>e.jsx(s.Popconfirm,{title:"Delete this skill?",onConfirm:()=>f(A?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.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(ee,{style:{width:"100%"},value:I.find(b=>String(b.value)===String(r))??null,placeholder:"Select Category",onChange:b=>o(b?.value??null),options:I}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(J,{placeholder:"New category",ref:c,value:n,onChange:b=>a(b.target.value)}),e.jsx(s.Button,{type:"text",icon:e.jsx(X.PlusOutlined,{}),onClick:R}),e.jsx(s.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{r&&(D(r),o(null))},children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{}),disabled:!r})})]})]}),e.jsx(ee,{label:"Class",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:y.find(b=>String(b.value)===String(l))??null,onChange:b=>d(b?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(J,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx($t,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:b=>b.id,columns:p,dataSource:w,loading:S,pagination:!1})})]})}function my({token:t}){return e.jsx(py,{token:t})}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:"":"",Co=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:Am(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=yy(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},gi=we.notes,fy=({token:t,url:n})=>G(t&&n?[n,t]:null,([a,r])=>Q(a,r),{revalidateOnFocus:!1}),la=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[]},hy=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r};function gy({token:t}){const[n]=s.Form.useForm(),[a]=s.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null,sectionId:null}),[c,x]=i.useState(!1),[y,u]=i.useState(""),{data:S}=G(t?[we.master.classes.dropdown,t]:null,([$,B])=>Q($,B)),j=i.useMemo(()=>la(S),[S]),w=i.useMemo(()=>l.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:m}=G(t&&w?[w,t]:null,([$,B])=>Q($,B)),h=i.useMemo(()=>la(m),[m]),g=i.useMemo(()=>!l.classId||!l.sectionId?null:`${gi.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:I,isLoading:R,mutate:D}=fy({token:t,url:g}),C=i.useMemo(()=>{const $=I?.data?.data??I?.data??I??[];return Array.isArray($)?$:Array.isArray($?.data)?$.data:[]},[I]),f=i.useMemo(()=>I?.pagination?.total_rows??I?.pagination?.total??C.length??0,[I,C.length]),[p,b]=i.useState(null),[A,O]=i.useState(null),[L,U]=i.useState(null),[v,M]=i.useState(!1),{data:P}=G(t&&L?[L,t]:null,([$,B])=>Q($,B),{revalidateOnFocus:!1}),N=i.useMemo(()=>la(P),[P]),{data:E}=G(t&&A?[A,t]:null,([$,B])=>Q($,B)),F=i.useMemo(()=>la(E),[E]),q=$=>{const B=$?.class_id?.value??null,Y=$?.section_id?.value??null;!B||!Y||(o(ne=>({...ne,page:1})),d({classId:B,sectionId:Y}))},z=()=>{u(""),x(!0),b(null),O(null),U(null),M($=>!$),a.resetFields()},k=async $=>{const B=$?.class_id?.value??null,Y=$?.section_id?.value??null,ne=$?.sub_id?.value??null,H=$?.status?.value??"publish",W=$?.title??"",Z=$?.remark??"";if(!B||!Y||!ne||!W||!Z||!y){_.error("Please fill all fields",{duration:1200});return}const se=new FormData;se.append("class_id",String(B)),se.append("section_id",String(Y)),se.append("sub_id",String(ne)),se.append("title",String(W)),se.append("remark",String(Z)),se.append("status",String(H)),se.append("file",String(y));try{await yt(gi.add,se,t),_.success("Success! Added new item.",{duration:1e3}),x(!1),D()}catch(pe){_.error(pe?.response?.data?.msg??pe?.message??"Failed to add the new item.",{duration:1500})}},T=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)=>{const Y=String(B?.status??"").toLowerCase();return e.jsx(s.Tag,{color:Y==="publish"?"green":"red",children:B?.status??"-"})}},{title:"File",key:"file",align:"center",render:($,B)=>{const Y=B?.file;if(!Y)return"-";const ne=hy(at(),`/student/note/${Y}`);return e.jsx("a",{href:ne,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(s.Modal,{title:"Add Note",open:c,onCancel:()=>x(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(s.Form,{form:a,layout:"vertical",onFinish:k,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const B=$?.value??null;b(B),a.setFieldValue("section_id",null),a.setFieldValue("sub_id",null),U(B?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(B))}`:null),O(B?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(B))}`:null),M(Y=>!Y)}},`class_${v}`)}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${v}_${p??"none"}`)}),e.jsx(s.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${v}_${A??"none"}`)}),e.jsx(s.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(J,{placeholder:"Remark"})}),e.jsx(s.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:$=>$,children:e.jsx(ee,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(s.Form.Item,{label:"File",required:!0,children:e.jsx(Co,{token:t,value:y,onChange:u})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>x(!1),children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx($t,{actions:["add","export","print","download","filter"],onAdd:z,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:n,layout:"vertical",onFinish:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const B=$?.value??null;n.setFieldValue("section_id",null),d({classId:B,sectionId:null})}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(s.Table,{rowKey:$=>$.id,columns:T,dataSource:C,loading:R,pagination:{current:r.page,pageSize:r.perPage,total:f,showSizeChanger:!0,onChange:($,B)=>o({page:$,perPage:B})}})})]})}function xy({token:t}){return e.jsx(gy,{token:t})}const by=({token:t})=>G(t?[we.promoteStudents.sessionDropdown,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),xi=we.transferCertificate,us=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[]},Sy={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},jy=(t,n)=>t.inputtype==="Select"?null:t.inputtype==="date"?ae():"",bi=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}],Si=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 vy({token:t,transferCertificateViewPath:n="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:a}){const[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState({page:1,perPage:10}),[c,x]=i.useState({classId:null,sectionId:null,sessionId:null}),[y,u]=i.useState(null),[S,j]=i.useState(!1),{data:w}=G(t?[we.master.classes.dropdown,t]:null,([T,$])=>Q(T,$)),m=i.useMemo(()=>us(w),[w]),{data:h}=G(t&&y?[y,t]:null,([T,$])=>Q(T,$)),g=i.useMemo(()=>us(h),[h]),{data:I}=by({token:t}),R=i.useMemo(()=>us(I),[I]),D=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${xi.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:f,mutate:p}=G(t&&D?[D,t]:null,([T,$])=>Q(T,$),{revalidateOnFocus:!1,onSuccess:T=>{const $=T?.data?.data??T?.data??[];Array.isArray($)&&$[0]?.transefer_certificate_id&&P(String($[0].transefer_certificate_id))}}),b=i.useMemo(()=>{const T=C?.data?.data??C?.data??C??[];return Array.isArray(T)?T:Array.isArray(T?.data)?T.data:[]},[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??b.length??0,[C,b.length]),[O,L]=i.useState(!1),[U,v]=i.useState(null),[M,P]=i.useState("1"),N=T=>{v(T);const $=M==="1"?bi(T):Si(T),B={};$.forEach(Y=>{B[Y.name]=Y.value??jy(Y)}),o.setFieldsValue(B),L(!0)},E=async T=>{if(!T)return;if(typeof a=="function")return a(T);const $=`${n}?id=${encodeURIComponent(String(T))}`;window.location.href=$},F=T=>{const $=T?.class_id?.value??null,B=T?.section_id?.value??null,Y=T?.session_id?.value??null;if(!$||!B||!Y){_.error("Please select Class, Section and Session",{duration:1200});return}d(ne=>({...ne,page:1})),x({classId:$,sectionId:B,sessionId:Y})},q=async T=>{const $=new FormData;Object.entries(T??{}).forEach(([B,Y])=>{if(Y!=null){if(ae.isDayjs(Y)){$.append(B,Y.format("YYYY-MM-DD"));return}$.append(B,String(Y))}});try{await yt(xi.addData,$,t),_.success("Success! Added new item.",{duration:1e3}),L(!1),v(null),p()}catch(B){_.error(B?.response?.data?.msg??B?.message??"Failed to add the new item.",{duration:1500})}},z=i.useMemo(()=>M==="1"?bi(U):Si(U),[M,U]),k=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:(T,$)=>e.jsx(s.Button,{type:"text",icon:$?.transfer_certificate_data==="not_present"?e.jsx(X.EyeOutlined,{}):e.jsx(X.CheckOutlined,{}),onClick:()=>{$?.transfer_certificate_data==="not_present"?N($?.id):E($?.id)}})}],[M]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:"Transfer Certificate",open:O,onCancel:()=>L(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:q,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:z.map(T=>T.inputtype==="hidden"?e.jsx(s.Form.Item,{name:T.name,initialValue:T.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},T.name):T.inputtype==="date"?e.jsx(s.Form.Item,{label:T.label,name:T.name,children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:Sy})},T.name):T.inputtype==="radio"?e.jsx(s.Form.Item,{label:T.label,name:T.name,children:e.jsx(s.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},T.name):T.inputtype==="Select"?e.jsx(s.Form.Item,{label:T.label,name:T.name,getValueFromEvent:$=>$,children:e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},T.name):e.jsx(s.Form.Item,{label:T.label,name:T.name,children:e.jsx(J,{placeholder:T.label})},T.name))}),e.jsxs(s.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(de,{type:"submit",value:"Submit",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>L(!1),children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(s.Form,{form:r,layout:"vertical",onFinish:F,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:T=>T,children:e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:T=>{const $=T?.value??null;u($?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String($))}`:null),j(B=>!B),r.setFieldValue("section_id",null)}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:T=>T,children:e.jsx(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${S}`)}),e.jsx(s.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:T=>T,children:e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx($t,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:T=>T.id,columns:k,dataSource:b,loading:f,pagination:{current:l.page,pageSize:l.perPage,total:A,showSizeChanger:!0,onChange:(T,$)=>d({page:T,perPage:$})}})})]})}function _y({token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a}){return e.jsx(vy,{token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a})}const wy=({token:t,url:n})=>G(t&&n?[n,t]:null,([a,r])=>Q(a,r),{revalidateOnFocus:!1}),ps=we.syllabus,ji=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[]},Cy=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r};function Ay({token:t}){const[n]=s.Form.useForm(),[a]=s.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null}),[c,x]=i.useState(!1),[y,u]=i.useState(null),[S,j]=i.useState(""),{data:w}=G(t?[we.master.classes.dropdown,t]:null,([E,F])=>Q(E,F)),m=i.useMemo(()=>ji(w),[w]),h=i.useMemo(()=>l.classId?`${ps.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:g,isLoading:I,mutate:R}=wy({token:t,url:h}),D=i.useMemo(()=>{const E=g?.data?.data??g?.data??g??[];return Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[]},[g]),C=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??D.length??0,[g,D.length]),[f,p]=i.useState(null),[b,A]=i.useState(!1),{data:O}=G(t&&f?[f,t]:null,([E,F])=>Q(E,F),{revalidateOnFocus:!1}),L=i.useMemo(()=>ji(O),[O]),U=E=>{const F=E?.class_id?.value??null;F&&(o(q=>({...q,page:1})),d({classId:F}))},v=()=>{u(null),j(""),p(null),A(E=>!E),a.resetFields(),x(!0)},M=E=>{u(E),j(E?.attchement??"");const F=E?.class_id;p(F?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(F))}`:null),A(q=>!q),a.setFieldsValue({class_id:m.find(q=>String(q.value)===String(F))??null,sub_id:L.find(q=>String(q.value)===String(E?.sub_id??E?.subject_id))??(E?.sub_id||E?.subject_id?{label:E?.subject_title??"Subject",value:E?.sub_id??E?.subject_id}:null),title:E?.title??"",description:E?.description??""}),x(!0)},P=async E=>{const F=E?.class_id?.value??null,q=E?.sub_id?.value??null,z=E?.title??"",k=E?.description??"";if(!F||!q||!z||!k||!S){_.error("Please fill all fields",{duration:1200});return}const T=new FormData;T.append("class_id",String(F)),T.append("sub_id",String(q)),T.append("title",String(z)),T.append("description",String(k)),T.append("file",String(S));try{y?.id?(T.append("id",String(y.id)),await yt(ps.edit,T,t),_.success("Success! Updated item.",{duration:1e3})):(await yt(ps.add,T,t),_.success("Success! Added new item.",{duration:1e3})),x(!1),u(null),R()}catch($){_.error($?.response?.data?.msg??$?.message??"Failed to save",{duration:1500})}},N=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:(E,F)=>{const q=F?.attchement;if(!q)return"-";const z=Cy(at(),`uploads/student/note/${q}`);return e.jsx("a",{href:z,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(E,F)=>e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>M(F)})}],[L,m]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:y?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{x(!1),u(null),j("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(s.Form,{form:a,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(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{const F=E?.value??null;a.setFieldValue("sub_id",null),p(F?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(F))}`:null),A(q=>!q)}},`class_${y?.id??"add"}_${b}`)}),e.jsx(s.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${y?.id??"add"}_${b}_${f??"none"}`)}),e.jsx(s.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(Ot,{placeholder:"Description"})}),e.jsx(s.Form.Item,{label:"File",required:!0,children:e.jsx(Co,{token:t,value:S,onChange:j})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>x(!1),children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx($t,{actions:["add","export","print","download","filter"],onAdd:v,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:n,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(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(s.Table,{rowKey:E=>E.id,columns:N,dataSource:D,loading:I,pagination:{current:r.page,pageSize:r.perPage,total:C,showSizeChanger:!0,onChange:(E,F)=>o({page:E,perPage:F})}})})]})}function Ty({token:t}){return e.jsx(Ay,{token:t})}const La=we.timetable,vi=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[]},_i=t=>{if(!t)return"";const n=ae(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},Ry=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let a=0;for(let o=0;o<n.length;o+=1)a=(a*31+n.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[a%r.length]},wi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Iy=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"};function Dy({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[y,u]=i.useState(""),{data:S}=G(t?[we.master.classes.dropdown,t]:null,([p,b])=>Q(p,b)),j=i.useMemo(()=>vi(S),[S]),{data:w}=G(t&&n?[n,t]:null,([p,b])=>Q(p,b)),m=i.useMemo(()=>vi(w),[w]),{data:h,isLoading:g}=G(t&&l?[l,t]:null,([p,b])=>Q(p,b),{revalidateOnFocus:!1}),I=i.useMemo(()=>h?.days??h?.data?.days??h?.data?.data?.days??{},[h]),{dataSource:R,daySpanByFirstKey:D}=i.useMemo(()=>{const p=Object.entries(I||{}).slice().sort((O,L)=>wi.indexOf(String(O[0]).toLowerCase())-wi.indexOf(String(L[0]).toLowerCase())),b=new Map,A=[];for(const[O,L]of p){const U=(Array.isArray(L)?L:[]).slice().sort((M,P)=>Number(M?.order_no||0)-Number(P?.order_no||0)),v=U.length;for(let M=0;M<v;M+=1){const P=U[M],N=P?.id||`${O}-${P?.order_no}-${M}`;M===0&&b.set(N,v),A.push({key:N,_dayKey:O,...P})}}return{dataSource:A,daySpanByFirstKey:b}},[I]),C=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(p,b)=>{const A=D.get(b.key);return A===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(X.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Iy(p)})]}),props:{rowSpan:A}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:p=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:p})},{title:"Time",key:"time",width:180,render:(p,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[_i(b?.time_from)," - ",_i(b?.time_to)]})]})},{title:"Subject",key:"subject",render:(p,b)=>{if(String(b?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const O=b?.subject_name||"-";return e.jsx(s.Tag,{color:Ry(O),style:{fontWeight:500},children:O})}},{title:"Teacher",key:"teacher",render:(p,b)=>{const A=String(b?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:A?"-":b?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(p,b)=>{const A=String(b?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:A?"-":b?.room_no||"-"})]})}}],[D]),f=p=>{p.preventDefault();const b=p.target.class_id?.value,A=p.target.section_id?.value;if(!b||!A)return;const O=j.find(M=>String(M.value)===String(b)),L=m.find(M=>String(M.value)===String(A));x(O?.label||""),u(L?.label||"");const v=`${La.byClassSection}/${b}/section/${A}`;d(v)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx($t,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),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.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:p=>{a(`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(p?.value??""))}`),o(b=>!b)}}),e.jsx(ee,{options:m,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(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:c||y?`Timetable: ${c} ${y}`:"Timetable"}),children:e.jsx(s.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:R,columns:C,rowKey:"key",loading:g,scroll:{x:"max-content"}})})]})}const ky=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[]},Ci=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Oy=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"},Ai=t=>{if(!t)return"";const n=ae(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},Py=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let a=0;for(let o=0;o<n.length;o+=1)a=(a*31+n.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[a%r.length]};function Ey({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(null),{data:l}=G(t?[we.assignByClass.teacherDropdown,t]:null,([w,m])=>Q(w,m)),d=i.useMemo(()=>ky(l),[l]),{data:c,isLoading:x}=G(t&&r?[r,t]:null,([w,m])=>Q(w,m),{revalidateOnFocus:!1}),{dataSource:y,daySpanByFirstKey:u}=i.useMemo(()=>{const m=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((R,D)=>{const C=Ci.indexOf(String(R?.day_name||"").toLowerCase()),f=Ci.indexOf(String(D?.day_name||"").toLowerCase());if(C!==f)return C-f;const p=Number(R?.order_no||0),b=Number(D?.order_no||0);return p!==b?p-b:String(R?.time_from||"").localeCompare(String(D?.time_from||""))}),h=new Map,g=[];let I=0;for(;I<m.length;){const R=String(m[I]?.day_name||"").toLowerCase();let D=I;for(;D<m.length&&String(m[D]?.day_name||"").toLowerCase()===R;)D+=1;const C=D-I;for(let f=I;f<D;f+=1){const p=m[f],b=p?.id||`${R}-${p?.order_no}-${f}`;f===I&&h.set(b,C),g.push({key:b,_dayKey:R,...p})}I=D}return{dataSource:g,daySpanByFirstKey:h}},[c]),S=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(w,m)=>{const h=u.get(m.key);return h===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(X.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Oy(w)})]}),props:{rowSpan:h}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:w=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:w})},{title:"Time",key:"time",width:180,render:(w,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[Ai(m?.time_from)," - ",Ai(m?.time_to)]})]})},{title:"Subject",key:"subject",render:(w,m)=>{if(String(m?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const g=m?.subject_name||"-";return e.jsx(s.Tag,{color:Py(g),style:{fontWeight:500},children:g})}},{title:"Class",key:"class",width:160,render:(w,m)=>e.jsxs(s.Tag,{color:"purple",style:{fontWeight:500},children:[m?.class_name||m?.class_id||"-"," ",m?.section_name?`(${m.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(w,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:m?.room_no||"-"})]})}],[u]),j=w=>{w.preventDefault();const m=w.target.teacher_id?.value;if(!m)return;a(m);const g=`${La.teacherTimetable}${encodeURIComponent(String(m))}`;o(g)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx($t,{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(ee,{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(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(s.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:y,columns:S,rowKey:"key",loading:x,scroll:{x:"max-content"}})})]})}function Ti(t){if(!t)return null;const n=String(t).trim().replaceAll(".",":");if(!n)return null;const a=n.toLowerCase(),r=a.includes("am")||a.includes("pm");let o=0,l=0,d=0;if(r){const x=a.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!x)return null;o=Number.parseInt(x[1],10),l=Number.parseInt(x[2],10),d=Number.parseInt(x[3]||"0",10);const y=x[4].toLowerCase();y==="pm"&&o<12&&(o+=12),y==="am"&&o===12&&(o=0)}else{const c=n.split(":").map(x=>x.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 An(t,n){const a=Number.parseInt(n,10);return!Number.isFinite(a)||a<=0||!t||!t.isValid?.()?null:t.add(a,"minute")}const wa=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[]},kn={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},My=t=>{const n=kn[String(t)];return n?n.charAt(0).toUpperCase()+n.slice(1):String(t)},Fy=({token:t,classId:n,sectionId:a,subjectId:r,value:o,onChange:l,disabled:d})=>{const c=t&&n&&a&&r?`${La.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(n))}§ion_id=${encodeURIComponent(String(a))}`:null,{data:x,isLoading:y}=G(c?[c,t]:null,([S,j])=>Q(S,j),{revalidateOnFocus:!1}),u=i.useMemo(()=>wa(x?.data??x).map(j=>({value:j?.value??j?.id,label:j?.label??j?.name??j?.teacher_name??""})),[x]);return e.jsx(s.Select,{placeholder:d?"-":"Select Teacher",loading:y,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:S=>l?.(S),showSearch:!0,optionFilterProp:"label"})};function Ny({token:t}){const[n]=s.Form.useForm(),[a,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:[]}),[x,y]=i.useState(!1),u=i.useMemo(()=>t?we.master.classes.dropdown:null,[t]),{data:S}=G(u?[u,t]:null,([v,M])=>Q(v,M)),j=i.useMemo(()=>wa(S).map(v=>({value:v?.value??v?.id,label:v?.label??v?.title??""})),[S]),w=i.useMemo(()=>!t||!a.classId?null:`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:m}=G(w?[w,t]:null,([v,M])=>Q(v,M)),h=i.useMemo(()=>wa(m).map(v=>({value:v?.value??v?.id,label:v?.label??v?.title??""})),[m]),g=i.useMemo(()=>!t||!a.classId?null:`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:I}=G(g?[g,t]:null,([v,M])=>Q(v,M)),R=i.useMemo(()=>wa(I).map(v=>({value:v?.value??v?.id,label:v?.label??v?.title??""})),[I]),D=i.useMemo(()=>Array.isArray(d?.[a.dayKey])?d[a.dayKey]:[],[a.dayKey,d]),C=i.useCallback((v,M,P)=>{c(N=>{const E={...N},F=Array.isArray(E[v])?E[v].slice():[];return F[M]={...F[M]??{},...P},E[v]=F,E})},[]),f=i.useCallback((v,M)=>{c(P=>{const N={...P},E=Array.isArray(N[v])?N[v].slice():[];return E.splice(M,1),N[v]=E.map((F,q)=>({...F,order_no:q+1})),N})},[]),p=i.useCallback(v=>{c(M=>{const P={...M},N=Array.isArray(P[v])?P[v].slice():[];let E=null,F=null;const q=N[N.length-1];if(q?.time_to){const z=Ti(q.time_to),k=Number.parseInt(o.interval,10)||0,T=Number.parseInt(o.duration,10)||0,$=An(z,k),B=T>0?An($,T):null;E=$?.isValid?.()?$.format("HH:mm:ss"):null,F=B?.isValid?.()?B.format("HH:mm:ss"):null}return N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:E,time_to:F,is_break:!1}),P[v]=N,P})},[o.duration,o.interval,o.roomNo]),b=i.useCallback(()=>{const v=o.startTime,M=o.endTime,P=Number.parseInt(o.duration,10),N=Number.parseInt(o.interval,10);if(!v||!v.isValid?.()){_.error("Start time is required",{duration:1500});return}if(!M||!M.isValid?.()){_.error("End time is required",{duration:1500});return}if(!M.isAfter(v)){_.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(P)||P<=0){_.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(N)||N<0){_.error("Interval must be 0 or more",{duration:1500});return}const E=()=>{const F=[];let q=v;for(let z=0;z<50;z+=1){const k=An(q,P);if(!k||!k.isValid?.()||k.isAfter(M))break;F.push({order_no:F.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:q.format("HH:mm:ss"),time_to:k.format("HH:mm:ss"),is_break:!1});const T=An(k,N);if(!T||!T.isValid?.()||T.isAfter(M)||T.isSame(M))break;q=T}if(o.tiffinEnabled){const z=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),k=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),T=Math.min(z,F.length);if(T>0&&k>0){const $=F[T-1],B=$?.time_to?Ti($.time_to):null,Y=B?An(B,k):null;B?.isValid?.()&&Y?.isValid?.()&&!Y.isAfter(M)&&F.splice(T,0,{order_no:T+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:B.format("HH:mm:ss"),time_to:Y.format("HH:mm:ss"),is_break:!0})}}return F.map((z,k)=>({...z,order_no:k+1}))};c(F=>{const q={...F};return Object.keys(kn).forEach(z=>{a.daysEnabled?.[z]&&(q[z]=E())}),q}),_.success("Generated schedule",{duration:1e3})},[o,a.daysEnabled]),A=i.useCallback(()=>{const v=localStorage.getItem("genrall_settings"),P=(v?JSON.parse(v):{})?.session_id??"1",N=a.classId,E=a.sectionId,F=Object.keys(kn).map(q=>{const z=(Array.isArray(d?.[q])?d[q]:[]).map((k,T)=>({order_no:T+1,subject_id:k?.is_break?0:k?.subject_id??null,teacher_id:k?.is_break?0:k?.teacher_id??null,room_no:k?.room_no??"",time_from:k?.time_from??null,time_to:k?.time_to??null,is_break:k?.is_break?1:0}));return{day:kn[q],class_id:N,section_id:E,session_id:P,args:z}});return{class_id:N,section_id:E,session_id:P,days:F}},[a.classId,a.sectionId,d]),O=i.useCallback(async()=>{if(!a.classId||!a.sectionId){_.error("Please select Class and Section",{duration:1500});return}const v=A(),M=Array.isArray(v?.days)?v.days:[];if(!M.some(E=>Array.isArray(E?.args)&&E.args.length>0)){_.error("No timetable rows to submit",{duration:1500});return}const N=E=>{const F=E?.is_break;return F===1||F==="1"||F===!0?!0:String(F??"").toLowerCase()==="true"};M.some(E=>(Array.isArray(E?.args)?E.args:[]).some(F=>String(F?.time_from??"").trim()&&String(F?.time_to??"").trim()?N(F)?!1:!String(F?.subject_id??"").trim()||!String(F?.teacher_id??"").trim():!0)),y(!0);try{const E=La.save,F=E==="api/timetable/save"?"timetable/save":null,q=async T=>{const $=await Ea(T,v,t);if($&&typeof $=="object")return $;throw new Error("No response from server")};let z;try{z=await q(E)}catch{z=await q(F)}const k=String(z?.msg??"");if(String(z?.Status)==="Success"){if(Array.isArray(z?.data)&&z.data.length===0&&k){_.error(k,{duration:3e3});return}_.success(k||"Weekly Time Table added successfully!",{duration:1200});return}_.error(k||"Failed to add time table",{duration:3e3})}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to add time table",{duration:3e3})}finally{y(!1)}},[A,a.classId,a.sectionId,t]),L=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:v=>v?ae(v,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:v=>v?ae(v,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(v,M,P)=>e.jsx(s.Switch,{checked:!!M?.is_break,onChange:N=>{C(a.dayKey,P,{is_break:N,subject_id:N?"":M?.subject_id??"",teacher_id:N?"":M?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(v,M,P)=>e.jsx(s.Select,{placeholder:M?.is_break?"-":"Select Subject",disabled:!!M?.is_break,style:{width:"100%"},options:R,value:M?.subject_id?String(M.subject_id):void 0,onChange:N=>C(a.dayKey,P,{subject_id:N,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(v,M,P)=>e.jsx(Fy,{token:t,classId:a.classId,sectionId:a.sectionId,subjectId:M?.subject_id,disabled:!!M?.is_break||!M?.subject_id,value:M?.teacher_id,onChange:N=>C(a.dayKey,P,{teacher_id:N})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(v,M,P)=>e.jsx(s.Input,{value:M?.room_no??"",onChange:N=>C(a.dayKey,P,{room_no:N.target.value})})},{title:"Action",key:"action",width:90,render:(v,M,P)=>e.jsx(s.Popconfirm,{title:"Delete this row?",onConfirm:()=>f(a.dayKey,P),children:e.jsx(s.Button,{danger:!0,type:"text",children:"Delete"})})}],[a.classId,a.dayKey,a.sectionId,f,R,t,C]),U=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(s.Form,{form:n,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(s.Form.Item,{label:"Class",required:!0,children:e.jsx(s.Select,{placeholder:"Select Class",options:j,value:a.classId?String(a.classId):void 0,onChange:v=>{r(M=>({...M,classId:v,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(s.Form.Item,{label:"Section",required:!0,children:e.jsx(s.Select,{placeholder:"Select Section",options:h,value:a.sectionId?String(a.sectionId):void 0,onChange:v=>r(M=>({...M,sectionId:v})),disabled:!a.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(s.Form.Item,{label:"Start Time",required:!0,children:e.jsx(s.TimePicker,{value:o.startTime,onChange:v=>l(M=>({...M,startTime:v})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"End Time",required:!0,children:e.jsx(s.TimePicker,{value:o.endTime,onChange:v=>l(M=>({...M,endTime:v})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(s.InputNumber,{min:1,value:o.duration,onChange:v=>l(M=>({...M,duration:v})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Interval (min)",children:e.jsx(s.InputNumber,{min:0,value:o.interval,onChange:v=>l(M=>({...M,interval:v})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Room No",children:e.jsx(s.Input,{value:o.roomNo,onChange:v=>l(M=>({...M,roomNo:v.target.value}))})}),e.jsx(s.Form.Item,{label:"Tiffin Break",children:e.jsxs(s.Space,{children:[e.jsx(s.Switch,{checked:o.tiffinEnabled,onChange:v=>l(M=>({...M,tiffinEnabled:v}))}),e.jsx(s.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(s.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(s.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:v=>l(M=>({...M,tiffinAfterPeriod:v})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(s.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(s.InputNumber,{min:1,value:o.tiffinDuration,onChange:v=>l(M=>({...M,tiffinDuration:v})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(s.Button,{onClick:b,children:"Generate"}),e.jsx(s.Button,{type:"primary",loading:x,onClick:O,children:"Save"})]})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(s.Space,{children:[e.jsx(s.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(s.Select,{style:{width:160},value:a.dayKey,onChange:v=>r(M=>({...M,dayKey:v})),options:Object.keys(kn).map(v=>({value:String(v),label:My(v)}))}),e.jsx(s.Button,{onClick:()=>p(a.dayKey),children:"Add Row"})]}),children:e.jsx(s.Table,{rowKey:(v,M)=>`${a.dayKey}_${M}`,columns:L,dataSource:D,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(s.Tabs,{type:"card",items:[{key:"create",label:"Create",children:U},{key:"routine",label:"Routine",children:e.jsx(Dy,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(Ey,{token:t})}]})]})}function $y({token:t}){return e.jsx(Ny,{token:t})}function Uy(){return null}const Vt=t=>t??localStorage.getItem("authToken")??"",Ls=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},lt={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"}},qs=t=>Ls(at(),t),By=()=>Ls(at(),"uploads"),Ao=t=>Ls(By(),t),Ly=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Vt(r))},qy=async(t,n)=>Q(t,Vt(n)),Wn=async(t,n,a)=>Ye(t,n,Vt(a)),To=async(t,n,a)=>mt(t,n,Vt(a)),zs=async(t,n,a)=>st(t,n,Vt(a)),zy=async(t,n,a)=>Ea(t,{arg:n},Vt(a)),Ro=async(t,n,a)=>On(t,{arg:n},Vt(a)),Io=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>Ly({baseUrl:l,page:d,perPage:c},x)),ct=({url:t,token:n})=>G(n&&t?[t,n]:null,([r,o])=>qy(r,o)),Yy={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function Wy({value:t,onChange:n,placeholder:a}){const[r,o]=i.useState(t??""),l=i.useMemo(()=>typeof t=="string"?t:r,[r,t]);return e.jsx("div",{style:Yy,children:e.jsx(lo,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),n?.(c)},style:{outline:"none",minHeight:280},placeholder:a})})}function Ut({title:t,actions:n,children:a,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:a})}const Vy=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 Ys({token:t,title:n,fetchUrl:a,saveUrl:r,fieldName:o,initialHtmlFieldName:l}){const d=i.useRef(null),c=ct({url:a,token:t}),y=i.useMemo(()=>Vy(c.data),[c.data])?.[l??o]??"",[u,S]=i.useState("");i.useEffect(()=>{S(typeof y=="string"?y:"")},[y]);const j=()=>S(typeof y=="string"?y:""),w=()=>{const g=new Blob([String(u??"")],{type:"text/html"}),I=URL.createObjectURL(g),R=document.createElement("a");R.href=I,R.download=`${String(n??"legal").toLowerCase().replaceAll(" ","-")}.html`,R.click(),URL.revokeObjectURL(I)},m=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:j},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:w,disabled:!u}],[u,y]),h=async g=>{g.preventDefault();try{(await Ro(r,{[o]:u??""},t))?.Status==="Success"?_.success("Updated successfully.",{duration:1e3}):_.success("Updated.",{duration:1e3}),c.mutate?.()}catch(I){_.error(I?.response?.data?.msg??I?.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(Ut,{title:n,actions:m,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:h,children:[e.jsx(Wy,{value:u,onChange:S,placeholder:`Enter ${n} content...`}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Update"})})]})})})]})}const Hy=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ky=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function sn({token:t,value:n,onChange:a,action:r,accept:o,maxCount:l=1,previewUrl:d}){const c=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),x=i.useMemo(()=>n?d||(Ky(n)?n:""):"",[d,n]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[x?e.jsx("img",{src:x,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(s.Upload,{maxCount:l,action:r,accept:o,headers:c,onChange:y=>{if(y?.file?.status==="removed"&&a?.(""),y?.file?.status==="done"){const u=Hy(y?.file?.response);u&&a?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})]})}const At=lt.organization,Do=()=>qs(At.uploadLogo),ms=()=>qs(At.uploadSignature),Gy=()=>qs(At.uploadFirebaseJson),Jy=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:[]:[],Qy=({token:t})=>ct({url:At.get,token:t}),Xy=({token:t})=>ct({url:At.currencyDropdown,token:t}),Zy=({token:t})=>ct({url:At.countryCodeDropdown,token:t}),ef=({token:t})=>ct({url:At.timezoneDropdown,token:t}),tf=({token:t})=>ct({url:At.boardsDropdown,token:t}),da=t=>Jy(t?.data),Ri={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},nf=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),Ii=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],Di=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],af=t=>{const n=t?.data;return Array.isArray(n?.data)?n.data[0]??null:Array.isArray(n)?n[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},sf=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,rf=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function of({token:t}){const n=i.useRef(null),a=Qy({token:t}),r=Xy({token:t}),o=Zy({token:t}),l=ef({token:t}),d=tf({token:t}),c=i.useMemo(()=>af(a.data),[a.data]),x=i.useMemo(()=>sf(a.data),[a.data]),y=i.useMemo(()=>rf(a.data),[a.data]),u=i.useMemo(()=>da(r),[r.data]),S=i.useMemo(()=>da(o),[o.data]),j=i.useMemo(()=>da(l),[l.data]),w=i.useMemo(()=>da(d),[d.data]),[m,h]=i.useState(null),[g,I]=i.useState(null),[R,D]=i.useState(null),[C,f]=i.useState(null),[p,b]=i.useState([]),[A,O]=i.useState("No"),[L,U]=i.useState("yes"),[v,M]=i.useState("no"),[P,N]=i.useState("Yes"),[E,F]=i.useState(""),[q,z]=i.useState(""),[k,T]=i.useState(null),[$,B]=i.useState(null),[Y,ne]=i.useState(null),[H,W]=i.useState(null),Z=()=>{const V=(()=>{try{const oe=c?.weekly_off;if(!oe)return[];const Ce=Array.isArray(oe)?oe:JSON.parse(oe);return Array.isArray(Ce)?Ce.filter(Boolean).map(Oe=>({value:Oe,label:Oe})):[]}catch{return[]}})();b(V),h(u.find(oe=>oe?.value===c?.currency)??null),I(S.find(oe=>oe?.value===c?.country_code)??null),D(j.find(oe=>oe?.value===c?.time_zone)??null),f(w.find(oe=>oe?.value===c?.affliated_board_id)??null),F(c?.logo??""),z(c?.json_file??""),O(c?.attendance_salary_calculation??"No"),U(c?.salary_period??"yes"),M(c?.multiple_shift??"no"),N(c?.readmission_charges??"Yes"),T(x?.in_from?ae(x.in_from,"h:mm A"):null),B(x?.in_to?ae(x.in_to,"h:mm A"):null),ne(x?.out_from?ae(x.out_from,"h:mm A"):null),W(x?.out_to?ae(x.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&Z()},[c,u,S,j,w]);const se=()=>{n.current?.reset?.(),Z()},pe=()=>{const V=new FormData(n.current??void 0),oe=Object.fromEntries(V.entries());oe.weekly_off_day=p.map(Fe=>Fe?.value).filter(Boolean);const Ce=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),Oe=URL.createObjectURL(Ce),Pe=document.createElement("a");Pe.href=Oe,Pe.download="organization-setting.json",Pe.click(),URL.revokeObjectURL(Oe)},ve=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:se},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:pe,disabled:!c}],[c,p]),re=async V=>{V.preventDefault();try{const oe=new FormData(V.target);oe.set("currency",m?.value??""),oe.set("code",g?.value??""),oe.set("time_zone",R?.value??""),oe.set("affliated_board_id",C?.value??""),oe.set("board_name",C?.label??""),oe.set("attendance_salary_calculation",A),oe.set("salary_period",L),oe.set("multiple_shift",v),oe.set("readmission_charges",P),p.forEach(Pe=>{Pe?.value&&oe.append("weekly_off_day[]",Pe.value)}),oe.set("logo",E??""),oe.set("json_file",q??""),oe.set("server_key",y?.server_key??""),oe.set("in_time_start",k?ae(k).format("h:mm A"):""),oe.set("in_time_end",$?ae($).format("h:mm A"):""),oe.set("out_time_start",Y?ae(Y).format("h:mm A"):""),oe.set("out_time_end",H?ae(H).format("h:mm A"):""),await Wn(At.save,oe,t);const Oe={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:E||c?.logo||"",affliated_board_id:C?.value??c?.affliated_board_id??"",board_name:C?.label??c?.board_name??"",multiple_shift:v??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(Oe)),_.success("Organization settings saved.",{duration:1e3}),a.mutate?.()}catch(oe){_.error(oe?.response?.data?.msg??oe?.message??"Failed to save settings.",{duration:1500})}},ie=A==="Yes";return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ut,{title:"Organization",actions:ve,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:n,onSubmit:re,children:[e.jsxs("div",{style:Ri,children:[e.jsx(J,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"Currency*",options:u,value:m,onChange:V=>h(V)}),e.jsx("input",{type:"hidden",name:"currency",value:m?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Default Country Code*",options:S,value:g,onChange:V=>I(V)}),e.jsx("input",{type:"hidden",name:"code",value:g?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Time Zone*",options:j,value:R,onChange:V=>D(V)}),e.jsx("input",{type:"hidden",name:"time_zone",value:R?.value??""})]}),e.jsx(J,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(J,{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(s.Radio.Group,{options:Ii,optionType:"button",buttonStyle:"solid",value:P,onChange:V=>N(V.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:P})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Weekly off Day",options:nf,isMulti:!0,value:p,onChange:V=>b(V??[])}),p.map(V=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:V.value},V.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:k,onChange:V=>T(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:k?ae(k).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(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:$,onChange:V=>B(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:$?ae($).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(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:Y,onChange:V=>ne(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:Y?ae(Y).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(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:H,onChange:V=>W(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",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:"Salary Period"}),e.jsx(s.Radio.Group,{options:Di,optionType:"button",buttonStyle:"solid",value:L,onChange:V=>U(V.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:L})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(s.Radio.Group,{options:Ii,optionType:"button",buttonStyle:"solid",value:A,onChange:V=>O(V.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(s.Radio.Group,{options:Di,optionType:"button",buttonStyle:"solid",value:v,onChange:V=>M(V.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:v})]}),ie?e.jsx(J,{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(s.Divider,{}),e.jsxs("div",{style:Ri,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(sn,{token:t,action:Do(),value:E,accept:"image/*",onChange:V=>F(V)}),e.jsx("input",{type:"hidden",name:"logo",value:E??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Select Affiliated Board",options:w,value:C,onChange:V=>f(V)}),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(Ot,{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(sn,{token:t,action:Gy(),value:q,accept:".json",onChange:V=>z(V)}),e.jsx("input",{type:"hidden",name:"json_file",value:q??""})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function lf({token:t}){return e.jsx(of,{token:t})}const Ca=lt.academicYear,df=({token:t,page:n=1,perPage:a=10})=>Io({baseUrl:Ca.table,token:t,page:n,perPage:a}),cf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},uf=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:[],pf=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function mf({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(()=>{const p=ae(),b=ae().add(1,"year");return`${p.format("YYYY")}-${b.format("YYYY")}`}),[c,x]=i.useState(ae()),[y,u]=i.useState(ae().add(1,"year")),{isLoading:S,data:j,mutate:w}=df({token:t,page:n.page,perPage:n.rowsPerPage}),m=i.useMemo(()=>uf(j),[j]),h=i.useMemo(()=>pf(j,m.length),[j,m.length]),g=async()=>{if(!l){_.error("Session name is required.");return}if(y&&c&&ae(y).isBefore(c)){_.error("End date must be after start date.");return}try{const p=new FormData;p.set("name",l),p.set("start_date",c?ae(c).format("YYYY-MM-DD"):""),p.set("end_date",y?ae(y).format("YYYY-MM-DD"):""),await Wn(Ca.add,p,t),_.success("Academic year added.",{duration:1e3}),o(!1),w?.()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add academic year.",{duration:1500})}},I=async p=>{try{const b=new FormData;b.set("session",String(p)),await To(Ca.setActive,b,t);const A=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...A,session_id:String(p)})),_.success("Academic year activated.",{duration:1e3}),w?.()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to activate academic year.",{duration:1500})}},R=async p=>{try{await w(zs(Ca.remove,p,t)),_.success("Academic year deleted.",{duration:1e3})}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to delete academic year.",{duration:1500})}},D=()=>{const p=new Blob([JSON.stringify(m,null,2)],{type:"application/json"}),b=URL.createObjectURL(p),A=document.createElement("a");A.href=b,A.download="academic-years.json",A.click(),URL.revokeObjectURL(b)},C=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(X.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:()=>w?.()},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:D,disabled:m.length===0}],[m.length,w]),f=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:(p,b)=>{const A=b.status==="Active";return e.jsxs("span",{children:[e.jsx(s.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."):I(b.id)},okText:"Yes",cancelText:"No",children:e.jsx(s.Switch,{checked:A})}),A&&e.jsx(s.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(p,b)=>e.jsx(s.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>R(b.id),okText:"Yes",cancelText:"No",children:e.jsx(s.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,m.length]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ut,{title:"Academic Year",actions:C,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(s.Table,{rowKey:"id",dataSource:m,columns:f,loading:S,pagination:{current:n.page,pageSize:n.rowsPerPage,total:h,showSizeChanger:!0,onChange:(p,b)=>a({page:p,rowsPerPage:Number(b)})}})})}),e.jsx(s.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:cf,children:[e.jsx(J,{label:"Session Name*",value:l,onChange:p=>d(p.target.value)}),e.jsxs("div",{children:[e.jsx(xt,{Desplay:"Start Date*",value:c,onChange:p=>x(p),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?ae(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(xt,{Desplay:"End Date*",value:y,onChange:p=>u(p),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:y?ae(y).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{value:"Submit",type:"button",onClick:g}),e.jsx(s.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function yf({token:t}){return e.jsx(mf,{token:t})}const ko=lt.feeReceiptSetting,ff=({token:t})=>ct({url:ko.get,token:t}),ys={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},hf=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 gf({token:t}){const n=i.useRef(null),a=ff({token:t}),r=i.useMemo(()=>hf(a.data),[a.data]),[o,l]=i.useState(""),[d,c]=i.useState(!1),[x,y]=i.useState(!1),[u,S]=i.useState(!1),[j,w]=i.useState("0"),[m,h]=i.useState("0"),[g,I]=i.useState("0"),[R,D]=i.useState(!1),[C,f]=i.useState(!1),[p,b]=i.useState(""),[A,O]=i.useState(!1),L=()=>{l(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),y(String(r?.address??"0")==="1"),S(String(r?.gardian_name??"0")==="1"),w(String(r?.authorized_signatory??"0")),h(String(r?.parent_signatory??"0")),I(String(r?.dynamic_qr_code_device??"0")),D(String(r?.sequence_payment??"0")==="1"),f(String(r?.previois_fees??"0")==="1"),b(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&L()},[r]);const U=()=>{n.current?.reset?.(),L()},v=()=>{const N={number_of_receipt:o,rollnumber:d?1:0,address:x?1:0,gardianname:u?1:0,authorizedsignatory:j,parentsignatory:m,dynamic_qr_code_device:g,sequence_payment:R?1:0,previois_fees:C?1:0,upfront_payment_months:p},E=new Blob([JSON.stringify(N,null,2)],{type:"application/json"}),F=URL.createObjectURL(E),q=document.createElement("a");q.href=F,q.download="fee-receipt-setting.json",q.click(),URL.revokeObjectURL(F)},M=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:U},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:v,disabled:!r}],[r,o,d,x,u,j,m,g,R,C,p]),P=async N=>{N.preventDefault(),O(!0);try{const E=new FormData;E.set("number_of_receipt",String(o??"")),E.set("rollnumber",d?"1":"0"),E.set("address",x?"1":"0"),E.set("gardianname",u?"1":"0"),E.set("authorizedsignatory",String(j??"0")),E.set("parentsignatory",String(m??"0")),E.set("dynamic_qr_code_device",String(g??"0")),E.set("sequence_payment",R?"1":"0"),E.set("previois_fees",C?"1":"0"),E.set("upfront_payment_months",String(p??"")),await Wn(ko.save,E,t),_.success("Fee receipt settings updated.",{duration:1e3}),a.mutate?.()}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to update settings.",{duration:1500})}finally{O(!1)}};return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ut,{title:"Fee Receipt Setting",actions:M,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:n,onSubmit:P,children:[e.jsxs("div",{style:ys,children:[e.jsx(J,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:N=>l(N.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(s.Checkbox,{checked:d,onChange:N=>c(N.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(s.Checkbox,{checked:x,onChange:N=>y(N.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(s.Checkbox,{checked:u,onChange:N=>S(N.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:ys,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(s.Radio.Group,{value:j,onChange:N=>w(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.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(s.Radio.Group,{value:m,onChange:N=>h(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.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(s.Radio.Group,{value:g,onChange:N=>I(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:ys,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(s.Checkbox,{checked:R,onChange:N=>D(N.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(s.Checkbox,{checked:C,onChange:N=>f(N.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(J,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:p,onChange:N=>b(N.target.value)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:A?"Updating...":"Done",disabled:A})})]})})})]})}function xf({token:t}){return e.jsx(gf,{token:t})}const En=lt.marksheetSetting,bf=({token:t})=>ct({url:En.templateTypes,token:t}),Sf=({token:t})=>ct({url:En.classDropdown,token:t}),jf=({token:t})=>ct({url:En.assignedTable,token:t}),vf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},ki=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:[]:[],_f=Array.from({length:12},(t,n)=>({value:String(n+1),label:`Design ${n+1}`})),wf=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function Cf({token:t}){const n=i.useRef(null),a=bf({token:t}),r=Sf({token:t}),o=jf({token:t}),l=i.useMemo(()=>ki(a.data),[a.data]),d=i.useMemo(()=>ki(r.data),[r.data]),c=i.useMemo(()=>wf(o.data),[o.data]),[x,y]=i.useState(null),[u,S]=i.useState(null),[j,w]=i.useState([]),m=()=>{n.current?.reset?.(),y(null),S(null),w([])},h=()=>{const C=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),f=URL.createObjectURL(C),p=document.createElement("a");p.href=f,p.download="marksheet-templates.json",p.click(),URL.revokeObjectURL(f)},g=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:m},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:h,disabled:c.length===0}],[c.length]),I=async C=>{if(C.preventDefault(),!x?.value){_.error("Select marksheet type.",{duration:1200});return}if(!u?.value){_.error("Select design.",{duration:1200});return}if(!j?.length){_.error("Select at least one class.",{duration:1200});return}try{const f=new FormData;f.set("temp_id",String(x.value)),f.set("ui_id",String(u.value)),j.forEach(p=>f.append("class_id[]",String(p))),await Wn(En.assign,f,t),_.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),m()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to assign template.",{duration:1500})}},R=async C=>{try{await zs(En.remove,C,t),_.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to remove template.",{duration:1500})}},D=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,f)=>e.jsx(dt,{id:f?.id,funcName:R})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ut,{title:"Marksheet Setting",actions:g,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:n,onSubmit:I,children:[e.jsxs("div",{style:vf,children:[e.jsxs("div",{children:[e.jsx(ee,{label:"Select Marksheet Type",options:l,value:x,onChange:C=>y(C)}),e.jsx("input",{type:"hidden",name:"temp_id",value:x?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Select Design",options:_f,value:u,onChange:C=>S(C)}),e.jsx("input",{type:"hidden",name:"ui_id",value:u?.value??""})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(s.Checkbox.Group,{options:d,value:j,onChange:C=>w(C)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(s.Table,{size:"small",rowKey:"id",columns:D,dataSource:c,pagination:!1})})]})})]})}function Af({token:t}){return e.jsx(Cf,{token:t})}const fs={fetch:`${lt.legalPages.get}?page_name=terms`,save:lt.legalPages.termsSave,fieldName:"terms_data"};function Tf({token:t}){return e.jsx(Ys,{token:t,title:"Terms",fetchUrl:fs.fetch,saveUrl:fs.save,fieldName:fs.fieldName})}function Rf({token:t}){return e.jsx(Tf,{token:t})}const hs={fetch:`${lt.legalPages.get}?page_name=privacy`,save:lt.legalPages.privacySave,fieldName:"privacy_data"};function If({token:t}){return e.jsx(Ys,{token:t,title:"Privacy",fetchUrl:hs.fetch,saveUrl:hs.save,fieldName:hs.fieldName})}function Df({token:t}){return e.jsx(If,{token:t})}const gs={fetch:`${lt.legalPages.get}?page_name=about_us`,save:lt.legalPages.aboutSave,fieldName:"about_data"};function kf({token:t}){return e.jsx(Ys,{token:t,title:"About",fetchUrl:gs.fetch,saveUrl:gs.save,fieldName:gs.fieldName})}function Of({token:t}){return e.jsx(kf,{token:t})}const Ws=lt.feesInfo,Pf=({token:t})=>ct({url:Ws.get,token:t}),Ef=({token:t})=>ct({url:Ws.statesDropdown,token:t}),xs={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Mf=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,Ff=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],Nf=t=>t?Ao(`branch/logo/${t}`):"",bs=t=>t?Ao(`branch/signature/${t}`):"";function $f({token:t}){const n=i.useRef(null),a=Pf({token:t}),r=Ef({token:t}),o=i.useMemo(()=>Mf(a.data),[a.data]),l=i.useMemo(()=>Ff(r.data),[r.data]),[d,c]=i.useState(null),[x,y]=i.useState(""),[u,S]=i.useState(""),[j,w]=i.useState(""),[m,h]=i.useState(""),g=p=>{const b=new FormData(p),A=Object.fromEntries(b.entries());return A.state_id=d?.value??"",A.fees_receipt_logo=x,A.manager_signature=u,A.principal_signature=j,A.stamp=m,A},I=()=>{c(l.find(p=>String(p?.value)===String(o?.state_id??""))??null),y(o?.fees_receipt_logo??""),S(o?.manager_signature??""),w(o?.principal_signature??""),h(o?.stamp??"")};i.useEffect(()=>{o&&I()},[o,l]);const R=()=>{n.current?.reset?.(),I()},D=()=>{const p=g(n.current),b=new Blob([JSON.stringify(p,null,2)],{type:"application/json"}),A=URL.createObjectURL(b),O=document.createElement("a");O.href=A,O.download="fees-info.json",O.click(),URL.revokeObjectURL(A)},C=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:R},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:D,disabled:!o}],[o,d,x,u,j,m]),f=async p=>{p.preventDefault();try{const b=g(p.target);await zy(Ws.save,b,t),_.success("Fees info saved.",{duration:1e3}),a.mutate?.()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to save fees info.",{duration:1500})}};return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ut,{title:"Fees Info",actions:C,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:n,onSubmit:f,children:[e.jsxs("div",{style:xs,children:[e.jsx(J,{name:"Bussiness_name",label:"Business Name*",defaultValue:o?.name??"",required:!0}),e.jsx(J,{name:"cin",label:"Sub Heading",defaultValue:o?.cin??""}),e.jsx(J,{name:"school_no",type:"number",label:"School Number",defaultValue:o?.school_no??""}),e.jsx(J,{name:"website",label:"Website",defaultValue:o?.website??""}),e.jsx(J,{name:"school_Code",label:"School Code",defaultValue:o?.school_Code??""}),e.jsx(J,{name:"offical_number",label:"Official Number",defaultValue:o?.offical_number??""}),e.jsx(J,{name:"email_id",label:"Email",defaultValue:o?.email_id??""}),e.jsx(J,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:o?.receipt_prefix??""}),e.jsx(J,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:o?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"State",options:l,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(J,{name:"affiliation_no",label:"Affiliation Number",defaultValue:o?.affiliation_no??""}),e.jsx(J,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:o?.affiliation_desc??""}),e.jsx(J,{name:"udise_code",label:"UDISE Code",defaultValue:o?.udise_code??""}),e.jsx(J,{name:"color_code",label:"Primary Color",defaultValue:o?.color_code??""}),e.jsx(J,{name:"fontcolor_code",label:"Font Color",defaultValue:o?.fontcolor_code??""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:xs,children:[e.jsx(Ot,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(Ot,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:xs,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(sn,{token:t,action:Do(),value:x,previewUrl:Nf(x),accept:"image/*",onChange:y}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:x})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(sn,{token:t,action:ms(),value:u,previewUrl:bs(u),accept:"image/*",onChange:S}),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(sn,{token:t,action:ms(),value:j,previewUrl:bs(j),accept:"image/*",onChange:w}),e.jsx("input",{type:"hidden",name:"principal_signature",value:j})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(sn,{token:t,action:ms(),value:m,previewUrl:bs(m),accept:"image/*",onChange:h}),e.jsx("input",{type:"hidden",name:"stamp",value:m})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})})})]})}function Uf({token:t}){return e.jsx($f,{token:t})}const Aa=lt.payrollSettings,Bf=({token:t,page:n=1,perPage:a=10})=>Io({baseUrl:Aa.table,token:t,page:n,perPage:a}),Lf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Tn=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],Ss=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],qf=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],zf=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function Yf({token:t}){const n=i.useRef(null),a=i.useRef(null),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,x]=i.useState(null),[y,u]=i.useState(Tn[0]),[S,j]=i.useState(null),[w,m]=i.useState(null),[h,g]=i.useState(null),I=Bf({token:t,page:r.page,perPage:r.rowsPerPage}),R=i.useMemo(()=>qf(I.data),[I.data]),D=i.useMemo(()=>zf(I.data,R.length),[I.data,R.length]),C=async U=>{U.preventDefault();try{const v=new FormData(U.target);v.set("type",y?.value??""),v.set("amount_type",S?.value??""),await Wn(Aa.add,v,t),_.success("Payroll setting added.",{duration:1e3}),I.mutate?.(),U.target.reset(),j(null),u(Tn[0])}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to add payroll setting.",{duration:1500})}},f=U=>{x(U),m(Tn.find(v=>v.value===U?.type)??null),g(Ss.find(v=>v.value===U?.amount_type)??null),d(!0)},p=async U=>{U.preventDefault();try{const v=new FormData(U.target);v.set("id",String(c?.id??"")),v.set("type",w?.value??""),v.set("amount_type",h?.value??""),await To(Aa.edit,v,t),_.success("Payroll setting updated.",{duration:1e3}),d(!1),I.mutate?.()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to update payroll setting.",{duration:1500})}},b=async U=>{try{await zs(Aa.remove,U,t),_.success("Payroll setting deleted.",{duration:1e3}),I.mutate?.()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to delete payroll setting.",{duration:1500})}},A=()=>{const U=new Blob([JSON.stringify(R,null,2)],{type:"application/json"}),v=URL.createObjectURL(U),M=document.createElement("a");M.href=v,M.download="payroll-settings.json",M.click(),URL.revokeObjectURL(v)},O=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(X.PlusOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:()=>I.mutate?.()},{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:A,disabled:R.length===0}],[R.length]),L=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,v)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>f(v)}),e.jsx(s.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>b(v.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ut,{title:"Payroll Settings",actions:O,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:n,onSubmit:C,children:[e.jsxs("div",{style:Lf,children:[e.jsx(J,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(ee,{label:"Type",options:Tn,value:y,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:y?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:Ss,value:S,onChange:j}),e.jsx("input",{type:"hidden",name:"amount_type",value:S?.value??""})]}),e.jsx(J,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(de,{type:"submit",value:"Submit"})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(s.Table,{rowKey:"id",columns:L,dataSource:R,loading:I.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:D,showSizeChanger:!0,onChange:(U,v)=>o({page:U,rowsPerPage:Number(v)})}})})]})}),e.jsx(s.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:a,onSubmit:p,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"Type",options:Tn,value:w,onChange:m}),e.jsx("input",{type:"hidden",name:"type",value:w?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:Ss,value:h,onChange:g}),e.jsx("input",{type:"hidden",name:"amount_type",value:h?.value??""})]}),e.jsx(J,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Update"})})]})})})]})}function Wf({token:t}){return e.jsx(Yf,{token:t})}const Oo=lt.paymentGateway,Vf=({token:t})=>ct({url:Oo.get,token:t}),Hf=[{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"]}],Bt={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}},Oi=t=>{const n=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!n?.data)return Bt;try{const a=JSON.parse(n.data||"{}"),r=a?.data&&typeof a.data=="object"?a.data:a;return{Razorpay:{...Bt.Razorpay,...r?.Razorpay??{}},PhonePe:{...Bt.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...Bt.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...Bt.SabPaisa,...r?.SabPaisa??{}}}}catch{return Bt}};function Kf({token:t}){const n=i.useRef(null),a=Vf({token:t}),[r,o]=i.useState(Bt);i.useEffect(()=>{a.data&&o(Oi(a.data))},[a.data]);const l=(u,S,j)=>{o(w=>({...w,[u]:{...w[u],[S]:j}}))},d=()=>o(Oi(a.data)),c=()=>{const u=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),S=URL.createObjectURL(u),j=document.createElement("a");j.href=S,j.download="payment-gateway-settings.json",j.click(),URL.revokeObjectURL(S)},x=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:c}],[r,a.data]),y=async u=>{u.preventDefault();try{await Ro(Oo.save,{data:r},t),_.success("Payment gateway settings saved.",{duration:1e3}),a.mutate?.()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to save gateway settings.",{duration:1500})}};return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ut,{title:"Payment Gateway",actions:x,children:e.jsxs("form",{ref:n,onSubmit:y,style:{display:"grid",gap:20},children:[Hf.map(u=>{const S=r[u.id]??{};return e.jsx(s.Card,{title:e.jsx(s.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(s.Switch,{checked:!!S.isActive,onChange:j=>l(u.id,"isActive",j)})]}),e.jsx(s.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:u.fields.map(j=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:j}),e.jsx(s.Input,{value:S[j]??"",type:j.toLowerCase().includes("secret")||j.toLowerCase().includes("password")?"password":"text",onChange:w=>l(u.id,j,w.target.value)})]},j))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})})]})}function Gf({token:t}){return e.jsx(Kf,{token:t})}const Jf=({routes:t=[],onNavigate:n})=>e.jsx(s.Row,{gutter:[16,16],children:t.map((a,r)=>e.jsx(s.Col,{xs:24,md:8,lg:8,children:e.jsx(le,{children:e.jsx(Mi,{icon:a?.icon??"",title:a?.title??"",path:a?.path??"",onClick:n})})},`${r}route001`))});exports.About=Of;exports.AcademicYear=yf;exports.Academics=wm;exports.AddBook=wc;exports.AddDriver=bc;exports.AddStaff=Wu;exports.AdmissionEnquiry=Qd;exports.ApplyLeave=Ip;exports.AprroveLeaveRequest=vp;exports.AssignByClass=Qm;exports.AssignStudentToTransport=xc;exports.AssignSubjects=Km;exports.AssignTimeGroup=ry;exports.AssignVehicles=ic;exports.AttendanceDashboard=um;exports.BookList=Cc;exports.BuySellProduct=cu;exports.Category=Zc;exports.Class=Fm;exports.CoScholasticArea=my;exports.CreateTimeGroup=ey;exports.DailyAttendance=hm;exports.Department=Mp;exports.Designation=$p;exports.ErpDashboard=Eo;exports.FeeReceiptSetting=xf;exports.FeesInfo=Uf;exports.GeneralSetting=Uy;exports.Holidays=Ym;exports.IssueReturn=Tc;exports.LeaveType=Op;exports.LibraryAssignStudent=Rc;exports.LibraryCategory=Ic;exports.LibraryRenewalReport=kc;exports.LibraryReport=Dc;exports.ManageStock=_u;exports.MarksheetSetting=Af;exports.MenuSubmenu=Od;exports.MonthlyReport=bm;exports.Notes=xy;exports.NpmReport=Iu;exports.Organization=lf;exports.PaymentGateway=Gf;exports.Payroll=gp;exports.PayrollReceiptDetails=Gp;exports.PayrollSettings=Wf;exports.Privacy=Df;exports.Products=Gc;exports.PromoteStudents=dy;exports.RoutePage=Jf;exports.RouteTimeTable=Sc;exports.Sections=km;exports.SellReports=Su;exports.Shift=Lp;exports.StaffAttendance=lp;exports.StaffAttendanceReport=pp;exports.StaffDailyAttendance=Vp;exports.StaffDirectory=Ju;exports.StockReport=Ru;exports.Stoppage=vc;exports.StudentAttendance=mm;exports.SubCategory=ru;exports.Subjects=Bm;exports.Syllabus=Ty;exports.Terms=Rf;exports.TimeTable=$y;exports.TransferCertificate=_y;exports.TransportRoutes=Zd;exports.TransportVehicles=ec;exports.Unit=yu;exports.Vendor=Uc;exports.YearlyReport=_m;exports.setBaseUrl=gd;
|