ubk.erp.webpack 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Api/api.d.ts +13 -0
- package/dist/Layout/Library/LibraryRenewalReport.d.ts +5 -0
- package/dist/Layout/npm/NpmReport.d.ts +3 -0
- package/dist/Layout/npm/Services/npmService.d.ts +10 -0
- package/dist/Layout/npm/index.d.ts +1 -0
- package/dist/index.cjs +13 -13
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6261 -5673
- 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"),r=require("antd"),G=require("swr"),_=require("react-hot-toast"),i=require("react"),Je=require("swr/mutation"),Z=require("@ant-design/icons"),ae=require("dayjs"),Io=require("react-dom/server"),on=require("react-to-print"),Ti=require("react-select"),Ii=require("react-barcode"),Ro=()=>e.jsxs(r.Card,{style:{borderRadius:16},children:[e.jsx(r.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(r.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),ye=({width:t,height:n,display:a,justifyContent:s,alignItems:o,flexDirection:l,gap:d,style:c,children:x,...m})=>{const u={width:t,height:n,display:a,justifyContent:s,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:u,...m,children:x})},Me=({variant:t,fontWeight:n,style:a,children:s,...o})=>{const l=n==="bold"?700:n==="light"?300:n;return t==="h1"?e.jsx(r.Typography.Title,{level:1,style:{fontWeight:l,...a},...o,children:s}):t==="h2"?e.jsx(r.Typography.Title,{level:2,style:{fontWeight:l,...a},...o,children:s}):t==="h3"?e.jsx(r.Typography.Title,{level:3,style:{fontWeight:l,...a},...o,children:s}):t==="h4"?e.jsx(r.Typography.Title,{level:4,style:{fontWeight:l,...a},...o,children:s}):t==="h5"?e.jsx(r.Typography.Title,{level:5,style:{fontWeight:l,...a},...o,children:s}):e.jsx(r.Typography.Text,{style:{fontWeight:l,...a},...o,children:s})};function Ri({title:t="",icon:n="",path:a="",onClick:s}){const o=()=>{if(s){s(a);return}typeof window<"u"&&typeof a=="string"&&a.length>0&&window.location.assign(a)};return e.jsxs(r.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(ye,{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(ye,{style:{padding:"0 12px"},children:e.jsx(r.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(ye,{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 Di(t,n){return function(){return t.apply(n,arguments)}}const{toString:Do}=Object.prototype,{getPrototypeOf:Ca}=Object,{iterator:Aa,toStringTag:Oi}=Symbol,Ta=(t=>n=>{const a=Do.call(n);return t[a]||(t[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),yt=t=>(t=t.toLowerCase(),n=>Ta(n)===t),Ia=t=>n=>typeof n===t,{isArray:ln}=Array,nn=Ia("undefined");function Pn(t){return t!==null&&!nn(t)&&t.constructor!==null&&!nn(t.constructor)&&tt(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Pi=yt("ArrayBuffer");function Oo(t){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(t):n=t&&t.buffer&&Pi(t.buffer),n}const Po=Ia("string"),tt=Ia("function"),ki=Ia("number"),kn=t=>t!==null&&typeof t=="object",ko=t=>t===!0||t===!1,oa=t=>{if(Ta(t)!=="object")return!1;const n=Ca(t);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Oi in t)&&!(Aa in t)},Eo=t=>{if(!kn(t)||Pn(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Mo=yt("Date"),Fo=yt("File"),$o=t=>!!(t&&typeof t.uri<"u"),No=t=>t&&typeof t.getParts<"u",Uo=yt("Blob"),Bo=yt("FileList"),Lo=t=>kn(t)&&tt(t.pipe);function qo(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Vs=qo(),Ws=typeof Vs.FormData<"u"?Vs.FormData:void 0,zo=t=>{if(!t)return!1;if(Ws&&t instanceof Ws)return!0;const n=Ca(t);if(!n||n===Object.prototype||!tt(t.append))return!1;const a=Ta(t);return a==="formdata"||a==="object"&&tt(t.toString)&&t.toString()==="[object FormData]"},Yo=yt("URLSearchParams"),[Vo,Wo,Ho,Ko]=["ReadableStream","Request","Response","Headers"].map(yt),Go=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function En(t,n,{allOwnKeys:a=!1}={}){if(t===null||typeof t>"u")return;let s,o;if(typeof t!="object"&&(t=[t]),ln(t))for(s=0,o=t.length;s<o;s++)n.call(null,t[s],s,t);else{if(Pn(t))return;const l=a?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(s=0;s<d;s++)c=l[s],n.call(null,t[c],c,t)}}function Ei(t,n){if(Pn(t))return null;n=n.toLowerCase();const a=Object.keys(t);let s=a.length,o;for(;s-- >0;)if(o=a[s],n===o.toLowerCase())return o;return null}const Nt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Mi=t=>!nn(t)&&t!==Nt;function Ss(){const{caseless:t,skipUndefined:n}=Mi(this)&&this||{},a={},s=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&Ei(a,l)||l;oa(a[d])&&oa(o)?a[d]=Ss(a[d],o):oa(o)?a[d]=Ss({},o):ln(o)?a[d]=o.slice():(!n||!nn(o))&&(a[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&En(arguments[o],s);return a}const Jo=(t,n,a,{allOwnKeys:s}={})=>(En(n,(o,l)=>{a&&tt(o)?Object.defineProperty(t,l,{value:Di(o,a),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),t),Qo=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Xo=(t,n,a,s)=>{t.prototype=Object.create(n.prototype,s),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)},Zo=(t,n,a,s)=>{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],(!s||s(d,t,n))&&!c[d]&&(n[d]=t[d],c[d]=!0);t=a!==!1&&Ca(t)}while(t&&(!a||a(t,n))&&t!==Object.prototype);return n},el=(t,n,a)=>{t=String(t),(a===void 0||a>t.length)&&(a=t.length),a-=n.length;const s=t.indexOf(n,a);return s!==-1&&s===a},tl=t=>{if(!t)return null;if(ln(t))return t;let n=t.length;if(!ki(n))return null;const a=new Array(n);for(;n-- >0;)a[n]=t[n];return a},nl=(t=>n=>t&&n instanceof t)(typeof Uint8Array<"u"&&Ca(Uint8Array)),al=(t,n)=>{const s=(t&&t[Aa]).call(t);let o;for(;(o=s.next())&&!o.done;){const l=o.value;n.call(t,l[0],l[1])}},sl=(t,n)=>{let a;const s=[];for(;(a=t.exec(n))!==null;)s.push(a);return s},rl=yt("HTMLFormElement"),il=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,s,o){return s.toUpperCase()+o}),Hs=(({hasOwnProperty:t})=>(n,a)=>t.call(n,a))(Object.prototype),ol=yt("RegExp"),Fi=(t,n)=>{const a=Object.getOwnPropertyDescriptors(t),s={};En(a,(o,l)=>{let d;(d=n(o,l,t))!==!1&&(s[l]=d||o)}),Object.defineProperties(t,s)},ll=t=>{Fi(t,(n,a)=>{if(tt(t)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const s=t[a];if(tt(s)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},dl=(t,n)=>{const a={},s=o=>{o.forEach(l=>{a[l]=!0})};return ln(t)?s(t):s(String(t).split(n)),a},cl=()=>{},ul=(t,n)=>t!=null&&Number.isFinite(t=+t)?t:n;function pl(t){return!!(t&&tt(t.append)&&t[Oi]==="FormData"&&t[Aa])}const ml=t=>{const n=new Array(10),a=(s,o)=>{if(kn(s)){if(n.indexOf(s)>=0)return;if(Pn(s))return s;if(!("toJSON"in s)){n[o]=s;const l=ln(s)?[]:{};return En(s,(d,c)=>{const x=a(d,o+1);!nn(x)&&(l[c]=x)}),n[o]=void 0,l}}return s};return a(t,0)},fl=yt("AsyncFunction"),yl=t=>t&&(kn(t)||tt(t))&&tt(t.then)&&tt(t.catch),$i=((t,n)=>t?setImmediate:n?((a,s)=>(Nt.addEventListener("message",({source:o,data:l})=>{o===Nt&&l===a&&s.length&&s.shift()()},!1),o=>{s.push(o),Nt.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",tt(Nt.postMessage)),hl=typeof queueMicrotask<"u"?queueMicrotask.bind(Nt):typeof process<"u"&&process.nextTick||$i,gl=t=>t!=null&&tt(t[Aa]),K={isArray:ln,isArrayBuffer:Pi,isBuffer:Pn,isFormData:zo,isArrayBufferView:Oo,isString:Po,isNumber:ki,isBoolean:ko,isObject:kn,isPlainObject:oa,isEmptyObject:Eo,isReadableStream:Vo,isRequest:Wo,isResponse:Ho,isHeaders:Ko,isUndefined:nn,isDate:Mo,isFile:Fo,isReactNativeBlob:$o,isReactNative:No,isBlob:Uo,isRegExp:ol,isFunction:tt,isStream:Lo,isURLSearchParams:Yo,isTypedArray:nl,isFileList:Bo,forEach:En,merge:Ss,extend:Jo,trim:Go,stripBOM:Qo,inherits:Xo,toFlatObject:Zo,kindOf:Ta,kindOfTest:yt,endsWith:el,toArray:tl,forEachEntry:al,matchAll:sl,isHTMLForm:rl,hasOwnProperty:Hs,hasOwnProp:Hs,reduceDescriptors:Fi,freezeMethods:ll,toObjectSet:dl,toCamelCase:il,noop:cl,toFiniteNumber:ul,findKey:Ei,global:Nt,isContextDefined:Mi,isSpecCompliantForm:pl,toJSONObject:ml,isAsyncFn:fl,isThenable:yl,setImmediate:$i,asap:hl,isIterable:gl};let _e=class Ni extends Error{static from(n,a,s,o,l,d){const c=new Ni(n.message,a||n.code,s,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,s,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),s&&(this.config=s),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 xl=null;function js(t){return K.isPlainObject(t)||K.isArray(t)}function Ui(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=Ui(o),!a&&l?"["+o+"]":o}).join(a?".":""):n}function bl(t){return K.isArray(t)&&!t.some(js)}const Sl=K.toFlatObject(K,{},null,function(n){return/^is[A-Z]/.test(n)});function Ra(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(h,R){return!K.isUndefined(R[h])});const s=a.metaTokens,o=a.visitor||b,l=a.dots,d=a.indexes,c=a.Blob||typeof Blob<"u"&&Blob,x=a.maxDepth===void 0?100:a.maxDepth,m=c&&K.isSpecCompliantForm(n);if(!K.isFunction(o))throw new TypeError("visitor must be a function");function u(y){if(y===null)return"";if(K.isDate(y))return y.toISOString();if(K.isBoolean(y))return y.toString();if(!m&&K.isBlob(y))throw new _e("Blob is not supported. Use a Buffer instead.");return K.isArrayBuffer(y)||K.isTypedArray(y)?m&&typeof Blob=="function"?new Blob([y]):Buffer.from(y):y}function b(y,h,R){let I=y;if(K.isReactNative(n)&&K.isReactNativeBlob(y))return n.append(Va(R,h,l),u(y)),!1;if(y&&!R&&typeof y=="object"){if(K.endsWith(h,"{}"))h=s?h:h.slice(0,-2),y=JSON.stringify(y);else if(K.isArray(y)&&bl(y)||(K.isFileList(y)||K.endsWith(h,"[]"))&&(I=K.toArray(y)))return h=Ui(h),I.forEach(function(C,g){!(K.isUndefined(C)||C===null)&&n.append(d===!0?Va([h],g,l):d===null?h:h+"[]",u(C))}),!1}return js(y)?!0:(n.append(Va(R,h,l),u(y)),!1)}const v=[],w=Object.assign(Sl,{defaultVisitor:b,convertValue:u,isVisitable:js});function p(y,h,R=0){if(!K.isUndefined(y)){if(R>x)throw new _e("Object is too deeply nested ("+R+" levels). Max depth: "+x,_e.ERR_FORM_DATA_DEPTH_EXCEEDED);if(v.indexOf(y)!==-1)throw Error("Circular reference detected in "+h.join("."));v.push(y),K.forEach(y,function(D,C){(!(K.isUndefined(D)||D===null)&&o.call(n,D,K.isString(C)?C.trim():C,h,w))===!0&&p(D,h?h.concat(C):[C],R+1)}),v.pop()}}if(!K.isObject(t))throw new TypeError("data must be an object");return p(t),n}function Ks(t){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(s){return n[s]})}function As(t,n){this._pairs=[],t&&Ra(t,this,n)}const Bi=As.prototype;Bi.append=function(n,a){this._pairs.push([n,a])};Bi.toString=function(n){const a=n?function(s){return n.call(this,s,Ks)}:Ks;return this._pairs.map(function(o){return a(o[0])+"="+a(o[1])},"").join("&")};function jl(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Li(t,n,a){if(!n)return t;const s=a&&a.encode||jl,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 As(n,o).toString(s),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class Gs{constructor(){this.handlers=[]}use(n,a,s){return this.handlers.push({fulfilled:n,rejected:a,synchronous:s?s.synchronous:!1,runWhen:s?s.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(s){s!==null&&n(s)})}}const Ts={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},vl=typeof URLSearchParams<"u"?URLSearchParams:As,_l=typeof FormData<"u"?FormData:null,wl=typeof Blob<"u"?Blob:null,Cl={isBrowser:!0,classes:{URLSearchParams:vl,FormData:_l,Blob:wl},protocols:["http","https","file","blob","url","data"]},Is=typeof window<"u"&&typeof document<"u",vs=typeof navigator=="object"&&navigator||void 0,Al=Is&&(!vs||["ReactNative","NativeScript","NS"].indexOf(vs.product)<0),Tl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Il=Is&&window.location.href||"http://localhost",Rl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Is,hasStandardBrowserEnv:Al,hasStandardBrowserWebWorkerEnv:Tl,navigator:vs,origin:Il},Symbol.toStringTag,{value:"Module"})),Ke={...Rl,...Cl};function Dl(t,n){return Ra(t,new Ke.classes.URLSearchParams,{visitor:function(a,s,o,l){return Ke.isNode&&K.isBuffer(a)?(this.append(s,a.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...n})}function Ol(t){return K.matchAll(/\w+|\[(\w*)]/g,t).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Pl(t){const n={},a=Object.keys(t);let s;const o=a.length;let l;for(s=0;s<o;s++)l=a[s],n[l]=t[l];return n}function qi(t){function n(a,s,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(s):[o[d],s]:o[d]=s,!c):((!o[d]||!K.isObject(o[d]))&&(o[d]=[]),n(a,s,o[d],l)&&K.isArray(o[d])&&(o[d]=Pl(o[d])),!c)}if(K.isFormData(t)&&K.isFunction(t.entries)){const a={};return K.forEachEntry(t,(s,o)=>{n(Ol(s),o,a,0)}),a}return null}const Ht=(t,n)=>t!=null&&K.hasOwnProp(t,n)?t[n]:void 0;function kl(t,n,a){if(K.isString(t))try{return(n||JSON.parse)(t),K.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(a||JSON.stringify)(t)}const Mn={transitional:Ts,adapter:["xhr","http","fetch"],transformRequest:[function(n,a){const s=a.getContentType()||"",o=s.indexOf("application/json")>-1,l=K.isObject(n);if(l&&K.isHTMLForm(n)&&(n=new FormData(n)),K.isFormData(n))return o?JSON.stringify(qi(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=Ht(this,"formSerializer");if(s.indexOf("application/x-www-form-urlencoded")>-1)return Dl(n,x).toString();if((c=K.isFileList(n))||s.indexOf("multipart/form-data")>-1){const m=Ht(this,"env"),u=m&&m.FormData;return Ra(c?{"files[]":n}:n,u&&new u,x)}}return l||o?(a.setContentType("application/json",!1),kl(n)):n}],transformResponse:[function(n){const a=Ht(this,"transitional")||Mn.transitional,s=a&&a.forcedJSONParsing,o=Ht(this,"responseType"),l=o==="json";if(K.isResponse(n)||K.isReadableStream(n))return n;if(n&&K.isString(n)&&(s&&!o||l)){const c=!(a&&a.silentJSONParsing)&&l;try{return JSON.parse(n,Ht(this,"parseReviver"))}catch(x){if(c)throw x.name==="SyntaxError"?_e.from(x,_e.ERR_BAD_RESPONSE,this,null,Ht(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=>{Mn.headers[t]={}});const El=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"]),Ml=t=>{const n={};let a,s,o;return t&&t.split(`
|
|
2
|
-
`).forEach(function(d){o=d.indexOf(":"),a=d.substring(0,o).trim().toLowerCase(),
|
|
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 s=new this(n);return a.forEach(o=>s.set(o)),s}static accessor(n){const s=(this[Js]=this[Js]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=un(d);s[c]||(ql(o,d),s[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(s){this[a]=s}}});K.freezeMethods(nt);function Ha(t,n){const a=this||Mn,s=n||a,o=nt.from(s.headers);let l=s.data;return K.forEach(t,function(c){l=c.call(a,l,o.normalize(),n?n.status:void 0)}),o.normalize(),l}function zi(t){return!!(t&&t.__CANCEL__)}let Fn=class extends _e{constructor(n,a,s){super(n??"canceled",_e.ERR_CANCELED,a,s),this.name="CanceledError",this.__CANCEL__=!0}};function Yi(t,n,a){const s=a.config.validateStatus;!a.status||!s||s(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 zl(t){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return n&&n[1]||""}function Yl(t,n){t=t||10;const a=new Array(t),s=new Array(t);let o=0,l=0,d;return n=n!==void 0?n:1e3,function(x){const m=Date.now(),u=s[l];d||(d=m),a[o]=x,s[o]=m;let b=l,v=0;for(;b!==o;)v+=a[b++],b=b%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),m-d<n)return;const w=u&&m-u;return w?Math.round(v*1e3/w):void 0}}function Vl(t,n){let a=0,s=1e3/n,o,l;const d=(m,u=Date.now())=>{a=u,o=null,l&&(clearTimeout(l),l=null),t(...m)};return[(...m)=>{const u=Date.now(),b=u-a;b>=s?d(m,u):(o=m,l||(l=setTimeout(()=>{l=null,d(o)},s-b)))},()=>o&&d(o)]}const wa=(t,n,a=3)=>{let s=0;const o=Yl(50,250);return Vl(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,x=c!=null?Math.min(d,c):d,m=Math.max(0,x-s),u=o(m);s=Math.max(s,x);const b={loaded:x,total:c,progress:c?x/c:void 0,bytes:m,rate:u||void 0,estimated:u&&c?(c-x)/u:void 0,event:l,lengthComputable:c!=null,[n?"download":"upload"]:!0};t(b)},a)},Qs=(t,n)=>{const a=t!=null;return[s=>n[0]({lengthComputable:a,total:t,loaded:s}),n[1]]},Xs=t=>(...n)=>K.asap(()=>t(...n)),Wl=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,Hl=Ke.hasStandardBrowserEnv?{write(t,n,a,s,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(s)&&c.push(`path=${s}`),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 Kl(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Gl(t,n){return n?t.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):t}function Vi(t,n,a){let s=!Kl(n);return t&&(s||a===!1)?Gl(t,n):n}const Zs=t=>t instanceof nt?{...t}:t;function qt(t,n){n=n||{};const a=Object.create(null);Object.defineProperty(a,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function s(m,u,b,v){return K.isPlainObject(m)&&K.isPlainObject(u)?K.merge.call({caseless:v},m,u):K.isPlainObject(u)?K.merge({},u):K.isArray(u)?u.slice():u}function o(m,u,b,v){if(K.isUndefined(u)){if(!K.isUndefined(m))return s(void 0,m,b,v)}else return s(m,u,b,v)}function l(m,u){if(!K.isUndefined(u))return s(void 0,u)}function d(m,u){if(K.isUndefined(u)){if(!K.isUndefined(m))return s(void 0,m)}else return s(void 0,u)}function c(m,u,b){if(K.hasOwnProp(n,b))return s(m,u);if(K.hasOwnProp(t,b))return s(void 0,m)}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:(m,u,b)=>o(Zs(m),Zs(u),b,!0)};return K.forEach(Object.keys({...t,...n}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const b=K.hasOwnProp(x,u)?x[u]:o,v=K.hasOwnProp(t,u)?t[u]:void 0,w=K.hasOwnProp(n,u)?n[u]:void 0,p=b(v,w,u);K.isUndefined(p)&&b!==c||(a[u]=p)}),a}const Wi=t=>{const n=qt({},t),a=v=>K.hasOwnProp(n,v)?n[v]:void 0,s=a("data");let o=a("withXSRFToken");const l=a("xsrfHeaderName"),d=a("xsrfCookieName");let c=a("headers");const x=a("auth"),m=a("baseURL"),u=a("allowAbsoluteUrls"),b=a("url");if(n.headers=c=nt.from(c),n.url=Li(Vi(m,b,u),t.params,t.paramsSerializer),x&&c.set("Authorization","Basic "+btoa((x.username||"")+":"+(x.password?unescape(encodeURIComponent(x.password)):""))),K.isFormData(s)){if(Ke.hasStandardBrowserEnv||Ke.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(K.isFunction(s.getHeaders)){const v=s.getHeaders(),w=["content-type","content-length"];Object.entries(v).forEach(([p,y])=>{w.includes(p.toLowerCase())&&c.set(p,y)})}}if(Ke.hasStandardBrowserEnv&&(K.isFunction(o)&&(o=o(n)),o===!0||o==null&&Wl(n.url))){const w=l&&d&&Hl.read(d);w&&c.set(l,w)}return n},Jl=typeof XMLHttpRequest<"u",Ql=Jl&&function(t){return new Promise(function(a,s){const o=Wi(t);let l=o.data;const d=nt.from(o.headers).normalize();let{responseType:c,onUploadProgress:x,onDownloadProgress:m}=o,u,b,v,w,p;function y(){w&&w(),p&&p(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let h=new XMLHttpRequest;h.open(o.method.toUpperCase(),o.url,!0),h.timeout=o.timeout;function R(){if(!h)return;const D=nt.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),g={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:D,config:t,request:h};Yi(function(S){a(S),y()},function(S){s(S),y()},g),h=null}"onloadend"in h?h.onloadend=R:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(R)},h.onabort=function(){h&&(s(new _e("Request aborted",_e.ECONNABORTED,t,h)),h=null)},h.onerror=function(C){const g=C&&C.message?C.message:"Network Error",f=new _e(g,_e.ERR_NETWORK,t,h);f.event=C||null,s(f),h=null},h.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const g=o.transitional||Ts;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),s(new _e(C,g.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,t,h)),h=null},l===void 0&&d.setContentType(null),"setRequestHeader"in h&&K.forEach(d.toJSON(),function(C,g){h.setRequestHeader(g,C)}),K.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),c&&c!=="json"&&(h.responseType=o.responseType),m&&([v,p]=wa(m,!0),h.addEventListener("progress",v)),x&&h.upload&&([b,w]=wa(x),h.upload.addEventListener("progress",b),h.upload.addEventListener("loadend",w)),(o.cancelToken||o.signal)&&(u=D=>{h&&(s(!D||D.type?new Fn(null,t,h):D),h.abort(),h=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const I=zl(o.url);if(I&&Ke.protocols.indexOf(I)===-1){s(new _e("Unsupported protocol "+I+":",_e.ERR_BAD_REQUEST,t));return}h.send(l||null)})},Xl=(t,n)=>{const{length:a}=t=t?t.filter(Boolean):[];if(n||a){let s=new AbortController,o;const l=function(m){if(!o){o=!0,c();const u=m instanceof Error?m:this.reason;s.abort(u instanceof _e?u:new Fn(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(m=>{m.unsubscribe?m.unsubscribe(l):m.removeEventListener("abort",l)}),t=null)};t.forEach(m=>m.addEventListener("abort",l));const{signal:x}=s;return x.unsubscribe=()=>K.asap(c),x}},Zl=function*(t,n){let a=t.byteLength;if(a<n){yield t;return}let s=0,o;for(;s<a;)o=s+n,yield t.slice(s,o),s=o},ed=async function*(t,n){for await(const a of td(t))yield*Zl(a,n)},td=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const n=t.getReader();try{for(;;){const{done:a,value:s}=await n.read();if(a)break;yield s}}finally{await n.cancel()}},er=(t,n,a,s)=>{const o=ed(t,n);let l=0,d,c=x=>{d||(d=!0,s&&s(x))};return new ReadableStream({async pull(x){try{const{done:m,value:u}=await o.next();if(m){c(),x.close();return}let b=u.byteLength;if(a){let v=l+=b;a(v)}x.enqueue(new Uint8Array(u))}catch(m){throw c(m),m}},cancel(x){return c(x),o.return()}},{highWaterMark:2})},tr=64*1024,{isFunction:zn}=K,nd=(({Request:t,Response:n})=>({Request:t,Response:n}))(K.global),{ReadableStream:nr,TextEncoder:ar}=K.global,sr=(t,...n)=>{try{return!!t(...n)}catch{return!1}},ad=t=>{t=K.merge.call({skipUndefined:!0},nd,t);const{fetch:n,Request:a,Response:s}=t,o=n?zn(n):typeof fetch=="function",l=zn(a),d=zn(s);if(!o)return!1;const c=o&&zn(nr),x=o&&(typeof ar=="function"?(p=>y=>p.encode(y))(new ar):async p=>new Uint8Array(await new a(p).arrayBuffer())),m=l&&c&&sr(()=>{let p=!1;const y=new a(Ke.origin,{body:new nr,method:"POST",get duplex(){return p=!0,"half"}}),h=y.headers.has("Content-Type");return y.body!=null&&y.body.cancel(),p&&!h}),u=d&&c&&sr(()=>K.isReadableStream(new s("").body)),b={stream:u&&(p=>p.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!b[p]&&(b[p]=(y,h)=>{let R=y&&y[p];if(R)return R.call(y);throw new _e(`Response type '${p}' is not supported`,_e.ERR_NOT_SUPPORT,h)})});const v=async p=>{if(p==null)return 0;if(K.isBlob(p))return p.size;if(K.isSpecCompliantForm(p))return(await new a(Ke.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(K.isArrayBufferView(p)||K.isArrayBuffer(p))return p.byteLength;if(K.isURLSearchParams(p)&&(p=p+""),K.isString(p))return(await x(p)).byteLength},w=async(p,y)=>{const h=K.toFiniteNumber(p.getContentLength());return h??v(y)};return async p=>{let{url:y,method:h,data:R,signal:I,cancelToken:D,timeout:C,onDownloadProgress:g,onUploadProgress:f,responseType:S,headers:A,withCredentials:P="same-origin",fetchOptions:L}=Wi(p),N=n||fetch;S=S?(S+"").toLowerCase():"text";let j=Xl([I,D&&D.toAbortSignal()],C),M=null;const k=j&&j.unsubscribe&&(()=>{j.unsubscribe()});let $;try{if(f&&m&&h!=="get"&&h!=="head"&&($=await w(A,R))!==0){let T=new a(y,{method:"POST",body:R,duplex:"half"}),F;if(K.isFormData(R)&&(F=T.headers.get("content-type"))&&A.setContentType(F),T.body){const[U,z]=Qs($,wa(Xs(f)));R=er(T.body,tr,U,z)}}K.isString(P)||(P=P?"include":"omit");const E=l&&"credentials"in a.prototype;if(K.isFormData(R)){const T=A.getContentType();T&&/^multipart\/form-data/i.test(T)&&!/boundary=/i.test(T)&&A.delete("content-type")}const B={...L,signal:j,method:h.toUpperCase(),headers:A.normalize().toJSON(),body:R,duplex:"half",credentials:E?P:void 0};M=l&&new a(y,B);let Y=await(l?N(M,L):N(y,B));const q=u&&(S==="stream"||S==="response");if(u&&(g||q&&k)){const T={};["status","statusText","headers"].forEach(ne=>{T[ne]=Y[ne]});const F=K.toFiniteNumber(Y.headers.get("content-length")),[U,z]=g&&Qs(F,wa(Xs(g),!0))||[];Y=new s(er(Y.body,tr,U,()=>{z&&z(),k&&k()}),T)}S=S||"text";let O=await b[K.findKey(b,S)||"text"](Y,p);return!q&&k&&k(),await new Promise((T,F)=>{Yi(T,F,{data:O,headers:nt.from(Y.headers),status:Y.status,statusText:Y.statusText,config:p,request:M})})}catch(E){throw k&&k(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,p,M,E&&E.response),{cause:E.cause||E}):_e.from(E,E&&E.code,p,M,E&&E.response)}}},sd=new Map,Hi=t=>{let n=t&&t.env||{};const{fetch:a,Request:s,Response:o}=n,l=[s,o,a];let d=l.length,c=d,x,m,u=sd;for(;c--;)x=l[c],m=u.get(x),m===void 0&&u.set(x,m=c?new Map:ad(n)),u=m;return m};Hi();const Rs={http:xl,xhr:Ql,fetch:{get:Hi}};K.forEach(Rs,(t,n)=>{if(t){try{Object.defineProperty(t,"name",{value:n})}catch{}Object.defineProperty(t,"adapterName",{value:n})}});const rr=t=>`- ${t}`,rd=t=>K.isFunction(t)||t===null||t===!1;function id(t,n){t=K.isArray(t)?t:[t];const{length:a}=t;let s,o;const l={};for(let d=0;d<a;d++){s=t[d];let c;if(o=s,!rd(s)&&(o=Rs[(c=String(s)).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,m])=>`adapter ${x} `+(m===!1?"is not supported by the environment":"is not available in the build"));let c=a?d.length>1?`since :
|
|
4
|
-
`+d.map(
|
|
5
|
-
`):" "+
|
|
6
|
-
`);return d===-1?"":o.stack.slice(d+1)})();try{if(!
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),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]&&Bl[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"),ql=/[^\x09\x20-\x7E\x80-\xFF]/g;function zl(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 mn(t){return t&&String(t).trim().toLowerCase()}function Yl(t){return zl(t.replace(ql,""))}function ca(t){return t===!1||t==null?t:K.isArray(t)?t.map(ca):Yl(String(t))}function Wl(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 Vl=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 Hl(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,a,r)=>a.toUpperCase()+r)}function Kl(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 tt=class{constructor(n){n&&this.set(n)}set(n,a,r){const o=this;function l(c,x,y){const u=mn(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]=ca(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())&&!Vl(n))d(Ll(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=mn(n),n){const r=K.findKey(this,n);if(r){const o=this[r];if(!a)return o;if(a===!0)return Wl(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=mn(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=mn(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]=ca(o),delete a[l];return}const c=n?Hl(l):String(l).trim();c!==l&&delete a[l],a[c]=ca(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=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 :
|
|
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:pd,adapters:Ds};function Ga(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new $n(null,t)}function or(t){return Ga(t),t.headers=tt.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||Nn.adapter,t)(t).then(function(r){return Ga(t),r.data=Ka.call(t,t.transformResponse,r),r.headers=tt.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=tt.from(r.response.headers))),Promise.reject(r)})}const to="1.15.2",Oa={};["object","boolean","number","function","string","symbol"].forEach((t,n)=>{Oa[t]=function(r){return typeof r===t||"a"+(n<1?"n ":" ")+t}});const lr={};Oa.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}};Oa.spelling=function(n){return(a,r)=>(console.warn(`${r} is likely a misspelling of ${n}`),!0)};function md(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 ua={assertOptions:md,validators:Oa},ct=ua.validators;let Lt=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
|
+
`);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
|
-
`,d+1),x=c===-1?"":l.slice(c+1);String(
|
|
9
|
-
`+l)}}catch{}}throw s}}_request(n,a){typeof n=="string"?(a=a||{},a.url=n):a=n||{},a=qt(this.defaults,a);const{transitional:s,paramsSerializer:o,headers:l}=a;s!==void 0&&da.assertOptions(s,{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}:da.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),da.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"],p=>{delete l[p]}),a.headers=nt.concat(d,l);const c=[];let x=!0;this.interceptors.request.forEach(function(y){if(typeof y.runWhen=="function"&&y.runWhen(a)===!1)return;x=x&&y.synchronous;const h=a.transitional||Ts;h&&h.legacyInterceptorReqResOrdering?c.unshift(y.fulfilled,y.rejected):c.push(y.fulfilled,y.rejected)});const m=[];this.interceptors.response.forEach(function(y){m.push(y.fulfilled,y.rejected)});let u,b=0,v;if(!x){const p=[ir.bind(this),void 0];for(p.unshift(...c),p.push(...m),v=p.length,u=Promise.resolve(a);b<v;)u=u.then(p[b++],p[b++]);return u}v=c.length;let w=a;for(;b<v;){const p=c[b++],y=c[b++];try{w=p(w)}catch(h){y.call(this,h);break}}try{u=ir.call(this,w)}catch(p){return Promise.reject(p)}for(b=0,v=m.length;b<v;)u=u.then(m[b++],m[b++]);return u}getUri(n){n=qt(this.defaults,n);const a=Vi(n.baseURL,n.url,n.allowAbsoluteUrls);return Li(a,n.params,n.paramsSerializer)}};K.forEach(["delete","get","head","options"],function(n){Ut.prototype[n]=function(a,s){return this.request(qt(s||{},{method:n,url:a,data:(s||{}).data}))}});K.forEach(["post","put","patch"],function(n){function a(s){return function(l,d,c){return this.request(qt(c||{},{method:n,headers:s?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Ut.prototype[n]=a(),Ut.prototype[n+"Form"]=a(!0)});let ld=class Ji{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 s=this;this.promise.then(o=>{if(!s._listeners)return;let l=s._listeners.length;for(;l-- >0;)s._listeners[l](o);s._listeners=null}),this.promise.then=o=>{let l;const d=new Promise(c=>{s.subscribe(c),l=c}).then(o);return d.cancel=function(){s.unsubscribe(l)},d},n(function(l,d,c){s.reason||(s.reason=new Fn(l,d,c),a(s.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=s=>{n.abort(s)};return this.subscribe(a),n.signal.unsubscribe=()=>this.unsubscribe(a),n.signal}static source(){let n;return{token:new Ji(function(o){n=o}),cancel:n}}};function dd(t){return function(a){return t.apply(null,a)}}function cd(t){return K.isObject(t)&&t.isAxiosError===!0}const _s={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(_s).forEach(([t,n])=>{_s[n]=t});function Qi(t){const n=new Ut(t),a=Di(Ut.prototype.request,n);return K.extend(a,Ut.prototype,n,{allOwnKeys:!0}),K.extend(a,n,null,{allOwnKeys:!0}),a.create=function(o){return Qi(qt(t,o))},a}const Ne=Qi(Mn);Ne.Axios=Ut;Ne.CanceledError=Fn;Ne.CancelToken=ld;Ne.isCancel=zi;Ne.VERSION=Gi;Ne.toFormData=Ra;Ne.AxiosError=_e;Ne.Cancel=Ne.CanceledError;Ne.all=function(n){return Promise.all(n)};Ne.spread=dd;Ne.isAxiosError=cd;Ne.mergeConfig=qt;Ne.AxiosHeaders=nt;Ne.formToJSON=t=>qi(K.isHTMLForm(t)?new FormData(t):t);Ne.getAdapter=Ki.getAdapter;Ne.HttpStatusCode=_s;Ne.default=Ne;const{Axios:My,AxiosError:Fy,CanceledError:$y,isCancel:Ny,CancelToken:Uy,VERSION:By,all:Ly,Cancel:qy,isAxiosError:zy,spread:Yy,toFormData:Vy,AxiosHeaders:Wy,HttpStatusCode:Hy,formToJSON:Ky,getAdapter:Gy,mergeConfig:Jy}=Ne,ud=()=>new Promise(t=>setTimeout(()=>t(),800));let ws=null;const pd=t=>{ws=t,mt.defaults.baseURL=Ds()},Ds=()=>ws||"https://npmapi.ubkerp.com/",mt=Ne.create({baseURL:Ds()}),at=()=>Ds(),Ye=async(t,n,a)=>{const s=await mt.post(t,n,{headers:{Authorization:a}});if(console.log("ddddfdfdfd",s.data?.Status),s.data?.Status=="Success")return s?.data?.data||s?.data;throw new Error(s.data?.msg)},Q=async(t,n)=>{try{let s=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";s=`${t}${l}session_id=1`}return(await mt.get(s,{headers:{Authorization:n}})).data}catch(a){throw a.response?.status===401&&console.error("401 Unauthorized"),a}},md=async(t,n)=>{const a=await mt.post(t,"",{headers:{Authorization:n}});if(a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},Oa=async(t,n,a)=>{try{console.log("========== ISSUE BOOK REQUEST =========="),console.log("URL:",mt.defaults.baseURL+t),console.log("DATA:",n),console.log("TOKEN:",a?"Present":"Missing");const s=await mt.post(t,n,{headers:{Authorization:a,"Content-Type":"application/json"}});return console.log("========== ISSUE BOOK RESPONSE =========="),console.log("STATUS:",s.status),console.log("DATA:",s.data),s.data?.Status==="Success"?s.data:(_.error(s.data?.msg||"Unable to issue library book",{duration:2e3}),!1)}catch(s){throw console.error("========== ISSUE BOOK ERROR =========="),console.error("HTTP STATUS:",s.response?.status),console.error("ERROR DATA:",s.response?.data),console.error("ERROR MESSAGE:",s.message),console.error("REQUEST DATA:",n),_.error(s.response?.data?.msg||s.response?.data?.message||"Request failed",{duration:2e3}),s}},Rn=async(t,n,a)=>{const s=n?.arg;return(await mt.post(t,s,{headers:{Authorization:a}}))?.data},Bt=async(t,n,a)=>{const s=n?.arg,o=t.includes("?")?"&":"?";return(await mt.get(t+o,{params:s,headers:{Authorization:a}}))?.data},fd="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Os=async(t,n,a)=>{const s=n?.arg,o=t.includes("?")?"&":"?",l=await mt.get(t+o,{params:s,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 ud(),(await mt.post(t,n,{headers:{Authorization:a}}))?.data),st=async(t,n,a)=>(await mt.delete(`${t}/${n}`,{headers:{Authorization:a}})).data,yd=({token:t,menu:n})=>{const{isLoading:a,data:s}=G(t?["api/sdk/Menus",t]:null,([l,d])=>md(l,d)),o=s?.find(l=>l.path===n)?.sub_menu??[];return console.log("menuData",s),e.jsx(r.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(r.Col,{xs:24,md:8,lg:8,children:e.jsx(ye,{children:e.jsx(Ri,{icon:`${at()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function Xi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qe={},Ga,lr;function hd(){return lr||(lr=1,Ga=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 s,o,l;if(Array.isArray(n)){if(s=n.length,s!=a.length)return!1;for(o=s;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),s=l.length,s!==Object.keys(a).length)return!1;for(o=s;o--!==0;)if(!Object.prototype.hasOwnProperty.call(a,l[o]))return!1;for(o=s;o--!==0;){var d=l[o];if(!t(n[d],a[d]))return!1}return!0}return n!==n&&a!==a}),Ga}var Yn={exports:{}},Vn={exports:{}},Re={};var dr;function gd(){if(dr)return Re;dr=1;var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,a=t?Symbol.for("react.portal"):60106,s=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,m=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,p=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,h=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function D(g){if(typeof g=="object"&&g!==null){var f=g.$$typeof;switch(f){case n:switch(g=g.type,g){case x:case m:case s:case l:case o:case b:return g;default:switch(g=g&&g.$$typeof,g){case c:case u:case p:case w:case d:return g;default:return f}}case a:return f}}}function C(g){return D(g)===m}return Re.AsyncMode=x,Re.ConcurrentMode=m,Re.ContextConsumer=c,Re.ContextProvider=d,Re.Element=n,Re.ForwardRef=u,Re.Fragment=s,Re.Lazy=p,Re.Memo=w,Re.Portal=a,Re.Profiler=l,Re.StrictMode=o,Re.Suspense=b,Re.isAsyncMode=function(g){return C(g)||D(g)===x},Re.isConcurrentMode=C,Re.isContextConsumer=function(g){return D(g)===c},Re.isContextProvider=function(g){return D(g)===d},Re.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===n},Re.isForwardRef=function(g){return D(g)===u},Re.isFragment=function(g){return D(g)===s},Re.isLazy=function(g){return D(g)===p},Re.isMemo=function(g){return D(g)===w},Re.isPortal=function(g){return D(g)===a},Re.isProfiler=function(g){return D(g)===l},Re.isStrictMode=function(g){return D(g)===o},Re.isSuspense=function(g){return D(g)===b},Re.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===s||g===m||g===l||g===o||g===b||g===v||typeof g=="object"&&g!==null&&(g.$$typeof===p||g.$$typeof===w||g.$$typeof===d||g.$$typeof===c||g.$$typeof===u||g.$$typeof===h||g.$$typeof===R||g.$$typeof===I||g.$$typeof===y)},Re.typeOf=D,Re}var De={};var cr;function xd(){return cr||(cr=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,s=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,m=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,p=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,h=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function D(ie){return typeof ie=="string"||typeof ie=="function"||ie===s||ie===m||ie===l||ie===o||ie===b||ie===v||typeof ie=="object"&&ie!==null&&(ie.$$typeof===p||ie.$$typeof===w||ie.$$typeof===d||ie.$$typeof===c||ie.$$typeof===u||ie.$$typeof===h||ie.$$typeof===R||ie.$$typeof===I||ie.$$typeof===y)}function C(ie){if(typeof ie=="object"&&ie!==null){var oe=ie.$$typeof;switch(oe){case n:var W=ie.type;switch(W){case x:case m:case s:case l:case o:case b:return W;default:var le=W&&W.$$typeof;switch(le){case c:case u:case p:case w:case d:return le;default:return oe}}case a:return oe}}}var g=x,f=m,S=c,A=d,P=n,L=u,N=s,j=p,M=w,k=a,$=l,E=o,B=b,Y=!1;function q(ie){return Y||(Y=!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.")),O(ie)||C(ie)===x}function O(ie){return C(ie)===m}function T(ie){return C(ie)===c}function F(ie){return C(ie)===d}function U(ie){return typeof ie=="object"&&ie!==null&&ie.$$typeof===n}function z(ie){return C(ie)===u}function ne(ie){return C(ie)===s}function H(ie){return C(ie)===p}function V(ie){return C(ie)===w}function X(ie){return C(ie)===a}function se(ie){return C(ie)===l}function ue(ie){return C(ie)===o}function ve(ie){return C(ie)===b}De.AsyncMode=g,De.ConcurrentMode=f,De.ContextConsumer=S,De.ContextProvider=A,De.Element=P,De.ForwardRef=L,De.Fragment=N,De.Lazy=j,De.Memo=M,De.Portal=k,De.Profiler=$,De.StrictMode=E,De.Suspense=B,De.isAsyncMode=q,De.isConcurrentMode=O,De.isContextConsumer=T,De.isContextProvider=F,De.isElement=U,De.isForwardRef=z,De.isFragment=ne,De.isLazy=H,De.isMemo=V,De.isPortal=X,De.isProfiler=se,De.isStrictMode=ue,De.isSuspense=ve,De.isValidElementType=D,De.typeOf=C})()),De}var ur;function Zi(){return ur||(ur=1,process.env.NODE_ENV==="production"?Vn.exports=gd():Vn.exports=xd()),Vn.exports}var Ja,pr;function bd(){if(pr)return Ja;pr=1;var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function s(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 m={};return"abcdefghijklmnopqrst".split("").forEach(function(u){m[u]=u}),Object.keys(Object.assign({},m)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Ja=o()?Object.assign:function(l,d){for(var c,x=s(l),m,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var b in c)n.call(c,b)&&(x[b]=c[b]);if(t){m=t(c);for(var v=0;v<m.length;v++)a.call(c,m[v])&&(x[m[v]]=c[m[v]])}}return x},Ja}var Qa,mr;function Ps(){if(mr)return Qa;mr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Qa=t,Qa}var Xa,fr;function eo(){return fr||(fr=1,Xa=Function.call.bind(Object.prototype.hasOwnProperty)),Xa}var Za,yr;function Sd(){if(yr)return Za;yr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=Ps(),a={},s=eo();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,m){if(process.env.NODE_ENV!=="production"){for(var u in l)if(s(l,u)){var b;try{if(typeof l[u]!="function"){var v=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 v.name="Invariant Violation",v}b=l[u](d,u,x,c,null,n)}catch(p){b=p}if(b&&!(b 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 b+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),b instanceof Error&&!(b.message in a)){a[b.message]=!0;var w=m?m():"";t("Failed "+c+" type: "+b.message+(w??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(a={})},Za=o,Za}var es,hr;function jd(){if(hr)return es;hr=1;var t=Zi(),n=bd(),a=Ps(),s=eo(),o=Sd(),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 es=function(c,x){var m=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function b(O){var T=O&&(m&&O[m]||O[u]);if(typeof T=="function")return T}var v="<<anonymous>>",w={array:R("array"),bigint:R("bigint"),bool:R("boolean"),func:R("function"),number:R("number"),object:R("object"),string:R("string"),symbol:R("symbol"),any:I(),arrayOf:D,element:C(),elementType:g(),instanceOf:f,node:L(),objectOf:A,oneOf:S,oneOfType:P,shape:j,exact:M};function p(O,T){return O===T?O!==0||1/O===1/T:O!==O&&T!==T}function y(O,T){this.message=O,this.data=T&&typeof T=="object"?T:{},this.stack=""}y.prototype=Error.prototype;function h(O){if(process.env.NODE_ENV!=="production")var T={},F=0;function U(ne,H,V,X,se,ue,ve){if(X=X||v,ue=ue||V,ve!==a){if(x){var ie=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 ie.name="Invariant Violation",ie}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var oe=X+":"+V;!T[oe]&&F<3&&(l("You are manually calling a React.PropTypes validation function for the `"+ue+"` prop on `"+X+"`. 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[oe]=!0,F++)}}return H[V]==null?ne?H[V]===null?new y("The "+se+" `"+ue+"` is marked as required "+("in `"+X+"`, but its value is `null`.")):new y("The "+se+" `"+ue+"` is marked as required in "+("`"+X+"`, but its value is `undefined`.")):null:O(H,V,X,se,ue)}var z=U.bind(null,!1);return z.isRequired=U.bind(null,!0),z}function R(O){function T(F,U,z,ne,H,V){var X=F[U],se=E(X);if(se!==O){var ue=B(X);return new y("Invalid "+ne+" `"+H+"` of type "+("`"+ue+"` supplied to `"+z+"`, expected ")+("`"+O+"`."),{expectedType:O})}return null}return h(T)}function I(){return h(d)}function D(O){function T(F,U,z,ne,H){if(typeof O!="function")return new y("Property `"+H+"` of component `"+z+"` has invalid PropType notation inside arrayOf.");var V=F[U];if(!Array.isArray(V)){var X=E(V);return new y("Invalid "+ne+" `"+H+"` of type "+("`"+X+"` supplied to `"+z+"`, expected an array."))}for(var se=0;se<V.length;se++){var ue=O(V,se,z,ne,H+"["+se+"]",a);if(ue instanceof Error)return ue}return null}return h(T)}function C(){function O(T,F,U,z,ne){var H=T[F];if(!c(H)){var V=E(H);return new y("Invalid "+z+" `"+ne+"` of type "+("`"+V+"` supplied to `"+U+"`, expected a single ReactElement."))}return null}return h(O)}function g(){function O(T,F,U,z,ne){var H=T[F];if(!t.isValidElementType(H)){var V=E(H);return new y("Invalid "+z+" `"+ne+"` of type "+("`"+V+"` supplied to `"+U+"`, expected a single ReactElement type."))}return null}return h(O)}function f(O){function T(F,U,z,ne,H){if(!(F[U]instanceof O)){var V=O.name||v,X=q(F[U]);return new y("Invalid "+ne+" `"+H+"` of type "+("`"+X+"` supplied to `"+z+"`, expected ")+("instance of `"+V+"`."))}return null}return h(T)}function S(O){if(!Array.isArray(O))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(F,U,z,ne,H){for(var V=F[U],X=0;X<O.length;X++)if(p(V,O[X]))return null;var se=JSON.stringify(O,function(ve,ie){var oe=B(ie);return oe==="symbol"?String(ie):ie});return new y("Invalid "+ne+" `"+H+"` of value `"+String(V)+"` "+("supplied to `"+z+"`, expected one of "+se+"."))}return h(T)}function A(O){function T(F,U,z,ne,H){if(typeof O!="function")return new y("Property `"+H+"` of component `"+z+"` has invalid PropType notation inside objectOf.");var V=F[U],X=E(V);if(X!=="object")return new y("Invalid "+ne+" `"+H+"` of type "+("`"+X+"` supplied to `"+z+"`, expected an object."));for(var se in V)if(s(V,se)){var ue=O(V,se,z,ne,H+"."+se,a);if(ue instanceof Error)return ue}return null}return h(T)}function P(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var T=0;T<O.length;T++){var F=O[T];if(typeof F!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Y(F)+" at index "+T+"."),d}function U(z,ne,H,V,X){for(var se=[],ue=0;ue<O.length;ue++){var ve=O[ue],ie=ve(z,ne,H,V,X,a);if(ie==null)return null;ie.data&&s(ie.data,"expectedType")&&se.push(ie.data.expectedType)}var oe=se.length>0?", expected one of type ["+se.join(", ")+"]":"";return new y("Invalid "+V+" `"+X+"` supplied to "+("`"+H+"`"+oe+"."))}return h(U)}function L(){function O(T,F,U,z,ne){return k(T[F])?null:new y("Invalid "+z+" `"+ne+"` supplied to "+("`"+U+"`, expected a ReactNode."))}return h(O)}function N(O,T,F,U,z){return new y((O||"React class")+": "+T+" type `"+F+"."+U+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+z+"`.")}function j(O){function T(F,U,z,ne,H){var V=F[U],X=E(V);if(X!=="object")return new y("Invalid "+ne+" `"+H+"` of type `"+X+"` "+("supplied to `"+z+"`, expected `object`."));for(var se in O){var ue=O[se];if(typeof ue!="function")return N(z,ne,H,se,B(ue));var ve=ue(V,se,z,ne,H+"."+se,a);if(ve)return ve}return null}return h(T)}function M(O){function T(F,U,z,ne,H){var V=F[U],X=E(V);if(X!=="object")return new y("Invalid "+ne+" `"+H+"` of type `"+X+"` "+("supplied to `"+z+"`, expected `object`."));var se=n({},F[U],O);for(var ue in se){var ve=O[ue];if(s(O,ue)&&typeof ve!="function")return N(z,ne,H,ue,B(ve));if(!ve)return new y("Invalid "+ne+" `"+H+"` key `"+ue+"` supplied to `"+z+"`.\nBad object: "+JSON.stringify(F[U],null," ")+`
|
|
10
|
-
Valid keys: `+JSON.stringify(Object.keys(O),null," "));var ie=ve(V,ue,z,ne,H+"."+ue,a);if(ie)return ie}return null}return h(T)}function k(O){switch(typeof O){case"number":case"string":case"undefined":return!0;case"boolean":return!O;case"object":if(Array.isArray(O))return O.every(k);if(O===null||c(O))return!0;var T=b(O);if(T){var F=T.call(O),U;if(T!==O.entries){for(;!(U=F.next()).done;)if(!k(U.value))return!1}else for(;!(U=F.next()).done;){var z=U.value;if(z&&!k(z[1]))return!1}}else return!1;return!0;default:return!1}}function $(O,T){return O==="symbol"?!0:T?T["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&T instanceof Symbol:!1}function E(O){var T=typeof O;return Array.isArray(O)?"array":O instanceof RegExp?"object":$(T,O)?"symbol":T}function B(O){if(typeof O>"u"||O===null)return""+O;var T=E(O);if(T==="object"){if(O instanceof Date)return"date";if(O instanceof RegExp)return"regexp"}return T}function Y(O){var T=B(O);switch(T){case"array":case"object":return"an "+T;case"boolean":case"date":case"regexp":return"a "+T;default:return T}}function q(O){return!O.constructor||!O.constructor.name?v:O.constructor.name}return w.checkPropTypes=o,w.resetWarningCache=o.resetWarningCache,w.PropTypes=w,w},es}var ts,gr;function vd(){if(gr)return ts;gr=1;var t=Ps();function n(){}function a(){}return a.resetWarningCache=n,ts=function(){function s(d,c,x,m,u,b){if(b!==t){var v=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 v.name="Invariant Violation",v}}s.isRequired=s;function o(){return s}var l={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:o,element:s,elementType:s,instanceOf:o,node:s,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:a,resetWarningCache:n};return l.PropTypes=l,l},ts}var xr;function to(){if(xr)return Yn.exports;if(xr=1,process.env.NODE_ENV!=="production"){var t=Zi(),n=!0;Yn.exports=jd()(t.isElement,n)}else Yn.exports=vd()();return Yn.exports}var br;function _d(){if(br)return qe;br=1;var t=qe&&qe.__extends||(function(){var w=function(p,y){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,R){h.__proto__=R}||function(h,R){for(var I in R)Object.prototype.hasOwnProperty.call(R,I)&&(h[I]=R[I])},w(p,y)};return function(p,y){if(typeof y!="function"&&y!==null)throw new TypeError("Class extends value "+String(y)+" is not a constructor or null");w(p,y);function h(){this.constructor=p}p.prototype=y===null?Object.create(y):(h.prototype=y.prototype,new h)}})(),n=qe&&qe.__assign||function(){return n=Object.assign||function(w){for(var p,y=1,h=arguments.length;y<h;y++){p=arguments[y];for(var R in p)Object.prototype.hasOwnProperty.call(p,R)&&(w[R]=p[R])}return w},n.apply(this,arguments)},a=qe&&qe.__createBinding||(Object.create?(function(w,p,y,h){h===void 0&&(h=y);var R=Object.getOwnPropertyDescriptor(p,y);(!R||("get"in R?!p.__esModule:R.writable||R.configurable))&&(R={enumerable:!0,get:function(){return p[y]}}),Object.defineProperty(w,h,R)}):(function(w,p,y,h){h===void 0&&(h=y),w[h]=p[y]})),s=qe&&qe.__setModuleDefault||(Object.create?(function(w,p){Object.defineProperty(w,"default",{enumerable:!0,value:p})}):function(w,p){w.default=p}),o=qe&&qe.__importStar||function(w){if(w&&w.__esModule)return w;var p={};if(w!=null)for(var y in w)y!=="default"&&Object.prototype.hasOwnProperty.call(w,y)&&a(p,w,y);return s(p,w),p},l=qe&&qe.__rest||function(w,p){var y={};for(var h in w)Object.prototype.hasOwnProperty.call(w,h)&&p.indexOf(h)<0&&(y[h]=w[h]);if(w!=null&&typeof Object.getOwnPropertySymbols=="function")for(var R=0,h=Object.getOwnPropertySymbols(w);R<h.length;R++)p.indexOf(h[R])<0&&Object.prototype.propertyIsEnumerable.call(w,h[R])&&(y[h[R]]=w[h[R]]);return y},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(hd()),m=o(to());function u(w){return w&&w.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function b(w){var p=document.createTextNode("");w.appendChild(p);var y=document.activeElement===w;if(p!==null&&p.nodeValue!==null&&y){var h=window.getSelection();if(h!==null){var R=document.createRange();R.setStart(p,p.nodeValue.length),R.collapse(!0),h.removeAllRanges(),h.addRange(R)}w instanceof HTMLElement&&w.focus()}}var v=(function(w){t(p,w);function p(){var y=w!==null&&w.apply(this,arguments)||this;return y.lastHtml=y.props.html,y.el=typeof y.props.innerRef=="function"?{current:null}:c.createRef(),y.getEl=function(){return(y.props.innerRef&&typeof y.props.innerRef!="function"?y.props.innerRef:y.el).current},y.emitChange=function(h){var R=y.getEl();if(R){var I=R.innerHTML;if(y.props.onChange&&I!==y.lastHtml){var D=Object.assign({},h,{target:{value:I}});y.props.onChange(D)}y.lastHtml=I}},y}return p.prototype.render=function(){var y=this,h=this.props,R=h.tagName,I=h.html,D=h.innerRef,C=l(h,["tagName","html","innerRef"]);return c.createElement(R||"div",n(n({},C),{ref:typeof D=="function"?function(g){D(g),y.el.current=g}: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:I}}),this.props.children)},p.prototype.shouldComponentUpdate=function(y){var h=this.props,R=this.getEl();return!R||u(y.html)!==u(R.innerHTML)?!0:h.disabled!==y.disabled||h.tagName!==y.tagName||h.className!==y.className||h.innerRef!==y.innerRef||h.placeholder!==y.placeholder||!(0,x.default)(h.style,y.style)},p.prototype.componentDidUpdate=function(){var y=this.getEl();y&&(this.props.html!==y.innerHTML&&(y.innerHTML=this.props.html),this.lastHtml=this.props.html,b(y))},p.propTypes={html:m.string.isRequired,onChange:m.func,disabled:m.bool,tagName:m.string,className:m.string,style:m.object,innerRef:m.oneOfType([m.object,m.func])},p})(c.Component);return qe.default=v,qe}var wd=_d();const no=Xi(wd),Cd={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ad={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,...s},o)=>{const[l,d]=i.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[s.label&&e.jsx("label",{className:"labelfont",style:Cd,children:s.label}),e.jsx("input",{placeholder:s.placeholder||s.label,...s,ref:o,onFocus:c=>{d(!0),n?.(c)},onBlur:c=>{d(!1),a?.(c)},style:{...Ad,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),Sr=[{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 ks(t){const n=ae().year(),a=[];for(let s=n;s>=n-t;s--)a.push({label:String(s),value:s});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 Es(t){const n=ae().year(),a=ae().month();return t<n?Sr:Sr.slice(0,a+1)}function jr(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 Td(){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 ao=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(r.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(r.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(r.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 pn={},mn={},it={},fn={},Kt={},vr;function Id(){if(vr)return Kt;vr=1;var t=Kt&&Kt.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Kt,"__esModule",{value:!0});const n=t(i),a=Io,s=["string","number","boolean"];function o({header:l,body:d}){const c=n.default.createElement("tr",null,l.map(m=>n.default.createElement("th",{key:m},m))),x=d.map((m,u)=>Array.isArray(m)?n.default.createElement("tr",{key:u},m.map((b,v)=>n.default.createElement("th",{key:v}," ",b," "))):m!==null&&typeof m=="object"?n.default.createElement("tr",{key:u},Object.entries(m).map(([b,v],w)=>typeof v=="object"?(console.error(`typeof ${b} is incorrect, only accept ${s.join(", ")} `),n.default.createElement("th",{key:w})):n.default.createElement("th",{key:w},n.default.createElement(n.default.Fragment,null,v)))):(console.error(`
|
|
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(`
|
|
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 Kt.default=o,Kt}var _r;function Rd(){return _r||(_r=1,(function(t){var n=fn&&fn.__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 s(l,d){return l.replace(/{(\w+)}/g,(c,x)=>d[x])}t.format=s,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=Id();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return n(o).default}})})(fn)),fn}var wr;function so(){if(wr)return it;wr=1;var t=it&&it.__createBinding||(Object.create?(function(m,u,b,v){v===void 0&&(v=b);var w=Object.getOwnPropertyDescriptor(u,b);(!w||("get"in w?!u.__esModule:w.writable||w.configurable))&&(w={enumerable:!0,get:function(){return u[b]}}),Object.defineProperty(m,v,w)}):(function(m,u,b,v){v===void 0&&(v=b),m[v]=u[b]})),n=it&&it.__setModuleDefault||(Object.create?(function(m,u){Object.defineProperty(m,"default",{enumerable:!0,value:u})}):function(m,u){m.default=u}),a=it&&it.__importStar||function(m){if(m&&m.__esModule)return m;var u={};if(m!=null)for(var b in m)b!=="default"&&Object.prototype.hasOwnProperty.call(m,b)&&t(u,m,b);return n(u,m),u};Object.defineProperty(it,"__esModule",{value:!0}),it.downloadExcel=it.excel=void 0;const s=a(Rd());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(m,u){const b=window.document.createElement("a");return b.href=s.uri+s.base64(s.format(s.template,u)),b.download=m,document.body.appendChild(b),b.click(),document.body.removeChild(b),!0}function d(m,u){if(m)return m.cloneNode(!0).outerHTML;if(u)return s.createTable(u);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:m,sheet:u,tablePayload:b},v){if(!o())return!1;const w=d(v,b);return l(m,{worksheet:u||"Worksheet",table:w})}it.downloadExcel=c;function x({currentTableRef:m,filename:u,sheet:b}){function v(){if(!o())return!1;const w=d(m),p=`${u}.xls`;return l(p,{worksheet:b||"Worksheet",table:w})}return{onDownload:v}}return it.excel=x,it}var Cr;function Dd(){if(Cr)return mn;Cr=1,Object.defineProperty(mn,"__esModule",{value:!0}),mn.useDownloadExcel=void 0;const t=i,n=so();function a({currentTableRef:s,filename:o,sheet:l}){const[d,c]=(0,t.useState)({});return(0,t.useEffect)(()=>{c({currentTableRef:s,filename:o,sheet:l})},[s,o,l]),(0,t.useMemo)(()=>(0,n.excel)(d),[d])}return mn.useDownloadExcel=a,mn}var Ar;function Od(){return Ar||(Ar=1,(function(t){var n=pn&&pn.__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),s=Dd();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return s.useDownloadExcel}});const o=so();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:x,children:m})=>{const{onDownload:u}=(0,s.useDownloadExcel)({currentTableRef:d,filename:c,sheet:x});return a.default.createElement("span",{onClick:u},m)};t.DownloadTableExcel=l})(pn)),pn}var ro=Od();const Pa=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:n}=t.data;t?.tableRef;const a=new Date().getTime(),s=on.useReactToPrint({content:()=>n.current});return e.jsx(e.Fragment,{children:e.jsx(r.Row,{justify:"end",children:e.jsx(r.Col,{children:e.jsxs(r.Row,{gutter:8,children:[e.jsx(r.Col,{children:e.jsx(r.Button,{type:"text",icon:e.jsx(Z.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:s})}),e.jsx(r.Col,{children:e.jsx(ro.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:n.current,children:e.jsx(r.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},vt=t=>{const{tableRef:n}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(r.Row,{justify:"center",children:e.jsx(r.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},Pd=i.createContext(),kd=()=>({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:s,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:x,open:m,ActionView:u,viewDetails:b,myType:v,type:w,urlkey:p,columnstype:y,rowSelection:h}=t.data,R=kd(),[I,D]=i.useState(!1),[C,g]=i.useState(null),[f,S]=i.useState("false"),[A,P]=i.useState(!1),[L,N]=i.useState(!1),[j,M]=i.useState(),[k,$]=i.useState(""),E=()=>D(!1),B=te=>{S(te),D(!0)},[Y,q]=i.useState(),[O,T]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),F=i.useRef(null),U=(te,pe)=>{t.parentCallback?.(te,pe),T({rowsPerPage:pe,page:te})},z=(te,pe)=>{g(pe),P(!0),M(te)},ne=(te,pe)=>{g(pe),N(!0),M(te)},H=t?.data?.onNavigate??t?.onNavigate,V=(te,pe)=>{if(typeof H=="function"){H(te,pe);return}typeof window<"u"&&typeof te=="string"&&te.length>0&&window.location.assign(te)},X=te=>{if(w==="staff"){V(`/HumanResourceDashboard/StaffFullInformation?id=${te.fk_staffID}`,te);return}V(`/StudentInformation/StudentFullInformation?id=${te.id}`,te)},se=(te,pe)=>{q(te),s?.(pe)},ue=async(te,pe,he,Te)=>{s?.(!0),he!==""&&((await Te({id:te,admission_no:pe,ec_no:he}))?.Status==="Success"?r.message.success("Ec No updated successfully"):r.message.error("Failed to Update Ec No."))},ve=()=>e.jsx(Pd.Provider,{value:Y,children:o}),{trigger:ie}=Je("branchapi/staff/updateStaffPassword",Rn),{trigger:oe}=Je("branchapi/Student/updateEcNo",Rn),{trigger:W}=Je(p,(te,pe)=>Rn("student/studentDetails/editStudentLogInCredential",pe)),le=async te=>{te.preventDefault(),P(!1);try{(await ie({staff_id:j,new_passwod:te.target.password.value}))?.Status==="Success"?r.message.success("Password updated successfully"):r.message.error("Failed to update password")}catch{r.message.error("Failed to update password")}},Ce=async te=>{te.preventDefault(),N(!1);try{(await W({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"?r.message.success("Password updated successfully"):r.message.error("Failed to update password")}catch(pe){r.message.error(pe?.response?.data?.msg??"Failed to update password")}},Pe=(Array.isArray(n)?n:[]).some(te=>te?.fixed==="left"),ke=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:y==="antd"&&Pe?"left":void 0,sorter:(te,pe)=>(te.__serialNumber??0)-(pe.__serialNumber??0),render:te=>te},...y==="antd"?n:(Array.isArray(n)?n:[]).map(te=>({title:te.name,dataIndex:te.selector,key:te.selector,sorter:te.sorter||(te.sortable?(pe,he)=>{const Te=pe[te.selector]??"",Ie=he[te.selector]??"";return typeof Te=="number"&&typeof Ie=="number"?Te-Ie:String(Te).localeCompare(String(Ie))}:!1),render:(pe,he)=>{switch(te.selector){case"my_staff":return he.staff_id!=="0"?he.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(r.Image,{width:50,src:`undefined/branch/gallery/${he.gallery_cat_logo}`});case"file01":return he.documents?e.jsx("div",{onClick:()=>B(`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(pe);case"full_name":return e.jsx("span",{onClick:()=>X(he),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:pe||`${he.firstname} ${he.lastname}`});case"extra_curricular_activity":return pe==="Yes"?"Extra Subject":"Fees Master";case"is_active":return pe==="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(r.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:()=>z(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(r.Tag,{onClick:()=>b?.(he.id),color:pe==="paid"?"#66aa18":pe==="partially_paid"?"#ff5722":"#DC143C",children:pe==="paid"?"Paid":pe==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return Td().find(Te=>Te.value===pe)?.label;case"status":return e.jsx("span",{onClick:()=>b?.(he?.fk_staffID,he?.total_leave),className:`label ${pe==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:pe==="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(no,{html:he.ec_no,onBlur:Te=>ue(he.id,he.admission_no,Te.target.innerHTML,oe)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(r.Button,{type:"primary",icon:e.jsx(Z.SendOutlined,{}),size:"small",onClick:()=>se(he.id,!0,te.name),children:te.name});case"Button":return e.jsx(r.Tag,{color:"cyan",onClick:()=>b?.(he),children:te.name});default:return pe}}})),...a?[{title:"Action",key:"action",render:(te,pe)=>{const he=pe?.current_status==="Promoted",Te=()=>{if(v=="sameAddUpdate"){se(pe,!0);return}if(v?.type==="examEdit"){v.editFunc(pe.id);return}se(pe.id||pe,!0)},Ie=()=>{if(v==="student_result"){b?.(pe);return}if(v==="student"){b?.(pe.id,pe.class_id);return}b?.(pe.id)},ht=()=>{x?.(pe?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[u?.[0]?.status&&e.jsx(r.Button,{icon:e.jsx(Z.EditOutlined,{}),size:"small",disabled:he,onClick:Te}),u?.[1]?.status&&e.jsx(r.Button,{icon:e.jsx(Z.DeleteOutlined,{}),size:"small",danger:!0,disabled:he,onClick:ht}),u?.[2]?.status&&e.jsx(r.Button,{icon:e.jsx(Z.EyeOutlined,{}),size:"small",onClick:Ie})]})}}]:[]],$e=i.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Ee=i.useMemo(()=>{const te=k.trim().toLowerCase();return te?$e.filter(pe=>Object.values(pe??{}).some(he=>String(he??"").toLowerCase().includes(te))):$e},[$e,k]),We=!!t.parentCallback,He=k?Ee.length:l?.pagination?.total_rows??Ee.length,Be=(O.page-1)*O.rowsPerPage,Ve=We?Ee:Ee.slice(Be,Be+O.rowsPerPage),Xe=i.useMemo(()=>(Ve??[]).map((te,pe)=>({...te??{},__serialNumber:Be+pe+1})),[Be,Ve]),fe=He===0?0:Math.min(Be+1,He),xe=He===0?0:Math.min(Be+Ve.length,He);let ge;return d?ge=e.jsx("p",{children:"Loading..."}):c?ge=e.jsx("p",{children:c.message}):Ve.length?ge=e.jsx(r.Table,{dataSource:Xe,columns:ke,size:"small",bordered:!0,pagination:!1,rowSelection:h,rowKey:(te,pe)=>te?.id??te?._id??pe,scroll:{x:"max-content"}}):ge=e.jsx(r.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(r.Drawer,{open:m,placement:"right",onClose:()=>s?.(!1),width:720,children:ve()}),e.jsx(r.Modal,{title:"Update Password",open:A,onCancel:()=>P(!1),footer:null,children:e.jsx("form",{onSubmit:le,children:e.jsxs(ye,{children:[e.jsx(ye,{style:{marginBottom:12},children:e.jsx(J,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(ye,{style:{marginTop:16},children:e.jsx(r.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(r.Modal,{title:" Update Credential",open:L,onCancel:()=>N(!1),footer:null,children:e.jsx("form",{onSubmit:Ce,children:e.jsxs(ye,{children:[e.jsx(ye,{style:{marginBottom:12},children:e.jsx(J,{type:"text",label:"User Name",name:"username",required:"required",value:C?.username?C?.username:"",onChange:te=>g({...C,username:te.target.value})})}),e.jsx(ye,{style:{marginBottom:12},children:e.jsx(J,{label:"Password",name:"password",required:"required",value:C?.password?C?.password:"",onChange:te=>g({...C,password:te.target.value})})}),e.jsx(ye,{style:{marginTop:16},children:e.jsx(r.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(r.Modal,{open:I,onCancel:E,footer:null,centered:!0,width:"80%",className:R.modal,children:e.jsxs("div",{style:{position:"relative"},className:R.img,children:[e.jsx(r.Image,{src:f,alt:"",style:{width:"100%"},preview:!1}),e.jsx(r.Button,{type:"text",icon:e.jsx(Z.CloseOutlined,{}),onClick:E,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(r.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 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:`
|
|
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(O),null," "));var ie=ve(V,ue,z,ne,H+".
|
|
|
56
56
|
.ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
|
|
57
57
|
color: #8f99ff;
|
|
58
58
|
}
|
|
59
|
-
`}),e.jsx(ye,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(Pa,{data:{tableRef:F}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:F,style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,flexWrap:"wrap",marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#222"},children:[e.jsx("span",{children:"Show"}),e.jsx(r.Select,{size:"small",value:O.rowsPerPage,onChange:te=>U(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(r.Input,{size:"small",allowClear:!0,value:k,onChange:te=>{$(te.target.value),T(pe=>({...pe,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(Z.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(vt,{})}),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(r.Pagination,{current:O.page,pageSize:O.rowsPerPage,total:He||0,showSizeChanger:!1,onChange:U})]})]})]})},Ed=({token:t,type:n})=>{const[a,s]=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:m}=G(t?[d,t]:null,([I,D])=>Q(I,D)),[u,b]=i.useState(!1),v=(I,D)=>{s({page:I,rowsPerPage:parseInt(D)})},w=async I=>{},p=I=>{console.log("dsdsdsdsd",I),b(I)},y=()=>{},h=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],R=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(I,D)=>I.name.localeCompare(D.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(I,D)=>(I.contact||"").localeCompare(D.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(I,D)=>(I.description||"").localeCompare(D.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(I,D)=>(I.source_name||"").localeCompare(D.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(I,D)=>new Date(I.date)-new Date(D.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(I,D)=>new Date(I.follow_up_date)-new Date(D.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Le,{parentCallback:v,data:{newData:x,columns:R,action:!0,Loading:c,error:m,open:u,viewDetails:y,deleteTodoMutation:w,DrawerUpdate:p,ActionView:h}})})},Md={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:s,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:a,style:{...Md,opacity:a?.7:1,cursor:a?"not-allowed":"pointer",...s||{}}})})),lt=({id:t,funcName:n,disabled:a=!1})=>{const s="Data",[o,l]=i.useState(!1),d=()=>{l(!0),n(t),r.message.success(`${s} deleted successfully!`)},c=()=>{r.message.info(`Deletion of ${s} cancelled`)};return e.jsx(r.Popconfirm,{title:`Delete ${s}?`,description:`Are you sure you want to delete ${s}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:a||o,children:e.jsx(r.Button,{danger:!0,disabled:a,loading:o,icon:e.jsx(Z.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(s=>s.id!==t)}),Tr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Fd({token:t}){const[n,a]=i.useState({pagination:{current:1,pageSize:10}}),[s,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",m="api/branchapi/Transport/editroute",u="api/branchapi/Transport/deleteroute",{isLoading:b,data:v,error:w,mutate:p}=G(t?[c,t]:null,([A,P])=>Q(A,P)),y=async(A,P)=>{try{await p(Ye(A,P,t),rt(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},h=A=>{A.preventDefault();const P=new FormData(A.target);y(x,P),A.target.reset()},R=(A,P)=>{a(L=>({...L,pagination:{current:A,pageSize:parseInt(P,10)}}))},I=async A=>{try{await p(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 pt(m,A,t),await p(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},g=async A=>{A.preventDefault();const P=new FormData(A.target);P.append("id",l?.id),C(P)},f=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(A,P)=>A.name.localeCompare(P.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(A,P)=>A.fare-P.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,P)=>A.note.localeCompare(P.note)}},{title:"Action",key:"action",render:(A,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(P),style:{padding:2}}),e.jsx(lt,{id:P?.id,funcName:I})]})}],S=l?.route_title?`Edit ${l.route_title}`:"Edit Route";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:s,title:S,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:"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(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Tr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ye,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,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(r.Button,{type:"text",htmlType:"reset",style:Tr,children:"Cancel"})]})]})})})]})}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:e.jsx(Le,{parentCallback:R,data:{newData:v,columns:f,columnstype:"antd",action:!1,Loading:b,error:w,deleteTodoMutation:I}})})]})})]})})]})}const Ir={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function $d({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,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",m="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:b,data:v,error:w,mutate:p}=G(t?[c,t]:null,([A,P])=>Q(A,P)),y=async(A,P)=>{try{await p(Ye(A,P,t),rt(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},h=A=>{A.preventDefault();const P=new FormData(A.target);y(x,P),A.target.reset()},R=async A=>{try{await p(st(u,A,t),Qe(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},I=A=>{d(A),o(!0)},D=async A=>{try{await pt(m,A,t),await p(),_.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 P=new FormData(A.target);P.append("id",l?.id),D(P)},g=(A,P)=>{a({page:A,rowsPerPage:parseInt(P,10)})},f=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(A,P)=>A.vehicle_no.localeCompare(P.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(A,P)=>A.vehicle_model.localeCompare(P.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(A,P)=>A.seating_capacity-P.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(A,P)=>A.manufacture_year-P.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(A,P)=>A.gps_url.localeCompare(P.gps_url)},render:(A,P)=>e.jsx("span",{title:P?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:P?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,P)=>A.note.localeCompare(P.note)}},{title:"Action",key:"action",render:(A,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>I(P),style:{padding:2}}),e.jsx(lt,{id:P?.id,funcName:R})]})}],S=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:s,title:S,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(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(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Ir,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ye,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,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(r.Button,{type:"text",htmlType:"reset",style:Ir,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:e.jsx(Le,{parentCallback:g,data:{newData:v,columns:f,columnstype:"antd",action:!1,Loading:b,error:w,deleteTodoMutation:R}})})]})})]})})]})}var Nd=to();const ns=Xi(Nd),io=()=>{};class Ms 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,...s}=this.props;console.log("sdsdsfsdddddddd",{...s});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(n,{...s,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:io,onFocus:()=>this.selectRef.focus(),required:a})]})}}Ms.defaultProps={onChange:io};Ms.protoTypes={selectComponent:ns.func.isRequired,onChange:ns.func,required:ns.bool};const Ud={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Bd={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"})},oo=t=>e.jsx(Ti.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),Ld=t=>e.jsx(Ms,{...t,SelectComponent:Ti,components:{Input:oo},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:Ud,children:t?.label}),e.jsx(Ld,{components:{Input:oo},menuPortalTarget:document.body,styles:Bd,className:"input-cont",...t,ref:n})]})),qd={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Rr=({dataIndex:t,title:n,record:a,children:s,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:s}):s});function zd({token:t}){const[n,a]=i.useState(!1),[s,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,x]=i.useState([]),m="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",b="api/branchapi/Transport/getchechkedVehicleData",v="api/branchapi/Transport/assignedVehicleTable",w="api/branchapi/transport/assignvehicle",p="api/branchapi/Transport/deleteassignvehicle",y=l?`${b}?route_id=${l}`:null,{isLoading:h,data:R,mutate:I}=G(t?[`${v}?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,t]:null,([T,F])=>Q(T,F)),{data:D}=G(t&&m?[m,t]:null,([T,F])=>Q(T,F)),{data:C}=G(t&&u?[u,t]:null,([T,F])=>Q(T,F)),g=t&&y?[y,t]:null,{isLoading:f,data:S}=G(g,([T,F])=>Q(T,F)),{Status:A="Failed",pagination:{total_rows:P=0}={}}=R||{},{data:L=[]}=A==="Success"?R:{},N=i.useMemo(()=>{const T=D?.data??D??[];return Array.isArray(T)?T:[]},[D]),j=i.useMemo(()=>{const T=C?.data??C??[];return(Array.isArray(T)?T:[]).map(U=>{if(U==null)return null;if(typeof U=="string"||typeof U=="number")return{label:String(U),value:U};const z=U.value??U.vehicle_id??U.id??U.vehicleID,ne=U.label??U.vehicle_name??U.vehicle_no??U.vehicle_number??U.name??String(z??"");return z==null||ne===""?null:{label:String(ne),value:z}}).filter(Boolean)},[C]),M=i.useMemo(()=>{const T=S?.data??S??[];return(Array.isArray(T)?T:[]).map(U=>U?.value??U?.vehicle_id??U?.id??U).filter(U=>U!=null)},[S]);i.useEffect(()=>{x(M)},[M,n]);const k=async(T,F,U)=>{try{await I(Ye(T,F,t),rt(F)),y&&G.mutate(g),a(z=>!z),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(z){_.error(z?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},$=T=>{T.preventDefault();const F=new FormData;F.append("route_id",l??""),c.length?c.forEach(U=>F.append("vehicle_ids[]",U)):F.append("vehicle_ids[]",""),k(w,F)},E=T=>{o(F=>({...F,pagination:{current:T,pageSize:F.pagination.pageSize}}))},B=async T=>{try{await I(st(p,T,t),Qe(T)),y&&G.mutate(g),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},Y=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(T,F,U)=>e.jsx(e.Fragment,{children:F.children.map((z,ne,H)=>e.jsx("span",{children:`${z.vehicle_name} ${ne+1===H.length?"":","}`},`${ne}vehicle001`))})},{title:"Action",render:(T,F,U)=>e.jsx(e.Fragment,{children:e.jsx(lt,{id:F?.route_id,funcName:B})})}],q=T=>{const F=["route_id","index"];for(let U=0;U<F.length;U++)if(T[F[U]])return T[F[U]]},O=T=>{const{children:F=[]}=T||{},U=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:z=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:z=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:z=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:z=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:z=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:z=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:z=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(r.Table,{components:{body:{cell:Rr}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:U,rowKey:z=>q(z)+"cell01",dataSource:F,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ye,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:T=>{d(T?.value??null),a(F=>!F)}})}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:e.jsx(r.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:j,value:c,onChange:T=>x(T),disabled:!l||f})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),x([]),a(T=>!T)},style:qd,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ye,{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(ye,{style:{padding:"10px 16px"},children:e.jsx(r.Table,{components:{body:{cell:Rr}},columns:Y,bordered:!0,rowKey:T=>q(T),dataSource:Array.isArray(L)?L:[],loading:h,expandable:{expandedRowRender:O,childrenColumnName:"changed"},pagination:{current:s.pagination.current,pageSize:s.pagination.pageSize,total:P,showSizeChanger:!0,onChange:E,onShowSizeChange:(T,F)=>{o(U=>({...U,pagination:{current:1,pageSize:F}}))},showTotal:(T,F)=>`${F[0]}-${F[1]} of ${T} items`}})})]})})]})})]})}const Yd={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Vd={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Wd=(t,n,a)=>n?t>ae(a).endOf("day")||t<ae(n).endOf("day"):!1,an=i.forwardRef(function(n,a){const{...s}=n;return e.jsxs("div",{className:"form-group",children:[s.Desplay&&e.jsx("label",{className:`labelfont ${s.classnme?s.classnme:""}`,style:Yd,children:s.Desplay}),e.jsx(r.DatePicker,{...s,style:{...Vd,...s.style||{}},className:"form-group",disabledDate:o=>Wd(o,s.sessionStart||s.minDate?.subtract(1,"day").format("YYYY-MM-DD"),s.sessionEnd||s.maxDate?.format("YYYY-MM-DD")),required:!0,ref:a})]})}),Dr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},as=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Gt=(t,n,a)=>{if(n==null||n==="")return null;const s=t.find(o=>String(o.value)===String(n));return s||(a?{label:String(a),value:n}:{label:String(n),value:n})},Hd=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Kd=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 Gd({token:t,assignmentId:n,studentName:a,onClose:s,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",x="api/branchapi/Transport/getvehicleListByRouteIdwithCount",m="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[b,v]=i.useState(null),[w,p]=i.useState(null),[y,h]=i.useState(null),[R,I]=i.useState(ae()),[D,C]=i.useState(""),[g,f]=i.useState(0),[S,A]=i.useState(0),{data:P,isLoading:L}=G(t&&n?[`${l}?id=${n}`,t]:null,([W,le])=>Q(W,le)),N=i.useMemo(()=>{if(!P||P?.Status&&P.Status!=="Success")return null;const W=P?.data??P;return Array.isArray(W)?W[0]??null:W},[P]);i.useEffect(()=>{const W=N?.fk_route_id??N?.route_id;W!=null&&v(W),N?.vehicle_id!=null&&p(N.vehicle_id),N?.stop_id!=null&&h(N.stop_id),I(N?.start_date?ae(N.start_date):ae()),C(Kd(N?.service_push))},[N]);const j=t&&b?`${x}?route_id=${b}`:null,M=t&&b?`${u}?id=${b}`:null,k=t&&b?`${m}?route_id=${b}`:null,{data:$}=G(t&&c?[c,t]:null,([W,le])=>Q(W,le)),{data:E,isLoading:B}=G(j?[j,t]:null,([W,le])=>Q(W,le)),{data:Y,isLoading:q}=G(k?[k,t]:null,([W,le])=>Q(W,le)),{data:O}=G(M?[M,t]:null,([W,le])=>Q(W,le)),T=i.useMemo(()=>as($),[$]),F=i.useMemo(()=>as(E),[E]),U=i.useMemo(()=>as(Y),[Y]),z=P?.data[0]?.rootCost,ne=Hd(),H=a||[N?.firstname,N?.lastname].filter(Boolean).join(" ")||"",V=(W,le)=>{switch(le){case"route_id":v(W?.value??null),p(null),h(null),f(Ce=>Ce+1),A(Ce=>Ce+1);break;case"vehicle_id":p(W?.value??null),h(null),A(Ce=>Ce+1);break;case"stop_id":h(W?.value??null);break}},X=async W=>{if(W.preventDefault(),!b||!w||!y){_.error("Please select Route, Vehicle and Stop",{duration:1200});return}const le=new FormData;le.append("id",String(n)),le.append("student_id",String(N?.fk_student_id??N?.student_id??"")),le.append("fk_route_id",String(b)),le.append("vehicle_id",String(w)),le.append("stop_id",String(y)),le.append("rootCost",String(z??"")),le.append("start_date",R?.isValid?.()?R.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),le.append("puse_service",String(D??""));try{await pt(d,le,t),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),s?.()}catch(Ce){_.error(Ce?.message??"Failed to update the item.",{duration:1e3})}};if(L||!(N&&!L&&(!b||!B&&!q)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(r.Spin,{})});if(!N)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(r.Button,{type:"text",onClick:s,style:Dr,children:"Close"})]});const ue=N.fk_route_id??N.route_id,ve=Gt(T,ue,N.route_title),ie=Gt(F,N.vehicle_id,N.vehicle_name??N.vehicle_no),oe=Gt(U,N.stop_id,N.stop_name??N.stoppage_name);return e.jsx("form",{onSubmit:X,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:N.fk_student_id??N.student_id??""}),e.jsx(ee,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:Gt(T,b,ve?.label)??null,onChange:W=>V(W,"route_id")}),e.jsx(ee,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Gt(F,w,ie?.label)??null,onChange:W=>V(W,"vehicle_id")},`edit-vehicle-${g}`),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Gt(U,y,oe?.label)??null,onChange:W=>V(W,"stop_id")},`edit-stop-${S}`),e.jsx(J,{type:"text",label:"Route Cost",value:z!=null?`${ne}${z}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:z??""}),e.jsx(an,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:R,onChange:W=>I(W)}),e.jsx(J,{type:"text",label:"Pause Service",value:D,onChange:W=>C(W?.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(r.Button,{type:"text",onClick:s,style:Dr,children:"Cancel"})]})]})},`edit-${n}-${g}`)}const Or={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Jd=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[]},yn=t=>Jd(t),Qd=t=>t||"",Xd=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Zd=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},ec=(t,n)=>{const a=n||"/TransportDashboard/EditAssignStudentTransport?id={id}",s=t?.id??"",o=encodeURIComponent(String(s));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(s)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=a.includes("?")?"&":"?";return`${a}${l}id=${o}`};function tc({token:t,editType:n,onNavigate:a,editPagePath:s}){const l=Zd(n)==="drawer",d="api/branchapi/academy/classdropdownlist",c="api/branchapi/academy/sectionoftheClass",x="api/branchapi/Transport/routeStudentList",m="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleListByRouteIdwithCount",b="api/branchapi/Transport/getStoppageDropdown",v="api/branchapi/Transport/routeShowdata",w="api/branchapi/Transport/assignTransportRoutesStudent",p="api/branchapi/transport/removeStudentTransport",[y,h]=i.useState(null),[R,I]=i.useState(!1),[D,C]=i.useState(!1),[g,f]=i.useState(null),[S,A]=i.useState(null),[P,L]=i.useState(null),[N,j]=i.useState(null),[M,k]=i.useState(!1),[$,E]=i.useState(!1),[B,Y]=i.useState({page:1,rowsPerPage:50}),[q,O]=i.useState(null),[T,F]=i.useState(!1),[U,z]=i.useState(null),[ne,H]=i.useState(null),[V,X]=i.useState(null),[se,ue]=i.useState(null),[ve,ie]=i.useState(null),[oe,W]=i.useState(null),[le,Ce]=i.useState(null),[Pe,ke]=i.useState(ae()),[$e,Ee]=i.useState(""),We=(me,be)=>{const Fe=me?.value??null;switch(be){case"class_id":X(Fe),ue(null),O(Fe?`${c}?class_id=${encodeURIComponent(String(Fe))}`:null),I(St=>!St);break;case"route_id":ie(Fe),W(null),Ce(null),H(Fe),A(Fe?`${u}?route_id=${encodeURIComponent(String(Fe))}`:null),L(Fe?`${v}?id=${encodeURIComponent(String(Fe))}`:null),j(null),k(St=>!St),E(St=>!St);break;case"vehicle_id":W(Fe),Ce(null),j(ve?`${b}?route_id=${encodeURIComponent(String(ve))}`:null),E(St=>!St);break;case"stop_id":Ce(Fe);break}},He=me=>{if(l){f(me),C(!0);return}const be=ec(me,s);if(typeof a=="function"){a(be,me);return}typeof window<"u"&&be&&window.location.assign(be)},Be=()=>{C(!1),f(null)},Ve=g?`Edit — ${g.firstname??""} ${g.lastname??""}`.trim():"Edit Student Transport",{data:Xe}=G(t&&d?[d,t]:null,([me,be])=>Q(me,be)),{data:fe}=G(t&&q?[q,t]:null,([me,be])=>Q(me,be)),{data:xe}=G(t&&S?[S,t]:null,([me,be])=>Q(me,be)),{data:ge}=G(t&&N?[N,t]:null,([me,be])=>Q(me,be)),{data:te}=G(t&&P?[P,t]:null,([me,be])=>Q(me,be)),{data:pe}=G(t&&m?[m,t]:null,([me,be])=>Q(me,be)),he=t&&y?`${y}&page=${B.page}&per_page=${B.rowsPerPage}`:null,{isLoading:Te,error:Ie,data:ht,mutate:wt}=G(he?[he,t]:null,([me,be])=>Q(me,be)),Ct=i.useMemo(()=>yn(Xe),[Xe]),Yt=i.useMemo(()=>yn(fe),[fe]),Vt=i.useMemo(()=>yn(xe),[xe]),Wt=i.useMemo(()=>yn(ge),[ge]),ce=i.useMemo(()=>yn(pe),[pe]),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 me=>{try{await wt(st(p,me,t),Qe(me)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},bt=[{title:"Route Status",key:"route_status",render:(me,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:(me,be)=>Qd(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:(me,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:(me,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(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>He(be),style:{padding:2}})]}):e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.PlusOutlined,{}),onClick:()=>za(be.student_id),style:{padding:2}})})}],Ba=async(me,be)=>{try{await wt(Ye(me,be,t),rt(be)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),F(!1),je()}catch{_.error("Failed to add the new item.",{duration:1e3})}},La=me=>{if(me.preventDefault(),!V||!se){_.error("Please select Class and Section",{duration:1200});return}h(`${x}?cID=${encodeURIComponent(String(V))}&sID=${encodeURIComponent(String(se))}`),Y(be=>({...be,page:1}))},qa=(me,be)=>{Y({page:me,rowsPerPage:parseInt(be,10)})},za=me=>{z(me),F(!0)},re=me=>{if(me.preventDefault(),!U){_.error("Student is required",{duration:1200});return}if(!ve||!oe||!le){_.error("Please select Route, Vehicle and Stop",{duration:1300});return}const be=new FormData;be.append("student_id",String(U)),be.append("fk_route_id",String(ve)),be.append("vehicle_id",String(oe)),be.append("stop_id",String(le)),be.append("start_date",Pe?.isValid?.()?Pe.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),be.append("rootCost",String($e??"")),Ba(w,be)},je=()=>{F(!1),A(null),L(null),j(null),H(null),ie(null),W(null),Ce(null),ke(ae()),Ee(""),k(me=>!me),E(me=>!me)},Oe=Xd();return e.jsxs("div",{children:[l&&e.jsx(r.Drawer,{open:D,title:Ve,placement:"right",width:420,destroyOnClose:!0,onClose:Be,children:g?.id&&e.jsx(Gd,{token:t,assignmentId:g.id,studentName:`${g.firstname??""} ${g.lastname??""}`.trim(),onClose:Be,onSuccess:()=>wt()})}),e.jsx(r.Modal,{open:T,title:"Assign Student to Transport",onCancel:je,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:re,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[e.jsx(ee,{options:ce,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:ce.find(me=>String(me.value)===String(ve))??null,onChange:me=>We(me,"route_id")}),e.jsx(ee,{options:Vt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Vt.find(me=>String(me.value)===String(oe))??null,onChange:me=>We(me,"vehicle_id")},`vehicle001${M}`),e.jsx(ee,{options:Wt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Wt.find(me=>String(me.value)===String(le))??null,onChange:me=>We(me,"stop_id")},`stop001${$}`),e.jsx(an,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Pe,onChange:me=>ke(me)}),e.jsx(J,{type:"text",name:"rootCost",label:"Route Cost",value:$e,onChange:me=>Ee(me?.target?.value??"")}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:String($e??"").trim()?`${Oe}${$e} — Assign`:"Assign",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:je,style:Or,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ye,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsx("form",{onSubmit:La,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:Ct,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:me=>We(me,"class_id"),required:!0,allowSelectAll:!1,value:Ct.find(me=>String(me.value)===String(V))??null}),e.jsx(ee,{options:Yt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:Yt.find(me=>String(me.value)===String(se))??null,onChange:me=>ue(me?.value??null)},`section1${R}`),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Search",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"button",onClick:()=>{h(null),O(null),X(null),ue(null),I(me=>!me)},style:Or,children:"Cancel"})]})]})})})]}),y&&e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:e.jsx(Le,{parentCallback:qa,data:{newData:ht,columns:bt,columnstype:"antd",action:!1,Loading:Te,error:Ie,deleteTodoMutation:Ge,pageController:B}})})]})})]})})]})}const Pr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Wn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function nc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(""),[b,v]=i.useState(""),[w,p]=i.useState(!1),y=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,h="api/branchapi/Transport/add_driver",R="api/branchapi/Transport/edit_driver",I="api/branchapi/Transport/deletedriver",D="api/branchapi/staff/uploadDocuments",C=i.useMemo(()=>String(D).startsWith("http")?D:`${at()??""}${String(D).replace(/^\/+/,"")}`,[D]),g=at()??"",{isLoading:f,data:S,error:A,mutate:P}=G(t?[y,t]:null,([q,O])=>Q(q,O)),L=async(q,O)=>{try{await Ye(q,O,t),await P(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),x("")}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},N=q=>{q.preventDefault();const O=new FormData(q.target);L(h,O),q.target.reset()},j=async q=>{try{await P(st(I,q,t),Qe(q)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},M=q=>{d(q),x(q?.image??""),o(!0)},k=async q=>{try{await pt(R,q,t),await P(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(O){_.error(O?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},$=q=>{q.preventDefault();const O=new FormData(q.target);O.append("id",l?.id??""),k(O)},E=(q,O)=>{a({page:q,rowsPerPage:parseInt(O,10)})},B=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(q,O)=>String(q?.name??"").localeCompare(String(O?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(q,O)=>String(q?.Driver_licence??"").localeCompare(String(O?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(q,O)=>Number(q?.contact_number??0)-Number(O?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(q,O)=>String(q?.address??"").localeCompare(String(O?.address??""))}},{title:"Image",key:"image",width:100,render:(q,O)=>{const T=O?.image?`${g}staff/document/${O.image}`:"";return T?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(r.Image,{width:80,src:T,preview:{visible:!1,onVisibleChange:()=>{p(!0),u(T),v(O?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(q,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>M(O),style:{padding:2}}),e.jsx(lt,{id:O?.id,funcName:j})]})}],Y=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:s,title:Y,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:$,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:Wn,children:"Address"}),e.jsx(r.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:Wn,children:"Image"}),e.jsx(r.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const O=q?.file?.response,T=O?.data??O?.filename??O?.file??O?.path??"";T&&x(String(T))},children:e.jsx(r.Button,{icon:e.jsx(Z.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(r.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Pr,children:"Cancel"})]})]})})}),e.jsx(r.Modal,{zIndex:9999,open:w,title:b,footer:null,onCancel:()=>p(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:m})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ye,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(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:Wn,children:"Address"}),e.jsx(r.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:Wn,children:"Image"}),e.jsx(r.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const O=q?.file?.response,T=O?.data??O?.filename??O?.file??O?.path??"";T&&x(String(T))},children:e.jsx(r.Button,{icon:e.jsx(Z.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(r.Button,{type:"text",htmlType:"reset",onClick:()=>x(""),style:Pr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:e.jsx(Le,{parentCallback:E,data:{newData:S,columns:B,columnstype:"antd",action:!1,Loading:f,error:A,deleteTodoMutation:j}})})]})})]})})]})}const kr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Jt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Hn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Er=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],Kn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function ac({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[s,o]=i.useState(!1),[l,d]=i.useState(!1),[c,x]=i.useState(null),[m,u]=i.useState(null),[b,v]=i.useState(null),[w,p]=i.useState(null),[y,h]=i.useState(ae()),[R,I]=i.useState(ae()),[D,C]=i.useState("pick"),[g,f]=i.useState(!1),[S,A]=i.useState(null),[P,L]=i.useState(null),[N,j]=i.useState(!1),[M,k]=i.useState(null),[$,E]=i.useState(null),[B,Y]=i.useState(null),[q,O]=i.useState(null),[T,F]=i.useState(ae()),[U,z]=i.useState(ae()),[ne,H]=i.useState("pick"),V=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,X="api/branchapi/Transport/assignRouteTime",se="api/branchapi/Transport/editAssignRouteTime",ue="api/branchapi/Transport/deleteAssignRouteTime",ve="api/branchapi/Transport/driverDropdown",ie="api/branchapi/transport/routeTimetableShowdata",oe="api/branchapi/Transport/getrouteDropdown",W="api/branchapi/Transport/getvehicleDropdown",{isLoading:le,data:Ce,error:Pe,mutate:ke}=G(t?[V,t]:null,([ce,Se])=>Q(ce,Se)),{data:$e}=G(t&&oe?[oe,t]:null,([ce,Se])=>Q(ce,Se)),{data:Ee}=G(t&&ve?[ve,t]:null,([ce,Se])=>Q(ce,Se)),We=i.useMemo(()=>c?`${W}?route_id=${c}`:null,[c,W]),{data:He}=G(t&&We?[We,t]:null,([ce,Se])=>Q(ce,Se)),Be=i.useMemo(()=>Kn($e),[$e]),Ve=i.useMemo(()=>Kn(Ee),[Ee]),Xe=i.useMemo(()=>Kn(He),[He]),fe=(ce,Se)=>{a({page:ce,rowsPerPage:parseInt(Se,10)})},xe=async ce=>{ce.preventDefault();const Se=new FormData(ce.target);Se.set("route_id",m?.value??c??""),Se.set("driver_id",b?.value??""),Se.set("vehicle_id",w?.value??""),Se.set("start_time",y?y.format("h:mm a"):""),Se.set("drop_time",R?R.format("h:mm a"):""),Se.set("type",D);try{await Ye(X,Se,t),await ke(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),ce.target.reset(),x(null),u(null),v(null),p(null),d(Ge=>!Ge),h(ae()),I(ae()),C("pick"),o(Ge=>!Ge)}catch(Ge){_.error(Ge?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},ge=async ce=>{try{await st(ue,ce,t),await ke(),_.success("Success! Deleted item.",{duration:1e3})}catch(Se){_.error(Se?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},te=ce=>{A(ce),f(!0);const Se=ce?.id??ce?.route_time_id??ce?.routeId??null;L(Se);const Ge=ce?.route_id??ce?.routeId??ce?.fk_route_id;k(Ge??null),E(Be.find(bt=>bt?.value===(Ge??ce?.route_id))??null),Y(Ve.find(bt=>bt?.value===(ce?.driver_id??ce?.driverId))??null),O(null),j(bt=>!bt),F(ce?.start_time?ae(ce.start_time,["h:mm a","HH:mm"]):ae()),z(ce?.drop_time?ae(ce.drop_time,["h:mm a","HH:mm"]):ae()),H(ce?.type??"pick")},pe=i.useMemo(()=>{if(!P)return null;const ce=String(ie).includes("?")?"&":"?";return`${ie}${ce}id=${encodeURIComponent(String(P))}`},[P,ie]),{data:he,isLoading:Te}=G(t&&pe?[pe,t]:null,([ce,Se])=>Q(ce,Se)),Ie=i.useMemo(()=>{const ce=he?.data??he;return Array.isArray(ce)?ce[0]??null:Array.isArray(ce?.data)?ce.data[0]??null:ce??null},[he]),ht=i.useMemo(()=>M?`${W}?route_id=${M}`:null,[M,W]),{data:wt}=G(t&&ht?[ht,t]:null,([ce,Se])=>Q(ce,Se)),Ct=i.useMemo(()=>Kn(wt),[wt]);i.useEffect(()=>{if(!Ie)return;const ce=Ie?.route_id??Ie?.fk_route_id??Ie?.routeId;k(ce??null),E(Be.find(Se=>Se?.value===ce)??null),Y(Ve.find(Se=>Se?.value===Ie?.driver_id)??null),O(null),F(Ie?.start_time?ae(Ie.start_time,["h:mm a","HH:mm"]):ae()),z(Ie?.drop_time?ae(Ie.drop_time,["h:mm a","HH:mm"]):ae()),H(Ie?.type??"pick"),j(Se=>!Se)},[Ve,Ie,Be]),i.useEffect(()=>{if(!Ie)return;const ce=Ie?.vehicle_id??Ie?.vehicleId;ce&&O(Ct.find(Se=>Se?.value===ce)??null)},[Ie,Ct]);const Yt=async ce=>{if(ce.preventDefault(),!P)return;const Se=new FormData(ce.target);Se.set("id",String(P)),Se.set("route_id",$?.value??M??""),Se.set("driver_id",B?.value??""),Se.set("vehicle_id",q?.value??""),Se.set("start_time",T?T.format("h:mm a"):""),Se.set("drop_time",U?U.format("h:mm a"):""),Se.set("type",ne);try{await pt(se,Se,t),await ke(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),f(!1),A(null)}catch(Ge){_.error(Ge?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Vt=[{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:(ce,Se)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>te(Se),style:{padding:2}}),e.jsx(lt,{id:Se?.id??Se?.routeId??Se?.route_time_id,funcName:ge})]})}],Wt=S?.route_title?`Edit ${S.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:g,title:Wt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{f(!1),A(null),L(null),k(null),E(null),Y(null),O(null)},children:e.jsx("form",{onSubmit:Yt,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:$,onChange:ce=>{k(ce?.value??null),E(ce??null),O(null),j(Se=>!Se)}}),e.jsx(ee,{options:Ve,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:B,onChange:ce=>Y(ce??null)}),e.jsx(ee,{options:Ct,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:q,onChange:ce=>O(ce??null)},`edit-vehicle-${N}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Jt,children:"Start Time"}),e.jsx(r.TimePicker,{value:T,onChange:ce=>F(ce),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Hn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Jt,children:"Drop Time"}),e.jsx(r.TimePicker,{value:U,onChange:ce=>z(ce),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Hn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Jt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(r.Radio.Group,{options:Er,optionType:"button",buttonStyle:"solid",value:ne,onChange:ce=>H(ce.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{f(!1),A(null)},style:kr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ye,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{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:m,onChange:ce=>{x(ce?.value??null),u(ce??null),p(null),d(Se=>!Se)},allowSelectAll:!1,required:!0}),e.jsx(ee,{options:Ve,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:b,onChange:ce=>v(ce??null),allowSelectAll:!1,required:!0}),e.jsx(ee,{options:Xe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:w,onChange:ce=>p(ce??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Jt,children:"Start Time"}),e.jsx(r.TimePicker,{value:y,onChange:ce=>h(ce),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Hn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Jt,children:"Drop Time"}),e.jsx(r.TimePicker,{value:R,onChange:ce=>I(ce),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Hn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Jt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(r.Radio.Group,{options:Er,optionType:"button",buttonStyle:"solid",value:D,onChange:ce=>C(ce.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Add",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"reset",onClick:()=>{x(null),u(null),v(null),p(null),d(ce=>!ce),h(ae()),I(ae()),C("pick"),o(ce=>!ce)},style:kr,children:"Cancel"})]})]})},`form-${s}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:e.jsx(Le,{parentCallback:fe,data:{newData:Ce,columns:Vt,columnstype:"antd",action:!1,Loading:le,error:Pe,deleteTodoMutation:ge}})})]})})]})})]})}const sc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Mr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Fr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},$r=({dataIndex:t,title:n,record:a,children:s,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:s}):s});let Nr=2;function rc({token:t}){const[n,a]=i.useState([]),[s,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:m,data:u,mutate:b}=G(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([k,$])=>Q(k,$)),{Status:v="Failed",pagination:{total_rows:w=0}={}}=u||{},{data:p=[]}=v==="Success"?u:{},{data:y}=G(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([k,$])=>Q(k,$)),h=i.useMemo(()=>{const k=y?.data??y??[];if(Array.isArray(k))return k;if(k&&typeof k=="object"){if(Array.isArray(k?.data))return k.data;if(Array.isArray(k?.data?.data))return k.data.data}return[]},[y]),{data:R}=G(t&&s?["api/branchapi/transport/getrouteStoppageData?route_id="+s,t]:null,([k,$])=>Q(k,$)),{Status:I="Failed"}=R||{},D=async(k,$)=>{try{await b(Ye(k,$,t),rt($)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},C=k=>k?typeof k=="string"?k:k?.isValid?.()?k.format("h:mm a"):"":"",g=(k,$=[])=>{const E=(Array.isArray(k)?k:[]).map(q=>({id:q?.id??"",name:String(q?.stop_name??q?.name??"").trim(),pickTime:C(q?.pickup_time??q?.pickTime??q?.pickupTime),drop_time:C(q?.drop_time??q?.dropTime)})),B=E.filter(q=>q?.id!=null&&String(q.id).trim()!==""),Y=E.filter(q=>!(q?.id!=null&&String(q.id).trim()!==""));return{route_id:s??"",edit_stoppage:B,add_stoppage:Y,delete_stoppage:Array.isArray($)?$:[]}},f=k=>{k.preventDefault();const $="/api/branchapi/transport/addstoppageToRoute",E=g(n,l);D($,E)},S=()=>{a(k=>[...Array.isArray(k)?k:[],{idKey:Nr++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}])},A=k=>{if(n.length===1)return;const $=n[k];$?.id!=null&&String($.id).trim()!==""&&!$?.idKey&&d(E=>{const B=Array.isArray(E)?E:[];return B.some(q=>String(q)===String($.id))?B:[...B,$.id]}),a(E=>{const B=[...E];return B.splice(k,1),B})},P=k=>{x($=>({...$,pagination:{current:k,pageSize:$.pagination.pageSize}}))},L=async k=>{const $="/api/branchapi/Transport/deletevehicle";try{await b(st($,k,t),Qe(k)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(I==="Success"){const k=Array.isArray(R?.data)?R.data:[];k.length>0?(a(k),d([])):s&&(a([{idKey:Nr++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}]),d([]))}},[I,R,s]);const N=k=>{const{children:$=[]}=k||{},E=[{title:"Stop Name",dataIndex:"stop_name",onCell:B=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:B=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:B=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(r.Table,{components:{body:{cell:$r}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:E,rowKey:B=>j(B)+"cell01",dataSource:$,pagination:!1})})})},j=k=>{const $=["id","index"];for(let E=0;E<$.length;E++)if(k[$[E]])return k[$[E]]},M=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(k,$,E)=>e.jsx(e.Fragment,{children:(Array.isArray($.children)?$.children:[]).map((B,Y,q)=>e.jsx("span",{children:`${B.stop_name} ${Y+1===q.length?"":","}`},`${Y}vehicle001`))})},{title:"Action",render:(k,$,E)=>e.jsx(e.Fragment,{children:e.jsx(lt,{id:$?.route_id,funcName:L})})}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(ye,{pt:5,pb:1,children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(ee,{options:h,value:h.find(k=>String(k.value)===String(s))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:k=>{o(k?.value??null),a([]),d([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:s&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:S,children:e.jsx(Z.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(r.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),a([]),d([])},style:sc,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((k,$)=>{const E=k.pickup_time?ae(k.pickup_time,"h:mm a"):null,B=k.drop_time?ae(k.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:k.stop_name??"",type:"text",name:`stoppage[${$}][name]`,label:"Place Name*",required:"required",onChange:Y=>{const q=Y?.target?.value??"";a(O=>{const T=[...O];return T[$]={...T[$]??{},stop_name:q},T})}}),k?.id!=null&&String(k.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${$}][id]`,value:String(k.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Mr,children:"Pick Time"}),e.jsx(r.TimePicker,{value:E,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][pickTime]`,allowClear:!1,style:Fr,onChange:Y=>{const q=Y?Y.format("h:mm a"):"";a(O=>{const T=[...O];return T[$]={...T[$]??{},pickup_time:q},T})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Mr,children:"Drop Time"}),e.jsx(r.TimePicker,{value:B,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][drop_time]`,allowClear:!1,style:Fr,onChange:Y=>{const q=Y?Y.format("h:mm a"):"";a(O=>{const T=[...O];return T[$]={...T[$]??{},drop_time:q},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($),children:e.jsx(Z.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},k.idKey?k.idKey+"exp":k.id+"exp")})})]})}),e.jsx(ye,{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(ye,{style:{padding:"10px 16px"},children:e.jsx(r.Table,{components:{body:{cell:$r}},columns:M,bordered:!0,size:"small",rowKey:k=>j(k),dataSource:p,loading:m,expandable:{expandedRowRender:N,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:w,showSizeChanger:!0,onChange:P,onShowSizeChange:(k,$)=>{x(E=>({...E,pagination:{current:1,pageSize:$}}))},showTotal:(k,$)=>`${$[0]}-${$[1]} of ${k} items`}})})]})]})}const ic=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),s=String(n).replace(/^\/+/,"");return`${a}/${s}`};function oc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState(null),[o,l]=i.useState(null),[d,c]=i.useState(null),[x,m]=i.useState(null),[u,b]=i.useState(null),[v,w]=i.useState(null),[p,y]=i.useState(null),h="api/branchapi/library/bookCategorydropdown",R="api/branchapi/academy/classdropdownlist",I="api/branchapi/Academy/getClassSubjectdropdown",D="api/branchapi/library/addBook",C="api/branchapi/library/uploadcsv",{data:g}=G(n?[h,n]:null,([j,M])=>Q(j,M)),{data:f}=G(n&&R?[R,n]:null,([j,M])=>Q(j,M)),{data:S}=G(n&&I?[I,n]:null,([j,M])=>Q(j,M)),A=i.useMemo(()=>ic(at(),C),[C]),P=async j=>{j.preventDefault();const M=new FormData(j.target);M.set("cat_id",u?.value??""),M.set("class_id",v?.value??""),M.set("subject_id",p?.value??"");try{await Ye(D,M,n),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),j.target.reset(),b(null),w(null),y(null)}catch(k){_.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},L=async j=>{if(j.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 k=await Ne.post(A,M,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});k?.data?.Status==="Failed"?_.error(String(k?.data?.msg??"Upload failed."),{duration:1e3}):(_.success(String(k?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),s(null),j.target.reset(),l(null),c(null),m(null))}catch(k){_.error(k?.response?.data?.msg??"Upload failed.",{duration:1e3})}},N=()=>{fetch("/books.csv").then(j=>{j.blob().then(M=>{const k=window.URL.createObjectURL(M);let $=document.createElement("a");$.href=k,$.download="/books.csv",$.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(r.Button,{type:"link",icon:e.jsx(Z.DownloadOutlined,{}),onClick:N,children:"Download Sample"}),children:[e.jsx(r.Divider,{children:"Information"}),e.jsx(r.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:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:j=>l(j??null)}),e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:j=>c(j??null)}),e.jsx(ee,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:x,onChange:j=>m(j??null)}),e.jsx(J,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:j=>s(j.target.files?.[0]??null),required:!0}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:P,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:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:j=>b(j??null)}),e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:v,onChange:j=>w(j??null)}),e.jsx(ee,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:p,onChange:j=>y(j??null)}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})})]})}const ss={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},rs=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function lc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:a,onChange:(X,se)=>{s(X),l(se)}},x=on.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),m=()=>{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,b]=i.useState(!1),[v,w]=i.useState(null),[p,y]=i.useState(null),[h,R]=i.useState(null),[I,D]=i.useState(null),[C,g]=i.useState({page:1,rowsPerPage:10}),f=(X,se)=>{g({page:X,rowsPerPage:parseInt(se,10)})},S="api/branchapi/library/booktable",A="api/branchapi/library/deletebooks",P="api/branchapi/library/editbook",L=`${S}?page=${C.page}&per_page=${C.rowsPerPage}`,{isLoading:N,error:j,data:M,mutate:k}=G(n?[L,n]:null,([X,se])=>Q(X,se)),$="api/branchapi/library/bookCategorydropdown",E="api/branchapi/academy/classdropdownlist",B="api/branchapi/Academy/getClassSubjectdropdown",{data:Y}=G(n?[$,n]:null,([X,se])=>Q(X,se)),{data:q}=G(n&&E?[E,n]:null,([X,se])=>Q(X,se)),{data:O}=G(n&&B?[B,n]:null,([X,se])=>Q(X,se)),T=i.useMemo(()=>rs(Y),[Y]),F=i.useMemo(()=>rs(q),[q]),U=i.useMemo(()=>rs(O),[O]),z=async X=>{try{await st(A,X,n),await k(),_.success("Success! Deleted item.",{duration:1e3})}catch(se){_.error(se?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ne=X=>{w(X??null);const se=X?.cat_id??X?.fk_cat_id??X?.category_id,ue=X?.class_id??X?.fk_class_id,ve=X?.subject_id??X?.fk_subject_id;y(T.find(ie=>ie?.value===se)??null),R(F.find(ie=>ie?.value===ue)??null),D(U.find(ie=>ie?.value===ve)??null),b(!0)},H=async X=>{X.preventDefault();const se=v?.id??v?.book_id??v?._id;if(!se)return;const ue=new FormData(X.target);ue.set("id",String(se)),ue.set("cat_id",p?.value??""),ue.set("class_id",h?.value??""),ue.set("subject_id",I?.value??"");try{await pt(P,ue,n),await k(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),b(!1),w(null)}catch(ve){_.error(ve?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},V=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:(X,se)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>ne(se),style:{padding:2}}),e.jsx(r.Button,{type:"text",size:"small",danger:!0,onClick:()=>z(se?.id??se?.book_id??se?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[T,F,z,U]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:u,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{b(!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:v?.book_title??"",required:!0}),e.jsx(J,{label:"Author",name:"author",defaultValue:v?.author??"",required:!0}),e.jsx(J,{label:"Publication",name:"publish",defaultValue:v?.publish??""}),e.jsx(J,{label:"Qty",name:"quantity",type:"number",defaultValue:v?.quantity??""}),e.jsx(J,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:v?.perunitcost??""}),e.jsx(J,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:v?.fine_amount??""}),e.jsx(J,{label:"Barcode",name:"barcode",defaultValue:v?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ss,children:"Category"}),e.jsx(ee,{options:T,value:p,onChange:X=>y(X??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ss,children:"Class"}),e.jsx(ee,{options:F,value:h,onChange:X=>R(X??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ss,children:"Subject"}),e.jsx(ee,{options:U,value:I,onChange:X=>D(X??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{b(!1),w(null)},children:"Cancel"})]})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(r.Button,{type:"primary",onClick:m,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Le,{parentCallback:f,data:{newData:M,columns:V,columnstype:"antd",action:!1,Loading:N,error:j,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((X,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:X.book_title}),e.jsx(Ii,{value:X.barcode?String(X.barcode):String(X.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},se))})})})]})}const dc=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),s=String(n).replace(/^\/+/,"");return`${a}/${s}`},At=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Gn=t=>ae(t).add(1,"month").format("YYYY-MM-DD");function cc({token:t,onReturn:n}){const a=t??localStorage.getItem("authToken")??"",[s,o]=i.useState("issue"),l=s==="return",[d,c]=i.useState(!1),[x,m]=i.useState(!1),[u,b]=i.useState(null),[v,w]=i.useState([]),[p,y]=i.useState([]),[h,R]=i.useState([]),[I,D]=i.useState(0),[C,g]=i.useState(!1),[f,S]=i.useState(null),[A,P]=i.useState(null),[L,N]=i.useState(null),[j,M]=i.useState(!1),[k,$]=i.useState("Cash"),[E,B]=i.useState(""),[Y,q]=i.useState(""),[O,T]=i.useState(0),[F,U]=i.useState("NO_FINE"),z=i.useRef(null),[ne]=r.Form.useForm(),[H]=r.Form.useForm(),V="api/branchapi/library/bookCategorydropdown",X="api/branchapi/academy/classdropdownlist",se="api/branchapi/Academy/getClassSubjectdropdown",{data:ue}=G(a?[V,a]:null,([re,je])=>Q(re,je)),{data:ve}=G(a&&X?[X,a]:null,([re,je])=>Q(re,je)),{data:ie}=G(a&&se?[se,a]:null,([re,je])=>Q(re,je)),oe=i.useMemo(()=>At(ue),[ue]),W=i.useMemo(()=>At(ve),[ve]),le=i.useMemo(()=>At(ie),[ie]),Ce="api/branchapi/library/studentsearchByNameID",Pe="api/branchapi/library/booksearchBybookname",ke="api/branchapi/library/issuedBookList",$e="api/branchapi/library/issueLibrarybook",Ee="api/branchapi/library/returnedLibrarybook",{trigger:We,data:He}=Je(Ce,(re,je)=>Bt(re,je,a)),{trigger:Be,data:Ve}=Je(Pe,(re,je)=>Bt(re,je,a)),{trigger:Xe,data:fe}=Je(ke,(re,je)=>Bt(re,je,a)),{trigger:xe}=Je(l?Ee:$e,(re,je)=>Oa(re,je,a)),ge=i.useMemo(()=>At(He),[He]),te=i.useMemo(()=>At(Ve),[Ve]),pe=i.useMemo(()=>At(fe),[fe]),he=re=>{const je=Gn(ae());w(Oe=>Oe.some(me=>String(me?.id)===String(re?.id))?Oe:[...Oe,{...re,return_date:re?.return_date?re.return_date:je}])},Te=()=>!u||!h.length?[]:(JSON.parse(localStorage.getItem("genrall_settings")??"null"),h.map(re=>({studentId:u?.student_id,fromDate:re?.return_date,toDate:re?.issue_date,customField1:re?.book_issues_id,description:`${re?.book_title}-${re?.author}`,amount:Number(re?.totalfine??0)}))),Ie=re=>{w(je=>je.filter(Oe=>String(Oe?.id)!==String(re)))},ht=async re=>{if(a){if(!re){b(null);return}d||await We({id:re})}},wt=async({search:re})=>{if(!a||!d)return;const je=await We({id:re}),Oe=At(je);Oe.length===1&&(b(Oe[0]),await Xe({id:Oe[0]?.student_id}),ne.resetFields())},Ct=async(re,je)=>{b(je??null),w([]),y([]),R([]),D(0),U("NO_FINE"),T(0),je?.student_id&&await Xe({id:je.student_id}),ne.resetFields()},Yt=async re=>{a&&re&&(x||await Be({book:re}))},Vt=async({search_book:re})=>{if(!a||!x)return;const je=await Be({book:re,catID:f?.value??"",sID:L?.value??"",cID:A?.value??""}),Oe=At(je);Oe.length&&(he(Oe[0]),H.resetFields())},Wt=(re,je)=>{he(je),H.resetFields()},ce=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!v.length){_.error("Select at least one book.",{duration:1e3});return}const re=await xe({member_id:u.member_id,fine:!1,books:v});re?.Status==="Success"&&(_.success(String(re?.msg??"Success"),{duration:1e3}),w([]),b(null),y([]),R([]),D(0))},Se=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!h.length){_.error("Select at least one book to return.",{duration:1e3});return}if(Number(I)>0){U("FINE_PAID"),M(!0);return}const re=await xe({member_id:u.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(h)});re?.Status==="Success"?(_.success(String(re?.msg??"Success"),{duration:1e3}),y([]),R([]),D(0),await Xe({id:u?.student_id})):_.error(String(re?.msg??"Failed"),{duration:1e3})},Ge=async()=>{if(!u?.member_id)return;const re=Math.max(0,Number(I)-Number(O||0)),je={member_id:u.member_id,collection_type:F,amount:F==="FINE_PAID"?re:0,payment_type:k,notes:E,attchement:Y,discount:O||0,books:JSON.stringify(h)},Oe=await xe(je);M(!1),Oe?.Status==="Success"?(_.success(String(Oe?.msg??"Success"),{duration:1e3}),y([]),R([]),D(0),T(0),B(""),q(""),U("NO_FINE"),await Xe({id:u?.student_id})):_.error(String(Oe?.msg??"Failed"),{duration:1e3})},bt=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!h.length){_.error("Select at least one book to return.",{duration:1e3});return}const re=await xe({member_id:u.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(h)});M(!1),re?.Status==="Success"?(_.success(String(re?.msg??"Success"),{duration:1e3}),y([]),R([]),D(0),U("FINE_PAY_LATER"),await Xe({id:u?.student_id}),typeof n=="function"&&n(Te())):_.error(String(re?.msg??"Failed"),{duration:1e3})},Ba=i.useMemo(()=>dc(at(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),La=[{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:(re,je)=>e.jsx(an,{defaultValue:ae(je?.return_date||ae().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(Oe,me)=>{w(be=>be.map(Fe=>String(Fe?.id)===String(je?.id)?{...Fe,return_date:me}:Fe))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(re,je)=>e.jsx(r.Button,{type:"text",danger:!0,onClick:()=>Ie(je?.id),children:"Remove"})}],qa={selectedRowKeys:p,onChange:(re,je)=>{y(re),R(je);const Oe=(je??[]).reduce((me,be)=>me+Number(be?.totalfine??0),0);D(Oe)},onSelect:(re,je,Oe)=>{if(je){const me=Oe.map(be=>({...be,return_date:be?.return_date?be.return_date:Gn(be?.issue_date||ae())}));R(me)}},onSelectAll:(re,je)=>{if(re){const Oe=je.map(me=>({...me,return_date:me?.return_date?me.return_date:Gn(me?.issue_date||ae())}));R(Oe)}}},za=[{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:(re,je)=>{const me=h.find(Fe=>String(Fe?.id)===String(je?.id))?.return_date||je?.return_date,be=Gn(je?.issue_date||ae());return e.jsx(an,{defaultValue:ae(me||be),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(Fe,St)=>{R(To=>To.map(Ya=>String(Ya?.id)===String(je?.id)?{...Ya,return_date:St}:Ya))}})}},{title:"Days",key:"days",width:100,render:(re,je)=>{const me=h.find(Fe=>String(Fe?.id)===String(je?.id))?.return_date||je?.return_date,be=je?.issue_date;if(be&&me){const Fe=ae(me).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:re=>e.jsxs("span",{children:["₹ ",re]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:j,onCancel:()=>M(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(r.Radio.Group,{value:k,onChange:re=>$(re.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(r.Input.TextArea,{rows:3,value:E,onChange:re=>B(re.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(r.Upload,{action:Ba,headers:{Authorization:a},maxCount:1,onChange:re=>{if(re.file.status==="done"){const je=re.file.response?.data??re.file.response?.file??"";q(String(je??""))}},children:e.jsx(r.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(r.Input,{type:"number",value:O,onChange:re=>T(re.target.value),placeholder:"0"})]}),e.jsxs(r.Button,{type:"primary",onClick:Ge,children:["Collect ₹",Math.max(0,Number(I)-Number(O||0))]}),e.jsx(r.Button,{onClick:()=>M(!1),children:"Cancel"})]})}),e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(r.Row,{gutter:[16,16],align:"middle",children:[e.jsx(r.Col,{xs:24,md:10,children:e.jsx(r.Radio.Group,{value:s,onChange:re=>{const je=re.target.value;o(je),w([]),y([]),R([]),D(0),U("NO_FINE"),T(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(r.Col,{xs:24,md:14,children:e.jsx(r.Form,{form:ne,onFinish:wt,layout:"vertical",children:e.jsx(r.Form.Item,{name:"search",label:"Search Student",children:e.jsx(r.Space.Compact,{style:{width:"100%"},children:d?e.jsx(r.Input,{autoFocus:!0,addonBefore:e.jsxs(r.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:d,onChange:re=>c(re.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(r.AutoComplete,{options:ge,onSelect:Ct,onSearch:ht,style:{width:"100%"},allowClear:!0,children:e.jsx(r.Input,{addonBefore:e.jsxs(r.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:d,onChange:re=>c(re.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),u?e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{}),e.jsxs(r.Row,{gutter:[12,12],children:[e.jsxs(r.Col,{xs:24,md:8,children:[e.jsx(r.Typography.Text,{strong:!0,children:"Name:"})," ",u?.value??""]}),e.jsxs(r.Col,{xs:24,md:8,children:[e.jsx(r.Typography.Text,{strong:!0,children:"Card No:"})," ",u?.library_card_no??""]}),e.jsxs(r.Col,{xs:24,md:8,children:[e.jsx(r.Typography.Text,{strong:!0,children:"Member ID:"})," ",u?.member_id??""]})]})]}):null,e.jsx(r.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(r.Table,{dataSource:pe,columns:za,rowSelection:qa,pagination:!1,rowKey:re=>re?.id??re?.issue_id??re?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(r.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(r.Typography.Text,{strong:!0,children:["Total Fine: ₹",I]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(r.Button,{type:"primary",onClick:Se,disabled:!h.length,children:I>0?`Pay Now ₹ ${Math.max(0,Number(I)-Number(O||0))}`:"Return Selected"}),I>0?e.jsx(r.Button,{onClick:bt,disabled:!h.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(r.Row,{gutter:[16,16],align:"middle",children:[e.jsx(r.Col,{xs:24,md:18,children:e.jsx(r.Form,{form:H,onFinish:Vt,layout:"vertical",children:e.jsx(r.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(r.Space.Compact,{style:{width:"100%"},children:x?e.jsx(r.Input,{autoFocus:!0,disabled:!u,addonBefore:e.jsxs(r.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:x,onChange:re=>m(re.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(r.AutoComplete,{disabled:!u,options:te,onSelect:Wt,onSearch:Yt,style:{width:"100%"},allowClear:!0,children:e.jsx(r.Input,{addonBefore:e.jsxs(r.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:x,onChange:re=>m(re.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(r.Col,{xs:24,md:6,children:e.jsx(r.Button,{style:{width:"100%"},icon:e.jsx(Z.FilterOutlined,{}),onClick:()=>g(!0),children:"Filter"})})]}),e.jsx(r.Drawer,{open:C,onClose:()=>g(!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:oe,value:f,onChange:re=>S(re??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(ee,{label:"Class",options:W,value:A,onChange:re=>P(re??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(ee,{label:"Subjects",options:le,value:L,onChange:re=>N(re??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(r.Button,{type:"primary",onClick:()=>g(!1),children:"Apply"})]})}),e.jsx(r.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(r.Table,{dataSource:v,columns:La,pagination:!1,rowKey:re=>re?.id??re?.book_id??re?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(r.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Issue",onClick:ce})})]})]}),e.jsx("div",{ref:z,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}const Ur=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function uc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,c]=i.useState(null),[x,m]=i.useState(!1),[u,b]=i.useState(!1),[v,w]=i.useState(null),[p,y]=i.useState(!1),h="api/branchapi/academy/classdropdownlist",R="api/branchapi/academy/sectionoftheClass",I="api/branchapi/library/studenttableForLibrary",D="api/branchapi/library/addmembershipforStudent",C="api/branchapi/library/removemembershipforStudent",g=i.useMemo(()=>{if(!o?.value)return null;const O=R.includes("?")?"&":"?";return`${R}${O}class_id=${encodeURIComponent(String(o.value))}`},[R,o?.value]),f=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const O=I.includes("?")?"&":"?";return`${I}${O}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,I]),{data:S}=G(n&&h?[h,n]:null,([O,T])=>Q(O,T)),{data:A}=G(n&&g?[g,n]:null,([O,T])=>Q(O,T)),{isLoading:P,error:L,data:N,mutate:j}=G(n&&f?[f,n]:null,([O,T])=>Q(O,T)),M=i.useMemo(()=>Ur(S),[S]),k=i.useMemo(()=>Ur(A),[A]),$=(O,T)=>{s({page:O,rowsPerPage:parseInt(T,10)})},E=O=>{const T=O?.id??O?.student_id??O?.member_id;w(T??null),b(!0),y(F=>!F)},B=async O=>{if(O.preventDefault(),!v)return;const T=new FormData(O.target);T.set("id",String(v));try{await Ye(D,T,n),_.success("Success! Added member.",{duration:1e3,icon:"🎉"}),b(!1),w(null),await j()}catch(F){_.error(F?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},Y=async O=>{try{await st(C,O,n),_.success("Success! Removed member.",{duration:1e3}),await j()}catch(T){_.error(T?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},q=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:(O,T)=>(console.log("data______________",T),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:T?.library_card_no==null?e.jsx(r.Button,{type:"primary",size:"small",icon:e.jsx(Z.UserAddOutlined,{}),onClick:()=>E(T)}):e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>Y(T?.id??T?.student_id??T?.member_id)})}))}],[Y]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:u,title:"Add Member",onCancel:()=>{b(!1),w(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:B,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-${p}`)}),e.jsx(r.Card,{title:e.jsx(r.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:O=>{l(O??null),c(null),m(T=>!T)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(ee,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:O=>c(O??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}s(O=>({...O,page:1}))}})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Le,{parentCallback:$,data:{newData:N,columns:q,columnstype:"antd",action:!1,Loading:P,error:L}})})]})}function pc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState({page:1,rowsPerPage:10}),[o]=r.Form.useForm(),[l]=r.Form.useForm(),[d,c]=i.useState(!1),[x,m]=i.useState(null),u="api/branchapi/library/BookCategorytable",b="api/branchapi/library/addBookCategory",v="api/branchapi/library/editBookCategory",w="api/branchapi/library/deleteBookCategory",p=i.useMemo(()=>{const L=u.includes("?")?"&":"?";return`${u}${L}page=${a.page}&per_page=${a.rowsPerPage}`},[u,a.page,a.rowsPerPage]),{isLoading:y,error:h,data:R,mutate:I}=G(n&&p?[p,n]:null,([L,N])=>Q(L,N)),D=(L,N)=>{s({page:L,rowsPerPage:parseInt(N,10)})},C=async L=>{const N=new FormData;N.set("title",L?.title??"");try{await Ye(b,N,n),_.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await I()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to add category.",{duration:1e3})}},g=L=>{m(L??null),l.setFieldsValue({title:L?.name??""}),c(!0)},f=()=>{c(!1),m(null),l.resetFields()},S=async L=>{const N=x?.id??x?.category_id??x?.cat_id;if(!N){_.error("Missing category id.",{duration:1e3});return}const j=new FormData;j.set("id",String(N)),j.set("title",L?.title??"");try{await pt(v,j,n),_.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),f(),await I()}catch(M){_.error(M?.response?.data?.msg??M?.message??"Failed to update category.",{duration:1e3})}},A=async L=>{const N=L?.id??L?.category_id??L?.cat_id;if(!N){_.error("Missing category id.",{duration:1e3});return}try{await st(w,N,n),_.success("Success! Deleted category.",{duration:1e3}),await I()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to delete category.",{duration:1e3})}},P=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(L,N)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>g(N)}),e.jsx(r.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>A(N),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[A]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:d,title:"Edit Category",onCancel:f,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:l,layout:"vertical",onFinish:S,children:[e.jsx(r.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(r.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:f,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(r.Row,{gutter:[16,16],children:[e.jsx(r.Col,{xs:24,lg:8,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:C,children:[e.jsx(r.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(r.Input,{placeholder:"Enter category name"})}),e.jsx(de,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(r.Col,{xs:24,lg:16,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Le,{parentCallback:D,data:{newData:R,columns:P,columnstype:"antd",action:!1,Loading:y,error:h}})})})]})]})}const is=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function mc({token:t}){const[n,a]=i.useState([ae().format("YYYY-MM-DD"),ae().format("YYYY-MM-DD")]),[s,o]=i.useState(null),[l,d]=i.useState(null),[c,x]=i.useState(null),[m,u]=i.useState(!1),[b,v]=i.useState(!1),w="api/branchapi/academy/classdropdownlist",p="api/branchapi/academy/sectionoftheClass",y="api/branchapi/library/memberDropdown",h="api/report/libraryReport/libraryReport",R=i.useMemo(()=>{if(!s?.value)return null;const E=p.includes("?")?"&":"?";return`${p}${E}class_id=${encodeURIComponent(String(s.value))}`},[p,s?.value]),I=i.useMemo(()=>{if(!s?.value)return null;const E=y.includes("?")?"&":"?",B=`${y}${E}class=${encodeURIComponent(String(s.value))}`;return l?.value?`${B}§ion=${encodeURIComponent(String(l.value))}`:B},[y,s?.value,l?.value]),{isLoading:D,error:C,data:g,mutate:f}=G(t&&w?[w,t]:null,([E,B])=>Q(E,B)),{data:S}=G(t&&R?[R,t]:null,([E,B])=>Q(E,B)),{data:A}=G(t&&I?[I,t]:null,([E,B])=>Q(E,B)),P=i.useMemo(()=>is(g),[g]),L=i.useMemo(()=>is(S),[S]),N=i.useMemo(()=>is(A),[A]),{trigger:j,data:M}=Je(h,(E,B)=>Os(E,B,t));i.useEffect(()=>{(async()=>{v(!0);try{await j({duration:n})}finally{v(!1)}})()},[]);const k=async()=>{v(!0);try{await j({duration:n,class:s?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{v(!1)}},$=[{title:"Name",dataIndex:"full_name",render:(E,B)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:B?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(E,B)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:B?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(E,B)=>e.jsxs(r.Typography.Text,{style:{fontSize:12},children:[B?.class??"","(",B?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(E,B)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:B?.book_title??""})},{title:"Issue Date",key:"date",render:(E,B,Y)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:B?.issue_date??""})},{title:"Due Return Date",key:"date",render:(E,B,Y)=>e.jsx(r.Tag,{color:"orange",children:B?.return_date??""})},{title:"Return Date",key:"date",render:(E,B,Y)=>B?.retured_by_user?e.jsx(r.Tag,{color:"green",children:B?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(E,B,Y)=>String(B?.is_returned??"")==="1"?e.jsx(r.Tag,{color:"green",children:"Return"}):e.jsx(r.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(E,B,Y)=>{const q=B?.late_fine?Number(B.late_fine):0;return q?e.jsx(r.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:q}):null}}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(r.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(r.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(r.DatePicker.RangePicker,{style:{width:"100%"},value:[ae(n[0],"YYYY-MM-DD"),ae(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(E,B)=>{Array.isArray(B)&&B.length===2&&a([B[0],B[1]])}})]})}),e.jsx(r.Col,{xs:24,md:5,children:e.jsx(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:s,onChange:E=>{o(E??null),d(null),x(null),u(B=>!B)},allowSelectAll:!1})}),e.jsx(r.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${m}`)}),e.jsx(r.Col,{xs:24,md:5,children:e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:E=>x(E??null),allowSelectAll:!1})}),e.jsx(r.Col,{xs:24,md:1,children:e.jsx(r.Button,{type:"primary",icon:e.jsx(Z.SearchOutlined,{}),onClick:k,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(r.Table,{columns:$,pagination:!1,dataSource:Array.isArray(M?.data)?M.data:[],size:"small",rowKey:(E,B)=>E?.id??E?.issue_id??E?.fees_receipt_id??B,loading:b,scroll:{x:"max-content"},summary:E=>{const B=E.reduce((q,O)=>q+Number(O?.late_fine??0),0),Y=E.reduce((q,O)=>q+Number(O?.is_returned??0),0);return e.jsxs(r.Table.Summary.Row,{children:[e.jsx(r.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",E.length]})}),e.jsx(r.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(E.length-Y)]})}),e.jsx(r.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",Y]})}),e.jsx(r.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",B.toLocaleString("en-IN")]})})]})}})})]})]})}const ka=t=>t??localStorage.getItem("authToken")??"",fc=(t,n)=>{const a=String(t??""),s=String(n);return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s},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"}},yc=()=>fc(at(),Ue.upload),hc=async({baseUrl:t,page:n=1,perPage:a=10},s)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,ka(s))},$n=async(t,n,a)=>Ye(t,n,ka(a)),dn=async(t,n,a)=>pt(t,n,ka(a)),Nn=async(t,n,a)=>st(t,n,ka(a)),gc=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=({token:t,value:n,onChange:a})=>{const s=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(r.Upload,{maxCount:1,action:yc(),headers:s,onChange:o=>{if(o?.file?.status==="done"){const l=gc(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},ca=Ue.vendor,Un=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>G(s&&t?[t,n,a,s]:null,([l,d,c,x])=>hc({baseUrl:l,page:d,perPage:c},x)),xc=({token:t,page:n=1,perPage:a=10})=>Un({baseUrl:ca.list,page:n,perPage:a,token:t}),bc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Br=[{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 Sc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:m,error:u,data:b,mutate:v}=xc({token:t,page:n.page,perPage:n.rowsPerPage}),w=async C=>{try{await v($n(ca.add,C,t),rt(C)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(g){_.error(g?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},p=C=>{C.preventDefault();const g=new FormData(C.target);c&&g.set("image",c),w(g),C.target.reset(),x("")},y=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},h=async C=>{try{await v(Nn(ca.remove,C,t),Qe(C)),_.success("Success! Deleted item.",{duration:1e3})}catch(g){_.error(g?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},R=C=>{d(C),o(!0),x("")},I=async C=>{C.preventDefault();const g=new FormData(C.target);g.set("id",String(l?.id??"")),c&&g.set("image",c);try{await dn(ca.edit,g,t),await v(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(f){_.error(f?.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,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>R(g),style:{padding:2}}),e.jsx(lt,{id:g?.id,funcName:h})]})}],[h]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:s,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[Br.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(sn,{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(r.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:bc,children:"Cancel"})]})]})})}),e.jsxs(ye,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{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:[Br.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(sn,{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(ye,{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(ye,{pt:3,children:e.jsx(Le,{parentCallback:y,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})]})]})}const jc=({token:t})=>e.jsx(Sc,{token:t}),vc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},_c={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"},Rt=({style:t,onFocus:n,onBlur:a,...s})=>{const[o,l]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[s.label&&e.jsx("label",{className:"labelfont",style:vc,children:s.label}),e.jsx("textarea",{placeholder:s.placeholder||s.label,...s,onFocus:d=>{l(!0),n?.(d)},onBlur:d=>{l(!1),a?.(d)},style:{..._c,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},ua=Ue.product,Lr=Ue.vendor.dropdown,qr=Ue.category.dropdown,wc=Ue.subCategory.dropdown,zr=Ue.unit.dropdown,lo=({token:t,page:n=1,perPage:a=10})=>Un({baseUrl:ua.list,page:n,perPage:a,token:t}),Cc=({token:t})=>G(t&&Lr?[Lr,t]:null,([a,s])=>Q(a,s)),Ac=({token:t})=>G(t&&qr?[qr,t]:null,([a,s])=>Q(a,s)),Tc=({token:t})=>G(t&&zr?[zr,t]:null,([a,s])=>Q(a,s)),Ic=({token:t,categoryId:n})=>{const a=t&&n?`${wc}?category_id=${encodeURIComponent(String(n))}`:null;return G(a?[a,t]:null,([o,l])=>Q(o,l))},Jn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Rc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Dc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(""),[b,v]=i.useState(""),[w,p]=i.useState(""),[y,h]=i.useState(""),{isLoading:R,error:I,data:D,mutate:C}=lo({token:t,page:n.page,perPage:n.rowsPerPage}),{data:g}=Cc({token:t}),{data:f}=Ac({token:t}),{data:S}=Tc({token:t}),{data:A}=Ic({token:t,categoryId:m}),P=i.useMemo(()=>Jn(g),[g]),L=i.useMemo(()=>Jn(f),[f]),N=i.useMemo(()=>Jn(S),[S]),j=i.useMemo(()=>Jn(A),[A]),M=async O=>{try{await C($n(ua.add,O,t),rt(O)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},k=O=>{O.preventDefault();const T=new FormData(O.target);m&&T.set("fk_categoryID",String(m)),b&&T.set("fk_sub_categoryID",String(b)),w&&T.set("vendor_id",String(w)),y&&T.set("unit",String(y)),c&&T.set("image",c),M(T),O.target.reset(),x(""),u(""),v(""),p(""),h("")},$=(O,T)=>{a({page:O,rowsPerPage:parseInt(T,10)})},E=async O=>{try{await C(Nn(ua.remove,O,t),Qe(O)),_.success("Success! Deleted item.",{duration:1e3})}catch(T){_.error(T?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},B=O=>{d(O),o(!0),x(""),u(O?.fk_categoryID??O?.category_id??""),v(O?.fk_sub_categoryID??O?.sub_category_id??""),p(O?.vendor_id??""),h(O?.unit??O?.unit_id??"")},Y=async O=>{O.preventDefault();const T=new FormData(O.target);T.set("id",String(l?.id??"")),m&&T.set("fk_categoryID",String(m)),b&&T.set("fk_sub_categoryID",String(b)),w&&T.set("vendor_id",String(w)),y&&T.set("unit",String(y)),c&&T.set("image",c);try{await dn(ua.edit,T,t),await C(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(F){_.error(F?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},q=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:(O,T)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>B(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(r.Drawer,{open:s,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:Y,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:O=>{const T=O?.value??"";u(T),v("")},defaultValue:m?L.find(O=>String(O?.value)===String(m)):null}),e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:O=>v(O?.value??""),defaultValue:b?j.find(O=>String(O?.value)===String(b)):null}),e.jsx(J,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:O=>h(O?.value??""),defaultValue:y?N.find(O=>String(O?.value)===String(y)):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:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:O=>p(O?.value??""),defaultValue:w?P.find(O=>String(O?.value)===String(w)):null}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(Rt,{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(sn,{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(r.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Rc,children:"Cancel"})]})]})})}),e.jsxs(ye,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsx("form",{onSubmit:k,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:O=>{const T=O?.value??"";u(T),v("")}}),e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:O=>v(O?.value??"")},`subcat_${m}`),e.jsx(J,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:O=>h(O?.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:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:O=>p(O?.value??"")}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(Rt,{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(sn,{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(ye,{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(ye,{pt:3,children:e.jsx(Le,{parentCallback:$,data:{newData:D,columns:q,columnstype:"antd",action:!1,Loading:R,error:I}})})]})]})]})}const Oc=({token:t})=>e.jsx(Dc,{token:t}),pa=Ue.category,Pc=({token:t,page:n=1,perPage:a=10})=>Un({baseUrl:pa.list,page:n,perPage:a,token:t}),kc={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}),[s,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:m,mutate:u}=Pc({token:t,page:n.page,perPage:n.rowsPerPage}),b=async I=>{try{await u($n(pa.add,I,t),rt(I)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=I=>{I.preventDefault();const D=new FormData(I.target);b(D),I.target.reset()},w=(I,D)=>{a({page:I,rowsPerPage:parseInt(D,10)})},p=async I=>{try{await u(Nn(pa.remove,I,t),Qe(I)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},y=I=>{d(I),o(!0)},h=async I=>{I.preventDefault();const D=new FormData(I.target);D.set("id",String(l?.id??""));try{await dn(pa.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})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(D),style:{padding:2}}),e.jsx(lt,{id:D?.id,funcName:p})]})}],[p]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:s,title:l?.name?`Edit ${l.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:h,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(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:kc,children:"Cancel"})]})]})})}),e.jsxs(ye,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(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(ye,{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(ye,{pt:3,children:e.jsx(Le,{parentCallback:w,data:{newData:m,columns:R,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const Mc=({token:t})=>e.jsx(Ec,{token:t}),ma=Ue.subCategory,Yr=Ue.category.dropdown,Fc=({token:t,page:n=1,perPage:a=10})=>Un({baseUrl:ma.list,page:n,perPage:a,token:t}),$c=({token:t})=>G(t&&Yr?[Yr,t]:null,([a,s])=>Q(a,s)),Nc=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Uc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Bc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:m,error:u,data:b,mutate:v}=Fc({token:t,page:n.page,perPage:n.rowsPerPage}),{data:w}=$c({token:t}),p=i.useMemo(()=>Nc(w),[w]),y=async f=>{try{await v($n(ma.add,f,t),rt(f)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(S){_.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},h=f=>{f.preventDefault();const S=new FormData(f.target);S.set("status","active"),S.set("img",c||""),y(S),f.target.reset(),x("")},R=(f,S)=>{a({page:f,rowsPerPage:parseInt(S,10)})},I=async f=>{try{await v(Nn(ma.remove,f,t),Qe(f)),_.success("Success! Deleted item.",{duration:1e3})}catch(S){_.error(S?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=f=>{d(f),o(!0)},C=async f=>{f.preventDefault();const S=new FormData(f.target);S.set("id",String(l?.id??"")),c&&S.set("img",c);try{await dn(ma.edit,S,t),await v(),_.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})}},g=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(f,S)=>String(f?.name??"").localeCompare(String(S?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(f,S)=>String(f?.description??"").localeCompare(String(S?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(f,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(S),style:{padding:2}}),e.jsx(lt,{id:S?.id,funcName:I})]})}],[I]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:s,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:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?p.find(f=>String(f?.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(sn,{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(r.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Uc,children:"Cancel"})]})]})})}),e.jsxs(ye,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:p,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(sn,{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(ye,{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(ye,{pt:3,children:e.jsx(Le,{parentCallback:R,data:{newData:b,columns:g,columnstype:"antd",action:!1,Loading:m,error:u}})})]})]})]})}const Lc=({token:t})=>e.jsx(Bc,{token:t}),os=Ue.product,qc=Ue.academy.classes,zc=Ue.academy.sections,Yc=Ue.student.dropdown;function hn(t){const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]}function Qn(t,n){const a=Math.trunc(Number(t)||1),s=Math.max(1,a);return!Number.isFinite(Number(n))||Number(n)<=0?s:Math.min(s,Math.trunc(Number(n)))}function Ze(t){return String(t??"")}function Vc({token:t}){const[n,a]=i.useState(""),[s,o]=i.useState(""),[l,d]=i.useState(""),[c,x]=i.useState(!1),[m,u]=i.useState(""),[b,v]=i.useState([]),[w,p]=i.useState({}),[y,h]=i.useState({}),[R,I]=i.useState(!1),[D,C]=i.useState(""),[g,f]=i.useState(0),[S,A]=i.useState(""),[P,L]=i.useState(ae()),[N,j]=i.useState([]),M={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},k=!!(n&&s&&l),{data:$}=G(t?[qc,t]:null,([fe,xe])=>Q(fe,xe)),E=i.useMemo(()=>hn($),[$]),B=t&&n?`${zc}?class_id=${encodeURIComponent(String(n))}`:null,{data:Y}=G(B?[B,t]:null,([fe,xe])=>Q(fe,xe)),q=i.useMemo(()=>hn(Y),[Y]),O=t&&n&&s?`${Yc}?class=${encodeURIComponent(String(n))}§ion=${encodeURIComponent(String(s))}`:null,{data:T}=G(O?[O,t]:null,([fe,xe])=>Q(fe,xe)),F=i.useMemo(()=>hn(T),[T]),U=k?`${os.list}?page=1&per_page=10000`:null,{data:z,isLoading:ne}=G(t&&U?[U,t]:null,([fe,xe])=>Q(fe,xe),{revalidateOnFocus:!1}),H=i.useMemo(()=>hn(z),[z]),V=i.useMemo(()=>{const fe=new Map;return(Array.isArray(H)?H:[]).forEach(xe=>{fe.set(Ze(xe?.id),xe)}),fe},[H]),X=i.useMemo(()=>{const fe=Object.entries(y||{});return fe.length===0?[]:fe.map(([xe,ge])=>{const te=V.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:Qn(ge,Number(te?.quantity||0))}:null}).filter(Boolean)},[y,V]),se=i.useMemo(()=>new Set(X.map(fe=>Ze(fe?.id))),[X]),ue=i.useMemo(()=>(Array.isArray(X)?X:[]).reduce((xe,ge)=>xe+Number(ge?.price||0)*Number(ge?.quantity||1),0),[X]),ve=i.useMemo(()=>{const fe=Number(g||0);return!Number.isFinite(fe)||fe<=0?0:Math.min(fe,ue)},[g,ue]),ie=i.useMemo(()=>Math.max(0,ue-ve),[ve,ue]),oe=i.useMemo(()=>(Array.isArray(H)?H:[]).slice(0,30).map(fe=>({value:Ze(fe?.id),label:`${fe?.name??""}${fe?.barcode?` • ${fe.barcode}`:""}${fe?.quantity!==void 0&&fe?.quantity!==null?` • Stock: ${fe.quantity}`:""}`,product:fe})),[H]),{trigger:W}=Je(t&&k?os.search:null,(fe,{arg:xe})=>Bt(fe,{arg:xe},t));i.useEffect(()=>{if(!k){v([]);return}const fe=String(m||"").trim();if(fe.length<2){v(oe);return}let xe=!0;const ge=setTimeout(async()=>{let te=[];try{if(W){const he=await W({search:fe});te=hn(he)}}catch{te=[]}if(!Array.isArray(te)||te.length===0){const he=fe.toLowerCase();te=(Array.isArray(H)?H:[]).filter(Te=>{const Ie=String(Te?.name??"").toLowerCase(),ht=String(Te?.barcode??"").toLowerCase();return Ie.includes(he)||ht.includes(he)}).slice(0,30)}const pe=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&&v(pe)},250);return()=>{xe=!1,clearTimeout(ge)}},[oe,k,W,H,m]),i.useEffect(()=>{h({}),p({}),u(""),v([]),I(!1),C(""),f(0),A(""),L(ae()),j([])},[n,s,l]);const le=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 pe=Qn(xe,te);h(he=>{const Te=he||{};return Object.prototype.hasOwnProperty.call(Te,Ze(ge))?(_.error("Product already added.",{duration:1e3}),Te):{...Te,[Ze(ge)]:pe}})},[h]),Ce=i.useCallback((fe,xe,ge)=>{h(te=>{const pe=te||{},he=Ze(fe);return Object.prototype.hasOwnProperty.call(pe,he)?{...pe,[he]:Qn(xe,ge)}:pe})},[]),Pe=i.useCallback(fe=>{h(xe=>{const ge=xe||{},te=Ze(fe);if(!Object.prototype.hasOwnProperty.call(ge,te))return ge;const pe={...ge};return delete pe[te],pe})},[]),ke=i.useCallback((fe,xe,ge)=>{p(te=>({...te||{},[Ze(fe)]:Qn(xe,ge)}))},[]),$e=i.useCallback((fe,xe)=>{xe?.product&&le(xe.product,1),u(""),v(oe)},[le,oe]),Ee=i.useCallback(fe=>{if(fe.key!=="Enter")return;fe.preventDefault();const xe=Array.isArray(b)&&b.length>0?b[0]:null;if(xe?.product){le(xe.product,1),u(""),v(oe);return}const ge=String(m||"").trim().toLowerCase();if(ge.length===0)return;const te=(Array.isArray(H)?H:[]).find(pe=>{const he=String(pe?.name??"").toLowerCase(),Te=String(pe?.barcode??"").toLowerCase();return he.includes(ge)||Te.includes(ge)});te&&(le(te,1),u(""),v(oe))},[le,oe,H,b,m]),We=()=>{if(!t){_.error("Missing token.",{duration:1e3});return}if(!n){_.error("Select class.",{duration:1e3});return}if(!s){_.error("Select section.",{duration:1e3});return}if(!l){_.error("Select student.",{duration:1e3});return}if(!X||X.length===0){_.error("Add at least one product.",{duration:1e3});return}I(!0)},{trigger:He,isMutating:Be}=Je(t?os.sellProduct:null,(fe,{arg:xe})=>Oa(fe,{arg:xe},t)),Ve=async()=>{if(!D){_.error("Select payment type.",{duration:1e3});return}const fe=(Array.isArray(X)?X:[]).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:ue,class:n,section:s,student_id:l,payment_type:D,discount:ve,notes:S||"",receipt_date:P?ae(P).format("YYYY-MM-DD"):"",product:JSON.stringify(fe),total_payable_amount:ue,attchement:N[0]?.originFileObj||""};try{const te=Array.isArray(N)&&N.length>0&&N[0]?.originFileObj?(()=>{const he=new FormData;return Object.entries(xe).forEach(([Te,Ie])=>{if(Te==="products"){he.append("product",JSON.stringify(Ie));return}he.append(Te,String(Ie??""))}),he.append("attachment",N[0].originFileObj),he})():xe,pe=await He(te);pe?.Status==="Success"?(_.success("Success! Product sold.",{duration:1e3}),I(!1),h({}),p({}),u(""),v(oe),C(""),f(0),A(""),L(ae()),j([])):_.error(pe?.msg??"Failed to submit.",{duration:1e3})}catch{_.error("Failed to submit.",{duration:1e3})}},Xe=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=Ze(xe?.id),te=Number(xe?.quantity||0),pe=se.has(ge),he=(pe?y?.[ge]:w?.[ge])??1;return e.jsx(r.InputNumber,{min:1,max:Number.isFinite(te)&&te>0?te:void 0,value:he,onChange:Te=>{pe?Ce(ge,Te,te):ke(ge,Te,te)},disabled:te<=0})}},{title:"Amount",key:"amount",width:140,render:(fe,xe)=>{const ge=Ze(xe?.id),te=(se.has(ge)?y?.[ge]:w?.[ge])??1;return Number(xe?.price||0)*Number(te||1)}},{title:"Action",key:"action",width:120,render:(fe,xe)=>{const ge=Ze(xe?.id),te=Number(xe?.quantity||0),pe=se.has(ge),he=(pe?y?.[ge]:w?.[ge])??1;return pe?e.jsx(r.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>Pe(ge),style:{padding:2}}):e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.PlusOutlined,{}),disabled:te<=0,onClick:()=>le(xe,he),style:{padding:2}})}}],[le,se,y,w,Pe,ke,Ce]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(ye,{pt:5,pb:2,children:[e.jsxs(ye,{style:{padding:"12px 16px"},children:[e.jsx(ye,{children:"Sell Product"}),e.jsx(r.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:q,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:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:fe=>d(fe?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(r.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(ye,{style:{marginTop:12},children:"Product Section"}),e.jsx(r.AutoComplete,{value:m,options:b,onSearch:u,onFocus:()=>{k&&String(m||"").trim().length<2&&v(oe)},onSelect:$e,disabled:!k,children:e.jsx(r.Input,{placeholder:"Search by product name or barcode",onKeyDown:Ee,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",gt(ue)]})]}),e.jsx(r.Table,{rowKey:fe=>Ze(fe?.id),columns:Xe,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:X.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(ue)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(de,{type:"button",value:"Submit",disabled:!k||X.length===0,onClick:We,style:{flex:1,minWidth:140}}),e.jsx(r.Button,{type:"text",style:M,onClick:()=>{h({}),p({}),u(""),v(oe)},disabled:X.length===0,children:"Clear"})]})]})]})})]}),e.jsx(r.Modal,{open:R,title:"Payment",onCancel:()=>I(!1),onOk:Ve,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(r.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(r.DatePicker,{value:P,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(r.InputNumber,{min:0,max:ue,value:g,onChange:fe=>f(Number(fe||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(r.Upload,{fileList:N,beforeUpload:()=>!1,onChange:({fileList:fe})=>j((fe||[]).slice(-1)),maxCount:1,children:e.jsx(r.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(r.Input.TextArea,{value:S,onChange:fe=>A(fe.target.value),rows:3})]}),e.jsx(r.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(ue)})]}),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(ie)})]})]})})]})})]})}const Wc=({token:t})=>e.jsx(Vc,{token:t}),fa=Ue.unit,Hc=({token:t,page:n=1,perPage:a=10})=>Un({baseUrl:fa.list,page:n,perPage:a,token:t}),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}),[s,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:m,mutate:u}=Hc({token:t,page:n.page,perPage:n.rowsPerPage}),b=async I=>{try{await u($n(fa.add,I,t),rt(I)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=I=>{I.preventDefault();const D=new FormData(I.target);b(D),I.target.reset()},w=(I,D)=>{a({page:I,rowsPerPage:parseInt(D,10)})},p=async I=>{try{await u(Nn(fa.remove,I,t),Qe(I)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},y=I=>{d(I),o(!0)},h=async I=>{I.preventDefault();const D=new FormData(I.target);D.set("id",String(l?.id??""));try{await dn(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})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(D),style:{padding:2}}),e.jsx(lt,{id:D?.id,funcName:p})]})}],[p]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:s,title:l?.name?`Edit ${l.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:h,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(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Kc,children:"Cancel"})]})]})})}),e.jsxs(ye,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{px:3,pb:2,children:e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(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(ye,{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(ye,{pt:3,children:e.jsx(Le,{parentCallback:w,data:{newData:m,columns:R,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const Jc=({token:t})=>e.jsx(Gc,{token:t}),Qc=Ue.product.sellReports,Xc=Ue.academy.classes,Zc=Ue.academy.sections,eu=Ue.student.dropdown,Vr=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function tu({token:t}){const n=i.useRef(null),[a,s]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(!1),v=j=>{const M=j?.data?.data??j?.data??j??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},{data:w}=G(t?[Xc,t]:null,([j,M])=>Q(j,M)),p=i.useMemo(()=>v(w),[w]),y=t&&o?`${Zc}?class_id=${encodeURIComponent(String(o))}`:null,{data:h}=G(y?[y,t]:null,([j,M])=>Q(j,M)),R=i.useMemo(()=>v(h),[h]),I=t&&o&&d?`${eu}?class=${encodeURIComponent(String(o))}§ion=${encodeURIComponent(String(d))}`:null,{data:D}=G(I?[I,t]:null,([j,M])=>Q(j,M)),C=i.useMemo(()=>v(D),[D]),{trigger:g,isMutating:f,data:S}=Je(Qc,(j,{arg:M})=>Os(j,{arg:M},t));i.useEffect(()=>{const M=new Date().toISOString().slice(0,10);g({duration:[M,M]})},[g]);const A=i.useMemo(()=>{const j=S?.data??S??[];return Array.isArray(j)?j:[]},[S]),P=j=>{const M=Array.isArray(j?.product_details)?j.product_details:[];return M.length===0?null:e.jsx(r.Table,{size:"small",bordered:!0,pagination:!1,rowKey:k=>`${j?.receipt_id??"r"}_${k?.product_name??k?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:k=>Vr(k)}],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:j=>Vr(j)}],N=async()=>{if(!a||a.length!==2)return;const[j,M]=a;await g({duration:[j.format("YYYY-MM-DD"),M.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:x||""})};return e.jsx("div",{children:e.jsxs(r.Row,{gutter:[16,16],children:[e.jsx(r.Col,{xs:24,lg:8,children:e.jsx(r.Card,{title:e.jsx(r.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(r.DatePicker.RangePicker,{value:a,onChange:s,style:{width:"100%"}})]}),e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:j=>{const M=j?.value??"";l(M),c(""),m(""),b(k=>!k)}}),e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:j=>{const M=j?.value??"";c(M),m("")}},`section_${u}`),e.jsx(ee,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:j=>m(j?.value??"")}),e.jsx(de,{type:"button",value:f?"Searching...":"Search",disabled:f,onClick:N,style:{width:"100%"}})]})})}),e.jsx(r.Col,{xs:24,lg:16,children:e.jsx(r.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(Pa,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(vt,{})}),e.jsx(r.Table,{bordered:!0,size:"small",loading:f,rowKey:j=>String(j?.receipt_id??j?.receipt_no??Math.random()),columns:L,expandable:{expandedRowRender:P},dataSource:A,pagination:{pageSize:20}})]})})})]})})}const nu=({token:t})=>e.jsx(tu,{token:t}),au=Ue.product;function su({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState([]),[l,d]=i.useState([]),[c,x]=i.useState(!1),[m,u]=i.useState(!1),[b,v]=i.useState(null),[w,p]=i.useState(0),[y,h]=i.useState(null),[R,I]=i.useState(""),D=i.useRef(null),C=on.useReactToPrint({contentRef:D,documentTitle:"Stock Barcodes"}),{isLoading:g,error:f,data:S,mutate:A}=lo({token:t,page:n.page,perPage:n.rowsPerPage}),P=($,E)=>{a({page:$,rowsPerPage:parseInt(E,10)})},L={selectedRowKeys:s,onChange:($,E)=>{o($),d(E)}},N=$=>{v($),p(Number($?.quantity??0)),h(null),I(""),x(!0)},j=()=>{x(!1),v(null),p(0),h(null),I("")},M=async()=>{if(!b?.id)return;u(!0);const $=new FormData;$.append("product_id",String(b.id)),$.append("qty",String(w??0)),y&&$.append("tran_date",y.format("YYYY-MM-DD")),R&&$.append("remarks",R);try{const E=await dn(au.addStock,$,t);E?.Status==="Success"?(_.success("Success! Updated quantity.",{duration:1e3}),j(),await A()):_.error(E?.msg??"Failed to update quantity.",{duration:1e3})}catch{_.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},k=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:($,E)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(r.Button,{size:"small",onClick:()=>N(E),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:b?.name?`Update Stock: ${b.name}`:"Update Stock",open:c,onCancel:j,onOk:M,okButtonProps:{loading:m},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(r.InputNumber,{min:0,style:{width:"100%"},value:w,onChange:$=>p($??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(r.DatePicker,{style:{width:"100%"},value:y,onChange:h})]}),e.jsx(Rt,{label:"Remarks",name:"remarks",rows:3,value:R,onChange:$=>I($.target.value)})]})}),e.jsxs(ye,{pt:5,pb:2,children:[e.jsxs(ye,{children:["Manage Stock",e.jsx(de,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>C?.(),style:{minWidth:170}})]}),e.jsx(ye,{style:{padding:"12px 16px"},children:e.jsx(r.Card,{style:{borderRadius:16},children:e.jsx(Le,{parentCallback:P,data:{newData:S,columns:k,columnstype:"antd",action:!1,Loading:g,error:f,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($=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:$?.name??""}),e.jsx(Ii,{value:String($?.barcode??$?.id??""),height:50,width:1.6,displayValue:!0})]},$?.id??$?.barcode??$?.name))})})})]})}const ru=({token:t})=>e.jsx(su,{token:t}),iu=Ue.report.stock,ou=Ue.product.dropdown,lu=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function du({token:t}){const n=i.useRef(null),[a,s]=i.useState(null),[o,l]=i.useState(""),{data:d}=G(t?[ou,t]:null,([p,y])=>Q(p,y)),c=i.useMemo(()=>lu(d),[d]),{trigger:x,isMutating:m,data:u}=Je(iu,(p,{arg:y})=>Os(p,{arg:y},t));i.useEffect(()=>{const y=new Date().toISOString().slice(0,10);x({duration:[y,y]})},[x]);const b=i.useMemo(()=>{const p=u?.data??u??[];return(Array.isArray(p)?p:[]).flatMap(h=>(Array.isArray(h?.ledger)?h.ledger:[]).map((R,I)=>({key:`${h.product_id??h.product_name??"p"}-${I}`,date:R?.date,product:h?.product_name,opening:R?.opening,inward:R?.inward,outward:R?.outward,closing:R?.closing})))},[u]),v=[{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:p=>e.jsx("span",{style:{color:Number(p)<0?"red":"green"},children:p})}],w=async()=>{if(!a||a.length!==2)return;const[p,y]=a;await x({duration:[p.format("YYYY-MM-DD"),y.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(r.Card,{title:e.jsx(r.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(r.DatePicker.RangePicker,{value:a,onChange:s}),e.jsxs("select",{value:o,onChange:p=>l(p.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(p=>e.jsx("option",{value:String(p?.value??""),children:String(p?.label??"")},String(p?.value??p?.id??p?.label)))]}),e.jsx(r.Button,{type:"primary",onClick:w,loading:m,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(Pa,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(vt,{})}),e.jsx(r.Table,{bordered:!0,size:"small",loading:m,rowKey:"key",columns:v,dataSource:b,pagination:{pageSize:50}})]})]})}const cu=({token:t})=>e.jsx(du,{token:t}),Ea=t=>t??localStorage.getItem("authToken")??"",Fs=(t,n)=>{const a=String(t??""),s=String(n??"");return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s},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"}},co=()=>Fs(at(),Ae.upload),uu=()=>Fs(at(),Ae.staff.uploadProfile),pu=()=>Fs(at(),Ae.staff.uploadDocuments),mu=async({baseUrl:t,page:n=1,perPage:a=10},s)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Ea(s))},xt=async(t,n,a)=>Ye(t,n,Ea(a)),Et=async(t,n,a)=>pt(t,n,Ea(a)),Bn=async(t,n,a)=>st(t,n,Ea(a)),Lt=Ae.staff,fu=Ae.master.shift.dropdown,yu=Ae.master.department.dropdown,hu=Ae.master.designation.dropdown,gu=Ae.roleDropdown,Xn=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},xu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",gn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Wr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function bu({token:t,mode:n,staffId:a,initialValues:s,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(s?.roleValue??null),[m,u]=i.useState(s?.departmentValue??null),[b,v]=i.useState(s?.designationValue??null),[w,p]=i.useState(s?.genderValue??null),[y,h]=i.useState(s?.shiftValue??(d?[]:null)),[R,I]=i.useState(s?.dob?ae(s.dob):null),[D,C]=i.useState(s?.doj?ae(s.doj):null),[g,f]=i.useState(s?.file??""),{data:S}=G(t?[fu,t]:null,([Y,q])=>Q(Y,q)),{data:A}=G(t?[yu,t]:null,([Y,q])=>Q(Y,q)),{data:P}=G(t?[hu,t]:null,([Y,q])=>Q(Y,q)),{data:L}=G(t?[gu,t]:null,([Y,q])=>Q(Y,q)),{data:N}=G(t?[Lt.lastEmpNo,t]:null,([Y,q])=>Q(Y,q)),j=i.useMemo(()=>Xn(S),[S]),M=i.useMemo(()=>Xn(A),[A]),k=i.useMemo(()=>Xn(P),[P]),$=i.useMemo(()=>Xn(L),[L]),E=i.useMemo(()=>{const Y=N?.data?.emp_number??N?.emp_number??N?.data??"";return String(Y??"")},[N]),B=async Y=>{Y.preventDefault();const q=new FormData(Y.target);q.set("role",c?.value??c??""),q.set("department",m?.value??m??""),q.set("designation",b?.value??b??""),q.set("gender",w?.value??w??""),q.set("dob",R?R.format("YYYY-MM-DD"):""),q.set("doj",D?D.format("YYYY-MM-DD"):""),d?(q.delete("shift_id"),(Array.isArray(y)?y:[]).forEach(T=>{q.append("shift_id[]",T?.value??T??"")})):q.set("shift_id",y?.value??y??""),g&&q.set("file",g);try{const O=n==="edit"&&a,T=O?Lt.editBasic:Lt.addBasic;O&&q.set("staff_id",String(a));const F=O?await Et(T,q,t):await xt(T,q,t),U=F?.ID??F?.id??a??null;_.success("Success!",{duration:1e3}),o?.({staffId:U,basic:{roleValue:c,departmentValue:m,designationValue:b,genderValue:w,shiftValue:y,dob:R,doj:D,file:g}})}catch(O){_.error(O?.response?.data?.msg??O?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"number",name:"emp_number",label:"EMP No",defaultValue:s?.emp_number??E,required:!0}),e.jsx(J,{type:"text",name:"f_name",label:"First Name",defaultValue:s?.f_name??"",required:!0}),e.jsx(J,{type:"text",name:"l_name",label:"Last Name",defaultValue:s?.l_name??"",required:!0}),e.jsx(J,{type:"text",name:"pan_no",label:"PAN",defaultValue:s?.pan_no??""}),e.jsx(J,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:s?.adhar_no??""}),e.jsx(ee,{label:"Role",options:$,value:c,onChange:Y=>x(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Department",options:M,value:m,onChange:Y=>u(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Designation",options:k,value:b,onChange:Y=>v(Y??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:Y=>p(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"email",label:"Email",defaultValue:s?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:gn,children:"DOB"}),e.jsx(r.DatePicker,{value:R,onChange:Y=>I(Y),style:Wr,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:gn,children:"DOJ"}),e.jsx(r.DatePicker,{value:D,onChange:Y=>C(Y),style:Wr,placeholder:"Select DOJ"})]}),e.jsx(J,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:s?.bloodGroup??""}),e.jsx(J,{type:"text",name:"contact_no",label:"Contact No",defaultValue:s?.contact_no??"",required:!0}),e.jsx(J,{type:"text",name:"education",label:"Education",defaultValue:s?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:gn,children:"Shift"}),e.jsx(ee,{options:j,value:y,onChange:Y=>h(Y??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:gn,children:"Profile Picture"}),e.jsx(r.Upload,{maxCount:1,action:uu(),headers:t?{Authorization:t}:void 0,onChange:Y=>{if(Y?.file?.status==="done"){const q=xu(Y?.file?.response);q&&f(q)}Y?.file?.status==="removed"&&f("")},children:e.jsx(r.Button,{type:"link",style:{paddingLeft:0},children:g?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:gn,children:"Address"}),e.jsx("textarea",{name:"address",rows:3,defaultValue:s?.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 Zn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Hr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Su=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Kr=t=>{if(!t)return null;const n=ae(t);return n.isValid()?n:null};function ju({token:t,mode:n,staffId:a,initialRows:s,onSubmitted:o,onBack:l}){const[d,c]=i.useState(()=>(Array.isArray(s)&&s.length?s:[{name:"",from:null,to:null,image:""}]).map(p=>({name:p?.name??"",from:Kr(p?.from),to:Kr(p?.to),image:p?.image??""}))),x=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),m=(w,p)=>{c(y=>y.map((h,R)=>R===w?{...h,...p}:h))},u=()=>c(w=>[...w,{name:"",from:null,to:null,image:""}]),b=w=>c(p=>p.length<=1?p:p.filter((y,h)=>h!==w)),v=async w=>{if(w.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const p=new FormData;p.append("staff_id",String(a)),d.forEach((y,h)=>{p.append(`experience[${h}][name]`,String(y?.name??"")),p.append(`experience[${h}][from]`,y?.from?y.from.format("YYYY-MM-DD"):""),p.append(`experience[${h}][to]`,y?.to?y.to.format("YYYY-MM-DD"):""),p.append(`experience[${h}][image]`,String(y?.image??""))});try{const y=n==="edit",h=y?Lt.editExperience:Lt.addExperience,R=y?await Et(h,p,t):await xt(h,p,t);_.success("Success!",{duration:1e3}),o?.({experience:d,result:R})}catch(y){_.error(y?.response?.data?.msg??y?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((w,p)=>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:Zn,children:"Name"}),e.jsx("input",{value:w.name,onChange:y=>m(p,{name:y.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:Zn,children:"From"}),e.jsx(r.DatePicker,{value:w.from,onChange:y=>m(p,{from:y}),style:Hr})]}),e.jsxs("div",{children:[e.jsx("div",{style:Zn,children:"To"}),e.jsx(r.DatePicker,{value:w.to,onChange:y=>m(p,{to:y}),style:Hr})]}),e.jsxs("div",{children:[e.jsx("div",{style:Zn,children:"Document"}),e.jsx(r.Upload,{maxCount:1,action:pu(),headers:x,onChange:y=>{if(y?.file?.status==="done"){const h=Su(y?.file?.response);h&&m(p,{image:h})}y?.file?.status==="removed"&&m(p,{image:""})},children:e.jsx(r.Button,{icon:e.jsx(Z.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(r.Button,{type:"text",icon:e.jsx(Z.DeleteOutlined,{}),danger:!0,onClick:()=>b(p),disabled:d.length<=1})})]},`exp-${p}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(r.Button,{icon:e.jsx(Z.PlusOutlined,{}),onClick:u,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(r.Button,{onClick:l,children:"Back"}),e.jsx(de,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const Gr=(t,n=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const a=n.length?n:["allowances","Allowances","dedection","Dedection","deductions","Deductions"],s=[t];t?.data&&typeof t.data=="object"&&s.push(t.data);for(const l of s)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[]},xn=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function vu({token:t,mode:n,staffId:a,initialValues:s,onSubmitted:o,onBack:l}){const[d,c]=i.useState(s?.type??"Permanent"),[x,m]=i.useState(s?.salary_type??xn[0]?.value),[u,b]=i.useState(Number(s?.amount??0)),[v,w]=i.useState(Number(s?.basic_pay)),[p,y]=i.useState(s?.declarationPERyear??""),{data:h}=G(t?[fd,t]:null,([f,S])=>Q(f,S),{revalidateOnFocus:!1}),R=i.useMemo(()=>Gr(h,["allowances","Allowances"]),[h]),I=i.useMemo(()=>Gr(h,["dedection","Dedection","deductions","Deductions"]),[h]),D=i.useMemo(()=>{const f=Number(v||0),S=(Array.isArray(R)?R:[]).map(j=>{const M=j?.amount_type??j?.amountType??j?.type??"",k=Number(j?.Amount??j?.amount??0),E=String(M).trim().toLowerCase()==="flat"?k:Number(f)/100*Number(k||0);return{...j,value:Number.isFinite(E)?E:0}}),A=(Array.isArray(I)?I:[]).map(j=>{const M=j?.amount_type??j?.amountType??j?.type??"",k=Number(j?.Amount??j?.amount??0),E=String(M).trim().toLowerCase()==="flat"?k:Number(f)/100*Number(k||0);return{...j,value:Number.isFinite(E)?E:0}}),P=S.reduce((j,M)=>j+Number(M?.value||0),0),L=A.reduce((j,M)=>j+Number(M?.value||0),0),N=Math.max(0,Number(f)+P-L);return{allowances:S,deductions:A,netAmount:N}},[R,I,v]),C=async f=>{if(f.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const S=new FormData;S.append("staff_id",String(a)),S.append("type",d),d==="Nonpermanent"?(S.append("salary_type",x??""),S.append("amount",String(u||"")),S.append("Allowances",JSON.stringify([])),S.append("Dedection",JSON.stringify([]))):(S.append("basic_pay",String(v||"")),S.append("declarationPERyear",String(p??"")),S.append("Allowances",JSON.stringify(D.allowances||[])),S.append("Dedection",JSON.stringify(D.deductions||[])),S.append("amount",String(D.netAmount||0)));try{const A=n==="edit",P=A?Lt.editPayroll:Lt.addPayroll,L=A?await Et(P,S,t):await xt(P,S,t);o?.({payroll:{staffType:d,salaryType:x,amount:u,basicPay:v,declaration:p},result:L})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(f,S)=>`${S?.Amount??""} / ${S?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:f=>c(f?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(ee,{label:"Type",options:xn,value:xn.find(f=>f.value===x)??xn[0],onChange:f=>m(f?.value??xn[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"number",label:"Amount",value:u,onChange:f=>b(Number(f.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{type:"number",label:"Basic Pay",value:v,onChange:f=>w(Number(f.target.value||0)),required:!0}),e.jsx(J,{type:"text",label:"IT Declarations/Year",value:p,onChange:f=>y(f.target.value)}),e.jsx(J,{type:"number",label:"Net Amount",value:D.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(r.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(r.Table,{bordered:!0,size:"small",rowKey:(f,S)=>`${f?.title??"a"}-${S}`,columns:g,dataSource:D.allowances,pagination:!1})}),e.jsx(r.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(r.Table,{bordered:!0,size:"small",rowKey:(f,S)=>`${f?.title??"d"}-${S}`,columns:g,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 _u=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function wu({token:t,mode:n="add",staffId:a,onFinished:s}){const[o,l]=i.useState(0),[d,c]=i.useState(a??null),[x,m]=i.useState(null),[u,b]=i.useState(null),[v,w]=i.useState(null),p=n==="edit"?a??d:null,y=i.useMemo(()=>p?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(p))}`:null,[p]),h=i.useMemo(()=>p?`${Ae.staff.experienceById}?staff_id=${encodeURIComponent(String(p))}`:null,[p]),R=i.useMemo(()=>p?`${Ae.staff.payrollById}?staff_id=${encodeURIComponent(String(p))}`:null,[p]),{data:I}=G(t&&y?[y,t]:null,([P,L])=>Q(P,L)),{data:D}=G(t&&h?[h,t]:null,([P,L])=>Q(P,L)),{data:C}=G(t&&R?[R,t]:null,([P,L])=>Q(P,L)),g=i.useMemo(()=>{const P=_u(I)[0]??I?.data??I??null;return P?{emp_number:P?.emp_number??P?.empNo??"",f_name:P?.f_name??P?.firstname??P?.first_name??"",l_name:P?.l_name??P?.lastname??P?.last_name??"",pan_no:P?.pan_no??"",adhar_no:P?.adhar_no??"",email:P?.email??"",dob:P?.dob??"",doj:P?.doj??"",bloodGroup:P?.bloodGroup??P?.blood_group??"",contact_no:P?.contact_no??P?.phone??"",education:P?.education??"",address:P?.address??"",file:P?.file??P?.profile_picture??""}:null},[I]),f=i.useMemo(()=>{const P=D?.data??D??null;return(Array.isArray(P?.experience)?P.experience:Array.isArray(P)?P:[]).map(N=>({name:N?.name??"",from:N?.from??"",to:N?.to??"",image:N?.image??""}))},[D]),S=i.useMemo(()=>{const P=C?.data??C??null;return P?{type:P?.type??"Permanent",salary_type:P?.salary_type??"",amount:P?.amount??"",basic_pay:P?.basic_pay??"",declarationPERyear:P?.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(r.Card,{title:e.jsx(r.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(r.Steps,{current:o,items:A}),o===0&&e.jsx(bu,{token:t,mode:n,staffId:p,initialValues:g,onSubmitted:({staffId:P})=>{P&&c(P),l(1)}}),o===1&&e.jsx(ju,{token:t,mode:n,staffId:p??d,initialRows:f,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(vu,{token:t,mode:n,staffId:p??d,initialValues:S,onBack:()=>l(1),onSubmitted:()=>{_.success("Completed.",{duration:1e3}),s?.({staffId:p??d}),l(0),n!=="edit"&&(c(null),m(null),b(null),w(null))}})]})})]})}function Cu({token:t}){return e.jsx(wu,{token:t,mode:"add"})}const Au=({token:t})=>e.jsx(Cu,{token:t}),ea=Ae.staff,Tu=Ae.roleDropdown,Iu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Ru=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Du({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(""),[l,d]=i.useState(""),{data:c}=G(t?[Tu,t]:null,([R,I])=>Q(R,I)),x=i.useMemo(()=>Iu(c),[c]),m=i.useMemo(()=>{const R=n.page,I=n.rowsPerPage,D=s&&!l?`${ea.searchByRole}?role_id=${encodeURIComponent(String(s))}`:l?`${ea.searchByKeywords}?key=${encodeURIComponent(String(l))}`:ea.list,C=D.includes("?")?"&":"?";return`${D}${C}page=${encodeURIComponent(String(R))}&per_page=${encodeURIComponent(String(I))}`},[n.page,n.rowsPerPage,l,s]),{isLoading:u,error:b,data:v,mutate:w}=G(t?[m,t]:null,([R,I])=>Q(R,I)),p=i.useMemo(()=>Ru(v),[v]),y=async R=>{const I=R?.id??R?.fk_staffID??R?.staff_id;if(I)try{await Bn(ea.deactivate,I,t),_.success("Success! Staff deactivated.",{duration:1e3}),await w()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to deactivate staff.",{duration:1e3})}},h=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(R,I)=>`${I?.firstname??I?.first_name??""} ${I?.lastname??I?.last_name??""}`.trim()||I?.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:(R,I)=>e.jsx(r.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>y(I),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(r.Card,{title:e.jsx(r.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:R=>{o(R?.value??""),a(I=>({...I,page:1}))}}),e.jsx(J,{type:"text",label:"Keyword",value:l,onChange:R=>d(R.target.value),placeholder:"Search by keywords"}),e.jsx(de,{type:"button",value:"Refresh",onClick:()=>w()})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(r.Table,{bordered:!0,size:"small",loading:u,rowKey:R=>String(R?.id??R?.fk_staffID??R?.staff_id??Math.random()),columns:h,dataSource:p,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(R,I)=>a({page:R,rowsPerPage:I}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const Ou=({token:t})=>e.jsx(Du,{token:t}),Pu=Ae.attendance,ku=Ae.roleDropdown,Jr=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ta={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Qr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Eu({token:t,open:n,onClose:a,roleId:s,onSaved:o}){const[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(ae()),[b,v]=i.useState(ae()),[w,p]=i.useState(ae()),y=i.useMemo(()=>s?`${Ae.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(s))}`:null,[s]),{data:h}=G(t&&y?[y,t]:null,([f,S])=>Q(f,S)),R=i.useMemo(()=>Jr(h),[h]),{trigger:I,data:D}=Je(t?Ae.attendance.staffShiftByStaffId:null,(f,{arg:S})=>Bt(f,{arg:S},t)),C=i.useMemo(()=>Jr(D),[D]),g=async()=>{if(!l?.value){_.error("Select staff.",{duration:1e3});return}if(!c){_.error("Select shift.",{duration:1e3});return}const f=new FormData;f.set("staffID",String(l.value)),f.set("shift_id",String(c)),f.set("attendance_date",m?m.format("YYYY-MM-DD"):""),f.set("intime",b?b.format("h:mm a"):""),f.set("outime",w?w.format("h:mm a"):"");try{await xt(Ae.attendance.manualAttendance,f,t),_.success("Success!",{duration:1e3}),o?.(),a?.(),d(null),x(""),u(ae()),v(ae()),p(ae())}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed.",{duration:1e3})}};return e.jsx(r.Modal,{open:n,onCancel:a,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(r.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{label:"Staff",options:R,value:l,onChange:async f=>{if(d(f??null),x(""),f?.value&&I)try{await I({staff_id:f.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:ta,children:"Shift"}),e.jsx(r.Radio.Group,{value:c,onChange:f=>x(f.target.value),style:{display:"grid",gap:8},children:C.map(f=>e.jsx(r.Radio,{value:f?.value,children:f?.label??f?.name??f?.title??String(f?.value??"")},String(f?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:ta,children:"Date"}),e.jsx(r.DatePicker,{value:m,onChange:f=>f&&u(f),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:ta,children:"Start Time"}),e.jsx(r.TimePicker,{value:b,onChange:f=>f&&v(f),use12Hours:!0,format:"h:mm a",style:Qr})]}),e.jsxs("div",{children:[e.jsx("div",{style:ta,children:"End Time"}),e.jsx(r.TimePicker,{value:w,onChange:f=>f&&p(f),use12Hours:!0,format:"h:mm a",style:Qr})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(r.Button,{onClick:a,children:"Cancel"}),e.jsx(de,{type:"button",value:"Save",color:"primary",onClick:g})]})]})})})}const Mu=({tableRef:t,excelDisabled:n})=>{const a=new Date().getTime(),s=on.useReactToPrint({content:()=>t?.current});return e.jsx(r.Row,{justify:"end",children:e.jsx(r.Col,{children:e.jsxs(r.Row,{gutter:8,children:[e.jsx(r.Col,{children:e.jsx(r.Button,{type:"text",icon:e.jsx(Z.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:s})}),e.jsx(r.Col,{children:n?e.jsx(r.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>_.error("You must save attendance before download",{duration:2e3})}):e.jsx(ro.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:t?.current,children:e.jsx(r.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},Fu=(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:[]:[]},$u=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},Nu=(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 Uu({token:t,url:n,columns:a,reload:s,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:x="staff"}){const m=i.useRef(null),[u,b]=i.useState({page:0,rowsPerPage:10}),[v,w]=i.useState(!1),[p,y]=i.useState(!1),[h,R]=i.useState(null),[I,D]=i.useState([]),[C,g]=i.useState({sunday:!1,holiday:!1}),[f,S]=i.useState(!0);i.useEffect(()=>{b(N=>({...N,page:0}))},[n]),i.useEffect(()=>{let N=!0;return(async()=>{if(!(!t||!n)){w(!0);try{const M=String(n).includes("?")?"&":"?",k=`${n}${M}page=${u.page+1}&per_page=${u.rowsPerPage}`,$=await Q(k,t);if(!N)return;R($),$?.Status==="Success"?(d?.(!1),D(Fu($,x)),g(Nu($,x))):(d?.(!0),D([]),g({sunday:!1,holiday:!1}))}catch{if(!N)return;d?.(!0),D([])}finally{N&&w(!1)}}})(),()=>{N=!1}},[u.page,u.rowsPerPage,s,d,t,x,n]);const A=i.useMemo(()=>$u(h),[h]);i.useEffect(()=>{const N=(Array.isArray(I)?I:[]).find(j=>j?.attendence_type_id===null);S(!!N)},[I]);const P=async()=>{if(t){y(!0);try{if(x==="staff"){const N=(Array.isArray(I)?I:[]).map(j=>({staff_id:j?.staff_id,attendence_type_id:j?.attendence_type_id?j.attendence_type_id:"1",in_time:j?.intime,out_time:j?.outtime,date:c}));await xt(Ae.attendance.addAttendanceToStaffByBranch,N,t),_.success("Attendance saved successfully",{duration:2e3}),o?.(j=>!j)}else _.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(N){_.error(N?.response?.data?.msg??N?.message??"Failed required dates",{duration:2e3})}finally{y(!1)}}},L=i.useMemo(()=>(Array.isArray(a)?a:[]).map(j=>j?.selector==="attendence_type_id"?{title:j?.name??"Attendance",dataIndex:j.selector,key:j.selector,render:M=>M==null||M===""?e.jsx(r.Tag,{color:"orange",children:"Not Set"}):String(M)==="1"?e.jsx(r.Tag,{color:"green",children:"Present"}):String(M)==="4"?e.jsx(r.Tag,{color:"red",children:"Absent"}):String(M)==="3"?e.jsx(r.Tag,{color:"orange",children:"Late"}):e.jsx(r.Tag,{children:String(M)})}:j?.selector==="snum"?{title:j?.name??"Sl",key:j.selector,render:(M,k,$)=>$+1}:{title:j?.name??j?.selector,dataIndex:j?.selector,key:j?.selector}),[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(r.Card,{children:[e.jsx(Mu,{tableRef:m,excelDisabled:f}),e.jsx(r.Modal,{open:p,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(r.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:m,children:e.jsx(r.Table,{bordered:!0,size:"small",rowKey:(N,j)=>String(N?.id??N?.staff_id??j),columns:L,dataSource:I,loading:v,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:A,showSizeChanger:!0,onChange:(N,j)=>b({page:N-1,rowsPerPage:j})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:P,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const Bu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Lu={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function qu({token:t}){const[n,a]=i.useState(""),[s,o]=i.useState(ae().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,x]=i.useState(null),[m,u]=i.useState(!1),[b,v]=i.useState(!0),[w,p]=i.useState(!1),y=i.useRef(null),{data:h}=G(t?[ku,t]:null,([D,C])=>Q(D,C)),R=i.useMemo(()=>Bu(h),[h]),I=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(r.Card,{title:e.jsx(r.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:R,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(r.DatePicker,{defaultValue:ae(),onChange:D=>D&&o(D.format("YYYY-MM-DD")),style:Lu,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!s||(x(`${Pu.staffListForAttendance}?role=${encodeURIComponent(String(n))}&date=${encodeURIComponent(String(s))}`),d(D=>!D))}})})]})}),e.jsxs(r.Card,{title:e.jsx(r.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(r.Button,{size:"small",type:m?"primary":"default",onClick:()=>u(D=>!D),children:m?"Marked":"Mark As Holiday"}),e.jsx(r.Button,{size:"small",type:"default",disabled:b,onClick:()=>p(!0),children:"Give Attendance"})]}),c?e.jsx(Uu,{token:t,url:c,columns:I,reload:l,setReload:d,saveBtnRef:y,setSaveBtnDisabled:v,date:s,type:"staff",holidayChecked:m}):null]}),e.jsx(Eu,{token:t,open:w,onClose:()=>p(!1),roleId:n,onSaved:()=>d(D=>!D)})]})}const zu=({token:t})=>e.jsx(qu,{token:t}),Xr=Ae.attendanceReport.monthlyStaffReport,Yu=Ae.roleDropdown,Vu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Wu({token:t}){const n=i.useRef(null),[a,s]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),x=i.useMemo(()=>ks(5),[]),{data:m}=G(t?[Yu,t]:null,([N,j])=>Q(N,j)),u=i.useMemo(()=>Vu(m),[m]),[b,v]=i.useState([]),[w,p]=i.useState(1),[y,h]=i.useState(!1),[R,I]=i.useState(!1),[D,C]=i.useState(null),g=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:f}=Je(t&&Xr?`${Xr}?page=${w}&per_page=3`:null,(N,{arg:j})=>Bt(N,{arg:j},t),{onSuccess:N=>{h(!1);const j=Array.isArray(N)?N:[];j.length>0&&v(M=>[...M||[],...j]),j.length>1?p(M=>M+1):I(!1)},onError:()=>{h(!1),I(!1)}});i.useEffect(()=>{R&&f&&D&&f(D)},[R,w,D,f]);const S=i.useMemo(()=>{const N=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(j,M)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:M?.full_name??""})}];return Array.isArray(b)&&b.length>0&&((b[0]?.monthly_data??[]).forEach((M,k)=>{N.push({title:k+1,align:"center",key:String(k+1),render:($,E)=>{const B=E?.monthly_data?.[k]?.[0]?.data?.[0]??{},Y=B?.intime??"",q=B?.outtime??"",O=B?.attendance_type??"";return e.jsx(r.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",Y]}),e.jsxs("div",{children:["Out Time ",q]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:ze(O)})})}})}),N.push({title:"Total",key:"Total",render:(M,k)=>{const $=k?.monthly_data??[],E=$.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="A").length,B=$.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",E," P : ",B]})})}})),N},[b]),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")}],[]),P=i.useMemo(()=>d.month?o.find(N=>N?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),L=async N=>{if(N.preventDefault(),!d.role||!d.year||!d.month)return;p(1),h(!0),v([]);const j={session:g,year:d.year,month:d.month,day:"01",role:d.role};C(j),I(!0),await f?.(j)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{className:"d-print-none",title:e.jsx(r.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:N=>c(j=>({...j,role:N?.value??"",rolllabel:N?.label??""}))}),e.jsx(ee,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:N=>{const j=Es(N?.value);l(j),s(M=>!M),c(M=>({...M,year:N?.label??""}))}}),e.jsx(ee,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:N=>c(j=>({...j,month:N?.value??""}))},`month-${a}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.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(vt,{})}),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:P})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(Pa,{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(N=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[N.label," :"]}),e.jsx("div",{children:N.el})]},N.label))})})]}),e.jsx(r.Skeleton,{active:!0,loading:y,paragraph:{rows:10},children:e.jsx(r.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:S,dataSource:b,pagination:!1,scroll:{x:"max-content"},rowKey:(N,j)=>String(N?.staff_id??N?.id??j)})})]})})]})}const Hu=({token:t})=>e.jsx(Wu,{token:t}),Zr=Ae.payroll,Ku=Ae.roleDropdown,Gu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Ju=t=>t?.data?.data??t?.data??t??[];function Qu({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:a}){const[s,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,x]=i.useState([]),[m,u]=i.useState({role:"",roleLabel:"",year:"",month:""}),[b,v]=i.useState(null),w=S=>{if(!S)return;if(typeof a=="function"){a(S);return}const A=`${n}?id=${encodeURIComponent(String(S))}`;typeof window<"u"&&window?.location&&(window.location.href=A)},{data:p}=G(t?[Ku,t]:null,([S,A])=>Q(S,A)),y=i.useMemo(()=>Gu(p),[p]),h=i.useMemo(()=>ks(5),[]),{isLoading:R,error:I,data:D}=G(t&&b?[b,t]:null,([S,A])=>Q(S,A)),C=i.useMemo(()=>{const S=Ju(D);return Array.isArray(S)?S:[]},[D]),g=i.useMemo(()=>{const S=D?.pagination?.total_rows??D?.data?.pagination?.total_rows??D?.total??D?.total_rows,A=Number(S);return Number.isFinite(A)&&A>=0?A:C.length},[D,C.length]),f=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(S,A,P)=>P+1},{title:"Name",dataIndex:"full_name",key:"full_name",ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Mobile No",dataIndex:"contact_no",key:"contact_no",width:140,responsive:["md"]},{title:"Status",dataIndex:"status",key:"status",width:120,align:"center",render:(S,A)=>{const P=A?.id??A?.staff_id??A?.staffId;return e.jsx(r.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{w(P)},children:ao(A?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:S=>{if(S.preventDefault(),!m.role||!m.year||!m.month)return;const A=`${Zr.payrollByRole}?page=${encodeURIComponent(String(s.page))}&per_page=${encodeURIComponent(String(s.rowsPerPage))}&role=${encodeURIComponent(String(m.role))}&year=${encodeURIComponent(String(m.year))}&month=${encodeURIComponent(String(m.month))}`;v(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:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:S=>u(A=>({...A,role:S?.value??"",roleLabel:S?.label??""}))}),e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:S=>{const A=Es(S?.value);x(A),d(P=>!P),u(P=>({...P,year:S?.label??"",month:""}))}}),e.jsx(ee,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:S=>u(A=>({...A,month:S?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary",onClick:()=>o(S=>({...S,page:1}))})})]})}),e.jsx(r.Table,{bordered:!0,size:"small",loading:R,rowKey:(S,A)=>String(S?.id??S?.staff_id??A),columns:f,dataSource:C,pagination:{current:s.page,pageSize:s.rowsPerPage,total:g,showSizeChanger:!0,onChange:(S,A)=>{o({page:S,rowsPerPage:A}),!(!m.role||!m.year||!m.month)&&v(`${Zr.payrollByRole}?page=${encodeURIComponent(String(S))}&per_page=${encodeURIComponent(String(A))}&role=${encodeURIComponent(String(m.role))}&year=${encodeURIComponent(String(m.year))}&month=${encodeURIComponent(String(m.month))}`)}},scroll:{x:"max-content"}})]})})}const Xu=({token:t})=>e.jsx(Qu,{token:t}),uo=Ae.leave,cn=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>G(s&&t?[t,n,a,s]:null,([l,d,c,x])=>mu({baseUrl:l,page:d,perPage:c},x)),Zu=({token:t,page:n=1,perPage:a=10})=>cn({token:t,baseUrl:uo.requestTable,page:n,perPage:a}),ep=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},tp=(t,n)=>{const a=new FormData;return Object.entries(t??{}).forEach(([s,o])=>{o!=null&&a.append(s,String(o))}),a.set("status",n),a};function np({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),{isLoading:s,error:o,data:l,mutate:d}=Zu({token:t,page:n.page,perPage:n.rowsPerPage}),c=i.useMemo(()=>ep(l),[l]),x=async(u,b)=>{try{const v=tp(u,b),w=await Et(uo.approveRequest,v,t);w?.Status==="Success"?_.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):_.error(w?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to update request.",{duration:1e3})}},m=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,b)=>b?.full_name??b?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,b)=>b?.leave_from??b?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,b)=>b?.leave_to??b?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,b)=>b?.leavetype??b?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,b)=>b?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,b)=>b?.employee_remark??b?.reason??""},{title:"View",key:"document_file",width:140,render:(u,b)=>{const v=b?.document_file;return v?e.jsx(r.Button,{size:"small",onClick:()=>window.open(v,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,b)=>{const v=String(b?.status??"").toLowerCase();return v==="approved"?e.jsx(r.Tag,{color:"green",children:"Approved"}):v==="declined"?e.jsx(r.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(r.Button,{type:"text",size:"small",onClick:()=>x(b,"approved"),icon:e.jsx(Z.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(r.Button,{type:"text",size:"small",onClick:()=>x(b,"declined"),icon:e.jsx(Z.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(r.Table,{bordered:!0,size:"small",loading:s,rowKey:(u,b)=>String(u?.id??u?.leave_id??b),columns:m,dataSource:c,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(u,b)=>a({page:u,rowsPerPage:b}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const ap=({token:t})=>e.jsx(np,{token:t}),sp=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",rp=({token:t,value:n,onChange:a})=>{const s=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(r.Upload,{maxCount:1,action:co(),headers:s,onChange:o=>{if(o?.file?.status==="done"){const l=sp(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},po=Ae.leave,ip=Ae.master.leaveType.dropdown,op=({token:t,page:n=1,perPage:a=10})=>cn({token:t,baseUrl:po.table,page:n,perPage:a}),lp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ls={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function dp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(""),[c]=r.Form.useForm(),{isLoading:x,error:m,data:u,mutate:b}=op({token:t,page:n.page,perPage:n.rowsPerPage}),{data:v}=G(t?[ip,t]:null,([C,g])=>Q(C,g)),w=i.useMemo(()=>lp(v),[v]),p=(C,g)=>a({page:C,rowsPerPage:parseInt(g,10)}),y=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:ae()}),o(!0)},h=()=>{o(!1),d(""),c.resetFields()},R=async C=>{const g=new FormData;g.set("apply_date",C?.apply_date?C.apply_date.format("YYYY-MM-DD"):""),g.set("leave_type",C?.leave_type?.value??C?.leave_type??""),g.set("from_date",C?.from_date?C.from_date.format("YYYY-MM-DD"):""),g.set("to_date",C?.to_date?C.to_date.format("YYYY-MM-DD"):""),g.set("reason",C?.reason??""),l&&g.set("file",l);try{await xt(po.apply,g,t),_.success("Success! Leave request submitted.",{duration:1e3}),h(),await b()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to submit leave request.",{duration:1e3})}},I=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,g)=>g?.leavetype??g?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(C,g)=>g?.date??g?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(C,g)=>g?.leave_from??g?.from_date??""},{title:"To",key:"leave_to",width:130,render:(C,g)=>g?.leave_to??g?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(C,g)=>g?.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(r.Modal,{open:s,title:"Add Leave Request",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:c,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(r.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(r.DatePicker,{style:ls})]})}),e.jsx(r.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(r.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(r.DatePicker,{style:ls})]})}),e.jsx(r.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(r.DatePicker,{style:ls})]})}),e.jsx(r.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(rp,{token:t,value:l,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(r.Button,{onClick:h,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(de,{type:"button",value:"Add Leave Request",onClick:y})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(r.Table,{bordered:!0,size:"small",loading:x,rowKey:(C,g)=>String(C?.id??C?.leave_id??g),columns:D,dataSource:I,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(C,g)=>p(C,g),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const cp=({token:t})=>e.jsx(dp,{token:t}),ya=Ae.master.leaveType,up=({token:t,page:n=1,perPage:a=10})=>cn({token:t,baseUrl:ya.table,page:n,perPage:a});function pp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=up({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},p=async C=>{const g=new FormData;g.set("title",C?.title??"");try{await v(xt(ya.add,g,t),rt(g)),_.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add leave type.",{duration:1e3})}},y=C=>{x(C??null),o.setFieldsValue({title:C?.leave_type_name??C?.name??""}),d(!0)},h=()=>{d(!1),x(null),o.resetFields()},R=async C=>{const g=c?.id??c?.leave_type_id;if(!g){_.error("Missing leave type id.",{duration:1e3});return}const f=new FormData;f.set("id",String(g)),f.set("title",C?.title??"");try{await Et(ya.edit,f,t),await v(),_.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),h()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update leave type.",{duration:1e3})}},I=async C=>{const g=C?.id??C?.leave_type_id;if(g)try{await v(Bn(ya.remove,g,t),Qe(g)),_.success("Success! Deleted leave type.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??f?.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,g)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(g)}),e.jsx(r.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Leave Type",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:R,children:[e.jsx(r.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(r.Button,{onClick:h,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(r.Form,{form:s,layout:"vertical",onFinish:p,children:[e.jsx(r.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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const mp=({token:t})=>e.jsx(pp,{token:t}),ha=Ae.master.department,fp=({token:t,page:n=1,perPage:a=10})=>cn({token:t,baseUrl:ha.table,page:n,perPage:a});function yp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=fp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},p=async C=>{const g=new FormData;g.set("title",C?.title??"");try{await v(xt(ha.add,g,t),rt(g)),_.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add department.",{duration:1e3})}},y=C=>{x(C??null),o.setFieldsValue({title:C?.department_name??C?.name??""}),d(!0)},h=()=>{d(!1),x(null),o.resetFields()},R=async C=>{const g=c?.id??c?.department_id;if(!g){_.error("Missing department id.",{duration:1e3});return}const f=new FormData;f.set("id",String(g)),f.set("title",C?.title??"");try{await Et(ha.edit,f,t),await v(),_.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),h()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update department.",{duration:1e3})}},I=async C=>{const g=C?.id??C?.department_id;if(g)try{await v(Bn(ha.remove,g,t),Qe(g)),_.success("Success! Deleted department.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??f?.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,g)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(g)}),e.jsx(r.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Department",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:R,children:[e.jsx(r.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(r.Button,{onClick:h,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(r.Form,{form:s,layout:"vertical",onFinish:p,children:[e.jsx(r.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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const hp=({token:t})=>e.jsx(yp,{token:t}),ga=Ae.master.designation,gp=({token:t,page:n=1,perPage:a=10})=>cn({token:t,baseUrl:ga.table,page:n,perPage:a});function xp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=gp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},p=async C=>{const g=new FormData;g.set("title",C?.title??"");try{await v(xt(ga.add,g,t),rt(g)),_.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add designation.",{duration:1e3})}},y=C=>{x(C??null),o.setFieldsValue({title:C?.designation??""}),d(!0)},h=()=>{d(!1),x(null),o.resetFields()},R=async C=>{const g=c?.id??c?.designation_id;if(!g){_.error("Missing designation id.",{duration:1e3});return}const f=new FormData;f.set("id",String(g)),f.set("title",C?.title??"");try{await Et(ga.edit,f,t),await v(),_.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),h()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update designation.",{duration:1e3})}},I=async C=>{const g=C?.id??C?.designation_id;if(g)try{await v(Bn(ga.remove,g,t),Qe(g)),_.success("Success! Deleted designation.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??f?.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,g)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(g)}),e.jsx(r.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Designation",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:R,children:[e.jsx(r.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(r.Button,{onClick:h,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(r.Form,{form:s,layout:"vertical",onFinish:p,children:[e.jsx(r.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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const bp=({token:t})=>e.jsx(xp,{token:t}),xa=Ae.master.shift,Sp=({token:t,page:n=1,perPage:a=10})=>cn({token:t,baseUrl:xa.table,page:n,perPage:a}),et="hh:mm A",Qt=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},Xt=t=>t?t.format(et):"",ut={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function jp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[c,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=Sp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(f,S)=>{a({page:f,rowsPerPage:parseInt(S,10)})},p=(f,S)=>{const A=new FormData;return S&&A.set("id",String(S)),A.set("name",f?.name??""),A.set("start_time",Xt(f?.start_time)),A.set("end_time",Xt(f?.end_time)),A.set("shift_start_from",Xt(f?.shift_start_from)),A.set("shift_start_to",Xt(f?.shift_start_to)),A.set("shift_end_from",Xt(f?.shift_end_from)),A.set("shift_end_to",Xt(f?.shift_end_to)),A},y=async f=>{try{const S=p(f);await v(xt(xa.add,S,t),rt(S)),_.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to add shift.",{duration:1e3})}},h=f=>{x(f??null),o.setFieldsValue({name:f?.shift_name??f?.name??"",start_time:Qt(f?.start_time),end_time:Qt(f?.end_time),shift_start_from:Qt(f?.shift_start_from),shift_start_to:Qt(f?.shift_start_to),shift_end_from:Qt(f?.shift_end_from),shift_end_to:Qt(f?.shift_end_to)}),d(!0)},R=()=>{d(!1),x(null),o.resetFields()},I=async f=>{const S=c?.id??c?.shift_id;if(!S){_.error("Missing shift id.",{duration:1e3});return}try{const A=p(f,S);await Et(xa.edit,A,t),await v(),_.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),R()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update shift.",{duration:1e3})}},D=async f=>{const S=f?.id??f?.shift_id;if(S)try{await v(Bn(xa.remove,S,t),Qe(S)),_.success("Success! Deleted shift.",{duration:1e3})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete shift.",{duration:1e3})}},C=i.useMemo(()=>[{title:"Name",dataIndex:"shift_name",key:"shift_name",ellipsis:!0,fixed:"left",width:160},{title:"Start Time",dataIndex:"start_time",key:"start_time",width:120},{title:"End Time",dataIndex:"end_time",key:"end_time",width:120},{title:"Start From",dataIndex:"shift_start_from",key:"shift_start_from",width:120,responsive:["md"]},{title:"Start To",dataIndex:"shift_start_to",key:"shift_start_to",width:120,responsive:["md"]},{title:"End From",dataIndex:"shift_end_from",key:"shift_end_from",width:120,responsive:["md"]},{title:"End To",dataIndex:"shift_end_to",key:"shift_end_to",width:120,responsive:["md"]},{title:"Action",key:"action",width:110,fixed:"right",render:(f,S)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>h(S)}),e.jsx(r.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>D(S),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]),g=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Shift",onCancel:R,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,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(r.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(r.Form.Item,{name:"start_time",label:"Start Time",rules:g,children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"end_time",label:"End Time",rules:g,children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:R,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(r.Form,{form:s,layout:"vertical",onFinish:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(r.Form.Item,{name:"start_time",label:"Start Time",rules:g,children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"end_time",label:"End Time",rules:g,children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(r.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(r.TimePicker,{format:et,use12Hours:!0,style:ut})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Le,{parentCallback:w,data:{newData:b,columns:C,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const vp=({token:t})=>e.jsx(jp,{token:t}),ei=Ae.attendance;function _p({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((s,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?.[s?.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?.[s?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${a}`))]},`${a}row`))})]})}):null}const wp=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Cp=t=>{const n=String(t??"").toLowerCase();return n==="present"?e.jsx(r.Tag,{color:"green",children:"Present"}):n==="absent"?e.jsx(r.Tag,{color:"red",children:"Absent"}):n==="leave"?e.jsx(r.Tag,{color:"orange",children:"Leave"}):e.jsx(r.Tag,{children:t??""})};function Ap({token:t}){const[n,a]=i.useState(ae()),[s,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${s?ei.dailyAttendanceMultipleShift:ei.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,s,l]),{isLoading:x,error:m,data:u}=G(t?[c,t]:null,([y,h])=>Q(y,h)),b=i.useMemo(()=>wp(u),[u]),v=i.useMemo(()=>s?u?.data?.data??u?.data??u??null:null,[u,s]),w=on.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),p=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(y,h,R)=>R+1},{title:"Name",key:"name",render:(y,h)=>`${h?.name??""} ${h?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(y,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[Cp(h?.attendance),h?.late_time?e.jsx(r.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(y,h)=>h?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(y,h)=>h?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(y,h)=>h?.late_time?e.jsx(r.Tag,{color:"red",children:h.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.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(r.DatePicker,{value:n,onChange:y=>y&&a(y),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(r.Switch,{checked:s,onChange:o})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",onClick:()=>d(y=>y+1)})})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(Z.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(vt,{})}),s?e.jsx(_p,{data:v}):e.jsx(r.Table,{bordered:!0,size:"small",loading:x,rowKey:(y,h)=>String(y?.id??y?.staff_id??h),columns:p,dataSource:b,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const Tp=({token:t})=>e.jsx(Ap,{token:t}),ti=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Ip=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 Rp({token:t,staffId:n}){const[a,s]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[x,m]=i.useState(""),[u,b]=i.useState(""),v=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),w=P=>{const L=Number(P??0),N=Number.isFinite(L)?L.toLocaleString("en-IN"):"0";return`${v?`${v} `:""}${N}`},p=i.useMemo(()=>n?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),y=i.useMemo(()=>n?`${Ae.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:h}=G(t&&p?[p,t]:null,([P,L])=>Q(P,L)),{data:R,isLoading:I,mutate:D}=G(t&&y?[y,t]:null,([P,L])=>Q(P,L)),C=i.useMemo(()=>ti(h)[0]??h?.data??h??null,[h]),g=i.useMemo(()=>ti(R),[R]),f=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:(P,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:(P,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:(P,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:(P,L)=>e.jsx("div",{style:{fontSize:11},children:gt(L?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(P,L)=>e.jsx("div",{style:{cursor:L?.status==="due"?"pointer":"default"},onClick:()=>{L?.status==="due"&&(l(L),s(!0))},children:ao(L?.status)})}],[]),S=i.useMemo(()=>[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"DD",label:"DD"},{value:"Bank",label:"Bank"},{value:"Internet Banking",label:"Internet Banking"},{value:"Cheque",label:"Cheque"}],[]),A=async()=>{if(!o)return;const P={...o,staff_id:n,payment_type:d?.value??"",notes:x,attchement:u};try{await Ye(Ae.payroll.generatePayslip,{arg:P},t),_.success("Success!",{duration:1e3}),s(!1),l(null),m(""),b(""),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(r.Card,{title:e.jsx(r.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(r.Table,{bordered:!0,size:"small",loading:I,rowKey:(P,L)=>String(P?.id??`${P?.month}-${L}`),columns:f,dataSource:g,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(r.Modal,{open:a,onCancel:()=>{s(!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:S,value:d,onChange:P=>c(P??S[0]),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Note"}),e.jsx(r.Input.TextArea,{rows:4,placeholder:"Note",value:x,onChange:P=>m(P.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(r.Upload,{maxCount:1,action:co(),headers:t?{Authorization:t}:void 0,onChange:P=>{if(P?.file?.status==="done"){const L=Ip(P?.file?.response);L&&b(L)}P?.file?.status==="removed"&&b("")},children:e.jsx(r.Button,{icon:e.jsx(Z.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(r.Button,{onClick:()=>s(!1),children:"Cancel"}),e.jsx(de,{type:"button",value:o?.Total_Payable_Amount?`Pay ${w(o.Total_Payable_Amount)}`:"Pay",onClick:A})]})]})})]})}function Dp({token:t,staffId:n}){const a=i.useMemo(()=>{if(n!=null&&String(n).trim()!=="")return n;if(typeof window>"u")return null;const s=new URLSearchParams(window.location.search).get("id");return s||null},[n]);return a?e.jsx(Rp,{token:t,staffId:a}):e.jsx(r.Card,{title:e.jsx(r.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 Mt({onAdd:t,onExport:n,onPrint:a,onDownload:s,onFilter:o,onRefresh:l,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(Z.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(Z.FileExcelOutlined,{}),onClick:n},{key:"print",title:"Print",icon:e.jsx(Z.PrinterOutlined,{}),onClick:a},{key:"download",title:"Download",icon:e.jsx(Z.DownloadOutlined,{}),onClick:s},{key:"filter",title:"Filter",icon:e.jsx(Z.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(Z.ReloadOutlined,{}),onClick:l}],[t,n,a,s,o,l]),x=i.useMemo(()=>{const m=Array.isArray(d)&&d.length?new Set(d):null;return m?c.filter(u=>m.has(u.key)):c},[c,d]);return e.jsx(r.Space,{size:8,children:x.map(m=>e.jsx(r.Tooltip,{title:m.title,children:e.jsx(r.Button,{type:"text",icon:m.icon,onClick:m.onClick,disabled:!m.onClick})},m.key))})}const $s=t=>t??localStorage.getItem("authToken")??"",jt={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"}},Dt=async(t,n)=>Q(t,$s(n)),Op=async(t,n,a)=>Ye(t,n,$s(a)),Pp=async(t,n,a)=>Rn(t,{arg:n},$s(a)),Dn=(t,n)=>{const a=new URLSearchParams;Object.entries(n??{}).forEach(([o,l])=>{l==null||l===""||a.set(o,String(l))});const s=t.includes("?")?"&":"?";return`${t}${s}${a.toString()}`},ni=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},kp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},mo=(t,n)=>{const a=t?.data?.data??t?.data??t??{},s=n?a?.[n]:a;return Array.isArray(s)?s:Array.isArray(a?.student)?a.student:Array.isArray(a?.staff)?a.staff:Array.isArray(a?.data)?a.data:[]},Ep=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],Mp=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)){Ep(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 s=String(a?.attendance_type??a?.attendence_type_id??"").toUpperCase();(s==="P"||s==="1")&&(n.present+=1),(s==="A"||s==="4")&&(n.absent+=1),(s==="L"||s==="3")&&(n.late+=1),(s==="LEAVE"||s==="2")&&(n.leave+=1)}),n},Ns=(t,n)=>{const{data:a,isLoading:s,error:o}=G(n&&t?[t,n]:null,([l,d])=>Dt(l,d));return{isLoading:s,error:o,data:a,options:i.useMemo(()=>kp(a),[a])}},Ma=t=>Ns(jt.dropdowns.classes,t),Fa=(t,n)=>{const a=t?`${jt.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return Ns(a,n)},Fp=t=>Ns(jt.dropdowns.sessions,t),Us=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||"-")},fo=(t,n,a)=>{const s=new Blob([t],{type:n}),o=URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=a,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},ai=t=>String(t??"").replace(/"/g,'""'),$p=({rows:t,columns:n,fileName:a})=>{const s=Array.isArray(n)?n:[],o=Array.isArray(t)?t:[],l=s.map(c=>`"${ai(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,x)=>s.map(m=>{const u=m?.dataIndex??m?.selector??m?.key,b=u==="sl"?x+1:c?.[u];return`"${ai(b)}"`}).join(",")).join(`
|
|
60
|
-
`);
|
|
61
|
-
`),"text/csv;charset=utf-8;",a)},Np=({value:t,fileName:n})=>{fo(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",n)};function yo({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(r.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 rn({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]),s=Math.max(...a.map(o=>o.value),1);return e.jsx(r.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/s*100}%`,height:"100%",background:o.color,borderRadius:999}})}),e.jsx("div",{style:{fontSize:12,fontWeight:600,textAlign:"right"},children:o.value})]},o.key))})})}function Up(){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(r.Space,{wrap:!0,size:[12,8],children:t.map(n=>e.jsxs(r.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:n.label}),n.node]},n.label))})}function Ot({items:t}){const n=Array.isArray(t)?t.filter(a=>a?.value):[];return n.length?e.jsx(r.Space,{wrap:!0,size:[8,8],children:n.map(a=>e.jsxs(r.Tag,{color:"blue",children:[a.label,": ",a.value]},a.label))}):null}function $a({title:t,subtitle:n,printRef:a,exportRows:s,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:x,chartContent:m,reportTitle:u,reportExtra:b,children:v,fileBaseName:w="attendance"}){const p=on.useReactToPrint({content:()=>a?.current});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{title:e.jsxs("div",{children:[e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:t}),n?e.jsx(r.Typography.Text,{type:"secondary",style:{display:"block",marginTop:4},children:n}):null]}),extra:e.jsx(Mt,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>$p({rows:s,columns:o,fileName:`${w}.csv`}),onPrint:p,onDownload:()=>Np({value:s,fileName:`${w}.json`}),onRefresh:l}),children:c}),e.jsx(yo,{summary:x}),m===!1?null:m||e.jsx(rn,{summary:x}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:u}),extra:b,children:v})]})}const Bp=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function Lp({rows:t,loading:n,sunday:a,holiday:s,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(m,u)=>{const b=(Array.isArray(t)?t:[]).map((v,w)=>(v?.student_session_id??v?.student_id??v?.id??w)===m?{...v,...u}:v);l?.(b)},x=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(m,u,b)=>b+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:(m,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(m,u,b)=>{const v=u?.student_session_id??u?.student_id??u?.id??b;return e.jsx(r.Select,{size:"small",style:{width:"100%"},options:Bp,value:String(m??"1"),onChange:w=>c(v,{attendence_type_id:w})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:m=>m?ae(m).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:(m,u)=>e.jsx(r.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(Z.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"}):s?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(r.Table,{bordered:!0,size:"small",rowKey:(m,u)=>String(m?.student_session_id??m?.student_id??m?.id??u),columns:x,dataSource:Array.isArray(t)?t:[],loading:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function qp({rows:t,loading:n,sunday:a,holiday:s,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=>Us(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"}):s?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(r.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 zp({data:t,loading:n,onViewStudent:a}){const s=t?.data??t??{},o=Array.isArray(s?.studentAttendance)?s.studentAttendance:Array.isArray(s)?s:[],l=Array.isArray(s?.monthly_holiday)?s.monthly_holiday:[],d=Array.isArray(s?.dateSun)?s.dateSun:[],c=Number(s?.totalDaysMonth??0),x=i.useMemo(()=>{const m=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,b)=>e.jsx(r.Button,{type:"link",style:{padding:0},onClick:()=>a?.(b),children:b?.student_name??b?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{m.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(b,v)=>{const p=v?.[`${v?.student_id}_${o.indexOf(v)}`]?.[u]??{},y=p?.attendance_date,h=l.find(R=>R?.date===y);return d.includes(y)?jr("sunday","W"):h?jr("holiday","H"):Us(p?.attendence_type_id)}})}),m.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,b)=>{let v=0,w=0,p=0;return[...new Array(c).keys()].forEach(y=>{const h=b?.[`${b?.student_id}_${o.indexOf(b)}`]?.[y]??{},R=String(h?.attendence_type_id??"");R==="1"&&(v+=1),R==="4"&&(w+=1),R==="3"&&(p+=1)}),e.jsxs("span",{children:["P: ",v," A: ",w," L: ",p]})}}),m},[l,a,o,d,c]);return e.jsx(r.Table,{bordered:!0,size:"small",rowKey:(m,u)=>String(m?.student_id??u),columns:x,dataSource:o,loading:n,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(r.Empty,{description:"No monthly report found"})}})}function Yp({open:t,onClose:n,loading:a,data:s,studentName:o}){const l=Array.isArray(s?.data?.report)?s.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)=>Us(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(r.Modal,{open:t,onCancel:n,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(r.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 Vp({open:t,onClose:n,onSubmit:a,loading:s}){const[o,l]=r.Modal.useModal(),[d,c]=i.useState(null),[x,m]=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),m("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(r.Modal,{title:"Emergency Leave",open:t,onCancel:n,onOk:u,confirmLoading:s,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(r.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(r.Input.TextArea,{rows:4,value:x,onChange:b=>m(b.target.value)})]})]})})]})}const ho=t=>Mp(t),si=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n.reduce((a,s)=>({present:a.present+Number(s?.present??s?.Present??s?.total_present??0),absent:a.absent+Number(s?.absent??s?.Absent??s?.total_absent??0),late:a.late+Number(s?.late??s?.Late??0),leave:a.leave+Number(s?.leave??s?.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 Wp({token:t}){const{data:n}=G(t?[jt.dashboard.monthlyGraph,t]:null,([l,d])=>Dt(l,d)),{data:a}=G(t?[jt.dashboard.weeklyGraph,t]:null,([l,d])=>Dt(l,d)),s=i.useMemo(()=>si(n),[n]),o=i.useMemo(()=>si(a),[a]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(r.Card,{children:[e.jsx(r.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(r.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(yo,{summary:s}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(rn,{summary:s,title:"Monthly Attendance Chart"}),e.jsx(rn,{summary:o,title:"Weekly Attendance Chart"})]})]})}const ds=jt.studentAttendance,Hp={width:"100%",height:40};function Kp({token:t}){const n=i.useRef(null),[a,s]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(""),[p,y]=i.useState(ae()),[h,R]=i.useState(0),[I,D]=i.useState([]),[C,g]=i.useState(!1),[f,S]=i.useState(null),[A,P]=i.useState(!1),[L,N]=i.useState(!1),j=Ma(t),M=Fa(a,t),k=i.useMemo(()=>!a||!d||h===0?null:Dn(ds.list,{cID:a,sID:d,batch_id:u,date:p.format("YYYY-MM-DD")}),[u,a,p,h,d]),{data:$,isLoading:E,mutate:B}=G(t&&k?[k,t]:null,([V,X])=>Dt(V,X));i.useEffect(()=>{D(mo($,"student"))},[$]);const Y=$?.data?.data??$?.data??$??{},q=!!Y?.sunday,O=!!Y?.holiday?.holiday,T=Y?.holiday?.title??"",F=i.useMemo(()=>ho(I),[I]),U=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"}],[]),z=async()=>{if(I.length)try{N(!0),await Op(ds.save,{attendenceData:I,date:p.format("YYYY-MM-DD"),holiday:C?"YES":"NO"},t),_.success("Student attendance saved."),B?.()}catch(V){_.error(V?.message??"Failed to save attendance.")}finally{N(!1)}},ne=async({outtime:V,message:X})=>{if(f?.attendence_id)try{P(!0),await Pp(ds.emergencyLeave,{outtime:V,message:X,id:f.attendence_id},t),_.success("Emergency leave updated."),S(null),B?.()}catch(se){_.error(se?.message??"Failed to update emergency leave.")}finally{P(!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:j.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:V=>{s(V?.value??""),l(V?.label??""),c(""),m(""),b(""),w("")},required:!0}),e.jsx(ee,{options:M.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:V=>{c(V?.value??""),m(V?.label??""),b(""),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(r.DatePicker,{value:p,onChange:V=>V&&y(V),style:Hp,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>R(V=>V+1)})})]}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:p.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{}),e.jsx($a,{title:"Student Attendance",printRef:n,exportRows:I,exportColumns:U,onRefresh:()=>B?.(),filterSection:H,summary:F,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(r.Button,{size:"small",type:C?"primary":"default",onClick:()=>g(V=>!V),children:C?"Marked":"Mark As Holiday"}),e.jsx(r.Button,{size:"small",type:"primary",onClick:z,loading:L,disabled:!I.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(vt,{}),e.jsx(r.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(r.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:p.format("DD-MM-YYYY")}]})})]}),e.jsx(Lp,{rows:I,loading:E,sunday:q,holiday:O,holidayTitle:T,onChangeRows:D,onEmergency:S})]})}),e.jsx(Vp,{open:!!f,onClose:()=>S(null),onSubmit:ne,loading:A})]})}const Gp=jt.dailyAttendance,Jp={width:"100%",height:40};function Qp({token:t}){const n=i.useRef(null),[a,s]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(ae()),[p,y]=i.useState(0),h=Ma(t),R=Fa(a,t),I=i.useMemo(()=>!a||!d||p===0?null:Dn(Gp.list,{cID:a,sID:d,batch_id:u,date:v.format("YYYY-MM-DD")}),[u,a,v,p,d]),{data:D,isLoading:C,mutate:g}=G(t&&I?[I,t]:null,([k,$])=>Dt(k,$)),f=i.useMemo(()=>mo(D,"student"),[D]),S=D?.data?.data??D?.data??D??{},A=!!S?.sunday,P=!!S?.holiday?.holiday,L=S?.holiday?.title??"",N=i.useMemo(()=>ho(f),[f]),j=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:h.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:k=>{s(k?.value??""),l(k?.label??""),c(""),m(""),b(""),setBatchLabel("")},required:!0}),e.jsx(ee,{options:R.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:k=>{c(k?.value??""),m(k?.label??""),b(""),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(r.DatePicker,{value:v,onChange:k=>k&&w(k),style:Jp,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>y(k=>k+1)})})]}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:v.format("DD-MM-YYYY")}]})]});return e.jsx($a,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:n,exportRows:f,exportColumns:j,onRefresh:()=>g?.(),filterSection:M,summary:N,chartContent:e.jsx(rn,{summary:N,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(vt,{}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:v.format("DD-MM-YYYY")}]})]}),e.jsx(qp,{rows:f,loading:C,sunday:A,holiday:P,holidayTitle:L})]})})}const ri=jt.monthlyReport,Xp=t=>{const n=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],a=Number(t?.totalDaysMonth??0),s={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"&&(s.present+=1),x==="4"&&(s.absent+=1),x==="3"&&(s.late+=1),x==="2"&&(s.leave+=1)})}),s},Zp=t=>{const n=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],a=Number(t?.totalDaysMonth??0);return n.map((s,o)=>{let l=0,d=0,c=0;return[...new Array(a).keys()].forEach(x=>{const m=s?.[`${s?.student_id}_${o}`]?.[x]??{},u=String(m?.attendence_type_id??"");u==="1"&&(l+=1),u==="4"&&(d+=1),u==="3"&&(c+=1)}),{roll_no:s?.roll_no??"",student_name:s?.student_name??s?.full_name??"",present:l,absent:d,late:c}})};function em({token:t}){const n=i.useRef(null),[a,s]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(""),[p,y]=i.useState(String(new Date().getFullYear())),[h,R]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[I,D]=i.useState(0),[C,g]=i.useState(null),f=Ma(t),S=Fa(a,t),A=i.useMemo(()=>Es(Number(p)),[p]),P=i.useMemo(()=>ks(10),[]),L=i.useMemo(()=>!a||!d||!p||!h||I===0?null:Dn(ri.table,{session:ni(),class_id:a,section_id:d,year:p,month:h,batch_id:u}),[u,a,h,I,d,p]),{data:N,isLoading:j,mutate:M}=G(t&&L?[L,t]:null,([F,U])=>Dt(F,U)),k=N?.data?.data??N?.data??N??{},$=i.useMemo(()=>Xp(k),[k]),E=i.useMemo(()=>Zp(k),[k]),B=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"}],[]),Y=i.useMemo(()=>C?.student_id?Dn(ri.byStudent,{student_id:C.student_id,month:h,year:p,session:ni()}):null,[h,C,p]),{data:q,isLoading:O}=G(t&&Y?[Y,t]:null,([F,U])=>Dt(F,U)),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:f.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{s(F?.value??""),l(F?.label??""),c(""),m(""),b(""),w("")},required:!0}),e.jsx(ee,{options:S.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{c(F?.value??""),m(F?.label??""),b(""),w("")},required:!0},`section-${a}`),e.jsx(ee,{options:P,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:P.find(F=>String(F?.value)===String(p))??null,onChange:F=>y(String(F?.value??"")),required:!0}),e.jsx(ee,{options:A,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:A.find(F=>String(F?.value)===String(h))??null,onChange:F=>R(String(F?.value??"").padStart(2,"0")),required:!0},`month-${p}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>D(F=>F+1)})})]}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Month",value:A.find(F=>String(F?.value)===String(h))?.label??h},{label:"Year",value:p}]}),e.jsx(Up,{})]});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:B,onRefresh:()=>M?.(),filterSection:T,summary:$,chartContent:e.jsx(rn,{summary:$,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(vt,{}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Month",value:A.find(F=>String(F?.value)===String(h))?.label??h},{label:"Year",value:p}]})]}),e.jsx(zp,{data:k,loading:j,onViewStudent:g})]})}),e.jsx(Yp,{open:!!C,onClose:()=>g(null),loading:O,data:q,studentName:C?.student_name??C?.full_name})]})}const tm=jt.yearlyReport,nm=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:[]},am=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 sm({token:t}){const n=i.useRef(null),[a,s]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(""),[p,y]=i.useState(""),[h,R]=i.useState(""),[I,D]=i.useState(0),C=Ma(t),g=Fa(a,t),f=Fp(t),S=i.useMemo(()=>!a||!d||I===0?null:Dn(tm.table,{class_id:a,section_id:d,session_id:u,batch_id:p}),[p,a,I,d,u]),{data:A,isLoading:P,mutate:L}=G(t&&S?[S,t]:null,([E,B])=>Dt(E,B)),N=i.useMemo(()=>nm(A),[A]),j=i.useMemo(()=>am(N),[N]),M=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),k=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(E,B,Y)=>Y+1},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",dataIndex:"full_name",key:"full_name"},{title:"Total Present",dataIndex:"singleStudentPresentData",key:"singleStudentPresentData",width:130},{title:"Total Absent",dataIndex:"singleStudentAbsentData",key:"singleStudentAbsentData",width:130}],[]),$=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ee,{options:C.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{s(E?.value??""),l(E?.label??""),c(""),m(""),y(""),R("")},required:!0}),e.jsx(ee,{options:g.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{c(E?.value??""),m(E?.label??""),y(""),R("")},required:!0},`section-${a}`),e.jsx(ee,{options:f.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{b(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(Ot,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Session",value:v}]})]});return e.jsx($a,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:n,exportRows:N,exportColumns:M,onRefresh:()=>L?.(),filterSection:$,summary:j,chartContent:e.jsx(rn,{summary:j,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(vt,{}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Session",value:v}]})]}),e.jsx(r.Table,{bordered:!0,size:"small",rowKey:(E,B)=>String(E?.student_id??E?.id??B),columns:k,dataSource:N,loading:P,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}function rm(){return null}const Na=t=>t??localStorage.getItem("authToken")??"",im=(t,n)=>{const a=String(t??""),s=String(n);return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s},go=()=>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"}},om=()=>im(at(),we.uploadNotes),lm=async({baseUrl:t,page:n=1,perPage:a=10},s)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Na(s))},ft=async(t,n,a,{includeSession:s=!1}={})=>{const o=n instanceof FormData?n:new FormData;return s&&!o.has("session_id")&&o.append("session_id",go()),Ye(t,o,Na(a))},Pt=async(t,n,a,{includeSession:s=!1}={})=>{const o=n instanceof FormData?n:new FormData;return s&&!o.has("session_id")&&o.append("session_id",go()),pt(t,o,Na(a))},kt=async(t,n,a)=>st(t,n,Na(a)),ba=we.master.sections,Ln=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>G(s&&t?[t,n,a,s]:null,([l,d,c,x])=>lm({baseUrl:l,page:d,perPage:c},x)),dm=({token:t,page:n=1,perPage:a=10})=>Ln({token:t,baseUrl:ba.table,page:n,perPage:a}),cm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function um({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c]=r.Form.useForm(),{data:x,isLoading:m,mutate:u}=dm({token:t,page:n.page,perPage:n.perPage}),b=i.useMemo(()=>cm(x),[x]),v=i.useMemo(()=>x?.pagination?.total_rows??x?.pagination?.total??b.length??0,[x,b]),w=async I=>{I.preventDefault();const D=new FormData(I.target);try{await ft(ba.add,D,t),_.success("Success! Added new item.",{duration:1e3}),I.target.reset(),u()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},p=async I=>{try{await kt(ba.remove,I,t),_.success("Success! Deleted item.",{duration:1e3}),u()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to delete the item.",{duration:1500})}},y=I=>{d(I),o(!0),c.setFieldsValue({section:I?.section??""})},h=async I=>{const D=new FormData;D.append("id",String(l?.id??"")),D.append("section",I.section??"");try{await Pt(ba.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})}},R=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(I,D)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(D)}),e.jsx(r.Popconfirm,{title:"Delete this section?",onConfirm:()=>p(D?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Section",open:s,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(r.Form,{form:c,layout:"vertical",onFinish:h,children:[e.jsx(r.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(r.Input,{placeholder:"Section Name"})}),e.jsxs(r.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(r.Space,{}),children:e.jsx(r.Table,{rowKey:I=>I.id,columns:R,dataSource:b,loading:m,pagination:{current:n.page,pageSize:n.perPage,total:v,showSizeChanger:!0,onChange:(I,D)=>a({page:I,perPage:D})}})})]})}function pm({token:t}){return e.jsx(um,{token:t})}const Cn=we.master.classes,mm=({token:t,page:n=1,perPage:a=10})=>Ln({token:t,baseUrl:Cn.table,page:n,perPage:a}),fm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ym=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function hm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c]=r.Form.useForm(),[x]=r.Form.useForm(),{data:m}=G(t?[we.master.sections.list,t]:null,([A,P])=>Q(A,P)),u=i.useMemo(()=>ym(m),[m]),b=i.useMemo(()=>u.map(A=>({label:A.label??A.section??String(A.value??""),value:String(A.value??A.id??"")})),[u]),{data:v,isLoading:w,mutate:p}=mm({token:t,page:n.page,perPage:n.perPage}),y=i.useMemo(()=>fm(v),[v]),h=i.useMemo(()=>v?.pagination?.total_rows??v?.pagination?.total??y.length??0,[v,y]),{data:R}=G(t&&l?[`${Cn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([A,P])=>Q(A,P)),I=i.useMemo(()=>{const A=R?.data??R;return Array.isArray(A)?A:Array.isArray(A?.data)?A.data:A?[A]:[]},[R]),D=A=>{const P=A?.id??A?.class_id;P&&(d(P),o(!0))};i.useEffect(()=>{if(!s||!I.length)return;const A=I[0],P=I.map(j=>j?.section_id??j?.fk_sectionId??j?.sectionId??j?.section).filter(j=>j!=null&&String(j).trim()!=="").map(j=>String(j)),L=Array.isArray(A?.section_ids)?A.section_ids.map(j=>String(j)):typeof A?.section_ids=="string"?A.section_ids.split(",").map(j=>j.trim()).filter(Boolean):Array.isArray(A?.section)?A.section.map(j=>String(j)):[],N=P.length?P:L;x.setFieldsValue({name:A?.class??A?.name??"",section:N})},[s,I,x]);const C=async A=>{const P=new FormData;P.append("name",A.name??""),(A.section??[]).forEach(L=>P.append("section[]",String(L)));try{await ft(Cn.add,P,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},g=async A=>{const P=new FormData;P.append("id",String(l??"")),P.append("name",A.name??""),(A.section??[]).forEach(L=>P.append("section[]",String(L)));try{await Pt(Cn.edit,P,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to update the item.",{duration:1500})}},f=async A=>{try{await kt(Cn.remove,A,t),_.success("Success! Deleted item.",{duration:1e3}),p()}catch(P){_.error(P?.response?.data?.msg??P?.message??"Failed to delete the item.",{duration:1500})}},S=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(A,P)=>A??P?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:A=>A??""},{title:"Actions",key:"actions",width:120,render:(A,P)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(P)}),e.jsx(r.Popconfirm,{title:"Delete this class?",onConfirm:()=>f(P?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Class",open:s,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(r.Form,{form:x,layout:"vertical",onFinish:g,children:[e.jsx(r.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(r.Input,{placeholder:"Class"})}),e.jsx(r.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(r.Checkbox.Group,{options:b})}),e.jsxs(r.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(r.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(r.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(r.Input,{placeholder:"Class"})}),e.jsx(r.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(r.Checkbox.Group,{options:b})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(r.Table,{rowKey:A=>A.id,columns:S,dataSource:y,loading:w,pagination:{current:n.page,pageSize:n.perPage,total:h,showSizeChanger:!0,onChange:(A,P)=>a({page:A,perPage:P})}})})]})}function gm({token:t}){return e.jsx(hm,{token:t})}const An=we.master.subjects,xm=({token:t,page:n=1,perPage:a=10})=>Ln({token:t,baseUrl:An.table,page:n,perPage:a}),bm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ii=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],oi=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function Sm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c]=r.Form.useForm(),[x]=r.Form.useForm(),{data:m,isLoading:u,mutate:b}=xm({token:t,page:n.page,perPage:n.perPage}),v=i.useMemo(()=>bm(m),[m]),w=i.useMemo(()=>m?.pagination?.total_rows??m?.pagination?.total??v.length??0,[m,v]),{data:p}=G(t&&l?[`${An.show}?id=${encodeURIComponent(String(l))}`,t]:null,([g,f])=>Q(g,f)),y=i.useMemo(()=>{const g=p?.data??p;return Array.isArray(g)?g[0]:g??null},[p]);i.useEffect(()=>{s&&y&&x.setFieldsValue({name:y?.name??"",subject_type:y?.subject_type??y?.type??"",type:"",subject_types:Array.isArray(y?.subject_types)?y.subject_types:typeof y?.subject_types=="string"?y.subject_types.split(",").map(g=>g.trim()).filter(Boolean):[],code:y?.code??""})},[s,y,x]);const h=async g=>{const f=g?.type??g?.subject_type??"",S={name:g?.name??"",subject_type:f,type:f,subject_types:Array.isArray(g?.subject_types)?g.subject_types:[],code:g?.code??""};try{await Ye(An.add,S,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),b()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},R=async g=>{const f=new FormData,S=g?.type??g?.subject_type??"";f.append("id",String(l??"")),f.append("name",g.name??""),f.append("subject_type",g.subject_type??""),f.append("subject_type",S),f.append("type",S),f.append("code",g.code??"");try{await Pt(An.edit,f,t),_.success("Success! Updated item.",{duration:1e3}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),b()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},I=async g=>{try{await kt(An.remove,g,t),_.success("Success! Deleted item.",{duration:1e3}),b()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},D=g=>{const f=g?.id;f&&(d(f),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:(g,f)=>{const S=[],A=f?.subject_types;Array.isArray(A)?A.forEach(M=>{const k=String(M??"").trim();k&&S.push(k)}):typeof A=="string"&&A.split(",").map(M=>M.trim()).filter(Boolean).forEach(M=>S.push(M));const P=["yes","1","true"].includes(String(f?.is_practical??"").toLowerCase()),L=["yes","1","true"].includes(String(f?.is_theory??"").toLowerCase());P&&S.push("Practical"),L&&S.push("Theory");const N=S.map(M=>String(M??"").trim()).filter(Boolean).map(M=>M.toLowerCase()==="practical"?"Practical":M.toLowerCase()==="theory"?"Theory":M),j=Array.from(new Set(N));return j.length?j.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(g,f)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(f)}),e.jsx(r.Popconfirm,{title:"Delete this subject?",onConfirm:()=>I(f?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Subject",open:s,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(r.Form,{form:x,layout:"vertical",onFinish:R,children:[e.jsx(r.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(J,{placeholder:"Subject Name"})}),e.jsx(r.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(r.Radio.Group,{options:oi})}),e.jsx(r.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(r.Checkbox.Group,{options:ii})}),e.jsx(r.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(J,{placeholder:"Subject Code"})}),e.jsxs(r.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(r.Form,{form:c,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(r.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(J,{placeholder:"Subject Name"})}),e.jsx(r.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(r.Radio.Group,{options:oi})}),e.jsx(r.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(r.Checkbox.Group,{options:ii})}),e.jsx(r.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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(r.Table,{rowKey:g=>g.id,columns:C,dataSource:v,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:w,showSizeChanger:!0,onChange:(g,f)=>a({page:g,perPage:f})}})})]})}function jm({token:t}){return e.jsx(Sm,{token:t})}const Tn=we.master.holidays,vm=({token:t,page:n=1,perPage:a=10})=>Ln({token:t,baseUrl:Tn.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:[]},na={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function wm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c]=r.Form.useForm(),[x]=r.Form.useForm(),{data:m,isLoading:u,mutate:b}=vm({token:t,page:n.page,perPage:n.perPage}),v=i.useMemo(()=>_m(m),[m]),w=i.useMemo(()=>m?.pagination?.total_rows??m?.pagination?.total??v.length??0,[m,v]),{data:p}=G(t&&l?[`${Tn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([g,f])=>Q(g,f)),y=i.useMemo(()=>{const g=p?.data??p;return Array.isArray(g)?g[0]:g??null},[p]);i.useEffect(()=>{s&&y&&x.setFieldsValue({title:y?.holiday_title??"",description:y?.holiday_description??"",from:y?.start_date?ae(y.start_date):null,to:y?.end_date?ae(y.end_date):null})},[s,y,x]);const h=async g=>{const f=new FormData;f.append("title",g.title??""),f.append("description",g.description??""),f.append("from",g.from?ae(g.from).format("YYYY-MM-DD"):""),f.append("to",g.to?ae(g.to).format("YYYY-MM-DD"):"");try{await ft(Tn.add,f,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),b()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to add the new item.",{duration:1500})}},R=async g=>{const f=new FormData;f.append("id",String(l??"")),f.append("title",g.title??""),f.append("description",g.description??""),f.append("from",g.from?ae(g.from).format("YYYY-MM-DD"):""),f.append("to",g.to?ae(g.to).format("YYYY-MM-DD"):"");try{await Pt(Tn.edit,f,t,{includeSession:!0}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),b()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update the item.",{duration:1500})}},I=async g=>{try{await kt(Tn.remove,g,t),_.success("Success! Deleted item.",{duration:1e3}),b()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},D=g=>{const f=g?.id;f&&(d(f),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:(g,f)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(f)}),e.jsx(r.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>I(f?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Holiday",open:s,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(r.Form,{form:x,layout:"vertical",onFinish:R,children:[e.jsx(r.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(J,{placeholder:"Holiday Title"})}),e.jsx(r.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(J,{placeholder:"Holiday Description"})}),e.jsx(r.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:na})}),e.jsx(r.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:na})}),e.jsxs(r.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(r.Form,{form:c,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(r.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(J,{placeholder:"Holiday Title"})}),e.jsx(r.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(Rt,{placeholder:"Holiday Description"})}),e.jsx(r.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:na})}),e.jsx(r.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:na})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(r.Table,{rowKey:g=>g.id,columns:C,dataSource:v,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:w,showSizeChanger:!0,onChange:(g,f)=>a({page:g,perPage:f})}})})]})}function Cm({token:t}){return e.jsx(wm,{token:t})}const Sa=we.assignSubjects,Am=({token:t,page:n=1,perPage:a=50})=>Ln({token:t,baseUrl:Sa.list,page:n,perPage:a}),li=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Tm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Im({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[s,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState(!1),[m,u]=i.useState(!1),[b,v]=i.useState(null),[w,p]=i.useState([]),{data:y}=G(t?[we.master.classes.dropdown,t]:null,([k,$])=>Q(k,$)),{data:h}=G(t?[we.master.subjects.dropdown,t]:null,([k,$])=>Q(k,$)),R=i.useMemo(()=>li(y),[y]),I=i.useMemo(()=>li(h),[h]),D=i.useMemo(()=>I.map(k=>({label:k.label??k.subject??String(k.value??""),value:k.value??k.id})),[I]),{data:C,isLoading:g,mutate:f}=Am({token:t,page:n.page,perPage:n.perPage}),S=i.useMemo(()=>Tm(C),[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??S.length??0,[C,S]),{data:P}=G(t&&b?[`${Sa.editByClass}?class_id=${encodeURIComponent(String(b))}`,t]:null,([k,$])=>Q(k,$));i.useEffect(()=>{if(!m)return;const k=P?.data??P,$=Array.isArray(k)?k:Array.isArray(k?.data)?k.data:[];p($.map(E=>E.subject_id).filter(Boolean))},[m,P]);const L=async k=>{if(k.preventDefault(),!s?.value){_.error("Please select class",{duration:1200});return}if(!l.length){_.error("Please select subjects",{duration:1200});return}const $=new FormData;$.append("class_id",String(s.value)),l.forEach(E=>$.append("subject[]",String(E)));try{x(!0),await Pt(Sa.assign,$,t),_.success("Success! Updated item.",{duration:1e3}),o(null),d([]),f()}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to update the item.",{duration:1500})}finally{x(!1)}},N=k=>{k&&(v(k),u(!0))},j=async()=>{if(!b)return;if(!w.length){_.error("Please select subjects",{duration:1200});return}const k=new FormData;k.append("class_id",String(b)),w.forEach($=>k.append("subject[]",String($)));try{await Pt(Sa.update,k,t),_.success("Success! Updated item.",{duration:1e3}),u(!1),v(null),f()}catch($){_.error($?.response?.data?.msg??$?.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:(k,$)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:($?.subject_name??k??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(k,$)=>e.jsx(r.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>N($?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Assigned Subjects",open:m,onClose:()=>{u(!1),v(null)},width:520,extra:e.jsxs(r.Space,{children:[e.jsx(r.Button,{onClick:()=>u(!1),children:"Cancel"}),e.jsx(r.Button,{type:"primary",onClick:j,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:R.find(k=>String(k.value)===String(b))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(r.Checkbox.Group,{options:D,value:w,onChange:p})]})]})}),e.jsx(r.Card,{title:e.jsx(r.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:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:s,onChange:k=>o(k??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(r.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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(r.Table,{rowKey:k=>k.id,columns:M,dataSource:S,loading:g,pagination:{current:n.page,pageSize:n.perPage,total:A,showSizeChanger:!0,onChange:(k,$)=>a({page:k,perPage:$})}})})]})}function Rm({token:t}){return e.jsx(Im,{token:t})}const Zt=we.assignByClass,xo=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[]},bn=t=>xo(t),Dm=t=>xo(t),Sn=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Om({token:t}){const[n,a]=i.useState(null),[s,o]=i.useState(null),[l,d]=i.useState(null),[c,x]=i.useState("No"),[m,u]=i.useState([]),[b,v]=i.useState([]),[w,p]=i.useState(null),[y,h]=i.useState(null),[R,I]=i.useState(!1),[D,C]=i.useState(""),{data:g}=G(t?[Zt.teacherDropdown,t]:null,([oe,W])=>Q(oe,W)),{data:f}=G(t?[we.master.classes.dropdown,t]:null,([oe,W])=>Q(oe,W)),{data:S}=G(t&&y?[y,t]:null,([oe,W])=>Q(oe,W)),{data:A}=G(t&&w?[w,t]:null,([oe,W])=>Q(oe,W)),P=i.useMemo(()=>bn(g),[g]),L=i.useMemo(()=>bn(f),[f]),N=i.useMemo(()=>bn(S),[S]),j=i.useMemo(()=>bn(A),[A]),{data:M}=G(t&&n&&s&&l?[`${Zt.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(n))}&class_id=${encodeURIComponent(String(s))}§ion_id=${encodeURIComponent(String(l))}`,t]:null,([oe,W])=>Q(oe,W)),k=M?.data??M??null;i.useEffect(()=>{k&&(u(Array.isArray(k?.subject_ids)?k.subject_ids:[]),x(k?.isClassTeacher||"No"),v([]))},[k]);const{data:$}=G(t?[Zt.classWithSection,t]:null,([oe,W])=>Q(oe,W)),E=i.useMemo(()=>bn($),[$]),[B,Y]=i.useState(null),[q,O]=i.useState({page:1,perPage:25});i.useEffect(()=>{B||E?.[0]&&Y(`${E[0].class_id}val${E[0].section_id}`)},[E,B]);const T=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),F=i.useMemo(()=>{if(!B)return null;const[oe,W]=String(B).split("val");if(!oe||!W)return null;const le=q.page??1,Ce=q.perPage??25;return`${Zt.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(le))}&per_page=${encodeURIComponent(String(Ce))}&session_id=${encodeURIComponent(String(T))}&class_id=${encodeURIComponent(String(oe))}§ion_id=${encodeURIComponent(String(W))}`},[B,q.page,q.perPage,T]),{data:U,isLoading:z,mutate:ne}=G(t&&F?[F,t]:null,([oe,W])=>Q(oe,W),{revalidateOnFocus:!1}),H=i.useMemo(()=>Dm(U),[U]),V=i.useMemo(()=>{const oe=U?.pagination??U?.data?.pagination??U?.data?.data?.pagination;return oe?.total_rows??oe?.total??H.length??0},[U,H]),X=async oe=>{if(oe.preventDefault(),C(""),!n||!s||!l){_.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(m)||m.length===0){C("error"),_.error("Please Select Subject",{duration:1200});return}const W=new FormData;W.append("teacher_id",String(n)),W.append("class_id",String(s)),W.append("section_id",String(l)),W.append("isClassTeacher",String(c??"No")),Sn(m).forEach(le=>W.append("subject_ids[]",String(le))),Sn(b).forEach(le=>W.append("delete_subject[]",String(le)));try{await ft(Zt.assignClassToTeacher,W,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),C(""),ne()}catch(le){_.error(le?.response?.data?.msg??le?.message??"Failed to add the new item.",{duration:1500})}},se=async oe=>{try{await kt(Zt.deleteTeacherSub,oe,t),_.success("Success! Deleted item.",{duration:1e3}),ne()}catch(W){_.error(W?.response?.data?.msg??W?.message??"Failed to delete the item.",{duration:1500})}},ue=oe=>{const W=Array.isArray(oe?.child)?oe.child:[],le=[{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,Pe)=>e.jsx(r.Popconfirm,{title:"Delete this subject?",onConfirm:()=>se(Pe?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(r.Table,{columns:le,bordered:!0,size:"small",dataSource:W,pagination:!1,rowKey:Ce=>Ce.id})})},ve=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(oe,W)=>e.jsxs("div",{children:[W.teacher_name,W.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],ie=i.useMemo(()=>(E??[]).map(oe=>({label:oe.label??`${oe.class_name??""} ${oe.section_name??""}`.trim(),key:`${oe.class_id}val${oe.section_id}`,children:e.jsx(r.Table,{size:"small",columns:ve,bordered:!0,dataSource:Array.isArray(H)?H:[],loading:z,rowKey:W=>W.id,expandable:{expandedRowRender:ue},pagination:{current:q.page,pageSize:q.perPage,total:V,showSizeChanger:!0,onChange:(W,le)=>O({page:W,perPage:le})}})})),[E,q.page,q.perPage,H,z,V]);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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:X,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:P.find(oe=>String(oe.value)===String(n))??null,onChange:oe=>a(oe?.value??null)}),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:L.find(oe=>String(oe.value)===String(s))??null,onChange:oe=>{const W=oe?.value??null;o(W),d(null),p(W?`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(W))}`:null),h(W?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(W))}`:null),I(le=>!le)}}),e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:N.find(oe=>String(oe.value)===String(l))??null,onChange:oe=>d(oe?.value??null)},`section_${R}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const oe=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(ee,{style:{width:"100%"},options:oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:oe.find(W=>String(W.value)===String(c??"No"))??oe[1],onChange:W=>x(W?.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:j,value:(j??[]).filter(oe=>Sn(m).some(W=>String(W)===String(oe.value))),onChange:(oe,W)=>{const Ce=(Array.isArray(oe)?oe:[]).map(Ee=>Ee?.value).filter(Ee=>Ee!=null&&Ee!=="");u(Ce);const Pe=Array.isArray(k?.subject_ids)?k.subject_ids.map(String):[],ke=W?.removedValue?.value,$e=W?.option?.value;(W?.action==="remove-value"||W?.action==="pop-value")&&ke!=null&&Pe.includes(String(ke))&&v(Ee=>Array.from(new Set([...Sn(Ee).map(String),String(ke)]))),W?.action==="select-option"&&$e!=null&&Pe.includes(String($e))&&v(Ee=>Sn(Ee).filter(We=>String(We)!==String($e)))}},`subjects_${R}`),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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(r.Tabs,{activeKey:B??void 0,onChange:oe=>{Y(oe),O(W=>({...W,page:1}))},items:ie,type:"card",size:"small"})})]})]})}function Pm({token:t}){return e.jsx(Om,{token:t})}const jn=we.timeGroup,km=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Tt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function aa(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 It(t){return t?ae(t).format("h:mm a"):""}function Em({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c]=r.Form.useForm(),[x]=r.Form.useForm(),m=`${jn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:u,isLoading:b,mutate:v}=G(t?[m,t]:null,([f,S])=>Q(f,S)),w=i.useMemo(()=>km(u),[u]),p=i.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??w.length??0,[u,w]),{data:y}=G(t&&l?[`${jn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,S])=>Q(f,S)),h=i.useMemo(()=>{const f=y?.data??y;return Array.isArray(f)?f[0]:f??null},[y]);i.useEffect(()=>{s&&h&&x.setFieldsValue({title:h?.title??"",start_time_from:aa(h?.start_time_from),start_time_to:aa(h?.start_time_to),end_time_from:aa(h?.end_time_from),end_time_to:aa(h?.end_time_to)})},[s,h,x]);const R=async f=>{const S=new FormData;S.append("title",f.title??""),S.append("start_time_from",It(f.start_time_from)),S.append("start_time_to",It(f.start_time_to)),S.append("end_time_from",It(f.end_time_from)),S.append("end_time_to",It(f.end_time_to));try{await ft(jn.add,S,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),v()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},I=async f=>{const S=new FormData;S.append("id",String(l??"")),S.append("title",f.title??""),S.append("start_time_from",It(f.start_time_from)),S.append("start_time_to",It(f.start_time_to)),S.append("end_time_from",It(f.end_time_from)),S.append("end_time_to",It(f.end_time_to));try{await Pt(jn.edit,S,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),v()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},D=async f=>{try{await kt(jn.remove,f,t),_.success("Success! Deleted item.",{duration:1e3}),v()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to delete the item.",{duration:1500})}},C=f=>{f?.id&&(d(f.id),o(!0))},g=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:(f,S)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>C(S)}),e.jsx(r.Popconfirm,{title:"Delete this time group?",onConfirm:()=>D(S?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Time Group",open:s,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(r.Form,{form:x,layout:"vertical",onFinish:I,children:[e.jsx(r.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(r.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:Tt})}),e.jsx(r.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:Tt})}),e.jsx(r.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:Tt})}),e.jsx(r.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:Tt})}),e.jsxs(r.Space,{children:[e.jsx(de,{type:"submit",value:"Submit",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(r.Form,{form:c,layout:"vertical",onFinish:R,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(r.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:Tt})}),e.jsx(r.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:Tt})}),e.jsx(r.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:Tt})}),e.jsx(r.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:Tt})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(r.Table,{rowKey:f=>f.id,columns:g,dataSource:w,loading:b,pagination:{current:n.page,pageSize:n.perPage,total:p,showSizeChanger:!0,onChange:(f,S)=>a({page:f,perPage:S})}})})]})}function Mm({token:t}){return e.jsx(Em,{token:t})}const vn=we.assignTimeGroup,Fm=we.timeGroup.dropdown,$m=we.master.classes.dropdown,di=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Nm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Um({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[s,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState(""),[m,u]=i.useState(""),[b,v]=i.useState(null),[w,p]=i.useState(!1),[y,h]=i.useState(!1),[R,I]=i.useState(null),[D,C]=i.useState([]),[g,f]=i.useState(""),[S,A]=i.useState(""),{data:P}=G(t?[Fm,t]:null,([H,V])=>Q(H,V)),{data:L}=G(t?[$m,t]:null,([H,V])=>Q(H,V)),N=i.useMemo(()=>di(P?.data??P),[P]),j=i.useMemo(()=>di(L),[L]),{data:M}=G(t&&b?[b,t]:null,([H,V])=>Q(H,V));i.useEffect(()=>{const H=Array.isArray(M?.data)?M.data.map(V=>V.fk_classId):[];H.length&&d(H)},[M]);const k=`${vn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:$,isLoading:E,mutate:B}=G(t?[k,t]:null,([H,V])=>Q(H,V)),Y=i.useMemo(()=>Nm($),[$]),q=i.useMemo(()=>$?.pagination?.total_rows??$?.pagination?.total??Y.length??0,[$,Y]),{data:O}=G(t&&R?[`${vn.show}?id=${encodeURIComponent(String(R))}`,t]:null,([H,V])=>Q(H,V)),T=O?.data??O??null;i.useEffect(()=>{if(!y||!T)return;const H=Array.isArray(T?.class_ids)?T.class_ids:[];C(H);const V=Array.isArray(N)?N.find(X=>String(X.value)===String(T?.timegroup_id)):null;V&&A(`${V.start_time_from} -> ${V.end_time_from}`)},[y,T,N]);const F=async H=>{if(H.preventDefault(),x(""),!s?.value){_.error("Select Time Group",{duration:1200});return}if(!l.length){x("error"),_.error("Please Select Classes",{duration:1200});return}const V=new FormData;V.append("timegroup_id",String(s.value)),l.forEach(X=>V.append("class_ids[]",String(X)));try{await ft(vn.assign,V,t),_.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),B()}catch(X){_.error(X?.response?.data?.msg??X?.message??"Failed to add the new item.",{duration:1500})}},U=async()=>{if(f(""),!R)return;if(!D.length){f("error"),_.error("Please Select Classes",{duration:1200});return}const H=new FormData;H.append("id",String(R)),H.append("timegroup_id",String(T?.timegroup_id??"")),D.forEach(V=>H.append("class_ids[]",String(V)));try{await Pt(vn.assign,H,t),_.success("Success! Updated item.",{duration:1e3}),h(!1),I(null),B()}catch(V){_.error(V?.response?.data?.msg??V?.message??"Failed to update the item.",{duration:1500})}},z=H=>{H&&(I(H),h(!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,V)=>V?.class_names?e.jsx(r.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>z(V?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Assigned Time Group",open:y,onClose:()=>{h(!1),I(null)},width:520,extra:e.jsxs(r.Space,{children:[e.jsx(r.Button,{onClick:()=>h(!1),children:"Cancel"}),e.jsx(r.Button,{type:"primary",onClick:U,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:Array.isArray(N)?N:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:N.find(H=>String(H.value)===String(T?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:S}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(r.Select,{mode:"multiple",style:{width:"100%"},status:g,value:D,placeholder:"Select Classes",onChange:H=>C(H),options:Array.isArray(j)?j:[]})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(ee,{options:Array.isArray(N)?N:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:s,onChange:H=>{o(H??null),d([]),x(""),H?.value?(v(`${vn.classIdByTimeGroup}?id=${encodeURIComponent(String(H.value))}`),u(`${H.start_time_from} -> ${H.end_time_from}`)):(v(null),u("")),p(V=>!V)}}),e.jsx("div",{style:{marginTop:6},children:m})]}),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(j)?j:[]},`class_${w}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(r.Table,{rowKey:H=>H.id,columns:ne,dataSource:Y,loading:E,pagination:{current:n.page,pageSize:n.perPage,total:q,showSizeChanger:!0,onChange:(H,V)=>a({page:H,perPage:V})}})})]})}function Bm({token:t}){return e.jsx(Um,{token:t})}const Cs=we.promoteStudents,Lm=({token:t})=>G(t?[Cs.sessionDropdown,t]:null,([n,a])=>Q(n,a)),sa=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[]},qm=(t,n)=>{const a=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,s=a?.total_rows??a?.total??a?.totalItems;return Number.isFinite(Number(s))?Number(s):n};function zm({token:t}){const[n]=r.Form.useForm(),[a,s]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[x,m]=i.useState(!1),[u,b]=i.useState([]),v=i.useMemo(()=>new Set(u),[u]),[w,p]=i.useState({}),[y,h]=i.useState({}),{data:R}=G(t?[we.master.classes.dropdown,t]:null,([U,z])=>Q(U,z)),I=i.useMemo(()=>sa(R),[R]),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,([U,z])=>Q(U,z)),g=i.useMemo(()=>sa(C),[C]),f=i.useMemo(()=>d.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:S}=G(t&&f?[f,t]:null,([U,z])=>Q(U,z),{revalidateOnFocus:!1}),A=i.useMemo(()=>sa(S),[S]),{data:P}=Lm({token:t}),L=i.useMemo(()=>sa(P),[P]),{trigger:N,data:j,isMutating:M}=Je(t?Cs.searchByClassSection:null,(U,{arg:z})=>Bt(U,{arg:z},t)),k=i.useMemo(()=>{const U=j?.data?.data??j?.data??j??[];return Array.isArray(U)?U:Array.isArray(U?.data)?U.data:[]},[j]),$=i.useMemo(()=>qm(j,k.length??0),[j,k.length]),E=i.useMemo(()=>{const U=new Map;return(Array.isArray(k)?k:[]).forEach(z=>{z?.id!==void 0&&z?.id!==null&&U.set(String(z.id),z)}),U},[k]),B=i.useCallback((U,z)=>{const ne=String(U);h(H=>({...H,[ne]:{...H?.[ne]??{},...z}}))},[]),Y=i.useCallback((U,z)=>{const ne=String(U),H=z==="Leave";p(V=>({...V,[ne]:H}))},[]),q=U=>{const z=U?.class_id?.value??U?.class_id??null,ne=U?.section_id?.value??U?.section_id??null;if(!z||!ne){_.error("Please select Class and Section",{duration:1200});return}s(H=>({...H,page:1})),l({classId:z,sectionId:ne}),b([]),p({}),h({})},O=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 U=u.map(V=>String(V)).map(V=>{const X=E.get(V)??{},se=!!w?.[V],ue=y?.[V]??{},ve=String(ue.current_result??"Pass");if(se){const W=String(ue.leave_date??"");return{student_id:V,current_result:ve,next_session_status:"Leave",leave_date:W}}const ie=String(ue.roll_no??X?.roll_no??""),oe=String(ue.section_id??"");return{student_id:V,roll_no:ie,section_id:oe,current_result:ve,next_session_status:"Continue"}});if(U.some(V=>V?.next_session_status==="Leave"&&!String(V?.leave_date??"").trim())){_.error("Leave date is required for Leave students.",{duration:1500});return}if(U.some(V=>V?.next_session_status==="Continue"&&!String(V?.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:U};try{const V=await pt(Cs.promote,H,t);if(V?.Status&&String(V.Status)!=="success")throw new Error(V?.msg||"Failed to update");_.success("Success! Updated.",{duration:1e3});const X=Number(V?.success_count??0)+Number(V?.leave_count??0),se=a.page===Math.ceil((Number($)||0)/a.perPage||1),ue=X>0&&X===k.length&&k.length===u.length,ve=se&&ue&&a.page>1?a.page-1:a.page;s(ie=>({...ie,page:ve})),N?.({cID:o.classId,sID:o.sectionId,page:ve,per_page:a.perPage}),b([]),p({}),h({})}catch(V){_.error(V?.response?.data?.msg??V?.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:(U,z)=>{const ne=String(z?.id??""),H=v.has(ne),V=!!w?.[ne],se=(y?.[ne]??{}).roll_no??(V?"":z?.roll_no??"");return e.jsx(r.Input,{value:H?se:z?.roll_no,style:H?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!H||V,onChange:ue=>B(ne,{roll_no:ue.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(U,z)=>`${z?.firstname??""} ${z?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(U,z)=>{const ne=String(z?.id??""),H=v.has(ne),V=!!w?.[ne],se=(y?.[ne]??{}).section_id??"",ue=Array.isArray(A)?A:[];return e.jsx(r.Select,{options:ue,placeholder:H&&!V?"Select Section":"Section",disabled:!H||V,value:H&&!V&&se||void 0,style:{width:"100%"},onChange:ve=>B(ne,{section_id:ve})},`section_${ne}_${x}_${V?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(U,z)=>{const ne=String(z?.id??""),H=v.has(ne),V=y?.[ne]??{},X=String(V.current_result??"Pass");return e.jsxs(r.Radio.Group,{value:X,disabled:!H,buttonStyle:"solid",onChange:se=>B(ne,{current_result:se.target.value}),children:[e.jsx(r.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(r.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(U,z)=>{const ne=String(z?.id??""),H=v.has(ne),V=!!w?.[ne],X=y?.[ne]??{},se=String(X.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(r.Radio.Group,{value:V?"Leave":"Continue",disabled:!H,buttonStyle:"solid",onChange:ue=>Y(ne,ue.target.value),children:[e.jsx(r.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(r.Radio.Button,{value:"Leave",children:"Leave"})]}),H&&V&&e.jsx(r.DatePicker,{style:{width:"100%"},value:se?ae(se):null,onChange:ue=>B(ne,{leave_date:ue?ue.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[Y,w,y,v,x,A,B]),F=i.useMemo(()=>({selectedRowKeys:u,onChange:U=>b((Array.isArray(U)?U:[]).map(z=>String(z)))}),[u]);return i.useEffect(()=>{!o.classId||!o.sectionId||N&&N({cID:o.classId,sID:o.sectionId,page:a.page,per_page:a.perPage})},[a.page,a.perPage,N,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(r.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(r.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:U=>U,children:e.jsx(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{const z=U?.value??null;n.setFieldValue("section_id",null),l({classId:z,sectionId:null})}})}),e.jsx(r.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:U=>U,children:e.jsx(ee,{options:g,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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Mt,{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(r.Typography.Text,{children:["Selected: ",u.length]}),e.jsx(r.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(U=>String(U.value)===String(d.sessionId))??null,onChange:U=>c(z=>({...z,sessionId:U?.value??null}))}),e.jsx(ee,{label:"Class",options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:I.find(U=>String(U.value)===String(d.classId))??null,onChange:U=>{const z=U?.value??null;c(ne=>({...ne,classId:z})),m(ne=>!ne)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Save",color:"primary",onClick:O})})]}),e.jsx(r.Table,{rowKey:U=>String(U.id),rowSelection:F,columns:T,dataSource:k,loading:M,pagination:{current:a.page,pageSize:a.perPage,total:$,showSizeChanger:!0,onChange:(U,z)=>{s({page:U,perPage:z}),b([]),p({}),h({})}}})]})})]})}function Ym({token:t}){return e.jsx(zm,{token:t})}const en=we.coscholastic,Vm=({token:t})=>G(t?[en.table,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),Wm=({token:t})=>G(t?[en.categoryDropdown,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),ci=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 Hm({token:t}){const[n,a]=i.useState(""),[s,o]=i.useState(null),[l,d]=i.useState(null),c=i.useRef(null),{data:x}=G(t?[we.master.classes.dropdown,t]:null,([S,A])=>Q(S,A)),m=i.useMemo(()=>ci(x),[x]),{data:u,isLoading:b,mutate:v}=Vm({token:t}),w=i.useMemo(()=>{const S=u?.data?.data??u?.data??u??[];return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:[]},[u]),{data:p,mutate:y}=Wm({token:t}),h=i.useMemo(()=>ci(p),[p]),R=i.useMemo(()=>(Array.isArray(h)?h:[]).map(S=>({value:S?.value??S?.id,label:S?.label??S?.title??""})),[h]),I=async()=>{const S=String(n??"").trim();if(!S){_.error("Please enter category title",{duration:1200});return}try{await Ye(en.addCategory,{title:S},t),_.success("Success! Added category.",{duration:1e3}),a(""),y()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add category",{duration:1500})}},D=async S=>{try{await kt(en.deleteCategory,S,t),_.success("Success! Deleted category.",{duration:1e3}),y()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete category",{duration:1500})}},C=async S=>{if(S.preventDefault(),!s){_.error("Please select Category",{duration:1200});return}if(!l){_.error("Please select Class",{duration:1200});return}if(!S?.target?.skill?.value){_.error("Please enter Skill Name",{duration:1200});return}const P=new FormData(S.target);P.append("scholastic_catid",String(s)),P.append("class_id",String(l));try{await ft(en.addSkill,P,t),_.success("Success! Added new item.",{duration:1e3}),S.target.reset(),d(null),v()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},g=async S=>{try{await kt(en.deleteSkill,S,t),_.success("Success! Deleted item.",{duration:1e3}),v()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete the item.",{duration:1500})}},f=i.useMemo(()=>[{title:"Skill Category",dataIndex:"title",key:"title"},{title:"Class",dataIndex:"class",key:"class"},{title:"Skill Name",dataIndex:"skill",key:"skill"},{title:"Action",key:"action",width:90,render:(S,A)=>e.jsx(r.Popconfirm,{title:"Delete this skill?",onConfirm:()=>g(A?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Card,{title:e.jsx(r.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:R.find(S=>String(S.value)===String(s))??null,placeholder:"Select Category",onChange:S=>o(S?.value??null),options:R}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(J,{placeholder:"New category",ref:c,value:n,onChange:S=>a(S.target.value)}),e.jsx(r.Button,{type:"text",icon:e.jsx(Z.PlusOutlined,{}),onClick:I}),e.jsx(r.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{s&&(D(s),o(null))},children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{}),disabled:!s})})]})]}),e.jsx(ee,{label:"Class",options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:m.find(S=>String(S.value)===String(l))??null,onChange:S=>d(S?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Mt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(r.Table,{rowKey:S=>S.id,columns:f,dataSource:w,loading:b,pagination:!1})})]})}function Km({token:t}){return e.jsx(Hm,{token:t})}const Gm=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",bo=({token:t,value:n,onChange:a})=>{const s=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(r.Upload,{maxCount:1,action:om(),headers:s,onChange:o=>{if(o?.file?.status==="done"){const l=Gm(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},ui=we.notes,Jm=({token:t,url:n})=>G(t&&n?[n,t]:null,([a,s])=>Q(a,s),{revalidateOnFocus:!1}),ra=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[]},Qm=(t,n)=>{const a=String(t??""),s=String(n??"");return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s};function Xm({token:t}){const[n]=r.Form.useForm(),[a]=r.Form.useForm(),[s,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null,sectionId:null}),[c,x]=i.useState(!1),[m,u]=i.useState(""),{data:b}=G(t?[we.master.classes.dropdown,t]:null,([F,U])=>Q(F,U)),v=i.useMemo(()=>ra(b),[b]),w=i.useMemo(()=>l.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:p}=G(t&&w?[w,t]:null,([F,U])=>Q(F,U)),y=i.useMemo(()=>ra(p),[p]),h=i.useMemo(()=>!l.classId||!l.sectionId?null:`${ui.table}?class_id=${encodeURIComponent(String(l.classId))}§ion_id=${encodeURIComponent(String(l.sectionId))}&page=${encodeURIComponent(String(s.page))}&per_page=${encodeURIComponent(String(s.perPage))}`,[l.classId,l.sectionId,s.page,s.perPage]),{data:R,isLoading:I,mutate:D}=Jm({token:t,url:h}),C=i.useMemo(()=>{const F=R?.data?.data??R?.data??R??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},[R]),g=i.useMemo(()=>R?.pagination?.total_rows??R?.pagination?.total??C.length??0,[R,C.length]),[f,S]=i.useState(null),[A,P]=i.useState(null),[L,N]=i.useState(null),[j,M]=i.useState(!1),{data:k}=G(t&&L?[L,t]:null,([F,U])=>Q(F,U),{revalidateOnFocus:!1}),$=i.useMemo(()=>ra(k),[k]),{data:E}=G(t&&A?[A,t]:null,([F,U])=>Q(F,U)),B=i.useMemo(()=>ra(E),[E]),Y=F=>{const U=F?.class_id?.value??null,z=F?.section_id?.value??null;!U||!z||(o(ne=>({...ne,page:1})),d({classId:U,sectionId:z}))},q=()=>{u(""),x(!0),S(null),P(null),N(null),M(F=>!F),a.resetFields()},O=async F=>{const U=F?.class_id?.value??null,z=F?.section_id?.value??null,ne=F?.sub_id?.value??null,H=F?.status?.value??"publish",V=F?.title??"",X=F?.remark??"";if(!U||!z||!ne||!V||!X||!m){_.error("Please fill all fields",{duration:1200});return}const se=new FormData;se.append("class_id",String(U)),se.append("section_id",String(z)),se.append("sub_id",String(ne)),se.append("title",String(V)),se.append("remark",String(X)),se.append("status",String(H)),se.append("file",String(m));try{await ft(ui.add,se,t),_.success("Success! Added new item.",{duration:1e3}),x(!1),D()}catch(ue){_.error(ue?.response?.data?.msg??ue?.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:(F,U)=>{const z=String(U?.status??"").toLowerCase();return e.jsx(r.Tag,{color:z==="publish"?"green":"red",children:U?.status??"-"})}},{title:"File",key:"file",align:"center",render:(F,U)=>{const z=U?.file;if(!z)return"-";const ne=Qm(at(),`/student/note/${z}`);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(r.Modal,{title:"Add Note",open:c,onCancel:()=>x(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(r.Form,{form:a,layout:"vertical",onFinish:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:F=>F,children:e.jsx(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{const U=F?.value??null;S(U),a.setFieldValue("section_id",null),a.setFieldValue("sub_id",null),N(U?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(U))}`:null),P(U?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(U))}`:null),M(z=>!z)}},`class_${j}`)}),e.jsx(r.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:F=>F,children:e.jsx(ee,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${j}_${f??"none"}`)}),e.jsx(r.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:F=>F,children:e.jsx(ee,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${j}_${A??"none"}`)}),e.jsx(r.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(r.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(J,{placeholder:"Remark"})}),e.jsx(r.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:F=>F,children:e.jsx(ee,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(r.Form.Item,{label:"File",required:!0,children:e.jsx(bo,{token:t,value:m,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(r.Button,{type:"text",onClick:()=>x(!1),children:"Cancel"})]})]})})}),e.jsx(r.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Mt,{actions:["add","export","print","download","filter"],onAdd:q,onPrint:()=>window.print()})]}),children:e.jsx(r.Form,{form:n,layout:"vertical",onFinish:Y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:F=>F,children:e.jsx(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{const U=F?.value??null;n.setFieldValue("section_id",null),d({classId:U,sectionId:null})}})}),e.jsx(r.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:F=>F,children:e.jsx(ee,{options:y,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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(r.Table,{rowKey:F=>F.id,columns:T,dataSource:C,loading:I,pagination:{current:s.page,pageSize:s.perPage,total:g,showSizeChanger:!0,onChange:(F,U)=>o({page:F,perPage:U})}})})]})}function Zm({token:t}){return e.jsx(Xm,{token:t})}const ef=({token:t})=>G(t?[we.promoteStudents.sessionDropdown,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),pi=we.transferCertificate,cs=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[]},tf={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},nf=(t,n)=>t.inputtype==="Select"?null:t.inputtype==="date"?ae():"",mi=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}],fi=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 af({token:t,transferCertificateViewPath:n="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:a}){const[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState({page:1,perPage:10}),[c,x]=i.useState({classId:null,sectionId:null,sessionId:null}),[m,u]=i.useState(null),[b,v]=i.useState(!1),{data:w}=G(t?[we.master.classes.dropdown,t]:null,([T,F])=>Q(T,F)),p=i.useMemo(()=>cs(w),[w]),{data:y}=G(t&&m?[m,t]:null,([T,F])=>Q(T,F)),h=i.useMemo(()=>cs(y),[y]),{data:R}=ef({token:t}),I=i.useMemo(()=>cs(R),[R]),D=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${pi.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:g,mutate:f}=G(t&&D?[D,t]:null,([T,F])=>Q(T,F),{revalidateOnFocus:!1,onSuccess:T=>{const F=T?.data?.data??T?.data??[];Array.isArray(F)&&F[0]?.transefer_certificate_id&&k(String(F[0].transefer_certificate_id))}}),S=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??S.length??0,[C,S.length]),[P,L]=i.useState(!1),[N,j]=i.useState(null),[M,k]=i.useState("1"),$=T=>{j(T);const F=M==="1"?mi(T):fi(T),U={};F.forEach(z=>{U[z.name]=z.value??nf(z)}),o.setFieldsValue(U),L(!0)},E=async T=>{if(!T)return;if(typeof a=="function")return a(T);const F=`${n}?id=${encodeURIComponent(String(T))}`;window.location.href=F},B=T=>{const F=T?.class_id?.value??null,U=T?.section_id?.value??null,z=T?.session_id?.value??null;if(!F||!U||!z){_.error("Please select Class, Section and Session",{duration:1200});return}d(ne=>({...ne,page:1})),x({classId:F,sectionId:U,sessionId:z})},Y=async T=>{const F=new FormData;Object.entries(T??{}).forEach(([U,z])=>{if(z!=null){if(ae.isDayjs(z)){F.append(U,z.format("YYYY-MM-DD"));return}F.append(U,String(z))}});try{await ft(pi.addData,F,t),_.success("Success! Added new item.",{duration:1e3}),L(!1),j(null),f()}catch(U){_.error(U?.response?.data?.msg??U?.message??"Failed to add the new item.",{duration:1500})}},q=i.useMemo(()=>M==="1"?mi(N):fi(N),[M,N]),O=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,F)=>e.jsx(r.Button,{type:"text",icon:F?.transfer_certificate_data==="not_present"?e.jsx(Z.EyeOutlined,{}):e.jsx(Z.CheckOutlined,{}),onClick:()=>{F?.transfer_certificate_data==="not_present"?$(F?.id):E(F?.id)}})}],[M]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:"Transfer Certificate",open:P,onCancel:()=>L(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:Y,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:q.map(T=>T.inputtype==="hidden"?e.jsx(r.Form.Item,{name:T.name,initialValue:T.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},T.name):T.inputtype==="date"?e.jsx(r.Form.Item,{label:T.label,name:T.name,children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:tf})},T.name):T.inputtype==="radio"?e.jsx(r.Form.Item,{label:T.label,name:T.name,children:e.jsx(r.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},T.name):T.inputtype==="Select"?e.jsx(r.Form.Item,{label:T.label,name:T.name,getValueFromEvent:F=>F,children:e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},T.name):e.jsx(r.Form.Item,{label:T.label,name:T.name,children:e.jsx(J,{placeholder:T.label})},T.name))}),e.jsxs(r.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(de,{type:"submit",value:"Submit",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>L(!1),children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(r.Form,{form:s,layout:"vertical",onFinish:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:T=>T,children:e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:T=>{const F=T?.value??null;u(F?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(F))}`:null),v(U=>!U),s.setFieldValue("section_id",null)}})}),e.jsx(r.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:T=>T,children:e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${b}`)}),e.jsx(r.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:T=>T,children:e.jsx(ee,{options:I,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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Mt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(r.Table,{rowKey:T=>T.id,columns:O,dataSource:S,loading:g,pagination:{current:l.page,pageSize:l.perPage,total:A,showSizeChanger:!0,onChange:(T,F)=>d({page:T,perPage:F})}})})]})}function sf({token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a}){return e.jsx(af,{token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a})}const rf=({token:t,url:n})=>G(t&&n?[n,t]:null,([a,s])=>Q(a,s),{revalidateOnFocus:!1}),us=we.syllabus,yi=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},of=(t,n)=>{const a=String(t??""),s=String(n??"");return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s};function lf({token:t}){const[n]=r.Form.useForm(),[a]=r.Form.useForm(),[s,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null}),[c,x]=i.useState(!1),[m,u]=i.useState(null),[b,v]=i.useState(""),{data:w}=G(t?[we.master.classes.dropdown,t]:null,([E,B])=>Q(E,B)),p=i.useMemo(()=>yi(w),[w]),y=i.useMemo(()=>l.classId?`${us.table}?class_id=${encodeURIComponent(String(l.classId))}&page=${encodeURIComponent(String(s.page))}&per_page=${encodeURIComponent(String(s.perPage))}`:null,[l.classId,s.page,s.perPage]),{data:h,isLoading:R,mutate:I}=rf({token:t,url:y}),D=i.useMemo(()=>{const E=h?.data?.data??h?.data??h??[];return Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[]},[h]),C=i.useMemo(()=>h?.pagination?.total_rows??h?.pagination?.total??D.length??0,[h,D.length]),[g,f]=i.useState(null),[S,A]=i.useState(!1),{data:P}=G(t&&g?[g,t]:null,([E,B])=>Q(E,B),{revalidateOnFocus:!1}),L=i.useMemo(()=>yi(P),[P]),N=E=>{const B=E?.class_id?.value??null;B&&(o(Y=>({...Y,page:1})),d({classId:B}))},j=()=>{u(null),v(""),f(null),A(E=>!E),a.resetFields(),x(!0)},M=E=>{u(E),v(E?.attchement??"");const B=E?.class_id;f(B?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(B))}`:null),A(Y=>!Y),a.setFieldsValue({class_id:p.find(Y=>String(Y.value)===String(B))??null,sub_id:L.find(Y=>String(Y.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)},k=async E=>{const B=E?.class_id?.value??null,Y=E?.sub_id?.value??null,q=E?.title??"",O=E?.description??"";if(!B||!Y||!q||!O||!b){_.error("Please fill all fields",{duration:1200});return}const T=new FormData;T.append("class_id",String(B)),T.append("sub_id",String(Y)),T.append("title",String(q)),T.append("description",String(O)),T.append("file",String(b));try{m?.id?(T.append("id",String(m.id)),await ft(us.edit,T,t),_.success("Success! Updated item.",{duration:1e3})):(await ft(us.add,T,t),_.success("Success! Added new item.",{duration:1e3})),x(!1),u(null),I()}catch(F){_.error(F?.response?.data?.msg??F?.message??"Failed to save",{duration:1500})}},$=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Description",dataIndex:"description",key:"description",align:"center"},{title:"Subject",dataIndex:"subject_title",key:"subject_title",align:"center"},{title:"File",key:"file",align:"center",render:(E,B)=>{const Y=B?.attchement;if(!Y)return"-";const q=of(at(),`uploads/student/note/${Y}`);return e.jsx("a",{href:q,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(E,B)=>e.jsx(r.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>M(B)})}],[L,p]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:m?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{x(!1),u(null),v("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(r.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(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{const B=E?.value??null;a.setFieldValue("sub_id",null),f(B?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(B))}`:null),A(Y=>!Y)}},`class_${m?.id??"add"}_${S}`)}),e.jsx(r.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_${m?.id??"add"}_${S}_${g??"none"}`)}),e.jsx(r.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(r.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(Rt,{placeholder:"Description"})}),e.jsx(r.Form.Item,{label:"File",required:!0,children:e.jsx(bo,{token:t,value:b,onChange:v})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>x(!1),children:"Cancel"})]})]})})}),e.jsx(r.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Mt,{actions:["add","export","print","download","filter"],onAdd:j,onPrint:()=>window.print()})]}),children:e.jsx(r.Form,{form:n,layout:"vertical",onFinish:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:p,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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(r.Table,{rowKey:E=>E.id,columns:$,dataSource:D,loading:R,pagination:{current:s.page,pageSize:s.perPage,total:C,showSizeChanger:!0,onChange:(E,B)=>o({page:E,perPage:B})}})})]})}function df({token:t}){return e.jsx(lf,{token:t})}const Ua=we.timetable,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[]},gi=t=>{if(!t)return"";const n=ae(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},cf=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 s=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return s[a%s.length]},xi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],uf=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"};function pf({token:t}){const[n,a]=i.useState(null),[s,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(""),{data:b}=G(t?[we.master.classes.dropdown,t]:null,([f,S])=>Q(f,S)),v=i.useMemo(()=>hi(b),[b]),{data:w}=G(t&&n?[n,t]:null,([f,S])=>Q(f,S)),p=i.useMemo(()=>hi(w),[w]),{data:y,isLoading:h}=G(t&&l?[l,t]:null,([f,S])=>Q(f,S),{revalidateOnFocus:!1}),R=i.useMemo(()=>y?.days??y?.data?.days??y?.data?.data?.days??{},[y]),{dataSource:I,daySpanByFirstKey:D}=i.useMemo(()=>{const f=Object.entries(R||{}).slice().sort((P,L)=>xi.indexOf(String(P[0]).toLowerCase())-xi.indexOf(String(L[0]).toLowerCase())),S=new Map,A=[];for(const[P,L]of f){const N=(Array.isArray(L)?L:[]).slice().sort((M,k)=>Number(M?.order_no||0)-Number(k?.order_no||0)),j=N.length;for(let M=0;M<j;M+=1){const k=N[M],$=k?.id||`${P}-${k?.order_no}-${M}`;M===0&&S.set($,j),A.push({key:$,_dayKey:P,...k})}}return{dataSource:A,daySpanByFirstKey:S}},[R]),C=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(f,S)=>{const A=D.get(S.key);return A===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Z.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(r.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:uf(f)})]}),props:{rowSpan:A}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:f=>e.jsx(r.Tag,{color:"#5080f8",style:{fontWeight:500},children:f})},{title:"Time",key:"time",width:180,render:(f,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(r.Typography.Text,{children:[gi(S?.time_from)," - ",gi(S?.time_to)]})]})},{title:"Subject",key:"subject",render:(f,S)=>{if(String(S?.is_break)==="1")return e.jsx(r.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const P=S?.subject_name||"-";return e.jsx(r.Tag,{color:cf(P),style:{fontWeight:500},children:P})}},{title:"Teacher",key:"teacher",render:(f,S)=>{const A=String(S?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(r.Typography.Text,{children:A?"-":S?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(f,S)=>{const A=String(S?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(r.Typography.Text,{children:A?"-":S?.room_no||"-"})]})}}],[D]),g=f=>{f.preventDefault();const S=f.target.class_id?.value,A=f.target.section_id?.value;if(!S||!A)return;const P=v.find(M=>String(M.value)===String(S)),L=p.find(M=>String(M.value)===String(A));x(P?.label||""),u(L?.label||"");const j=`${Ua.byClassSection}/${S}/section/${A}`;d(j)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Mt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),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:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:f=>{a(`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(f?.value??""))}`),o(S=>!S)}}),e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${s}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:c||m?`Timetable: ${c} ${m}`:"Timetable"}),children:e.jsx(r.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:I,columns:C,rowKey:"key",loading:h,scroll:{x:"max-content"}})})]})}const mf=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[]},bi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],ff=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"},Si=t=>{if(!t)return"";const n=ae(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},yf=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 s=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return s[a%s.length]};function hf({token:t}){const[n,a]=i.useState(null),[s,o]=i.useState(null),{data:l}=G(t?[we.assignByClass.teacherDropdown,t]:null,([w,p])=>Q(w,p)),d=i.useMemo(()=>mf(l),[l]),{data:c,isLoading:x}=G(t&&s?[s,t]:null,([w,p])=>Q(w,p),{revalidateOnFocus:!1}),{dataSource:m,daySpanByFirstKey:u}=i.useMemo(()=>{const p=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((I,D)=>{const C=bi.indexOf(String(I?.day_name||"").toLowerCase()),g=bi.indexOf(String(D?.day_name||"").toLowerCase());if(C!==g)return C-g;const f=Number(I?.order_no||0),S=Number(D?.order_no||0);return f!==S?f-S:String(I?.time_from||"").localeCompare(String(D?.time_from||""))}),y=new Map,h=[];let R=0;for(;R<p.length;){const I=String(p[R]?.day_name||"").toLowerCase();let D=R;for(;D<p.length&&String(p[D]?.day_name||"").toLowerCase()===I;)D+=1;const C=D-R;for(let g=R;g<D;g+=1){const f=p[g],S=f?.id||`${I}-${f?.order_no}-${g}`;g===R&&y.set(S,C),h.push({key:S,_dayKey:I,...f})}R=D}return{dataSource:h,daySpanByFirstKey:y}},[c]),b=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(w,p)=>{const y=u.get(p.key);return y===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Z.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(r.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:ff(w)})]}),props:{rowSpan:y}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:w=>e.jsx(r.Tag,{color:"#5080f8",style:{fontWeight:500},children:w})},{title:"Time",key:"time",width:180,render:(w,p)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(r.Typography.Text,{children:[Si(p?.time_from)," - ",Si(p?.time_to)]})]})},{title:"Subject",key:"subject",render:(w,p)=>{if(String(p?.is_break)==="1")return e.jsx(r.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const h=p?.subject_name||"-";return e.jsx(r.Tag,{color:yf(h),style:{fontWeight:500},children:h})}},{title:"Class",key:"class",width:160,render:(w,p)=>e.jsxs(r.Tag,{color:"purple",style:{fontWeight:500},children:[p?.class_name||p?.class_id||"-"," ",p?.section_name?`(${p.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(w,p)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(r.Typography.Text,{children:p?.room_no||"-"})]})}],[u]),v=w=>{w.preventDefault();const p=w.target.teacher_id?.value;if(!p)return;a(p);const h=`${Ua.teacherTimetable}${encodeURIComponent(String(p))}`;o(h)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Mt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(r.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:m,columns:b,rowKey:"key",loading:x,scroll:{x:"max-content"}})})]})}function ji(t){if(!t)return null;const n=String(t).trim().replaceAll(".",":");if(!n)return null;const a=n.toLowerCase(),s=a.includes("am")||a.includes("pm");let o=0,l=0,d=0;if(s){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 m=x[4].toLowerCase();m==="pm"&&o<12&&(o+=12),m==="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 _n(t,n){const a=Number.parseInt(n,10);return!Number.isFinite(a)||a<=0||!t||!t.isValid?.()?null:t.add(a,"minute")}const ja=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[]},In={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},gf=t=>{const n=In[String(t)];return n?n.charAt(0).toUpperCase()+n.slice(1):String(t)},xf=({token:t,classId:n,sectionId:a,subjectId:s,value:o,onChange:l,disabled:d})=>{const c=t&&n&&a&&s?`${Ua.teachersBySubject}?subject_id=${encodeURIComponent(String(s))}&class_id=${encodeURIComponent(String(n))}§ion_id=${encodeURIComponent(String(a))}`:null,{data:x,isLoading:m}=G(c?[c,t]:null,([b,v])=>Q(b,v),{revalidateOnFocus:!1}),u=i.useMemo(()=>ja(x?.data??x).map(v=>({value:v?.value??v?.id,label:v?.label??v?.name??v?.teacher_name??""})),[x]);return e.jsx(r.Select,{placeholder:d?"-":"Select Teacher",loading:m,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:b=>l?.(b),showSearch:!0,optionFilterProp:"label"})};function bf({token:t}){const[n]=r.Form.useForm(),[a,s]=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,m]=i.useState(!1),u=i.useMemo(()=>t?we.master.classes.dropdown:null,[t]),{data:b}=G(u?[u,t]:null,([j,M])=>Q(j,M)),v=i.useMemo(()=>ja(b).map(j=>({value:j?.value??j?.id,label:j?.label??j?.title??""})),[b]),w=i.useMemo(()=>!t||!a.classId?null:`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:p}=G(w?[w,t]:null,([j,M])=>Q(j,M)),y=i.useMemo(()=>ja(p).map(j=>({value:j?.value??j?.id,label:j?.label??j?.title??""})),[p]),h=i.useMemo(()=>!t||!a.classId?null:`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:R}=G(h?[h,t]:null,([j,M])=>Q(j,M)),I=i.useMemo(()=>ja(R).map(j=>({value:j?.value??j?.id,label:j?.label??j?.title??""})),[R]),D=i.useMemo(()=>Array.isArray(d?.[a.dayKey])?d[a.dayKey]:[],[a.dayKey,d]),C=i.useCallback((j,M,k)=>{c($=>{const E={...$},B=Array.isArray(E[j])?E[j].slice():[];return B[M]={...B[M]??{},...k},E[j]=B,E})},[]),g=i.useCallback((j,M)=>{c(k=>{const $={...k},E=Array.isArray($[j])?$[j].slice():[];return E.splice(M,1),$[j]=E.map((B,Y)=>({...B,order_no:Y+1})),$})},[]),f=i.useCallback(j=>{c(M=>{const k={...M},$=Array.isArray(k[j])?k[j].slice():[];let E=null,B=null;const Y=$[$.length-1];if(Y?.time_to){const q=ji(Y.time_to),O=Number.parseInt(o.interval,10)||0,T=Number.parseInt(o.duration,10)||0,F=_n(q,O),U=T>0?_n(F,T):null;E=F?.isValid?.()?F.format("HH:mm:ss"):null,B=U?.isValid?.()?U.format("HH:mm:ss"):null}return $.push({order_no:$.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:E,time_to:B,is_break:!1}),k[j]=$,k})},[o.duration,o.interval,o.roomNo]),S=i.useCallback(()=>{const j=o.startTime,M=o.endTime,k=Number.parseInt(o.duration,10),$=Number.parseInt(o.interval,10);if(!j||!j.isValid?.()){_.error("Start time is required",{duration:1500});return}if(!M||!M.isValid?.()){_.error("End time is required",{duration:1500});return}if(!M.isAfter(j)){_.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(k)||k<=0){_.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite($)||$<0){_.error("Interval must be 0 or more",{duration:1500});return}const E=()=>{const B=[];let Y=j;for(let q=0;q<50;q+=1){const O=_n(Y,k);if(!O||!O.isValid?.()||O.isAfter(M))break;B.push({order_no:B.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:Y.format("HH:mm:ss"),time_to:O.format("HH:mm:ss"),is_break:!1});const T=_n(O,$);if(!T||!T.isValid?.()||T.isAfter(M)||T.isSame(M))break;Y=T}if(o.tiffinEnabled){const q=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),O=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),T=Math.min(q,B.length);if(T>0&&O>0){const F=B[T-1],U=F?.time_to?ji(F.time_to):null,z=U?_n(U,O):null;U?.isValid?.()&&z?.isValid?.()&&!z.isAfter(M)&&B.splice(T,0,{order_no:T+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:U.format("HH:mm:ss"),time_to:z.format("HH:mm:ss"),is_break:!0})}}return B.map((q,O)=>({...q,order_no:O+1}))};c(B=>{const Y={...B};return Object.keys(In).forEach(q=>{a.daysEnabled?.[q]&&(Y[q]=E())}),Y}),_.success("Generated schedule",{duration:1e3})},[o,a.daysEnabled]),A=i.useCallback(()=>{const j=localStorage.getItem("genrall_settings"),k=(j?JSON.parse(j):{})?.session_id??"1",$=a.classId,E=a.sectionId,B=Object.keys(In).map(Y=>{const q=(Array.isArray(d?.[Y])?d[Y]:[]).map((O,T)=>({order_no:T+1,subject_id:O?.is_break?0:O?.subject_id??null,teacher_id:O?.is_break?0:O?.teacher_id??null,room_no:O?.room_no??"",time_from:O?.time_from??null,time_to:O?.time_to??null,is_break:O?.is_break?1:0}));return{day:In[Y],class_id:$,section_id:E,session_id:k,args:q}});return{class_id:$,section_id:E,session_id:k,days:B}},[a.classId,a.sectionId,d]),P=i.useCallback(async()=>{if(!a.classId||!a.sectionId){_.error("Please select Class and Section",{duration:1500});return}const j=A(),M=Array.isArray(j?.days)?j.days:[];if(!M.some(E=>Array.isArray(E?.args)&&E.args.length>0)){_.error("No timetable rows to submit",{duration:1500});return}const $=E=>{const B=E?.is_break;return B===1||B==="1"||B===!0?!0:String(B??"").toLowerCase()==="true"};M.some(E=>(Array.isArray(E?.args)?E.args:[]).some(B=>String(B?.time_from??"").trim()&&String(B?.time_to??"").trim()?$(B)?!1:!String(B?.subject_id??"").trim()||!String(B?.teacher_id??"").trim():!0)),m(!0);try{const E=Ua.save,B=E==="api/timetable/save"?"timetable/save":null,Y=async T=>{const F=await Oa(T,j,t);if(F&&typeof F=="object")return F;throw new Error("No response from server")};let q;try{q=await Y(E)}catch{q=await Y(B)}const O=String(q?.msg??"");if(String(q?.Status)==="Success"){if(Array.isArray(q?.data)&&q.data.length===0&&O){_.error(O,{duration:3e3});return}_.success(O||"Weekly Time Table added successfully!",{duration:1200});return}_.error(O||"Failed to add time table",{duration:3e3})}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to add time table",{duration:3e3})}finally{m(!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:j=>j?ae(j,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:j=>j?ae(j,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(j,M,k)=>e.jsx(r.Switch,{checked:!!M?.is_break,onChange:$=>{C(a.dayKey,k,{is_break:$,subject_id:$?"":M?.subject_id??"",teacher_id:$?"":M?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(j,M,k)=>e.jsx(r.Select,{placeholder:M?.is_break?"-":"Select Subject",disabled:!!M?.is_break,style:{width:"100%"},options:I,value:M?.subject_id?String(M.subject_id):void 0,onChange:$=>C(a.dayKey,k,{subject_id:$,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(j,M,k)=>e.jsx(xf,{token:t,classId:a.classId,sectionId:a.sectionId,subjectId:M?.subject_id,disabled:!!M?.is_break||!M?.subject_id,value:M?.teacher_id,onChange:$=>C(a.dayKey,k,{teacher_id:$})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(j,M,k)=>e.jsx(r.Input,{value:M?.room_no??"",onChange:$=>C(a.dayKey,k,{room_no:$.target.value})})},{title:"Action",key:"action",width:90,render:(j,M,k)=>e.jsx(r.Popconfirm,{title:"Delete this row?",onConfirm:()=>g(a.dayKey,k),children:e.jsx(r.Button,{danger:!0,type:"text",children:"Delete"})})}],[a.classId,a.dayKey,a.sectionId,g,I,t,C]),N=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(r.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(r.Form.Item,{label:"Class",required:!0,children:e.jsx(r.Select,{placeholder:"Select Class",options:v,value:a.classId?String(a.classId):void 0,onChange:j=>{s(M=>({...M,classId:j,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(r.Form.Item,{label:"Section",required:!0,children:e.jsx(r.Select,{placeholder:"Select Section",options:y,value:a.sectionId?String(a.sectionId):void 0,onChange:j=>s(M=>({...M,sectionId:j})),disabled:!a.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(r.Form.Item,{label:"Start Time",required:!0,children:e.jsx(r.TimePicker,{value:o.startTime,onChange:j=>l(M=>({...M,startTime:j})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"End Time",required:!0,children:e.jsx(r.TimePicker,{value:o.endTime,onChange:j=>l(M=>({...M,endTime:j})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(r.InputNumber,{min:1,value:o.duration,onChange:j=>l(M=>({...M,duration:j})),style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"Interval (min)",children:e.jsx(r.InputNumber,{min:0,value:o.interval,onChange:j=>l(M=>({...M,interval:j})),style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"Room No",children:e.jsx(r.Input,{value:o.roomNo,onChange:j=>l(M=>({...M,roomNo:j.target.value}))})}),e.jsx(r.Form.Item,{label:"Tiffin Break",children:e.jsxs(r.Space,{children:[e.jsx(r.Switch,{checked:o.tiffinEnabled,onChange:j=>l(M=>({...M,tiffinEnabled:j}))}),e.jsx(r.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(r.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(r.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:j=>l(M=>({...M,tiffinAfterPeriod:j})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(r.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(r.InputNumber,{min:1,value:o.tiffinDuration,onChange:j=>l(M=>({...M,tiffinDuration:j})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(r.Button,{onClick:S,children:"Generate"}),e.jsx(r.Button,{type:"primary",loading:x,onClick:P,children:"Save"})]})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(r.Space,{children:[e.jsx(r.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(r.Select,{style:{width:160},value:a.dayKey,onChange:j=>s(M=>({...M,dayKey:j})),options:Object.keys(In).map(j=>({value:String(j),label:gf(j)}))}),e.jsx(r.Button,{onClick:()=>f(a.dayKey),children:"Add Row"})]}),children:e.jsx(r.Table,{rowKey:(j,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(r.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(r.Tabs,{type:"card",items:[{key:"create",label:"Create",children:N},{key:"routine",label:"Routine",children:e.jsx(pf,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(hf,{token:t})}]})]})}function Sf({token:t}){return e.jsx(bf,{token:t})}function jf(){return null}const zt=t=>t??localStorage.getItem("authToken")??"",Bs=(t,n)=>{const a=String(t??""),s=String(n??"");return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s},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"}},Ls=t=>Bs(at(),t),vf=()=>Bs(at(),"uploads"),So=t=>Bs(vf(),t),_f=async({baseUrl:t,page:n=1,perPage:a=10},s)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,zt(s))},wf=async(t,n)=>Q(t,zt(n)),qn=async(t,n,a)=>Ye(t,n,zt(a)),jo=async(t,n,a)=>pt(t,n,zt(a)),qs=async(t,n,a)=>st(t,n,zt(a)),Cf=async(t,n,a)=>Oa(t,{arg:n},zt(a)),vo=async(t,n,a)=>Rn(t,{arg:n},zt(a)),_o=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>G(s&&t?[t,n,a,s]:null,([l,d,c,x])=>_f({baseUrl:l,page:d,perPage:c},x)),dt=({url:t,token:n})=>G(n&&t?[t,n]:null,([s,o])=>wf(s,o)),Af={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function Tf({value:t,onChange:n,placeholder:a}){const[s,o]=i.useState(t??""),l=i.useMemo(()=>typeof t=="string"?t:s,[s,t]);return e.jsx("div",{style:Af,children:e.jsx(no,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),n?.(c)},style:{outline:"none",minHeight:280},placeholder:a})})}function Ft({title:t,actions:n,children:a,headerExtra:s}){return e.jsx("div",{style:{display:"grid",gap:20},children:a})}const If=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 zs({token:t,title:n,fetchUrl:a,saveUrl:s,fieldName:o,initialHtmlFieldName:l}){const d=i.useRef(null),c=dt({url:a,token:t}),m=i.useMemo(()=>If(c.data),[c.data])?.[l??o]??"",[u,b]=i.useState("");i.useEffect(()=>{b(typeof m=="string"?m:"")},[m]);const v=()=>b(typeof m=="string"?m:""),w=()=>{const h=new Blob([String(u??"")],{type:"text/html"}),R=URL.createObjectURL(h),I=document.createElement("a");I.href=R,I.download=`${String(n??"legal").toLowerCase().replaceAll(" ","-")}.html`,I.click(),URL.revokeObjectURL(R)},p=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:v},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:w,disabled:!u}],[u,m]),y=async h=>{h.preventDefault();try{(await vo(s,{[o]:u??""},t))?.Status==="Success"?_.success("Updated successfully.",{duration:1e3}):_.success("Updated.",{duration:1e3}),c.mutate?.()}catch(R){_.error(R?.response?.data?.msg??R?.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(Ft,{title:n,actions:p,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:y,children:[e.jsx(Tf,{value:u,onChange:b,placeholder:`Enter ${n} content...`}),e.jsx(r.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Update"})})]})})})]})}const Rf=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Df=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function tn({token:t,value:n,onChange:a,action:s,accept:o,maxCount:l=1,previewUrl:d}){const c=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),x=i.useMemo(()=>n?d||(Df(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(r.Upload,{maxCount:l,action:s,accept:o,headers:c,onChange:m=>{if(m?.file?.status==="removed"&&a?.(""),m?.file?.status==="done"){const u=Rf(m?.file?.response);u&&a?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})]})}const _t=ot.organization,wo=()=>Ls(_t.uploadLogo),ps=()=>Ls(_t.uploadSignature),Of=()=>Ls(_t.uploadFirebaseJson),Pf=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:[]:[],kf=({token:t})=>dt({url:_t.get,token:t}),Ef=({token:t})=>dt({url:_t.currencyDropdown,token:t}),Mf=({token:t})=>dt({url:_t.countryCodeDropdown,token:t}),Ff=({token:t})=>dt({url:_t.timezoneDropdown,token:t}),$f=({token:t})=>dt({url:_t.boardsDropdown,token:t}),ia=t=>Pf(t?.data),vi={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})),_i=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],wi=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],Uf=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},Bf=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,Lf=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function qf({token:t}){const n=i.useRef(null),a=kf({token:t}),s=Ef({token:t}),o=Mf({token:t}),l=Ff({token:t}),d=$f({token:t}),c=i.useMemo(()=>Uf(a.data),[a.data]),x=i.useMemo(()=>Bf(a.data),[a.data]),m=i.useMemo(()=>Lf(a.data),[a.data]),u=i.useMemo(()=>ia(s),[s.data]),b=i.useMemo(()=>ia(o),[o.data]),v=i.useMemo(()=>ia(l),[l.data]),w=i.useMemo(()=>ia(d),[d.data]),[p,y]=i.useState(null),[h,R]=i.useState(null),[I,D]=i.useState(null),[C,g]=i.useState(null),[f,S]=i.useState([]),[A,P]=i.useState("No"),[L,N]=i.useState("yes"),[j,M]=i.useState("no"),[k,$]=i.useState("Yes"),[E,B]=i.useState(""),[Y,q]=i.useState(""),[O,T]=i.useState(null),[F,U]=i.useState(null),[z,ne]=i.useState(null),[H,V]=i.useState(null),X=()=>{const W=(()=>{try{const le=c?.weekly_off;if(!le)return[];const Ce=Array.isArray(le)?le:JSON.parse(le);return Array.isArray(Ce)?Ce.filter(Boolean).map(Pe=>({value:Pe,label:Pe})):[]}catch{return[]}})();S(W),y(u.find(le=>le?.value===c?.currency)??null),R(b.find(le=>le?.value===c?.country_code)??null),D(v.find(le=>le?.value===c?.time_zone)??null),g(w.find(le=>le?.value===c?.affliated_board_id)??null),B(c?.logo??""),q(c?.json_file??""),P(c?.attendance_salary_calculation??"No"),N(c?.salary_period??"yes"),M(c?.multiple_shift??"no"),$(c?.readmission_charges??"Yes"),T(x?.in_from?ae(x.in_from,"h:mm A"):null),U(x?.in_to?ae(x.in_to,"h:mm A"):null),ne(x?.out_from?ae(x.out_from,"h:mm A"):null),V(x?.out_to?ae(x.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&X()},[c,u,b,v,w]);const se=()=>{n.current?.reset?.(),X()},ue=()=>{const W=new FormData(n.current??void 0),le=Object.fromEntries(W.entries());le.weekly_off_day=f.map($e=>$e?.value).filter(Boolean);const Ce=new Blob([JSON.stringify(le,null,2)],{type:"application/json"}),Pe=URL.createObjectURL(Ce),ke=document.createElement("a");ke.href=Pe,ke.download="organization-setting.json",ke.click(),URL.revokeObjectURL(Pe)},ve=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:se},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:ue,disabled:!c}],[c,f]),ie=async W=>{W.preventDefault();try{const le=new FormData(W.target);le.set("currency",p?.value??""),le.set("code",h?.value??""),le.set("time_zone",I?.value??""),le.set("affliated_board_id",C?.value??""),le.set("board_name",C?.label??""),le.set("attendance_salary_calculation",A),le.set("salary_period",L),le.set("multiple_shift",j),le.set("readmission_charges",k),f.forEach(ke=>{ke?.value&&le.append("weekly_off_day[]",ke.value)}),le.set("logo",E??""),le.set("json_file",Y??""),le.set("server_key",m?.server_key??""),le.set("in_time_start",O?ae(O).format("h:mm A"):""),le.set("in_time_end",F?ae(F).format("h:mm A"):""),le.set("out_time_start",z?ae(z).format("h:mm A"):""),le.set("out_time_end",H?ae(H).format("h:mm A"):""),await qn(_t.save,le,t);const Pe={...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:j??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(Pe)),_.success("Organization settings saved.",{duration:1e3}),a.mutate?.()}catch(le){_.error(le?.response?.data?.msg??le?.message??"Failed to save settings.",{duration:1500})}},oe=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(Ft,{title:"Organization",actions:ve,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:n,onSubmit:ie,children:[e.jsxs("div",{style:vi,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:p,onChange:W=>y(W)}),e.jsx("input",{type:"hidden",name:"currency",value:p?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Default Country Code*",options:b,value:h,onChange:W=>R(W)}),e.jsx("input",{type:"hidden",name:"code",value:h?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Time Zone*",options:v,value:I,onChange:W=>D(W)}),e.jsx("input",{type:"hidden",name:"time_zone",value:I?.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(r.Radio.Group,{options:_i,optionType:"button",buttonStyle:"solid",value:k,onChange:W=>$(W.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:k})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Weekly off Day",options:Nf,isMulti:!0,value:f,onChange:W=>S(W??[])}),f.map(W=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:W.value},W.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm A",value:O,onChange:W=>T(W),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:O?ae(O).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(r.TimePicker,{use12Hours:!0,format:"h:mm A",value:F,onChange:W=>U(W),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:F?ae(F).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time Start*"}),e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm A",value:z,onChange:W=>ne(W),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:z?ae(z).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(r.TimePicker,{use12Hours:!0,format:"h:mm A",value:H,onChange:W=>V(W),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(r.Radio.Group,{options:wi,optionType:"button",buttonStyle:"solid",value:L,onChange:W=>N(W.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(r.Radio.Group,{options:_i,optionType:"button",buttonStyle:"solid",value:A,onChange:W=>P(W.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(r.Radio.Group,{options:wi,optionType:"button",buttonStyle:"solid",value:j,onChange:W=>M(W.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:j})]}),oe?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(r.Divider,{}),e.jsxs("div",{style:vi,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(tn,{token:t,action:wo(),value:E,accept:"image/*",onChange:W=>B(W)}),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:W=>g(W)}),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(Rt,{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(tn,{token:t,action:Of(),value:Y,accept:".json",onChange:W=>q(W)}),e.jsx("input",{type:"hidden",name:"json_file",value:Y??""})]})]}),e.jsx(r.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function zf({token:t}){return e.jsx(qf,{token:t})}const va=ot.academicYear,Yf=({token:t,page:n=1,perPage:a=10})=>_o({baseUrl:va.table,token:t,page:n,perPage:a}),Vf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Wf=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:[],Hf=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function Kf({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(()=>{const f=ae(),S=ae().add(1,"year");return`${f.format("YYYY")}-${S.format("YYYY")}`}),[c,x]=i.useState(ae()),[m,u]=i.useState(ae().add(1,"year")),{isLoading:b,data:v,mutate:w}=Yf({token:t,page:n.page,perPage:n.rowsPerPage}),p=i.useMemo(()=>Wf(v),[v]),y=i.useMemo(()=>Hf(v,p.length),[v,p.length]),h=async()=>{if(!l){_.error("Session name is required.");return}if(m&&c&&ae(m).isBefore(c)){_.error("End date must be after start date.");return}try{const f=new FormData;f.set("name",l),f.set("start_date",c?ae(c).format("YYYY-MM-DD"):""),f.set("end_date",m?ae(m).format("YYYY-MM-DD"):""),await qn(va.add,f,t),_.success("Academic year added.",{duration:1e3}),o(!1),w?.()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add academic year.",{duration:1500})}},R=async f=>{try{const S=new FormData;S.set("session",String(f)),await jo(va.setActive,S,t);const A=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...A,session_id:String(f)})),_.success("Academic year activated.",{duration:1e3}),w?.()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to activate academic year.",{duration:1500})}},I=async f=>{try{await w(qs(va.remove,f,t)),_.success("Academic year deleted.",{duration:1e3})}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to delete academic year.",{duration:1500})}},D=()=>{const f=new Blob([JSON.stringify(p,null,2)],{type:"application/json"}),S=URL.createObjectURL(f),A=document.createElement("a");A.href=S,A.download="academic-years.json",A.click(),URL.revokeObjectURL(S)},C=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(Z.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:()=>w?.()},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:D,disabled:p.length===0}],[p.length,w]),g=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:(f,S)=>{const A=S.status==="Active";return e.jsxs("span",{children:[e.jsx(r.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."):R(S.id)},okText:"Yes",cancelText:"No",children:e.jsx(r.Switch,{checked:A})}),A&&e.jsx(r.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(f,S)=>e.jsx(r.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>I(S.id),okText:"Yes",cancelText:"No",children:e.jsx(r.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,p.length]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ft,{title:"Academic Year",actions:C,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(r.Table,{rowKey:"id",dataSource:p,columns:g,loading:b,pagination:{current:n.page,pageSize:n.rowsPerPage,total:y,showSizeChanger:!0,onChange:(f,S)=>a({page:f,rowsPerPage:Number(S)})}})})}),e.jsx(r.Modal,{open:s,onCancel:()=>o(!1),footer:null,title:"Add Academic Year",children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:Vf,children:[e.jsx(J,{label:"Session Name*",value:l,onChange:f=>d(f.target.value)}),e.jsxs("div",{children:[e.jsx(an,{Desplay:"Start Date*",value:c,onChange:f=>x(f),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?ae(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(an,{Desplay:"End Date*",value:m,onChange:f=>u(f),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:m?ae(m).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{value:"Submit",type:"button",onClick:h}),e.jsx(r.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function Gf({token:t}){return e.jsx(Kf,{token:t})}const Co=ot.feeReceiptSetting,Jf=({token:t})=>dt({url:Co.get,token:t}),ms={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},Qf=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=Jf({token:t}),s=i.useMemo(()=>Qf(a.data),[a.data]),[o,l]=i.useState(""),[d,c]=i.useState(!1),[x,m]=i.useState(!1),[u,b]=i.useState(!1),[v,w]=i.useState("0"),[p,y]=i.useState("0"),[h,R]=i.useState("0"),[I,D]=i.useState(!1),[C,g]=i.useState(!1),[f,S]=i.useState(""),[A,P]=i.useState(!1),L=()=>{l(s?.number_of_receipt??""),c(String(s?.roll_number??"0")==="1"),m(String(s?.address??"0")==="1"),b(String(s?.gardian_name??"0")==="1"),w(String(s?.authorized_signatory??"0")),y(String(s?.parent_signatory??"0")),R(String(s?.dynamic_qr_code_device??"0")),D(String(s?.sequence_payment??"0")==="1"),g(String(s?.previois_fees??"0")==="1"),S(s?.upfront_payment_months??"")};i.useEffect(()=>{s&&L()},[s]);const N=()=>{n.current?.reset?.(),L()},j=()=>{const $={number_of_receipt:o,rollnumber:d?1:0,address:x?1:0,gardianname:u?1:0,authorizedsignatory:v,parentsignatory:p,dynamic_qr_code_device:h,sequence_payment:I?1:0,previois_fees:C?1:0,upfront_payment_months:f},E=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),B=URL.createObjectURL(E),Y=document.createElement("a");Y.href=B,Y.download="fee-receipt-setting.json",Y.click(),URL.revokeObjectURL(B)},M=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:N},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:j,disabled:!s}],[s,o,d,x,u,v,p,h,I,C,f]),k=async $=>{$.preventDefault(),P(!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(v??"0")),E.set("parentsignatory",String(p??"0")),E.set("dynamic_qr_code_device",String(h??"0")),E.set("sequence_payment",I?"1":"0"),E.set("previois_fees",C?"1":"0"),E.set("upfront_payment_months",String(f??"")),await qn(Co.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{P(!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(Ft,{title:"Fee Receipt Setting",actions:M,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:n,onSubmit:k,children:[e.jsxs("div",{style:ms,children:[e.jsx(J,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:$=>l($.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(r.Checkbox,{checked:d,onChange:$=>c($.target.checked),children:"Show Roll Number in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Address"}),e.jsx(r.Checkbox,{checked:x,onChange:$=>m($.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(r.Checkbox,{checked:u,onChange:$=>b($.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(r.Divider,{}),e.jsxs("div",{style:ms,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(r.Radio.Group,{value:v,onChange:$=>w($.target.value),children:[e.jsx(r.Radio,{value:"1",children:"Enable"}),e.jsx(r.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(r.Radio.Group,{value:p,onChange:$=>y($.target.value),children:[e.jsx(r.Radio,{value:"1",children:"Enable"}),e.jsx(r.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(r.Radio.Group,{value:h,onChange:$=>R($.target.value),children:[e.jsx(r.Radio,{value:"1",children:"Enable"}),e.jsx(r.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(r.Divider,{}),e.jsxs("div",{style:ms,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(r.Checkbox,{checked:I,onChange:$=>D($.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(r.Checkbox,{checked:C,onChange:$=>g($.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:f,onChange:$=>S($.target.value)})]}),e.jsx(r.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:A?"Updating...":"Done",disabled:A})})]})})})]})}function Zf({token:t}){return e.jsx(Xf,{token:t})}const On=ot.marksheetSetting,ey=({token:t})=>dt({url:On.templateTypes,token:t}),ty=({token:t})=>dt({url:On.classDropdown,token:t}),ny=({token:t})=>dt({url:On.assignedTable,token:t}),ay={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},Ci=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:[]:[],sy=Array.from({length:12},(t,n)=>({value:String(n+1),label:`Design ${n+1}`})),ry=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function iy({token:t}){const n=i.useRef(null),a=ey({token:t}),s=ty({token:t}),o=ny({token:t}),l=i.useMemo(()=>Ci(a.data),[a.data]),d=i.useMemo(()=>Ci(s.data),[s.data]),c=i.useMemo(()=>ry(o.data),[o.data]),[x,m]=i.useState(null),[u,b]=i.useState(null),[v,w]=i.useState([]),p=()=>{n.current?.reset?.(),m(null),b(null),w([])},y=()=>{const C=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),g=URL.createObjectURL(C),f=document.createElement("a");f.href=g,f.download="marksheet-templates.json",f.click(),URL.revokeObjectURL(g)},h=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:p},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:y,disabled:c.length===0}],[c.length]),R=async C=>{if(C.preventDefault(),!x?.value){_.error("Select marksheet type.",{duration:1200});return}if(!u?.value){_.error("Select design.",{duration:1200});return}if(!v?.length){_.error("Select at least one class.",{duration:1200});return}try{const g=new FormData;g.set("temp_id",String(x.value)),g.set("ui_id",String(u.value)),v.forEach(f=>g.append("class_id[]",String(f))),await qn(On.assign,g,t),_.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),p()}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to assign template.",{duration:1500})}},I=async C=>{try{await qs(On.remove,C,t),_.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(g){_.error(g?.response?.data?.msg??g?.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,g)=>e.jsx(lt,{id:g?.id,funcName:I})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ft,{title:"Marksheet Setting",actions:h,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:n,onSubmit:R,children:[e.jsxs("div",{style:ay,children:[e.jsxs("div",{children:[e.jsx(ee,{label:"Select Marksheet Type",options:l,value:x,onChange:C=>m(C)}),e.jsx("input",{type:"hidden",name:"temp_id",value:x?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Select Design",options:sy,value:u,onChange:C=>b(C)}),e.jsx("input",{type:"hidden",name:"ui_id",value:u?.value??""})]})]}),e.jsx(r.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(r.Checkbox.Group,{options:d,value:v,onChange:C=>w(C)})]}),e.jsx(r.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(r.Table,{size:"small",rowKey:"id",columns:D,dataSource:c,pagination:!1})})]})})]})}function oy({token:t}){return e.jsx(iy,{token:t})}const fs={fetch:`${ot.legalPages.get}?page_name=terms`,save:ot.legalPages.termsSave,fieldName:"terms_data"};function ly({token:t}){return e.jsx(zs,{token:t,title:"Terms",fetchUrl:fs.fetch,saveUrl:fs.save,fieldName:fs.fieldName})}function dy({token:t}){return e.jsx(ly,{token:t})}const ys={fetch:`${ot.legalPages.get}?page_name=privacy`,save:ot.legalPages.privacySave,fieldName:"privacy_data"};function cy({token:t}){return e.jsx(zs,{token:t,title:"Privacy",fetchUrl:ys.fetch,saveUrl:ys.save,fieldName:ys.fieldName})}function uy({token:t}){return e.jsx(cy,{token:t})}const hs={fetch:`${ot.legalPages.get}?page_name=about_us`,save:ot.legalPages.aboutSave,fieldName:"about_data"};function py({token:t}){return e.jsx(zs,{token:t,title:"About",fetchUrl:hs.fetch,saveUrl:hs.save,fieldName:hs.fieldName})}function my({token:t}){return e.jsx(py,{token:t})}const Ys=ot.feesInfo,fy=({token:t})=>dt({url:Ys.get,token:t}),yy=({token:t})=>dt({url:Ys.statesDropdown,token:t}),gs={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},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,gy=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],xy=t=>t?So(`branch/logo/${t}`):"",xs=t=>t?So(`branch/signature/${t}`):"";function by({token:t}){const n=i.useRef(null),a=fy({token:t}),s=yy({token:t}),o=i.useMemo(()=>hy(a.data),[a.data]),l=i.useMemo(()=>gy(s.data),[s.data]),[d,c]=i.useState(null),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(""),[p,y]=i.useState(""),h=f=>{const S=new FormData(f),A=Object.fromEntries(S.entries());return A.state_id=d?.value??"",A.fees_receipt_logo=x,A.manager_signature=u,A.principal_signature=v,A.stamp=p,A},R=()=>{c(l.find(f=>String(f?.value)===String(o?.state_id??""))??null),m(o?.fees_receipt_logo??""),b(o?.manager_signature??""),w(o?.principal_signature??""),y(o?.stamp??"")};i.useEffect(()=>{o&&R()},[o,l]);const I=()=>{n.current?.reset?.(),R()},D=()=>{const f=h(n.current),S=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),A=URL.createObjectURL(S),P=document.createElement("a");P.href=A,P.download="fees-info.json",P.click(),URL.revokeObjectURL(A)},C=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:I},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:D,disabled:!o}],[o,d,x,u,v,p]),g=async f=>{f.preventDefault();try{const S=h(f.target);await Cf(Ys.save,S,t),_.success("Fees info saved.",{duration:1e3}),a.mutate?.()}catch(S){_.error(S?.response?.data?.msg??S?.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(Ft,{title:"Fees Info",actions:C,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:n,onSubmit:g,children:[e.jsxs("div",{style:gs,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(r.Divider,{}),e.jsxs("div",{style:gs,children:[e.jsx(Rt,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(Rt,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(r.Divider,{}),e.jsxs("div",{style:gs,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(tn,{token:t,action:wo(),value:x,previewUrl:xy(x),accept:"image/*",onChange:m}),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(tn,{token:t,action:ps(),value:u,previewUrl:xs(u),accept:"image/*",onChange:b}),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(tn,{token:t,action:ps(),value:v,previewUrl:xs(v),accept:"image/*",onChange:w}),e.jsx("input",{type:"hidden",name:"principal_signature",value:v})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(tn,{token:t,action:ps(),value:p,previewUrl:xs(p),accept:"image/*",onChange:y}),e.jsx("input",{type:"hidden",name:"stamp",value:p})]})]}),e.jsx(r.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})})})]})}function Sy({token:t}){return e.jsx(by,{token:t})}const _a=ot.payrollSettings,jy=({token:t,page:n=1,perPage:a=10})=>_o({baseUrl:_a.table,token:t,page:n,perPage:a}),vy={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},wn=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],bs=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],_y=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],wy=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function Cy({token:t}){const n=i.useRef(null),a=i.useRef(null),[s,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,x]=i.useState(null),[m,u]=i.useState(wn[0]),[b,v]=i.useState(null),[w,p]=i.useState(null),[y,h]=i.useState(null),R=jy({token:t,page:s.page,perPage:s.rowsPerPage}),I=i.useMemo(()=>_y(R.data),[R.data]),D=i.useMemo(()=>wy(R.data,I.length),[R.data,I.length]),C=async N=>{N.preventDefault();try{const j=new FormData(N.target);j.set("type",m?.value??""),j.set("amount_type",b?.value??""),await qn(_a.add,j,t),_.success("Payroll setting added.",{duration:1e3}),R.mutate?.(),N.target.reset(),v(null),u(wn[0])}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to add payroll setting.",{duration:1500})}},g=N=>{x(N),p(wn.find(j=>j.value===N?.type)??null),h(bs.find(j=>j.value===N?.amount_type)??null),d(!0)},f=async N=>{N.preventDefault();try{const j=new FormData(N.target);j.set("id",String(c?.id??"")),j.set("type",w?.value??""),j.set("amount_type",y?.value??""),await jo(_a.edit,j,t),_.success("Payroll setting updated.",{duration:1e3}),d(!1),R.mutate?.()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to update payroll setting.",{duration:1500})}},S=async N=>{try{await qs(_a.remove,N,t),_.success("Payroll setting deleted.",{duration:1e3}),R.mutate?.()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to delete payroll setting.",{duration:1500})}},A=()=>{const N=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),j=URL.createObjectURL(N),M=document.createElement("a");M.href=j,M.download="payroll-settings.json",M.click(),URL.revokeObjectURL(j)},P=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(Z.PlusOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:()=>R.mutate?.()},{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:A,disabled:I.length===0}],[I.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:(N,j)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(r.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>g(j)}),e.jsx(r.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>S(j.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ft,{title:"Payroll Settings",actions:P,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:n,onSubmit:C,children:[e.jsxs("div",{style:vy,children:[e.jsx(J,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(ee,{label:"Type",options:wn,value:m,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:m?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:bs,value:b,onChange:v}),e.jsx("input",{type:"hidden",name:"amount_type",value:b?.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(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(r.Table,{rowKey:"id",columns:L,dataSource:I,loading:R.isLoading,pagination:{current:s.page,pageSize:s.rowsPerPage,total:D,showSizeChanger:!0,onChange:(N,j)=>o({page:N,rowsPerPage:Number(j)})}})})]})}),e.jsx(r.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:a,onSubmit:f,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:wn,value:w,onChange:p}),e.jsx("input",{type:"hidden",name:"type",value:w?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:bs,value:y,onChange:h}),e.jsx("input",{type:"hidden",name:"amount_type",value:y?.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 Ay({token:t}){return e.jsx(Cy,{token:t})}const Ao=ot.paymentGateway,Ty=({token:t})=>dt({url:Ao.get,token:t}),Iy=[{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"]}],$t={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}},Ai=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 $t;try{const a=JSON.parse(n.data||"{}"),s=a?.data&&typeof a.data=="object"?a.data:a;return{Razorpay:{...$t.Razorpay,...s?.Razorpay??{}},PhonePe:{...$t.PhonePe,...s?.PhonePe??s?.PineLab??s?.PineLabs??{}},Paytm:{...$t.Paytm,...s?.Paytm??s?.HDFC??{}},SabPaisa:{...$t.SabPaisa,...s?.SabPaisa??{}}}}catch{return $t}};function Ry({token:t}){const n=i.useRef(null),a=Ty({token:t}),[s,o]=i.useState($t);i.useEffect(()=>{a.data&&o(Ai(a.data))},[a.data]);const l=(u,b,v)=>{o(w=>({...w,[u]:{...w[u],[b]:v}}))},d=()=>o(Ai(a.data)),c=()=>{const u=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),b=URL.createObjectURL(u),v=document.createElement("a");v.href=b,v.download="payment-gateway-settings.json",v.click(),URL.revokeObjectURL(b)},x=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:c}],[s,a.data]),m=async u=>{u.preventDefault();try{await vo(Ao.save,{data:s},t),_.success("Payment gateway settings saved.",{duration:1e3}),a.mutate?.()}catch(b){_.error(b?.response?.data?.msg??b?.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(Ft,{title:"Payment Gateway",actions:x,children:e.jsxs("form",{ref:n,onSubmit:m,style:{display:"grid",gap:20},children:[Iy.map(u=>{const b=s[u.id]??{};return e.jsx(r.Card,{title:e.jsx(r.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(r.Switch,{checked:!!b.isActive,onChange:v=>l(u.id,"isActive",v)})]}),e.jsx(r.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:u.fields.map(v=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:v}),e.jsx(r.Input,{value:b[v]??"",type:v.toLowerCase().includes("secret")||v.toLowerCase().includes("password")?"password":"text",onChange:w=>l(u.id,v,w.target.value)})]},v))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})})]})}function Dy({token:t}){return e.jsx(Ry,{token:t})}const Oy=({routes:t=[],onNavigate:n})=>e.jsx(r.Row,{gutter:[16,16],children:t.map((a,s)=>e.jsx(r.Col,{xs:24,md:8,lg:8,children:e.jsx(ye,{children:e.jsx(Ri,{icon:a?.icon??"",title:a?.title??"",path:a?.path??"",onClick:n})})},`${s}route001`))});exports.About=my;exports.AcademicYear=Gf;exports.Academics=rm;exports.AddBook=oc;exports.AddDriver=nc;exports.AddStaff=Au;exports.AdmissionEnquiry=Ed;exports.ApplyLeave=cp;exports.AprroveLeaveRequest=ap;exports.AssignByClass=Pm;exports.AssignStudentToTransport=tc;exports.AssignSubjects=Rm;exports.AssignTimeGroup=Bm;exports.AssignVehicles=zd;exports.AttendanceDashboard=Wp;exports.BookList=lc;exports.BuySellProduct=Wc;exports.Category=Mc;exports.Class=gm;exports.CoScholasticArea=Km;exports.CreateTimeGroup=Mm;exports.DailyAttendance=Qp;exports.Department=hp;exports.Designation=bp;exports.ErpDashboard=Ro;exports.FeeReceiptSetting=Zf;exports.FeesInfo=Sy;exports.GeneralSetting=jf;exports.Holidays=Cm;exports.IssueReturn=cc;exports.LeaveType=mp;exports.LibraryAssignStudent=uc;exports.LibraryCategory=pc;exports.LibraryReport=mc;exports.ManageStock=ru;exports.MarksheetSetting=oy;exports.MenuSubmenu=yd;exports.MonthlyReport=em;exports.Notes=Zm;exports.Organization=zf;exports.PaymentGateway=Dy;exports.Payroll=Xu;exports.PayrollReceiptDetails=Dp;exports.PayrollSettings=Ay;exports.Privacy=uy;exports.Products=Oc;exports.PromoteStudents=Ym;exports.RoutePage=Oy;exports.RouteTimeTable=ac;exports.Sections=pm;exports.SellReports=nu;exports.Shift=vp;exports.StaffAttendance=zu;exports.StaffAttendanceReport=Hu;exports.StaffDailyAttendance=Tp;exports.StaffDirectory=Ou;exports.StockReport=cu;exports.Stoppage=rc;exports.StudentAttendance=Kp;exports.SubCategory=Lc;exports.Subjects=jm;exports.Syllabus=df;exports.Terms=dy;exports.TimeTable=Sf;exports.TransferCertificate=sf;exports.TransportRoutes=Fd;exports.TransportVehicles=$d;exports.Unit=Jc;exports.Vendor=jc;exports.YearlyReport=sm;exports.setBaseUrl=pd;
|
|
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(`
|
|
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;
|