ubk.erp.webpack 1.1.1 → 1.1.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/README.md +91 -29
- package/dist/index.cjs +12 -12
- package/dist/index.d.ts +60 -0
- package/dist/index.js +9250 -5706
- 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"),o=require("antd"),X=require("swr"),l=require("react"),ze=require("swr/mutation"),ce=require("@ant-design/icons"),ye=require("dayjs"),gs=require("react-dom/server"),Vt=require("react-to-print"),A=require("react-hot-toast"),Ar=require("react-select"),Or=require("react-barcode"),xs=()=>e.jsxs(o.Card,{style:{borderRadius:16},children:[e.jsx(o.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(o.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),ne=({width:t,height:n,display:a,justifyContent:r,alignItems:s,flexDirection:i,gap:d,style:u,children:b,...h})=>{const p={width:t,height:n,display:a,justifyContent:r,alignItems:s,flexDirection:i,gap:d,...u};return e.jsx("div",{style:p,...h,children:b})},Re=({variant:t,fontWeight:n,style:a,children:r,...s})=>{const i=n==="bold"?700:n==="light"?300:n;return t==="h1"?e.jsx(o.Typography.Title,{level:1,style:{fontWeight:i,...a},...s,children:r}):t==="h2"?e.jsx(o.Typography.Title,{level:2,style:{fontWeight:i,...a},...s,children:r}):t==="h3"?e.jsx(o.Typography.Title,{level:3,style:{fontWeight:i,...a},...s,children:r}):t==="h4"?e.jsx(o.Typography.Title,{level:4,style:{fontWeight:i,...a},...s,children:r}):t==="h5"?e.jsx(o.Typography.Title,{level:5,style:{fontWeight:i,...a},...s,children:r}):e.jsx(o.Typography.Text,{style:{fontWeight:i,...a},...s,children:r})};function Pr({title:t="",icon:n="",path:a="",onClick:r}){const s=()=>{if(r){r(a);return}typeof window<"u"&&typeof a=="string"&&a.length>0&&window.location.assign(a)};return e.jsxs(o.Card,{hoverable:!0,onClick:s,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(ne,{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(ne,{style:{padding:"0 12px"},children:e.jsx(o.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(ne,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(Re,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function Ir(t,n){return function(){return t.apply(n,arguments)}}const{toString:bs}=Object.prototype,{getPrototypeOf:Rn}=Object,{iterator:Dn,toStringTag:Er}=Symbol,An=(t=>n=>{const a=bs.call(n);return t[a]||(t[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),it=t=>(t=t.toLowerCase(),n=>An(n)===t),On=t=>n=>typeof n===t,{isArray:It}=Array,Ot=On("undefined");function Yt(t){return t!==null&&!Ot(t)&&t.constructor!==null&&!Ot(t.constructor)&&Ve(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const kr=it("ArrayBuffer");function Ss(t){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(t):n=t&&t.buffer&&kr(t.buffer),n}const js=On("string"),Ve=On("function"),Mr=On("number"),Wt=t=>t!==null&&typeof t=="object",ws=t=>t===!0||t===!1,mn=t=>{if(An(t)!=="object")return!1;const n=Rn(t);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Er in t)&&!(Dn in t)},vs=t=>{if(!Wt(t)||Yt(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},_s=it("Date"),Cs=it("File"),Ts=t=>!!(t&&typeof t.uri<"u"),Rs=t=>t&&typeof t.getParts<"u",Ds=it("Blob"),As=it("FileList"),Os=t=>Wt(t)&&Ve(t.pipe);function Ps(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const ba=Ps(),Sa=typeof ba.FormData<"u"?ba.FormData:void 0,Is=t=>{if(!t)return!1;if(Sa&&t instanceof Sa)return!0;const n=Rn(t);if(!n||n===Object.prototype||!Ve(t.append))return!1;const a=An(t);return a==="formdata"||a==="object"&&Ve(t.toString)&&t.toString()==="[object FormData]"},Es=it("URLSearchParams"),[ks,Ms,Fs,Bs]=["ReadableStream","Request","Response","Headers"].map(it),Ns=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ht(t,n,{allOwnKeys:a=!1}={}){if(t===null||typeof t>"u")return;let r,s;if(typeof t!="object"&&(t=[t]),It(t))for(r=0,s=t.length;r<s;r++)n.call(null,t[r],r,t);else{if(Yt(t))return;const i=a?Object.getOwnPropertyNames(t):Object.keys(t),d=i.length;let u;for(r=0;r<d;r++)u=i[r],n.call(null,t[u],u,t)}}function Fr(t,n){if(Yt(t))return null;n=n.toLowerCase();const a=Object.keys(t);let r=a.length,s;for(;r-- >0;)if(s=a[r],n===s.toLowerCase())return s;return null}const bt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Br=t=>!Ot(t)&&t!==bt;function ra(){const{caseless:t,skipUndefined:n}=Br(this)&&this||{},a={},r=(s,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const d=t&&Fr(a,i)||i;mn(a[d])&&mn(s)?a[d]=ra(a[d],s):mn(s)?a[d]=ra({},s):It(s)?a[d]=s.slice():(!n||!Ot(s))&&(a[d]=s)};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&Ht(arguments[s],r);return a}const $s=(t,n,a,{allOwnKeys:r}={})=>(Ht(n,(s,i)=>{a&&Ve(s)?Object.defineProperty(t,i,{value:Ir(s,a),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),Us=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Ls=(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)},qs=(t,n,a,r)=>{let s,i,d;const u={};if(n=n||{},t==null)return n;do{for(s=Object.getOwnPropertyNames(t),i=s.length;i-- >0;)d=s[i],(!r||r(d,t,n))&&!u[d]&&(n[d]=t[d],u[d]=!0);t=a!==!1&&Rn(t)}while(t&&(!a||a(t,n))&&t!==Object.prototype);return n},zs=(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},Vs=t=>{if(!t)return null;if(It(t))return t;let n=t.length;if(!Mr(n))return null;const a=new Array(n);for(;n-- >0;)a[n]=t[n];return a},Ys=(t=>n=>t&&n instanceof t)(typeof Uint8Array<"u"&&Rn(Uint8Array)),Ws=(t,n)=>{const r=(t&&t[Dn]).call(t);let s;for(;(s=r.next())&&!s.done;){const i=s.value;n.call(t,i[0],i[1])}},Hs=(t,n)=>{let a;const r=[];for(;(a=t.exec(n))!==null;)r.push(a);return r},Ks=it("HTMLFormElement"),Js=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,r,s){return r.toUpperCase()+s}),ja=(({hasOwnProperty:t})=>(n,a)=>t.call(n,a))(Object.prototype),Gs=it("RegExp"),Nr=(t,n)=>{const a=Object.getOwnPropertyDescriptors(t),r={};Ht(a,(s,i)=>{let d;(d=n(s,i,t))!==!1&&(r[i]=d||s)}),Object.defineProperties(t,r)},Qs=t=>{Nr(t,(n,a)=>{if(Ve(t)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const r=t[a];if(Ve(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+"'")})}})},Xs=(t,n)=>{const a={},r=s=>{s.forEach(i=>{a[i]=!0})};return It(t)?r(t):r(String(t).split(n)),a},Zs=()=>{},eo=(t,n)=>t!=null&&Number.isFinite(t=+t)?t:n;function to(t){return!!(t&&Ve(t.append)&&t[Er]==="FormData"&&t[Dn])}const no=t=>{const n=new Array(10),a=(r,s)=>{if(Wt(r)){if(n.indexOf(r)>=0)return;if(Yt(r))return r;if(!("toJSON"in r)){n[s]=r;const i=It(r)?[]:{};return Ht(r,(d,u)=>{const b=a(d,s+1);!Ot(b)&&(i[u]=b)}),n[s]=void 0,i}}return r};return a(t,0)},ao=it("AsyncFunction"),ro=t=>t&&(Wt(t)||Ve(t))&&Ve(t.then)&&Ve(t.catch),$r=((t,n)=>t?setImmediate:n?((a,r)=>(bt.addEventListener("message",({source:s,data:i})=>{s===bt&&i===a&&r.length&&r.shift()()},!1),s=>{r.push(s),bt.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",Ve(bt.postMessage)),so=typeof queueMicrotask<"u"?queueMicrotask.bind(bt):typeof process<"u"&&process.nextTick||$r,oo=t=>t!=null&&Ve(t[Dn]),M={isArray:It,isArrayBuffer:kr,isBuffer:Yt,isFormData:Is,isArrayBufferView:Ss,isString:js,isNumber:Mr,isBoolean:ws,isObject:Wt,isPlainObject:mn,isEmptyObject:vs,isReadableStream:ks,isRequest:Ms,isResponse:Fs,isHeaders:Bs,isUndefined:Ot,isDate:_s,isFile:Cs,isReactNativeBlob:Ts,isReactNative:Rs,isBlob:Ds,isRegExp:Gs,isFunction:Ve,isStream:Os,isURLSearchParams:Es,isTypedArray:Ys,isFileList:As,forEach:Ht,merge:ra,extend:$s,trim:Ns,stripBOM:Us,inherits:Ls,toFlatObject:qs,kindOf:An,kindOfTest:it,endsWith:zs,toArray:Vs,forEachEntry:Ws,matchAll:Hs,isHTMLForm:Ks,hasOwnProperty:ja,hasOwnProp:ja,reduceDescriptors:Nr,freezeMethods:Qs,toObjectSet:Xs,toCamelCase:Js,noop:Zs,toFiniteNumber:eo,findKey:Fr,global:bt,isContextDefined:Br,isSpecCompliantForm:to,toJSONObject:no,isAsyncFn:ao,isThenable:ro,setImmediate:$r,asap:so,isIterable:oo};let ge=class Ur extends Error{static from(n,a,r,s,i,d){const u=new Ur(n.message,a||n.code,r,s,i);return u.cause=n,u.name=n.name,n.status!=null&&u.status==null&&(u.status=n.status),d&&Object.assign(u,d),u}constructor(n,a,r,s,i){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),s&&(this.request=s),i&&(this.response=i,this.status=i.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:M.toJSONObject(this.config),code:this.code,status:this.status}}};ge.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ge.ERR_BAD_OPTION="ERR_BAD_OPTION";ge.ECONNABORTED="ECONNABORTED";ge.ETIMEDOUT="ETIMEDOUT";ge.ERR_NETWORK="ERR_NETWORK";ge.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ge.ERR_DEPRECATED="ERR_DEPRECATED";ge.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ge.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ge.ERR_CANCELED="ERR_CANCELED";ge.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ge.ERR_INVALID_URL="ERR_INVALID_URL";ge.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const io=null;function sa(t){return M.isPlainObject(t)||M.isArray(t)}function Lr(t){return M.endsWith(t,"[]")?t.slice(0,-2):t}function Nn(t,n,a){return t?t.concat(n).map(function(s,i){return s=Lr(s),!a&&i?"["+s+"]":s}).join(a?".":""):n}function lo(t){return M.isArray(t)&&!t.some(sa)}const co=M.toFlatObject(M,{},null,function(n){return/^is[A-Z]/.test(n)});function Pn(t,n,a){if(!M.isObject(t))throw new TypeError("target must be an object");n=n||new FormData,a=M.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(f,T){return!M.isUndefined(T[f])});const r=a.metaTokens,s=a.visitor||y,i=a.dots,d=a.indexes,u=a.Blob||typeof Blob<"u"&&Blob,b=a.maxDepth===void 0?100:a.maxDepth,h=u&&M.isSpecCompliantForm(n);if(!M.isFunction(s))throw new TypeError("visitor must be a function");function p(c){if(c===null)return"";if(M.isDate(c))return c.toISOString();if(M.isBoolean(c))return c.toString();if(!h&&M.isBlob(c))throw new ge("Blob is not supported. Use a Buffer instead.");return M.isArrayBuffer(c)||M.isTypedArray(c)?h&&typeof Blob=="function"?new Blob([c]):Buffer.from(c):c}function y(c,f,T){let C=c;if(M.isReactNative(n)&&M.isReactNativeBlob(c))return n.append(Nn(T,f,i),p(c)),!1;if(c&&!T&&typeof c=="object"){if(M.endsWith(f,"{}"))f=r?f:f.slice(0,-2),c=JSON.stringify(c);else if(M.isArray(c)&&lo(c)||(M.isFileList(c)||M.endsWith(f,"[]"))&&(C=M.toArray(c)))return f=Lr(f),C.forEach(function(j,g){!(M.isUndefined(j)||j===null)&&n.append(d===!0?Nn([f],g,i):d===null?f:f+"[]",p(j))}),!1}return sa(c)?!0:(n.append(Nn(T,f,i),p(c)),!1)}const v=[],w=Object.assign(co,{defaultVisitor:y,convertValue:p,isVisitable:sa});function m(c,f,T=0){if(!M.isUndefined(c)){if(T>b)throw new ge("Object is too deeply nested ("+T+" levels). Max depth: "+b,ge.ERR_FORM_DATA_DEPTH_EXCEEDED);if(v.indexOf(c)!==-1)throw Error("Circular reference detected in "+f.join("."));v.push(c),M.forEach(c,function(S,j){(!(M.isUndefined(S)||S===null)&&s.call(n,S,M.isString(j)?j.trim():j,f,w))===!0&&m(S,f?f.concat(j):[j],T+1)}),v.pop()}}if(!M.isObject(t))throw new TypeError("data must be an object");return m(t),n}function wa(t){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return n[r]})}function ca(t,n){this._pairs=[],t&&Pn(t,this,n)}const qr=ca.prototype;qr.append=function(n,a){this._pairs.push([n,a])};qr.toString=function(n){const a=n?function(r){return n.call(this,r,wa)}:wa;return this._pairs.map(function(s){return a(s[0])+"="+a(s[1])},"").join("&")};function uo(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function zr(t,n,a){if(!n)return t;const r=a&&a.encode||uo,s=M.isFunction(a)?{serialize:a}:a,i=s&&s.serialize;let d;if(i?d=i(n,s):d=M.isURLSearchParams(n)?n.toString():new ca(n,s).toString(r),d){const u=t.indexOf("#");u!==-1&&(t=t.slice(0,u)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class va{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){M.forEach(this.handlers,function(r){r!==null&&n(r)})}}const ua={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},po=typeof URLSearchParams<"u"?URLSearchParams:ca,fo=typeof FormData<"u"?FormData:null,mo=typeof Blob<"u"?Blob:null,ho={isBrowser:!0,classes:{URLSearchParams:po,FormData:fo,Blob:mo},protocols:["http","https","file","blob","url","data"]},pa=typeof window<"u"&&typeof document<"u",oa=typeof navigator=="object"&&navigator||void 0,yo=pa&&(!oa||["ReactNative","NativeScript","NS"].indexOf(oa.product)<0),go=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",xo=pa&&window.location.href||"http://localhost",bo=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:pa,hasStandardBrowserEnv:yo,hasStandardBrowserWebWorkerEnv:go,navigator:oa,origin:xo},Symbol.toStringTag,{value:"Module"})),Ne={...bo,...ho};function So(t,n){return Pn(t,new Ne.classes.URLSearchParams,{visitor:function(a,r,s,i){return Ne.isNode&&M.isBuffer(a)?(this.append(r,a.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...n})}function jo(t){return M.matchAll(/\w+|\[(\w*)]/g,t).map(n=>n[0]==="[]"?"":n[1]||n[0])}function wo(t){const n={},a=Object.keys(t);let r;const s=a.length;let i;for(r=0;r<s;r++)i=a[r],n[i]=t[i];return n}function Vr(t){function n(a,r,s,i){let d=a[i++];if(d==="__proto__")return!0;const u=Number.isFinite(+d),b=i>=a.length;return d=!d&&M.isArray(s)?s.length:d,b?(M.hasOwnProp(s,d)?s[d]=M.isArray(s[d])?s[d].concat(r):[s[d],r]:s[d]=r,!u):((!s[d]||!M.isObject(s[d]))&&(s[d]=[]),n(a,r,s[d],i)&&M.isArray(s[d])&&(s[d]=wo(s[d])),!u)}if(M.isFormData(t)&&M.isFunction(t.entries)){const a={};return M.forEachEntry(t,(r,s)=>{n(jo(r),s,a,0)}),a}return null}const vt=(t,n)=>t!=null&&M.hasOwnProp(t,n)?t[n]:void 0;function vo(t,n,a){if(M.isString(t))try{return(n||JSON.parse)(t),M.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(a||JSON.stringify)(t)}const Kt={transitional:ua,adapter:["xhr","http","fetch"],transformRequest:[function(n,a){const r=a.getContentType()||"",s=r.indexOf("application/json")>-1,i=M.isObject(n);if(i&&M.isHTMLForm(n)&&(n=new FormData(n)),M.isFormData(n))return s?JSON.stringify(Vr(n)):n;if(M.isArrayBuffer(n)||M.isBuffer(n)||M.isStream(n)||M.isFile(n)||M.isBlob(n)||M.isReadableStream(n))return n;if(M.isArrayBufferView(n))return n.buffer;if(M.isURLSearchParams(n))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let u;if(i){const b=vt(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return So(n,b).toString();if((u=M.isFileList(n))||r.indexOf("multipart/form-data")>-1){const h=vt(this,"env"),p=h&&h.FormData;return Pn(u?{"files[]":n}:n,p&&new p,b)}}return i||s?(a.setContentType("application/json",!1),vo(n)):n}],transformResponse:[function(n){const a=vt(this,"transitional")||Kt.transitional,r=a&&a.forcedJSONParsing,s=vt(this,"responseType"),i=s==="json";if(M.isResponse(n)||M.isReadableStream(n))return n;if(n&&M.isString(n)&&(r&&!s||i)){const u=!(a&&a.silentJSONParsing)&&i;try{return JSON.parse(n,vt(this,"parseReviver"))}catch(b){if(u)throw b.name==="SyntaxError"?ge.from(b,ge.ERR_BAD_RESPONSE,this,null,vt(this,"response")):b}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ne.classes.FormData,Blob:Ne.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};M.forEach(["delete","get","head","post","put","patch"],t=>{Kt.headers[t]={}});const _o=M.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"]),Co=t=>{const n={};let a,r,s;return t&&t.split(`
|
|
2
|
-
`).forEach(function(d){
|
|
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(s=>r.set(s)),r}static accessor(n){const r=(this[_a]=this[_a]={accessors:{}}).accessors,s=this.prototype;function i(d){const u=Ft(d);r[u]||(Io(s,d),r[u]=!0)}return M.isArray(n)?n.forEach(i):i(n),this}};Ye.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);M.reduceDescriptors(Ye.prototype,({value:t},n)=>{let a=n[0].toUpperCase()+n.slice(1);return{get:()=>t,set(r){this[a]=r}}});M.freezeMethods(Ye);function Un(t,n){const a=this||Kt,r=n||a,s=Ye.from(r.headers);let i=r.data;return M.forEach(t,function(u){i=u.call(a,i,s.normalize(),n?n.status:void 0)}),s.normalize(),i}function Yr(t){return!!(t&&t.__CANCEL__)}let Jt=class extends ge{constructor(n,a,r){super(n??"canceled",ge.ERR_CANCELED,a,r),this.name="CanceledError",this.__CANCEL__=!0}};function Wr(t,n,a){const r=a.config.validateStatus;!a.status||!r||r(a.status)?t(a):n(new ge("Request failed with status code "+a.status,[ge.ERR_BAD_REQUEST,ge.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function Eo(t){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return n&&n[1]||""}function ko(t,n){t=t||10;const a=new Array(t),r=new Array(t);let s=0,i=0,d;return n=n!==void 0?n:1e3,function(b){const h=Date.now(),p=r[i];d||(d=h),a[s]=b,r[s]=h;let y=i,v=0;for(;y!==s;)v+=a[y++],y=y%t;if(s=(s+1)%t,s===i&&(i=(i+1)%t),h-d<n)return;const w=p&&h-p;return w?Math.round(v*1e3/w):void 0}}function Mo(t,n){let a=0,r=1e3/n,s,i;const d=(h,p=Date.now())=>{a=p,s=null,i&&(clearTimeout(i),i=null),t(...h)};return[(...h)=>{const p=Date.now(),y=p-a;y>=r?d(h,p):(s=h,i||(i=setTimeout(()=>{i=null,d(s)},r-y)))},()=>s&&d(s)]}const Tn=(t,n,a=3)=>{let r=0;const s=ko(50,250);return Mo(i=>{const d=i.loaded,u=i.lengthComputable?i.total:void 0,b=u!=null?Math.min(d,u):d,h=Math.max(0,b-r),p=s(h);r=Math.max(r,b);const y={loaded:b,total:u,progress:u?b/u:void 0,bytes:h,rate:p||void 0,estimated:p&&u?(u-b)/p:void 0,event:i,lengthComputable:u!=null,[n?"download":"upload"]:!0};t(y)},a)},Ca=(t,n)=>{const a=t!=null;return[r=>n[0]({lengthComputable:a,total:t,loaded:r}),n[1]]},Ta=t=>(...n)=>M.asap(()=>t(...n)),Fo=Ne.hasStandardBrowserEnv?((t,n)=>a=>(a=new URL(a,Ne.origin),t.protocol===a.protocol&&t.host===a.host&&(n||t.port===a.port)))(new URL(Ne.origin),Ne.navigator&&/(msie|trident)/i.test(Ne.navigator.userAgent)):()=>!0,Bo=Ne.hasStandardBrowserEnv?{write(t,n,a,r,s,i,d){if(typeof document>"u")return;const u=[`${t}=${encodeURIComponent(n)}`];M.isNumber(a)&&u.push(`expires=${new Date(a).toUTCString()}`),M.isString(r)&&u.push(`path=${r}`),M.isString(s)&&u.push(`domain=${s}`),i===!0&&u.push("secure"),M.isString(d)&&u.push(`SameSite=${d}`),document.cookie=u.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 No(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function $o(t,n){return n?t.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):t}function Hr(t,n,a){let r=!No(n);return t&&(r||a===!1)?$o(t,n):n}const Ra=t=>t instanceof Ye?{...t}:t;function wt(t,n){n=n||{};const a=Object.create(null);Object.defineProperty(a,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(h,p,y,v){return M.isPlainObject(h)&&M.isPlainObject(p)?M.merge.call({caseless:v},h,p):M.isPlainObject(p)?M.merge({},p):M.isArray(p)?p.slice():p}function s(h,p,y,v){if(M.isUndefined(p)){if(!M.isUndefined(h))return r(void 0,h,y,v)}else return r(h,p,y,v)}function i(h,p){if(!M.isUndefined(p))return r(void 0,p)}function d(h,p){if(M.isUndefined(p)){if(!M.isUndefined(h))return r(void 0,h)}else return r(void 0,p)}function u(h,p,y){if(M.hasOwnProp(n,y))return r(h,p);if(M.hasOwnProp(t,y))return r(void 0,h)}const b={url:i,method:i,data:i,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:u,headers:(h,p,y)=>s(Ra(h),Ra(p),y,!0)};return M.forEach(Object.keys({...t,...n}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const y=M.hasOwnProp(b,p)?b[p]:s,v=M.hasOwnProp(t,p)?t[p]:void 0,w=M.hasOwnProp(n,p)?n[p]:void 0,m=y(v,w,p);M.isUndefined(m)&&y!==u||(a[p]=m)}),a}const Kr=t=>{const n=wt({},t),a=v=>M.hasOwnProp(n,v)?n[v]:void 0,r=a("data");let s=a("withXSRFToken");const i=a("xsrfHeaderName"),d=a("xsrfCookieName");let u=a("headers");const b=a("auth"),h=a("baseURL"),p=a("allowAbsoluteUrls"),y=a("url");if(n.headers=u=Ye.from(u),n.url=zr(Hr(h,y,p),t.params,t.paramsSerializer),b&&u.set("Authorization","Basic "+btoa((b.username||"")+":"+(b.password?unescape(encodeURIComponent(b.password)):""))),M.isFormData(r)){if(Ne.hasStandardBrowserEnv||Ne.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if(M.isFunction(r.getHeaders)){const v=r.getHeaders(),w=["content-type","content-length"];Object.entries(v).forEach(([m,c])=>{w.includes(m.toLowerCase())&&u.set(m,c)})}}if(Ne.hasStandardBrowserEnv&&(M.isFunction(s)&&(s=s(n)),s===!0||s==null&&Fo(n.url))){const w=i&&d&&Bo.read(d);w&&u.set(i,w)}return n},Uo=typeof XMLHttpRequest<"u",Lo=Uo&&function(t){return new Promise(function(a,r){const s=Kr(t);let i=s.data;const d=Ye.from(s.headers).normalize();let{responseType:u,onUploadProgress:b,onDownloadProgress:h}=s,p,y,v,w,m;function c(){w&&w(),m&&m(),s.cancelToken&&s.cancelToken.unsubscribe(p),s.signal&&s.signal.removeEventListener("abort",p)}let f=new XMLHttpRequest;f.open(s.method.toUpperCase(),s.url,!0),f.timeout=s.timeout;function T(){if(!f)return;const S=Ye.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders()),g={data:!u||u==="text"||u==="json"?f.responseText:f.response,status:f.status,statusText:f.statusText,headers:S,config:t,request:f};Wr(function(P){a(P),c()},function(P){r(P),c()},g),f=null}"onloadend"in f?f.onloadend=T:f.onreadystatechange=function(){!f||f.readyState!==4||f.status===0&&!(f.responseURL&&f.responseURL.indexOf("file:")===0)||setTimeout(T)},f.onabort=function(){f&&(r(new ge("Request aborted",ge.ECONNABORTED,t,f)),f=null)},f.onerror=function(j){const g=j&&j.message?j.message:"Network Error",_=new ge(g,ge.ERR_NETWORK,t,f);_.event=j||null,r(_),f=null},f.ontimeout=function(){let j=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const g=s.transitional||ua;s.timeoutErrorMessage&&(j=s.timeoutErrorMessage),r(new ge(j,g.clarifyTimeoutError?ge.ETIMEDOUT:ge.ECONNABORTED,t,f)),f=null},i===void 0&&d.setContentType(null),"setRequestHeader"in f&&M.forEach(d.toJSON(),function(j,g){f.setRequestHeader(g,j)}),M.isUndefined(s.withCredentials)||(f.withCredentials=!!s.withCredentials),u&&u!=="json"&&(f.responseType=s.responseType),h&&([v,m]=Tn(h,!0),f.addEventListener("progress",v)),b&&f.upload&&([y,w]=Tn(b),f.upload.addEventListener("progress",y),f.upload.addEventListener("loadend",w)),(s.cancelToken||s.signal)&&(p=S=>{f&&(r(!S||S.type?new Jt(null,t,f):S),f.abort(),f=null)},s.cancelToken&&s.cancelToken.subscribe(p),s.signal&&(s.signal.aborted?p():s.signal.addEventListener("abort",p)));const C=Eo(s.url);if(C&&Ne.protocols.indexOf(C)===-1){r(new ge("Unsupported protocol "+C+":",ge.ERR_BAD_REQUEST,t));return}f.send(i||null)})},qo=(t,n)=>{const{length:a}=t=t?t.filter(Boolean):[];if(n||a){let r=new AbortController,s;const i=function(h){if(!s){s=!0,u();const p=h instanceof Error?h:this.reason;r.abort(p instanceof ge?p:new Jt(p instanceof Error?p.message:p))}};let d=n&&setTimeout(()=>{d=null,i(new ge(`timeout of ${n}ms exceeded`,ge.ETIMEDOUT))},n);const u=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(h=>{h.unsubscribe?h.unsubscribe(i):h.removeEventListener("abort",i)}),t=null)};t.forEach(h=>h.addEventListener("abort",i));const{signal:b}=r;return b.unsubscribe=()=>M.asap(u),b}},zo=function*(t,n){let a=t.byteLength;if(a<n){yield t;return}let r=0,s;for(;r<a;)s=r+n,yield t.slice(r,s),r=s},Vo=async function*(t,n){for await(const a of Yo(t))yield*zo(a,n)},Yo=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()}},Da=(t,n,a,r)=>{const s=Vo(t,n);let i=0,d,u=b=>{d||(d=!0,r&&r(b))};return new ReadableStream({async pull(b){try{const{done:h,value:p}=await s.next();if(h){u(),b.close();return}let y=p.byteLength;if(a){let v=i+=y;a(v)}b.enqueue(new Uint8Array(p))}catch(h){throw u(h),h}},cancel(b){return u(b),s.return()}},{highWaterMark:2})},Aa=64*1024,{isFunction:tn}=M,Wo=(({Request:t,Response:n})=>({Request:t,Response:n}))(M.global),{ReadableStream:Oa,TextEncoder:Pa}=M.global,Ia=(t,...n)=>{try{return!!t(...n)}catch{return!1}},Ho=t=>{t=M.merge.call({skipUndefined:!0},Wo,t);const{fetch:n,Request:a,Response:r}=t,s=n?tn(n):typeof fetch=="function",i=tn(a),d=tn(r);if(!s)return!1;const u=s&&tn(Oa),b=s&&(typeof Pa=="function"?(m=>c=>m.encode(c))(new Pa):async m=>new Uint8Array(await new a(m).arrayBuffer())),h=i&&u&&Ia(()=>{let m=!1;const c=new a(Ne.origin,{body:new Oa,method:"POST",get duplex(){return m=!0,"half"}}),f=c.headers.has("Content-Type");return c.body!=null&&c.body.cancel(),m&&!f}),p=d&&u&&Ia(()=>M.isReadableStream(new r("").body)),y={stream:p&&(m=>m.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!y[m]&&(y[m]=(c,f)=>{let T=c&&c[m];if(T)return T.call(c);throw new ge(`Response type '${m}' is not supported`,ge.ERR_NOT_SUPPORT,f)})});const v=async m=>{if(m==null)return 0;if(M.isBlob(m))return m.size;if(M.isSpecCompliantForm(m))return(await new a(Ne.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(M.isArrayBufferView(m)||M.isArrayBuffer(m))return m.byteLength;if(M.isURLSearchParams(m)&&(m=m+""),M.isString(m))return(await b(m)).byteLength},w=async(m,c)=>{const f=M.toFiniteNumber(m.getContentLength());return f??v(c)};return async m=>{let{url:c,method:f,data:T,signal:C,cancelToken:S,timeout:j,onDownloadProgress:g,onUploadProgress:_,responseType:P,headers:I,withCredentials:O="same-origin",fetchOptions:k}=Kr(m),E=n||fetch;P=P?(P+"").toLowerCase():"text";let D=qo([C,S&&S.toAbortSignal()],j),F=null;const V=D&&D.unsubscribe&&(()=>{D.unsubscribe()});let Z;try{if(_&&h&&f!=="get"&&f!=="head"&&(Z=await w(I,T))!==0){let R=new a(c,{method:"POST",body:T,duplex:"half"}),$;if(M.isFormData(T)&&($=R.headers.get("content-type"))&&I.setContentType($),R.body){const[q,Q]=Ca(Z,Tn(Ta(_)));T=Da(R.body,Aa,q,Q)}}M.isString(O)||(O=O?"include":"omit");const U=i&&"credentials"in a.prototype;if(M.isFormData(T)){const R=I.getContentType();R&&/^multipart\/form-data/i.test(R)&&!/boundary=/i.test(R)&&I.delete("content-type")}const Y={...k,signal:D,method:f.toUpperCase(),headers:I.normalize().toJSON(),body:T,duplex:"half",credentials:U?O:void 0};F=i&&new a(c,Y);let W=await(i?E(F,k):E(c,Y));const L=p&&(P==="stream"||P==="response");if(p&&(g||L&&V)){const R={};["status","statusText","headers"].forEach(ue=>{R[ue]=W[ue]});const $=M.toFiniteNumber(W.headers.get("content-length")),[q,Q]=g&&Ca($,Tn(Ta(g),!0))||[];W=new r(Da(W.body,Aa,q,()=>{Q&&Q(),V&&V()}),R)}P=P||"text";let x=await y[M.findKey(y,P)||"text"](W,m);return!L&&V&&V(),await new Promise((R,$)=>{Wr(R,$,{data:x,headers:Ye.from(W.headers),status:W.status,statusText:W.statusText,config:m,request:F})})}catch(U){throw V&&V(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new ge("Network Error",ge.ERR_NETWORK,m,F,U&&U.response),{cause:U.cause||U}):ge.from(U,U&&U.code,m,F,U&&U.response)}}},Ko=new Map,Jr=t=>{let n=t&&t.env||{};const{fetch:a,Request:r,Response:s}=n,i=[r,s,a];let d=i.length,u=d,b,h,p=Ko;for(;u--;)b=i[u],h=p.get(b),h===void 0&&p.set(b,h=u?new Map:Ho(n)),p=h;return h};Jr();const fa={http:io,xhr:Lo,fetch:{get:Jr}};M.forEach(fa,(t,n)=>{if(t){try{Object.defineProperty(t,"name",{value:n})}catch{}Object.defineProperty(t,"adapterName",{value:n})}});const Ea=t=>`- ${t}`,Jo=t=>M.isFunction(t)||t===null||t===!1;function Go(t,n){t=M.isArray(t)?t:[t];const{length:a}=t;let r,s;const i={};for(let d=0;d<a;d++){r=t[d];let u;if(s=r,!Jo(r)&&(s=fa[(u=String(r)).toLowerCase()],s===void 0))throw new ge(`Unknown adapter '${u}'`);if(s&&(M.isFunction(s)||(s=s.get(n))))break;i[u||"#"+d]=s}if(!s){const d=Object.entries(i).map(([b,h])=>`adapter ${b} `+(h===!1?"is not supported by the environment":"is not available in the build"));let u=a?d.length>1?`since :
|
|
4
|
-
`+d.map(
|
|
5
|
-
`):" "+
|
|
6
|
-
`);return d===-1?"":
|
|
7
|
-
`),u=d===-1?-1:
|
|
8
|
-
`,d+1),b=u===-1?"":
|
|
9
|
-
`+i)}}catch{}}throw r}}_request(n,a){typeof n=="string"?(a=a||{},a.url=n):a=n||{},a=wt(this.defaults,a);const{transitional:r,paramsSerializer:s,headers:i}=a;r!==void 0&&yn.assertOptions(r,{silentJSONParsing:et.transitional(et.boolean),forcedJSONParsing:et.transitional(et.boolean),clarifyTimeoutError:et.transitional(et.boolean),legacyInterceptorReqResOrdering:et.transitional(et.boolean)},!1),s!=null&&(M.isFunction(s)?a.paramsSerializer={serialize:s}:yn.assertOptions(s,{encode:et.function,serialize:et.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),yn.assertOptions(a,{baseUrl:et.spelling("baseURL"),withXsrfToken:et.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let d=i&&M.merge(i.common,i[a.method]);i&&M.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),a.headers=Ye.concat(d,i);const u=[];let b=!0;this.interceptors.request.forEach(function(c){if(typeof c.runWhen=="function"&&c.runWhen(a)===!1)return;b=b&&c.synchronous;const f=a.transitional||ua;f&&f.legacyInterceptorReqResOrdering?u.unshift(c.fulfilled,c.rejected):u.push(c.fulfilled,c.rejected)});const h=[];this.interceptors.response.forEach(function(c){h.push(c.fulfilled,c.rejected)});let p,y=0,v;if(!b){const m=[ka.bind(this),void 0];for(m.unshift(...u),m.push(...h),v=m.length,p=Promise.resolve(a);y<v;)p=p.then(m[y++],m[y++]);return p}v=u.length;let w=a;for(;y<v;){const m=u[y++],c=u[y++];try{w=m(w)}catch(f){c.call(this,f);break}}try{p=ka.call(this,w)}catch(m){return Promise.reject(m)}for(y=0,v=h.length;y<v;)p=p.then(h[y++],h[y++]);return p}getUri(n){n=wt(this.defaults,n);const a=Hr(n.baseURL,n.url,n.allowAbsoluteUrls);return zr(a,n.params,n.paramsSerializer)}};M.forEach(["delete","get","head","options"],function(n){St.prototype[n]=function(a,r){return this.request(wt(r||{},{method:n,url:a,data:(r||{}).data}))}});M.forEach(["post","put","patch"],function(n){function a(r){return function(i,d,u){return this.request(wt(u||{},{method:n,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:d}))}}St.prototype[n]=a(),St.prototype[n+"Form"]=a(!0)});let Xo=class Xr{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(i){a=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const d=new Promise(u=>{r.subscribe(u),i=u}).then(s);return d.cancel=function(){r.unsubscribe(i)},d},n(function(i,d,u){r.reason||(r.reason=new Jt(i,d,u),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 Xr(function(s){n=s}),cancel:n}}};function Zo(t){return function(a){return t.apply(null,a)}}function ei(t){return M.isObject(t)&&t.isAxiosError===!0}const ia={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(ia).forEach(([t,n])=>{ia[n]=t});function Zr(t){const n=new St(t),a=Ir(St.prototype.request,n);return M.extend(a,St.prototype,n,{allOwnKeys:!0}),M.extend(a,n,null,{allOwnKeys:!0}),a.create=function(s){return Zr(wt(t,s))},a}const De=Zr(Kt);De.Axios=St;De.CanceledError=Jt;De.CancelToken=Xo;De.isCancel=Yr;De.VERSION=Qr;De.toFormData=Pn;De.AxiosError=ge;De.Cancel=De.CanceledError;De.all=function(n){return Promise.all(n)};De.spread=Zo;De.isAxiosError=ei;De.mergeConfig=wt;De.AxiosHeaders=Ye;De.formToJSON=t=>Vr(M.isHTMLForm(t)?new FormData(t):t);De.getAdapter=Gr.getAdapter;De.HttpStatusCode=ia;De.default=De;const{Axios:Cc,AxiosError:Tc,CanceledError:Rc,isCancel:Dc,CancelToken:Ac,VERSION:Oc,all:Pc,Cancel:Ic,isAxiosError:Ec,spread:kc,toFormData:Mc,AxiosHeaders:Fc,HttpStatusCode:Bc,formToJSON:Nc,getAdapter:$c,mergeConfig:Uc}=De,ti=()=>new Promise(t=>setTimeout(()=>t(),800));let la=null;const ni=t=>{la=t,ct.defaults.baseURL=ma()},ma=()=>la||"https://npmapi.ubkerp.com/",ct=De.create({baseURL:ma()}),pt=()=>ma(),Ge=async(t,n,a)=>{const r=await ct.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)},te=async(t,n)=>{try{let r=t;if(!t.includes("session_id")){const i=t.includes("?")?"&":"?";r=`${t}${i}session_id=1`}return(await ct.get(r,{headers:{Authorization:n}})).data}catch(a){throw a.response?.status===401&&console.error("401 Unauthorized"),a}},ai=async(t,n)=>{const a=await ct.post(t,"",{headers:{Authorization:n}});if(a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},es=async(t,n,a)=>(await ct.post(t,n,{headers:{Authorization:a}}))?.data,qn=async(t,n,a)=>{const r=n?.arg;return(await ct.post(t,r,{headers:{Authorization:a}}))?.data},At=async(t,n,a)=>{const r=n?.arg,s=t.includes("?")?"&":"?";return(await ct.get(t+s,{params:r,headers:{Authorization:a}}))?.data},ri="/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",ha=async(t,n,a)=>{const r=n?.arg,s=t.includes("?")?"&":"?";return(await ct.get(t+s,{params:r,headers:{Authorization:a}}))?.data},ft=async(t,n,a)=>(await ti(),(await ct.post(t,n,{headers:{Authorization:a}}))?.data),nt=async(t,n,a)=>(await ct.delete(`${t}/${n}`,{headers:{Authorization:a}})).data,si=({token:t,menu:n})=>{const{isLoading:a,data:r}=X(t?["api/sdk/Menus",t]:null,([i,d])=>ai(i,d)),s=r?.find(i=>i.path===n)?.sub_menu??[];return console.log("menuData",r),e.jsx(o.Row,{gutter:[16,16],children:s?.map((i,d)=>i.dashboard_show==="YES"?e.jsx(o.Col,{xs:24,md:8,lg:8,children:e.jsx(ne,{children:e.jsx(Pr,{icon:`${pt()}icons/frontoffice/${i.icons}`,title:i.submenu_name,path:i.menu_key})})},`${d}office001`):null)})};function ts(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Me={},zn,Fa;function oi(){return Fa||(Fa=1,zn=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,s,i;if(Array.isArray(n)){if(r=n.length,r!=a.length)return!1;for(s=r;s--!==0;)if(!t(n[s],a[s]))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(i=Object.keys(n),r=i.length,r!==Object.keys(a).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(a,i[s]))return!1;for(s=r;s--!==0;){var d=i[s];if(!t(n[d],a[d]))return!1}return!0}return n!==n&&a!==a}),zn}var nn={exports:{}},an={exports:{}},Ce={};var Ba;function ii(){if(Ba)return Ce;Ba=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,s=t?Symbol.for("react.strict_mode"):60108,i=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,u=t?Symbol.for("react.context"):60110,b=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,y=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,c=t?Symbol.for("react.block"):60121,f=t?Symbol.for("react.fundamental"):60117,T=t?Symbol.for("react.responder"):60118,C=t?Symbol.for("react.scope"):60119;function S(g){if(typeof g=="object"&&g!==null){var _=g.$$typeof;switch(_){case n:switch(g=g.type,g){case b:case h:case r:case i:case s:case y:return g;default:switch(g=g&&g.$$typeof,g){case u:case p:case m:case w:case d:return g;default:return _}}case a:return _}}}function j(g){return S(g)===h}return Ce.AsyncMode=b,Ce.ConcurrentMode=h,Ce.ContextConsumer=u,Ce.ContextProvider=d,Ce.Element=n,Ce.ForwardRef=p,Ce.Fragment=r,Ce.Lazy=m,Ce.Memo=w,Ce.Portal=a,Ce.Profiler=i,Ce.StrictMode=s,Ce.Suspense=y,Ce.isAsyncMode=function(g){return j(g)||S(g)===b},Ce.isConcurrentMode=j,Ce.isContextConsumer=function(g){return S(g)===u},Ce.isContextProvider=function(g){return S(g)===d},Ce.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===n},Ce.isForwardRef=function(g){return S(g)===p},Ce.isFragment=function(g){return S(g)===r},Ce.isLazy=function(g){return S(g)===m},Ce.isMemo=function(g){return S(g)===w},Ce.isPortal=function(g){return S(g)===a},Ce.isProfiler=function(g){return S(g)===i},Ce.isStrictMode=function(g){return S(g)===s},Ce.isSuspense=function(g){return S(g)===y},Ce.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===r||g===h||g===i||g===s||g===y||g===v||typeof g=="object"&&g!==null&&(g.$$typeof===m||g.$$typeof===w||g.$$typeof===d||g.$$typeof===u||g.$$typeof===p||g.$$typeof===f||g.$$typeof===T||g.$$typeof===C||g.$$typeof===c)},Ce.typeOf=S,Ce}var Te={};var Na;function li(){return Na||(Na=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,s=t?Symbol.for("react.strict_mode"):60108,i=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,u=t?Symbol.for("react.context"):60110,b=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,y=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,c=t?Symbol.for("react.block"):60121,f=t?Symbol.for("react.fundamental"):60117,T=t?Symbol.for("react.responder"):60118,C=t?Symbol.for("react.scope"):60119;function S(K){return typeof K=="string"||typeof K=="function"||K===r||K===h||K===i||K===s||K===y||K===v||typeof K=="object"&&K!==null&&(K.$$typeof===m||K.$$typeof===w||K.$$typeof===d||K.$$typeof===u||K.$$typeof===p||K.$$typeof===f||K.$$typeof===T||K.$$typeof===C||K.$$typeof===c)}function j(K){if(typeof K=="object"&&K!==null){var ve=K.$$typeof;switch(ve){case n:var Pe=K.type;switch(Pe){case b:case h:case r:case i:case s:case y:return Pe;default:var ke=Pe&&Pe.$$typeof;switch(ke){case u:case p:case m:case w:case d:return ke;default:return ve}}case a:return ve}}}var g=b,_=h,P=u,I=d,O=n,k=p,E=r,D=m,F=w,V=a,Z=i,U=s,Y=y,W=!1;function L(K){return W||(W=!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.")),x(K)||j(K)===b}function x(K){return j(K)===h}function R(K){return j(K)===u}function $(K){return j(K)===d}function q(K){return typeof K=="object"&&K!==null&&K.$$typeof===n}function Q(K){return j(K)===p}function ue(K){return j(K)===r}function se(K){return j(K)===m}function pe(K){return j(K)===w}function B(K){return j(K)===a}function H(K){return j(K)===i}function ie(K){return j(K)===s}function je(K){return j(K)===y}Te.AsyncMode=g,Te.ConcurrentMode=_,Te.ContextConsumer=P,Te.ContextProvider=I,Te.Element=O,Te.ForwardRef=k,Te.Fragment=E,Te.Lazy=D,Te.Memo=F,Te.Portal=V,Te.Profiler=Z,Te.StrictMode=U,Te.Suspense=Y,Te.isAsyncMode=L,Te.isConcurrentMode=x,Te.isContextConsumer=R,Te.isContextProvider=$,Te.isElement=q,Te.isForwardRef=Q,Te.isFragment=ue,Te.isLazy=se,Te.isMemo=pe,Te.isPortal=B,Te.isProfiler=H,Te.isStrictMode=ie,Te.isSuspense=je,Te.isValidElementType=S,Te.typeOf=j})()),Te}var $a;function ns(){return $a||($a=1,process.env.NODE_ENV==="production"?an.exports=ii():an.exports=li()),an.exports}var Vn,Ua;function di(){if(Ua)return Vn;Ua=1;var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function r(i){if(i==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(i)}function s(){try{if(!Object.assign)return!1;var i=new String("abc");if(i[5]="de",Object.getOwnPropertyNames(i)[0]==="5")return!1;for(var d={},u=0;u<10;u++)d["_"+String.fromCharCode(u)]=u;var b=Object.getOwnPropertyNames(d).map(function(p){return d[p]});if(b.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(p){h[p]=p}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Vn=s()?Object.assign:function(i,d){for(var u,b=r(i),h,p=1;p<arguments.length;p++){u=Object(arguments[p]);for(var y in u)n.call(u,y)&&(b[y]=u[y]);if(t){h=t(u);for(var v=0;v<h.length;v++)a.call(u,h[v])&&(b[h[v]]=u[h[v]])}}return b},Vn}var Yn,La;function ya(){if(La)return Yn;La=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Yn=t,Yn}var Wn,qa;function as(){return qa||(qa=1,Wn=Function.call.bind(Object.prototype.hasOwnProperty)),Wn}var Hn,za;function ci(){if(za)return Hn;za=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=ya(),a={},r=as();t=function(i){var d="Warning: "+i;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function s(i,d,u,b,h){if(process.env.NODE_ENV!=="production"){for(var p in i)if(r(i,p)){var y;try{if(typeof i[p]!="function"){var v=Error((b||"React class")+": "+u+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}y=i[p](d,p,b,u,null,n)}catch(m){y=m}if(y&&!(y instanceof Error)&&t((b||"React class")+": type specification of "+u+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof y+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),y instanceof Error&&!(y.message in a)){a[y.message]=!0;var w=h?h():"";t("Failed "+u+" type: "+y.message+(w??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(a={})},Hn=s,Hn}var Kn,Va;function ui(){if(Va)return Kn;Va=1;var t=ns(),n=di(),a=ya(),r=as(),s=ci(),i=function(){};process.env.NODE_ENV!=="production"&&(i=function(u){var b="Warning: "+u;typeof console<"u"&&console.error(b);try{throw new Error(b)}catch{}});function d(){return null}return Kn=function(u,b){var h=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function y(x){var R=x&&(h&&x[h]||x[p]);if(typeof R=="function")return R}var v="<<anonymous>>",w={array:T("array"),bigint:T("bigint"),bool:T("boolean"),func:T("function"),number:T("number"),object:T("object"),string:T("string"),symbol:T("symbol"),any:C(),arrayOf:S,element:j(),elementType:g(),instanceOf:_,node:k(),objectOf:I,oneOf:P,oneOfType:O,shape:D,exact:F};function m(x,R){return x===R?x!==0||1/x===1/R:x!==x&&R!==R}function c(x,R){this.message=x,this.data=R&&typeof R=="object"?R:{},this.stack=""}c.prototype=Error.prototype;function f(x){if(process.env.NODE_ENV!=="production")var R={},$=0;function q(ue,se,pe,B,H,ie,je){if(B=B||v,ie=ie||pe,je!==a){if(b){var K=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 K.name="Invariant Violation",K}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ve=B+":"+pe;!R[ve]&&$<3&&(i("You are manually calling a React.PropTypes validation function for the `"+ie+"` prop on `"+B+"`. 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."),R[ve]=!0,$++)}}return se[pe]==null?ue?se[pe]===null?new c("The "+H+" `"+ie+"` is marked as required "+("in `"+B+"`, but its value is `null`.")):new c("The "+H+" `"+ie+"` is marked as required in "+("`"+B+"`, but its value is `undefined`.")):null:x(se,pe,B,H,ie)}var Q=q.bind(null,!1);return Q.isRequired=q.bind(null,!0),Q}function T(x){function R($,q,Q,ue,se,pe){var B=$[q],H=U(B);if(H!==x){var ie=Y(B);return new c("Invalid "+ue+" `"+se+"` of type "+("`"+ie+"` supplied to `"+Q+"`, expected ")+("`"+x+"`."),{expectedType:x})}return null}return f(R)}function C(){return f(d)}function S(x){function R($,q,Q,ue,se){if(typeof x!="function")return new c("Property `"+se+"` of component `"+Q+"` has invalid PropType notation inside arrayOf.");var pe=$[q];if(!Array.isArray(pe)){var B=U(pe);return new c("Invalid "+ue+" `"+se+"` of type "+("`"+B+"` supplied to `"+Q+"`, expected an array."))}for(var H=0;H<pe.length;H++){var ie=x(pe,H,Q,ue,se+"["+H+"]",a);if(ie instanceof Error)return ie}return null}return f(R)}function j(){function x(R,$,q,Q,ue){var se=R[$];if(!u(se)){var pe=U(se);return new c("Invalid "+Q+" `"+ue+"` of type "+("`"+pe+"` supplied to `"+q+"`, expected a single ReactElement."))}return null}return f(x)}function g(){function x(R,$,q,Q,ue){var se=R[$];if(!t.isValidElementType(se)){var pe=U(se);return new c("Invalid "+Q+" `"+ue+"` of type "+("`"+pe+"` supplied to `"+q+"`, expected a single ReactElement type."))}return null}return f(x)}function _(x){function R($,q,Q,ue,se){if(!($[q]instanceof x)){var pe=x.name||v,B=L($[q]);return new c("Invalid "+ue+" `"+se+"` of type "+("`"+B+"` supplied to `"+Q+"`, expected ")+("instance of `"+pe+"`."))}return null}return f(R)}function P(x){if(!Array.isArray(x))return process.env.NODE_ENV!=="production"&&(arguments.length>1?i("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])."):i("Invalid argument supplied to oneOf, expected an array.")),d;function R($,q,Q,ue,se){for(var pe=$[q],B=0;B<x.length;B++)if(m(pe,x[B]))return null;var H=JSON.stringify(x,function(je,K){var ve=Y(K);return ve==="symbol"?String(K):K});return new c("Invalid "+ue+" `"+se+"` of value `"+String(pe)+"` "+("supplied to `"+Q+"`, expected one of "+H+"."))}return f(R)}function I(x){function R($,q,Q,ue,se){if(typeof x!="function")return new c("Property `"+se+"` of component `"+Q+"` has invalid PropType notation inside objectOf.");var pe=$[q],B=U(pe);if(B!=="object")return new c("Invalid "+ue+" `"+se+"` of type "+("`"+B+"` supplied to `"+Q+"`, expected an object."));for(var H in pe)if(r(pe,H)){var ie=x(pe,H,Q,ue,se+"."+H,a);if(ie instanceof Error)return ie}return null}return f(R)}function O(x){if(!Array.isArray(x))return process.env.NODE_ENV!=="production"&&i("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var R=0;R<x.length;R++){var $=x[R];if(typeof $!="function")return i("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+W($)+" at index "+R+"."),d}function q(Q,ue,se,pe,B){for(var H=[],ie=0;ie<x.length;ie++){var je=x[ie],K=je(Q,ue,se,pe,B,a);if(K==null)return null;K.data&&r(K.data,"expectedType")&&H.push(K.data.expectedType)}var ve=H.length>0?", expected one of type ["+H.join(", ")+"]":"";return new c("Invalid "+pe+" `"+B+"` supplied to "+("`"+se+"`"+ve+"."))}return f(q)}function k(){function x(R,$,q,Q,ue){return V(R[$])?null:new c("Invalid "+Q+" `"+ue+"` supplied to "+("`"+q+"`, expected a ReactNode."))}return f(x)}function E(x,R,$,q,Q){return new c((x||"React class")+": "+R+" type `"+$+"."+q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Q+"`.")}function D(x){function R($,q,Q,ue,se){var pe=$[q],B=U(pe);if(B!=="object")return new c("Invalid "+ue+" `"+se+"` of type `"+B+"` "+("supplied to `"+Q+"`, expected `object`."));for(var H in x){var ie=x[H];if(typeof ie!="function")return E(Q,ue,se,H,Y(ie));var je=ie(pe,H,Q,ue,se+"."+H,a);if(je)return je}return null}return f(R)}function F(x){function R($,q,Q,ue,se){var pe=$[q],B=U(pe);if(B!=="object")return new c("Invalid "+ue+" `"+se+"` of type `"+B+"` "+("supplied to `"+Q+"`, expected `object`."));var H=n({},$[q],x);for(var ie in H){var je=x[ie];if(r(x,ie)&&typeof je!="function")return E(Q,ue,se,ie,Y(je));if(!je)return new c("Invalid "+ue+" `"+se+"` key `"+ie+"` supplied to `"+Q+"`.\nBad object: "+JSON.stringify($[q],null," ")+`
|
|
10
|
-
Valid keys: `+JSON.stringify(Object.keys(x),null," "));var K=je(pe,ie,Q,ue,se+"."+ie,a);if(K)return K}return null}return f(R)}function V(x){switch(typeof x){case"number":case"string":case"undefined":return!0;case"boolean":return!x;case"object":if(Array.isArray(x))return x.every(V);if(x===null||u(x))return!0;var R=y(x);if(R){var $=R.call(x),q;if(R!==x.entries){for(;!(q=$.next()).done;)if(!V(q.value))return!1}else for(;!(q=$.next()).done;){var Q=q.value;if(Q&&!V(Q[1]))return!1}}else return!1;return!0;default:return!1}}function Z(x,R){return x==="symbol"?!0:R?R["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&R instanceof Symbol:!1}function U(x){var R=typeof x;return Array.isArray(x)?"array":x instanceof RegExp?"object":Z(R,x)?"symbol":R}function Y(x){if(typeof x>"u"||x===null)return""+x;var R=U(x);if(R==="object"){if(x instanceof Date)return"date";if(x instanceof RegExp)return"regexp"}return R}function W(x){var R=Y(x);switch(R){case"array":case"object":return"an "+R;case"boolean":case"date":case"regexp":return"a "+R;default:return R}}function L(x){return!x.constructor||!x.constructor.name?v:x.constructor.name}return w.checkPropTypes=s,w.resetWarningCache=s.resetWarningCache,w.PropTypes=w,w},Kn}var Jn,Ya;function pi(){if(Ya)return Jn;Ya=1;var t=ya();function n(){}function a(){}return a.resetWarningCache=n,Jn=function(){function r(d,u,b,h,p,y){if(y!==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}}r.isRequired=r;function s(){return r}var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:s,element:r,elementType:r,instanceOf:s,node:r,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:a,resetWarningCache:n};return i.PropTypes=i,i},Jn}var Wa;function rs(){if(Wa)return nn.exports;if(Wa=1,process.env.NODE_ENV!=="production"){var t=ns(),n=!0;nn.exports=ui()(t.isElement,n)}else nn.exports=pi()();return nn.exports}var Ha;function fi(){if(Ha)return Me;Ha=1;var t=Me&&Me.__extends||(function(){var w=function(m,c){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,T){f.__proto__=T}||function(f,T){for(var C in T)Object.prototype.hasOwnProperty.call(T,C)&&(f[C]=T[C])},w(m,c)};return function(m,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");w(m,c);function f(){this.constructor=m}m.prototype=c===null?Object.create(c):(f.prototype=c.prototype,new f)}})(),n=Me&&Me.__assign||function(){return n=Object.assign||function(w){for(var m,c=1,f=arguments.length;c<f;c++){m=arguments[c];for(var T in m)Object.prototype.hasOwnProperty.call(m,T)&&(w[T]=m[T])}return w},n.apply(this,arguments)},a=Me&&Me.__createBinding||(Object.create?(function(w,m,c,f){f===void 0&&(f=c);var T=Object.getOwnPropertyDescriptor(m,c);(!T||("get"in T?!m.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return m[c]}}),Object.defineProperty(w,f,T)}):(function(w,m,c,f){f===void 0&&(f=c),w[f]=m[c]})),r=Me&&Me.__setModuleDefault||(Object.create?(function(w,m){Object.defineProperty(w,"default",{enumerable:!0,value:m})}):function(w,m){w.default=m}),s=Me&&Me.__importStar||function(w){if(w&&w.__esModule)return w;var m={};if(w!=null)for(var c in w)c!=="default"&&Object.prototype.hasOwnProperty.call(w,c)&&a(m,w,c);return r(m,w),m},i=Me&&Me.__rest||function(w,m){var c={};for(var f in w)Object.prototype.hasOwnProperty.call(w,f)&&m.indexOf(f)<0&&(c[f]=w[f]);if(w!=null&&typeof Object.getOwnPropertySymbols=="function")for(var T=0,f=Object.getOwnPropertySymbols(w);T<f.length;T++)m.indexOf(f[T])<0&&Object.prototype.propertyIsEnumerable.call(w,f[T])&&(c[f[T]]=w[f[T]]);return c},d=Me&&Me.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(Me,"__esModule",{value:!0});var u=s(l),b=d(oi()),h=s(rs());function p(w){return w&&w.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function y(w){var m=document.createTextNode("");w.appendChild(m);var c=document.activeElement===w;if(m!==null&&m.nodeValue!==null&&c){var f=window.getSelection();if(f!==null){var T=document.createRange();T.setStart(m,m.nodeValue.length),T.collapse(!0),f.removeAllRanges(),f.addRange(T)}w instanceof HTMLElement&&w.focus()}}var v=(function(w){t(m,w);function m(){var c=w!==null&&w.apply(this,arguments)||this;return c.lastHtml=c.props.html,c.el=typeof c.props.innerRef=="function"?{current:null}:u.createRef(),c.getEl=function(){return(c.props.innerRef&&typeof c.props.innerRef!="function"?c.props.innerRef:c.el).current},c.emitChange=function(f){var T=c.getEl();if(T){var C=T.innerHTML;if(c.props.onChange&&C!==c.lastHtml){var S=Object.assign({},f,{target:{value:C}});c.props.onChange(S)}c.lastHtml=C}},c}return m.prototype.render=function(){var c=this,f=this.props,T=f.tagName,C=f.html,S=f.innerRef,j=i(f,["tagName","html","innerRef"]);return u.createElement(T||"div",n(n({},j),{ref:typeof S=="function"?function(g){S(g),c.el.current=g}:S||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:C}}),this.props.children)},m.prototype.shouldComponentUpdate=function(c){var f=this.props,T=this.getEl();return!T||p(c.html)!==p(T.innerHTML)?!0:f.disabled!==c.disabled||f.tagName!==c.tagName||f.className!==c.className||f.innerRef!==c.innerRef||f.placeholder!==c.placeholder||!(0,b.default)(f.style,c.style)},m.prototype.componentDidUpdate=function(){var c=this.getEl();c&&(this.props.html!==c.innerHTML&&(c.innerHTML=this.props.html),this.lastHtml=this.props.html,y(c))},m.propTypes={html:h.string.isRequired,onChange:h.func,disabled:h.bool,tagName:h.string,className:h.string,style:h.object,innerRef:h.oneOfType([h.object,h.func])},m})(u.Component);return Me.default=v,Me}var mi=fi();const hi=ts(mi),yi={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},gi={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"},z=l.forwardRef(({style:t,onFocus:n,onBlur:a,...r},s)=>{const[i,d]=l.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:yi,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:s,onFocus:u=>{d(!0),n?.(u)},onBlur:u=>{d(!1),a?.(u)},style:{...gi,borderBottom:`1px solid ${i?"#222":"#d9d9d9"}`,...t||{}}})]})}),Ka=[{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 ss(t){const n=ye().year(),a=[];for(let r=n;r>=n-t;r--)a.push({label:String(r),value:r});return a}function _t(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 os(t){const n=ye().year(),a=ye().month();return t<n?Ka:Ka.slice(0,a+1)}function xi(){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 is=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(o.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(o.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(o.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""}},dt=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 Bt={},Nt={},Je={},$t={},Ct={},Ja;function bi(){if(Ja)return Ct;Ja=1;var t=Ct&&Ct.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ct,"__esModule",{value:!0});const n=t(l),a=gs,r=["string","number","boolean"];function s({header:i,body:d}){const u=n.default.createElement("tr",null,i.map(h=>n.default.createElement("th",{key:h},h))),b=d.map((h,p)=>Array.isArray(h)?n.default.createElement("tr",{key:p},h.map((y,v)=>n.default.createElement("th",{key:v}," ",y," "))):h!==null&&typeof h=="object"?n.default.createElement("tr",{key:p},Object.entries(h).map(([y,v],w)=>typeof v=="object"?(console.error(`typeof ${y} 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,v)))):(console.error(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("antd"),H=require("swr"),i=require("react"),Ke=require("swr/mutation"),se=require("@ant-design/icons"),fe=require("dayjs"),xi=require("react-dom/server"),gn=require("react-to-print"),v=require("react-hot-toast"),As=require("react-select"),Is=require("react-barcode"),bi=()=>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."})]}),ue=({width:t,height:n,display:a,justifyContent:s,alignItems:o,flexDirection:l,gap:d,style:u,children:b,...g})=>{const p={width:t,height:n,display:a,justifyContent:s,alignItems:o,flexDirection:l,gap:d,...u};return e.jsx("div",{style:p,...g,children:b})},Pe=({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 Rs({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(ue,{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(ue,{style:{padding:"0 12px"},children:e.jsx(r.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(ue,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(Pe,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function Ds(t,n){return function(){return t.apply(n,arguments)}}const{toString:Si}=Object.prototype,{getPrototypeOf:oa}=Object,{iterator:la,toStringTag:Os}=Symbol,da=(t=>n=>{const a=Si.call(n);return t[a]||(t[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),ct=t=>(t=t.toLowerCase(),n=>da(n)===t),ca=t=>n=>typeof n===t,{isArray:Kt}=Array,Wt=ca("undefined");function xn(t){return t!==null&&!Wt(t)&&t.constructor!==null&&!Wt(t.constructor)&&Xe(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Ps=ct("ArrayBuffer");function ji(t){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(t):n=t&&t.buffer&&Ps(t.buffer),n}const wi=ca("string"),Xe=ca("function"),Es=ca("number"),bn=t=>t!==null&&typeof t=="object",vi=t=>t===!0||t===!1,Yn=t=>{if(da(t)!=="object")return!1;const n=oa(t);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Os in t)&&!(la in t)},_i=t=>{if(!bn(t)||xn(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Ci=ct("Date"),Ti=ct("File"),Ai=t=>!!(t&&typeof t.uri<"u"),Ii=t=>t&&typeof t.getParts<"u",Ri=ct("Blob"),Di=ct("FileList"),Oi=t=>bn(t)&&Xe(t.pipe);function Pi(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const tr=Pi(),nr=typeof tr.FormData<"u"?tr.FormData:void 0,Ei=t=>{if(!t)return!1;if(nr&&t instanceof nr)return!0;const n=oa(t);if(!n||n===Object.prototype||!Xe(t.append))return!1;const a=da(t);return a==="formdata"||a==="object"&&Xe(t.toString)&&t.toString()==="[object FormData]"},Fi=ct("URLSearchParams"),[ki,Mi,$i,Ui]=["ReadableStream","Request","Response","Headers"].map(ct),Bi=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Sn(t,n,{allOwnKeys:a=!1}={}){if(t===null||typeof t>"u")return;let s,o;if(typeof t!="object"&&(t=[t]),Kt(t))for(s=0,o=t.length;s<o;s++)n.call(null,t[s],s,t);else{if(xn(t))return;const l=a?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let u;for(s=0;s<d;s++)u=l[s],n.call(null,t[u],u,t)}}function Fs(t,n){if(xn(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 It=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ks=t=>!Wt(t)&&t!==It;function Ba(){const{caseless:t,skipUndefined:n}=ks(this)&&this||{},a={},s=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&Fs(a,l)||l;Yn(a[d])&&Yn(o)?a[d]=Ba(a[d],o):Yn(o)?a[d]=Ba({},o):Kt(o)?a[d]=o.slice():(!n||!Wt(o))&&(a[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&Sn(arguments[o],s);return a}const Ni=(t,n,a,{allOwnKeys:s}={})=>(Sn(n,(o,l)=>{a&&Xe(o)?Object.defineProperty(t,l,{value:Ds(o,a),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),t),qi=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Li=(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)},zi=(t,n,a,s)=>{let o,l,d;const u={};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))&&!u[d]&&(n[d]=t[d],u[d]=!0);t=a!==!1&&oa(t)}while(t&&(!a||a(t,n))&&t!==Object.prototype);return n},Vi=(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},Yi=t=>{if(!t)return null;if(Kt(t))return t;let n=t.length;if(!Es(n))return null;const a=new Array(n);for(;n-- >0;)a[n]=t[n];return a},Wi=(t=>n=>t&&n instanceof t)(typeof Uint8Array<"u"&&oa(Uint8Array)),Hi=(t,n)=>{const s=(t&&t[la]).call(t);let o;for(;(o=s.next())&&!o.done;){const l=o.value;n.call(t,l[0],l[1])}},Ki=(t,n)=>{let a;const s=[];for(;(a=t.exec(n))!==null;)s.push(a);return s},Gi=ct("HTMLFormElement"),Ji=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,s,o){return s.toUpperCase()+o}),ar=(({hasOwnProperty:t})=>(n,a)=>t.call(n,a))(Object.prototype),Qi=ct("RegExp"),Ms=(t,n)=>{const a=Object.getOwnPropertyDescriptors(t),s={};Sn(a,(o,l)=>{let d;(d=n(o,l,t))!==!1&&(s[l]=d||o)}),Object.defineProperties(t,s)},Xi=t=>{Ms(t,(n,a)=>{if(Xe(t)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const s=t[a];if(Xe(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+"'")})}})},Zi=(t,n)=>{const a={},s=o=>{o.forEach(l=>{a[l]=!0})};return Kt(t)?s(t):s(String(t).split(n)),a},eo=()=>{},to=(t,n)=>t!=null&&Number.isFinite(t=+t)?t:n;function no(t){return!!(t&&Xe(t.append)&&t[Os]==="FormData"&&t[la])}const ao=t=>{const n=new Array(10),a=(s,o)=>{if(bn(s)){if(n.indexOf(s)>=0)return;if(xn(s))return s;if(!("toJSON"in s)){n[o]=s;const l=Kt(s)?[]:{};return Sn(s,(d,u)=>{const b=a(d,o+1);!Wt(b)&&(l[u]=b)}),n[o]=void 0,l}}return s};return a(t,0)},ro=ct("AsyncFunction"),so=t=>t&&(bn(t)||Xe(t))&&Xe(t.then)&&Xe(t.catch),$s=((t,n)=>t?setImmediate:n?((a,s)=>(It.addEventListener("message",({source:o,data:l})=>{o===It&&l===a&&s.length&&s.shift()()},!1),o=>{s.push(o),It.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",Xe(It.postMessage)),io=typeof queueMicrotask<"u"?queueMicrotask.bind(It):typeof process<"u"&&process.nextTick||$s,oo=t=>t!=null&&Xe(t[la]),Y={isArray:Kt,isArrayBuffer:Ps,isBuffer:xn,isFormData:Ei,isArrayBufferView:ji,isString:wi,isNumber:Es,isBoolean:vi,isObject:bn,isPlainObject:Yn,isEmptyObject:_i,isReadableStream:ki,isRequest:Mi,isResponse:$i,isHeaders:Ui,isUndefined:Wt,isDate:Ci,isFile:Ti,isReactNativeBlob:Ai,isReactNative:Ii,isBlob:Ri,isRegExp:Qi,isFunction:Xe,isStream:Oi,isURLSearchParams:Fi,isTypedArray:Wi,isFileList:Di,forEach:Sn,merge:Ba,extend:Ni,trim:Bi,stripBOM:qi,inherits:Li,toFlatObject:zi,kindOf:da,kindOfTest:ct,endsWith:Vi,toArray:Yi,forEachEntry:Hi,matchAll:Ki,isHTMLForm:Gi,hasOwnProperty:ar,hasOwnProp:ar,reduceDescriptors:Ms,freezeMethods:Xi,toObjectSet:Zi,toCamelCase:Ji,noop:eo,toFiniteNumber:to,findKey:Fs,global:It,isContextDefined:ks,isSpecCompliantForm:no,toJSONObject:ao,isAsyncFn:ro,isThenable:so,setImmediate:$s,asap:io,isIterable:oo};let Se=class Us extends Error{static from(n,a,s,o,l,d){const u=new Us(n.message,a||n.code,s,o,l);return u.cause=n,u.name=n.name,n.status!=null&&u.status==null&&(u.status=n.status),d&&Object.assign(u,d),u}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:Y.toJSONObject(this.config),code:this.code,status:this.status}}};Se.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Se.ERR_BAD_OPTION="ERR_BAD_OPTION";Se.ECONNABORTED="ECONNABORTED";Se.ETIMEDOUT="ETIMEDOUT";Se.ERR_NETWORK="ERR_NETWORK";Se.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Se.ERR_DEPRECATED="ERR_DEPRECATED";Se.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Se.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Se.ERR_CANCELED="ERR_CANCELED";Se.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Se.ERR_INVALID_URL="ERR_INVALID_URL";Se.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const lo=null;function Na(t){return Y.isPlainObject(t)||Y.isArray(t)}function Bs(t){return Y.endsWith(t,"[]")?t.slice(0,-2):t}function xa(t,n,a){return t?t.concat(n).map(function(o,l){return o=Bs(o),!a&&l?"["+o+"]":o}).join(a?".":""):n}function co(t){return Y.isArray(t)&&!t.some(Na)}const uo=Y.toFlatObject(Y,{},null,function(n){return/^is[A-Z]/.test(n)});function ua(t,n,a){if(!Y.isObject(t))throw new TypeError("target must be an object");n=n||new FormData,a=Y.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,P){return!Y.isUndefined(P[y])});const s=a.metaTokens,o=a.visitor||j,l=a.dots,d=a.indexes,u=a.Blob||typeof Blob<"u"&&Blob,b=a.maxDepth===void 0?100:a.maxDepth,g=u&&Y.isSpecCompliantForm(n);if(!Y.isFunction(o))throw new TypeError("visitor must be a function");function p(c){if(c===null)return"";if(Y.isDate(c))return c.toISOString();if(Y.isBoolean(c))return c.toString();if(!g&&Y.isBlob(c))throw new Se("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(c)||Y.isTypedArray(c)?g&&typeof Blob=="function"?new Blob([c]):Buffer.from(c):c}function j(c,y,P){let R=c;if(Y.isReactNative(n)&&Y.isReactNativeBlob(c))return n.append(xa(P,y,l),p(c)),!1;if(c&&!P&&typeof c=="object"){if(Y.endsWith(y,"{}"))y=s?y:y.slice(0,-2),c=JSON.stringify(c);else if(Y.isArray(c)&&co(c)||(Y.isFileList(c)||Y.endsWith(y,"[]"))&&(R=Y.toArray(c)))return y=Bs(y),R.forEach(function(C,h){!(Y.isUndefined(C)||C===null)&&n.append(d===!0?xa([y],h,l):d===null?y:y+"[]",p(C))}),!1}return Na(c)?!0:(n.append(xa(P,y,l),p(c)),!1)}const I=[],A=Object.assign(uo,{defaultVisitor:j,convertValue:p,isVisitable:Na});function m(c,y,P=0){if(!Y.isUndefined(c)){if(P>b)throw new Se("Object is too deeply nested ("+P+" levels). Max depth: "+b,Se.ERR_FORM_DATA_DEPTH_EXCEEDED);if(I.indexOf(c)!==-1)throw Error("Circular reference detected in "+y.join("."));I.push(c),Y.forEach(c,function(D,C){(!(Y.isUndefined(D)||D===null)&&o.call(n,D,Y.isString(C)?C.trim():C,y,A))===!0&&m(D,y?y.concat(C):[C],P+1)}),I.pop()}}if(!Y.isObject(t))throw new TypeError("data must be an object");return m(t),n}function rr(t){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(s){return n[s]})}function Ya(t,n){this._pairs=[],t&&ua(t,this,n)}const Ns=Ya.prototype;Ns.append=function(n,a){this._pairs.push([n,a])};Ns.toString=function(n){const a=n?function(s){return n.call(this,s,rr)}:rr;return this._pairs.map(function(o){return a(o[0])+"="+a(o[1])},"").join("&")};function po(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function qs(t,n,a){if(!n)return t;const s=a&&a.encode||po,o=Y.isFunction(a)?{serialize:a}:a,l=o&&o.serialize;let d;if(l?d=l(n,o):d=Y.isURLSearchParams(n)?n.toString():new Ya(n,o).toString(s),d){const u=t.indexOf("#");u!==-1&&(t=t.slice(0,u)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class sr{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){Y.forEach(this.handlers,function(s){s!==null&&n(s)})}}const Wa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},mo=typeof URLSearchParams<"u"?URLSearchParams:Ya,fo=typeof FormData<"u"?FormData:null,yo=typeof Blob<"u"?Blob:null,ho={isBrowser:!0,classes:{URLSearchParams:mo,FormData:fo,Blob:yo},protocols:["http","https","file","blob","url","data"]},Ha=typeof window<"u"&&typeof document<"u",qa=typeof navigator=="object"&&navigator||void 0,go=Ha&&(!qa||["ReactNative","NativeScript","NS"].indexOf(qa.product)<0),xo=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",bo=Ha&&window.location.href||"http://localhost",So=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ha,hasStandardBrowserEnv:go,hasStandardBrowserWebWorkerEnv:xo,navigator:qa,origin:bo},Symbol.toStringTag,{value:"Module"})),Ye={...So,...ho};function jo(t,n){return ua(t,new Ye.classes.URLSearchParams,{visitor:function(a,s,o,l){return Ye.isNode&&Y.isBuffer(a)?(this.append(s,a.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...n})}function wo(t){return Y.matchAll(/\w+|\[(\w*)]/g,t).map(n=>n[0]==="[]"?"":n[1]||n[0])}function vo(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 Ls(t){function n(a,s,o,l){let d=a[l++];if(d==="__proto__")return!0;const u=Number.isFinite(+d),b=l>=a.length;return d=!d&&Y.isArray(o)?o.length:d,b?(Y.hasOwnProp(o,d)?o[d]=Y.isArray(o[d])?o[d].concat(s):[o[d],s]:o[d]=s,!u):((!o[d]||!Y.isObject(o[d]))&&(o[d]=[]),n(a,s,o[d],l)&&Y.isArray(o[d])&&(o[d]=vo(o[d])),!u)}if(Y.isFormData(t)&&Y.isFunction(t.entries)){const a={};return Y.forEachEntry(t,(s,o)=>{n(wo(s),o,a,0)}),a}return null}const $t=(t,n)=>t!=null&&Y.hasOwnProp(t,n)?t[n]:void 0;function _o(t,n,a){if(Y.isString(t))try{return(n||JSON.parse)(t),Y.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(a||JSON.stringify)(t)}const jn={transitional:Wa,adapter:["xhr","http","fetch"],transformRequest:[function(n,a){const s=a.getContentType()||"",o=s.indexOf("application/json")>-1,l=Y.isObject(n);if(l&&Y.isHTMLForm(n)&&(n=new FormData(n)),Y.isFormData(n))return o?JSON.stringify(Ls(n)):n;if(Y.isArrayBuffer(n)||Y.isBuffer(n)||Y.isStream(n)||Y.isFile(n)||Y.isBlob(n)||Y.isReadableStream(n))return n;if(Y.isArrayBufferView(n))return n.buffer;if(Y.isURLSearchParams(n))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let u;if(l){const b=$t(this,"formSerializer");if(s.indexOf("application/x-www-form-urlencoded")>-1)return jo(n,b).toString();if((u=Y.isFileList(n))||s.indexOf("multipart/form-data")>-1){const g=$t(this,"env"),p=g&&g.FormData;return ua(u?{"files[]":n}:n,p&&new p,b)}}return l||o?(a.setContentType("application/json",!1),_o(n)):n}],transformResponse:[function(n){const a=$t(this,"transitional")||jn.transitional,s=a&&a.forcedJSONParsing,o=$t(this,"responseType"),l=o==="json";if(Y.isResponse(n)||Y.isReadableStream(n))return n;if(n&&Y.isString(n)&&(s&&!o||l)){const u=!(a&&a.silentJSONParsing)&&l;try{return JSON.parse(n,$t(this,"parseReviver"))}catch(b){if(u)throw b.name==="SyntaxError"?Se.from(b,Se.ERR_BAD_RESPONSE,this,null,$t(this,"response")):b}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ye.classes.FormData,Blob:Ye.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],t=>{jn.headers[t]={}});const Co=Y.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"]),To=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(),s=d.substring(o+1).trim(),!(!a||n[a]&&Co[a])&&(a==="set-cookie"?n[a]?n[a].push(s):n[a]=[s]:n[a]=n[a]?n[a]+", "+s:s)}),n},ir=Symbol("internals"),Ao=/[^\x09\x20-\x7E\x80-\xFF]/g;function Io(t){let n=0,a=t.length;for(;n<a;){const s=t.charCodeAt(n);if(s!==9&&s!==32)break;n+=1}for(;a>n;){const s=t.charCodeAt(a-1);if(s!==9&&s!==32)break;a-=1}return n===0&&a===t.length?t:t.slice(n,a)}function Xt(t){return t&&String(t).trim().toLowerCase()}function Ro(t){return Io(t.replace(Ao,""))}function Wn(t){return t===!1||t==null?t:Y.isArray(t)?t.map(Wn):Ro(String(t))}function Do(t){const n=Object.create(null),a=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=a.exec(t);)n[s[1]]=s[2];return n}const Oo=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function ba(t,n,a,s,o){if(Y.isFunction(s))return s.call(this,n,a);if(o&&(n=a),!!Y.isString(n)){if(Y.isString(s))return n.indexOf(s)!==-1;if(Y.isRegExp(s))return s.test(n)}}function Po(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,a,s)=>a.toUpperCase()+s)}function Eo(t,n){const a=Y.toCamelCase(" "+n);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+a,{value:function(o,l,d){return this[s].call(this,n,o,l,d)},configurable:!0})})}let Ze=class{constructor(n){n&&this.set(n)}set(n,a,s){const o=this;function l(u,b,g){const p=Xt(b);if(!p)throw new Error("header name must be a non-empty string");const j=Y.findKey(o,p);(!j||o[j]===void 0||g===!0||g===void 0&&o[j]!==!1)&&(o[j||b]=Wn(u))}const d=(u,b)=>Y.forEach(u,(g,p)=>l(g,p,b));if(Y.isPlainObject(n)||n instanceof this.constructor)d(n,a);else if(Y.isString(n)&&(n=n.trim())&&!Oo(n))d(To(n),a);else if(Y.isObject(n)&&Y.isIterable(n)){let u={},b,g;for(const p of n){if(!Y.isArray(p))throw TypeError("Object iterator must return a key-value pair");u[g=p[0]]=(b=u[g])?Y.isArray(b)?[...b,p[1]]:[b,p[1]]:p[1]}d(u,a)}else n!=null&&l(a,n,s);return this}get(n,a){if(n=Xt(n),n){const s=Y.findKey(this,n);if(s){const o=this[s];if(!a)return o;if(a===!0)return Do(o);if(Y.isFunction(a))return a.call(this,o,s);if(Y.isRegExp(a))return a.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,a){if(n=Xt(n),n){const s=Y.findKey(this,n);return!!(s&&this[s]!==void 0&&(!a||ba(this,this[s],s,a)))}return!1}delete(n,a){const s=this;let o=!1;function l(d){if(d=Xt(d),d){const u=Y.findKey(s,d);u&&(!a||ba(s,s[u],u,a))&&(delete s[u],o=!0)}}return Y.isArray(n)?n.forEach(l):l(n),o}clear(n){const a=Object.keys(this);let s=a.length,o=!1;for(;s--;){const l=a[s];(!n||ba(this,this[l],l,n,!0))&&(delete this[l],o=!0)}return o}normalize(n){const a=this,s={};return Y.forEach(this,(o,l)=>{const d=Y.findKey(s,l);if(d){a[d]=Wn(o),delete a[l];return}const u=n?Po(l):String(l).trim();u!==l&&delete a[l],a[u]=Wn(o),s[u]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const a=Object.create(null);return Y.forEach(this,(s,o)=>{s!=null&&s!==!1&&(a[o]=n&&Y.isArray(s)?s.join(", "):s)}),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 s=new this(n);return a.forEach(o=>s.set(o)),s}static accessor(n){const s=(this[ir]=this[ir]={accessors:{}}).accessors,o=this.prototype;function l(d){const u=Xt(d);s[u]||(Eo(o,d),s[u]=!0)}return Y.isArray(n)?n.forEach(l):l(n),this}};Ze.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Y.reduceDescriptors(Ze.prototype,({value:t},n)=>{let a=n[0].toUpperCase()+n.slice(1);return{get:()=>t,set(s){this[a]=s}}});Y.freezeMethods(Ze);function Sa(t,n){const a=this||jn,s=n||a,o=Ze.from(s.headers);let l=s.data;return Y.forEach(t,function(u){l=u.call(a,l,o.normalize(),n?n.status:void 0)}),o.normalize(),l}function zs(t){return!!(t&&t.__CANCEL__)}let wn=class extends Se{constructor(n,a,s){super(n??"canceled",Se.ERR_CANCELED,a,s),this.name="CanceledError",this.__CANCEL__=!0}};function Vs(t,n,a){const s=a.config.validateStatus;!a.status||!s||s(a.status)?t(a):n(new Se("Request failed with status code "+a.status,[Se.ERR_BAD_REQUEST,Se.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function Fo(t){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return n&&n[1]||""}function ko(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(b){const g=Date.now(),p=s[l];d||(d=g),a[o]=b,s[o]=g;let j=l,I=0;for(;j!==o;)I+=a[j++],j=j%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),g-d<n)return;const A=p&&g-p;return A?Math.round(I*1e3/A):void 0}}function Mo(t,n){let a=0,s=1e3/n,o,l;const d=(g,p=Date.now())=>{a=p,o=null,l&&(clearTimeout(l),l=null),t(...g)};return[(...g)=>{const p=Date.now(),j=p-a;j>=s?d(g,p):(o=g,l||(l=setTimeout(()=>{l=null,d(o)},s-j)))},()=>o&&d(o)]}const ia=(t,n,a=3)=>{let s=0;const o=ko(50,250);return Mo(l=>{const d=l.loaded,u=l.lengthComputable?l.total:void 0,b=u!=null?Math.min(d,u):d,g=Math.max(0,b-s),p=o(g);s=Math.max(s,b);const j={loaded:b,total:u,progress:u?b/u:void 0,bytes:g,rate:p||void 0,estimated:p&&u?(u-b)/p:void 0,event:l,lengthComputable:u!=null,[n?"download":"upload"]:!0};t(j)},a)},or=(t,n)=>{const a=t!=null;return[s=>n[0]({lengthComputable:a,total:t,loaded:s}),n[1]]},lr=t=>(...n)=>Y.asap(()=>t(...n)),$o=Ye.hasStandardBrowserEnv?((t,n)=>a=>(a=new URL(a,Ye.origin),t.protocol===a.protocol&&t.host===a.host&&(n||t.port===a.port)))(new URL(Ye.origin),Ye.navigator&&/(msie|trident)/i.test(Ye.navigator.userAgent)):()=>!0,Uo=Ye.hasStandardBrowserEnv?{write(t,n,a,s,o,l,d){if(typeof document>"u")return;const u=[`${t}=${encodeURIComponent(n)}`];Y.isNumber(a)&&u.push(`expires=${new Date(a).toUTCString()}`),Y.isString(s)&&u.push(`path=${s}`),Y.isString(o)&&u.push(`domain=${o}`),l===!0&&u.push("secure"),Y.isString(d)&&u.push(`SameSite=${d}`),document.cookie=u.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 Bo(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function No(t,n){return n?t.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):t}function Ys(t,n,a){let s=!Bo(n);return t&&(s||a===!1)?No(t,n):n}const dr=t=>t instanceof Ze?{...t}:t;function Pt(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(g,p,j,I){return Y.isPlainObject(g)&&Y.isPlainObject(p)?Y.merge.call({caseless:I},g,p):Y.isPlainObject(p)?Y.merge({},p):Y.isArray(p)?p.slice():p}function o(g,p,j,I){if(Y.isUndefined(p)){if(!Y.isUndefined(g))return s(void 0,g,j,I)}else return s(g,p,j,I)}function l(g,p){if(!Y.isUndefined(p))return s(void 0,p)}function d(g,p){if(Y.isUndefined(p)){if(!Y.isUndefined(g))return s(void 0,g)}else return s(void 0,p)}function u(g,p,j){if(Y.hasOwnProp(n,j))return s(g,p);if(Y.hasOwnProp(t,j))return s(void 0,g)}const b={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:u,headers:(g,p,j)=>o(dr(g),dr(p),j,!0)};return Y.forEach(Object.keys({...t,...n}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const j=Y.hasOwnProp(b,p)?b[p]:o,I=Y.hasOwnProp(t,p)?t[p]:void 0,A=Y.hasOwnProp(n,p)?n[p]:void 0,m=j(I,A,p);Y.isUndefined(m)&&j!==u||(a[p]=m)}),a}const Ws=t=>{const n=Pt({},t),a=I=>Y.hasOwnProp(n,I)?n[I]:void 0,s=a("data");let o=a("withXSRFToken");const l=a("xsrfHeaderName"),d=a("xsrfCookieName");let u=a("headers");const b=a("auth"),g=a("baseURL"),p=a("allowAbsoluteUrls"),j=a("url");if(n.headers=u=Ze.from(u),n.url=qs(Ys(g,j,p),t.params,t.paramsSerializer),b&&u.set("Authorization","Basic "+btoa((b.username||"")+":"+(b.password?unescape(encodeURIComponent(b.password)):""))),Y.isFormData(s)){if(Ye.hasStandardBrowserEnv||Ye.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if(Y.isFunction(s.getHeaders)){const I=s.getHeaders(),A=["content-type","content-length"];Object.entries(I).forEach(([m,c])=>{A.includes(m.toLowerCase())&&u.set(m,c)})}}if(Ye.hasStandardBrowserEnv&&(Y.isFunction(o)&&(o=o(n)),o===!0||o==null&&$o(n.url))){const A=l&&d&&Uo.read(d);A&&u.set(l,A)}return n},qo=typeof XMLHttpRequest<"u",Lo=qo&&function(t){return new Promise(function(a,s){const o=Ws(t);let l=o.data;const d=Ze.from(o.headers).normalize();let{responseType:u,onUploadProgress:b,onDownloadProgress:g}=o,p,j,I,A,m;function c(){A&&A(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(p),o.signal&&o.signal.removeEventListener("abort",p)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function P(){if(!y)return;const D=Ze.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),h={data:!u||u==="text"||u==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:D,config:t,request:y};Vs(function(x){a(x),c()},function(x){s(x),c()},h),y=null}"onloadend"in y?y.onloadend=P:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(P)},y.onabort=function(){y&&(s(new Se("Request aborted",Se.ECONNABORTED,t,y)),y=null)},y.onerror=function(C){const h=C&&C.message?C.message:"Network Error",f=new Se(h,Se.ERR_NETWORK,t,y);f.event=C||null,s(f),y=null},y.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const h=o.transitional||Wa;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),s(new Se(C,h.clarifyTimeoutError?Se.ETIMEDOUT:Se.ECONNABORTED,t,y)),y=null},l===void 0&&d.setContentType(null),"setRequestHeader"in y&&Y.forEach(d.toJSON(),function(C,h){y.setRequestHeader(h,C)}),Y.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),u&&u!=="json"&&(y.responseType=o.responseType),g&&([I,m]=ia(g,!0),y.addEventListener("progress",I)),b&&y.upload&&([j,A]=ia(b),y.upload.addEventListener("progress",j),y.upload.addEventListener("loadend",A)),(o.cancelToken||o.signal)&&(p=D=>{y&&(s(!D||D.type?new wn(null,t,y):D),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(p),o.signal&&(o.signal.aborted?p():o.signal.addEventListener("abort",p)));const R=Fo(o.url);if(R&&Ye.protocols.indexOf(R)===-1){s(new Se("Unsupported protocol "+R+":",Se.ERR_BAD_REQUEST,t));return}y.send(l||null)})},zo=(t,n)=>{const{length:a}=t=t?t.filter(Boolean):[];if(n||a){let s=new AbortController,o;const l=function(g){if(!o){o=!0,u();const p=g instanceof Error?g:this.reason;s.abort(p instanceof Se?p:new wn(p instanceof Error?p.message:p))}};let d=n&&setTimeout(()=>{d=null,l(new Se(`timeout of ${n}ms exceeded`,Se.ETIMEDOUT))},n);const u=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(g=>{g.unsubscribe?g.unsubscribe(l):g.removeEventListener("abort",l)}),t=null)};t.forEach(g=>g.addEventListener("abort",l));const{signal:b}=s;return b.unsubscribe=()=>Y.asap(u),b}},Vo=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},Yo=async function*(t,n){for await(const a of Wo(t))yield*Vo(a,n)},Wo=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()}},cr=(t,n,a,s)=>{const o=Yo(t,n);let l=0,d,u=b=>{d||(d=!0,s&&s(b))};return new ReadableStream({async pull(b){try{const{done:g,value:p}=await o.next();if(g){u(),b.close();return}let j=p.byteLength;if(a){let I=l+=j;a(I)}b.enqueue(new Uint8Array(p))}catch(g){throw u(g),g}},cancel(b){return u(b),o.return()}},{highWaterMark:2})},ur=64*1024,{isFunction:Rn}=Y,Ho=(({Request:t,Response:n})=>({Request:t,Response:n}))(Y.global),{ReadableStream:pr,TextEncoder:mr}=Y.global,fr=(t,...n)=>{try{return!!t(...n)}catch{return!1}},Ko=t=>{t=Y.merge.call({skipUndefined:!0},Ho,t);const{fetch:n,Request:a,Response:s}=t,o=n?Rn(n):typeof fetch=="function",l=Rn(a),d=Rn(s);if(!o)return!1;const u=o&&Rn(pr),b=o&&(typeof mr=="function"?(m=>c=>m.encode(c))(new mr):async m=>new Uint8Array(await new a(m).arrayBuffer())),g=l&&u&&fr(()=>{let m=!1;const c=new a(Ye.origin,{body:new pr,method:"POST",get duplex(){return m=!0,"half"}}),y=c.headers.has("Content-Type");return c.body!=null&&c.body.cancel(),m&&!y}),p=d&&u&&fr(()=>Y.isReadableStream(new s("").body)),j={stream:p&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!j[m]&&(j[m]=(c,y)=>{let P=c&&c[m];if(P)return P.call(c);throw new Se(`Response type '${m}' is not supported`,Se.ERR_NOT_SUPPORT,y)})});const I=async m=>{if(m==null)return 0;if(Y.isBlob(m))return m.size;if(Y.isSpecCompliantForm(m))return(await new a(Ye.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(Y.isArrayBufferView(m)||Y.isArrayBuffer(m))return m.byteLength;if(Y.isURLSearchParams(m)&&(m=m+""),Y.isString(m))return(await b(m)).byteLength},A=async(m,c)=>{const y=Y.toFiniteNumber(m.getContentLength());return y??I(c)};return async m=>{let{url:c,method:y,data:P,signal:R,cancelToken:D,timeout:C,onDownloadProgress:h,onUploadProgress:f,responseType:x,headers:_,withCredentials:O="same-origin",fetchOptions:z}=Ws(m),B=n||fetch;x=x?(x+"").toLowerCase():"text";let w=zo([R,D&&D.toAbortSignal()],C),F=null;const E=w&&w.unsubscribe&&(()=>{w.unsubscribe()});let U;try{if(f&&g&&y!=="get"&&y!=="head"&&(U=await A(_,P))!==0){let S=new a(c,{method:"POST",body:P,duplex:"half"}),$;if(Y.isFormData(P)&&($=S.headers.get("content-type"))&&_.setContentType($),S.body){const[M,L]=or(U,ia(lr(f)));P=cr(S.body,ur,M,L)}}Y.isString(O)||(O=O?"include":"omit");const k=l&&"credentials"in a.prototype;if(Y.isFormData(P)){const S=_.getContentType();S&&/^multipart\/form-data/i.test(S)&&!/boundary=/i.test(S)&&_.delete("content-type")}const N={...z,signal:w,method:y.toUpperCase(),headers:_.normalize().toJSON(),body:P,duplex:"half",credentials:k?O:void 0};F=l&&new a(c,N);let V=await(l?B(F,z):B(c,N));const q=p&&(x==="stream"||x==="response");if(p&&(h||q&&E)){const S={};["status","statusText","headers"].forEach(ee=>{S[ee]=V[ee]});const $=Y.toFiniteNumber(V.headers.get("content-length")),[M,L]=h&&or($,ia(lr(h),!0))||[];V=new s(cr(V.body,ur,M,()=>{L&&L(),E&&E()}),S)}x=x||"text";let T=await j[Y.findKey(j,x)||"text"](V,m);return!q&&E&&E(),await new Promise((S,$)=>{Vs(S,$,{data:T,headers:Ze.from(V.headers),status:V.status,statusText:V.statusText,config:m,request:F})})}catch(k){throw E&&E(),k&&k.name==="TypeError"&&/Load failed|fetch/i.test(k.message)?Object.assign(new Se("Network Error",Se.ERR_NETWORK,m,F,k&&k.response),{cause:k.cause||k}):Se.from(k,k&&k.code,m,F,k&&k.response)}}},Go=new Map,Hs=t=>{let n=t&&t.env||{};const{fetch:a,Request:s,Response:o}=n,l=[s,o,a];let d=l.length,u=d,b,g,p=Go;for(;u--;)b=l[u],g=p.get(b),g===void 0&&p.set(b,g=u?new Map:Ko(n)),p=g;return g};Hs();const Ka={http:lo,xhr:Lo,fetch:{get:Hs}};Y.forEach(Ka,(t,n)=>{if(t){try{Object.defineProperty(t,"name",{value:n})}catch{}Object.defineProperty(t,"adapterName",{value:n})}});const yr=t=>`- ${t}`,Jo=t=>Y.isFunction(t)||t===null||t===!1;function Qo(t,n){t=Y.isArray(t)?t:[t];const{length:a}=t;let s,o;const l={};for(let d=0;d<a;d++){s=t[d];let u;if(o=s,!Jo(s)&&(o=Ka[(u=String(s)).toLowerCase()],o===void 0))throw new Se(`Unknown adapter '${u}'`);if(o&&(Y.isFunction(o)||(o=o.get(n))))break;l[u||"#"+d]=o}if(!o){const d=Object.entries(l).map(([b,g])=>`adapter ${b} `+(g===!1?"is not supported by the environment":"is not available in the build"));let u=a?d.length>1?`since :
|
|
4
|
+
`+d.map(yr).join(`
|
|
5
|
+
`):" "+yr(d[0]):"as no adapter specified";throw new Se("There is no suitable adapter to dispatch the request "+u,"ERR_NOT_SUPPORT")}return o}const Ks={getAdapter:Qo,adapters:Ka};function ja(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new wn(null,t)}function hr(t){return ja(t),t.headers=Ze.from(t.headers),t.data=Sa.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Ks.getAdapter(t.adapter||jn.adapter,t)(t).then(function(s){return ja(t),s.data=Sa.call(t,t.transformResponse,s),s.headers=Ze.from(s.headers),s},function(s){return zs(s)||(ja(t),s&&s.response&&(s.response.data=Sa.call(t,t.transformResponse,s.response),s.response.headers=Ze.from(s.response.headers))),Promise.reject(s)})}const Gs="1.15.2",pa={};["object","boolean","number","function","string","symbol"].forEach((t,n)=>{pa[t]=function(s){return typeof s===t||"a"+(n<1?"n ":" ")+t}});const gr={};pa.transitional=function(n,a,s){function o(l,d){return"[Axios v"+Gs+"] Transitional option '"+l+"'"+d+(s?". "+s:"")}return(l,d,u)=>{if(n===!1)throw new Se(o(d," has been removed"+(a?" in "+a:"")),Se.ERR_DEPRECATED);return a&&!gr[d]&&(gr[d]=!0,console.warn(o(d," has been deprecated since v"+a+" and will be removed in the near future"))),n?n(l,d,u):!0}};pa.spelling=function(n){return(a,s)=>(console.warn(`${s} is likely a misspelling of ${n}`),!0)};function Xo(t,n,a){if(typeof t!="object")throw new Se("options must be an object",Se.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let o=s.length;for(;o-- >0;){const l=s[o],d=Object.prototype.hasOwnProperty.call(n,l)?n[l]:void 0;if(d){const u=t[l],b=u===void 0||d(u,l,t);if(b!==!0)throw new Se("option "+l+" must be "+b,Se.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new Se("Unknown option "+l,Se.ERR_BAD_OPTION)}}const Hn={assertOptions:Xo,validators:pa},st=Hn.validators;let Rt=class{constructor(n){this.defaults=n||{},this.interceptors={request:new sr,response:new sr}}async request(n,a){try{return await this._request(n,a)}catch(s){if(s 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(!s.stack)s.stack=l;else if(l){const d=l.indexOf(`
|
|
7
|
+
`),u=d===-1?-1:l.indexOf(`
|
|
8
|
+
`,d+1),b=u===-1?"":l.slice(u+1);String(s.stack).endsWith(b)||(s.stack+=`
|
|
9
|
+
`+l)}}catch{}}throw s}}_request(n,a){typeof n=="string"?(a=a||{},a.url=n):a=n||{},a=Pt(this.defaults,a);const{transitional:s,paramsSerializer:o,headers:l}=a;s!==void 0&&Hn.assertOptions(s,{silentJSONParsing:st.transitional(st.boolean),forcedJSONParsing:st.transitional(st.boolean),clarifyTimeoutError:st.transitional(st.boolean),legacyInterceptorReqResOrdering:st.transitional(st.boolean)},!1),o!=null&&(Y.isFunction(o)?a.paramsSerializer={serialize:o}:Hn.assertOptions(o,{encode:st.function,serialize:st.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),Hn.assertOptions(a,{baseUrl:st.spelling("baseURL"),withXsrfToken:st.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let d=l&&Y.merge(l.common,l[a.method]);l&&Y.forEach(["delete","get","head","post","put","patch","common"],m=>{delete l[m]}),a.headers=Ze.concat(d,l);const u=[];let b=!0;this.interceptors.request.forEach(function(c){if(typeof c.runWhen=="function"&&c.runWhen(a)===!1)return;b=b&&c.synchronous;const y=a.transitional||Wa;y&&y.legacyInterceptorReqResOrdering?u.unshift(c.fulfilled,c.rejected):u.push(c.fulfilled,c.rejected)});const g=[];this.interceptors.response.forEach(function(c){g.push(c.fulfilled,c.rejected)});let p,j=0,I;if(!b){const m=[hr.bind(this),void 0];for(m.unshift(...u),m.push(...g),I=m.length,p=Promise.resolve(a);j<I;)p=p.then(m[j++],m[j++]);return p}I=u.length;let A=a;for(;j<I;){const m=u[j++],c=u[j++];try{A=m(A)}catch(y){c.call(this,y);break}}try{p=hr.call(this,A)}catch(m){return Promise.reject(m)}for(j=0,I=g.length;j<I;)p=p.then(g[j++],g[j++]);return p}getUri(n){n=Pt(this.defaults,n);const a=Ys(n.baseURL,n.url,n.allowAbsoluteUrls);return qs(a,n.params,n.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(n){Rt.prototype[n]=function(a,s){return this.request(Pt(s||{},{method:n,url:a,data:(s||{}).data}))}});Y.forEach(["post","put","patch"],function(n){function a(s){return function(l,d,u){return this.request(Pt(u||{},{method:n,headers:s?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Rt.prototype[n]=a(),Rt.prototype[n+"Form"]=a(!0)});let Zo=class Js{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(u=>{s.subscribe(u),l=u}).then(o);return d.cancel=function(){s.unsubscribe(l)},d},n(function(l,d,u){s.reason||(s.reason=new wn(l,d,u),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 Js(function(o){n=o}),cancel:n}}};function el(t){return function(a){return t.apply(null,a)}}function tl(t){return Y.isObject(t)&&t.isAxiosError===!0}const La={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(La).forEach(([t,n])=>{La[n]=t});function Qs(t){const n=new Rt(t),a=Ds(Rt.prototype.request,n);return Y.extend(a,Rt.prototype,n,{allOwnKeys:!0}),Y.extend(a,n,null,{allOwnKeys:!0}),a.create=function(o){return Qs(Pt(t,o))},a}const ke=Qs(jn);ke.Axios=Rt;ke.CanceledError=wn;ke.CancelToken=Zo;ke.isCancel=zs;ke.VERSION=Gs;ke.toFormData=ua;ke.AxiosError=Se;ke.Cancel=ke.CanceledError;ke.all=function(n){return Promise.all(n)};ke.spread=el;ke.isAxiosError=tl;ke.mergeConfig=Pt;ke.AxiosHeaders=Ze;ke.formToJSON=t=>Ls(Y.isHTMLForm(t)?new FormData(t):t);ke.getAdapter=Ks.getAdapter;ke.HttpStatusCode=La;ke.default=ke;const{Axios:Lp,AxiosError:zp,CanceledError:Vp,isCancel:Yp,CancelToken:Wp,VERSION:Hp,all:Kp,Cancel:Gp,isAxiosError:Jp,spread:Qp,toFormData:Xp,AxiosHeaders:Zp,HttpStatusCode:em,formToJSON:tm,getAdapter:nm,mergeConfig:am}=ke,nl=()=>new Promise(t=>setTimeout(()=>t(),800));let za=null;const al=t=>{za=t,ft.defaults.baseURL=Ga()},Ga=()=>za||"https://npmapi.ubkerp.com/",ft=ke.create({baseURL:Ga()}),ot=()=>Ga(),We=async(t,n,a)=>{const s=await ft.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)},G=async(t,n)=>{try{let s=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";s=`${t}${l}session_id=1`}return(await ft.get(s,{headers:{Authorization:n}})).data}catch(a){throw a.response?.status===401&&console.error("401 Unauthorized"),a}},rl=async(t,n)=>{const a=await ft.post(t,"",{headers:{Authorization:n}});if(a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},Ja=async(t,n,a)=>(await ft.post(t,n,{headers:{Authorization:a}}))?.data,wa=async(t,n,a)=>{const s=n?.arg;return(await ft.post(t,s,{headers:{Authorization:a}}))?.data},Dt=async(t,n,a)=>{const s=n?.arg,o=t.includes("?")?"&":"?";return(await ft.get(t+o,{params:s,headers:{Authorization:a}}))?.data},sl="/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Qa=async(t,n,a)=>{const s=n?.arg,o=t.includes("?")?"&":"?";return(await ft.get(t+o,{params:s,headers:{Authorization:a}}))?.data},ut=async(t,n,a)=>(await nl(),(await ft.post(t,n,{headers:{Authorization:a}}))?.data),nt=async(t,n,a)=>(await ft.delete(`${t}/${n}`,{headers:{Authorization:a}})).data,il=({token:t,menu:n})=>{const{isLoading:a,data:s}=H(t?["api/sdk/Menus",t]:null,([l,d])=>rl(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(ue,{children:e.jsx(Rs,{icon:`${ot()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function Xs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ne={},va,xr;function ol(){return xr||(xr=1,va=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}),va}var Dn={exports:{}},On={exports:{}},Ie={};var br;function ll(){if(br)return Ie;br=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,u=t?Symbol.for("react.context"):60110,b=t?Symbol.for("react.async_mode"):60111,g=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,j=t?Symbol.for("react.suspense"):60113,I=t?Symbol.for("react.suspense_list"):60120,A=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,c=t?Symbol.for("react.block"):60121,y=t?Symbol.for("react.fundamental"):60117,P=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function D(h){if(typeof h=="object"&&h!==null){var f=h.$$typeof;switch(f){case n:switch(h=h.type,h){case b:case g:case s:case l:case o:case j:return h;default:switch(h=h&&h.$$typeof,h){case u:case p:case m:case A:case d:return h;default:return f}}case a:return f}}}function C(h){return D(h)===g}return Ie.AsyncMode=b,Ie.ConcurrentMode=g,Ie.ContextConsumer=u,Ie.ContextProvider=d,Ie.Element=n,Ie.ForwardRef=p,Ie.Fragment=s,Ie.Lazy=m,Ie.Memo=A,Ie.Portal=a,Ie.Profiler=l,Ie.StrictMode=o,Ie.Suspense=j,Ie.isAsyncMode=function(h){return C(h)||D(h)===b},Ie.isConcurrentMode=C,Ie.isContextConsumer=function(h){return D(h)===u},Ie.isContextProvider=function(h){return D(h)===d},Ie.isElement=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===n},Ie.isForwardRef=function(h){return D(h)===p},Ie.isFragment=function(h){return D(h)===s},Ie.isLazy=function(h){return D(h)===m},Ie.isMemo=function(h){return D(h)===A},Ie.isPortal=function(h){return D(h)===a},Ie.isProfiler=function(h){return D(h)===l},Ie.isStrictMode=function(h){return D(h)===o},Ie.isSuspense=function(h){return D(h)===j},Ie.isValidElementType=function(h){return typeof h=="string"||typeof h=="function"||h===s||h===g||h===l||h===o||h===j||h===I||typeof h=="object"&&h!==null&&(h.$$typeof===m||h.$$typeof===A||h.$$typeof===d||h.$$typeof===u||h.$$typeof===p||h.$$typeof===y||h.$$typeof===P||h.$$typeof===R||h.$$typeof===c)},Ie.typeOf=D,Ie}var Re={};var Sr;function dl(){return Sr||(Sr=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,u=t?Symbol.for("react.context"):60110,b=t?Symbol.for("react.async_mode"):60111,g=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,j=t?Symbol.for("react.suspense"):60113,I=t?Symbol.for("react.suspense_list"):60120,A=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,c=t?Symbol.for("react.block"):60121,y=t?Symbol.for("react.fundamental"):60117,P=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function D(ae){return typeof ae=="string"||typeof ae=="function"||ae===s||ae===g||ae===l||ae===o||ae===j||ae===I||typeof ae=="object"&&ae!==null&&(ae.$$typeof===m||ae.$$typeof===A||ae.$$typeof===d||ae.$$typeof===u||ae.$$typeof===p||ae.$$typeof===y||ae.$$typeof===P||ae.$$typeof===R||ae.$$typeof===c)}function C(ae){if(typeof ae=="object"&&ae!==null){var re=ae.$$typeof;switch(re){case n:var X=ae.type;switch(X){case b:case g:case s:case l:case o:case j:return X;default:var xe=X&&X.$$typeof;switch(xe){case u:case p:case m:case A:case d:return xe;default:return re}}case a:return re}}}var h=b,f=g,x=u,_=d,O=n,z=p,B=s,w=m,F=A,E=a,U=l,k=o,N=j,V=!1;function q(ae){return V||(V=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),T(ae)||C(ae)===b}function T(ae){return C(ae)===g}function S(ae){return C(ae)===u}function $(ae){return C(ae)===d}function M(ae){return typeof ae=="object"&&ae!==null&&ae.$$typeof===n}function L(ae){return C(ae)===p}function ee(ae){return C(ae)===s}function W(ae){return C(ae)===m}function K(ae){return C(ae)===A}function Q(ae){return C(ae)===a}function ne(ae){return C(ae)===l}function le(ae){return C(ae)===o}function je(ae){return C(ae)===j}Re.AsyncMode=h,Re.ConcurrentMode=f,Re.ContextConsumer=x,Re.ContextProvider=_,Re.Element=O,Re.ForwardRef=z,Re.Fragment=B,Re.Lazy=w,Re.Memo=F,Re.Portal=E,Re.Profiler=U,Re.StrictMode=k,Re.Suspense=N,Re.isAsyncMode=q,Re.isConcurrentMode=T,Re.isContextConsumer=S,Re.isContextProvider=$,Re.isElement=M,Re.isForwardRef=L,Re.isFragment=ee,Re.isLazy=W,Re.isMemo=K,Re.isPortal=Q,Re.isProfiler=ne,Re.isStrictMode=le,Re.isSuspense=je,Re.isValidElementType=D,Re.typeOf=C})()),Re}var jr;function Zs(){return jr||(jr=1,process.env.NODE_ENV==="production"?On.exports=ll():On.exports=dl()),On.exports}var _a,wr;function cl(){if(wr)return _a;wr=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={},u=0;u<10;u++)d["_"+String.fromCharCode(u)]=u;var b=Object.getOwnPropertyNames(d).map(function(p){return d[p]});if(b.join("")!=="0123456789")return!1;var g={};return"abcdefghijklmnopqrst".split("").forEach(function(p){g[p]=p}),Object.keys(Object.assign({},g)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return _a=o()?Object.assign:function(l,d){for(var u,b=s(l),g,p=1;p<arguments.length;p++){u=Object(arguments[p]);for(var j in u)n.call(u,j)&&(b[j]=u[j]);if(t){g=t(u);for(var I=0;I<g.length;I++)a.call(u,g[I])&&(b[g[I]]=u[g[I]])}}return b},_a}var Ca,vr;function Xa(){if(vr)return Ca;vr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Ca=t,Ca}var Ta,_r;function ei(){return _r||(_r=1,Ta=Function.call.bind(Object.prototype.hasOwnProperty)),Ta}var Aa,Cr;function ul(){if(Cr)return Aa;Cr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=Xa(),a={},s=ei();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,u,b,g){if(process.env.NODE_ENV!=="production"){for(var p in l)if(s(l,p)){var j;try{if(typeof l[p]!="function"){var I=Error((b||"React class")+": "+u+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw I.name="Invariant Violation",I}j=l[p](d,p,b,u,null,n)}catch(m){j=m}if(j&&!(j instanceof Error)&&t((b||"React class")+": type specification of "+u+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof j+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),j instanceof Error&&!(j.message in a)){a[j.message]=!0;var A=g?g():"";t("Failed "+u+" type: "+j.message+(A??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(a={})},Aa=o,Aa}var Ia,Tr;function pl(){if(Tr)return Ia;Tr=1;var t=Zs(),n=cl(),a=Xa(),s=ei(),o=ul(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(u){var b="Warning: "+u;typeof console<"u"&&console.error(b);try{throw new Error(b)}catch{}});function d(){return null}return Ia=function(u,b){var g=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function j(T){var S=T&&(g&&T[g]||T[p]);if(typeof S=="function")return S}var I="<<anonymous>>",A={array:P("array"),bigint:P("bigint"),bool:P("boolean"),func:P("function"),number:P("number"),object:P("object"),string:P("string"),symbol:P("symbol"),any:R(),arrayOf:D,element:C(),elementType:h(),instanceOf:f,node:z(),objectOf:_,oneOf:x,oneOfType:O,shape:w,exact:F};function m(T,S){return T===S?T!==0||1/T===1/S:T!==T&&S!==S}function c(T,S){this.message=T,this.data=S&&typeof S=="object"?S:{},this.stack=""}c.prototype=Error.prototype;function y(T){if(process.env.NODE_ENV!=="production")var S={},$=0;function M(ee,W,K,Q,ne,le,je){if(Q=Q||I,le=le||K,je!==a){if(b){var ae=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 ae.name="Invariant Violation",ae}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var re=Q+":"+K;!S[re]&&$<3&&(l("You are manually calling a React.PropTypes validation function for the `"+le+"` prop on `"+Q+"`. 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."),S[re]=!0,$++)}}return W[K]==null?ee?W[K]===null?new c("The "+ne+" `"+le+"` is marked as required "+("in `"+Q+"`, but its value is `null`.")):new c("The "+ne+" `"+le+"` is marked as required in "+("`"+Q+"`, but its value is `undefined`.")):null:T(W,K,Q,ne,le)}var L=M.bind(null,!1);return L.isRequired=M.bind(null,!0),L}function P(T){function S($,M,L,ee,W,K){var Q=$[M],ne=k(Q);if(ne!==T){var le=N(Q);return new c("Invalid "+ee+" `"+W+"` of type "+("`"+le+"` supplied to `"+L+"`, expected ")+("`"+T+"`."),{expectedType:T})}return null}return y(S)}function R(){return y(d)}function D(T){function S($,M,L,ee,W){if(typeof T!="function")return new c("Property `"+W+"` of component `"+L+"` has invalid PropType notation inside arrayOf.");var K=$[M];if(!Array.isArray(K)){var Q=k(K);return new c("Invalid "+ee+" `"+W+"` of type "+("`"+Q+"` supplied to `"+L+"`, expected an array."))}for(var ne=0;ne<K.length;ne++){var le=T(K,ne,L,ee,W+"["+ne+"]",a);if(le instanceof Error)return le}return null}return y(S)}function C(){function T(S,$,M,L,ee){var W=S[$];if(!u(W)){var K=k(W);return new c("Invalid "+L+" `"+ee+"` of type "+("`"+K+"` supplied to `"+M+"`, expected a single ReactElement."))}return null}return y(T)}function h(){function T(S,$,M,L,ee){var W=S[$];if(!t.isValidElementType(W)){var K=k(W);return new c("Invalid "+L+" `"+ee+"` of type "+("`"+K+"` supplied to `"+M+"`, expected a single ReactElement type."))}return null}return y(T)}function f(T){function S($,M,L,ee,W){if(!($[M]instanceof T)){var K=T.name||I,Q=q($[M]);return new c("Invalid "+ee+" `"+W+"` of type "+("`"+Q+"` supplied to `"+L+"`, expected ")+("instance of `"+K+"`."))}return null}return y(S)}function x(T){if(!Array.isArray(T))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 S($,M,L,ee,W){for(var K=$[M],Q=0;Q<T.length;Q++)if(m(K,T[Q]))return null;var ne=JSON.stringify(T,function(je,ae){var re=N(ae);return re==="symbol"?String(ae):ae});return new c("Invalid "+ee+" `"+W+"` of value `"+String(K)+"` "+("supplied to `"+L+"`, expected one of "+ne+"."))}return y(S)}function _(T){function S($,M,L,ee,W){if(typeof T!="function")return new c("Property `"+W+"` of component `"+L+"` has invalid PropType notation inside objectOf.");var K=$[M],Q=k(K);if(Q!=="object")return new c("Invalid "+ee+" `"+W+"` of type "+("`"+Q+"` supplied to `"+L+"`, expected an object."));for(var ne in K)if(s(K,ne)){var le=T(K,ne,L,ee,W+"."+ne,a);if(le instanceof Error)return le}return null}return y(S)}function O(T){if(!Array.isArray(T))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var S=0;S<T.length;S++){var $=T[S];if(typeof $!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+V($)+" at index "+S+"."),d}function M(L,ee,W,K,Q){for(var ne=[],le=0;le<T.length;le++){var je=T[le],ae=je(L,ee,W,K,Q,a);if(ae==null)return null;ae.data&&s(ae.data,"expectedType")&&ne.push(ae.data.expectedType)}var re=ne.length>0?", expected one of type ["+ne.join(", ")+"]":"";return new c("Invalid "+K+" `"+Q+"` supplied to "+("`"+W+"`"+re+"."))}return y(M)}function z(){function T(S,$,M,L,ee){return E(S[$])?null:new c("Invalid "+L+" `"+ee+"` supplied to "+("`"+M+"`, expected a ReactNode."))}return y(T)}function B(T,S,$,M,L){return new c((T||"React class")+": "+S+" type `"+$+"."+M+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+L+"`.")}function w(T){function S($,M,L,ee,W){var K=$[M],Q=k(K);if(Q!=="object")return new c("Invalid "+ee+" `"+W+"` of type `"+Q+"` "+("supplied to `"+L+"`, expected `object`."));for(var ne in T){var le=T[ne];if(typeof le!="function")return B(L,ee,W,ne,N(le));var je=le(K,ne,L,ee,W+"."+ne,a);if(je)return je}return null}return y(S)}function F(T){function S($,M,L,ee,W){var K=$[M],Q=k(K);if(Q!=="object")return new c("Invalid "+ee+" `"+W+"` of type `"+Q+"` "+("supplied to `"+L+"`, expected `object`."));var ne=n({},$[M],T);for(var le in ne){var je=T[le];if(s(T,le)&&typeof je!="function")return B(L,ee,W,le,N(je));if(!je)return new c("Invalid "+ee+" `"+W+"` key `"+le+"` supplied to `"+L+"`.\nBad object: "+JSON.stringify($[M],null," ")+`
|
|
10
|
+
Valid keys: `+JSON.stringify(Object.keys(T),null," "));var ae=je(K,le,L,ee,W+"."+le,a);if(ae)return ae}return null}return y(S)}function E(T){switch(typeof T){case"number":case"string":case"undefined":return!0;case"boolean":return!T;case"object":if(Array.isArray(T))return T.every(E);if(T===null||u(T))return!0;var S=j(T);if(S){var $=S.call(T),M;if(S!==T.entries){for(;!(M=$.next()).done;)if(!E(M.value))return!1}else for(;!(M=$.next()).done;){var L=M.value;if(L&&!E(L[1]))return!1}}else return!1;return!0;default:return!1}}function U(T,S){return T==="symbol"?!0:S?S["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&S instanceof Symbol:!1}function k(T){var S=typeof T;return Array.isArray(T)?"array":T instanceof RegExp?"object":U(S,T)?"symbol":S}function N(T){if(typeof T>"u"||T===null)return""+T;var S=k(T);if(S==="object"){if(T instanceof Date)return"date";if(T instanceof RegExp)return"regexp"}return S}function V(T){var S=N(T);switch(S){case"array":case"object":return"an "+S;case"boolean":case"date":case"regexp":return"a "+S;default:return S}}function q(T){return!T.constructor||!T.constructor.name?I:T.constructor.name}return A.checkPropTypes=o,A.resetWarningCache=o.resetWarningCache,A.PropTypes=A,A},Ia}var Ra,Ar;function ml(){if(Ar)return Ra;Ar=1;var t=Xa();function n(){}function a(){}return a.resetWarningCache=n,Ra=function(){function s(d,u,b,g,p,j){if(j!==t){var I=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 I.name="Invariant Violation",I}}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},Ra}var Ir;function ti(){if(Ir)return Dn.exports;if(Ir=1,process.env.NODE_ENV!=="production"){var t=Zs(),n=!0;Dn.exports=pl()(t.isElement,n)}else Dn.exports=ml()();return Dn.exports}var Rr;function fl(){if(Rr)return Ne;Rr=1;var t=Ne&&Ne.__extends||(function(){var A=function(m,c){return A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,P){y.__proto__=P}||function(y,P){for(var R in P)Object.prototype.hasOwnProperty.call(P,R)&&(y[R]=P[R])},A(m,c)};return function(m,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");A(m,c);function y(){this.constructor=m}m.prototype=c===null?Object.create(c):(y.prototype=c.prototype,new y)}})(),n=Ne&&Ne.__assign||function(){return n=Object.assign||function(A){for(var m,c=1,y=arguments.length;c<y;c++){m=arguments[c];for(var P in m)Object.prototype.hasOwnProperty.call(m,P)&&(A[P]=m[P])}return A},n.apply(this,arguments)},a=Ne&&Ne.__createBinding||(Object.create?(function(A,m,c,y){y===void 0&&(y=c);var P=Object.getOwnPropertyDescriptor(m,c);(!P||("get"in P?!m.__esModule:P.writable||P.configurable))&&(P={enumerable:!0,get:function(){return m[c]}}),Object.defineProperty(A,y,P)}):(function(A,m,c,y){y===void 0&&(y=c),A[y]=m[c]})),s=Ne&&Ne.__setModuleDefault||(Object.create?(function(A,m){Object.defineProperty(A,"default",{enumerable:!0,value:m})}):function(A,m){A.default=m}),o=Ne&&Ne.__importStar||function(A){if(A&&A.__esModule)return A;var m={};if(A!=null)for(var c in A)c!=="default"&&Object.prototype.hasOwnProperty.call(A,c)&&a(m,A,c);return s(m,A),m},l=Ne&&Ne.__rest||function(A,m){var c={};for(var y in A)Object.prototype.hasOwnProperty.call(A,y)&&m.indexOf(y)<0&&(c[y]=A[y]);if(A!=null&&typeof Object.getOwnPropertySymbols=="function")for(var P=0,y=Object.getOwnPropertySymbols(A);P<y.length;P++)m.indexOf(y[P])<0&&Object.prototype.propertyIsEnumerable.call(A,y[P])&&(c[y[P]]=A[y[P]]);return c},d=Ne&&Ne.__importDefault||function(A){return A&&A.__esModule?A:{default:A}};Object.defineProperty(Ne,"__esModule",{value:!0});var u=o(i),b=d(ol()),g=o(ti());function p(A){return A&&A.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function j(A){var m=document.createTextNode("");A.appendChild(m);var c=document.activeElement===A;if(m!==null&&m.nodeValue!==null&&c){var y=window.getSelection();if(y!==null){var P=document.createRange();P.setStart(m,m.nodeValue.length),P.collapse(!0),y.removeAllRanges(),y.addRange(P)}A instanceof HTMLElement&&A.focus()}}var I=(function(A){t(m,A);function m(){var c=A!==null&&A.apply(this,arguments)||this;return c.lastHtml=c.props.html,c.el=typeof c.props.innerRef=="function"?{current:null}:u.createRef(),c.getEl=function(){return(c.props.innerRef&&typeof c.props.innerRef!="function"?c.props.innerRef:c.el).current},c.emitChange=function(y){var P=c.getEl();if(P){var R=P.innerHTML;if(c.props.onChange&&R!==c.lastHtml){var D=Object.assign({},y,{target:{value:R}});c.props.onChange(D)}c.lastHtml=R}},c}return m.prototype.render=function(){var c=this,y=this.props,P=y.tagName,R=y.html,D=y.innerRef,C=l(y,["tagName","html","innerRef"]);return u.createElement(P||"div",n(n({},C),{ref:typeof D=="function"?function(h){D(h),c.el.current=h}: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(c){var y=this.props,P=this.getEl();return!P||p(c.html)!==p(P.innerHTML)?!0:y.disabled!==c.disabled||y.tagName!==c.tagName||y.className!==c.className||y.innerRef!==c.innerRef||y.placeholder!==c.placeholder||!(0,b.default)(y.style,c.style)},m.prototype.componentDidUpdate=function(){var c=this.getEl();c&&(this.props.html!==c.innerHTML&&(c.innerHTML=this.props.html),this.lastHtml=this.props.html,j(c))},m.propTypes={html:g.string.isRequired,onChange:g.func,disabled:g.bool,tagName:g.string,className:g.string,style:g.object,innerRef:g.oneOfType([g.object,g.func])},m})(u.Component);return Ne.default=I,Ne}var yl=fl();const hl=Xs(yl),gl={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},xl={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"},Z=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:gl,children:s.label}),e.jsx("input",{placeholder:s.placeholder||s.label,...s,ref:o,onFocus:u=>{d(!0),n?.(u)},onBlur:u=>{d(!1),a?.(u)},style:{...xl,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),Dr=[{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 ni(t){const n=fe().year(),a=[];for(let s=n;s>=n-t;s--)a.push({label:String(s),value:s});return a}function Ut(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 ai(t){const n=fe().year(),a=fe().month();return t<n?Dr:Dr.slice(0,a+1)}function bl(){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 ri=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""}},mt=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 Zt={},en={},tt={},tn={},Bt={},Or;function Sl(){if(Or)return Bt;Or=1;var t=Bt&&Bt.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Bt,"__esModule",{value:!0});const n=t(i),a=xi,s=["string","number","boolean"];function o({header:l,body:d}){const u=n.default.createElement("tr",null,l.map(g=>n.default.createElement("th",{key:g},g))),b=d.map((g,p)=>Array.isArray(g)?n.default.createElement("tr",{key:p},g.map((j,I)=>n.default.createElement("th",{key:I}," ",j," "))):g!==null&&typeof g=="object"?n.default.createElement("tr",{key:p},Object.entries(g).map(([j,I],A)=>typeof I=="object"?(console.error(`typeof ${j} is incorrect, only accept ${s.join(", ")} `),n.default.createElement("th",{key:A})):n.default.createElement("th",{key:A},n.default.createElement(n.default.Fragment,null,I)))):(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,u,b)))}return Ct.default=s,Ct}var Ga;function Si(){return Ga||(Ga=1,(function(t){var n=$t&&$t.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(t,"__esModule",{value:!0}),t.createTable=t.template=t.uri=t.format=t.base64=void 0;function a(i){return window.btoa(unescape(encodeURIComponent(i)))}t.base64=a;function r(i,d){return i.replace(/{(\w+)}/g,(u,b)=>d[b])}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 s=bi();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return n(s).default}})})($t)),$t}var Qa;function ls(){if(Qa)return Je;Qa=1;var t=Je&&Je.__createBinding||(Object.create?(function(h,p,y,v){v===void 0&&(v=y);var w=Object.getOwnPropertyDescriptor(p,y);(!w||("get"in w?!p.__esModule:w.writable||w.configurable))&&(w={enumerable:!0,get:function(){return p[y]}}),Object.defineProperty(h,v,w)}):(function(h,p,y,v){v===void 0&&(v=y),h[v]=p[y]})),n=Je&&Je.__setModuleDefault||(Object.create?(function(h,p){Object.defineProperty(h,"default",{enumerable:!0,value:p})}):function(h,p){h.default=p}),a=Je&&Je.__importStar||function(h){if(h&&h.__esModule)return h;var p={};if(h!=null)for(var y in h)y!=="default"&&Object.prototype.hasOwnProperty.call(h,y)&&t(p,h,y);return n(p,h),p};Object.defineProperty(Je,"__esModule",{value:!0}),Je.downloadExcel=Je.excel=void 0;const r=a(Si());function s(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function i(h,p){const y=window.document.createElement("a");return y.href=r.uri+r.base64(r.format(r.template,p)),y.download=h,document.body.appendChild(y),y.click(),document.body.removeChild(y),!0}function d(h,p){if(h)return h.cloneNode(!0).outerHTML;if(p)return r.createTable(p);console.error("currentTableRef or tablePayload does not exist")}function u({fileName:h,sheet:p,tablePayload:y},v){if(!s())return!1;const w=d(v,y);return i(h,{worksheet:p||"Worksheet",table:w})}Je.downloadExcel=u;function b({currentTableRef:h,filename:p,sheet:y}){function v(){if(!s())return!1;const w=d(h),m=`${p}.xls`;return i(m,{worksheet:y||"Worksheet",table:w})}return{onDownload:v}}return Je.excel=b,Je}var Xa;function ji(){if(Xa)return Nt;Xa=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.useDownloadExcel=void 0;const t=l,n=ls();function a({currentTableRef:r,filename:s,sheet:i}){const[d,u]=(0,t.useState)({});return(0,t.useEffect)(()=>{u({currentTableRef:r,filename:s,sheet:i})},[r,s,i]),(0,t.useMemo)(()=>(0,n.excel)(d),[d])}return Nt.useDownloadExcel=a,Nt}var Za;function wi(){return Za||(Za=1,(function(t){var n=Bt&&Bt.__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(l),r=ji();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const s=ls();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return s.downloadExcel}});const i=({currentTableRef:d,filename:u,sheet:b,children:h})=>{const{onDownload:p}=(0,r.useDownloadExcel)({currentTableRef:d,filename:u,sheet:b});return a.default.createElement("span",{onClick:p},h)};t.DownloadTableExcel=i})(Bt)),Bt}var ds=wi();const En=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:n}=t.data;t?.tableRef;const a=new Date().getTime(),r=Vt.useReactToPrint({content:()=>n.current});return e.jsx(e.Fragment,{children:e.jsx(o.Row,{justify:"end",children:e.jsx(o.Col,{children:e.jsxs(o.Row,{gutter:8,children:[e.jsx(o.Col,{children:e.jsx(o.Button,{type:"text",icon:e.jsx(ce.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(o.Col,{children:e.jsx(ds.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:n.current,children:e.jsx(o.Button,{type:"text",icon:e.jsx(ce.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},Gt=t=>{const{tableRef:n}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(o.Row,{justify:"center",children:e.jsx(o.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},vi=l.createContext(),_i=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Ee=t=>{const{columns:n,action:a,DrawerUpdate:r,editDesign:s,newData:i,Loading:d,error:u,deleteTodoMutation:b,open:h,ActionView:p,viewDetails:y,myType:v,type:w,urlkey:m,columnstype:c,rowSelection:f}=t.data,T=_i(),[C,S]=l.useState(!1),[j,g]=l.useState(null),[_,P]=l.useState("false"),[I,O]=l.useState(!1),[k,E]=l.useState(!1),[D,F]=l.useState(),[V,Z]=l.useState(""),U=()=>S(!1),Y=N=>{P(N),S(!0)},[W,L]=l.useState(),[x,R]=l.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),$=l.useRef(null),q=(N,G)=>{t.parentCallback?.(N,G),R({rowsPerPage:G,page:N})},Q=(N,G)=>{g(G),O(!0),F(N)},ue=(N,G)=>{g(G),E(!0),F(N)},se=t?.data?.onNavigate??t?.onNavigate,pe=(N,G)=>{if(typeof se=="function"){se(N,G);return}typeof window<"u"&&typeof N=="string"&&N.length>0&&window.location.assign(N)},B=N=>{if(w==="staff"){pe(`/HumanResourceDashboard/StaffFullInformation?id=${N.fk_staffID}`,N);return}pe(`/StudentInformation/StudentFullInformation?id=${N.id}`,N)},H=(N,G)=>{L(N),r?.(G)},ie=async(N,G,re,we)=>{r?.(!0),re!==""&&((await we({id:N,admission_no:G,ec_no:re}))?.Status==="Success"?o.message.success("Ec No updated successfully"):o.message.error("Failed to Update Ec No."))},je=()=>e.jsx(vi.Provider,{value:W,children:s}),{trigger:K}=ze("branchapi/staff/updateStaffPassword",qn),{trigger:ve}=ze("branchapi/Student/updateEcNo",qn),{trigger:Pe}=ze(m,(N,G)=>qn("student/studentDetails/editStudentLogInCredential",G)),ke=async N=>{N.preventDefault(),O(!1);try{(await K({staff_id:D,new_passwod:N.target.password.value}))?.Status==="Success"?o.message.success("Password updated successfully"):o.message.error("Failed to update password")}catch{o.message.error("Failed to update password")}},rt=async N=>{N.preventDefault(),E(!1);try{(await Pe({edit_id:j?.edit_id,new_passwod:N.target.password.value,username:N.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?o.message.success("Password updated successfully"):o.message.error("Failed to update password")}catch(G){o.message.error(G?.response?.data?.msg??"Failed to update password")}},st=(Array.isArray(n)?n:[]).some(N=>N?.fixed==="left"),Qe=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:c==="antd"&&st?"left":void 0,sorter:(N,G)=>(N.__serialNumber??0)-(G.__serialNumber??0),render:N=>N},...c==="antd"?n:(Array.isArray(n)?n:[]).map(N=>({title:N.name,dataIndex:N.selector,key:N.selector,sorter:N.sorter||(N.sortable?(G,re)=>{const we=G[N.selector]??"",_e=re[N.selector]??"";return typeof we=="number"&&typeof _e=="number"?we-_e:String(we).localeCompare(String(_e))}:!1),render:(G,re)=>{switch(N.selector){case"my_staff":return re.staff_id!=="0"?re.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(o.Image,{width:50,src:`undefined/branch/gallery/${re.gallery_cat_logo}`});case"file01":return re.documents?e.jsx("div",{onClick:()=>Y(`undefined/branch/frontoffice/${re.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 dt(G);case"full_name":return e.jsx("span",{onClick:()=>B(re),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:G||`${re.firstname} ${re.lastname}`});case"extra_curricular_activity":return G==="Yes"?"Extra Subject":"Fees Master";case"is_active":return G==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return re?.current_status==="Active"?e.jsx(o.Progress,{percent:re.steps==="1"?30:re.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:re?.current_status});case"Password":return e.jsx("span",{onClick:()=>Q(re.id,re),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>ue(re.id,re),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(o.Tag,{onClick:()=>y?.(re.id),color:G==="paid"?"#66aa18":G==="partially_paid"?"#ff5722":"#DC143C",children:G==="paid"?"Paid":G==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return xi().find(we=>we.value===G)?.label;case"status":return e.jsx("span",{onClick:()=>y?.(re?.fk_staffID,re?.total_leave),className:`label ${G==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:G==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[re.is_theory==="yes"&&"Theory, ",re.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(hi,{html:re.ec_no,onBlur:we=>ie(re.id,re.admission_no,we.target.innerHTML,ve)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(o.Button,{type:"primary",icon:e.jsx(ce.SendOutlined,{}),size:"small",onClick:()=>H(re.id,!0,N.name),children:N.name});case"Button":return e.jsx(o.Tag,{color:"cyan",onClick:()=>y?.(re),children:N.name});default:return G}}})),...a?[{title:"Action",key:"action",render:(N,G)=>{const re=G?.current_status==="Promoted",we=()=>{if(v=="sameAddUpdate"){H(G,!0);return}if(v?.type==="examEdit"){v.editFunc(G.id);return}H(G.id||G,!0)},_e=()=>{if(v==="student_result"){y?.(G);return}if(v==="student"){y?.(G.id,G.class_id);return}y?.(G.id)},lt=()=>{b?.(G?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[p?.[0]?.status&&e.jsx(o.Button,{icon:e.jsx(ce.EditOutlined,{}),size:"small",disabled:re,onClick:we}),p?.[1]?.status&&e.jsx(o.Button,{icon:e.jsx(ce.DeleteOutlined,{}),size:"small",danger:!0,disabled:re,onClick:lt}),p?.[2]?.status&&e.jsx(o.Button,{icon:e.jsx(ce.EyeOutlined,{}),size:"small",onClick:_e})]})}}]:[]],He=l.useMemo(()=>i?Array.isArray(i?.data)?i.data:Array.isArray(i)?i:[]:[],[i]),Ue=l.useMemo(()=>{const N=V.trim().toLowerCase();return N?He.filter(G=>Object.values(G??{}).some(re=>String(re??"").toLowerCase().includes(N))):He},[He,V]),Ke=!!t.parentCallback,Be=V?Ue.length:i?.pagination?.total_rows??Ue.length,Oe=(x.page-1)*x.rowsPerPage,Fe=Ke?Ue:Ue.slice(Oe,Oe+x.rowsPerPage),ot=l.useMemo(()=>(Fe??[]).map((N,G)=>({...N??{},__serialNumber:Oe+G+1})),[Oe,Fe]),ae=Be===0?0:Math.min(Oe+1,Be),de=Be===0?0:Math.min(Oe+Fe.length,Be);let oe;return d?oe=e.jsx("p",{children:"Loading..."}):u?oe=e.jsx("p",{children:u.message}):Fe.length?oe=e.jsx(o.Table,{dataSource:ot,columns:Qe,size:"small",bordered:!0,pagination:!1,rowSelection:f,rowKey:(N,G)=>N?.id??N?._id??G,scroll:{x:"max-content"}}):oe=e.jsx(o.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(o.Drawer,{open:h,placement:"right",onClose:()=>r?.(!1),width:720,children:je()}),e.jsx(o.Modal,{title:"Update Password",open:I,onCancel:()=>O(!1),footer:null,children:e.jsx("form",{onSubmit:ke,children:e.jsxs(ne,{children:[e.jsx(ne,{style:{marginBottom:12},children:e.jsx(z,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(ne,{style:{marginTop:16},children:e.jsx(o.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(o.Modal,{title:" Update Credential",open:k,onCancel:()=>E(!1),footer:null,children:e.jsx("form",{onSubmit:rt,children:e.jsxs(ne,{children:[e.jsx(ne,{style:{marginBottom:12},children:e.jsx(z,{type:"text",label:"User Name",name:"username",required:"required",value:j?.username?j?.username:"",onChange:N=>g({...j,username:N.target.value})})}),e.jsx(ne,{style:{marginBottom:12},children:e.jsx(z,{label:"Password",name:"password",required:"required",value:j?.password?j?.password:"",onChange:N=>g({...j,password:N.target.value})})}),e.jsx(ne,{style:{marginTop:16},children:e.jsx(o.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(o.Modal,{open:C,onCancel:U,footer:null,centered:!0,width:"80%",className:T.modal,children:e.jsxs("div",{style:{position:"relative"},className:T.img,children:[e.jsx(o.Image,{src:_,alt:"",style:{width:"100%"},preview:!1}),e.jsx(o.Button,{type:"text",icon:e.jsx(ce.CloseOutlined,{}),onClick:U,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(o.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,u,b)))}return Bt.default=o,Bt}var Pr;function jl(){return Pr||(Pr=1,(function(t){var n=tn&&tn.__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,(u,b)=>d[b])}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=Sl();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return n(o).default}})})(tn)),tn}var Er;function si(){if(Er)return tt;Er=1;var t=tt&&tt.__createBinding||(Object.create?(function(g,p,j,I){I===void 0&&(I=j);var A=Object.getOwnPropertyDescriptor(p,j);(!A||("get"in A?!p.__esModule:A.writable||A.configurable))&&(A={enumerable:!0,get:function(){return p[j]}}),Object.defineProperty(g,I,A)}):(function(g,p,j,I){I===void 0&&(I=j),g[I]=p[j]})),n=tt&&tt.__setModuleDefault||(Object.create?(function(g,p){Object.defineProperty(g,"default",{enumerable:!0,value:p})}):function(g,p){g.default=p}),a=tt&&tt.__importStar||function(g){if(g&&g.__esModule)return g;var p={};if(g!=null)for(var j in g)j!=="default"&&Object.prototype.hasOwnProperty.call(g,j)&&t(p,g,j);return n(p,g),p};Object.defineProperty(tt,"__esModule",{value:!0}),tt.downloadExcel=tt.excel=void 0;const s=a(jl());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(g,p){const j=window.document.createElement("a");return j.href=s.uri+s.base64(s.format(s.template,p)),j.download=g,document.body.appendChild(j),j.click(),document.body.removeChild(j),!0}function d(g,p){if(g)return g.cloneNode(!0).outerHTML;if(p)return s.createTable(p);console.error("currentTableRef or tablePayload does not exist")}function u({fileName:g,sheet:p,tablePayload:j},I){if(!o())return!1;const A=d(I,j);return l(g,{worksheet:p||"Worksheet",table:A})}tt.downloadExcel=u;function b({currentTableRef:g,filename:p,sheet:j}){function I(){if(!o())return!1;const A=d(g),m=`${p}.xls`;return l(m,{worksheet:j||"Worksheet",table:A})}return{onDownload:I}}return tt.excel=b,tt}var Fr;function wl(){if(Fr)return en;Fr=1,Object.defineProperty(en,"__esModule",{value:!0}),en.useDownloadExcel=void 0;const t=i,n=si();function a({currentTableRef:s,filename:o,sheet:l}){const[d,u]=(0,t.useState)({});return(0,t.useEffect)(()=>{u({currentTableRef:s,filename:o,sheet:l})},[s,o,l]),(0,t.useMemo)(()=>(0,n.excel)(d),[d])}return en.useDownloadExcel=a,en}var kr;function vl(){return kr||(kr=1,(function(t){var n=Zt&&Zt.__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=wl();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return s.useDownloadExcel}});const o=si();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:u,sheet:b,children:g})=>{const{onDownload:p}=(0,s.useDownloadExcel)({currentTableRef:d,filename:u,sheet:b});return a.default.createElement("span",{onClick:p},g)};t.DownloadTableExcel=l})(Zt)),Zt}var ii=vl();const ma=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:n}=t.data;t?.tableRef;const a=new Date().getTime(),s=gn.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(se.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:s})}),e.jsx(r.Col,{children:e.jsx(ii.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:n.current,children:e.jsx(r.Button,{type:"text",icon:e.jsx(se.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},vn=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"}})})})},_l=i.createContext(),Cl=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Ue=t=>{const{columns:n,action:a,DrawerUpdate:s,editDesign:o,newData:l,Loading:d,error:u,deleteTodoMutation:b,open:g,ActionView:p,viewDetails:j,myType:I,type:A,urlkey:m,columnstype:c,rowSelection:y}=t.data,P=Cl(),[R,D]=i.useState(!1),[C,h]=i.useState(null),[f,x]=i.useState("false"),[_,O]=i.useState(!1),[z,B]=i.useState(!1),[w,F]=i.useState(),[E,U]=i.useState(""),k=()=>D(!1),N=J=>{x(J),D(!0)},[V,q]=i.useState(),[T,S]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),$=i.useRef(null),M=(J,oe)=>{t.parentCallback?.(J,oe),S({rowsPerPage:oe,page:J})},L=(J,oe)=>{h(oe),O(!0),F(J)},ee=(J,oe)=>{h(oe),B(!0),F(J)},W=t?.data?.onNavigate??t?.onNavigate,K=(J,oe)=>{if(typeof W=="function"){W(J,oe);return}typeof window<"u"&&typeof J=="string"&&J.length>0&&window.location.assign(J)},Q=J=>{if(A==="staff"){K(`/HumanResourceDashboard/StaffFullInformation?id=${J.fk_staffID}`,J);return}K(`/StudentInformation/StudentFullInformation?id=${J.id}`,J)},ne=(J,oe)=>{q(J),s?.(oe)},le=async(J,oe,me,Te)=>{s?.(!0),me!==""&&((await Te({id:J,admission_no:oe,ec_no:me}))?.Status==="Success"?r.message.success("Ec No updated successfully"):r.message.error("Failed to Update Ec No."))},je=()=>e.jsx(_l.Provider,{value:V,children:o}),{trigger:ae}=Ke("branchapi/staff/updateStaffPassword",wa),{trigger:re}=Ke("branchapi/Student/updateEcNo",wa),{trigger:X}=Ke(m,(J,oe)=>wa("student/studentDetails/editStudentLogInCredential",oe)),xe=async J=>{J.preventDefault(),O(!1);try{(await ae({staff_id:w,new_passwod:J.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")}},De=async J=>{J.preventDefault(),B(!1);try{(await X({edit_id:C?.edit_id,new_passwod:J.target.password.value,username:J.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(oe){r.message.error(oe?.response?.data?.msg??"Failed to update password")}},qe=(Array.isArray(n)?n:[]).some(J=>J?.fixed==="left"),Be=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:c==="antd"&&qe?"left":void 0,sorter:(J,oe)=>(J.__serialNumber??0)-(oe.__serialNumber??0),render:J=>J},...c==="antd"?n:(Array.isArray(n)?n:[]).map(J=>({title:J.name,dataIndex:J.selector,key:J.selector,sorter:J.sorter||(J.sortable?(oe,me)=>{const Te=oe[J.selector]??"",Ae=me[J.selector]??"";return typeof Te=="number"&&typeof Ae=="number"?Te-Ae:String(Te).localeCompare(String(Ae))}:!1),render:(oe,me)=>{switch(J.selector){case"my_staff":return me.staff_id!=="0"?me.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(r.Image,{width:50,src:`undefined/branch/gallery/${me.gallery_cat_logo}`});case"file01":return me.documents?e.jsx("div",{onClick:()=>N(`undefined/branch/frontoffice/${me.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 mt(oe);case"full_name":return e.jsx("span",{onClick:()=>Q(me),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:oe||`${me.firstname} ${me.lastname}`});case"extra_curricular_activity":return oe==="Yes"?"Extra Subject":"Fees Master";case"is_active":return oe==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return me?.current_status==="Active"?e.jsx(r.Progress,{percent:me.steps==="1"?30:me.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:me?.current_status});case"Password":return e.jsx("span",{onClick:()=>L(me.id,me),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>ee(me.id,me),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(r.Tag,{onClick:()=>j?.(me.id),color:oe==="paid"?"#66aa18":oe==="partially_paid"?"#ff5722":"#DC143C",children:oe==="paid"?"Paid":oe==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return bl().find(Te=>Te.value===oe)?.label;case"status":return e.jsx("span",{onClick:()=>j?.(me?.fk_staffID,me?.total_leave),className:`label ${oe==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:oe==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[me.is_theory==="yes"&&"Theory, ",me.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(hl,{html:me.ec_no,onBlur:Te=>le(me.id,me.admission_no,Te.target.innerHTML,re)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(r.Button,{type:"primary",icon:e.jsx(se.SendOutlined,{}),size:"small",onClick:()=>ne(me.id,!0,J.name),children:J.name});case"Button":return e.jsx(r.Tag,{color:"cyan",onClick:()=>j?.(me),children:J.name});default:return oe}}})),...a?[{title:"Action",key:"action",render:(J,oe)=>{const me=oe?.current_status==="Promoted",Te=()=>{if(I=="sameAddUpdate"){ne(oe,!0);return}if(I?.type==="examEdit"){I.editFunc(oe.id);return}ne(oe.id||oe,!0)},Ae=()=>{if(I==="student_result"){j?.(oe);return}if(I==="student"){j?.(oe.id,oe.class_id);return}j?.(oe.id)},pt=()=>{b?.(oe?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[p?.[0]?.status&&e.jsx(r.Button,{icon:e.jsx(se.EditOutlined,{}),size:"small",disabled:me,onClick:Te}),p?.[1]?.status&&e.jsx(r.Button,{icon:e.jsx(se.DeleteOutlined,{}),size:"small",danger:!0,disabled:me,onClick:pt}),p?.[2]?.status&&e.jsx(r.Button,{icon:e.jsx(se.EyeOutlined,{}),size:"small",onClick:Ae})]})}}]:[]],$e=i.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Oe=i.useMemo(()=>{const J=E.trim().toLowerCase();return J?$e.filter(oe=>Object.values(oe??{}).some(me=>String(me??"").toLowerCase().includes(J))):$e},[$e,E]),ze=!!t.parentCallback,Ve=E?Oe.length:l?.pagination?.total_rows??Oe.length,Ee=(T.page-1)*T.rowsPerPage,Le=ze?Oe:Oe.slice(Ee,Ee+T.rowsPerPage),at=i.useMemo(()=>(Le??[]).map((J,oe)=>({...J??{},__serialNumber:Ee+oe+1})),[Ee,Le]),ce=Ve===0?0:Math.min(Ee+1,Ve),ge=Ve===0?0:Math.min(Ee+Le.length,Ve);let ye;return d?ye=e.jsx("p",{children:"Loading..."}):u?ye=e.jsx("p",{children:u.message}):Le.length?ye=e.jsx(r.Table,{dataSource:at,columns:Be,size:"small",bordered:!0,pagination:!1,rowSelection:y,rowKey:(J,oe)=>J?.id??J?._id??oe,scroll:{x:"max-content"}}):ye=e.jsx(r.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(r.Drawer,{open:g,placement:"right",onClose:()=>s?.(!1),width:720,children:je()}),e.jsx(r.Modal,{title:"Update Password",open:_,onCancel:()=>O(!1),footer:null,children:e.jsx("form",{onSubmit:xe,children:e.jsxs(ue,{children:[e.jsx(ue,{style:{marginBottom:12},children:e.jsx(Z,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(ue,{style:{marginTop:16},children:e.jsx(r.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(r.Modal,{title:" Update Credential",open:z,onCancel:()=>B(!1),footer:null,children:e.jsx("form",{onSubmit:De,children:e.jsxs(ue,{children:[e.jsx(ue,{style:{marginBottom:12},children:e.jsx(Z,{type:"text",label:"User Name",name:"username",required:"required",value:C?.username?C?.username:"",onChange:J=>h({...C,username:J.target.value})})}),e.jsx(ue,{style:{marginBottom:12},children:e.jsx(Z,{label:"Password",name:"password",required:"required",value:C?.password?C?.password:"",onChange:J=>h({...C,password:J.target.value})})}),e.jsx(ue,{style:{marginTop:16},children:e.jsx(r.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(r.Modal,{open:R,onCancel:k,footer:null,centered:!0,width:"80%",className:P.modal,children:e.jsxs("div",{style:{position:"relative"},className:P.img,children:[e.jsx(r.Image,{src:f,alt:"",style:{width:"100%"},preview:!1}),e.jsx(r.Button,{type:"text",icon:e.jsx(se.CloseOutlined,{}),onClick:k,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:`
|
|
17
17
|
.ubk-table-shell .ant-table-wrapper {
|
|
18
18
|
background: #fff;
|
|
19
19
|
border: 1px solid #e7e8f2;
|
|
@@ -56,4 +56,4 @@ Valid keys: `+JSON.stringify(Object.keys(x),null," "));var K=je(pe,ie,Q,ue,se+"
|
|
|
56
56
|
.ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
|
|
57
57
|
color: #8f99ff;
|
|
58
58
|
}
|
|
59
|
-
`}),e.jsx(ne,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(En,{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(o.Select,{size:"small",value:x.rowsPerPage,onChange:N=>q(1,N),options:[10,25,50,100].map(N=>({label:N,value:N})),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(o.Input,{size:"small",allowClear:!0,value:V,onChange:N=>{Z(N.target.value),R(G=>({...G,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(ce.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(Gt,{})}),oe]}),i&&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 ${ae} to ${de} of ${Be} entries`}),e.jsx(o.Pagination,{current:x.page,pageSize:x.rowsPerPage,total:Be||0,showSizeChanger:!1,onChange:q})]})]})]})},Ci=({token:t,type:n})=>{const[a,r]=l.useState({page:1,rowsPerPage:10}),s="api/branchapi/frontoffice/enquirytablelist",i=s.includes("?")?s.endsWith("?")||s.endsWith("&")?"":"&":"?",d=`${s}${i}page=${a.page}&per_page=${a.rowsPerPage}`,{isLoading:u,data:b,error:h}=X(t?[d,t]:null,([C,S])=>te(C,S)),[p,y]=l.useState(!1),v=(C,S)=>{r({page:C,rowsPerPage:parseInt(S)})},w=async C=>{},m=C=>{console.log("dsdsdsdsd",C),y(C)},c=()=>{},f=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],T=l.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(C,S)=>C.name.localeCompare(S.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(C,S)=>(C.contact||"").localeCompare(S.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(C,S)=>(C.description||"").localeCompare(S.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(C,S)=>(C.source_name||"").localeCompare(S.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(C,S)=>new Date(C.date)-new Date(S.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(C,S)=>new Date(C.follow_up_date)-new Date(S.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Ee,{parentCallback:v,data:{newData:b,columns:T,action:!0,Loading:u,error:h,open:p,viewDetails:c,deleteTodoMutation:w,DrawerUpdate:m,ActionView:f}})})},Ti={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"},me=l.forwardRef(({error:t,success:n,disabled:a,style:r,...s},i)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...s,ref:i,disabled:a,style:{...Ti,opacity:a?.7:1,cursor:a?"not-allowed":"pointer",...r||{}}})})),at=({id:t,funcName:n,disabled:a=!1})=>{const r="Data",[s,i]=l.useState(!1),d=()=>{i(!0),n(t),o.message.success(`${r} deleted successfully!`)},u=()=>{o.message.info(`Deletion of ${r} cancelled`)};return e.jsx(o.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:u,okText:"Yes",cancelText:"No",disabled:a||s,children:e.jsx(o.Button,{danger:!0,disabled:a,loading:s,icon:e.jsx(ce.DeleteOutlined,{}),size:"small"})})},We=t=>({optimisticData:n=>[...n.data,t],populateCache:(n,a)=>[...a.data,n]}),$e=t=>({optimisticData:n=>n.data.filter(a=>a.id!==t),populateCache:(n,a)=>a.data.filter(r=>r.id!==t)}),er={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ri({token:t}){const[n,a]=l.useState({pagination:{current:1,pageSize:10}}),[r,s]=l.useState(!1),[i,d]=l.useState(null),u=`api/branchapi/Transport/routeTableList?page=${n.pagination.current}&per_page=${n.pagination.pageSize}`,b="api/branchapi/Transport/addroute",h="api/branchapi/Transport/editroute",p="api/branchapi/Transport/deleteroute",{isLoading:y,data:v,error:w,mutate:m}=X(t?[u,t]:null,([I,O])=>te(I,O)),c=async(I,O)=>{try{await m(Ge(I,O,t),We(O)),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{A.error("Failed to add the new item.",{duration:1e3})}},f=I=>{I.preventDefault();const O=new FormData(I.target);c(b,O),I.target.reset()},T=(I,O)=>{a(k=>({...k,pagination:{current:I,pageSize:parseInt(O,10)}}))},C=async I=>{try{await m(nt(p,I,t),$e(I)),A.success("Success! Deleted item.",{duration:1e3})}catch{A.error("Failed to delete the item.",{duration:1e3})}},S=I=>{d(I),s(!0)},j=async I=>{try{await ft(h,I,t),await m(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),d(null)}catch{A.error("Failed to update the item.",{duration:1e3})}},g=async I=>{I.preventDefault();const O=new FormData(I.target);O.append("id",i?.id),j(O)},_=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(I,O)=>I.name.localeCompare(O.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(I,O)=>I.fare-O.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(I,O)=>I.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(I,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>S(O),style:{padding:2}}),e.jsx(at,{id:O?.id,funcName:C})]})}],P=i?.route_title?`Edit ${i.route_title}`:"Edit Route";return e.jsxs("div",{children:[e.jsx(o.Drawer,{open:r,title:P,placement:"right",width:420,onClose:()=>{s(!1),d(null)},children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"title",label:"Title",defaultValue:i?.route_title||"",required:"required"}),e.jsx(z,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:i?.fare||"",required:"required"}),e.jsx(z,{type:"text",name:"note",label:"Note",defaultValue:i?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(z,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{s(!1),d(null)},style:er,children:"Cancel"})]})]})})}),e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ne,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Add Route"})}),e.jsx(ne,{px:3,pb:2,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(z,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"}),e.jsx(z,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"}),e.jsx(z,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Save",color:"primary"}),e.jsx(o.Button,{type:"text",htmlType:"reset",style:er,children:"Cancel"})]})]})})})]})}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Route List"})}),e.jsx(ne,{children:e.jsx(Ee,{parentCallback:T,data:{newData:v,columns:_,columnstype:"antd",action:!1,Loading:y,error:w,deleteTodoMutation:C}})})]})})]})})]})}const tr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Di({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r,s]=l.useState(!1),[i,d]=l.useState(null),u=`api/branchapi/Transport/vehiclesTableList?page=${n.page}&per_page=${n.rowsPerPage}`,b="api/branchapi/Transport/addvehicles",h="api/branchapi/Transport/editvehicle",p="api/branchapi/Transport/deletevehicle",{isLoading:y,data:v,error:w,mutate:m}=X(t?[u,t]:null,([I,O])=>te(I,O)),c=async(I,O)=>{try{await m(Ge(I,O,t),We(O)),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{A.error("Failed to add the new item.",{duration:1e3})}},f=I=>{I.preventDefault();const O=new FormData(I.target);c(b,O),I.target.reset()},T=async I=>{try{await m(nt(p,I,t),$e(I)),A.success("Success! Deleted item.",{duration:1e3})}catch{A.error("Failed to delete the item.",{duration:1e3})}},C=I=>{d(I),s(!0)},S=async I=>{try{await ft(h,I,t),await m(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),d(null)}catch{A.error("Failed to update the item.",{duration:1e3})}},j=async I=>{I.preventDefault();const O=new FormData(I.target);O.append("id",i?.id),S(O)},g=(I,O)=>{a({page:I,rowsPerPage:parseInt(O,10)})},_=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(I,O)=>I.vehicle_no.localeCompare(O.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(I,O)=>I.vehicle_model.localeCompare(O.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(I,O)=>I.seating_capacity-O.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(I,O)=>I.manufacture_year-O.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(I,O)=>I.gps_url.localeCompare(O.gps_url)},render:(I,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:(I,O)=>I.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(I,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>C(O),style:{padding:2}}),e.jsx(at,{id:O?.id,funcName:T})]})}],P=i?.vehicle_no?`Edit ${i.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(o.Drawer,{open:r,title:P,placement:"right",width:420,onClose:()=>{s(!1),d(null)},children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"number",label:"Vehicle Number",defaultValue:i?.vehicle_no||"",required:"required"}),e.jsx(z,{type:"text",name:"model",label:"Vehicle Model",defaultValue:i?.vehicle_model||""}),e.jsx(z,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:i?.manufacture_year||""}),e.jsx(z,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:i?.seating_capacity||""}),e.jsx(z,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:i?.gps_url||""}),e.jsx(z,{type:"text",name:"note",label:"Note",defaultValue:i?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{s(!1),d(null)},style:tr,children:"Cancel"})]})]})})}),e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ne,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(ne,{px:3,pb:2,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(z,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(z,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(z,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(z,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(z,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(z,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Save",color:"primary"}),e.jsx(o.Button,{type:"text",htmlType:"reset",style:tr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(ne,{children:e.jsx(Ee,{parentCallback:g,data:{newData:v,columns:_,columnstype:"antd",action:!1,Loading:y,error:w,deleteTodoMutation:T}})})]})})]})})]})}var Ai=rs();const Gn=ts(Ai),cs=()=>{};class ga extends l.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:s}=this.props,i=!s;return e.jsxs("div",{children:[e.jsx(n,{...r,ref:this.setSelectRef,onChange:this.onChange}),i&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:cs,onFocus:()=>this.selectRef.focus(),required:a})]})}}ga.defaultProps={onChange:cs};ga.protoTypes={selectComponent:Gn.func.isRequired,onChange:Gn.func,required:Gn.bool};const Oi={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Pi={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"})},us=t=>e.jsx(Ar.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),Ii=t=>e.jsx(ga,{...t,SelectComponent:Ar,components:{Input:us},options:t.options}),le=l.forwardRef(({...t},n)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:Oi,children:t?.label}),e.jsx(Ii,{components:{Input:us},menuPortalTarget:document.body,styles:Pi,className:"input-cont",...t,ref:n})]})),Ei={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},nr=({dataIndex:t,title:n,record:a,children:r,isEditable:s,...i})=>e.jsx("td",{...i,children:s?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function ki({token:t}){const[n,a]=l.useState(!1),[r,s]=l.useState({pagination:{current:1,pageSize:50}}),[i,d]=l.useState(null),[u,b]=l.useState([]),h="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleDropdown",y="api/branchapi/Transport/getchechkedVehicleData",v="api/branchapi/Transport/assignedVehicleTable",w="api/branchapi/transport/assignvehicle",m="api/branchapi/Transport/deleteassignvehicle",c=i?`${y}?route_id=${i}`:null,{isLoading:f,data:T,mutate:C}=X(t?[`${v}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([R,$])=>te(R,$)),{data:S}=X(t&&h?[h,t]:null,([R,$])=>te(R,$)),{data:j}=X(t&&p?[p,t]:null,([R,$])=>te(R,$)),g=t&&c?[c,t]:null,{isLoading:_,data:P}=X(g,([R,$])=>te(R,$)),{Status:I="Failed",pagination:{total_rows:O=0}={}}=T||{},{data:k=[]}=I==="Success"?T:{},E=l.useMemo(()=>{const R=S?.data??S??[];return Array.isArray(R)?R:[]},[S]),D=l.useMemo(()=>{const R=j?.data??j??[];return(Array.isArray(R)?R:[]).map(q=>{if(q==null)return null;if(typeof q=="string"||typeof q=="number")return{label:String(q),value:q};const Q=q.value??q.vehicle_id??q.id??q.vehicleID,ue=q.label??q.vehicle_name??q.vehicle_no??q.vehicle_number??q.name??String(Q??"");return Q==null||ue===""?null:{label:String(ue),value:Q}}).filter(Boolean)},[j]),F=l.useMemo(()=>{const R=P?.data??P??[];return(Array.isArray(R)?R:[]).map(q=>q?.value??q?.vehicle_id??q?.id??q).filter(q=>q!=null)},[P]);l.useEffect(()=>{b(F)},[F,n]);const V=async(R,$,q)=>{try{await C(Ge(R,$,t),We($)),c&&X.mutate(g),a(Q=>!Q),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(Q){A.error(Q?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},Z=R=>{R.preventDefault();const $=new FormData;$.append("route_id",i??""),u.length?u.forEach(q=>$.append("vehicle_ids[]",q)):$.append("vehicle_ids[]",""),V(w,$)},U=R=>{s($=>({...$,pagination:{current:R,pageSize:$.pagination.pageSize}}))},Y=async R=>{try{await C(nt(m,R,t),$e(R)),c&&X.mutate(g),A.success("Success! Deleted item.",{duration:1e3})}catch{A.error("Failed to delete the item.",{duration:1e3})}},W=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(R,$,q)=>e.jsx(e.Fragment,{children:$.children.map((Q,ue,se)=>e.jsx("span",{children:`${Q.vehicle_name} ${ue+1===se.length?"":","}`},`${ue}vehicle001`))})},{title:"Action",render:(R,$,q)=>e.jsx(e.Fragment,{children:e.jsx(at,{id:$?.route_id,funcName:Y})})}],L=R=>{const $=["route_id","index"];for(let q=0;q<$.length;q++)if(R[$[q]])return R[$[q]]},x=R=>{const{children:$=[]}=R||{},q=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:Q=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:Q=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:Q=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:Q=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:Q=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:Q=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:Q=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(o.Table,{components:{body:{cell:nr}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:q,rowKey:Q=>L(Q)+"cell01",dataSource:$,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ne,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(ne,{px:3,pb:2,children:e.jsx("form",{onSubmit:Z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(le,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:R=>{d(R?.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(o.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:D,value:u,onChange:R=>b(R),disabled:!i||_})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Save",color:"primary"}),e.jsx(o.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),b([]),a(R=>!R)},style:Ei,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(ne,{style:{padding:"10px 16px"},children:e.jsx(o.Table,{components:{body:{cell:nr}},columns:W,bordered:!0,rowKey:R=>L(R),dataSource:Array.isArray(k)?k:[],loading:f,expandable:{expandedRowRender:x,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:O,showSizeChanger:!0,onChange:U,onShowSizeChange:(R,$)=>{s(q=>({...q,pagination:{current:1,pageSize:$}}))},showTotal:(R,$)=>`${$[0]}-${$[1]} of ${R} items`}})})]})})]})})]})}const Mi={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Fi={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Bi=(t,n,a)=>n?t>ye(a).endOf("day")||t<ye(n).endOf("day"):!1,ps=l.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:Mi,children:r.Desplay}),e.jsx(o.DatePicker,{...r,style:{...Fi,...r.style||{}},className:"form-group",disabledDate:s=>Bi(s,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:a})]})}),ar={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Qn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Xn=(t,n,a)=>{if(n==null||n==="")return null;const r=t.find(s=>String(s.value)===String(n));return r||(a?{label:String(a),value:n}:{label:String(n),value:n})},Ni=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},$i=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 Ui({token:t,assignmentId:n,studentName:a,onClose:r,onSuccess:s}){const i="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",u="api/branchapi/Transport/getrouteDropdown",b="api/branchapi/Transport/getvehicleListByRouteIdwithCount",h="api/branchapi/Transport/getStoppageDropdown",p="api/branchapi/Transport/routeShowdata",[y,v]=l.useState(null),[w,m]=l.useState(0),[c,f]=l.useState(0),{data:T,isLoading:C}=X(t&&n?[`${i}?id=${n}`,t]:null,([B,H])=>te(B,H)),S=l.useMemo(()=>{if(!T||T?.Status&&T.Status!=="Success")return null;const B=T?.data??T;return Array.isArray(B)?B[0]??null:B},[T]);l.useEffect(()=>{const B=S?.fk_route_id??S?.route_id;B!=null&&v(B)},[S]);const j=t&&y?`${b}?route_id=${y}`:null,g=t&&y?`${p}?id=${y}`:null,_=t&&y?`${h}?route_id=${y}`:null,{data:P}=X(t&&u?[u,t]:null,([B,H])=>te(B,H)),{data:I,isLoading:O}=X(j?[j,t]:null,([B,H])=>te(B,H)),{data:k,isLoading:E}=X(_?[_,t]:null,([B,H])=>te(B,H)),{data:D}=X(g?[g,t]:null,([B,H])=>te(B,H)),F=l.useMemo(()=>Qn(P),[P]),V=l.useMemo(()=>Qn(I),[I]),Z=l.useMemo(()=>Qn(k),[k]),U=D?.data?.[0]?.fare??S?.fare??S?.rootCost??S?.rootcost,Y=Ni(),W=a||[S?.firstname,S?.lastname].filter(Boolean).join(" ")||"",L=(B,H)=>{switch(H){case"route_id":v(B?.value??null),m(ie=>ie+1),f(ie=>ie+1);break;case"vehicle_id":f(ie=>ie+1);break}},x=async B=>{B.preventDefault();const H=new FormData(B.target);H.append("id",n);try{await ft(d,H,t),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s?.(),r?.()}catch(ie){A.error(ie?.message??"Failed to update the item.",{duration:1e3})}};if(C||!(S&&!C&&(!y||!O&&!E)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(o.Spin,{})});if(!S)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(o.Button,{type:"text",onClick:r,style:ar,children:"Close"})]});const $=S.fk_route_id??S.route_id,q=Xn(F,$,S.route_title),Q=Xn(V,S.vehicle_id,S.vehicle_name??S.vehicle_no),ue=Xn(Z,S.stop_id,S.stop_name??S.stoppage_name),se=S.start_date?ye(S.start_date):ye(),pe=$i(S?.service_push);return e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"title",label:"Student",defaultValue:W,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:S.fk_student_id??S.student_id??""}),e.jsx(le,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"fk_route_id",required:!0,allowSelectAll:!1,defaultValue:q,onChange:B=>L(B,"route_id")}),e.jsx(le,{options:V,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,defaultValue:Q,onChange:B=>L(B,"vehicle_id")},`edit-vehicle-${w}`),e.jsx(le,{options:Z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",name:"stop_id",required:!0,allowSelectAll:!1,defaultValue:ue},`edit-stop-${c}`),e.jsx(z,{type:"text",label:"Route Cost",value:U!=null?`${Y}${U}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:U??""}),e.jsx(ps,{defaultValue:se,Desplay:"Start Date",name:"start_date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1}),e.jsx(z,{type:"text",name:"puse_service",label:"Pause Service",defaultValue:pe,placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:r,style:ar,children:"Cancel"})]})]})},`edit-${n}-${w}`)}const rr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ut=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Li=t=>t||"",qi=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},zi=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},Vi=(t,n)=>{const a=n||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",s=encodeURIComponent(String(r));if(a.includes("{id}"))return a.replaceAll("{id}",s);if(a.includes(":id"))return a.replace(":id",s);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 i=a.includes("?")?"&":"?";return`${a}${i}id=${s}`};function Yi({token:t,editType:n,onNavigate:a,editPagePath:r}){const i=zi(n)==="drawer",d="api/branchapi/academy/classdropdownlist",u="api/branchapi/academy/sectionoftheClass",b="api/branchapi/Transport/routeStudentList",h="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleListByRouteIdwithCount",y="api/branchapi/Transport/getStoppageDropdown",v="api/branchapi/Transport/routeShowdata",w="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",[c,f]=l.useState(null),[T,C]=l.useState(!1),[S,j]=l.useState(!1),[g,_]=l.useState(null),[P,I]=l.useState(null),[O,k]=l.useState(null),[E,D]=l.useState(null),[F,V]=l.useState(!1),[Z,U]=l.useState(!1),[Y,W]=l.useState({page:1,rowsPerPage:50}),[L,x]=l.useState(null),[R,$]=l.useState(!1),[q,Q]=l.useState(null),[ue,se]=l.useState(null),pe=(fe,xe)=>{switch(xe){case"class_id":x(`${u}?class_id=${fe.value}`),C(Xe=>!Xe);break;case"route_id":I(`${p}?route_id=${fe.value}`),k(`${v}?id=${fe.value}`),se(fe.value),V(Xe=>!Xe);break;case"vehicle_id":D(`${y}?route_id=${ue}`),U(Xe=>!Xe);break}},B=fe=>{if(i){_(fe),j(!0);return}const xe=Vi(fe,r);if(typeof a=="function"){a(xe,fe);return}typeof window<"u"&&xe&&window.location.assign(xe)},H=()=>{j(!1),_(null)},ie=g?`Edit — ${g.firstname??""} ${g.lastname??""}`.trim():"Edit Student Transport",{data:je}=X(t&&d?[d,t]:null,([fe,xe])=>te(fe,xe)),{data:K}=X(t&&L?[L,t]:null,([fe,xe])=>te(fe,xe)),{data:ve}=X(t&&P?[P,t]:null,([fe,xe])=>te(fe,xe)),{data:Pe}=X(t&&E?[E,t]:null,([fe,xe])=>te(fe,xe)),{data:ke}=X(t&&O?[O,t]:null,([fe,xe])=>te(fe,xe)),{data:rt}=X(t&&h?[h,t]:null,([fe,xe])=>te(fe,xe)),st=t&&c?`${c}&page=${Y.page}&per_page=${Y.rowsPerPage}`:null,{isLoading:Qe,error:He,data:Ue,mutate:Ke}=X(st?[st,t]:null,([fe,xe])=>te(fe,xe)),Be=l.useMemo(()=>Ut(je),[je]),Oe=l.useMemo(()=>Ut(K),[K]),Fe=l.useMemo(()=>Ut(ve),[ve]),ot=l.useMemo(()=>Ut(Pe),[Pe]),ae=l.useMemo(()=>Ut(rt),[rt]),de=ke?.data?.[0]?.fare,oe=async fe=>{try{await Ke(nt(m,fe,t),$e(fe)),A.success("Success! Deleted item.",{duration:1e3})}catch{A.error("Failed to delete the item.",{duration:1e3})}},N=[{title:"Route Status",key:"route_status",render:(fe,xe)=>xe.fk_route_id?e.jsx("span",{children:xe.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(fe,xe)=>Li(xe.start_date)},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Roll No",dataIndex:"roll_no",key:"roll_no"},{title:"Name",key:"name",render:(fe,xe)=>`${xe.firstname} ${xe.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(fe,xe)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:xe.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(at,{id:xe?.id,funcName:oe}),e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>B(xe),style:{padding:2}})]}):e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.PlusOutlined,{}),onClick:()=>_e(xe.student_id),style:{padding:2}})})}],G=async(fe,xe)=>{try{await Ke(Ge(fe,xe,t),We(xe)),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),$(!1),mt()}catch{A.error("Failed to add the new item.",{duration:1e3})}},re=fe=>{fe.preventDefault();const xe=fe?.target?.class_id?.value,Xe=fe?.target?.section_id?.value;f(`${b}?cID=${xe}&sID=${Xe}`),W(J=>({...J,page:1}))},we=(fe,xe)=>{W({page:fe,rowsPerPage:parseInt(xe,10)})},_e=fe=>{Q(fe),$(!0)},lt=fe=>{fe.preventDefault();const xe=new FormData(fe.target);G(w,xe)},mt=()=>{$(!1),I(null),k(null),D(null),se(null)},gt=qi();return e.jsxs("div",{children:[i&&e.jsx(o.Drawer,{open:S,title:ie,placement:"right",width:420,destroyOnClose:!0,onClose:H,children:g?.id&&e.jsx(Ui,{token:t,assignmentId:g.id,studentName:`${g.firstname??""} ${g.lastname??""}`.trim(),onClose:H,onSuccess:()=>Ke()})}),e.jsx(o.Modal,{open:R,title:"Assign Student to Transport",onCancel:mt,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:lt,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[e.jsx(le,{options:ae,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"fk_route_id",required:!0,allowSelectAll:!1,onChange:fe=>pe(fe,"route_id")}),e.jsx(le,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,onChange:fe=>pe(fe,"vehicle_id")},`vehicle001${F}`),e.jsx(le,{options:ot,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",name:"stop_id",required:!0,allowSelectAll:!1},`stop001${Z}`),e.jsx(ps,{defaultValue:ye(),Desplay:"Start Date",name:"start_date",placement:"bottomRight",format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:q??"",name:"student_id"}),e.jsx(z,{className:"noDisplay",type:"text",name:"rootCost",value:de??""}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:de!=null?`${gt}${de} — Assign`:"Assign",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:mt,style:rr,children:"Cancel"})]})]})})}),e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ne,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Search Students"})}),e.jsx(ne,{px:3,pb:2,children:e.jsx("form",{onSubmit:re,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(le,{options:Be,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:fe=>pe(fe,"class_id"),name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(le,{options:Oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,name:"section_id",required:!0},`section1${T}`),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Search",color:"primary"}),e.jsx(o.Button,{type:"text",htmlType:"button",onClick:()=>{f(null),x(null),C(fe=>!fe)},style:rr,children:"Cancel"})]})]})})})]}),c&&e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Student List"})}),e.jsx(ne,{children:e.jsx(Ee,{parentCallback:we,data:{newData:Ue,columns:N,columnstype:"antd",action:!1,Loading:Qe,error:He,deleteTodoMutation:oe,pageController:Y}})})]})})]})})]})}const sr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},rn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Wi({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:50}),[r,s]=l.useState(!1),[i,d]=l.useState(null),[u,b]=l.useState(""),[h,p]=l.useState(""),[y,v]=l.useState(""),[w,m]=l.useState(!1),c=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,f="api/branchapi/Transport/add_driver",T="api/branchapi/Transport/edit_driver",C="api/branchapi/Transport/deletedriver",S="api/branchapi/staff/uploadDocuments",j=l.useMemo(()=>String(S).startsWith("http")?S:`${pt()??""}${String(S).replace(/^\/+/,"")}`,[S]),g=pt()??"",{isLoading:_,data:P,error:I,mutate:O}=X(t?[c,t]:null,([L,x])=>te(L,x)),k=async(L,x)=>{try{await Ge(L,x,t),await O(),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),b("")}catch(R){A.error(R?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},E=L=>{L.preventDefault();const x=new FormData(L.target);k(f,x),L.target.reset()},D=async L=>{try{await O(nt(C,L,t),$e(L)),A.success("Success! Deleted item.",{duration:1e3})}catch{A.error("Failed to delete the item.",{duration:1e3})}},F=L=>{d(L),b(L?.image??""),s(!0)},V=async L=>{try{await ft(T,L,t),await O(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),d(null),b("")}catch(x){A.error(x?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Z=L=>{L.preventDefault();const x=new FormData(L.target);x.append("id",i?.id??""),V(x)},U=(L,x)=>{a({page:L,rowsPerPage:parseInt(x,10)})},Y=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(L,x)=>String(L?.name??"").localeCompare(String(x?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(L,x)=>String(L?.Driver_licence??"").localeCompare(String(x?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(L,x)=>Number(L?.contact_number??0)-Number(x?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(L,x)=>String(L?.address??"").localeCompare(String(x?.address??""))}},{title:"Image",key:"image",width:100,render:(L,x)=>{const R=x?.image?`${g}staff/document/${x.image}`:"";return R?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(o.Image,{width:80,src:R,preview:{visible:!1,onVisibleChange:()=>{m(!0),p(R),v(x?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(L,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>F(x),style:{padding:2}}),e.jsx(at,{id:x?.id,funcName:D})]})}],W=i?.name?`Edit ${i.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(o.Drawer,{open:r,title:W,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{s(!1),d(null),b("")},children:e.jsx("form",{onSubmit:Z,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"name",label:"Driver Name",defaultValue:i?.name??"",required:"required"}),e.jsx(z,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:i?.Driver_licence??"",required:"required"}),e.jsx(z,{type:"number",name:"contact_number",label:"Driver Contact",defaultValue:i?.contact_number??"",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:rn,children:"Address"}),e.jsx(o.Input.TextArea,{name:"address",defaultValue:i?.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:rn,children:"Image"}),e.jsx(o.Upload,{maxCount:1,action:j,headers:t?{Authorization:t}:void 0,onChange:L=>{if(L?.file?.status!=="done")return;const x=L?.file?.response,R=x?.data??x?.filename??x?.file??x?.path??"";R&&b(String(R))},children:e.jsx(o.Button,{icon:e.jsx(ce.UploadOutlined,{}),disabled:!j,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:u})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{s(!1),d(null),b("")},style:sr,children:"Cancel"})]})]})})}),e.jsx(o.Modal,{zIndex:9999,open:w,title:y,footer:null,onCancel:()=>m(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:h})}),e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ne,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(ne,{px:3,pb:2,children:e.jsx("form",{onSubmit:E,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(z,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(z,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(z,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:rn,children:"Address"}),e.jsx(o.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:rn,children:"Image"}),e.jsx(o.Upload,{maxCount:1,action:j,headers:t?{Authorization:t}:void 0,onChange:L=>{if(L?.file?.status!=="done")return;const x=L?.file?.response,R=x?.data??x?.filename??x?.file??x?.path??"";R&&b(String(R))},children:e.jsx(o.Button,{icon:e.jsx(ce.UploadOutlined,{}),disabled:!j,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:u})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Save",color:"primary"}),e.jsx(o.Button,{type:"text",htmlType:"reset",onClick:()=>b(""),style:sr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(ne,{children:e.jsx(Ee,{parentCallback:U,data:{newData:P,columns:Y,columnstype:"antd",action:!1,Loading:_,error:I,deleteTodoMutation:D}})})]})})]})})]})}const or={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Tt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},sn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ir=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],on=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Hi({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:50}),[r,s]=l.useState(!1),[i,d]=l.useState(!1),[u,b]=l.useState(null),[h,p]=l.useState(null),[y,v]=l.useState(null),[w,m]=l.useState(null),[c,f]=l.useState(ye()),[T,C]=l.useState(ye()),[S,j]=l.useState("pick"),[g,_]=l.useState(!1),[P,I]=l.useState(null),[O,k]=l.useState(null),[E,D]=l.useState(!1),[F,V]=l.useState(null),[Z,U]=l.useState(null),[Y,W]=l.useState(null),[L,x]=l.useState(null),[R,$]=l.useState(ye()),[q,Q]=l.useState(ye()),[ue,se]=l.useState("pick"),pe=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,B="api/branchapi/Transport/assignRouteTime",H="api/branchapi/Transport/editAssignRouteTime",ie="api/branchapi/Transport/deleteAssignRouteTime",je="api/branchapi/Transport/driverDropdown",K="api/branchapi/transport/routeTimetableShowdata",ve="api/branchapi/Transport/getrouteDropdown",Pe="api/branchapi/Transport/getvehicleDropdown",{isLoading:ke,data:rt,error:st,mutate:Qe}=X(t?[pe,t]:null,([J,he])=>te(J,he)),{data:He}=X(t&&ve?[ve,t]:null,([J,he])=>te(J,he)),{data:Ue}=X(t&&je?[je,t]:null,([J,he])=>te(J,he)),Ke=l.useMemo(()=>u?`${Pe}?route_id=${u}`:null,[u,Pe]),{data:Be}=X(t&&Ke?[Ke,t]:null,([J,he])=>te(J,he)),Oe=l.useMemo(()=>on(He),[He]),Fe=l.useMemo(()=>on(Ue),[Ue]),ot=l.useMemo(()=>on(Be),[Be]),ae=(J,he)=>{a({page:J,rowsPerPage:parseInt(he,10)})},de=async J=>{J.preventDefault();const he=new FormData(J.target);he.set("route_id",h?.value??u??""),he.set("driver_id",y?.value??""),he.set("vehicle_id",w?.value??""),he.set("start_time",c?c.format("h:mm a"):""),he.set("drop_time",T?T.format("h:mm a"):""),he.set("type",S);try{await Ge(B,he,t),await Qe(),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),J.target.reset(),b(null),p(null),v(null),m(null),d(Ze=>!Ze),f(ye()),C(ye()),j("pick"),s(Ze=>!Ze)}catch(Ze){A.error(Ze?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},oe=async J=>{try{await nt(ie,J,t),await Qe(),A.success("Success! Deleted item.",{duration:1e3})}catch(he){A.error(he?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},N=J=>{I(J),_(!0);const he=J?.id??J?.route_time_id??J?.routeId??null;k(he);const Ze=J?.route_id??J?.routeId??J?.fk_route_id;V(Ze??null),U(Oe.find(xt=>xt?.value===(Ze??J?.route_id))??null),W(Fe.find(xt=>xt?.value===(J?.driver_id??J?.driverId))??null),x(null),D(xt=>!xt),$(J?.start_time?ye(J.start_time,["h:mm a","HH:mm"]):ye()),Q(J?.drop_time?ye(J.drop_time,["h:mm a","HH:mm"]):ye()),se(J?.type??"pick")},G=l.useMemo(()=>{if(!O)return null;const J=String(K).includes("?")?"&":"?";return`${K}${J}id=${encodeURIComponent(String(O))}`},[O,K]),{data:re,isLoading:we}=X(t&&G?[G,t]:null,([J,he])=>te(J,he)),_e=l.useMemo(()=>{const J=re?.data??re;return Array.isArray(J)?J[0]??null:Array.isArray(J?.data)?J.data[0]??null:J??null},[re]),lt=l.useMemo(()=>F?`${Pe}?route_id=${F}`:null,[F,Pe]),{data:mt}=X(t&<?[lt,t]:null,([J,he])=>te(J,he)),gt=l.useMemo(()=>on(mt),[mt]);l.useEffect(()=>{if(!_e)return;const J=_e?.route_id??_e?.fk_route_id??_e?.routeId;V(J??null),U(Oe.find(he=>he?.value===J)??null),W(Fe.find(he=>he?.value===_e?.driver_id)??null),x(null),$(_e?.start_time?ye(_e.start_time,["h:mm a","HH:mm"]):ye()),Q(_e?.drop_time?ye(_e.drop_time,["h:mm a","HH:mm"]):ye()),se(_e?.type??"pick"),D(he=>!he)},[Fe,_e,Oe]),l.useEffect(()=>{if(!_e)return;const J=_e?.vehicle_id??_e?.vehicleId;J&&x(gt.find(he=>he?.value===J)??null)},[_e,gt]);const fe=async J=>{if(J.preventDefault(),!O)return;const he=new FormData(J.target);he.set("id",String(O)),he.set("route_id",Z?.value??F??""),he.set("driver_id",Y?.value??""),he.set("vehicle_id",L?.value??""),he.set("start_time",R?R.format("h:mm a"):""),he.set("drop_time",q?q.format("h:mm a"):""),he.set("type",ue);try{await ft(H,he,t),await Qe(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),_(!1),I(null)}catch(Ze){A.error(Ze?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},xe=[{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:(J,he)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>N(he),style:{padding:2}}),e.jsx(at,{id:he?.id??he?.routeId??he?.route_time_id,funcName:oe})]})}],Xe=P?.route_title?`Edit ${P.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(o.Drawer,{open:g,title:Xe,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{_(!1),I(null),k(null),V(null),U(null),W(null),x(null)},children:e.jsx("form",{onSubmit:fe,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:we?.6:1},children:[e.jsx(le,{options:Oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:Z,onChange:J=>{V(J?.value??null),U(J??null),x(null),D(he=>!he)}}),e.jsx(le,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:Y,onChange:J=>W(J??null)}),e.jsx(le,{options:gt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:L,onChange:J=>x(J??null)},`edit-vehicle-${E}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Tt,children:"Start Time"}),e.jsx(o.TimePicker,{value:R,onChange:J=>$(J),use12Hours:!0,format:"h:mm a",allowClear:!1,style:sn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Tt,children:"Drop Time"}),e.jsx(o.TimePicker,{value:q,onChange:J=>Q(J),use12Hours:!0,format:"h:mm a",allowClear:!1,style:sn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Tt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(o.Radio.Group,{options:ir,optionType:"button",buttonStyle:"solid",value:ue,onChange:J=>se(J.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{_(!1),I(null)},style:or,children:"Cancel"})]})]})})}),e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ne,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(ne,{px:3,pb:2,children:e.jsx("form",{onSubmit:de,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(le,{options:Oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:h,onChange:J=>{b(J?.value??null),p(J??null),m(null),d(he=>!he)},allowSelectAll:!1,required:!0}),e.jsx(le,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:y,onChange:J=>v(J??null),allowSelectAll:!1,required:!0}),e.jsx(le,{options:ot,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:w,onChange:J=>m(J??null),allowSelectAll:!1,required:!0},`vehicle-${i}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Tt,children:"Start Time"}),e.jsx(o.TimePicker,{value:c,onChange:J=>f(J),use12Hours:!0,format:"h:mm a",allowClear:!1,style:sn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Tt,children:"Drop Time"}),e.jsx(o.TimePicker,{value:T,onChange:J=>C(J),use12Hours:!0,format:"h:mm a",allowClear:!1,style:sn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Tt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(o.Radio.Group,{options:ir,optionType:"button",buttonStyle:"solid",value:S,onChange:J=>j(J.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Add",color:"primary"}),e.jsx(o.Button,{type:"text",htmlType:"reset",onClick:()=>{b(null),p(null),v(null),m(null),d(J=>!J),f(ye()),C(ye()),j("pick"),s(J=>!J)},style:or,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(ne,{children:e.jsx(Ee,{parentCallback:ae,data:{newData:rt,columns:xe,columnstype:"antd",action:!1,Loading:ke,error:st,deleteTodoMutation:oe}})})]})})]})})]})}const Ki={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},lr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},dr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},cr=({dataIndex:t,title:n,record:a,children:r,isEditable:s,...i})=>e.jsx("td",{...i,children:s?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let ur=2;function Ji({token:t}){const[n,a]=l.useState([]),[r,s]=l.useState(null),[i,d]=l.useState({pagination:{current:1,pageSize:50}}),{isLoading:u,data:b,mutate:h}=X(t?[`api/branchapi/transport/getrouteStoppageData?page=${i.pagination.current}&per_page=${i.pagination.pageSize}`,t]:null,([k,E])=>te(k,E)),{Status:p="Failed",pagination:{total_rows:y=0}={}}=b||{},{data:v=[]}=p==="Success"?b:{},{data:w}=X(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([k,E])=>te(k,E)),m=l.useMemo(()=>{const k=w?.data??w??[];return Array.isArray(k)?k:[]},[w]),{data:c}=X(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([k,E])=>te(k,E)),{Status:f="Failed"}=c||{},T=async(k,E)=>{try{await h(Ge(k,E,t),We(E)),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{A.error("Failed to add the new item.",{duration:1e3})}},C=k=>{k.preventDefault();const E=new FormData(k.target);T("/branchapi/transport/addstoppageToRoute",E)},S=()=>{a(k=>[...k,{idKey:ur++}])},j=k=>{if(n.length===1)return;const E=[...n];E.splice(k,1),a(E)},g=k=>{d(E=>({...E,pagination:{current:k,pageSize:E.pagination.pageSize}}))},_=async k=>{const E="/branchapi/Transport/deletevehicle";try{await h(nt(E,k,t),$e(k)),A.success("Success! Deleted item.",{duration:1e3})}catch{A.error("Failed to delete the item.",{duration:1e3})}};l.useEffect(()=>{if(f==="Success"){const k=Array.isArray(c?.data)?c.data:[];k.length>0?a(k):r&&a([{idKey:ur++}])}},[f,c,r]);const P=k=>{const{children:E=[]}=k||{},D=[{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(o.Table,{components:{body:{cell:cr}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:D,rowKey:F=>I(F)+"cell01",dataSource:E,pagination:!1})})})},I=k=>{const E=["id","index"];for(let D=0;D<E.length;D++)if(k[E[D]])return k[E[D]]},O=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(k,E,D)=>e.jsx(e.Fragment,{children:E.children?.map((F,V,Z)=>e.jsx("span",{children:`${F.stop_name} ${V+1===Z.length?"":","}`},`${V}vehicle001`))})},{title:"Action",render:(k,E,D)=>e.jsx(e.Fragment,{children:e.jsx(at,{id:E?.route_id,funcName:_})})}];return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(ne,{pt:5,pb:1,children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(ne,{px:3,pb:2,children:e.jsxs("form",{onSubmit:C,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(le,{options:m,value:m.find(k=>k.value===r)??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:k=>{s(k?.value??null),a([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:r&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:S,children:e.jsx(ce.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(me,{type:"submit",value:"Add",color:"primary"}),e.jsx(o.Button,{type:"text",htmlType:"button",onClick:()=>{s(null),a([])},style:Ki,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((k,E)=>{const D=k.pickup_time?ye(k.pickup_time,"h:mm a"):ye(),F=k.drop_time?ye(k.drop_time,"h:mm a"):ye();return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[e.jsx("div",{children:e.jsx(z,{defaultValue:k.stop_name??"",type:"text",name:`stoppage[${E}][name]`,label:"Place Name*",required:"required"})}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:lr,children:"Pick Time"}),e.jsx(o.TimePicker,{defaultValue:D,use12Hours:!0,format:"h:mm a",name:`stoppage[${E}][pickTime]`,allowClear:!1,style:dr})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:lr,children:"Drop Time"}),e.jsx(o.TimePicker,{defaultValue:F,use12Hours:!0,format:"h:mm a",name:`stoppage[${E}][drop_time]`,allowClear:!1,style:dr})]}),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:()=>j(E),children:e.jsx(ce.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},k.idKey?k.idKey+"exp":k.id+"exp")})})]})}),e.jsx(ne,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(ne,{style:{padding:"10px 16px"},children:e.jsx(o.Table,{components:{body:{cell:cr}},columns:O,bordered:!0,size:"small",rowKey:k=>I(k),dataSource:v,loading:u,expandable:{expandedRowRender:P,childrenColumnName:"changed"},pagination:{current:i.pagination.current,pageSize:i.pagination.pageSize,total:y,showSizeChanger:!0,onChange:g,onShowSizeChange:(k,E)=>{d(D=>({...D,pagination:{current:1,pageSize:E}}))},showTotal:(k,E)=>`${E[0]}-${E[1]} of ${k} items`}})})]})]})}const Gi=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`};function Qi({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=l.useState(null),[s,i]=l.useState(null),[d,u]=l.useState(null),[b,h]=l.useState(null),[p,y]=l.useState(null),[v,w]=l.useState(null),[m,c]=l.useState(null),f="api/branchapi/library/bookCategorydropdown",T="api/branchapi/academy/classdropdownlist",C="api/branchapi/Academy/getClassSubjectdropdown",S="api/branchapi/library/addBook",j="api/branchapi/library/uploadcsv",{data:g}=X(n?[f,n]:null,([D,F])=>te(D,F)),{data:_}=X(n&&T?[T,n]:null,([D,F])=>te(D,F)),{data:P}=X(n&&C?[C,n]:null,([D,F])=>te(D,F)),I=l.useMemo(()=>Gi(pt(),j),[j]),O=async D=>{D.preventDefault();const F=new FormData(D.target);F.set("cat_id",p?.value??""),F.set("class_id",v?.value??""),F.set("subject_id",m?.value??"");try{await Ge(S,F,n),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),D.target.reset(),y(null),w(null),c(null)}catch(V){A.error(V?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},k=async D=>{if(D.preventDefault(),!a){A.error("Please select a CSV file.",{duration:1e3});return}const F=new FormData;F.append("file",a),F.append("cat_id",s?.value??""),F.append("class_id",d?.value??""),F.append("subject_id",b?.value??"");try{const V=await De.post(I,F,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});V?.data?.Status==="Failed"?A.error(String(V?.data?.msg??"Upload failed."),{duration:1e3}):(A.success(String(V?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),r(null),D.target.reset(),i(null),u(null),h(null))}catch(V){A.error(V?.response?.data?.msg??"Upload failed.",{duration:1e3})}},E=()=>{fetch("/books.csv").then(D=>{D.blob().then(F=>{const V=window.URL.createObjectURL(F);let Z=document.createElement("a");Z.href=V,Z.download="/books.csv",Z.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(o.Button,{type:"link",icon:e.jsx(ce.DownloadOutlined,{}),onClick:E,children:"Download Sample"}),children:[e.jsx(o.Divider,{children:"Information"}),e.jsx(o.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:k,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(le,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:s,onChange:D=>i(D??null)}),e.jsx(le,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:D=>u(D??null)}),e.jsx(le,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:b,onChange:D=>h(D??null)}),e.jsx(z,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:D=>r(D.target.files?.[0]??null),required:!0}),e.jsx(me,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(o.Card,{title:e.jsx(o.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(z,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(z,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(z,{type:"text",label:"Publication",name:"publisher"}),e.jsx(z,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(z,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(z,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(z,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(le,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:p,onChange:D=>y(D??null)}),e.jsx(le,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:v,onChange:D=>w(D??null)}),e.jsx(le,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:m,onChange:D=>c(D??null)}),e.jsx(me,{type:"submit",value:"Save",color:"primary"})]})})})]})}const Zn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ea=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Xi({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=l.useState([]),[s,i]=l.useState([]),d=l.useRef(),u={selectedRowKeys:a,onChange:(B,H)=>{r(B),i(H)}},b=Vt.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),h=()=>{if(!(typeof window>"u")){if(!s.length){A.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){A.error("Nothing to print.",{duration:1e3});return}b?.()}},[p,y]=l.useState(!1),[v,w]=l.useState(null),[m,c]=l.useState(null),[f,T]=l.useState(null),[C,S]=l.useState(null),[j,g]=l.useState({page:1,rowsPerPage:10}),_=(B,H)=>{g({page:B,rowsPerPage:parseInt(H,10)})},P="api/branchapi/library/booktable",I="api/branchapi/library/deletebooks",O="api/branchapi/library/editbook",k=`${P}?page=${j.page}&per_page=${j.rowsPerPage}`,{isLoading:E,error:D,data:F,mutate:V}=X(n?[k,n]:null,([B,H])=>te(B,H)),Z="api/branchapi/library/bookCategorydropdown",U="api/branchapi/academy/classdropdownlist",Y="api/branchapi/Academy/getClassSubjectdropdown",{data:W}=X(n?[Z,n]:null,([B,H])=>te(B,H)),{data:L}=X(n&&U?[U,n]:null,([B,H])=>te(B,H)),{data:x}=X(n&&Y?[Y,n]:null,([B,H])=>te(B,H)),R=l.useMemo(()=>ea(W),[W]),$=l.useMemo(()=>ea(L),[L]),q=l.useMemo(()=>ea(x),[x]),Q=async B=>{try{await nt(I,B,n),await V(),A.success("Success! Deleted item.",{duration:1e3})}catch(H){A.error(H?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ue=B=>{w(B??null);const H=B?.cat_id??B?.fk_cat_id??B?.category_id,ie=B?.class_id??B?.fk_class_id,je=B?.subject_id??B?.fk_subject_id;c(R.find(K=>K?.value===H)??null),T($.find(K=>K?.value===ie)??null),S(q.find(K=>K?.value===je)??null),y(!0)},se=async B=>{B.preventDefault();const H=v?.id??v?.book_id??v?._id;if(!H)return;const ie=new FormData(B.target);ie.set("id",String(H)),ie.set("cat_id",m?.value??""),ie.set("class_id",f?.value??""),ie.set("subject_id",C?.value??"");try{await ft(O,ie,n),await V(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),y(!1),w(null)}catch(je){A.error(je?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},pe=l.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:(B,H)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>ue(H),style:{padding:2}}),e.jsx(o.Button,{type:"text",size:"small",danger:!0,onClick:()=>Q(H?.id??H?.book_id??H?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[R,$,Q,q]);return e.jsxs("div",{style:{},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Drawer,{open:p,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{y(!1),w(null)},children:e.jsx("form",{onSubmit:se,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(z,{label:"Book Name",name:"title",defaultValue:v?.book_title??"",required:!0}),e.jsx(z,{label:"Author",name:"author",defaultValue:v?.author??"",required:!0}),e.jsx(z,{label:"Publication",name:"publish",defaultValue:v?.publish??""}),e.jsx(z,{label:"Qty",name:"quantity",type:"number",defaultValue:v?.quantity??""}),e.jsx(z,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:v?.perunitcost??""}),e.jsx(z,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:v?.fine_amount??""}),e.jsx(z,{label:"Barcode",name:"barcode",defaultValue:v?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Zn,children:"Category"}),e.jsx(le,{options:R,value:m,onChange:B=>c(B??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Zn,children:"Class"}),e.jsx(le,{options:$,value:f,onChange:B=>T(B??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Zn,children:"Subject"}),e.jsx(le,{options:q,value:C,onChange:B=>S(B??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{y(!1),w(null)},children:"Cancel"})]})]})})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:s.length>0?e.jsxs(o.Button,{type:"primary",onClick:h,children:["Print Barcode (",s.length,")"]}):null,children:e.jsx(Ee,{parentCallback:_,data:{newData:F,columns:pe,columnstype:"antd",action:!1,Loading:E,error:D,rowSelection:u}})}),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:s.map((B,H)=>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:B.book_title}),e.jsx(Or,{value:B.barcode?String(B.barcode):String(B.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},H))})})})]})}const Zi=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`},ht=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function el({token:t}){const n=t??localStorage.getItem("authToken")??"",a=JSON.parse(localStorage.getItem("genrall_settings")??"null")?.currency_symbol??"",[r,s]=l.useState("issue"),i=r==="return",[d,u]=l.useState(!1),[b,h]=l.useState(!1),[p,y]=l.useState(null),[v,w]=l.useState([]),[m,c]=l.useState([]),[f,T]=l.useState([]),[C,S]=l.useState(0),[j,g]=l.useState(!1),[_,P]=l.useState(null),[I,O]=l.useState(null),[k,E]=l.useState(null),[D,F]=l.useState(!1),[V,Z]=l.useState("Cash"),[U,Y]=l.useState(""),[W,L]=l.useState(""),[x,R]=l.useState(0),$=l.useRef(null),[q]=o.Form.useForm(),[Q]=o.Form.useForm(),ue="api/branchapi/library/bookCategorydropdown",se="api/branchapi/academy/classdropdownlist",pe="api/branchapi/Academy/getClassSubjectdropdown",{data:B}=X(n?[ue,n]:null,([ee,be])=>te(ee,be)),{data:H}=X(n&&se?[se,n]:null,([ee,be])=>te(ee,be)),{data:ie}=X(n&&pe?[pe,n]:null,([ee,be])=>te(ee,be)),je=l.useMemo(()=>ht(B),[B]),K=l.useMemo(()=>ht(H),[H]),ve=l.useMemo(()=>ht(ie),[ie]),Pe="api/branchapi/library/studentsearchByNameID",ke="api/branchapi/library/booksearchBybookname",rt="api/branchapi/library/issuedBookList",st="api/branchapi/library/issueLibrarybook",Qe="api/branchapi/library/returnedLibrarybook",{trigger:He,data:Ue}=ze(Pe,(ee,be)=>At(ee,be,n)),{trigger:Ke,data:Be}=ze(ke,(ee,be)=>At(ee,be,n)),{trigger:Oe,data:Fe}=ze(rt,(ee,be)=>At(ee,be,n)),{trigger:ot}=ze(i?Qe:st,(ee,be)=>es(ee,be,n)),ae=l.useMemo(()=>ht(Ue),[Ue]),de=l.useMemo(()=>ht(Be),[Be]),oe=l.useMemo(()=>ht(Fe),[Fe]),N=ee=>{const be=ye().format("YYYY-MM-DD");w(Ie=>Ie.some(Mt=>String(Mt?.id)===String(ee?.id))?Ie:[...Ie,{...ee,return_date:ee?.return_date?ee.return_date:be}])},G=ee=>{w(be=>be.filter(Ie=>String(Ie?.id)!==String(ee)))},re=async ee=>{if(n){if(!ee){y(null);return}d||await He({id:ee})}},we=async({search:ee})=>{if(!n||!d)return;const be=await He({id:ee}),Ie=ht(be);Ie.length===1&&(y(Ie[0]),await Oe({id:Ie[0]?.student_id}),q.resetFields())},_e=async(ee,be)=>{y(be??null),w([]),c([]),T([]),S(0),be?.student_id&&await Oe({id:be.student_id}),q.resetFields()},lt=async ee=>{n&&ee&&(b||await Ke({book:ee}))},mt=async({search_book:ee})=>{if(!n||!b)return;const be=await Ke({book:ee,catID:_?.value??"",sID:k?.value??"",cID:I?.value??""}),Ie=ht(be);Ie.length&&(N(Ie[0]),Q.resetFields())},gt=(ee,be)=>{N(be),Q.resetFields()},fe=async()=>{if(!p?.member_id){A.error("Select a student first.",{duration:1e3});return}if(!v.length){A.error("Select at least one book.",{duration:1e3});return}const ee=await ot({member_id:p.member_id,fine:!1,books:v});ee?.Status==="Success"?(A.success(String(ee?.msg??"Success"),{duration:1e3}),w([]),y(null),c([]),T([]),S(0)):A.error(String(ee?.msg??"Failed"),{duration:1e3})},xe=async()=>{if(!p?.member_id){A.error("Select a student first.",{duration:1e3});return}if(!f.length){A.error("Select at least one book to return.",{duration:1e3});return}if(Number(C)>0){F(!0);return}const ee=await ot({member_id:p.member_id,fine:!1,books:JSON.stringify(f)});ee?.Status==="Success"?(A.success(String(ee?.msg??"Success"),{duration:1e3}),c([]),T([]),S(0),await Oe({id:p?.student_id})):A.error(String(ee?.msg??"Failed"),{duration:1e3})},Xe=async()=>{if(!p?.member_id)return;const ee=Math.max(0,Number(C)-Number(x||0)),be={member_id:p.member_id,amount:ee,fine:!0,books:JSON.stringify(f),payment_type:V,notes:U,attchement:W,discount:x||0},Ie=await ot(be);F(!1),Ie?.Status==="Success"?(A.success(String(Ie?.msg??"Success"),{duration:1e3}),c([]),T([]),S(0),R(0),Y(""),L(""),await Oe({id:p?.student_id})):A.error(String(Ie?.msg??"Failed"),{duration:1e3})},J=l.useMemo(()=>Zi(pt(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),he=[{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:(ee,be)=>e.jsx(o.Input,{value:be?.return_date??"",onChange:Ie=>{const Mt=Ie.target.value;w(Fn=>Fn.map(Bn=>String(Bn?.id)===String(be?.id)?{...Bn,return_date:Mt}:Bn))},placeholder:"YYYY-MM-DD"})},{title:"Action",key:"action",width:120,fixed:"right",render:(ee,be)=>e.jsx(o.Button,{type:"text",danger:!0,onClick:()=>G(be?.id),children:"Remove"})}],Ze={selectedRowKeys:m,onChange:(ee,be)=>{c(ee),T(be);const Ie=(be??[]).reduce((Mt,Fn)=>Mt+Number(Fn?.totalfine??0),0);S(Ie)}},xt=[{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:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:ee=>e.jsxs("span",{children:[a," ",ee]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Modal,{open:D,onCancel:()=>F(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(o.Radio.Group,{value:V,onChange:ee=>Z(ee.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(o.Input.TextArea,{rows:3,value:U,onChange:ee=>Y(ee.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(o.Upload,{action:J,headers:{Authorization:n},maxCount:1,onChange:ee=>{if(ee.file.status==="done"){const be=ee.file.response?.data??ee.file.response?.file??"";L(String(be??""))}},children:e.jsx(o.Button,{icon:e.jsx(ce.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(o.Input,{type:"number",value:x,onChange:ee=>R(ee.target.value),placeholder:"0"})]}),e.jsxs(o.Button,{type:"primary",onClick:Xe,children:["Collect ",a,Math.max(0,Number(C)-Number(x||0))]})]})}),e.jsxs(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(o.Row,{gutter:[16,16],align:"middle",children:[e.jsx(o.Col,{xs:24,md:10,children:e.jsx(o.Radio.Group,{value:r,onChange:ee=>{const be=ee.target.value;s(be),w([]),c([]),T([]),S(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(o.Col,{xs:24,md:14,children:e.jsx(o.Form,{form:q,onFinish:we,layout:"vertical",children:e.jsx(o.Form.Item,{name:"search",label:"Search Student",children:e.jsx(o.Space.Compact,{style:{width:"100%"},children:d?e.jsx(o.Input,{autoFocus:!0,addonBefore:e.jsxs(o.Space,{children:[e.jsx(ce.BarcodeOutlined,{}),e.jsx(o.Checkbox,{checked:d,onChange:ee=>u(ee.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(o.AutoComplete,{options:ae,onSelect:_e,onSearch:re,style:{width:"100%"},allowClear:!0,children:e.jsx(o.Input,{addonBefore:e.jsxs(o.Space,{children:[e.jsx(ce.BarcodeOutlined,{}),e.jsx(o.Checkbox,{checked:d,onChange:ee=>u(ee.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),p?e.jsxs(e.Fragment,{children:[e.jsx(o.Divider,{}),e.jsxs(o.Row,{gutter:[12,12],children:[e.jsxs(o.Col,{xs:24,md:8,children:[e.jsx(o.Typography.Text,{strong:!0,children:"Name:"})," ",p?.value??""]}),e.jsxs(o.Col,{xs:24,md:8,children:[e.jsx(o.Typography.Text,{strong:!0,children:"Card No:"})," ",p?.library_card_no??""]}),e.jsxs(o.Col,{xs:24,md:8,children:[e.jsx(o.Typography.Text,{strong:!0,children:"Member ID:"})," ",p?.member_id??""]})]})]}):null,e.jsx(o.Divider,{}),i?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(o.Table,{dataSource:oe,columns:xt,rowSelection:Ze,pagination:!1,rowKey:ee=>ee?.id??ee?.issue_id??ee?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(o.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(o.Typography.Text,{strong:!0,children:["Total Fine: ",a,C]}),e.jsx(o.Button,{type:"primary",onClick:xe,disabled:!f.length,children:C>0?`Pay Now ${a}${Math.max(0,Number(C)-Number(x||0))}`:"Return Selected"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(o.Row,{gutter:[16,16],align:"middle",children:[e.jsx(o.Col,{xs:24,md:18,children:e.jsx(o.Form,{form:Q,onFinish:mt,layout:"vertical",children:e.jsx(o.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(o.Space.Compact,{style:{width:"100%"},children:b?e.jsx(o.Input,{autoFocus:!0,disabled:!p,addonBefore:e.jsxs(o.Space,{children:[e.jsx(ce.BarcodeOutlined,{}),e.jsx(o.Checkbox,{checked:b,onChange:ee=>h(ee.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(o.AutoComplete,{disabled:!p,options:de,onSelect:gt,onSearch:lt,style:{width:"100%"},allowClear:!0,children:e.jsx(o.Input,{addonBefore:e.jsxs(o.Space,{children:[e.jsx(ce.BarcodeOutlined,{}),e.jsx(o.Checkbox,{checked:b,onChange:ee=>h(ee.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(o.Col,{xs:24,md:6,children:e.jsx(o.Button,{style:{width:"100%"},icon:e.jsx(ce.FilterOutlined,{}),onClick:()=>g(!0),children:"Filter"})})]}),e.jsx(o.Drawer,{open:j,onClose:()=>g(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(le,{label:"Category",options:je,value:_,onChange:ee=>P(ee??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(le,{label:"Class",options:K,value:I,onChange:ee=>O(ee??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(le,{label:"Subjects",options:ve,value:k,onChange:ee=>E(ee??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(o.Button,{type:"primary",onClick:()=>g(!1),children:"Apply"})]})}),e.jsx(o.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(o.Table,{dataSource:v,columns:he,pagination:!1,rowKey:ee=>ee?.id??ee?.book_id??ee?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(o.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"button",value:"Issue",onClick:fe})})]})]}),e.jsx("div",{ref:$,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}const pr=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function tl({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=l.useState({page:1,rowsPerPage:10}),[s,i]=l.useState(null),[d,u]=l.useState(null),[b,h]=l.useState(!1),[p,y]=l.useState(!1),[v,w]=l.useState(null),[m,c]=l.useState(!1),f="api/branchapi/academy/classdropdownlist",T="api/branchapi/academy/sectionoftheClass",C="api/branchapi/library/studenttableForLibrary",S="api/branchapi/library/addmembershipforStudent",j="api/branchapi/library/removemembershipforStudent",g=l.useMemo(()=>{if(!s?.value)return null;const x=T.includes("?")?"&":"?";return`${T}${x}class_id=${encodeURIComponent(String(s.value))}`},[T,s?.value]),_=l.useMemo(()=>{if(!s?.value||!d?.value)return null;const x=C.includes("?")?"&":"?";return`${C}${x}cID=${encodeURIComponent(String(s.value))}&sID=${encodeURIComponent(String(d.value))}&page=${a.page}&per_page=${a.rowsPerPage}`},[a.page,a.rowsPerPage,s?.value,d?.value,C]),{data:P}=X(n&&f?[f,n]:null,([x,R])=>te(x,R)),{data:I}=X(n&&g?[g,n]:null,([x,R])=>te(x,R)),{isLoading:O,error:k,data:E,mutate:D}=X(n&&_?[_,n]:null,([x,R])=>te(x,R)),F=l.useMemo(()=>pr(P),[P]),V=l.useMemo(()=>pr(I),[I]),Z=(x,R)=>{r({page:x,rowsPerPage:parseInt(R,10)})},U=x=>{const R=x?.id??x?.student_id??x?.member_id;w(R??null),y(!0),c($=>!$)},Y=async x=>{if(x.preventDefault(),!v)return;const R=new FormData(x.target);R.set("id",String(v));try{await Ge(S,R,n),A.success("Success! Added member.",{duration:1e3,icon:"🎉"}),y(!1),w(null),await D()}catch($){A.error($?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},W=async x=>{try{await nt(j,x,n),A.success("Success! Removed member.",{duration:1e3}),await D()}catch(R){A.error(R?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},L=l.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:(x,R)=>(console.log("data______________",R),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:R?.library_card_no==null?e.jsx(o.Button,{type:"primary",size:"small",icon:e.jsx(ce.UserAddOutlined,{}),onClick:()=>U(R)}):e.jsx(o.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ce.DeleteOutlined,{}),onClick:()=>W(R?.id??R?.student_id??R?.member_id)})}))}],[W]);return e.jsxs("div",{style:{},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Modal,{open:p,title:"Add Member",onCancel:()=>{y(!1),w(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:Y,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(z,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"submit",value:"Add",color:"primary"})})]})},`add-${m}`)}),e.jsx(o.Card,{title:e.jsx(o.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(le,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:s,onChange:x=>{i(x??null),u(null),h(R=>!R)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(le,{options:V,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:x=>u(x??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${b}`),e.jsx(me,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!s?.value||!d?.value){A.error("Select class and section.",{duration:1e3});return}r(x=>({...x,page:1}))}})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Ee,{parentCallback:Z,data:{newData:E,columns:L,columnstype:"antd",action:!1,Loading:O,error:k}})})]})}function nl({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=l.useState({page:1,rowsPerPage:10}),[s]=o.Form.useForm(),[i]=o.Form.useForm(),[d,u]=l.useState(!1),[b,h]=l.useState(null),p="api/branchapi/library/BookCategorytable",y="api/branchapi/library/addBookCategory",v="api/branchapi/library/editBookCategory",w="api/branchapi/library/deleteBookCategory",m=l.useMemo(()=>{const k=p.includes("?")?"&":"?";return`${p}${k}page=${a.page}&per_page=${a.rowsPerPage}`},[p,a.page,a.rowsPerPage]),{isLoading:c,error:f,data:T,mutate:C}=X(n&&m?[m,n]:null,([k,E])=>te(k,E)),S=(k,E)=>{r({page:k,rowsPerPage:parseInt(E,10)})},j=async k=>{const E=new FormData;E.set("title",k?.title??"");try{await Ge(y,E,n),A.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),s.resetFields(),await C()}catch(D){A.error(D?.response?.data?.msg??D?.message??"Failed to add category.",{duration:1e3})}},g=k=>{h(k??null),i.setFieldsValue({title:k?.name??""}),u(!0)},_=()=>{u(!1),h(null),i.resetFields()},P=async k=>{const E=b?.id??b?.category_id??b?.cat_id;if(!E){A.error("Missing category id.",{duration:1e3});return}const D=new FormData;D.set("id",String(E)),D.set("title",k?.title??"");try{await ft(v,D,n),A.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),_(),await C()}catch(F){A.error(F?.response?.data?.msg??F?.message??"Failed to update category.",{duration:1e3})}},I=async k=>{const E=k?.id??k?.category_id??k?.cat_id;if(!E){A.error("Missing category id.",{duration:1e3});return}try{await nt(w,E,n),A.success("Success! Deleted category.",{duration:1e3}),await C()}catch(D){A.error(D?.response?.data?.msg??D?.message??"Failed to delete category.",{duration:1e3})}},O=l.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(k,E)=>e.jsxs(o.Space,{size:6,children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>g(E)}),e.jsx(o.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>I(E),children:e.jsx(o.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ce.DeleteOutlined,{})})})]})}],[I]);return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Modal,{open:d,title:"Edit Category",onCancel:_,footer:null,destroyOnClose:!0,children:e.jsxs(o.Form,{form:i,layout:"vertical",onFinish:P,children:[e.jsx(o.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(o.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(o.Button,{onClick:_,children:"Cancel"}),e.jsx(me,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(o.Row,{gutter:[16,16],children:[e.jsx(o.Col,{xs:24,lg:8,children:e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(o.Form,{form:s,layout:"vertical",onFinish:j,children:[e.jsx(o.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(o.Input,{placeholder:"Enter category name"})}),e.jsx(me,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(o.Col,{xs:24,lg:16,children:e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Ee,{parentCallback:S,data:{newData:T,columns:O,columnstype:"antd",action:!1,Loading:c,error:f}})})})]})]})}const ta=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function al({token:t}){const[n,a]=l.useState([ye().format("YYYY-MM-DD"),ye().format("YYYY-MM-DD")]),[r,s]=l.useState(null),[i,d]=l.useState(null),[u,b]=l.useState(null),[h,p]=l.useState(!1),[y,v]=l.useState(!1),w="api/branchapi/academy/classdropdownlist",m="api/branchapi/academy/sectionoftheClass",c="api/branchapi/library/memberDropdown",f="api/report/libraryReport/libraryReport",T=l.useMemo(()=>{if(!r?.value)return null;const U=m.includes("?")?"&":"?";return`${m}${U}class_id=${encodeURIComponent(String(r.value))}`},[m,r?.value]),C=l.useMemo(()=>{if(!r?.value)return null;const U=c.includes("?")?"&":"?",Y=`${c}${U}class=${encodeURIComponent(String(r.value))}`;return i?.value?`${Y}§ion=${encodeURIComponent(String(i.value))}`:Y},[c,r?.value,i?.value]),{isLoading:S,error:j,data:g,mutate:_}=X(t&&w?[w,t]:null,([U,Y])=>te(U,Y)),{data:P}=X(t&&T?[T,t]:null,([U,Y])=>te(U,Y)),{data:I}=X(t&&C?[C,t]:null,([U,Y])=>te(U,Y)),O=l.useMemo(()=>ta(g),[g]),k=l.useMemo(()=>ta(P),[P]),E=l.useMemo(()=>ta(I),[I]),{trigger:D,data:F}=ze(f,(U,Y)=>ha(U,Y,t));l.useEffect(()=>{(async()=>{v(!0);try{await D({duration:n})}finally{v(!1)}})()},[]);const V=async()=>{v(!0);try{await D({duration:n,class:r?.value??"",section:i?.value??"",student_id:u?.value??""})}finally{v(!1)}},Z=[{title:"Name",dataIndex:"full_name",render:(U,Y)=>e.jsx(o.Typography.Text,{style:{fontSize:12},children:Y?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(U,Y)=>e.jsx(o.Typography.Text,{style:{fontSize:12},children:Y?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(U,Y)=>e.jsxs(o.Typography.Text,{style:{fontSize:12},children:[Y?.class??"","(",Y?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(U,Y)=>e.jsx(o.Typography.Text,{style:{fontSize:12},children:Y?.book_title??""})},{title:"Issue Date",key:"date",render:(U,Y,W)=>e.jsx(o.Typography.Text,{style:{fontSize:12},children:Y?.issue_date??""})},{title:"Due Return Date",key:"date",render:(U,Y,W)=>e.jsx(o.Tag,{color:"orange",children:Y?.return_date??""})},{title:"Return Date",key:"date",render:(U,Y,W)=>Y?.retured_by_user?e.jsx(o.Tag,{color:"green",children:Y?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(U,Y,W)=>String(Y?.is_returned??"")==="1"?e.jsx(o.Tag,{color:"green",children:"Return"}):e.jsx(o.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(U,Y,W)=>{const L=Y?.late_fine?Number(Y.late_fine):0;return L?e.jsx(o.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:L}):null}}];return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(o.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(o.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(o.DatePicker.RangePicker,{style:{width:"100%"},value:[ye(n[0],"YYYY-MM-DD"),ye(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(U,Y)=>{Array.isArray(Y)&&Y.length===2&&a([Y[0],Y[1]])}})]})}),e.jsx(o.Col,{xs:24,md:5,children:e.jsx(le,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:U=>{s(U??null),d(null),b(null),p(Y=>!Y)},allowSelectAll:!1})}),e.jsx(o.Col,{xs:24,md:5,children:e.jsx(le,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:i,onChange:U=>{d(U??null),b(null)},allowSelectAll:!1},`section1${h}`)}),e.jsx(o.Col,{xs:24,md:5,children:e.jsx(le,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:u,onChange:U=>b(U??null),allowSelectAll:!1})}),e.jsx(o.Col,{xs:24,md:1,children:e.jsx(o.Button,{type:"primary",icon:e.jsx(ce.SearchOutlined,{}),onClick:V,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(o.Table,{columns:Z,pagination:!1,dataSource:Array.isArray(F?.data)?F.data:[],size:"small",rowKey:(U,Y)=>U?.id??U?.issue_id??U?.fees_receipt_id??Y,loading:y,scroll:{x:"max-content"},summary:U=>{const Y=U.reduce((L,x)=>L+Number(x?.late_fine??0),0),W=U.reduce((L,x)=>L+Number(x?.is_returned??0),0);return e.jsxs(o.Table.Summary.Row,{children:[e.jsx(o.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",U.length]})}),e.jsx(o.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(U.length-W)]})}),e.jsx(o.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",W]})}),e.jsx(o.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",Y.toLocaleString("en-IN")]})})]})}})})]})]})}const kn=t=>t??localStorage.getItem("authToken")??"",rl=(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",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"}},sl=()=>rl(pt(),Ae.upload),ol=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const s=t.includes("?")?"&":"?",i=`${t}${s}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return te(i,kn(r))},Qt=async(t,n,a)=>Ge(t,n,kn(a)),Et=async(t,n,a)=>ft(t,n,kn(a)),Xt=async(t,n,a)=>nt(t,n,kn(a)),il=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Pt=({token:t,value:n,onChange:a})=>{const r=l.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(o.Upload,{maxCount:1,action:sl(),headers:r,onChange:s=>{if(s?.file?.status==="done"){const i=il(s?.file?.response);i&&a?.(i)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},gn=Ae.vendor,Zt=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>X(r&&t?[t,n,a,r]:null,([i,d,u,b])=>ol({baseUrl:i,page:d,perPage:u},b)),ll=({token:t,page:n=1,perPage:a=10})=>Zt({baseUrl:gn.list,page:n,perPage:a,token:t}),dl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},fr=[{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 cl({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r,s]=l.useState(!1),[i,d]=l.useState(null),[u,b]=l.useState(""),{isLoading:h,error:p,data:y,mutate:v}=ll({token:t,page:n.page,perPage:n.rowsPerPage}),w=async j=>{try{await v(Qt(gn.add,j,t),We(j)),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(g){A.error(g?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},m=j=>{j.preventDefault();const g=new FormData(j.target);u&&g.set("image",u),w(g),j.target.reset(),b("")},c=(j,g)=>{a({page:j,rowsPerPage:parseInt(g,10)})},f=async j=>{try{await v(Xt(gn.remove,j,t),$e(j)),A.success("Success! Deleted item.",{duration:1e3})}catch(g){A.error(g?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},T=j=>{d(j),s(!0),b("")},C=async j=>{j.preventDefault();const g=new FormData(j.target);g.set("id",String(i?.id??"")),u&&g.set("image",u);try{await Et(gn.edit,g,t),await v(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),d(null),b("")}catch(_){A.error(_?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},S=l.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:(j,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>T(g),style:{padding:2}}),e.jsx(at,{id:g?.id,funcName:f})]})}],[f]);return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Drawer,{open:r,title:i?.name?`Edit ${i.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{s(!1),d(null),b("")},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[fr.map(j=>e.jsx(z,{type:j.type,name:j.name,label:j.label,defaultValue:i?.[j.name]??"",required:j.required?"required":void 0},j.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(Pt,{token:t,value:u,onChange:b})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{s(!1),d(null),b("")},style:dl,children:"Cancel"})]})]})})}),e.jsxs(ne,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(ne,{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:[fr.map(j=>e.jsx(z,{type:j.type,name:j.name,label:j.label,required:j.required?"required":void 0},j.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(Pt,{token:t,value:u,onChange:b})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(ne,{pt:3,children:e.jsx(Ee,{parentCallback:c,data:{newData:y,columns:S,columnstype:"antd",action:!1,Loading:h,error:p}})})]})]})]})}const ul=({token:t})=>e.jsx(cl,{token:t}),pl={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},fl={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"},da=({style:t,onFocus:n,onBlur:a,...r})=>{const[s,i]=l.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:pl,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{i(!0),n?.(d)},onBlur:d=>{i(!1),a?.(d)},style:{...fl,borderBottom:`1px solid ${s?"#222":"#d9d9d9"}`,...t||{}}})]})},xn=Ae.product,mr=Ae.vendor.dropdown,hr=Ae.category.dropdown,ml=Ae.subCategory.dropdown,yr=Ae.unit.dropdown,fs=({token:t,page:n=1,perPage:a=10})=>Zt({baseUrl:xn.list,page:n,perPage:a,token:t}),hl=({token:t})=>X(t&&mr?[mr,t]:null,([a,r])=>te(a,r)),yl=({token:t})=>X(t&&hr?[hr,t]:null,([a,r])=>te(a,r)),gl=({token:t})=>X(t&&yr?[yr,t]:null,([a,r])=>te(a,r)),xl=({token:t,categoryId:n})=>{const a=t&&n?`${ml}?category_id=${encodeURIComponent(String(n))}`:null;return X(a?[a,t]:null,([s,i])=>te(s,i))},ln=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},bl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Sl({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r,s]=l.useState(!1),[i,d]=l.useState(null),[u,b]=l.useState(""),[h,p]=l.useState(""),[y,v]=l.useState(""),[w,m]=l.useState(""),[c,f]=l.useState(""),{isLoading:T,error:C,data:S,mutate:j}=fs({token:t,page:n.page,perPage:n.rowsPerPage}),{data:g}=hl({token:t}),{data:_}=yl({token:t}),{data:P}=gl({token:t}),{data:I}=xl({token:t,categoryId:h}),O=l.useMemo(()=>ln(g),[g]),k=l.useMemo(()=>ln(_),[_]),E=l.useMemo(()=>ln(P),[P]),D=l.useMemo(()=>ln(I),[I]),F=async x=>{try{await j(Qt(xn.add,x,t),We(x)),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(R){A.error(R?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},V=x=>{x.preventDefault();const R=new FormData(x.target);h&&R.set("fk_categoryID",String(h)),y&&R.set("fk_sub_categoryID",String(y)),w&&R.set("vendor_id",String(w)),c&&R.set("unit",String(c)),u&&R.set("image",u),F(R),x.target.reset(),b(""),p(""),v(""),m(""),f("")},Z=(x,R)=>{a({page:x,rowsPerPage:parseInt(R,10)})},U=async x=>{try{await j(Xt(xn.remove,x,t),$e(x)),A.success("Success! Deleted item.",{duration:1e3})}catch(R){A.error(R?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},Y=x=>{d(x),s(!0),b(""),p(x?.fk_categoryID??x?.category_id??""),v(x?.fk_sub_categoryID??x?.sub_category_id??""),m(x?.vendor_id??""),f(x?.unit??x?.unit_id??"")},W=async x=>{x.preventDefault();const R=new FormData(x.target);R.set("id",String(i?.id??"")),h&&R.set("fk_categoryID",String(h)),y&&R.set("fk_sub_categoryID",String(y)),w&&R.set("vendor_id",String(w)),c&&R.set("unit",String(c)),u&&R.set("image",u);try{await Et(xn.edit,R,t),await j(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),d(null),b("")}catch($){A.error($?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},L=l.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:(x,R)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>Y(R),style:{padding:2}}),e.jsx(at,{id:R?.id,funcName:U})]})}],[U]);return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Drawer,{open:r,title:i?.name?`Edit ${i.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{s(!1),d(null),b("")},children:e.jsx("form",{onSubmit:W,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(z,{type:"text",name:"name",label:"Product Name*",defaultValue:i?.name??"",required:"required"}),e.jsx(le,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:x=>{const R=x?.value??"";p(R),v("")},defaultValue:h?k.find(x=>String(x?.value)===String(h)):null}),e.jsx(le,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:x=>v(x?.value??""),defaultValue:y?D.find(x=>String(x?.value)===String(y)):null}),e.jsx(z,{type:"text",name:"barcode",label:"Barcode",defaultValue:i?.barcode??""}),e.jsx(le,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:x=>f(x?.value??""),defaultValue:c?E.find(x=>String(x?.value)===String(c)):null}),e.jsx(z,{type:"number",name:"quantity",label:"Quantity*",defaultValue:i?.quantity??"",required:"required"}),e.jsx(z,{type:"number",name:"price",label:"Price*",defaultValue:i?.price??"",required:"required"}),e.jsx(le,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:x=>m(x?.value??""),defaultValue:w?O.find(x=>String(x?.value)===String(w)):null}),e.jsx(z,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:i?.hsn_code??""}),e.jsx(da,{type:"text",label:"Description",name:"description",rows:3,defaultValue:i?.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(Pt,{token:t,value:u,onChange:b})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{s(!1),d(null),b("")},style:bl,children:"Cancel"})]})]})})}),e.jsxs(ne,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(ne,{px:3,pb:2,children:e.jsx("form",{onSubmit:V,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(z,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(le,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:x=>{const R=x?.value??"";p(R),v("")}}),e.jsx(le,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:x=>v(x?.value??"")},`subcat_${h}`),e.jsx(z,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(le,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:x=>f(x?.value??"")}),e.jsx(z,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(z,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(le,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:x=>m(x?.value??"")}),e.jsx(z,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(da,{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(Pt,{token:t,value:u,onChange:b})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(ne,{pt:3,children:e.jsx(Ee,{parentCallback:Z,data:{newData:S,columns:L,columnstype:"antd",action:!1,Loading:T,error:C}})})]})]})]})}const jl=({token:t})=>e.jsx(Sl,{token:t}),bn=Ae.category,wl=({token:t,page:n=1,perPage:a=10})=>Zt({baseUrl:bn.list,page:n,perPage:a,token:t}),vl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function _l({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r,s]=l.useState(!1),[i,d]=l.useState(null),{isLoading:u,error:b,data:h,mutate:p}=wl({token:t,page:n.page,perPage:n.rowsPerPage}),y=async C=>{try{await p(Qt(bn.add,C,t),We(C)),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(S){A.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=C=>{C.preventDefault();const S=new FormData(C.target);y(S),C.target.reset()},w=(C,S)=>{a({page:C,rowsPerPage:parseInt(S,10)})},m=async C=>{try{await p(Xt(bn.remove,C,t),$e(C)),A.success("Success! Deleted item.",{duration:1e3})}catch(S){A.error(S?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},c=C=>{d(C),s(!0)},f=async C=>{C.preventDefault();const S=new FormData(C.target);S.set("id",String(i?.id??""));try{await Et(bn.edit,S,t),await p(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),d(null)}catch(j){A.error(j?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},T=l.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(C,S)=>String(C?.name??"").localeCompare(String(S?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(C,S)=>String(C?.description??"").localeCompare(String(S?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(C,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>c(S),style:{padding:2}}),e.jsx(at,{id:S?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Drawer,{open:r,title:i?.name?`Edit ${i.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{s(!1),d(null)},children:e.jsx("form",{onSubmit:f,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"name",label:"Name",defaultValue:i?.name??"",required:"required"}),e.jsx(z,{type:"text",name:"description",label:"Description",defaultValue:i?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{s(!1),d(null)},style:vl,children:"Cancel"})]})]})})}),e.jsxs(ne,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(ne,{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(z,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(z,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(ne,{pt:3,children:e.jsx(Ee,{parentCallback:w,data:{newData:h,columns:T,columnstype:"antd",action:!1,Loading:u,error:b}})})]})]})]})}const Cl=({token:t})=>e.jsx(_l,{token:t}),Sn=Ae.subCategory,gr=Ae.category.dropdown,Tl=({token:t,page:n=1,perPage:a=10})=>Zt({baseUrl:Sn.list,page:n,perPage:a,token:t}),Rl=({token:t})=>X(t&&gr?[gr,t]:null,([a,r])=>te(a,r)),Dl=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Al={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ol({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r,s]=l.useState(!1),[i,d]=l.useState(null),[u,b]=l.useState(""),{isLoading:h,error:p,data:y,mutate:v}=Tl({token:t,page:n.page,perPage:n.rowsPerPage}),{data:w}=Rl({token:t}),m=l.useMemo(()=>Dl(w),[w]),c=async _=>{try{await v(Qt(Sn.add,_,t),We(_)),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(P){A.error(P?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},f=_=>{_.preventDefault();const P=new FormData(_.target);P.set("status","active"),P.set("img",u||""),c(P),_.target.reset(),b("")},T=(_,P)=>{a({page:_,rowsPerPage:parseInt(P,10)})},C=async _=>{try{await v(Xt(Sn.remove,_,t),$e(_)),A.success("Success! Deleted item.",{duration:1e3})}catch(P){A.error(P?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},S=_=>{d(_),s(!0)},j=async _=>{_.preventDefault();const P=new FormData(_.target);P.set("id",String(i?.id??"")),u&&P.set("img",u);try{await Et(Sn.edit,P,t),await v(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),d(null),b("")}catch(I){A.error(I?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},g=l.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(_,P)=>String(_?.name??"").localeCompare(String(P?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(_,P)=>String(_?.description??"").localeCompare(String(P?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(_,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>S(P),style:{padding:2}}),e.jsx(at,{id:P?.id,funcName:C})]})}],[C]);return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Drawer,{open:r,title:i?.name?`Edit ${i.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{s(!1),d(null),b("")},children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(le,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:i?.category_id?m.find(_=>String(_?.value)===String(i.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(z,{type:"text",name:"name",label:"Name*",defaultValue:i?.name??"",required:"required"}),e.jsx(z,{type:"text",name:"description",label:"Description",defaultValue:i?.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(Pt,{token:t,value:u,onChange:b})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{s(!1),d(null),b("")},style:Al,children:"Cancel"})]})]})})}),e.jsxs(ne,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(ne,{px:3,pb:2,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(le,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(z,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(z,{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(Pt,{token:t,value:u,onChange:b})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(ne,{pt:3,children:e.jsx(Ee,{parentCallback:T,data:{newData:y,columns:g,columnstype:"antd",action:!1,Loading:h,error:p}})})]})]})]})}const Pl=({token:t})=>e.jsx(Ol,{token:t}),na=Ae.product,Il=Ae.academy.classes,El=Ae.academy.sections,kl=Ae.student.dropdown;function Lt(t){const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]}function dn(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 Le(t){return String(t??"")}function Ml({token:t}){const[n,a]=l.useState(""),[r,s]=l.useState(""),[i,d]=l.useState(""),[u,b]=l.useState(!1),[h,p]=l.useState(""),[y,v]=l.useState([]),[w,m]=l.useState({}),[c,f]=l.useState({}),[T,C]=l.useState(!1),[S,j]=l.useState(""),[g,_]=l.useState(0),[P,I]=l.useState(""),[O,k]=l.useState(ye()),[E,D]=l.useState([]),F={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},V=!!(n&&r&&i),{data:Z}=X(t?[Il,t]:null,([ae,de])=>te(ae,de)),U=l.useMemo(()=>Lt(Z),[Z]),Y=t&&n?`${El}?class_id=${encodeURIComponent(String(n))}`:null,{data:W}=X(Y?[Y,t]:null,([ae,de])=>te(ae,de)),L=l.useMemo(()=>Lt(W),[W]),x=t&&n&&r?`${kl}?class=${encodeURIComponent(String(n))}§ion=${encodeURIComponent(String(r))}`:null,{data:R}=X(x?[x,t]:null,([ae,de])=>te(ae,de)),$=l.useMemo(()=>Lt(R),[R]),q=V?`${na.list}?page=1&per_page=10000`:null,{data:Q,isLoading:ue}=X(t&&q?[q,t]:null,([ae,de])=>te(ae,de),{revalidateOnFocus:!1}),se=l.useMemo(()=>Lt(Q),[Q]),pe=l.useMemo(()=>{const ae=new Map;return(Array.isArray(se)?se:[]).forEach(de=>{ae.set(Le(de?.id),de)}),ae},[se]),B=l.useMemo(()=>{const ae=Object.entries(c||{});return ae.length===0?[]:ae.map(([de,oe])=>{const N=pe.get(Le(de));return N?{id:N?.id,name:N?.name,barcode:N?.barcode,stock:Number(N?.quantity||0),price:Number(N?.price||0),quantity:dn(oe,Number(N?.quantity||0))}:null}).filter(Boolean)},[c,pe]),H=l.useMemo(()=>new Set(B.map(ae=>Le(ae?.id))),[B]),ie=l.useMemo(()=>(Array.isArray(B)?B:[]).reduce((de,oe)=>de+Number(oe?.price||0)*Number(oe?.quantity||1),0),[B]),je=l.useMemo(()=>{const ae=Number(g||0);return!Number.isFinite(ae)||ae<=0?0:Math.min(ae,ie)},[g,ie]),K=l.useMemo(()=>Math.max(0,ie-je),[je,ie]),ve=l.useMemo(()=>(Array.isArray(se)?se:[]).slice(0,30).map(ae=>({value:Le(ae?.id),label:`${ae?.name??""}${ae?.barcode?` • ${ae.barcode}`:""}${ae?.quantity!==void 0&&ae?.quantity!==null?` • Stock: ${ae.quantity}`:""}`,product:ae})),[se]),{trigger:Pe}=ze(t&&V?na.search:null,(ae,{arg:de})=>At(ae,{arg:de},t));l.useEffect(()=>{if(!V){v([]);return}const ae=String(h||"").trim();if(ae.length<2){v(ve);return}let de=!0;const oe=setTimeout(async()=>{let N=[];try{if(Pe){const re=await Pe({search:ae});N=Lt(re)}}catch{N=[]}if(!Array.isArray(N)||N.length===0){const re=ae.toLowerCase();N=(Array.isArray(se)?se:[]).filter(we=>{const _e=String(we?.name??"").toLowerCase(),lt=String(we?.barcode??"").toLowerCase();return _e.includes(re)||lt.includes(re)}).slice(0,30)}const G=N.slice(0,30).map(re=>({value:Le(re?.id),label:`${re?.name??""}${re?.barcode?` • ${re.barcode}`:""}${re?.quantity!==void 0&&re?.quantity!==null?` • Stock: ${re.quantity}`:""}`,product:re}));de&&v(G)},250);return()=>{de=!1,clearTimeout(oe)}},[ve,V,Pe,se,h]),l.useEffect(()=>{f({}),m({}),p(""),v([]),C(!1),j(""),_(0),I(""),k(ye()),D([])},[n,r,i]);const ke=l.useCallback((ae,de=1)=>{const oe=ae?.id;if(!oe)return;const N=Number(ae?.quantity||0);if(N<=0){A.error("Out of stock.",{duration:1e3});return}const G=dn(de,N);f(re=>{const we=re||{};return Object.prototype.hasOwnProperty.call(we,Le(oe))?(A.error("Product already added.",{duration:1e3}),we):{...we,[Le(oe)]:G}})},[f]),rt=l.useCallback((ae,de,oe)=>{f(N=>{const G=N||{},re=Le(ae);return Object.prototype.hasOwnProperty.call(G,re)?{...G,[re]:dn(de,oe)}:G})},[]),st=l.useCallback(ae=>{f(de=>{const oe=de||{},N=Le(ae);if(!Object.prototype.hasOwnProperty.call(oe,N))return oe;const G={...oe};return delete G[N],G})},[]),Qe=l.useCallback((ae,de,oe)=>{m(N=>({...N||{},[Le(ae)]:dn(de,oe)}))},[]),He=l.useCallback((ae,de)=>{de?.product&&ke(de.product,1),p(""),v(ve)},[ke,ve]),Ue=l.useCallback(ae=>{if(ae.key!=="Enter")return;ae.preventDefault();const de=Array.isArray(y)&&y.length>0?y[0]:null;if(de?.product){ke(de.product,1),p(""),v(ve);return}const oe=String(h||"").trim().toLowerCase();if(oe.length===0)return;const N=(Array.isArray(se)?se:[]).find(G=>{const re=String(G?.name??"").toLowerCase(),we=String(G?.barcode??"").toLowerCase();return re.includes(oe)||we.includes(oe)});N&&(ke(N,1),p(""),v(ve))},[ke,ve,se,y,h]),Ke=()=>{if(!t){A.error("Missing token.",{duration:1e3});return}if(!n){A.error("Select class.",{duration:1e3});return}if(!r){A.error("Select section.",{duration:1e3});return}if(!i){A.error("Select student.",{duration:1e3});return}if(!B||B.length===0){A.error("Add at least one product.",{duration:1e3});return}C(!0)},{trigger:Be,isMutating:Oe}=ze(t?na.sellProduct:null,(ae,{arg:de})=>es(ae,{arg:de},t)),Fe=async()=>{if(!S){A.error("Select payment type.",{duration:1e3});return}const ae=(Array.isArray(B)?B:[]).map(oe=>({id:oe?.id,quantity:Number(oe?.quantity||1),price:Number(oe?.price||0),total_price:Number(oe?.total_price||0),fk_vendor_id:oe?.fk_vendor_id||"",fk_categoryID:oe?.fk_categoryID||"",name:oe?.name||"",class_id:oe?.class_id||"",fk_sub_categoryID:oe?.fk_sub_categoryID||"",description:oe?.description||"",min_quantity:Number(oe?.min_quantity||0),storecategory:Number(oe?.storecategory||0),barcode:oe?.barcode||""})),de={amount:ie,class:n,section:r,student_id:i,payment_type:S,discount:je,notes:P||"",receipt_date:O?ye(O).format("YYYY-MM-DD"):"",product:JSON.stringify(ae),total_payable_amount:ie,attchement:E[0]?.originFileObj||""};try{const N=Array.isArray(E)&&E.length>0&&E[0]?.originFileObj?(()=>{const re=new FormData;return Object.entries(de).forEach(([we,_e])=>{if(we==="products"){re.append("product",JSON.stringify(_e));return}re.append(we,String(_e??""))}),re.append("attachment",E[0].originFileObj),re})():de,G=await Be(N);G?.Status==="Success"?(A.success("Success! Product sold.",{duration:1e3}),C(!1),f({}),m({}),p(""),v(ve),j(""),_(0),I(""),k(ye()),D([])):A.error(G?.msg??"Failed to submit.",{duration:1e3})}catch{A.error("Failed to submit.",{duration:1e3})}},ot=l.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:(ae,de)=>{const oe=Le(de?.id),N=Number(de?.quantity||0),G=H.has(oe),re=(G?c?.[oe]:w?.[oe])??1;return e.jsx(o.InputNumber,{min:1,max:Number.isFinite(N)&&N>0?N:void 0,value:re,onChange:we=>{G?rt(oe,we,N):Qe(oe,we,N)},disabled:N<=0})}},{title:"Amount",key:"amount",width:140,render:(ae,de)=>{const oe=Le(de?.id),N=(H.has(oe)?c?.[oe]:w?.[oe])??1;return Number(de?.price||0)*Number(N||1)}},{title:"Action",key:"action",width:120,render:(ae,de)=>{const oe=Le(de?.id),N=Number(de?.quantity||0),G=H.has(oe),re=(G?c?.[oe]:w?.[oe])??1;return G?e.jsx(o.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ce.DeleteOutlined,{}),onClick:()=>st(oe),style:{padding:2}}):e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.PlusOutlined,{}),disabled:N<=0,onClick:()=>ke(de,re),style:{padding:2}})}}],[ke,H,c,w,st,Qe,rt]);return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(ne,{pt:5,pb:2,children:[e.jsxs(ne,{style:{padding:"12px 16px"},children:[e.jsx(ne,{children:"Sell Product"}),e.jsx(o.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(le,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:ae=>{const de=ae?.value??"";a(de),s(""),d(""),b(oe=>!oe)}}),e.jsx(le,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:ae=>{const de=ae?.value??"";s(de),d("")}},`section_${u}`),e.jsx(le,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:ae=>d(ae?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(o.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(ne,{style:{marginTop:12},children:"Product Section"}),e.jsx(o.AutoComplete,{value:h,options:y,onSearch:p,onFocus:()=>{V&&String(h||"").trim().length<2&&v(ve)},onSelect:He,disabled:!V,children:e.jsx(o.Input,{placeholder:"Search by product name or barcode",onKeyDown:Ue,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",dt(ie)]})]}),e.jsx(o.Table,{rowKey:ae=>Le(ae?.id),columns:ot,dataSource:se,loading:ue,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:B.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:dt(ie)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(me,{type:"button",value:"Submit",disabled:!V||B.length===0,onClick:Ke,style:{flex:1,minWidth:140}}),e.jsx(o.Button,{type:"text",style:F,onClick:()=>{f({}),m({}),p(""),v(ve)},disabled:B.length===0,children:"Clear"})]})]})]})})]}),e.jsx(o.Modal,{open:T,title:"Payment",onCancel:()=>C(!1),onOk:Fe,confirmLoading:Oe,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(o.Select,{value:S||void 0,onChange:j,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(o.DatePicker,{value:O,onChange:ae=>k(ae),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(o.InputNumber,{min:0,max:ie,value:g,onChange:ae=>_(Number(ae||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(o.Upload,{fileList:E,beforeUpload:()=>!1,onChange:({fileList:ae})=>D((ae||[]).slice(-1)),maxCount:1,children:e.jsx(o.Button,{icon:e.jsx(ce.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(o.Input.TextArea,{value:P,onChange:ae=>I(ae.target.value),rows:3})]}),e.jsx(o.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:dt(ie)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:dt(je)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:dt(K)})]})]})})]})})]})}const Fl=({token:t})=>e.jsx(Ml,{token:t}),jn=Ae.unit,Bl=({token:t,page:n=1,perPage:a=10})=>Zt({baseUrl:jn.list,page:n,perPage:a,token:t}),Nl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function $l({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r,s]=l.useState(!1),[i,d]=l.useState(null),{isLoading:u,error:b,data:h,mutate:p}=Bl({token:t,page:n.page,perPage:n.rowsPerPage}),y=async C=>{try{await p(Qt(jn.add,C,t),We(C)),A.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(S){A.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=C=>{C.preventDefault();const S=new FormData(C.target);y(S),C.target.reset()},w=(C,S)=>{a({page:C,rowsPerPage:parseInt(S,10)})},m=async C=>{try{await p(Xt(jn.remove,C,t),$e(C)),A.success("Success! Deleted item.",{duration:1e3})}catch(S){A.error(S?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},c=C=>{d(C),s(!0)},f=async C=>{C.preventDefault();const S=new FormData(C.target);S.set("id",String(i?.id??""));try{await Et(jn.edit,S,t),await p(),A.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),d(null)}catch(j){A.error(j?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},T=l.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(C,S)=>String(C?.name??"").localeCompare(String(S?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(C,S)=>String(C?.description??"").localeCompare(String(S?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(C,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>c(S),style:{padding:2}}),e.jsx(at,{id:S?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Drawer,{open:r,title:i?.name?`Edit ${i.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{s(!1),d(null)},children:e.jsx("form",{onSubmit:f,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"name",label:"Unit Name",defaultValue:i?.name??"",required:"required"}),e.jsx(z,{type:"text",name:"description",label:"Description",defaultValue:i?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(me,{type:"submit",value:"Update",color:"primary"}),e.jsx(o.Button,{type:"text",onClick:()=>{s(!1),d(null)},style:Nl,children:"Cancel"})]})]})})}),e.jsxs(ne,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(ne,{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(z,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(z,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ne,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Re,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(ne,{pt:3,children:e.jsx(Ee,{parentCallback:w,data:{newData:h,columns:T,columnstype:"antd",action:!1,Loading:u,error:b}})})]})]})]})}const Ul=({token:t})=>e.jsx($l,{token:t}),Ll=Ae.product.sellReports,ql=Ae.academy.classes,zl=Ae.academy.sections,Vl=Ae.student.dropdown,xr=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Yl({token:t}){const n=l.useRef(null),[a,r]=l.useState(null),[s,i]=l.useState(""),[d,u]=l.useState(""),[b,h]=l.useState(""),[p,y]=l.useState(!1),v=D=>{const F=D?.data?.data??D?.data??D??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},{data:w}=X(t?[ql,t]:null,([D,F])=>te(D,F)),m=l.useMemo(()=>v(w),[w]),c=t&&s?`${zl}?class_id=${encodeURIComponent(String(s))}`:null,{data:f}=X(c?[c,t]:null,([D,F])=>te(D,F)),T=l.useMemo(()=>v(f),[f]),C=t&&s&&d?`${Vl}?class=${encodeURIComponent(String(s))}§ion=${encodeURIComponent(String(d))}`:null,{data:S}=X(C?[C,t]:null,([D,F])=>te(D,F)),j=l.useMemo(()=>v(S),[S]),{trigger:g,isMutating:_,data:P}=ze(Ll,(D,{arg:F})=>ha(D,{arg:F},t));l.useEffect(()=>{const F=new Date().toISOString().slice(0,10);g({duration:[F,F]})},[g]);const I=l.useMemo(()=>{const D=P?.data??P??[];return Array.isArray(D)?D:[]},[P]),O=D=>{const F=Array.isArray(D?.product_details)?D.product_details:[];return F.length===0?null:e.jsx(o.Table,{size:"small",bordered:!0,pagination:!1,rowKey:V=>`${D?.receipt_id??"r"}_${V?.product_name??V?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:V=>xr(V)}],dataSource:F})},k=[{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:D=>xr(D)}],E=async()=>{if(!a||a.length!==2)return;const[D,F]=a;await g({duration:[D.format("YYYY-MM-DD"),F.format("YYYY-MM-DD")],class:s||"",section:d||"",student_id:b||""})};return e.jsx("div",{children:e.jsxs(o.Row,{gutter:[16,16],children:[e.jsx(o.Col,{xs:24,lg:8,children:e.jsx(o.Card,{title:e.jsx(o.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(o.DatePicker.RangePicker,{value:a,onChange:r,style:{width:"100%"}})]}),e.jsx(le,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:D=>{const F=D?.value??"";i(F),u(""),h(""),y(V=>!V)}}),e.jsx(le,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:D=>{const F=D?.value??"";u(F),h("")}},`section_${p}`),e.jsx(le,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:D=>h(D?.value??"")}),e.jsx(me,{type:"button",value:_?"Searching...":"Search",disabled:_,onClick:E,style:{width:"100%"}})]})})}),e.jsx(o.Col,{xs:24,lg:16,children:e.jsx(o.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(En,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(Gt,{})}),e.jsx(o.Table,{bordered:!0,size:"small",loading:_,rowKey:D=>String(D?.receipt_id??D?.receipt_no??Math.random()),columns:k,expandable:{expandedRowRender:O},dataSource:I,pagination:{pageSize:20}})]})})})]})})}const Wl=({token:t})=>e.jsx(Yl,{token:t}),Hl=Ae.product;function Kl({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r,s]=l.useState([]),[i,d]=l.useState([]),[u,b]=l.useState(!1),[h,p]=l.useState(!1),[y,v]=l.useState(null),[w,m]=l.useState(0),[c,f]=l.useState(null),[T,C]=l.useState(""),S=l.useRef(null),j=Vt.useReactToPrint({contentRef:S,documentTitle:"Stock Barcodes"}),{isLoading:g,error:_,data:P,mutate:I}=fs({token:t,page:n.page,perPage:n.rowsPerPage}),O=(Z,U)=>{a({page:Z,rowsPerPage:parseInt(U,10)})},k={selectedRowKeys:r,onChange:(Z,U)=>{s(Z),d(U)}},E=Z=>{v(Z),m(Number(Z?.quantity??0)),f(null),C(""),b(!0)},D=()=>{b(!1),v(null),m(0),f(null),C("")},F=async()=>{if(!y?.id)return;p(!0);const Z=new FormData;Z.append("product_id",String(y.id)),Z.append("qty",String(w??0)),c&&Z.append("tran_date",c.format("YYYY-MM-DD")),T&&Z.append("remarks",T);try{const U=await Et(Hl.addStock,Z,t);U?.Status==="Success"?(A.success("Success! Updated quantity.",{duration:1e3}),D(),await I()):A.error(U?.msg??"Failed to update quantity.",{duration:1e3})}catch{A.error("Failed to update quantity.",{duration:1e3})}finally{p(!1)}},V=l.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:(Z,U)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(o.Button,{size:"small",onClick:()=>E(U),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Modal,{title:y?.name?`Update Stock: ${y.name}`:"Update Stock",open:u,onCancel:D,onOk:F,okButtonProps:{loading:h},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(o.InputNumber,{min:0,style:{width:"100%"},value:w,onChange:Z=>m(Z??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(o.DatePicker,{style:{width:"100%"},value:c,onChange:f})]}),e.jsx(da,{label:"Remarks",name:"remarks",rows:3,value:T,onChange:Z=>C(Z.target.value)})]})}),e.jsxs(ne,{pt:5,pb:2,children:[e.jsxs(ne,{children:["Manage Stock",e.jsx(me,{type:"button",value:"Print Barcodes",disabled:!i||i.length===0,onClick:()=>j?.(),style:{minWidth:170}})]}),e.jsx(ne,{style:{padding:"12px 16px"},children:e.jsx(o.Card,{style:{borderRadius:16},children:e.jsx(Ee,{parentCallback:O,data:{newData:P,columns:V,columnstype:"antd",action:!1,Loading:g,error:_,rowSelection:k}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:S,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(i)?i:[]).map(Z=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:Z?.name??""}),e.jsx(Or,{value:String(Z?.barcode??Z?.id??""),height:50,width:1.6,displayValue:!0})]},Z?.id??Z?.barcode??Z?.name))})})})]})}const Jl=({token:t})=>e.jsx(Kl,{token:t}),Gl=Ae.report.stock,Ql=Ae.product.dropdown,Xl=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Zl({token:t}){const n=l.useRef(null),[a,r]=l.useState(null),[s,i]=l.useState(""),{data:d}=X(t?[Ql,t]:null,([m,c])=>te(m,c)),u=l.useMemo(()=>Xl(d),[d]),{trigger:b,isMutating:h,data:p}=ze(Gl,(m,{arg:c})=>ha(m,{arg:c},t));l.useEffect(()=>{const c=new Date().toISOString().slice(0,10);b({duration:[c,c]})},[b]);const y=l.useMemo(()=>{const m=p?.data??p??[];return(Array.isArray(m)?m:[]).flatMap(f=>(Array.isArray(f?.ledger)?f.ledger:[]).map((T,C)=>({key:`${f.product_id??f.product_name??"p"}-${C}`,date:T?.date,product:f?.product_name,opening:T?.opening,inward:T?.inward,outward:T?.outward,closing:T?.closing})))},[p]),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:m=>e.jsx("span",{style:{color:Number(m)<0?"red":"green"},children:m})}],w=async()=>{if(!a||a.length!==2)return;const[m,c]=a;await b({duration:[m.format("YYYY-MM-DD"),c.format("YYYY-MM-DD")],product_id:s||""})};return e.jsxs(o.Card,{title:e.jsx(o.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(o.DatePicker.RangePicker,{value:a,onChange:r}),e.jsxs("select",{value:s,onChange:m=>i(m.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),u.map(m=>e.jsx("option",{value:String(m?.value??""),children:String(m?.label??"")},String(m?.value??m?.id??m?.label)))]}),e.jsx(o.Button,{type:"primary",onClick:w,loading:h,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(En,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(Gt,{})}),e.jsx(o.Table,{bordered:!0,size:"small",loading:h,rowKey:"key",columns:v,dataSource:y,pagination:{pageSize:50}})]})]})}const ed=({token:t})=>e.jsx(Zl,{token:t}),Mn=t=>t??localStorage.getItem("authToken")??"",xa=(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},Se={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"}},ms=()=>xa(pt(),Se.upload),td=()=>xa(pt(),Se.staff.uploadProfile),nd=()=>xa(pt(),Se.staff.uploadDocuments),ad=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const s=t.includes("?")?"&":"?",i=`${t}${s}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return te(i,Mn(r))},ut=async(t,n,a)=>Ge(t,n,Mn(a)),yt=async(t,n,a)=>ft(t,n,Mn(a)),en=async(t,n,a)=>nt(t,n,Mn(a)),jt=Se.staff,rd=Se.master.shift.dropdown,sd=Se.master.department.dropdown,od=Se.master.designation.dropdown,id=Se.roleDropdown,cn=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ld=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",qt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},br={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function dd({token:t,mode:n,staffId:a,initialValues:r,onSubmitted:s}){const i=l.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),d=String(i?.multiple_shift??"").toLowerCase()==="yes",[u,b]=l.useState(r?.roleValue??null),[h,p]=l.useState(r?.departmentValue??null),[y,v]=l.useState(r?.designationValue??null),[w,m]=l.useState(r?.genderValue??null),[c,f]=l.useState(r?.shiftValue??(d?[]:null)),[T,C]=l.useState(r?.dob?ye(r.dob):null),[S,j]=l.useState(r?.doj?ye(r.doj):null),[g,_]=l.useState(r?.file??""),{data:P}=X(t?[rd,t]:null,([W,L])=>te(W,L)),{data:I}=X(t?[sd,t]:null,([W,L])=>te(W,L)),{data:O}=X(t?[od,t]:null,([W,L])=>te(W,L)),{data:k}=X(t?[id,t]:null,([W,L])=>te(W,L)),{data:E}=X(t?[jt.lastEmpNo,t]:null,([W,L])=>te(W,L)),D=l.useMemo(()=>cn(P),[P]),F=l.useMemo(()=>cn(I),[I]),V=l.useMemo(()=>cn(O),[O]),Z=l.useMemo(()=>cn(k),[k]),U=l.useMemo(()=>{const W=E?.data?.emp_number??E?.emp_number??E?.data??"";return String(W??"")},[E]),Y=async W=>{W.preventDefault();const L=new FormData(W.target);L.set("role",u?.value??u??""),L.set("department",h?.value??h??""),L.set("designation",y?.value??y??""),L.set("gender",w?.value??w??""),L.set("dob",T?T.format("YYYY-MM-DD"):""),L.set("doj",S?S.format("YYYY-MM-DD"):""),d?(L.delete("shift_id"),(Array.isArray(c)?c:[]).forEach(R=>{L.append("shift_id[]",R?.value??R??"")})):L.set("shift_id",c?.value??c??""),g&&L.set("file",g);try{const x=n==="edit"&&a,R=x?jt.editBasic:jt.addBasic;x&&L.set("staff_id",String(a));const $=x?await yt(R,L,t):await ut(R,L,t),q=$?.ID??$?.id??a??null;A.success("Success!",{duration:1e3}),s?.({staffId:q,basic:{roleValue:u,departmentValue:h,designationValue:y,genderValue:w,shiftValue:c,dob:T,doj:S,file:g}})}catch(x){A.error(x?.response?.data?.msg??x?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:Y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(z,{type:"number",name:"emp_number",label:"EMP No",defaultValue:r?.emp_number??U,required:!0}),e.jsx(z,{type:"text",name:"f_name",label:"First Name",defaultValue:r?.f_name??"",required:!0}),e.jsx(z,{type:"text",name:"l_name",label:"Last Name",defaultValue:r?.l_name??"",required:!0}),e.jsx(z,{type:"text",name:"pan_no",label:"PAN",defaultValue:r?.pan_no??""}),e.jsx(z,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??""}),e.jsx(le,{label:"Role",options:Z,value:u,onChange:W=>b(W??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(le,{label:"Department",options:F,value:h,onChange:W=>p(W??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(le,{label:"Designation",options:V,value:y,onChange:W=>v(W??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(le,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:w,onChange:W=>m(W??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(z,{type:"text",name:"email",label:"Email",defaultValue:r?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:qt,children:"DOB"}),e.jsx(o.DatePicker,{value:T,onChange:W=>C(W),style:br,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:qt,children:"DOJ"}),e.jsx(o.DatePicker,{value:S,onChange:W=>j(W),style:br,placeholder:"Select DOJ"})]}),e.jsx(z,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:r?.bloodGroup??""}),e.jsx(z,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0}),e.jsx(z,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:qt,children:"Shift"}),e.jsx(le,{options:D,value:c,onChange:W=>f(W??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:qt,children:"Profile Picture"}),e.jsx(o.Upload,{maxCount:1,action:td(),headers:t?{Authorization:t}:void 0,onChange:W=>{if(W?.file?.status==="done"){const L=ld(W?.file?.response);L&&_(L)}W?.file?.status==="removed"&&_("")},children:e.jsx(o.Button,{type:"link",style:{paddingLeft:0},children:g?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:qt,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(me,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const un={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Sr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},cd=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",jr=t=>{if(!t)return null;const n=ye(t);return n.isValid()?n:null};function ud({token:t,mode:n,staffId:a,initialRows:r,onSubmitted:s,onBack:i}){const[d,u]=l.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(m=>({name:m?.name??"",from:jr(m?.from),to:jr(m?.to),image:m?.image??""}))),b=l.useMemo(()=>t?{Authorization:t}:void 0,[t]),h=(w,m)=>{u(c=>c.map((f,T)=>T===w?{...f,...m}:f))},p=()=>u(w=>[...w,{name:"",from:null,to:null,image:""}]),y=w=>u(m=>m.length<=1?m:m.filter((c,f)=>f!==w)),v=async w=>{if(w.preventDefault(),!a){A.error("Missing staff id.",{duration:1e3});return}const m=new FormData;m.append("staff_id",String(a)),d.forEach((c,f)=>{m.append(`experience[${f}][name]`,String(c?.name??"")),m.append(`experience[${f}][from]`,c?.from?c.from.format("YYYY-MM-DD"):""),m.append(`experience[${f}][to]`,c?.to?c.to.format("YYYY-MM-DD"):""),m.append(`experience[${f}][image]`,String(c?.image??""))});try{const c=n==="edit",f=c?jt.editExperience:jt.addExperience,T=c?await yt(f,m,t):await ut(f,m,t);A.success("Success!",{duration:1e3}),s?.({experience:d,result:T})}catch(c){A.error(c?.response?.data?.msg??c?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:v,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:un,children:"Name"}),e.jsx("input",{value:w.name,onChange:c=>h(m,{name:c.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:un,children:"From"}),e.jsx(o.DatePicker,{value:w.from,onChange:c=>h(m,{from:c}),style:Sr})]}),e.jsxs("div",{children:[e.jsx("div",{style:un,children:"To"}),e.jsx(o.DatePicker,{value:w.to,onChange:c=>h(m,{to:c}),style:Sr})]}),e.jsxs("div",{children:[e.jsx("div",{style:un,children:"Document"}),e.jsx(o.Upload,{maxCount:1,action:nd(),headers:b,onChange:c=>{if(c?.file?.status==="done"){const f=cd(c?.file?.response);f&&h(m,{image:f})}c?.file?.status==="removed"&&h(m,{image:""})},children:e.jsx(o.Button,{icon:e.jsx(ce.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(o.Button,{type:"text",icon:e.jsx(ce.DeleteOutlined,{}),danger:!0,onClick:()=>y(m),disabled:d.length<=1})})]},`exp-${m}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(o.Button,{icon:e.jsx(ce.PlusOutlined,{}),onClick:p,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(o.Button,{onClick:i,children:"Back"}),e.jsx(me,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const wr=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:n??[]},zt=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function pd({token:t,mode:n,staffId:a,initialValues:r,onSubmitted:s,onBack:i}){const[d,u]=l.useState(r?.type??"Permanent"),[b,h]=l.useState(r?.salary_type??zt[0]?.value),[p,y]=l.useState(Number(r?.amount??0)),[v,w]=l.useState(Number(r?.basic_pay??0)),[m,c]=l.useState(r?.declarationPERyear??""),{data:f}=X(t?[ri,t]:null,([_,P])=>te(_,P),{revalidateOnFocus:!1}),T=l.useMemo(()=>wr(f?.Allowances),[f]),C=l.useMemo(()=>wr(f?.Dedection),[f]),S=l.useMemo(()=>{const _=Number(v||0),P=(Array.isArray(T)?T:[]).map(D=>{const F=D?.amount_type??D?.amountType??D?.type,V=Number(D?.Amount??D?.amount??0),Z=String(F).toLowerCase()==="flat"?V:Number(_)/100*Number(V||0);return{...D,value:Number.isFinite(Z)?Z:0}}),I=(Array.isArray(C)?C:[]).map(D=>{const F=D?.amount_type??D?.amountType??D?.type,V=Number(D?.Amount??D?.amount??0),Z=String(F).toLowerCase()==="flat"?V:Number(_)/100*Number(V||0);return{...D,value:Number.isFinite(Z)?Z:0}}),O=P.reduce((D,F)=>D+Number(F?.value||0),0),k=I.reduce((D,F)=>D+Number(F?.value||0),0),E=Math.max(0,Number(_)+O-k);return{allowances:P,deductions:I,netAmount:E}},[T,C,v]),j=async _=>{if(_.preventDefault(),!a){A.error("Missing staff id.",{duration:1e3});return}const P=new FormData;P.append("staff_id",String(a)),P.append("type",d),d==="Nonpermanent"?(P.append("salary_type",b??""),P.append("amount",String(p||"")),P.append("Allowances",JSON.stringify([])),P.append("Dedection",JSON.stringify([]))):(P.append("basic_pay",String(v||"")),P.append("declarationPERyear",String(m??"")),P.append("Allowances",JSON.stringify(S.allowances||[])),P.append("Dedection",JSON.stringify(S.deductions||[])),P.append("amount",String(S.netAmount||0)));try{const I=n==="edit",O=I?jt.editPayroll:jt.addPayroll,k=I?await yt(O,P,t):await ut(O,P,t);A.success("Success!",{duration:1e3}),s?.({payroll:{staffType:d,salaryType:b,amount:p,basicPay:v,declaration:m},result:k})}catch(I){A.error(I?.response?.data?.msg??I?.message??"Failed.",{duration:1e3})}},g=l.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(_,P)=>`${P?.Amount??""} / ${P?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:j,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(le,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:_=>u(_?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(le,{label:"Type",options:zt,value:zt.find(_=>_.value===b)??zt[0],onChange:_=>h(_?.value??zt[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(z,{type:"number",label:"Amount",value:p,onChange:_=>y(Number(_.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(z,{type:"number",label:"Basic Pay",value:v,onChange:_=>w(Number(_.target.value||0)),required:!0}),e.jsx(z,{type:"text",label:"IT Declarations/Year",value:m,onChange:_=>c(_.target.value)}),e.jsx(z,{type:"number",label:"Net Amount",value:S.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(o.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(o.Table,{bordered:!0,size:"small",rowKey:(_,P)=>`${_?.title??"a"}-${P}`,columns:g,dataSource:S.allowances,pagination:!1})}),e.jsx(o.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(o.Table,{bordered:!0,size:"small",rowKey:(_,P)=>`${_?.title??"d"}-${P}`,columns:g,dataSource:S.deductions,pagination:!1})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(Button,{onClick:i,children:"Back"}),e.jsx(me,{type:"submit",value:"Finish",color:"primary"})]})]})})}const fd=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function md({token:t,mode:n="add",staffId:a,onFinished:r}){const[s,i]=l.useState(0),[d,u]=l.useState(a??null),[b,h]=l.useState(null),[p,y]=l.useState(null),[v,w]=l.useState(null),m=n==="edit"?a??d:null,c=l.useMemo(()=>m?`${Se.staff.basicById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),f=l.useMemo(()=>m?`${Se.staff.experienceById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),T=l.useMemo(()=>m?`${Se.staff.payrollById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),{data:C}=X(t&&c?[c,t]:null,([O,k])=>te(O,k)),{data:S}=X(t&&f?[f,t]:null,([O,k])=>te(O,k)),{data:j}=X(t&&T?[T,t]:null,([O,k])=>te(O,k)),g=l.useMemo(()=>{const O=fd(C)[0]??C?.data??C??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},[C]),_=l.useMemo(()=>{const O=S?.data??S??null;return(Array.isArray(O?.experience)?O.experience:Array.isArray(O)?O:[]).map(E=>({name:E?.name??"",from:E?.from??"",to:E?.to??"",image:E?.image??""}))},[S]),P=l.useMemo(()=>{const O=j?.data??j??null;return O?{type:O?.type??"Permanent",salary_type:O?.salary_type??"",amount:O?.amount??"",basic_pay:O?.basic_pay??"",declarationPERyear:O?.declarationPERyear??""}:null},[j]),I=l.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Card,{title:e.jsx(o.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(o.Steps,{current:s,items:I}),s===0&&e.jsx(dd,{token:t,mode:n,staffId:m,initialValues:g,onSubmitted:({staffId:O})=>{O&&u(O),i(1)}}),s===1&&e.jsx(ud,{token:t,mode:n,staffId:m??d,initialRows:_,onBack:()=>i(0),onSubmitted:()=>i(2)}),s===2&&e.jsx(pd,{token:t,mode:n,staffId:m??d,initialValues:P,onBack:()=>i(1),onSubmitted:()=>{A.success("Completed.",{duration:1e3}),r?.({staffId:m??d})}})]})})]})}function hd({token:t}){return e.jsx(md,{token:t,mode:"add"})}const yd=({token:t})=>e.jsx(hd,{token:t}),pn=Se.staff,gd=Se.roleDropdown,xd=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},bd=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Sd({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r,s]=l.useState(""),[i,d]=l.useState(""),{data:u}=X(t?[gd,t]:null,([T,C])=>te(T,C)),b=l.useMemo(()=>xd(u),[u]),h=l.useMemo(()=>{const T=n.page,C=n.rowsPerPage,S=r&&!i?`${pn.searchByRole}?role_id=${encodeURIComponent(String(r))}`:i?`${pn.searchByKeywords}?key=${encodeURIComponent(String(i))}`:pn.list,j=S.includes("?")?"&":"?";return`${S}${j}page=${encodeURIComponent(String(T))}&per_page=${encodeURIComponent(String(C))}`},[n.page,n.rowsPerPage,i,r]),{isLoading:p,error:y,data:v,mutate:w}=X(t?[h,t]:null,([T,C])=>te(T,C)),m=l.useMemo(()=>bd(v),[v]),c=async T=>{const C=T?.id??T?.fk_staffID??T?.staff_id;if(C)try{await en(pn.deactivate,C,t),A.success("Success! Staff deactivated.",{duration:1e3}),await w()}catch(S){A.error(S?.response?.data?.msg??S?.message??"Failed to deactivate staff.",{duration:1e3})}},f=l.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(T,C)=>`${C?.firstname??C?.first_name??""} ${C?.lastname??C?.last_name??""}`.trim()||C?.name||""},{title:"Role",dataIndex:"role_name",key:"role_name",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["lg"]},{title:"Status",dataIndex:"status",key:"status",width:120,responsive:["lg"]},{title:"Action",key:"action",width:90,fixed:"right",render:(T,C)=>e.jsx(o.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ce.DeleteOutlined,{}),onClick:()=>c(C),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(A.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(o.Card,{title:e.jsx(o.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(le,{options:[{value:"",label:"All Roles"},...b],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:T=>{s(T?.value??""),a(C=>({...C,page:1}))}}),e.jsx(z,{type:"text",label:"Keyword",value:i,onChange:T=>d(T.target.value),placeholder:"Search by keywords"}),e.jsx(me,{type:"button",value:"Refresh",onClick:()=>w()})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(o.Table,{bordered:!0,size:"small",loading:p,rowKey:T=>String(T?.id??T?.fk_staffID??T?.staff_id??Math.random()),columns:f,dataSource:m,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(T,C)=>a({page:T,rowsPerPage:C}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const jd=({token:t})=>e.jsx(Sd,{token:t}),wd=Se.attendance,vd=Se.roleDropdown,vr=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},fn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},_r={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function _d({token:t,open:n,onClose:a,roleId:r,onSaved:s}){const[i,d]=l.useState(null),[u,b]=l.useState(""),[h,p]=l.useState(ye()),[y,v]=l.useState(ye()),[w,m]=l.useState(ye()),c=l.useMemo(()=>r?`${Se.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:f}=X(t&&c?[c,t]:null,([_,P])=>te(_,P)),T=l.useMemo(()=>vr(f),[f]),{trigger:C,data:S}=ze(t?Se.attendance.staffShiftByStaffId:null,(_,{arg:P})=>At(_,{arg:P},t)),j=l.useMemo(()=>vr(S),[S]),g=async()=>{if(!i?.value){A.error("Select staff.",{duration:1e3});return}if(!u){A.error("Select shift.",{duration:1e3});return}const _=new FormData;_.set("staffID",String(i.value)),_.set("shift_id",String(u)),_.set("attendance_date",h?h.format("YYYY-MM-DD"):""),_.set("intime",y?y.format("h:mm a"):""),_.set("outime",w?w.format("h:mm a"):"");try{await ut(Se.attendance.manualAttendance,_,t),A.success("Success!",{duration:1e3}),s?.(),a?.(),d(null),b(""),p(ye()),v(ye()),m(ye())}catch(P){A.error(P?.response?.data?.msg??P?.message??"Failed.",{duration:1e3})}};return e.jsx(o.Modal,{open:n,onCancel:a,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(o.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(le,{label:"Staff",options:T,value:i,onChange:async _=>{if(d(_??null),b(""),_?.value&&C)try{await C({staff_id:_.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:fn,children:"Shift"}),e.jsx(o.Radio.Group,{value:u,onChange:_=>b(_.target.value),style:{display:"grid",gap:8},children:j.map(_=>e.jsx(o.Radio,{value:_?.value,children:_?.label??_?.name??_?.title??String(_?.value??"")},String(_?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:fn,children:"Date"}),e.jsx(o.DatePicker,{value:h,onChange:_=>_&&p(_),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:fn,children:"Start Time"}),e.jsx(o.TimePicker,{value:y,onChange:_=>_&&v(_),use12Hours:!0,format:"h:mm a",style:_r})]}),e.jsxs("div",{children:[e.jsx("div",{style:fn,children:"End Time"}),e.jsx(o.TimePicker,{value:w,onChange:_=>_&&m(_),use12Hours:!0,format:"h:mm a",style:_r})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(o.Button,{onClick:a,children:"Cancel"}),e.jsx(me,{type:"button",value:"Save",color:"primary",onClick:g})]})]})})})}const Cd=({tableRef:t,excelDisabled:n})=>{const a=new Date().getTime(),r=Vt.useReactToPrint({content:()=>t?.current});return e.jsx(o.Row,{justify:"end",children:e.jsx(o.Col,{children:e.jsxs(o.Row,{gutter:8,children:[e.jsx(o.Col,{children:e.jsx(o.Button,{type:"text",icon:e.jsx(ce.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(o.Col,{children:n?e.jsx(o.Button,{type:"text",icon:e.jsx(ce.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>A.error("You must save attendance before download",{duration:2e3})}):e.jsx(ds.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:t?.current,children:e.jsx(o.Button,{type:"text",icon:e.jsx(ce.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},Td=(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:[]:[]},Rd=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},Dd=(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 Ad({token:t,url:n,columns:a,reload:r,setReload:s,saveBtnRef:i,setSaveBtnDisabled:d,date:u,type:b="staff"}){const h=l.useRef(null),[p,y]=l.useState({page:0,rowsPerPage:10}),[v,w]=l.useState(!1),[m,c]=l.useState(!1),[f,T]=l.useState(null),[C,S]=l.useState([]),[j,g]=l.useState({sunday:!1,holiday:!1}),[_,P]=l.useState(!0);l.useEffect(()=>{y(E=>({...E,page:0}))},[n]),l.useEffect(()=>{let E=!0;return(async()=>{if(!(!t||!n)){w(!0);try{const F=String(n).includes("?")?"&":"?",V=`${n}${F}page=${p.page+1}&per_page=${p.rowsPerPage}`,Z=await te(V,t);if(!E)return;T(Z),Z?.Status==="Success"?(d?.(!1),S(Td(Z,b)),g(Dd(Z,b))):(d?.(!0),S([]),g({sunday:!1,holiday:!1}))}catch{if(!E)return;d?.(!0),S([])}finally{E&&w(!1)}}})(),()=>{E=!1}},[p.page,p.rowsPerPage,r,d,t,b,n]);const I=l.useMemo(()=>Rd(f),[f]);l.useEffect(()=>{const E=(Array.isArray(C)?C:[]).find(D=>D?.attendence_type_id===null);P(!!E)},[C]);const O=async()=>{if(t){c(!0);try{if(b==="staff"){const E=(Array.isArray(C)?C:[]).map(D=>({staff_id:D?.staff_id,attendence_type_id:D?.attendence_type_id?D.attendence_type_id:"1",in_time:D?.intime,out_time:D?.outtime,date:u}));await ut(Se.attendance.addAttendanceToStaffByBranch,E,t),A.success("Attendance saved successfully",{duration:2e3}),s?.(D=>!D)}else A.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(E){A.error(E?.response?.data?.msg??E?.message??"Failed required dates",{duration:2e3})}finally{c(!1)}}},k=l.useMemo(()=>(Array.isArray(a)?a:[]).map(D=>D?.selector==="attendence_type_id"?{title:D?.name??"Attendance",dataIndex:D.selector,key:D.selector,render:F=>F==null||F===""?e.jsx(o.Tag,{color:"orange",children:"Not Set"}):String(F)==="1"?e.jsx(o.Tag,{color:"green",children:"Present"}):String(F)==="4"?e.jsx(o.Tag,{color:"red",children:"Absent"}):String(F)==="3"?e.jsx(o.Tag,{color:"orange",children:"Late"}):e.jsx(o.Tag,{children:String(F)})}:D?.selector==="snum"?{title:D?.name??"Sl",key:D.selector,render:(F,V,Z)=>Z+1}:{title:D?.name??D?.selector,dataIndex:D?.selector,key:D?.selector}),[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(o.Card,{children:[e.jsx(Cd,{tableRef:h,excelDisabled:_}),e.jsx(o.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(o.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),j.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):j.holiday?e.jsx("div",{style:{textAlign:"center",padding:"16px 0"},children:e.jsx("div",{style:{fontWeight:700,marginBottom:6},children:"Holiday"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:h,children:e.jsx(o.Table,{bordered:!0,size:"small",rowKey:(E,D)=>String(E?.id??E?.staff_id??D),columns:k,dataSource:C,loading:v,pagination:{current:p.page+1,pageSize:p.rowsPerPage,total:I,showSizeChanger:!0,onChange:(E,D)=>y({page:E-1,rowsPerPage:D})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:O,ref:i,style:{display:"none"},children:"hidden"})]})]})]})}const Od=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Pd={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Id({token:t}){const[n,a]=l.useState(""),[r,s]=l.useState(ye().format("YYYY-MM-DD")),[i,d]=l.useState(!1),[u,b]=l.useState(null),[h,p]=l.useState(!1),[y,v]=l.useState(!0),[w,m]=l.useState(!1),c=l.useRef(null),{data:f}=X(t?[vd,t]:null,([S,j])=>te(S,j)),T=l.useMemo(()=>Od(f),[f]),C=l.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(o.Card,{title:e.jsx(o.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(le,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:S=>a(S?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(o.DatePicker,{defaultValue:ye(),onChange:S=>S&&s(S.format("YYYY-MM-DD")),style:Pd,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!r||(b(`${wd.staffListForAttendance}?role=${encodeURIComponent(String(n))}&date=${encodeURIComponent(String(r))}`),d(S=>!S))}})})]})}),e.jsxs(o.Card,{title:e.jsx(o.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(o.Button,{size:"small",type:h?"primary":"default",onClick:()=>p(S=>!S),children:h?"Marked":"Mark As Holiday"}),e.jsx(o.Button,{size:"small",type:"default",disabled:y,onClick:()=>m(!0),children:"Give Attendance"})]}),u?e.jsx(Ad,{token:t,url:u,columns:C,reload:i,setReload:d,saveBtnRef:c,setSaveBtnDisabled:v,date:r,type:"staff",holidayChecked:h}):null]}),e.jsx(_d,{token:t,open:w,onClose:()=>m(!1),roleId:n,onSaved:()=>d(S=>!S)})]})}const Ed=({token:t})=>e.jsx(Id,{token:t}),Cr=Se.attendanceReport.monthlyStaffReport,kd=Se.roleDropdown,Md=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Fd({token:t}){const n=l.useRef(null),[a,r]=l.useState(!1),[s,i]=l.useState([]),[d,u]=l.useState({role:"",rolllabel:"",year:"",month:""}),b=l.useMemo(()=>ss(5),[]),{data:h}=X(t?[kd,t]:null,([E,D])=>te(E,D)),p=l.useMemo(()=>Md(h),[h]),[y,v]=l.useState([]),[w,m]=l.useState(1),[c,f]=l.useState(!1),[T,C]=l.useState(!1),[S,j]=l.useState(null),g=l.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:_}=ze(t&&Cr?`${Cr}?page=${w}&per_page=3`:null,(E,{arg:D})=>At(E,{arg:D},t),{onSuccess:E=>{f(!1);const D=Array.isArray(E)?E:[];D.length>0&&v(F=>[...F||[],...D]),D.length>1?m(F=>F+1):C(!1)},onError:()=>{f(!1),C(!1)}});l.useEffect(()=>{T&&_&&S&&_(S)},[T,w,S,_]);const P=l.useMemo(()=>{const E=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(D,F)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:F?.full_name??""})}];return Array.isArray(y)&&y.length>0&&((y[0]?.monthly_data??[]).forEach((F,V)=>{E.push({title:V+1,align:"center",key:String(V+1),render:(Z,U)=>{const Y=U?.monthly_data?.[V]?.[0]?.data?.[0]??{},W=Y?.intime??"",L=Y?.outtime??"",x=Y?.attendance_type??"";return e.jsx(o.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",W]}),e.jsxs("div",{children:["Out Time ",L]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:_t(x)})})}})}),E.push({title:"Total",key:"Total",render:(F,V)=>{const Z=V?.monthly_data??[],U=Z.filter(W=>W?.[0]?.data?.[0]?.attendance_type==="A").length,Y=Z.filter(W=>W?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",U," P : ",Y]})})}})),E},[y]),I=l.useMemo(()=>[{label:"Present",el:_t("P")},{label:"Absent",el:_t("A")},{label:"Leave",el:_t("L")},{label:"Weekly Off",el:_t("W")},{label:"Holiday",el:_t("H")}],[]),O=l.useMemo(()=>d.month?s.find(E=>E?.value==d.month)?.label??d.month??"--":"--",[d.month,s]),k=async E=>{if(E.preventDefault(),!d.role||!d.year||!d.month)return;m(1),f(!0),v([]);const D={session:g,year:d.year,month:d.month,day:"01",role:d.role};j(D),C(!0),await _?.(D)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(o.Card,{className:"d-print-none",title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:k,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(le,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:E=>u(D=>({...D,role:E?.value??"",rolllabel:E?.label??""}))}),e.jsx(le,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:E=>{const D=os(E?.value);i(D),r(F=>!F),u(F=>({...F,year:E?.label??""}))}}),e.jsx(le,{options:s,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:E=>u(D=>({...D,month:E?.value??""}))},`month-${a}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(o.Card,{title:e.jsx(o.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(Gt,{})}),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(En,{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:I.map(E=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[E.label," :"]}),e.jsx("div",{children:E.el})]},E.label))})})]}),e.jsx(o.Skeleton,{active:!0,loading:c,paragraph:{rows:10},children:e.jsx(o.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:P,dataSource:y,pagination:!1,scroll:{x:"max-content"},rowKey:(E,D)=>String(E?.staff_id??E?.id??D)})})]})})]})}const Bd=({token:t})=>e.jsx(Fd,{token:t}),Tr=Se.payroll,Nd=Se.roleDropdown,$d=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Ud=t=>t?.data?.data??t?.data??t??[];function Ld({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:a}){const[r,s]=l.useState({page:1,rowsPerPage:10}),[i,d]=l.useState(!1),[u,b]=l.useState([]),[h,p]=l.useState({role:"",roleLabel:"",year:"",month:""}),[y,v]=l.useState(null),w=P=>{if(!P)return;if(typeof a=="function"){a(P);return}const I=`${n}?id=${encodeURIComponent(String(P))}`;typeof window<"u"&&window?.location&&(window.location.href=I)},{data:m}=X(t?[Nd,t]:null,([P,I])=>te(P,I)),c=l.useMemo(()=>$d(m),[m]),f=l.useMemo(()=>ss(5),[]),{isLoading:T,error:C,data:S}=X(t&&y?[y,t]:null,([P,I])=>te(P,I)),j=l.useMemo(()=>{const P=Ud(S);return Array.isArray(P)?P:[]},[S]),g=l.useMemo(()=>{const P=S?.pagination?.total_rows??S?.data?.pagination?.total_rows??S?.total??S?.total_rows,I=Number(P);return Number.isFinite(I)&&I>=0?I:j.length},[S,j.length]),_=l.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(P,I,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:(P,I)=>{const O=I?.id??I?.staff_id??I?.staffId;return e.jsx(o.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{w(O)},children:is(I?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:P=>{if(P.preventDefault(),!h.role||!h.year||!h.month)return;const I=`${Tr.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(h.role))}&year=${encodeURIComponent(String(h.year))}&month=${encodeURIComponent(String(h.month))}`;v(I)},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(le,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:P=>p(I=>({...I,role:P?.value??"",roleLabel:P?.label??""}))}),e.jsx(le,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:P=>{const I=os(P?.value);b(I),d(O=>!O),p(O=>({...O,year:P?.label??"",month:""}))}}),e.jsx(le,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:P=>p(I=>({...I,month:P?.value??""}))},`month-${i}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"submit",value:"Search",color:"primary",onClick:()=>s(P=>({...P,page:1}))})})]})}),e.jsx(o.Table,{bordered:!0,size:"small",loading:T,rowKey:(P,I)=>String(P?.id??P?.staff_id??I),columns:_,dataSource:j,pagination:{current:r.page,pageSize:r.rowsPerPage,total:g,showSizeChanger:!0,onChange:(P,I)=>{s({page:P,rowsPerPage:I}),!(!h.role||!h.year||!h.month)&&v(`${Tr.payrollByRole}?page=${encodeURIComponent(String(P))}&per_page=${encodeURIComponent(String(I))}&role=${encodeURIComponent(String(h.role))}&year=${encodeURIComponent(String(h.year))}&month=${encodeURIComponent(String(h.month))}`)}},scroll:{x:"max-content"}})]})})}const qd=({token:t})=>e.jsx(Ld,{token:t}),hs=Se.leave,kt=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>X(r&&t?[t,n,a,r]:null,([i,d,u,b])=>ad({baseUrl:i,page:d,perPage:u},b)),zd=({token:t,page:n=1,perPage:a=10})=>kt({token:t,baseUrl:hs.requestTable,page:n,perPage:a}),Vd=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Yd=(t,n)=>{const a=new FormData;return Object.entries(t??{}).forEach(([r,s])=>{s!=null&&a.append(r,String(s))}),a.set("status",n),a};function Wd({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),{isLoading:r,error:s,data:i,mutate:d}=zd({token:t,page:n.page,perPage:n.rowsPerPage}),u=l.useMemo(()=>Vd(i),[i]),b=async(p,y)=>{try{const v=Yd(p,y),w=await yt(hs.approveRequest,v,t);w?.Status==="Success"?A.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):A.error(w?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(v){A.error(v?.response?.data?.msg??v?.message??"Failed to update request.",{duration:1e3})}},h=l.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(p,y)=>y?.full_name??y?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(p,y)=>y?.leave_from??y?.from_date??""},{title:"To",key:"leave_to",width:120,render:(p,y)=>y?.leave_to??y?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(p,y)=>y?.leavetype??y?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(p,y)=>y?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(p,y)=>y?.employee_remark??y?.reason??""},{title:"View",key:"document_file",width:140,render:(p,y)=>{const v=y?.document_file;return v?e.jsx(o.Button,{size:"small",onClick:()=>window.open(v,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(p,y)=>{const v=String(y?.status??"").toLowerCase();return v==="approved"?e.jsx(o.Tag,{color:"green",children:"Approved"}):v==="declined"?e.jsx(o.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(o.Button,{type:"text",size:"small",onClick:()=>b(y,"approved"),icon:e.jsx(ce.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(o.Button,{type:"text",size:"small",onClick:()=>b(y,"declined"),icon:e.jsx(ce.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(o.Table,{bordered:!0,size:"small",loading:r,rowKey:(p,y)=>String(p?.id??p?.leave_id??y),columns:h,dataSource:u,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(p,y)=>a({page:p,rowsPerPage:y}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Hd=({token:t})=>e.jsx(Wd,{token:t}),Kd=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Jd=({token:t,value:n,onChange:a})=>{const r=l.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(o.Upload,{maxCount:1,action:ms(),headers:r,onChange:s=>{if(s?.file?.status==="done"){const i=Kd(s?.file?.response);i&&a?.(i)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},ys=Se.leave,Gd=Se.master.leaveType.dropdown,Qd=({token:t,page:n=1,perPage:a=10})=>kt({token:t,baseUrl:ys.table,page:n,perPage:a}),Xd=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},aa={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Zd({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r,s]=l.useState(!1),[i,d]=l.useState(""),[u]=o.Form.useForm(),{isLoading:b,error:h,data:p,mutate:y}=Qd({token:t,page:n.page,perPage:n.rowsPerPage}),{data:v}=X(t?[Gd,t]:null,([j,g])=>te(j,g)),w=l.useMemo(()=>Xd(v),[v]),m=(j,g)=>a({page:j,rowsPerPage:parseInt(g,10)}),c=()=>{d(""),u.resetFields(),u.setFieldsValue({apply_date:ye()}),s(!0)},f=()=>{s(!1),d(""),u.resetFields()},T=async j=>{const g=new FormData;g.set("apply_date",j?.apply_date?j.apply_date.format("YYYY-MM-DD"):""),g.set("leave_type",j?.leave_type?.value??j?.leave_type??""),g.set("from_date",j?.from_date?j.from_date.format("YYYY-MM-DD"):""),g.set("to_date",j?.to_date?j.to_date.format("YYYY-MM-DD"):""),g.set("reason",j?.reason??""),i&&g.set("file",i);try{await ut(ys.apply,g,t),A.success("Success! Leave request submitted.",{duration:1e3}),f(),await y()}catch(_){A.error(_?.response?.data?.msg??_?.message??"Failed to submit leave request.",{duration:1e3})}},C=l.useMemo(()=>{const j=p?.data??p??[];return Array.isArray(j)?j:Array.isArray(j?.data)?j.data:[]},[p]),S=l.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(j,g)=>g?.leavetype??g?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(j,g)=>g?.date??g?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(j,g)=>g?.leave_from??g?.from_date??""},{title:"To",key:"leave_to",width:130,render:(j,g)=>g?.leave_to??g?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(j,g)=>g?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Modal,{open:r,title:"Add Leave Request",onCancel:f,footer:null,destroyOnClose:!0,children:e.jsxs(o.Form,{form:u,layout:"vertical",onFinish:T,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(o.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(o.DatePicker,{style:aa})]})}),e.jsx(o.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(le,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsx(o.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(o.DatePicker,{style:aa})]})}),e.jsx(o.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(o.DatePicker,{style:aa})]})}),e.jsx(o.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(z,{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(Jd,{token:t,value:i,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(o.Button,{onClick:f,children:"Cancel"}),e.jsx(me,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(me,{type:"button",value:"Add Leave Request",onClick:c})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(o.Table,{bordered:!0,size:"small",loading:b,rowKey:(j,g)=>String(j?.id??j?.leave_id??g),columns:S,dataSource:C,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(j,g)=>m(j,g),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const ec=({token:t})=>e.jsx(Zd,{token:t}),wn=Se.master.leaveType,tc=({token:t,page:n=1,perPage:a=10})=>kt({token:t,baseUrl:wn.table,page:n,perPage:a});function nc({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r]=o.Form.useForm(),[s]=o.Form.useForm(),[i,d]=l.useState(!1),[u,b]=l.useState(null),{isLoading:h,error:p,data:y,mutate:v}=tc({token:t,page:n.page,perPage:n.rowsPerPage}),w=(j,g)=>{a({page:j,rowsPerPage:parseInt(g,10)})},m=async j=>{const g=new FormData;g.set("title",j?.title??"");try{await v(ut(wn.add,g,t),We(g)),A.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(_){A.error(_?.response?.data?.msg??_?.message??"Failed to add leave type.",{duration:1e3})}},c=j=>{b(j??null),s.setFieldsValue({title:j?.leave_type_name??j?.name??""}),d(!0)},f=()=>{d(!1),b(null),s.resetFields()},T=async j=>{const g=u?.id??u?.leave_type_id;if(!g){A.error("Missing leave type id.",{duration:1e3});return}const _=new FormData;_.set("id",String(g)),_.set("title",j?.title??"");try{await yt(wn.edit,_,t),await v(),A.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),f()}catch(P){A.error(P?.response?.data?.msg??P?.message??"Failed to update leave type.",{duration:1e3})}},C=async j=>{const g=j?.id??j?.leave_type_id;if(g)try{await v(en(wn.remove,g,t),$e(g)),A.success("Success! Deleted leave type.",{duration:1e3})}catch(_){A.error(_?.response?.data?.msg??_?.message??"Failed to delete leave type.",{duration:1e3})}},S=l.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(j,g)=>e.jsxs(o.Space,{size:6,children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>c(g)}),e.jsx(o.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>C(g),children:e.jsx(o.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ce.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Modal,{open:i,title:"Edit Leave Type",onCancel:f,footer:null,destroyOnClose:!0,children:e.jsxs(o.Form,{form:s,layout:"vertical",onFinish:T,children:[e.jsx(o.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(o.Button,{onClick:f,children:"Cancel"}),e.jsx(me,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(o.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(o.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(me,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Ee,{parentCallback:w,data:{newData:y,columns:S,columnstype:"antd",action:!1,Loading:h,error:p}})})]})}const ac=({token:t})=>e.jsx(nc,{token:t}),vn=Se.master.department,rc=({token:t,page:n=1,perPage:a=10})=>kt({token:t,baseUrl:vn.table,page:n,perPage:a});function sc({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r]=o.Form.useForm(),[s]=o.Form.useForm(),[i,d]=l.useState(!1),[u,b]=l.useState(null),{isLoading:h,error:p,data:y,mutate:v}=rc({token:t,page:n.page,perPage:n.rowsPerPage}),w=(j,g)=>{a({page:j,rowsPerPage:parseInt(g,10)})},m=async j=>{const g=new FormData;g.set("title",j?.title??"");try{await v(ut(vn.add,g,t),We(g)),A.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(_){A.error(_?.response?.data?.msg??_?.message??"Failed to add department.",{duration:1e3})}},c=j=>{b(j??null),s.setFieldsValue({title:j?.department_name??j?.name??""}),d(!0)},f=()=>{d(!1),b(null),s.resetFields()},T=async j=>{const g=u?.id??u?.department_id;if(!g){A.error("Missing department id.",{duration:1e3});return}const _=new FormData;_.set("id",String(g)),_.set("title",j?.title??"");try{await yt(vn.edit,_,t),await v(),A.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),f()}catch(P){A.error(P?.response?.data?.msg??P?.message??"Failed to update department.",{duration:1e3})}},C=async j=>{const g=j?.id??j?.department_id;if(g)try{await v(en(vn.remove,g,t),$e(g)),A.success("Success! Deleted department.",{duration:1e3})}catch(_){A.error(_?.response?.data?.msg??_?.message??"Failed to delete department.",{duration:1e3})}},S=l.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(j,g)=>e.jsxs(o.Space,{size:6,children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>c(g)}),e.jsx(o.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>C(g),children:e.jsx(o.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ce.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Modal,{open:i,title:"Edit Department",onCancel:f,footer:null,destroyOnClose:!0,children:e.jsxs(o.Form,{form:s,layout:"vertical",onFinish:T,children:[e.jsx(o.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(o.Button,{onClick:f,children:"Cancel"}),e.jsx(me,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(o.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(o.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(me,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Ee,{parentCallback:w,data:{newData:y,columns:S,columnstype:"antd",action:!1,Loading:h,error:p}})})]})}const oc=({token:t})=>e.jsx(sc,{token:t}),_n=Se.master.designation,ic=({token:t,page:n=1,perPage:a=10})=>kt({token:t,baseUrl:_n.table,page:n,perPage:a});function lc({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r]=o.Form.useForm(),[s]=o.Form.useForm(),[i,d]=l.useState(!1),[u,b]=l.useState(null),{isLoading:h,error:p,data:y,mutate:v}=ic({token:t,page:n.page,perPage:n.rowsPerPage}),w=(j,g)=>{a({page:j,rowsPerPage:parseInt(g,10)})},m=async j=>{const g=new FormData;g.set("title",j?.title??"");try{await v(ut(_n.add,g,t),We(g)),A.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(_){A.error(_?.response?.data?.msg??_?.message??"Failed to add designation.",{duration:1e3})}},c=j=>{b(j??null),s.setFieldsValue({title:j?.designation??""}),d(!0)},f=()=>{d(!1),b(null),s.resetFields()},T=async j=>{const g=u?.id??u?.designation_id;if(!g){A.error("Missing designation id.",{duration:1e3});return}const _=new FormData;_.set("id",String(g)),_.set("title",j?.title??"");try{await yt(_n.edit,_,t),await v(),A.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),f()}catch(P){A.error(P?.response?.data?.msg??P?.message??"Failed to update designation.",{duration:1e3})}},C=async j=>{const g=j?.id??j?.designation_id;if(g)try{await v(en(_n.remove,g,t),$e(g)),A.success("Success! Deleted designation.",{duration:1e3})}catch(_){A.error(_?.response?.data?.msg??_?.message??"Failed to delete designation.",{duration:1e3})}},S=l.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(j,g)=>e.jsxs(o.Space,{size:6,children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>c(g)}),e.jsx(o.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>C(g),children:e.jsx(o.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ce.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Modal,{open:i,title:"Edit Designation",onCancel:f,footer:null,destroyOnClose:!0,children:e.jsxs(o.Form,{form:s,layout:"vertical",onFinish:T,children:[e.jsx(o.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(o.Button,{onClick:f,children:"Cancel"}),e.jsx(me,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(o.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(o.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(me,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Ee,{parentCallback:w,data:{newData:y,columns:S,columnstype:"antd",action:!1,Loading:h,error:p}})})]})}const dc=({token:t})=>e.jsx(lc,{token:t}),Cn=Se.master.shift,cc=({token:t,page:n=1,perPage:a=10})=>kt({token:t,baseUrl:Cn.table,page:n,perPage:a}),qe="hh:mm A",Rt=t=>{const n=String(t??"");if(!n)return null;const a=ye(n,[qe,"HH:mm","HH:mm:ss"],!0);return a.isValid()?a:null},Dt=t=>t?t.format(qe):"",tt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function uc({token:t}){const[n,a]=l.useState({page:1,rowsPerPage:10}),[r]=o.Form.useForm(),[s]=o.Form.useForm(),[i,d]=l.useState(!1),[u,b]=l.useState(null),{isLoading:h,error:p,data:y,mutate:v}=cc({token:t,page:n.page,perPage:n.rowsPerPage}),w=(_,P)=>{a({page:_,rowsPerPage:parseInt(P,10)})},m=(_,P)=>{const I=new FormData;return P&&I.set("id",String(P)),I.set("name",_?.name??""),I.set("start_time",Dt(_?.start_time)),I.set("end_time",Dt(_?.end_time)),I.set("shift_start_from",Dt(_?.shift_start_from)),I.set("shift_start_to",Dt(_?.shift_start_to)),I.set("shift_end_from",Dt(_?.shift_end_from)),I.set("shift_end_to",Dt(_?.shift_end_to)),I},c=async _=>{try{const P=m(_);await v(ut(Cn.add,P,t),We(P)),A.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(P){A.error(P?.response?.data?.msg??P?.message??"Failed to add shift.",{duration:1e3})}},f=_=>{b(_??null),s.setFieldsValue({name:_?.shift_name??_?.name??"",start_time:Rt(_?.start_time),end_time:Rt(_?.end_time),shift_start_from:Rt(_?.shift_start_from),shift_start_to:Rt(_?.shift_start_to),shift_end_from:Rt(_?.shift_end_from),shift_end_to:Rt(_?.shift_end_to)}),d(!0)},T=()=>{d(!1),b(null),s.resetFields()},C=async _=>{const P=u?.id??u?.shift_id;if(!P){A.error("Missing shift id.",{duration:1e3});return}try{const I=m(_,P);await yt(Cn.edit,I,t),await v(),A.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),T()}catch(I){A.error(I?.response?.data?.msg??I?.message??"Failed to update shift.",{duration:1e3})}},S=async _=>{const P=_?.id??_?.shift_id;if(P)try{await v(en(Cn.remove,P,t),$e(P)),A.success("Success! Deleted shift.",{duration:1e3})}catch(I){A.error(I?.response?.data?.msg??I?.message??"Failed to delete shift.",{duration:1e3})}},j=l.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)=>e.jsxs(o.Space,{size:6,children:[e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(ce.EditOutlined,{}),onClick:()=>f(P)}),e.jsx(o.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>S(P),children:e.jsx(o.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ce.DeleteOutlined,{})})})]})}],[]),g=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(A.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(o.Modal,{open:i,title:"Edit Shift",onCancel:T,footer:null,destroyOnClose:!0,children:e.jsxs(o.Form,{form:s,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(o.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(o.Form.Item,{name:"start_time",label:"Start Time",rules:g,children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"end_time",label:"End Time",rules:g,children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(o.Button,{onClick:T,children:"Cancel"}),e.jsx(me,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(o.Form,{form:r,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(o.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(o.Form.Item,{name:"start_time",label:"Start Time",rules:g,children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"end_time",label:"End Time",rules:g,children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(o.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(o.TimePicker,{format:qe,use12Hours:!0,style:tt})}),e.jsx(me,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Ee,{parentCallback:w,data:{newData:y,columns:j,columnstype:"antd",action:!1,Loading:h,error:p}})})]})}const pc=({token:t})=>e.jsx(uc,{token:t}),Rr=Se.attendance;function fc({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(l.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,s)=>e.jsxs(l.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():""})})]},`${s}cells${a}`))]},`${a}row`))})]})}):null}const mc=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},hc=t=>{const n=String(t??"").toLowerCase();return n==="present"?e.jsx(o.Tag,{color:"green",children:"Present"}):n==="absent"?e.jsx(o.Tag,{color:"red",children:"Absent"}):n==="leave"?e.jsx(o.Tag,{color:"orange",children:"Leave"}):e.jsx(o.Tag,{children:t??""})};function yc({token:t}){const[n,a]=l.useState(ye()),[r,s]=l.useState(!1),[i,d]=l.useState(0),u=l.useMemo(()=>`${r?Rr.dailyAttendanceMultipleShift:Rr.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,r,i]),{isLoading:b,error:h,data:p}=X(t?[u,t]:null,([c,f])=>te(c,f)),y=l.useMemo(()=>mc(p),[p]),v=l.useMemo(()=>r?p?.data?.data??p?.data??p??null:null,[p,r]),w=Vt.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),m=l.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(c,f,T)=>T+1},{title:"Name",key:"name",render:(c,f)=>`${f?.name??""} ${f?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(c,f)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[hc(f?.attendance),f?.late_time?e.jsx(o.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(c,f)=>f?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(c,f)=>f?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(c,f)=>f?.late_time?e.jsx(o.Tag,{color:"red",children:f.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(o.Card,{title:e.jsx(o.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(o.DatePicker,{value:n,onChange:c=>c&&a(c),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(o.Switch,{checked:r,onChange:s})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(me,{type:"button",value:"Search",onClick:()=>d(c=>c+1)})})]})}),e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(ce.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(Gt,{})}),r?e.jsx(fc,{data:v}):e.jsx(o.Table,{bordered:!0,size:"small",loading:b,rowKey:(c,f)=>String(c?.id??c?.staff_id??f),columns:m,dataSource:y,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const gc=({token:t})=>e.jsx(yc,{token:t}),Dr=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},xc=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 bc({token:t,staffId:n}){const[a,r]=l.useState(!1),[s,i]=l.useState(null),[d,u]=l.useState({value:"Cash",label:"Cash"}),[b,h]=l.useState(""),[p,y]=l.useState(""),v=l.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),w=O=>{const k=Number(O??0),E=Number.isFinite(k)?k.toLocaleString("en-IN"):"0";return`${v?`${v} `:""}${E}`},m=l.useMemo(()=>n?`${Se.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),c=l.useMemo(()=>n?`${Se.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:f}=X(t&&m?[m,t]:null,([O,k])=>te(O,k)),{data:T,isLoading:C,mutate:S}=X(t&&c?[c,t]:null,([O,k])=>te(O,k)),j=l.useMemo(()=>Dr(f)[0]??f?.data??f??null,[f]),g=l.useMemo(()=>Dr(T),[T]),_=l.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,k)=>e.jsx("div",{style:{fontSize:11},children:dt(k?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(O,k)=>e.jsx("div",{style:{fontSize:11},children:dt(k?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(O,k)=>e.jsx("div",{style:{fontSize:11},children:dt(k?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(O,k)=>e.jsx("div",{style:{fontSize:11},children:dt(k?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(O,k)=>e.jsx("div",{style:{cursor:k?.status==="due"?"pointer":"default"},onClick:()=>{k?.status==="due"&&(i(k),r(!0))},children:is(k?.status)})}],[]),P=l.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"}],[]),I=async()=>{if(!s)return;const O={...s,staff_id:n,payment_type:d?.value??"",notes:b,attchement:p};try{await Ge(Se.payroll.generatePayslip,{arg:O},t),A.success("Success!",{duration:1e3}),r(!1),i(null),h(""),y(""),await S()}catch(k){A.error(k?.response?.data?.msg??k?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(o.Card,{title:e.jsx(o.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:j?`${j?.f_name??j?.firstname??""} ${j?.l_name??j?.lastname??""}`.trim():""}),e.jsx(o.Table,{bordered:!0,size:"small",loading:C,rowKey:(O,k)=>String(O?.id??`${O?.month}-${k}`),columns:_,dataSource:g,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(o.Modal,{open:a,onCancel:()=>{r(!1),i(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(le,{label:"Pay",options:P,value:d,onChange:O=>u(O??P[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(o.Input.TextArea,{rows:4,placeholder:"Note",value:b,onChange:O=>h(O.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(o.Upload,{maxCount:1,action:ms(),headers:t?{Authorization:t}:void 0,onChange:O=>{if(O?.file?.status==="done"){const k=xc(O?.file?.response);k&&y(k)}O?.file?.status==="removed"&&y("")},children:e.jsx(o.Button,{icon:e.jsx(ce.UploadOutlined,{}),children:"Upload"})}),!!p&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:p})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(o.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(me,{type:"button",value:s?.Total_Payable_Amount?`Pay ${w(s.Total_Payable_Amount)}`:"Pay",onClick:I})]})]})})]})}function Sc({token:t,staffId:n}){const a=l.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(bc,{token:t,staffId:a}):e.jsx(o.Card,{title:e.jsx(o.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsx("div",{style:{fontSize:13,color:"#666"},children:"Missing staff id."})})}const jc=({routes:t=[],onNavigate:n})=>e.jsx(o.Row,{gutter:[16,16],children:t.map((a,r)=>e.jsx(o.Col,{xs:24,md:8,lg:8,children:e.jsx(ne,{children:e.jsx(Pr,{icon:a?.icon??"",title:a?.title??"",path:a?.path??"",onClick:n})})},`${r}route001`))});exports.AddBook=Qi;exports.AddDriver=Wi;exports.AddStaff=yd;exports.AdmissionEnquiry=Ci;exports.ApplyLeave=ec;exports.AprroveLeaveRequest=Hd;exports.AssignStudentToTransport=Yi;exports.AssignVehicles=ki;exports.BookList=Xi;exports.BuySellProduct=Fl;exports.Category=Cl;exports.Department=oc;exports.Designation=dc;exports.ErpDashboard=xs;exports.IssueReturn=el;exports.LeaveType=ac;exports.LibraryAssignStudent=tl;exports.LibraryCategory=nl;exports.LibraryReport=al;exports.ManageStock=Jl;exports.MenuSubmenu=si;exports.Payroll=qd;exports.PayrollReceiptDetails=Sc;exports.Products=jl;exports.RoutePage=jc;exports.RouteTimeTable=Hi;exports.SellReports=Wl;exports.Shift=pc;exports.StaffAttendance=Ed;exports.StaffAttendanceReport=Bd;exports.StaffDailyAttendance=gc;exports.StaffDirectory=jd;exports.StockReport=ed;exports.Stoppage=Ji;exports.SubCategory=Pl;exports.TransportRoutes=Ri;exports.TransportVehicles=Di;exports.Unit=Ul;exports.Vendor=ul;exports.setBaseUrl=ni;
|
|
59
|
+
`}),e.jsx(ue,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(ma,{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(r.Select,{size:"small",value:T.rowsPerPage,onChange:J=>M(1,J),options:[10,25,50,100].map(J=>({label:J,value:J})),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:E,onChange:J=>{U(J.target.value),S(oe=>({...oe,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(se.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(vn,{})}),ye]}),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 ${ce} to ${ge} of ${Ve} entries`}),e.jsx(r.Pagination,{current:T.page,pageSize:T.rowsPerPage,total:Ve||0,showSizeChanger:!1,onChange:M})]})]})]})},Tl=({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:u,data:b,error:g}=H(t?[d,t]:null,([R,D])=>G(R,D)),[p,j]=i.useState(!1),I=(R,D)=>{s({page:R,rowsPerPage:parseInt(D)})},A=async R=>{},m=R=>{console.log("dsdsdsdsd",R),j(R)},c=()=>{},y=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],P=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(Ue,{parentCallback:I,data:{newData:b,columns:P,action:!0,Loading:u,error:g,open:p,viewDetails:c,deleteTodoMutation:A,DrawerUpdate:m,ActionView:y}})})},Al={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"},pe=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:{...Al,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!`)},u=()=>{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:u,okText:"Yes",cancelText:"No",disabled:a||o,children:e.jsx(r.Button,{danger:!0,disabled:a,loading:o,icon:e.jsx(se.DeleteOutlined,{}),size:"small"})})},et=t=>({optimisticData:n=>[...n.data,t],populateCache:(n,a)=>[...a.data,n]}),Ge=t=>({optimisticData:n=>n.data.filter(a=>a.id!==t),populateCache:(n,a)=>a.data.filter(s=>s.id!==t)}),Mr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Il({token:t}){const[n,a]=i.useState({pagination:{current:1,pageSize:10}}),[s,o]=i.useState(!1),[l,d]=i.useState(null),u=`api/branchapi/Transport/routeTableList?page=${n.pagination.current}&per_page=${n.pagination.pageSize}`,b="api/branchapi/Transport/addroute",g="api/branchapi/Transport/editroute",p="api/branchapi/Transport/deleteroute",{isLoading:j,data:I,error:A,mutate:m}=H(t?[u,t]:null,([_,O])=>G(_,O)),c=async(_,O)=>{try{await m(We(_,O,t),et(O)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},y=_=>{_.preventDefault();const O=new FormData(_.target);c(b,O),_.target.reset()},P=(_,O)=>{a(z=>({...z,pagination:{current:_,pageSize:parseInt(O,10)}}))},R=async _=>{try{await m(nt(p,_,t),Ge(_)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},D=_=>{d(_),o(!0)},C=async _=>{try{await ut(g,_,t),await m(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},h=async _=>{_.preventDefault();const O=new FormData(_.target);O.append("id",l?.id),C(O)},f=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(_,O)=>_.name.localeCompare(O.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(_,O)=>_.fare-O.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(_,O)=>_.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(_,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>D(O),style:{padding:2}}),e.jsx(lt,{id:O?.id,funcName:R})]})}],x=l?.route_title?`Edit ${l.route_title}`:"Edit Route";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:s,title:x,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(Z,{type:"text",name:"title",label:"Title",defaultValue:l?.route_title||"",required:"required"}),e.jsx(Z,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:l?.fare||"",required:"required"}),e.jsx(Z,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(Z,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Mr,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ue,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Add Route"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"}),e.jsx(Z,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"}),e.jsx(Z,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"reset",style:Mr,children:"Cancel"})]})]})})})]})}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Route List"})}),e.jsx(ue,{children:e.jsx(Ue,{parentCallback:P,data:{newData:I,columns:f,columnstype:"antd",action:!1,Loading:j,error:A,deleteTodoMutation:R}})})]})})]})})]})}const $r={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Rl({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),u=`api/branchapi/Transport/vehiclesTableList?page=${n.page}&per_page=${n.rowsPerPage}`,b="api/branchapi/Transport/addvehicles",g="api/branchapi/Transport/editvehicle",p="api/branchapi/Transport/deletevehicle",{isLoading:j,data:I,error:A,mutate:m}=H(t?[u,t]:null,([_,O])=>G(_,O)),c=async(_,O)=>{try{await m(We(_,O,t),et(O)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},y=_=>{_.preventDefault();const O=new FormData(_.target);c(b,O),_.target.reset()},P=async _=>{try{await m(nt(p,_,t),Ge(_)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},R=_=>{d(_),o(!0)},D=async _=>{try{await ut(g,_,t),await m(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},C=async _=>{_.preventDefault();const O=new FormData(_.target);O.append("id",l?.id),D(O)},h=(_,O)=>{a({page:_,rowsPerPage:parseInt(O,10)})},f=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(_,O)=>_.vehicle_no.localeCompare(O.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(_,O)=>_.vehicle_model.localeCompare(O.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(_,O)=>_.seating_capacity-O.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(_,O)=>_.manufacture_year-O.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(_,O)=>_.gps_url.localeCompare(O.gps_url)},render:(_,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:(_,O)=>_.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(_,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>R(O),style:{padding:2}}),e.jsx(lt,{id:O?.id,funcName:P})]})}],x=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:s,title:x,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(Z,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(Z,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(Z,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(Z,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(Z,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(Z,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:$r,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ue,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(Z,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(Z,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(Z,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(Z,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(Z,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"reset",style:$r,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(ue,{children:e.jsx(Ue,{parentCallback:h,data:{newData:I,columns:f,columnstype:"antd",action:!1,Loading:j,error:A,deleteTodoMutation:P}})})]})})]})})]})}var Dl=ti();const Da=Xs(Dl),oi=()=>{};class Za 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:oi,onFocus:()=>this.selectRef.focus(),required:a})]})}}Za.defaultProps={onChange:oi};Za.protoTypes={selectComponent:Da.func.isRequired,onChange:Da.func,required:Da.bool};const Ol={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Pl={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"})},li=t=>e.jsx(As.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),El=t=>e.jsx(Za,{...t,SelectComponent:As,components:{Input:li},options:t.options}),te=i.forwardRef(({...t},n)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:Ol,children:t?.label}),e.jsx(El,{components:{Input:li},menuPortalTarget:document.body,styles:Pl,className:"input-cont",...t,ref:n})]})),Fl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ur=({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 kl({token:t}){const[n,a]=i.useState(!1),[s,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[u,b]=i.useState([]),g="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleDropdown",j="api/branchapi/Transport/getchechkedVehicleData",I="api/branchapi/Transport/assignedVehicleTable",A="api/branchapi/transport/assignvehicle",m="api/branchapi/Transport/deleteassignvehicle",c=l?`${j}?route_id=${l}`:null,{isLoading:y,data:P,mutate:R}=H(t?[`${I}?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,t]:null,([S,$])=>G(S,$)),{data:D}=H(t&&g?[g,t]:null,([S,$])=>G(S,$)),{data:C}=H(t&&p?[p,t]:null,([S,$])=>G(S,$)),h=t&&c?[c,t]:null,{isLoading:f,data:x}=H(h,([S,$])=>G(S,$)),{Status:_="Failed",pagination:{total_rows:O=0}={}}=P||{},{data:z=[]}=_==="Success"?P:{},B=i.useMemo(()=>{const S=D?.data??D??[];return Array.isArray(S)?S:[]},[D]),w=i.useMemo(()=>{const S=C?.data??C??[];return(Array.isArray(S)?S:[]).map(M=>{if(M==null)return null;if(typeof M=="string"||typeof M=="number")return{label:String(M),value:M};const L=M.value??M.vehicle_id??M.id??M.vehicleID,ee=M.label??M.vehicle_name??M.vehicle_no??M.vehicle_number??M.name??String(L??"");return L==null||ee===""?null:{label:String(ee),value:L}}).filter(Boolean)},[C]),F=i.useMemo(()=>{const S=x?.data??x??[];return(Array.isArray(S)?S:[]).map(M=>M?.value??M?.vehicle_id??M?.id??M).filter(M=>M!=null)},[x]);i.useEffect(()=>{b(F)},[F,n]);const E=async(S,$,M)=>{try{await R(We(S,$,t),et($)),c&&H.mutate(h),a(L=>!L),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(L){v.error(L?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},U=S=>{S.preventDefault();const $=new FormData;$.append("route_id",l??""),u.length?u.forEach(M=>$.append("vehicle_ids[]",M)):$.append("vehicle_ids[]",""),E(A,$)},k=S=>{o($=>({...$,pagination:{current:S,pageSize:$.pagination.pageSize}}))},N=async S=>{try{await R(nt(m,S,t),Ge(S)),c&&H.mutate(h),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},V=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(S,$,M)=>e.jsx(e.Fragment,{children:$.children.map((L,ee,W)=>e.jsx("span",{children:`${L.vehicle_name} ${ee+1===W.length?"":","}`},`${ee}vehicle001`))})},{title:"Action",render:(S,$,M)=>e.jsx(e.Fragment,{children:e.jsx(lt,{id:$?.route_id,funcName:N})})}],q=S=>{const $=["route_id","index"];for(let M=0;M<$.length;M++)if(S[$[M]])return S[$[M]]},T=S=>{const{children:$=[]}=S||{},M=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:L=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:L=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:L=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:L=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:L=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:L=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:L=>({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:Ur}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:M,rowKey:L=>q(L)+"cell01",dataSource:$,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ue,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(te,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:S=>{d(S?.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(r.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:w,value:u,onChange:S=>b(S),disabled:!l||f})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),b([]),a(S=>!S)},style:Fl,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(ue,{style:{padding:"10px 16px"},children:e.jsx(r.Table,{components:{body:{cell:Ur}},columns:V,bordered:!0,rowKey:S=>q(S),dataSource:Array.isArray(z)?z:[],loading:y,expandable:{expandedRowRender:T,childrenColumnName:"changed"},pagination:{current:s.pagination.current,pageSize:s.pagination.pageSize,total:O,showSizeChanger:!0,onChange:k,onShowSizeChange:(S,$)=>{o(M=>({...M,pagination:{current:1,pageSize:$}}))},showTotal:(S,$)=>`${$[0]}-${$[1]} of ${S} items`}})})]})})]})})]})}const Ml={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},$l={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Ul=(t,n,a)=>n?t>fe(a).endOf("day")||t<fe(n).endOf("day"):!1,di=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:Ml,children:s.Desplay}),e.jsx(r.DatePicker,{...s,style:{...$l,...s.style||{}},className:"form-group",disabledDate:o=>Ul(o,s.sessionStart||s.minDate?.subtract(1,"day").format("YYYY-MM-DD"),s.sessionEnd||s.maxDate?.format("YYYY-MM-DD")),required:!0,ref:a})]})}),Br={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Oa=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Nt=(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})},Bl=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Nl=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 ql({token:t,assignmentId:n,studentName:a,onClose:s,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",u="api/branchapi/Transport/getrouteDropdown",b="api/branchapi/Transport/getvehicleListByRouteIdwithCount",g="api/branchapi/Transport/getStoppageDropdown",p="api/branchapi/Transport/routeShowdata",[j,I]=i.useState(null),[A,m]=i.useState(null),[c,y]=i.useState(null),[P,R]=i.useState(fe()),[D,C]=i.useState(""),[h,f]=i.useState(0),[x,_]=i.useState(0),{data:O,isLoading:z}=H(t&&n?[`${l}?id=${n}`,t]:null,([X,xe])=>G(X,xe)),B=i.useMemo(()=>{if(!O||O?.Status&&O.Status!=="Success")return null;const X=O?.data??O;return Array.isArray(X)?X[0]??null:X},[O]);i.useEffect(()=>{const X=B?.fk_route_id??B?.route_id;X!=null&&I(X),B?.vehicle_id!=null&&m(B.vehicle_id),B?.stop_id!=null&&y(B.stop_id),R(B?.start_date?fe(B.start_date):fe()),C(Nl(B?.service_push))},[B]);const w=t&&j?`${b}?route_id=${j}`:null,F=t&&j?`${p}?id=${j}`:null,E=t&&j?`${g}?route_id=${j}`:null,{data:U}=H(t&&u?[u,t]:null,([X,xe])=>G(X,xe)),{data:k,isLoading:N}=H(w?[w,t]:null,([X,xe])=>G(X,xe)),{data:V,isLoading:q}=H(E?[E,t]:null,([X,xe])=>G(X,xe)),{data:T}=H(F?[F,t]:null,([X,xe])=>G(X,xe)),S=i.useMemo(()=>Oa(U),[U]),$=i.useMemo(()=>Oa(k),[k]),M=i.useMemo(()=>Oa(V),[V]),L=O?.data[0]?.rootCost;console.log("aaaaaaaaaaaaaaaaaaa",O),console.log("aaaaaaaaaaaaaaaaaaa",T);const ee=Bl(),W=a||[B?.firstname,B?.lastname].filter(Boolean).join(" ")||"",K=(X,xe)=>{switch(xe){case"route_id":I(X?.value??null),m(null),y(null),f(De=>De+1),_(De=>De+1);break;case"vehicle_id":m(X?.value??null),y(null),_(De=>De+1);break;case"stop_id":y(X?.value??null);break}},Q=async X=>{if(X.preventDefault(),!j||!A||!c){v.error("Please select Route, Vehicle and Stop",{duration:1200});return}const xe=new FormData;xe.append("id",String(n)),xe.append("student_id",String(B?.fk_student_id??B?.student_id??"")),xe.append("fk_route_id",String(j)),xe.append("vehicle_id",String(A)),xe.append("stop_id",String(c)),xe.append("rootCost",String(L??"")),xe.append("start_date",P?.isValid?.()?P.format("YYYY-MM-DD"):fe().format("YYYY-MM-DD")),xe.append("puse_service",String(D??""));try{await ut(d,xe,t),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),s?.()}catch(De){v.error(De?.message??"Failed to update the item.",{duration:1e3})}};if(z||!(B&&!z&&(!j||!N&&!q)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(r.Spin,{})});if(!B)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:Br,children:"Close"})]});const le=B.fk_route_id??B.route_id,je=Nt(S,le,B.route_title),ae=Nt($,B.vehicle_id,B.vehicle_name??B.vehicle_no),re=Nt(M,B.stop_id,B.stop_name??B.stoppage_name);return e.jsx("form",{onSubmit:Q,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Z,{type:"text",name:"title",label:"Student",defaultValue:W,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:B.fk_student_id??B.student_id??""}),e.jsx(te,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:Nt(S,j,je?.label)??null,onChange:X=>K(X,"route_id")}),e.jsx(te,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Nt($,A,ae?.label)??null,onChange:X=>K(X,"vehicle_id")},`edit-vehicle-${h}`),e.jsx(te,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Nt(M,c,re?.label)??null,onChange:X=>K(X,"stop_id")},`edit-stop-${x}`),e.jsx(Z,{type:"text",label:"Route Cost",value:L!=null?`${ee}${L}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:L??""}),e.jsx(di,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:P,onChange:X=>R(X)}),e.jsx(Z,{type:"text",label:"Pause Service",value:D,onChange:X=>C(X?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:s,style:Br,children:"Cancel"})]})]})},`edit-${n}-${h}`)}const Nr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ll=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[]},nn=t=>Ll(t),zl=t=>t||"",Vl=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Yl=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},Wl=(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 Hl({token:t,editType:n,onNavigate:a,editPagePath:s}){const l=Yl(n)==="drawer",d="api/branchapi/academy/classdropdownlist",u="api/branchapi/academy/sectionoftheClass",b="api/branchapi/Transport/routeStudentList",g="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleListByRouteIdwithCount",j="api/branchapi/Transport/getStoppageDropdown",I="api/branchapi/Transport/routeShowdata",A="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",[c,y]=i.useState(null),[P,R]=i.useState(!1),[D,C]=i.useState(!1),[h,f]=i.useState(null),[x,_]=i.useState(null),[O,z]=i.useState(null),[B,w]=i.useState(null),[F,E]=i.useState(!1),[U,k]=i.useState(!1),[N,V]=i.useState({page:1,rowsPerPage:50}),[q,T]=i.useState(null),[S,$]=i.useState(!1),[M,L]=i.useState(null),[ee,W]=i.useState(null),[K,Q]=i.useState(null),[ne,le]=i.useState(null),[je,ae]=i.useState(null),[re,X]=i.useState(null),[xe,De]=i.useState(null),[qe,Be]=i.useState(fe()),[$e,Oe]=i.useState(""),ze=(he,we)=>{const rt=he?.value??null;switch(we){case"class_id":Q(rt),le(null),T(rt?`${u}?class_id=${encodeURIComponent(String(rt))}`:null),R(At=>!At);break;case"route_id":ae(rt),X(null),De(null),W(rt),_(rt?`${p}?route_id=${encodeURIComponent(String(rt))}`:null),z(rt?`${I}?id=${encodeURIComponent(String(rt))}`:null),w(null),E(At=>!At),k(At=>!At);break;case"vehicle_id":X(rt),De(null),w(je?`${j}?route_id=${encodeURIComponent(String(je))}`:null),k(At=>!At);break;case"stop_id":De(rt);break}},Ve=he=>{if(l){f(he),C(!0);return}const we=Wl(he,s);if(typeof a=="function"){a(we,he);return}typeof window<"u"&&we&&window.location.assign(we)},Ee=()=>{C(!1),f(null)},Le=h?`Edit — ${h.firstname??""} ${h.lastname??""}`.trim():"Edit Student Transport",{data:at}=H(t&&d?[d,t]:null,([he,we])=>G(he,we)),{data:ce}=H(t&&q?[q,t]:null,([he,we])=>G(he,we)),{data:ge}=H(t&&x?[x,t]:null,([he,we])=>G(he,we)),{data:ye}=H(t&&B?[B,t]:null,([he,we])=>G(he,we)),{data:J}=H(t&&O?[O,t]:null,([he,we])=>G(he,we)),{data:oe}=H(t&&g?[g,t]:null,([he,we])=>G(he,we)),me=t&&c?`${c}&page=${N.page}&per_page=${N.rowsPerPage}`:null,{isLoading:Te,error:Ae,data:pt,mutate:gt}=H(me?[me,t]:null,([he,we])=>G(he,we)),xt=i.useMemo(()=>nn(at),[at]),Ft=i.useMemo(()=>nn(ce),[ce]),kt=i.useMemo(()=>nn(ge),[ge]),Mt=i.useMemo(()=>nn(ye),[ye]),ie=i.useMemo(()=>nn(oe),[oe]),be=J?.data?.[0]?.fare??J?.data?.fare??J?.fare??J?.data?.data?.[0]?.fare??J?.data?.data?.fare;console.log("aaaaaaaaaaaa",J),i.useEffect(()=>{be==null||be===""||Oe(String(be))},[be]);const He=async he=>{try{await gt(nt(m,he,t),Ge(he)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},ht=[{title:"Route Status",key:"route_status",render:(he,we)=>we.fk_route_id?e.jsx("span",{children:we.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(he,we)=>zl(we.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:(he,we)=>`${we.firstname} ${we.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(he,we)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:we.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(lt,{id:we?.id,funcName:He}),e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>Ve(we),style:{padding:2}})]}):e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.PlusOutlined,{}),onClick:()=>Ct(we.student_id),style:{padding:2}})})}],de=async(he,we)=>{try{await gt(We(he,we,t),et(we)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),$(!1),Tt()}catch{v.error("Failed to add the new item.",{duration:1e3})}},ve=he=>{if(he.preventDefault(),!K||!ne){v.error("Please select Class and Section",{duration:1200});return}y(`${b}?cID=${encodeURIComponent(String(K))}&sID=${encodeURIComponent(String(ne))}`),V(we=>({...we,page:1}))},Fe=(he,we)=>{V({page:he,rowsPerPage:parseInt(we,10)})},Ct=he=>{L(he),$(!0)},Qt=he=>{if(he.preventDefault(),!M){v.error("Student is required",{duration:1200});return}if(!je||!re||!xe){v.error("Please select Route, Vehicle and Stop",{duration:1300});return}const we=new FormData;we.append("student_id",String(M)),we.append("fk_route_id",String(je)),we.append("vehicle_id",String(re)),we.append("stop_id",String(xe)),we.append("start_date",qe?.isValid?.()?qe.format("YYYY-MM-DD"):fe().format("YYYY-MM-DD")),we.append("rootCost",String($e??"")),de(A,we)},Tt=()=>{$(!1),_(null),z(null),w(null),W(null),ae(null),X(null),De(null),Be(fe()),Oe(""),E(he=>!he),k(he=>!he)},gi=Vl();return e.jsxs("div",{children:[l&&e.jsx(r.Drawer,{open:D,title:Le,placement:"right",width:420,destroyOnClose:!0,onClose:Ee,children:h?.id&&e.jsx(ql,{token:t,assignmentId:h.id,studentName:`${h.firstname??""} ${h.lastname??""}`.trim(),onClose:Ee,onSuccess:()=>gt()})}),e.jsx(r.Modal,{open:S,title:"Assign Student to Transport",onCancel:Tt,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:Qt,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[e.jsx(te,{options:ie,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:ie.find(he=>String(he.value)===String(je))??null,onChange:he=>ze(he,"route_id")}),e.jsx(te,{options:kt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:kt.find(he=>String(he.value)===String(re))??null,onChange:he=>ze(he,"vehicle_id")},`vehicle001${F}`),e.jsx(te,{options:Mt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Mt.find(he=>String(he.value)===String(xe))??null,onChange:he=>ze(he,"stop_id")},`stop001${U}`),e.jsx(di,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:qe,onChange:he=>Be(he)}),e.jsx(Z,{type:"text",name:"rootCost",label:"Route Cost",value:$e,onChange:he=>Oe(he?.target?.value??"")}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:String($e??"").trim()?`${gi}${$e} — Assign`:"Assign",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:Tt,style:Nr,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ue,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Search Students"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:ve,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:xt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:he=>ze(he,"class_id"),required:!0,allowSelectAll:!1,value:xt.find(he=>String(he.value)===String(K))??null}),e.jsx(te,{options:Ft,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:Ft.find(he=>String(he.value)===String(ne))??null,onChange:he=>le(he?.value??null)},`section1${P}`),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Search",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"button",onClick:()=>{y(null),T(null),Q(null),le(null),R(he=>!he)},style:Nr,children:"Cancel"})]})]})})})]}),c&&e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Student List"})}),e.jsx(ue,{children:e.jsx(Ue,{parentCallback:Fe,data:{newData:pt,columns:ht,columnstype:"antd",action:!1,Loading:Te,error:Ae,deleteTodoMutation:He,pageController:N}})})]})})]})})]})}const qr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Pn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Kl({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,b]=i.useState(""),[g,p]=i.useState(""),[j,I]=i.useState(""),[A,m]=i.useState(!1),c=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,y="api/branchapi/Transport/add_driver",P="api/branchapi/Transport/edit_driver",R="api/branchapi/Transport/deletedriver",D="api/branchapi/staff/uploadDocuments",C=i.useMemo(()=>String(D).startsWith("http")?D:`${ot()??""}${String(D).replace(/^\/+/,"")}`,[D]),h=ot()??"",{isLoading:f,data:x,error:_,mutate:O}=H(t?[c,t]:null,([q,T])=>G(q,T)),z=async(q,T)=>{try{await We(q,T,t),await O(),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),b("")}catch(S){v.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},B=q=>{q.preventDefault();const T=new FormData(q.target);z(y,T),q.target.reset()},w=async q=>{try{await O(nt(R,q,t),Ge(q)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},F=q=>{d(q),b(q?.image??""),o(!0)},E=async q=>{try{await ut(P,q,t),await O(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),b("")}catch(T){v.error(T?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},U=q=>{q.preventDefault();const T=new FormData(q.target);T.append("id",l?.id??""),E(T)},k=(q,T)=>{a({page:q,rowsPerPage:parseInt(T,10)})},N=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(q,T)=>String(q?.name??"").localeCompare(String(T?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(q,T)=>String(q?.Driver_licence??"").localeCompare(String(T?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(q,T)=>Number(q?.contact_number??0)-Number(T?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(q,T)=>String(q?.address??"").localeCompare(String(T?.address??""))}},{title:"Image",key:"image",width:100,render:(q,T)=>{const S=T?.image?`${h}staff/document/${T.image}`:"";return S?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(r.Image,{width:80,src:S,preview:{visible:!1,onVisibleChange:()=>{m(!0),p(S),I(T?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(q,T)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>F(T),style:{padding:2}}),e.jsx(lt,{id:T?.id,funcName:w})]})}],V=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:s,title:V,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),b("")},children:e.jsx("form",{onSubmit:U,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Z,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Z,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(Z,{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:Pn,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:Pn,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 T=q?.file?.response,S=T?.data??T?.filename??T?.file??T?.path??"";S&&b(String(S))},children:e.jsx(r.Button,{icon:e.jsx(se.UploadOutlined,{}),disabled:!C,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:u})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null),b("")},style:qr,children:"Cancel"})]})]})})}),e.jsx(r.Modal,{zIndex:9999,open:A,title:j,footer:null,onCancel:()=>m(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:g})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ue,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(Z,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(Z,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Pn,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:Pn,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 T=q?.file?.response,S=T?.data??T?.filename??T?.file??T?.path??"";S&&b(String(S))},children:e.jsx(r.Button,{icon:e.jsx(se.UploadOutlined,{}),disabled:!C,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:u})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"reset",onClick:()=>b(""),style:qr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(ue,{children:e.jsx(Ue,{parentCallback:k,data:{newData:x,columns:N,columnstype:"antd",action:!1,Loading:f,error:_,deleteTodoMutation:w}})})]})})]})})]})}const Lr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},qt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},En={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},zr=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],Fn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Gl({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[s,o]=i.useState(!1),[l,d]=i.useState(!1),[u,b]=i.useState(null),[g,p]=i.useState(null),[j,I]=i.useState(null),[A,m]=i.useState(null),[c,y]=i.useState(fe()),[P,R]=i.useState(fe()),[D,C]=i.useState("pick"),[h,f]=i.useState(!1),[x,_]=i.useState(null),[O,z]=i.useState(null),[B,w]=i.useState(!1),[F,E]=i.useState(null),[U,k]=i.useState(null),[N,V]=i.useState(null),[q,T]=i.useState(null),[S,$]=i.useState(fe()),[M,L]=i.useState(fe()),[ee,W]=i.useState("pick"),K=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,Q="api/branchapi/Transport/assignRouteTime",ne="api/branchapi/Transport/editAssignRouteTime",le="api/branchapi/Transport/deleteAssignRouteTime",je="api/branchapi/Transport/driverDropdown",ae="api/branchapi/transport/routeTimetableShowdata",re="api/branchapi/Transport/getrouteDropdown",X="api/branchapi/Transport/getvehicleDropdown",{isLoading:xe,data:De,error:qe,mutate:Be}=H(t?[K,t]:null,([ie,be])=>G(ie,be)),{data:$e}=H(t&&re?[re,t]:null,([ie,be])=>G(ie,be)),{data:Oe}=H(t&&je?[je,t]:null,([ie,be])=>G(ie,be)),ze=i.useMemo(()=>u?`${X}?route_id=${u}`:null,[u,X]),{data:Ve}=H(t&&ze?[ze,t]:null,([ie,be])=>G(ie,be)),Ee=i.useMemo(()=>Fn($e),[$e]),Le=i.useMemo(()=>Fn(Oe),[Oe]),at=i.useMemo(()=>Fn(Ve),[Ve]),ce=(ie,be)=>{a({page:ie,rowsPerPage:parseInt(be,10)})},ge=async ie=>{ie.preventDefault();const be=new FormData(ie.target);be.set("route_id",g?.value??u??""),be.set("driver_id",j?.value??""),be.set("vehicle_id",A?.value??""),be.set("start_time",c?c.format("h:mm a"):""),be.set("drop_time",P?P.format("h:mm a"):""),be.set("type",D);try{await We(Q,be,t),await Be(),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),ie.target.reset(),b(null),p(null),I(null),m(null),d(He=>!He),y(fe()),R(fe()),C("pick"),o(He=>!He)}catch(He){v.error(He?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},ye=async ie=>{try{await nt(le,ie,t),await Be(),v.success("Success! Deleted item.",{duration:1e3})}catch(be){v.error(be?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},J=ie=>{_(ie),f(!0);const be=ie?.id??ie?.route_time_id??ie?.routeId??null;z(be);const He=ie?.route_id??ie?.routeId??ie?.fk_route_id;E(He??null),k(Ee.find(ht=>ht?.value===(He??ie?.route_id))??null),V(Le.find(ht=>ht?.value===(ie?.driver_id??ie?.driverId))??null),T(null),w(ht=>!ht),$(ie?.start_time?fe(ie.start_time,["h:mm a","HH:mm"]):fe()),L(ie?.drop_time?fe(ie.drop_time,["h:mm a","HH:mm"]):fe()),W(ie?.type??"pick")},oe=i.useMemo(()=>{if(!O)return null;const ie=String(ae).includes("?")?"&":"?";return`${ae}${ie}id=${encodeURIComponent(String(O))}`},[O,ae]),{data:me,isLoading:Te}=H(t&&oe?[oe,t]:null,([ie,be])=>G(ie,be)),Ae=i.useMemo(()=>{const ie=me?.data??me;return Array.isArray(ie)?ie[0]??null:Array.isArray(ie?.data)?ie.data[0]??null:ie??null},[me]),pt=i.useMemo(()=>F?`${X}?route_id=${F}`:null,[F,X]),{data:gt}=H(t&&pt?[pt,t]:null,([ie,be])=>G(ie,be)),xt=i.useMemo(()=>Fn(gt),[gt]);i.useEffect(()=>{if(!Ae)return;const ie=Ae?.route_id??Ae?.fk_route_id??Ae?.routeId;E(ie??null),k(Ee.find(be=>be?.value===ie)??null),V(Le.find(be=>be?.value===Ae?.driver_id)??null),T(null),$(Ae?.start_time?fe(Ae.start_time,["h:mm a","HH:mm"]):fe()),L(Ae?.drop_time?fe(Ae.drop_time,["h:mm a","HH:mm"]):fe()),W(Ae?.type??"pick"),w(be=>!be)},[Le,Ae,Ee]),i.useEffect(()=>{if(!Ae)return;const ie=Ae?.vehicle_id??Ae?.vehicleId;ie&&T(xt.find(be=>be?.value===ie)??null)},[Ae,xt]);const Ft=async ie=>{if(ie.preventDefault(),!O)return;const be=new FormData(ie.target);be.set("id",String(O)),be.set("route_id",U?.value??F??""),be.set("driver_id",N?.value??""),be.set("vehicle_id",q?.value??""),be.set("start_time",S?S.format("h:mm a"):""),be.set("drop_time",M?M.format("h:mm a"):""),be.set("type",ee);try{await ut(ne,be,t),await Be(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),f(!1),_(null)}catch(He){v.error(He?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},kt=[{title:"Route Name",dataIndex:"route_title",key:"route_title"},{title:"Driver Name",dataIndex:"driver_name",key:"driver_name"},{title:"Vehicle Name",dataIndex:"vehicle_name",key:"vehicle_name"},{title:"Start Time",dataIndex:"start_time",key:"start_time"},{title:"End Time",dataIndex:"drop_time",key:"drop_time"},{title:"Type",dataIndex:"type",key:"type"},{title:"Action",key:"action",render:(ie,be)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>J(be),style:{padding:2}}),e.jsx(lt,{id:be?.id??be?.routeId??be?.route_time_id,funcName:ye})]})}],Mt=x?.route_title?`Edit ${x.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:h,title:Mt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{f(!1),_(null),z(null),E(null),k(null),V(null),T(null)},children:e.jsx("form",{onSubmit:Ft,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Te?.6:1},children:[e.jsx(te,{options:Ee,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:U,onChange:ie=>{E(ie?.value??null),k(ie??null),T(null),w(be=>!be)}}),e.jsx(te,{options:Le,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:N,onChange:ie=>V(ie??null)}),e.jsx(te,{options:xt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:q,onChange:ie=>T(ie??null)},`edit-vehicle-${B}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:qt,children:"Start Time"}),e.jsx(r.TimePicker,{value:S,onChange:ie=>$(ie),use12Hours:!0,format:"h:mm a",allowClear:!1,style:En})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:qt,children:"Drop Time"}),e.jsx(r.TimePicker,{value:M,onChange:ie=>L(ie),use12Hours:!0,format:"h:mm a",allowClear:!1,style:En})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:qt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(r.Radio.Group,{options:zr,optionType:"button",buttonStyle:"solid",value:ee,onChange:ie=>W(ie.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{f(!1),_(null)},style:Lr,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(ue,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:ge,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:Ee,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:g,onChange:ie=>{b(ie?.value??null),p(ie??null),m(null),d(be=>!be)},allowSelectAll:!1,required:!0}),e.jsx(te,{options:Le,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:j,onChange:ie=>I(ie??null),allowSelectAll:!1,required:!0}),e.jsx(te,{options:at,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:A,onChange:ie=>m(ie??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:qt,children:"Start Time"}),e.jsx(r.TimePicker,{value:c,onChange:ie=>y(ie),use12Hours:!0,format:"h:mm a",allowClear:!1,style:En})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:qt,children:"Drop Time"}),e.jsx(r.TimePicker,{value:P,onChange:ie=>R(ie),use12Hours:!0,format:"h:mm a",allowClear:!1,style:En})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:qt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(r.Radio.Group,{options:zr,optionType:"button",buttonStyle:"solid",value:D,onChange:ie=>C(ie.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Add",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"reset",onClick:()=>{b(null),p(null),I(null),m(null),d(ie=>!ie),y(fe()),R(fe()),C("pick"),o(ie=>!ie)},style:Lr,children:"Cancel"})]})]})},`form-${s}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(ue,{children:e.jsx(Ue,{parentCallback:ce,data:{newData:De,columns:kt,columnstype:"antd",action:!1,Loading:xe,error:qe,deleteTodoMutation:ye}})})]})})]})})]})}const Jl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Vr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Yr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Wr=({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 Hr=2;function Ql({token:t}){const[n,a]=i.useState([]),[s,o]=i.useState(null),[l,d]=i.useState([]),[u,b]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:g,data:p,mutate:j}=H(t?[`api/branchapi/transport/getrouteStoppageData?page=${u.pagination.current}&per_page=${u.pagination.pageSize}`,t]:null,([E,U])=>G(E,U)),{Status:I="Failed",pagination:{total_rows:A=0}={}}=p||{},{data:m=[]}=I==="Success"?p:{},{data:c}=H(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([E,U])=>G(E,U)),y=i.useMemo(()=>{const E=c?.data??c??[];if(Array.isArray(E))return E;if(E&&typeof E=="object"){if(Array.isArray(E?.data))return E.data;if(Array.isArray(E?.data?.data))return E.data.data}return[]},[c]),{data:P}=H(t&&s?["api/branchapi/transport/getrouteStoppageData?route_id="+s,t]:null,([E,U])=>G(E,U)),{Status:R="Failed"}=P||{},D=async(E,U)=>{try{await j(We(E,U,t),et(U)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},C=E=>E?typeof E=="string"?E:E?.isValid?.()?E.format("h:mm a"):"":"",h=(E,U=[])=>{const k=(Array.isArray(E)?E:[]).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)})),N=k.filter(q=>q?.id!=null&&String(q.id).trim()!==""),V=k.filter(q=>!(q?.id!=null&&String(q.id).trim()!==""));return{route_id:s??"",edit_stoppage:N,add_stoppage:V,delete_stoppage:Array.isArray(U)?U:[]}},f=E=>{E.preventDefault();const U="/api/branchapi/transport/addstoppageToRoute",k=h(n,l);D(U,k)},x=()=>{a(E=>[...Array.isArray(E)?E:[],{idKey:Hr++,stop_name:"",pickup_time:fe().format("h:mm a"),drop_time:fe().format("h:mm a")}])},_=E=>{if(n.length===1)return;const U=n[E];U?.id!=null&&String(U.id).trim()!==""&&!U?.idKey&&d(k=>{const N=Array.isArray(k)?k:[];return N.some(q=>String(q)===String(U.id))?N:[...N,U.id]}),a(k=>{const N=[...k];return N.splice(E,1),N})},O=E=>{b(U=>({...U,pagination:{current:E,pageSize:U.pagination.pageSize}}))},z=async E=>{const U="/api/branchapi/Transport/deletevehicle";try{await j(nt(U,E,t),Ge(E)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(R==="Success"){const E=Array.isArray(P?.data)?P.data:[];E.length>0?(a(E),d([])):s&&(a([{idKey:Hr++,stop_name:"",pickup_time:fe().format("h:mm a"),drop_time:fe().format("h:mm a")}]),d([]))}},[R,P,s]);const B=E=>{const{children:U=[]}=E||{},k=[{title:"Stop Name",dataIndex:"stop_name",onCell:N=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:N=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:N=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(r.Table,{components:{body:{cell:Wr}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:k,rowKey:N=>w(N)+"cell01",dataSource:U,pagination:!1})})})},w=E=>{const U=["id","index"];for(let k=0;k<U.length;k++)if(E[U[k]])return E[U[k]]},F=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(E,U,k)=>e.jsx(e.Fragment,{children:(Array.isArray(U.children)?U.children:[]).map((N,V,q)=>e.jsx("span",{children:`${N.stop_name} ${V+1===q.length?"":","}`},`${V}vehicle001`))})},{title:"Action",render:(E,U,k)=>e.jsx(e.Fragment,{children:e.jsx(lt,{id:U?.route_id,funcName:z})})}];return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(ue,{pt:5,pb:1,children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(ue,{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(te,{options:y,value:y.find(E=>String(E.value)===String(s))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:E=>{o(E?.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:x,children:e.jsx(se.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(pe,{type:"submit",value:"Add",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),a([]),d([])},style:Jl,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((E,U)=>{const k=E.pickup_time?fe(E.pickup_time,"h:mm a"):null,N=E.drop_time?fe(E.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(Z,{value:E.stop_name??"",type:"text",name:`stoppage[${U}][name]`,label:"Place Name*",required:"required",onChange:V=>{const q=V?.target?.value??"";a(T=>{const S=[...T];return S[U]={...S[U]??{},stop_name:q},S})}}),E?.id!=null&&String(E.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${U}][id]`,value:String(E.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Vr,children:"Pick Time"}),e.jsx(r.TimePicker,{value:k,use12Hours:!0,format:"h:mm a",name:`stoppage[${U}][pickTime]`,allowClear:!1,style:Yr,onChange:V=>{const q=V?V.format("h:mm a"):"";a(T=>{const S=[...T];return S[U]={...S[U]??{},pickup_time:q},S})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Vr,children:"Drop Time"}),e.jsx(r.TimePicker,{value:N,use12Hours:!0,format:"h:mm a",name:`stoppage[${U}][drop_time]`,allowClear:!1,style:Yr,onChange:V=>{const q=V?V.format("h:mm a"):"";a(T=>{const S=[...T];return S[U]={...S[U]??{},drop_time:q},S})}})]}),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:()=>_(U),children:e.jsx(se.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},E.idKey?E.idKey+"exp":E.id+"exp")})})]})}),e.jsx(ue,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(ue,{style:{padding:"10px 16px"},children:e.jsx(r.Table,{components:{body:{cell:Wr}},columns:F,bordered:!0,size:"small",rowKey:E=>w(E),dataSource:m,loading:g,expandable:{expandedRowRender:B,childrenColumnName:"changed"},pagination:{current:u.pagination.current,pageSize:u.pagination.pageSize,total:A,showSizeChanger:!0,onChange:O,onShowSizeChange:(E,U)=>{b(k=>({...k,pagination:{current:1,pageSize:U}}))},showTotal:(E,U)=>`${U[0]}-${U[1]} of ${E} items`}})})]})]})}const Xl=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),s=String(n).replace(/^\/+/,"");return`${a}/${s}`};function Zl({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState(null),[o,l]=i.useState(null),[d,u]=i.useState(null),[b,g]=i.useState(null),[p,j]=i.useState(null),[I,A]=i.useState(null),[m,c]=i.useState(null),y="api/branchapi/library/bookCategorydropdown",P="api/branchapi/academy/classdropdownlist",R="api/branchapi/Academy/getClassSubjectdropdown",D="api/branchapi/library/addBook",C="api/branchapi/library/uploadcsv",{data:h}=H(n?[y,n]:null,([w,F])=>G(w,F)),{data:f}=H(n&&P?[P,n]:null,([w,F])=>G(w,F)),{data:x}=H(n&&R?[R,n]:null,([w,F])=>G(w,F)),_=i.useMemo(()=>Xl(ot(),C),[C]),O=async w=>{w.preventDefault();const F=new FormData(w.target);F.set("cat_id",p?.value??""),F.set("class_id",I?.value??""),F.set("subject_id",m?.value??"");try{await We(D,F,n),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),w.target.reset(),j(null),A(null),c(null)}catch(E){v.error(E?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},z=async w=>{if(w.preventDefault(),!a){v.error("Please select a CSV file.",{duration:1e3});return}const F=new FormData;F.append("file",a),F.append("cat_id",o?.value??""),F.append("class_id",d?.value??""),F.append("subject_id",b?.value??"");try{const E=await ke.post(_,F,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});E?.data?.Status==="Failed"?v.error(String(E?.data?.msg??"Upload failed."),{duration:1e3}):(v.success(String(E?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),s(null),w.target.reset(),l(null),u(null),g(null))}catch(E){v.error(E?.response?.data?.msg??"Upload failed.",{duration:1e3})}},B=()=>{fetch("/books.csv").then(w=>{w.blob().then(F=>{const E=window.URL.createObjectURL(F);let U=document.createElement("a");U.href=E,U.download="/books.csv",U.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.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(se.DownloadOutlined,{}),onClick:B,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:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:w=>l(w??null)}),e.jsx(te,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:w=>u(w??null)}),e.jsx(te,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:b,onChange:w=>g(w??null)}),e.jsx(Z,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:w=>s(w.target.files?.[0]??null),required:!0}),e.jsx(pe,{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:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(Z,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(Z,{type:"text",label:"Publication",name:"publisher"}),e.jsx(Z,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(Z,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(Z,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(Z,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(te,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:p,onChange:w=>j(w??null)}),e.jsx(te,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:I,onChange:w=>A(w??null)}),e.jsx(te,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:m,onChange:w=>c(w??null)}),e.jsx(pe,{type:"submit",value:"Save",color:"primary"})]})})})]})}const Pa={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ea=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function ed({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),u={selectedRowKeys:a,onChange:(Q,ne)=>{s(Q),l(ne)}},b=gn.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),g=()=>{if(!(typeof window>"u")){if(!o.length){v.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){v.error("Nothing to print.",{duration:1e3});return}b?.()}},[p,j]=i.useState(!1),[I,A]=i.useState(null),[m,c]=i.useState(null),[y,P]=i.useState(null),[R,D]=i.useState(null),[C,h]=i.useState({page:1,rowsPerPage:10}),f=(Q,ne)=>{h({page:Q,rowsPerPage:parseInt(ne,10)})},x="api/branchapi/library/booktable",_="api/branchapi/library/deletebooks",O="api/branchapi/library/editbook",z=`${x}?page=${C.page}&per_page=${C.rowsPerPage}`,{isLoading:B,error:w,data:F,mutate:E}=H(n?[z,n]:null,([Q,ne])=>G(Q,ne)),U="api/branchapi/library/bookCategorydropdown",k="api/branchapi/academy/classdropdownlist",N="api/branchapi/Academy/getClassSubjectdropdown",{data:V}=H(n?[U,n]:null,([Q,ne])=>G(Q,ne)),{data:q}=H(n&&k?[k,n]:null,([Q,ne])=>G(Q,ne)),{data:T}=H(n&&N?[N,n]:null,([Q,ne])=>G(Q,ne)),S=i.useMemo(()=>Ea(V),[V]),$=i.useMemo(()=>Ea(q),[q]),M=i.useMemo(()=>Ea(T),[T]),L=async Q=>{try{await nt(_,Q,n),await E(),v.success("Success! Deleted item.",{duration:1e3})}catch(ne){v.error(ne?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ee=Q=>{A(Q??null);const ne=Q?.cat_id??Q?.fk_cat_id??Q?.category_id,le=Q?.class_id??Q?.fk_class_id,je=Q?.subject_id??Q?.fk_subject_id;c(S.find(ae=>ae?.value===ne)??null),P($.find(ae=>ae?.value===le)??null),D(M.find(ae=>ae?.value===je)??null),j(!0)},W=async Q=>{Q.preventDefault();const ne=I?.id??I?.book_id??I?._id;if(!ne)return;const le=new FormData(Q.target);le.set("id",String(ne)),le.set("cat_id",m?.value??""),le.set("class_id",y?.value??""),le.set("subject_id",R?.value??"");try{await ut(O,le,n),await E(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),j(!1),A(null)}catch(je){v.error(je?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},K=i.useMemo(()=>[{title:"Name",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Publisher",dataIndex:"publish",key:"publish",width:160,responsive:["lg"]},{title:"Author",dataIndex:"author",key:"author",width:160,responsive:["lg"]},{title:"Class",dataIndex:"class_name",key:"class_name",width:140,responsive:["xl"]},{title:"Subject",dataIndex:"subject_name",key:"subject_name",width:160,responsive:["xl"]},{title:"Avl Qty",dataIndex:"available_qty",key:"available_qty",width:90},{title:"Book Price",dataIndex:"perunitcost",key:"perunitcost",width:120,responsive:["xl"]},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",width:120,responsive:["xl"]},{title:"Category",dataIndex:"cat_name",key:"cat_name",width:160,responsive:["xl"]},{title:"Action",key:"action",width:140,fixed:"right",render:(Q,ne)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>ee(ne),style:{padding:2}}),e.jsx(r.Button,{type:"text",size:"small",danger:!0,onClick:()=>L(ne?.id??ne?.book_id??ne?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[S,$,L,M]);return e.jsxs("div",{style:{},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:p,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{j(!1),A(null)},children:e.jsx("form",{onSubmit:W,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{label:"Book Name",name:"title",defaultValue:I?.book_title??"",required:!0}),e.jsx(Z,{label:"Author",name:"author",defaultValue:I?.author??"",required:!0}),e.jsx(Z,{label:"Publication",name:"publish",defaultValue:I?.publish??""}),e.jsx(Z,{label:"Qty",name:"quantity",type:"number",defaultValue:I?.quantity??""}),e.jsx(Z,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:I?.perunitcost??""}),e.jsx(Z,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:I?.fine_amount??""}),e.jsx(Z,{label:"Barcode",name:"barcode",defaultValue:I?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Pa,children:"Category"}),e.jsx(te,{options:S,value:m,onChange:Q=>c(Q??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Pa,children:"Class"}),e.jsx(te,{options:$,value:y,onChange:Q=>P(Q??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Pa,children:"Subject"}),e.jsx(te,{options:M,value:R,onChange:Q=>D(Q??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{j(!1),A(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:g,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Ue,{parentCallback:f,data:{newData:F,columns:K,columnstype:"antd",action:!1,Loading:B,error:w,rowSelection:u}})}),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((Q,ne)=>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:Q.book_title}),e.jsx(Is,{value:Q.barcode?String(Q.barcode):String(Q.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},ne))})})})]})}const td=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),s=String(n).replace(/^\/+/,"");return`${a}/${s}`},bt=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function nd({token:t}){const n=t??localStorage.getItem("authToken")??"",a=JSON.parse(localStorage.getItem("genrall_settings")??"null")?.currency_symbol??"",[s,o]=i.useState("issue"),l=s==="return",[d,u]=i.useState(!1),[b,g]=i.useState(!1),[p,j]=i.useState(null),[I,A]=i.useState([]),[m,c]=i.useState([]),[y,P]=i.useState([]),[R,D]=i.useState(0),[C,h]=i.useState(!1),[f,x]=i.useState(null),[_,O]=i.useState(null),[z,B]=i.useState(null),[w,F]=i.useState(!1),[E,U]=i.useState("Cash"),[k,N]=i.useState(""),[V,q]=i.useState(""),[T,S]=i.useState(0),$=i.useRef(null),[M]=r.Form.useForm(),[L]=r.Form.useForm(),ee="api/branchapi/library/bookCategorydropdown",W="api/branchapi/academy/classdropdownlist",K="api/branchapi/Academy/getClassSubjectdropdown",{data:Q}=H(n?[ee,n]:null,([de,ve])=>G(de,ve)),{data:ne}=H(n&&W?[W,n]:null,([de,ve])=>G(de,ve)),{data:le}=H(n&&K?[K,n]:null,([de,ve])=>G(de,ve)),je=i.useMemo(()=>bt(Q),[Q]),ae=i.useMemo(()=>bt(ne),[ne]),re=i.useMemo(()=>bt(le),[le]),X="api/branchapi/library/studentsearchByNameID",xe="api/branchapi/library/booksearchBybookname",De="api/branchapi/library/issuedBookList",qe="api/branchapi/library/issueLibrarybook",Be="api/branchapi/library/returnedLibrarybook",{trigger:$e,data:Oe}=Ke(X,(de,ve)=>Dt(de,ve,n)),{trigger:ze,data:Ve}=Ke(xe,(de,ve)=>Dt(de,ve,n)),{trigger:Ee,data:Le}=Ke(De,(de,ve)=>Dt(de,ve,n)),{trigger:at}=Ke(l?Be:qe,(de,ve)=>Ja(de,ve,n)),ce=i.useMemo(()=>bt(Oe),[Oe]),ge=i.useMemo(()=>bt(Ve),[Ve]),ye=i.useMemo(()=>bt(Le),[Le]),J=de=>{const ve=fe().format("YYYY-MM-DD");A(Fe=>Fe.some(Ct=>String(Ct?.id)===String(de?.id))?Fe:[...Fe,{...de,return_date:de?.return_date?de.return_date:ve}])},oe=de=>{A(ve=>ve.filter(Fe=>String(Fe?.id)!==String(de)))},me=async de=>{if(n){if(!de){j(null);return}d||await $e({id:de})}},Te=async({search:de})=>{if(!n||!d)return;const ve=await $e({id:de}),Fe=bt(ve);Fe.length===1&&(j(Fe[0]),await Ee({id:Fe[0]?.student_id}),M.resetFields())},Ae=async(de,ve)=>{j(ve??null),A([]),c([]),P([]),D(0),ve?.student_id&&await Ee({id:ve.student_id}),M.resetFields()},pt=async de=>{n&&de&&(b||await ze({book:de}))},gt=async({search_book:de})=>{if(!n||!b)return;const ve=await ze({book:de,catID:f?.value??"",sID:z?.value??"",cID:_?.value??""}),Fe=bt(ve);Fe.length&&(J(Fe[0]),L.resetFields())},xt=(de,ve)=>{J(ve),L.resetFields()},Ft=async()=>{if(!p?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!I.length){v.error("Select at least one book.",{duration:1e3});return}const de=await at({member_id:p.member_id,fine:!1,books:I});de?.Status==="Success"?(v.success(String(de?.msg??"Success"),{duration:1e3}),A([]),j(null),c([]),P([]),D(0)):v.error(String(de?.msg??"Failed"),{duration:1e3})},kt=async()=>{if(!p?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!y.length){v.error("Select at least one book to return.",{duration:1e3});return}if(Number(R)>0){F(!0);return}const de=await at({member_id:p.member_id,fine:!1,books:JSON.stringify(y)});de?.Status==="Success"?(v.success(String(de?.msg??"Success"),{duration:1e3}),c([]),P([]),D(0),await Ee({id:p?.student_id})):v.error(String(de?.msg??"Failed"),{duration:1e3})},Mt=async()=>{if(!p?.member_id)return;const de=Math.max(0,Number(R)-Number(T||0)),ve={member_id:p.member_id,amount:de,fine:!0,books:JSON.stringify(y),payment_type:E,notes:k,attchement:V,discount:T||0},Fe=await at(ve);F(!1),Fe?.Status==="Success"?(v.success(String(Fe?.msg??"Success"),{duration:1e3}),c([]),P([]),D(0),S(0),N(""),q(""),await Ee({id:p?.student_id})):v.error(String(Fe?.msg??"Failed"),{duration:1e3})},ie=i.useMemo(()=>td(ot(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),be=[{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:(de,ve)=>e.jsx(r.Input,{value:ve?.return_date??"",onChange:Fe=>{const Ct=Fe.target.value;A(Qt=>Qt.map(Tt=>String(Tt?.id)===String(ve?.id)?{...Tt,return_date:Ct}:Tt))},placeholder:"YYYY-MM-DD"})},{title:"Action",key:"action",width:120,fixed:"right",render:(de,ve)=>e.jsx(r.Button,{type:"text",danger:!0,onClick:()=>oe(ve?.id),children:"Remove"})}],He={selectedRowKeys:m,onChange:(de,ve)=>{c(de),P(ve);const Fe=(ve??[]).reduce((Ct,Qt)=>Ct+Number(Qt?.totalfine??0),0);D(Fe)}},ht=[{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:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:de=>e.jsxs("span",{children:[a," ",de]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:w,onCancel:()=>F(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(r.Radio.Group,{value:E,onChange:de=>U(de.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:k,onChange:de=>N(de.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(r.Upload,{action:ie,headers:{Authorization:n},maxCount:1,onChange:de=>{if(de.file.status==="done"){const ve=de.file.response?.data??de.file.response?.file??"";q(String(ve??""))}},children:e.jsx(r.Button,{icon:e.jsx(se.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(r.Input,{type:"number",value:T,onChange:de=>S(de.target.value),placeholder:"0"})]}),e.jsxs(r.Button,{type:"primary",onClick:Mt,children:["Collect ",a,Math.max(0,Number(R)-Number(T||0))]})]})}),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:de=>{const ve=de.target.value;o(ve),A([]),c([]),P([]),D(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(r.Col,{xs:24,md:14,children:e.jsx(r.Form,{form:M,onFinish:Te,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(se.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:d,onChange:de=>u(de.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(r.AutoComplete,{options:ce,onSelect:Ae,onSearch:me,style:{width:"100%"},allowClear:!0,children:e.jsx(r.Input,{addonBefore:e.jsxs(r.Space,{children:[e.jsx(se.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:d,onChange:de=>u(de.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),p?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:"})," ",p?.value??""]}),e.jsxs(r.Col,{xs:24,md:8,children:[e.jsx(r.Typography.Text,{strong:!0,children:"Card No:"})," ",p?.library_card_no??""]}),e.jsxs(r.Col,{xs:24,md:8,children:[e.jsx(r.Typography.Text,{strong:!0,children:"Member ID:"})," ",p?.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:ye,columns:ht,rowSelection:He,pagination:!1,rowKey:de=>de?.id??de?.issue_id??de?.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: ",a,R]}),e.jsx(r.Button,{type:"primary",onClick:kt,disabled:!y.length,children:R>0?`Pay Now ${a}${Math.max(0,Number(R)-Number(T||0))}`:"Return Selected"})]})]}):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:L,onFinish:gt,layout:"vertical",children:e.jsx(r.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(r.Space.Compact,{style:{width:"100%"},children:b?e.jsx(r.Input,{autoFocus:!0,disabled:!p,addonBefore:e.jsxs(r.Space,{children:[e.jsx(se.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:b,onChange:de=>g(de.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(r.AutoComplete,{disabled:!p,options:ge,onSelect:xt,onSearch:pt,style:{width:"100%"},allowClear:!0,children:e.jsx(r.Input,{addonBefore:e.jsxs(r.Space,{children:[e.jsx(se.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:b,onChange:de=>g(de.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(se.FilterOutlined,{}),onClick:()=>h(!0),children:"Filter"})})]}),e.jsx(r.Drawer,{open:C,onClose:()=>h(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{label:"Category",options:je,value:f,onChange:de=>x(de??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(te,{label:"Class",options:ae,value:_,onChange:de=>O(de??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(te,{label:"Subjects",options:re,value:z,onChange:de=>B(de??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(r.Button,{type:"primary",onClick:()=>h(!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:I,columns:be,pagination:!1,rowKey:de=>de?.id??de?.book_id??de?.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(pe,{type:"button",value:"Issue",onClick:Ft})})]})]}),e.jsx("div",{ref:$,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}const Kr=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function ad({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,u]=i.useState(null),[b,g]=i.useState(!1),[p,j]=i.useState(!1),[I,A]=i.useState(null),[m,c]=i.useState(!1),y="api/branchapi/academy/classdropdownlist",P="api/branchapi/academy/sectionoftheClass",R="api/branchapi/library/studenttableForLibrary",D="api/branchapi/library/addmembershipforStudent",C="api/branchapi/library/removemembershipforStudent",h=i.useMemo(()=>{if(!o?.value)return null;const T=P.includes("?")?"&":"?";return`${P}${T}class_id=${encodeURIComponent(String(o.value))}`},[P,o?.value]),f=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const T=R.includes("?")?"&":"?";return`${R}${T}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:x}=H(n&&y?[y,n]:null,([T,S])=>G(T,S)),{data:_}=H(n&&h?[h,n]:null,([T,S])=>G(T,S)),{isLoading:O,error:z,data:B,mutate:w}=H(n&&f?[f,n]:null,([T,S])=>G(T,S)),F=i.useMemo(()=>Kr(x),[x]),E=i.useMemo(()=>Kr(_),[_]),U=(T,S)=>{s({page:T,rowsPerPage:parseInt(S,10)})},k=T=>{const S=T?.id??T?.student_id??T?.member_id;A(S??null),j(!0),c($=>!$)},N=async T=>{if(T.preventDefault(),!I)return;const S=new FormData(T.target);S.set("id",String(I));try{await We(D,S,n),v.success("Success! Added member.",{duration:1e3,icon:"🎉"}),j(!1),A(null),await w()}catch($){v.error($?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},V=async T=>{try{await nt(C,T,n),v.success("Success! Removed member.",{duration:1e3}),await w()}catch(S){v.error(S?.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:(T,S)=>(console.log("data______________",S),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:S?.library_card_no==null?e.jsx(r.Button,{type:"primary",size:"small",icon:e.jsx(se.UserAddOutlined,{}),onClick:()=>k(S)}):e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(se.DeleteOutlined,{}),onClick:()=>V(S?.id??S?.student_id??S?.member_id)})}))}],[V]);return e.jsxs("div",{style:{},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:p,title:"Add Member",onCancel:()=>{j(!1),A(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Add",color:"primary"})})]})},`add-${m}`)}),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(te,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:T=>{l(T??null),u(null),g(S=>!S)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(te,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:T=>u(T??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${b}`),e.jsx(pe,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){v.error("Select class and section.",{duration:1e3});return}s(T=>({...T,page:1}))}})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Ue,{parentCallback:U,data:{newData:B,columns:q,columnstype:"antd",action:!1,Loading:O,error:z}})})]})}function rd({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,u]=i.useState(!1),[b,g]=i.useState(null),p="api/branchapi/library/BookCategorytable",j="api/branchapi/library/addBookCategory",I="api/branchapi/library/editBookCategory",A="api/branchapi/library/deleteBookCategory",m=i.useMemo(()=>{const z=p.includes("?")?"&":"?";return`${p}${z}page=${a.page}&per_page=${a.rowsPerPage}`},[p,a.page,a.rowsPerPage]),{isLoading:c,error:y,data:P,mutate:R}=H(n&&m?[m,n]:null,([z,B])=>G(z,B)),D=(z,B)=>{s({page:z,rowsPerPage:parseInt(B,10)})},C=async z=>{const B=new FormData;B.set("title",z?.title??"");try{await We(j,B,n),v.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await R()}catch(w){v.error(w?.response?.data?.msg??w?.message??"Failed to add category.",{duration:1e3})}},h=z=>{g(z??null),l.setFieldsValue({title:z?.name??""}),u(!0)},f=()=>{u(!1),g(null),l.resetFields()},x=async z=>{const B=b?.id??b?.category_id??b?.cat_id;if(!B){v.error("Missing category id.",{duration:1e3});return}const w=new FormData;w.set("id",String(B)),w.set("title",z?.title??"");try{await ut(I,w,n),v.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),f(),await R()}catch(F){v.error(F?.response?.data?.msg??F?.message??"Failed to update category.",{duration:1e3})}},_=async z=>{const B=z?.id??z?.category_id??z?.cat_id;if(!B){v.error("Missing category id.",{duration:1e3});return}try{await nt(A,B,n),v.success("Success! Deleted category.",{duration:1e3}),await R()}catch(w){v.error(w?.response?.data?.msg??w?.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:(z,B)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>h(B)}),e.jsx(r.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>_(B),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(se.DeleteOutlined,{})})})]})}],[_]);return e.jsxs("div",{children:[e.jsx(v.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:x,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(pe,{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(pe,{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(Ue,{parentCallback:D,data:{newData:P,columns:O,columnstype:"antd",action:!1,Loading:c,error:y}})})})]})]})}const Fa=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function sd({token:t}){const[n,a]=i.useState([fe().format("YYYY-MM-DD"),fe().format("YYYY-MM-DD")]),[s,o]=i.useState(null),[l,d]=i.useState(null),[u,b]=i.useState(null),[g,p]=i.useState(!1),[j,I]=i.useState(!1),A="api/branchapi/academy/classdropdownlist",m="api/branchapi/academy/sectionoftheClass",c="api/branchapi/library/memberDropdown",y="api/report/libraryReport/libraryReport",P=i.useMemo(()=>{if(!s?.value)return null;const k=m.includes("?")?"&":"?";return`${m}${k}class_id=${encodeURIComponent(String(s.value))}`},[m,s?.value]),R=i.useMemo(()=>{if(!s?.value)return null;const k=c.includes("?")?"&":"?",N=`${c}${k}class=${encodeURIComponent(String(s.value))}`;return l?.value?`${N}§ion=${encodeURIComponent(String(l.value))}`:N},[c,s?.value,l?.value]),{isLoading:D,error:C,data:h,mutate:f}=H(t&&A?[A,t]:null,([k,N])=>G(k,N)),{data:x}=H(t&&P?[P,t]:null,([k,N])=>G(k,N)),{data:_}=H(t&&R?[R,t]:null,([k,N])=>G(k,N)),O=i.useMemo(()=>Fa(h),[h]),z=i.useMemo(()=>Fa(x),[x]),B=i.useMemo(()=>Fa(_),[_]),{trigger:w,data:F}=Ke(y,(k,N)=>Qa(k,N,t));i.useEffect(()=>{(async()=>{I(!0);try{await w({duration:n})}finally{I(!1)}})()},[]);const E=async()=>{I(!0);try{await w({duration:n,class:s?.value??"",section:l?.value??"",student_id:u?.value??""})}finally{I(!1)}},U=[{title:"Name",dataIndex:"full_name",render:(k,N)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:N?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(k,N)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:N?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(k,N)=>e.jsxs(r.Typography.Text,{style:{fontSize:12},children:[N?.class??"","(",N?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(k,N)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:N?.book_title??""})},{title:"Issue Date",key:"date",render:(k,N,V)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:N?.issue_date??""})},{title:"Due Return Date",key:"date",render:(k,N,V)=>e.jsx(r.Tag,{color:"orange",children:N?.return_date??""})},{title:"Return Date",key:"date",render:(k,N,V)=>N?.retured_by_user?e.jsx(r.Tag,{color:"green",children:N?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(k,N,V)=>String(N?.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:(k,N,V)=>{const q=N?.late_fine?Number(N.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(v.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:[fe(n[0],"YYYY-MM-DD"),fe(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(k,N)=>{Array.isArray(N)&&N.length===2&&a([N[0],N[1]])}})]})}),e.jsx(r.Col,{xs:24,md:5,children:e.jsx(te,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:s,onChange:k=>{o(k??null),d(null),b(null),p(N=>!N)},allowSelectAll:!1})}),e.jsx(r.Col,{xs:24,md:5,children:e.jsx(te,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:k=>{d(k??null),b(null)},allowSelectAll:!1},`section1${g}`)}),e.jsx(r.Col,{xs:24,md:5,children:e.jsx(te,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:u,onChange:k=>b(k??null),allowSelectAll:!1})}),e.jsx(r.Col,{xs:24,md:1,children:e.jsx(r.Button,{type:"primary",icon:e.jsx(se.SearchOutlined,{}),onClick:E,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(r.Table,{columns:U,pagination:!1,dataSource:Array.isArray(F?.data)?F.data:[],size:"small",rowKey:(k,N)=>k?.id??k?.issue_id??k?.fees_receipt_id??N,loading:j,scroll:{x:"max-content"},summary:k=>{const N=k.reduce((q,T)=>q+Number(T?.late_fine??0),0),V=k.reduce((q,T)=>q+Number(T?.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: ",k.length]})}),e.jsx(r.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(k.length-V)]})}),e.jsx(r.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",V]})}),e.jsx(r.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",N.toLocaleString("en-IN")]})})]})}})})]})]})}const fa=t=>t??localStorage.getItem("authToken")??"",id=(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},Me={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"}},od=()=>id(ot(),Me.upload),ld=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 G(l,fa(s))},_n=async(t,n,a)=>We(t,n,fa(a)),Gt=async(t,n,a)=>ut(t,n,fa(a)),Cn=async(t,n,a)=>nt(t,n,fa(a)),dd=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ht=({token:t,value:n,onChange:a})=>{const s=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(r.Upload,{maxCount:1,action:od(),headers:s,onChange:o=>{if(o?.file?.status==="done"){const l=dd(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},Kn=Me.vendor,Tn=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>H(s&&t?[t,n,a,s]:null,([l,d,u,b])=>ld({baseUrl:l,page:d,perPage:u},b)),cd=({token:t,page:n=1,perPage:a=10})=>Tn({baseUrl:Kn.list,page:n,perPage:a,token:t}),ud={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Gr=[{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 pd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,b]=i.useState(""),{isLoading:g,error:p,data:j,mutate:I}=cd({token:t,page:n.page,perPage:n.rowsPerPage}),A=async C=>{try{await I(_n(Kn.add,C,t),et(C)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(h){v.error(h?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},m=C=>{C.preventDefault();const h=new FormData(C.target);u&&h.set("image",u),A(h),C.target.reset(),b("")},c=(C,h)=>{a({page:C,rowsPerPage:parseInt(h,10)})},y=async C=>{try{await I(Cn(Kn.remove,C,t),Ge(C)),v.success("Success! Deleted item.",{duration:1e3})}catch(h){v.error(h?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},P=C=>{d(C),o(!0),b("")},R=async C=>{C.preventDefault();const h=new FormData(C.target);h.set("id",String(l?.id??"")),u&&h.set("image",u);try{await Gt(Kn.edit,h,t),await I(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),b("")}catch(f){v.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,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>P(h),style:{padding:2}}),e.jsx(lt,{id:h?.id,funcName:y})]})}],[y]);return e.jsxs("div",{children:[e.jsx(v.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),b("")},children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[Gr.map(C=>e.jsx(Z,{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(Ht,{token:t,value:u,onChange:b})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null),b("")},style:ud,children:"Cancel"})]})]})})}),e.jsxs(ue,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(ue,{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:[Gr.map(C=>e.jsx(Z,{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(Ht,{token:t,value:u,onChange:b})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(ue,{pt:3,children:e.jsx(Ue,{parentCallback:c,data:{newData:j,columns:D,columnstype:"antd",action:!1,Loading:g,error:p}})})]})]})]})}const md=({token:t})=>e.jsx(pd,{token:t}),fd={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},yd={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"},hn=({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:fd,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:{...yd,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},Gn=Me.product,Jr=Me.vendor.dropdown,Qr=Me.category.dropdown,hd=Me.subCategory.dropdown,Xr=Me.unit.dropdown,ci=({token:t,page:n=1,perPage:a=10})=>Tn({baseUrl:Gn.list,page:n,perPage:a,token:t}),gd=({token:t})=>H(t&&Jr?[Jr,t]:null,([a,s])=>G(a,s)),xd=({token:t})=>H(t&&Qr?[Qr,t]:null,([a,s])=>G(a,s)),bd=({token:t})=>H(t&&Xr?[Xr,t]:null,([a,s])=>G(a,s)),Sd=({token:t,categoryId:n})=>{const a=t&&n?`${hd}?category_id=${encodeURIComponent(String(n))}`:null;return H(a?[a,t]:null,([o,l])=>G(o,l))},kn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},jd={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function wd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,b]=i.useState(""),[g,p]=i.useState(""),[j,I]=i.useState(""),[A,m]=i.useState(""),[c,y]=i.useState(""),{isLoading:P,error:R,data:D,mutate:C}=ci({token:t,page:n.page,perPage:n.rowsPerPage}),{data:h}=gd({token:t}),{data:f}=xd({token:t}),{data:x}=bd({token:t}),{data:_}=Sd({token:t,categoryId:g}),O=i.useMemo(()=>kn(h),[h]),z=i.useMemo(()=>kn(f),[f]),B=i.useMemo(()=>kn(x),[x]),w=i.useMemo(()=>kn(_),[_]),F=async T=>{try{await C(_n(Gn.add,T,t),et(T)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(S){v.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},E=T=>{T.preventDefault();const S=new FormData(T.target);g&&S.set("fk_categoryID",String(g)),j&&S.set("fk_sub_categoryID",String(j)),A&&S.set("vendor_id",String(A)),c&&S.set("unit",String(c)),u&&S.set("image",u),F(S),T.target.reset(),b(""),p(""),I(""),m(""),y("")},U=(T,S)=>{a({page:T,rowsPerPage:parseInt(S,10)})},k=async T=>{try{await C(Cn(Gn.remove,T,t),Ge(T)),v.success("Success! Deleted item.",{duration:1e3})}catch(S){v.error(S?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},N=T=>{d(T),o(!0),b(""),p(T?.fk_categoryID??T?.category_id??""),I(T?.fk_sub_categoryID??T?.sub_category_id??""),m(T?.vendor_id??""),y(T?.unit??T?.unit_id??"")},V=async T=>{T.preventDefault();const S=new FormData(T.target);S.set("id",String(l?.id??"")),g&&S.set("fk_categoryID",String(g)),j&&S.set("fk_sub_categoryID",String(j)),A&&S.set("vendor_id",String(A)),c&&S.set("unit",String(c)),u&&S.set("image",u);try{await Gt(Gn.edit,S,t),await C(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),b("")}catch($){v.error($?.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:(T,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>N(S),style:{padding:2}}),e.jsx(lt,{id:S?.id,funcName:k})]})}],[k]);return e.jsxs("div",{children:[e.jsx(v.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),b("")},children:e.jsx("form",{onSubmit:V,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(Z,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(te,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:T=>{const S=T?.value??"";p(S),I("")},defaultValue:g?z.find(T=>String(T?.value)===String(g)):null}),e.jsx(te,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:T=>I(T?.value??""),defaultValue:j?w.find(T=>String(T?.value)===String(j)):null}),e.jsx(Z,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(te,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:T=>y(T?.value??""),defaultValue:c?B.find(T=>String(T?.value)===String(c)):null}),e.jsx(Z,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(Z,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(te,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:T=>m(T?.value??""),defaultValue:A?O.find(T=>String(T?.value)===String(A)):null}),e.jsx(Z,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(hn,{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(Ht,{token:t,value:u,onChange:b})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null),b("")},style:jd,children:"Cancel"})]})]})})}),e.jsxs(ue,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:E,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(te,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:T=>{const S=T?.value??"";p(S),I("")}}),e.jsx(te,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:T=>I(T?.value??"")},`subcat_${g}`),e.jsx(Z,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(te,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:T=>y(T?.value??"")}),e.jsx(Z,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(Z,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(te,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:T=>m(T?.value??"")}),e.jsx(Z,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(hn,{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(Ht,{token:t,value:u,onChange:b})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(ue,{pt:3,children:e.jsx(Ue,{parentCallback:U,data:{newData:D,columns:q,columnstype:"antd",action:!1,Loading:P,error:R}})})]})]})]})}const vd=({token:t})=>e.jsx(wd,{token:t}),Jn=Me.category,_d=({token:t,page:n=1,perPage:a=10})=>Tn({baseUrl:Jn.list,page:n,perPage:a,token:t}),Cd={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Td({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:u,error:b,data:g,mutate:p}=_d({token:t,page:n.page,perPage:n.rowsPerPage}),j=async R=>{try{await p(_n(Jn.add,R,t),et(R)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){v.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},I=R=>{R.preventDefault();const D=new FormData(R.target);j(D),R.target.reset()},A=(R,D)=>{a({page:R,rowsPerPage:parseInt(D,10)})},m=async R=>{try{await p(Cn(Jn.remove,R,t),Ge(R)),v.success("Success! Deleted item.",{duration:1e3})}catch(D){v.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},c=R=>{d(R),o(!0)},y=async R=>{R.preventDefault();const D=new FormData(R.target);D.set("id",String(l?.id??""));try{await Gt(Jn.edit,D,t),await p(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(C){v.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},P=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(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>c(D),style:{padding:2}}),e.jsx(lt,{id:D?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(v.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:y,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Z,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Z,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Cd,children:"Cancel"})]})]})})}),e.jsxs(ue,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Z,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(ue,{pt:3,children:e.jsx(Ue,{parentCallback:A,data:{newData:g,columns:P,columnstype:"antd",action:!1,Loading:u,error:b}})})]})]})]})}const Ad=({token:t})=>e.jsx(Td,{token:t}),Qn=Me.subCategory,Zr=Me.category.dropdown,Id=({token:t,page:n=1,perPage:a=10})=>Tn({baseUrl:Qn.list,page:n,perPage:a,token:t}),Rd=({token:t})=>H(t&&Zr?[Zr,t]:null,([a,s])=>G(a,s)),Dd=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Od={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Pd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,b]=i.useState(""),{isLoading:g,error:p,data:j,mutate:I}=Id({token:t,page:n.page,perPage:n.rowsPerPage}),{data:A}=Rd({token:t}),m=i.useMemo(()=>Dd(A),[A]),c=async f=>{try{await I(_n(Qn.add,f,t),et(f)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(x){v.error(x?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},y=f=>{f.preventDefault();const x=new FormData(f.target);x.set("status","active"),x.set("img",u||""),c(x),f.target.reset(),b("")},P=(f,x)=>{a({page:f,rowsPerPage:parseInt(x,10)})},R=async f=>{try{await I(Cn(Qn.remove,f,t),Ge(f)),v.success("Success! Deleted item.",{duration:1e3})}catch(x){v.error(x?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=f=>{d(f),o(!0)},C=async f=>{f.preventDefault();const x=new FormData(f.target);x.set("id",String(l?.id??"")),u&&x.set("img",u);try{await Gt(Qn.edit,x,t),await I(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),b("")}catch(_){v.error(_?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},h=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(f,x)=>String(f?.name??"").localeCompare(String(x?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(f,x)=>String(f?.description??"").localeCompare(String(x?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(f,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>D(x),style:{padding:2}}),e.jsx(lt,{id:x?.id,funcName:R})]})}],[R]);return e.jsxs("div",{children:[e.jsx(v.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),b("")},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?m.find(f=>String(f?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(Z,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(Z,{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(Ht,{token:t,value:u,onChange:b})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null),b("")},style:Od,children:"Cancel"})]})]})})}),e.jsxs(ue,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(Z,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Z,{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(Ht,{token:t,value:u,onChange:b})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(ue,{pt:3,children:e.jsx(Ue,{parentCallback:P,data:{newData:j,columns:h,columnstype:"antd",action:!1,Loading:g,error:p}})})]})]})]})}const Ed=({token:t})=>e.jsx(Pd,{token:t}),ka=Me.product,Fd=Me.academy.classes,kd=Me.academy.sections,Md=Me.student.dropdown;function an(t){const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]}function Mn(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 Je(t){return String(t??"")}function $d({token:t}){const[n,a]=i.useState(""),[s,o]=i.useState(""),[l,d]=i.useState(""),[u,b]=i.useState(!1),[g,p]=i.useState(""),[j,I]=i.useState([]),[A,m]=i.useState({}),[c,y]=i.useState({}),[P,R]=i.useState(!1),[D,C]=i.useState(""),[h,f]=i.useState(0),[x,_]=i.useState(""),[O,z]=i.useState(fe()),[B,w]=i.useState([]),F={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},E=!!(n&&s&&l),{data:U}=H(t?[Fd,t]:null,([ce,ge])=>G(ce,ge)),k=i.useMemo(()=>an(U),[U]),N=t&&n?`${kd}?class_id=${encodeURIComponent(String(n))}`:null,{data:V}=H(N?[N,t]:null,([ce,ge])=>G(ce,ge)),q=i.useMemo(()=>an(V),[V]),T=t&&n&&s?`${Md}?class=${encodeURIComponent(String(n))}§ion=${encodeURIComponent(String(s))}`:null,{data:S}=H(T?[T,t]:null,([ce,ge])=>G(ce,ge)),$=i.useMemo(()=>an(S),[S]),M=E?`${ka.list}?page=1&per_page=10000`:null,{data:L,isLoading:ee}=H(t&&M?[M,t]:null,([ce,ge])=>G(ce,ge),{revalidateOnFocus:!1}),W=i.useMemo(()=>an(L),[L]),K=i.useMemo(()=>{const ce=new Map;return(Array.isArray(W)?W:[]).forEach(ge=>{ce.set(Je(ge?.id),ge)}),ce},[W]),Q=i.useMemo(()=>{const ce=Object.entries(c||{});return ce.length===0?[]:ce.map(([ge,ye])=>{const J=K.get(Je(ge));return J?{id:J?.id,name:J?.name,barcode:J?.barcode,stock:Number(J?.quantity||0),price:Number(J?.price||0),quantity:Mn(ye,Number(J?.quantity||0))}:null}).filter(Boolean)},[c,K]),ne=i.useMemo(()=>new Set(Q.map(ce=>Je(ce?.id))),[Q]),le=i.useMemo(()=>(Array.isArray(Q)?Q:[]).reduce((ge,ye)=>ge+Number(ye?.price||0)*Number(ye?.quantity||1),0),[Q]),je=i.useMemo(()=>{const ce=Number(h||0);return!Number.isFinite(ce)||ce<=0?0:Math.min(ce,le)},[h,le]),ae=i.useMemo(()=>Math.max(0,le-je),[je,le]),re=i.useMemo(()=>(Array.isArray(W)?W:[]).slice(0,30).map(ce=>({value:Je(ce?.id),label:`${ce?.name??""}${ce?.barcode?` • ${ce.barcode}`:""}${ce?.quantity!==void 0&&ce?.quantity!==null?` • Stock: ${ce.quantity}`:""}`,product:ce})),[W]),{trigger:X}=Ke(t&&E?ka.search:null,(ce,{arg:ge})=>Dt(ce,{arg:ge},t));i.useEffect(()=>{if(!E){I([]);return}const ce=String(g||"").trim();if(ce.length<2){I(re);return}let ge=!0;const ye=setTimeout(async()=>{let J=[];try{if(X){const me=await X({search:ce});J=an(me)}}catch{J=[]}if(!Array.isArray(J)||J.length===0){const me=ce.toLowerCase();J=(Array.isArray(W)?W:[]).filter(Te=>{const Ae=String(Te?.name??"").toLowerCase(),pt=String(Te?.barcode??"").toLowerCase();return Ae.includes(me)||pt.includes(me)}).slice(0,30)}const oe=J.slice(0,30).map(me=>({value:Je(me?.id),label:`${me?.name??""}${me?.barcode?` • ${me.barcode}`:""}${me?.quantity!==void 0&&me?.quantity!==null?` • Stock: ${me.quantity}`:""}`,product:me}));ge&&I(oe)},250);return()=>{ge=!1,clearTimeout(ye)}},[re,E,X,W,g]),i.useEffect(()=>{y({}),m({}),p(""),I([]),R(!1),C(""),f(0),_(""),z(fe()),w([])},[n,s,l]);const xe=i.useCallback((ce,ge=1)=>{const ye=ce?.id;if(!ye)return;const J=Number(ce?.quantity||0);if(J<=0){v.error("Out of stock.",{duration:1e3});return}const oe=Mn(ge,J);y(me=>{const Te=me||{};return Object.prototype.hasOwnProperty.call(Te,Je(ye))?(v.error("Product already added.",{duration:1e3}),Te):{...Te,[Je(ye)]:oe}})},[y]),De=i.useCallback((ce,ge,ye)=>{y(J=>{const oe=J||{},me=Je(ce);return Object.prototype.hasOwnProperty.call(oe,me)?{...oe,[me]:Mn(ge,ye)}:oe})},[]),qe=i.useCallback(ce=>{y(ge=>{const ye=ge||{},J=Je(ce);if(!Object.prototype.hasOwnProperty.call(ye,J))return ye;const oe={...ye};return delete oe[J],oe})},[]),Be=i.useCallback((ce,ge,ye)=>{m(J=>({...J||{},[Je(ce)]:Mn(ge,ye)}))},[]),$e=i.useCallback((ce,ge)=>{ge?.product&&xe(ge.product,1),p(""),I(re)},[xe,re]),Oe=i.useCallback(ce=>{if(ce.key!=="Enter")return;ce.preventDefault();const ge=Array.isArray(j)&&j.length>0?j[0]:null;if(ge?.product){xe(ge.product,1),p(""),I(re);return}const ye=String(g||"").trim().toLowerCase();if(ye.length===0)return;const J=(Array.isArray(W)?W:[]).find(oe=>{const me=String(oe?.name??"").toLowerCase(),Te=String(oe?.barcode??"").toLowerCase();return me.includes(ye)||Te.includes(ye)});J&&(xe(J,1),p(""),I(re))},[xe,re,W,j,g]),ze=()=>{if(!t){v.error("Missing token.",{duration:1e3});return}if(!n){v.error("Select class.",{duration:1e3});return}if(!s){v.error("Select section.",{duration:1e3});return}if(!l){v.error("Select student.",{duration:1e3});return}if(!Q||Q.length===0){v.error("Add at least one product.",{duration:1e3});return}R(!0)},{trigger:Ve,isMutating:Ee}=Ke(t?ka.sellProduct:null,(ce,{arg:ge})=>Ja(ce,{arg:ge},t)),Le=async()=>{if(!D){v.error("Select payment type.",{duration:1e3});return}const ce=(Array.isArray(Q)?Q:[]).map(ye=>({id:ye?.id,quantity:Number(ye?.quantity||1),price:Number(ye?.price||0),total_price:Number(ye?.total_price||0),fk_vendor_id:ye?.fk_vendor_id||"",fk_categoryID:ye?.fk_categoryID||"",name:ye?.name||"",class_id:ye?.class_id||"",fk_sub_categoryID:ye?.fk_sub_categoryID||"",description:ye?.description||"",min_quantity:Number(ye?.min_quantity||0),storecategory:Number(ye?.storecategory||0),barcode:ye?.barcode||""})),ge={amount:le,class:n,section:s,student_id:l,payment_type:D,discount:je,notes:x||"",receipt_date:O?fe(O).format("YYYY-MM-DD"):"",product:JSON.stringify(ce),total_payable_amount:le,attchement:B[0]?.originFileObj||""};try{const J=Array.isArray(B)&&B.length>0&&B[0]?.originFileObj?(()=>{const me=new FormData;return Object.entries(ge).forEach(([Te,Ae])=>{if(Te==="products"){me.append("product",JSON.stringify(Ae));return}me.append(Te,String(Ae??""))}),me.append("attachment",B[0].originFileObj),me})():ge,oe=await Ve(J);oe?.Status==="Success"?(v.success("Success! Product sold.",{duration:1e3}),R(!1),y({}),m({}),p(""),I(re),C(""),f(0),_(""),z(fe()),w([])):v.error(oe?.msg??"Failed to submit.",{duration:1e3})}catch{v.error("Failed to submit.",{duration:1e3})}},at=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:(ce,ge)=>{const ye=Je(ge?.id),J=Number(ge?.quantity||0),oe=ne.has(ye),me=(oe?c?.[ye]:A?.[ye])??1;return e.jsx(r.InputNumber,{min:1,max:Number.isFinite(J)&&J>0?J:void 0,value:me,onChange:Te=>{oe?De(ye,Te,J):Be(ye,Te,J)},disabled:J<=0})}},{title:"Amount",key:"amount",width:140,render:(ce,ge)=>{const ye=Je(ge?.id),J=(ne.has(ye)?c?.[ye]:A?.[ye])??1;return Number(ge?.price||0)*Number(J||1)}},{title:"Action",key:"action",width:120,render:(ce,ge)=>{const ye=Je(ge?.id),J=Number(ge?.quantity||0),oe=ne.has(ye),me=(oe?c?.[ye]:A?.[ye])??1;return oe?e.jsx(r.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(se.DeleteOutlined,{}),onClick:()=>qe(ye),style:{padding:2}}):e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.PlusOutlined,{}),disabled:J<=0,onClick:()=>xe(ge,me),style:{padding:2}})}}],[xe,ne,c,A,qe,Be,De]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(ue,{pt:5,pb:2,children:[e.jsxs(ue,{style:{padding:"12px 16px"},children:[e.jsx(ue,{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(te,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:ce=>{const ge=ce?.value??"";a(ge),o(""),d(""),b(ye=>!ye)}}),e.jsx(te,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:ce=>{const ge=ce?.value??"";o(ge),d("")}},`section_${u}`),e.jsx(te,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:ce=>d(ce?.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(ue,{style:{marginTop:12},children:"Product Section"}),e.jsx(r.AutoComplete,{value:g,options:j,onSearch:p,onFocus:()=>{E&&String(g||"").trim().length<2&&I(re)},onSelect:$e,disabled:!E,children:e.jsx(r.Input,{placeholder:"Search by product name or barcode",onKeyDown:Oe,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",mt(le)]})]}),e.jsx(r.Table,{rowKey:ce=>Je(ce?.id),columns:at,dataSource:W,loading:ee,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:Q.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:mt(le)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(pe,{type:"button",value:"Submit",disabled:!E||Q.length===0,onClick:ze,style:{flex:1,minWidth:140}}),e.jsx(r.Button,{type:"text",style:F,onClick:()=>{y({}),m({}),p(""),I(re)},disabled:Q.length===0,children:"Clear"})]})]})]})})]}),e.jsx(r.Modal,{open:P,title:"Payment",onCancel:()=>R(!1),onOk:Le,confirmLoading:Ee,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:O,onChange:ce=>z(ce),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:le,value:h,onChange:ce=>f(Number(ce||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:B,beforeUpload:()=>!1,onChange:({fileList:ce})=>w((ce||[]).slice(-1)),maxCount:1,children:e.jsx(r.Button,{icon:e.jsx(se.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:x,onChange:ce=>_(ce.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:mt(le)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:mt(je)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:mt(ae)})]})]})})]})})]})}const Ud=({token:t})=>e.jsx($d,{token:t}),Xn=Me.unit,Bd=({token:t,page:n=1,perPage:a=10})=>Tn({baseUrl:Xn.list,page:n,perPage:a,token:t}),Nd={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function qd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:u,error:b,data:g,mutate:p}=Bd({token:t,page:n.page,perPage:n.rowsPerPage}),j=async R=>{try{await p(_n(Xn.add,R,t),et(R)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){v.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},I=R=>{R.preventDefault();const D=new FormData(R.target);j(D),R.target.reset()},A=(R,D)=>{a({page:R,rowsPerPage:parseInt(D,10)})},m=async R=>{try{await p(Cn(Xn.remove,R,t),Ge(R)),v.success("Success! Deleted item.",{duration:1e3})}catch(D){v.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},c=R=>{d(R),o(!0)},y=async R=>{R.preventDefault();const D=new FormData(R.target);D.set("id",String(l?.id??""));try{await Gt(Xn.edit,D,t),await p(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(C){v.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},P=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(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>c(D),style:{padding:2}}),e.jsx(lt,{id:D?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(v.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:y,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Z,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Z,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Nd,children:"Cancel"})]})]})})}),e.jsxs(ue,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(ue,{px:3,pb:2,children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(Z,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(ue,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Pe,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(ue,{pt:3,children:e.jsx(Ue,{parentCallback:A,data:{newData:g,columns:P,columnstype:"antd",action:!1,Loading:u,error:b}})})]})]})]})}const Ld=({token:t})=>e.jsx(qd,{token:t}),zd=Me.product.sellReports,Vd=Me.academy.classes,Yd=Me.academy.sections,Wd=Me.student.dropdown,es=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Hd({token:t}){const n=i.useRef(null),[a,s]=i.useState(null),[o,l]=i.useState(""),[d,u]=i.useState(""),[b,g]=i.useState(""),[p,j]=i.useState(!1),I=w=>{const F=w?.data?.data??w?.data??w??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},{data:A}=H(t?[Vd,t]:null,([w,F])=>G(w,F)),m=i.useMemo(()=>I(A),[A]),c=t&&o?`${Yd}?class_id=${encodeURIComponent(String(o))}`:null,{data:y}=H(c?[c,t]:null,([w,F])=>G(w,F)),P=i.useMemo(()=>I(y),[y]),R=t&&o&&d?`${Wd}?class=${encodeURIComponent(String(o))}§ion=${encodeURIComponent(String(d))}`:null,{data:D}=H(R?[R,t]:null,([w,F])=>G(w,F)),C=i.useMemo(()=>I(D),[D]),{trigger:h,isMutating:f,data:x}=Ke(zd,(w,{arg:F})=>Qa(w,{arg:F},t));i.useEffect(()=>{const F=new Date().toISOString().slice(0,10);h({duration:[F,F]})},[h]);const _=i.useMemo(()=>{const w=x?.data??x??[];return Array.isArray(w)?w:[]},[x]),O=w=>{const F=Array.isArray(w?.product_details)?w.product_details:[];return F.length===0?null:e.jsx(r.Table,{size:"small",bordered:!0,pagination:!1,rowKey:E=>`${w?.receipt_id??"r"}_${E?.product_name??E?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:E=>es(E)}],dataSource:F})},z=[{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:w=>es(w)}],B=async()=>{if(!a||a.length!==2)return;const[w,F]=a;await h({duration:[w.format("YYYY-MM-DD"),F.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:b||""})};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(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:w=>{const F=w?.value??"";l(F),u(""),g(""),j(E=>!E)}}),e.jsx(te,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:w=>{const F=w?.value??"";u(F),g("")}},`section_${p}`),e.jsx(te,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:w=>g(w?.value??"")}),e.jsx(pe,{type:"button",value:f?"Searching...":"Search",disabled:f,onClick:B,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(ma,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(vn,{})}),e.jsx(r.Table,{bordered:!0,size:"small",loading:f,rowKey:w=>String(w?.receipt_id??w?.receipt_no??Math.random()),columns:z,expandable:{expandedRowRender:O},dataSource:_,pagination:{pageSize:20}})]})})})]})})}const Kd=({token:t})=>e.jsx(Hd,{token:t}),Gd=Me.product;function Jd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState([]),[l,d]=i.useState([]),[u,b]=i.useState(!1),[g,p]=i.useState(!1),[j,I]=i.useState(null),[A,m]=i.useState(0),[c,y]=i.useState(null),[P,R]=i.useState(""),D=i.useRef(null),C=gn.useReactToPrint({contentRef:D,documentTitle:"Stock Barcodes"}),{isLoading:h,error:f,data:x,mutate:_}=ci({token:t,page:n.page,perPage:n.rowsPerPage}),O=(U,k)=>{a({page:U,rowsPerPage:parseInt(k,10)})},z={selectedRowKeys:s,onChange:(U,k)=>{o(U),d(k)}},B=U=>{I(U),m(Number(U?.quantity??0)),y(null),R(""),b(!0)},w=()=>{b(!1),I(null),m(0),y(null),R("")},F=async()=>{if(!j?.id)return;p(!0);const U=new FormData;U.append("product_id",String(j.id)),U.append("qty",String(A??0)),c&&U.append("tran_date",c.format("YYYY-MM-DD")),P&&U.append("remarks",P);try{const k=await Gt(Gd.addStock,U,t);k?.Status==="Success"?(v.success("Success! Updated quantity.",{duration:1e3}),w(),await _()):v.error(k?.msg??"Failed to update quantity.",{duration:1e3})}catch{v.error("Failed to update quantity.",{duration:1e3})}finally{p(!1)}},E=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:(U,k)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(r.Button,{size:"small",onClick:()=>B(k),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:j?.name?`Update Stock: ${j.name}`:"Update Stock",open:u,onCancel:w,onOk:F,okButtonProps:{loading:g},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:A,onChange:U=>m(U??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(r.DatePicker,{style:{width:"100%"},value:c,onChange:y})]}),e.jsx(hn,{label:"Remarks",name:"remarks",rows:3,value:P,onChange:U=>R(U.target.value)})]})}),e.jsxs(ue,{pt:5,pb:2,children:[e.jsxs(ue,{children:["Manage Stock",e.jsx(pe,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>C?.(),style:{minWidth:170}})]}),e.jsx(ue,{style:{padding:"12px 16px"},children:e.jsx(r.Card,{style:{borderRadius:16},children:e.jsx(Ue,{parentCallback:O,data:{newData:x,columns:E,columnstype:"antd",action:!1,Loading:h,error:f,rowSelection:z}})})})]}),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(U=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:U?.name??""}),e.jsx(Is,{value:String(U?.barcode??U?.id??""),height:50,width:1.6,displayValue:!0})]},U?.id??U?.barcode??U?.name))})})})]})}const Qd=({token:t})=>e.jsx(Jd,{token:t}),Xd=Me.report.stock,Zd=Me.product.dropdown,ec=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function tc({token:t}){const n=i.useRef(null),[a,s]=i.useState(null),[o,l]=i.useState(""),{data:d}=H(t?[Zd,t]:null,([m,c])=>G(m,c)),u=i.useMemo(()=>ec(d),[d]),{trigger:b,isMutating:g,data:p}=Ke(Xd,(m,{arg:c})=>Qa(m,{arg:c},t));i.useEffect(()=>{const c=new Date().toISOString().slice(0,10);b({duration:[c,c]})},[b]);const j=i.useMemo(()=>{const m=p?.data??p??[];return(Array.isArray(m)?m:[]).flatMap(y=>(Array.isArray(y?.ledger)?y.ledger:[]).map((P,R)=>({key:`${y.product_id??y.product_name??"p"}-${R}`,date:P?.date,product:y?.product_name,opening:P?.opening,inward:P?.inward,outward:P?.outward,closing:P?.closing})))},[p]),I=[{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})}],A=async()=>{if(!a||a.length!==2)return;const[m,c]=a;await b({duration:[m.format("YYYY-MM-DD"),c.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: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"}),u.map(m=>e.jsx("option",{value:String(m?.value??""),children:String(m?.label??"")},String(m?.value??m?.id??m?.label)))]}),e.jsx(r.Button,{type:"primary",onClick:A,loading:g,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(ma,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(vn,{})}),e.jsx(r.Table,{bordered:!0,size:"small",loading:g,rowKey:"key",columns:I,dataSource:j,pagination:{pageSize:50}})]})]})}const nc=({token:t})=>e.jsx(tc,{token:t}),ya=t=>t??localStorage.getItem("authToken")??"",er=(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},Ce={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"}},ui=()=>er(ot(),Ce.upload),ac=()=>er(ot(),Ce.staff.uploadProfile),rc=()=>er(ot(),Ce.staff.uploadDocuments),sc=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 G(l,ya(s))},yt=async(t,n,a)=>We(t,n,ya(a)),_t=async(t,n,a)=>ut(t,n,ya(a)),An=async(t,n,a)=>nt(t,n,ya(a)),Ot=Ce.staff,ic=Ce.master.shift.dropdown,oc=Ce.master.department.dropdown,lc=Ce.master.designation.dropdown,dc=Ce.roleDropdown,$n=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},cc=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={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ts={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function uc({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",[u,b]=i.useState(s?.roleValue??null),[g,p]=i.useState(s?.departmentValue??null),[j,I]=i.useState(s?.designationValue??null),[A,m]=i.useState(s?.genderValue??null),[c,y]=i.useState(s?.shiftValue??(d?[]:null)),[P,R]=i.useState(s?.dob?fe(s.dob):null),[D,C]=i.useState(s?.doj?fe(s.doj):null),[h,f]=i.useState(s?.file??""),{data:x}=H(t?[ic,t]:null,([V,q])=>G(V,q)),{data:_}=H(t?[oc,t]:null,([V,q])=>G(V,q)),{data:O}=H(t?[lc,t]:null,([V,q])=>G(V,q)),{data:z}=H(t?[dc,t]:null,([V,q])=>G(V,q)),{data:B}=H(t?[Ot.lastEmpNo,t]:null,([V,q])=>G(V,q)),w=i.useMemo(()=>$n(x),[x]),F=i.useMemo(()=>$n(_),[_]),E=i.useMemo(()=>$n(O),[O]),U=i.useMemo(()=>$n(z),[z]),k=i.useMemo(()=>{const V=B?.data?.emp_number??B?.emp_number??B?.data??"";return String(V??"")},[B]),N=async V=>{V.preventDefault();const q=new FormData(V.target);q.set("role",u?.value??u??""),q.set("department",g?.value??g??""),q.set("designation",j?.value??j??""),q.set("gender",A?.value??A??""),q.set("dob",P?P.format("YYYY-MM-DD"):""),q.set("doj",D?D.format("YYYY-MM-DD"):""),d?(q.delete("shift_id"),(Array.isArray(c)?c:[]).forEach(S=>{q.append("shift_id[]",S?.value??S??"")})):q.set("shift_id",c?.value??c??""),h&&q.set("file",h);try{const T=n==="edit"&&a,S=T?Ot.editBasic:Ot.addBasic;T&&q.set("staff_id",String(a));const $=T?await _t(S,q,t):await yt(S,q,t),M=$?.ID??$?.id??a??null;v.success("Success!",{duration:1e3}),o?.({staffId:M,basic:{roleValue:u,departmentValue:g,designationValue:j,genderValue:A,shiftValue:c,dob:P,doj:D,file:h}})}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{type:"number",name:"emp_number",label:"EMP No",defaultValue:s?.emp_number??k,required:!0}),e.jsx(Z,{type:"text",name:"f_name",label:"First Name",defaultValue:s?.f_name??"",required:!0}),e.jsx(Z,{type:"text",name:"l_name",label:"Last Name",defaultValue:s?.l_name??"",required:!0}),e.jsx(Z,{type:"text",name:"pan_no",label:"PAN",defaultValue:s?.pan_no??""}),e.jsx(Z,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:s?.adhar_no??""}),e.jsx(te,{label:"Role",options:U,value:u,onChange:V=>b(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(te,{label:"Department",options:F,value:g,onChange:V=>p(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(te,{label:"Designation",options:E,value:j,onChange:V=>I(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(te,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:A,onChange:V=>m(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{type:"text",name:"email",label:"Email",defaultValue:s?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:rn,children:"DOB"}),e.jsx(r.DatePicker,{value:P,onChange:V=>R(V),style:ts,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:rn,children:"DOJ"}),e.jsx(r.DatePicker,{value:D,onChange:V=>C(V),style:ts,placeholder:"Select DOJ"})]}),e.jsx(Z,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:s?.bloodGroup??""}),e.jsx(Z,{type:"text",name:"contact_no",label:"Contact No",defaultValue:s?.contact_no??"",required:!0}),e.jsx(Z,{type:"text",name:"education",label:"Education",defaultValue:s?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:rn,children:"Shift"}),e.jsx(te,{options:w,value:c,onChange:V=>y(V??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:rn,children:"Profile Picture"}),e.jsx(r.Upload,{maxCount:1,action:ac(),headers:t?{Authorization:t}:void 0,onChange:V=>{if(V?.file?.status==="done"){const q=cc(V?.file?.response);q&&f(q)}V?.file?.status==="removed"&&f("")},children:e.jsx(r.Button,{type:"link",style:{paddingLeft:0},children:h?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:rn,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(pe,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const Un={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ns={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},pc=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",as=t=>{if(!t)return null;const n=fe(t);return n.isValid()?n:null};function mc({token:t,mode:n,staffId:a,initialRows:s,onSubmitted:o,onBack:l}){const[d,u]=i.useState(()=>(Array.isArray(s)&&s.length?s:[{name:"",from:null,to:null,image:""}]).map(m=>({name:m?.name??"",from:as(m?.from),to:as(m?.to),image:m?.image??""}))),b=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),g=(A,m)=>{u(c=>c.map((y,P)=>P===A?{...y,...m}:y))},p=()=>u(A=>[...A,{name:"",from:null,to:null,image:""}]),j=A=>u(m=>m.length<=1?m:m.filter((c,y)=>y!==A)),I=async A=>{if(A.preventDefault(),!a){v.error("Missing staff id.",{duration:1e3});return}const m=new FormData;m.append("staff_id",String(a)),d.forEach((c,y)=>{m.append(`experience[${y}][name]`,String(c?.name??"")),m.append(`experience[${y}][from]`,c?.from?c.from.format("YYYY-MM-DD"):""),m.append(`experience[${y}][to]`,c?.to?c.to.format("YYYY-MM-DD"):""),m.append(`experience[${y}][image]`,String(c?.image??""))});try{const c=n==="edit",y=c?Ot.editExperience:Ot.addExperience,P=c?await _t(y,m,t):await yt(y,m,t);v.success("Success!",{duration:1e3}),o?.({experience:d,result:P})}catch(c){v.error(c?.response?.data?.msg??c?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((A,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:Un,children:"Name"}),e.jsx("input",{value:A.name,onChange:c=>g(m,{name:c.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:Un,children:"From"}),e.jsx(r.DatePicker,{value:A.from,onChange:c=>g(m,{from:c}),style:ns})]}),e.jsxs("div",{children:[e.jsx("div",{style:Un,children:"To"}),e.jsx(r.DatePicker,{value:A.to,onChange:c=>g(m,{to:c}),style:ns})]}),e.jsxs("div",{children:[e.jsx("div",{style:Un,children:"Document"}),e.jsx(r.Upload,{maxCount:1,action:rc(),headers:b,onChange:c=>{if(c?.file?.status==="done"){const y=pc(c?.file?.response);y&&g(m,{image:y})}c?.file?.status==="removed"&&g(m,{image:""})},children:e.jsx(r.Button,{icon:e.jsx(se.UploadOutlined,{}),children:"Upload"})}),!!A.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:A.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(r.Button,{type:"text",icon:e.jsx(se.DeleteOutlined,{}),danger:!0,onClick:()=>j(m),disabled:d.length<=1})})]},`exp-${m}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(r.Button,{icon:e.jsx(se.PlusOutlined,{}),onClick:p,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(r.Button,{onClick:l,children:"Back"}),e.jsx(pe,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const rs=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:n??[]},sn=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function fc({token:t,mode:n,staffId:a,initialValues:s,onSubmitted:o,onBack:l}){const[d,u]=i.useState(s?.type??"Permanent"),[b,g]=i.useState(s?.salary_type??sn[0]?.value),[p,j]=i.useState(Number(s?.amount??0)),[I,A]=i.useState(Number(s?.basic_pay??0)),[m,c]=i.useState(s?.declarationPERyear??""),{data:y}=H(t?[sl,t]:null,([f,x])=>G(f,x),{revalidateOnFocus:!1}),P=i.useMemo(()=>rs(y?.Allowances),[y]),R=i.useMemo(()=>rs(y?.Dedection),[y]),D=i.useMemo(()=>{const f=Number(I||0),x=(Array.isArray(P)?P:[]).map(w=>{const F=w?.amount_type??w?.amountType??w?.type,E=Number(w?.Amount??w?.amount??0),U=String(F).toLowerCase()==="flat"?E:Number(f)/100*Number(E||0);return{...w,value:Number.isFinite(U)?U:0}}),_=(Array.isArray(R)?R:[]).map(w=>{const F=w?.amount_type??w?.amountType??w?.type,E=Number(w?.Amount??w?.amount??0),U=String(F).toLowerCase()==="flat"?E:Number(f)/100*Number(E||0);return{...w,value:Number.isFinite(U)?U:0}}),O=x.reduce((w,F)=>w+Number(F?.value||0),0),z=_.reduce((w,F)=>w+Number(F?.value||0),0),B=Math.max(0,Number(f)+O-z);return{allowances:x,deductions:_,netAmount:B}},[P,R,I]),C=async f=>{if(f.preventDefault(),!a){v.error("Missing staff id.",{duration:1e3});return}const x=new FormData;x.append("staff_id",String(a)),x.append("type",d),d==="Nonpermanent"?(x.append("salary_type",b??""),x.append("amount",String(p||"")),x.append("Allowances",JSON.stringify([])),x.append("Dedection",JSON.stringify([]))):(x.append("basic_pay",String(I||"")),x.append("declarationPERyear",String(m??"")),x.append("Allowances",JSON.stringify(D.allowances||[])),x.append("Dedection",JSON.stringify(D.deductions||[])),x.append("amount",String(D.netAmount||0)));try{const _=n==="edit",O=_?Ot.editPayroll:Ot.addPayroll,z=_?await _t(O,x,t):await yt(O,x,t);v.success("Success!",{duration:1e3}),o?.({payroll:{staffType:d,salaryType:b,amount:p,basicPay:I,declaration:m},result:z})}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed.",{duration:1e3})}},h=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(f,x)=>`${x?.Amount??""} / ${x?.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(te,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:f=>u(f?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(te,{label:"Type",options:sn,value:sn.find(f=>f.value===b)??sn[0],onChange:f=>g(f?.value??sn[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{type:"number",label:"Amount",value:p,onChange:f=>j(Number(f.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{type:"number",label:"Basic Pay",value:I,onChange:f=>A(Number(f.target.value||0)),required:!0}),e.jsx(Z,{type:"text",label:"IT Declarations/Year",value:m,onChange:f=>c(f.target.value)}),e.jsx(Z,{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,x)=>`${f?.title??"a"}-${x}`,columns:h,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,x)=>`${f?.title??"d"}-${x}`,columns:h,dataSource:D.deductions,pagination:!1})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(Button,{onClick:l,children:"Back"}),e.jsx(pe,{type:"submit",value:"Finish",color:"primary"})]})]})})}const yc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function hc({token:t,mode:n="add",staffId:a,onFinished:s}){const[o,l]=i.useState(0),[d,u]=i.useState(a??null),[b,g]=i.useState(null),[p,j]=i.useState(null),[I,A]=i.useState(null),m=n==="edit"?a??d:null,c=i.useMemo(()=>m?`${Ce.staff.basicById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),y=i.useMemo(()=>m?`${Ce.staff.experienceById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),P=i.useMemo(()=>m?`${Ce.staff.payrollById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),{data:R}=H(t&&c?[c,t]:null,([O,z])=>G(O,z)),{data:D}=H(t&&y?[y,t]:null,([O,z])=>G(O,z)),{data:C}=H(t&&P?[P,t]:null,([O,z])=>G(O,z)),h=i.useMemo(()=>{const O=yc(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]),f=i.useMemo(()=>{const O=D?.data??D??null;return(Array.isArray(O?.experience)?O.experience:Array.isArray(O)?O:[]).map(B=>({name:B?.name??"",from:B?.from??"",to:B?.to??"",image:B?.image??""}))},[D]),x=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]),_=i.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(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:_}),o===0&&e.jsx(uc,{token:t,mode:n,staffId:m,initialValues:h,onSubmitted:({staffId:O})=>{O&&u(O),l(1)}}),o===1&&e.jsx(mc,{token:t,mode:n,staffId:m??d,initialRows:f,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(fc,{token:t,mode:n,staffId:m??d,initialValues:x,onBack:()=>l(1),onSubmitted:()=>{v.success("Completed.",{duration:1e3}),s?.({staffId:m??d})}})]})})]})}function gc({token:t}){return e.jsx(hc,{token:t,mode:"add"})}const xc=({token:t})=>e.jsx(gc,{token:t}),Bn=Ce.staff,bc=Ce.roleDropdown,Sc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},jc=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function wc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(""),[l,d]=i.useState(""),{data:u}=H(t?[bc,t]:null,([P,R])=>G(P,R)),b=i.useMemo(()=>Sc(u),[u]),g=i.useMemo(()=>{const P=n.page,R=n.rowsPerPage,D=s&&!l?`${Bn.searchByRole}?role_id=${encodeURIComponent(String(s))}`:l?`${Bn.searchByKeywords}?key=${encodeURIComponent(String(l))}`:Bn.list,C=D.includes("?")?"&":"?";return`${D}${C}page=${encodeURIComponent(String(P))}&per_page=${encodeURIComponent(String(R))}`},[n.page,n.rowsPerPage,l,s]),{isLoading:p,error:j,data:I,mutate:A}=H(t?[g,t]:null,([P,R])=>G(P,R)),m=i.useMemo(()=>jc(I),[I]),c=async P=>{const R=P?.id??P?.fk_staffID??P?.staff_id;if(R)try{await An(Bn.deactivate,R,t),v.success("Success! Staff deactivated.",{duration:1e3}),await A()}catch(D){v.error(D?.response?.data?.msg??D?.message??"Failed to deactivate staff.",{duration:1e3})}},y=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(P,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:(P,R)=>e.jsx(r.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(se.DeleteOutlined,{}),onClick:()=>c(R),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(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(te,{options:[{value:"",label:"All Roles"},...b],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:P=>{o(P?.value??""),a(R=>({...R,page:1}))}}),e.jsx(Z,{type:"text",label:"Keyword",value:l,onChange:P=>d(P.target.value),placeholder:"Search by keywords"}),e.jsx(pe,{type:"button",value:"Refresh",onClick:()=>A()})]})}),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:p,rowKey:P=>String(P?.id??P?.fk_staffID??P?.staff_id??Math.random()),columns:y,dataSource:m,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(P,R)=>a({page:P,rowsPerPage:R}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const vc=({token:t})=>e.jsx(wc,{token:t}),_c=Ce.attendance,Cc=Ce.roleDropdown,ss=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Nn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},is={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Tc({token:t,open:n,onClose:a,roleId:s,onSaved:o}){const[l,d]=i.useState(null),[u,b]=i.useState(""),[g,p]=i.useState(fe()),[j,I]=i.useState(fe()),[A,m]=i.useState(fe()),c=i.useMemo(()=>s?`${Ce.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(s))}`:null,[s]),{data:y}=H(t&&c?[c,t]:null,([f,x])=>G(f,x)),P=i.useMemo(()=>ss(y),[y]),{trigger:R,data:D}=Ke(t?Ce.attendance.staffShiftByStaffId:null,(f,{arg:x})=>Dt(f,{arg:x},t)),C=i.useMemo(()=>ss(D),[D]),h=async()=>{if(!l?.value){v.error("Select staff.",{duration:1e3});return}if(!u){v.error("Select shift.",{duration:1e3});return}const f=new FormData;f.set("staffID",String(l.value)),f.set("shift_id",String(u)),f.set("attendance_date",g?g.format("YYYY-MM-DD"):""),f.set("intime",j?j.format("h:mm a"):""),f.set("outime",A?A.format("h:mm a"):"");try{await yt(Ce.attendance.manualAttendance,f,t),v.success("Success!",{duration:1e3}),o?.(),a?.(),d(null),b(""),p(fe()),I(fe()),m(fe())}catch(x){v.error(x?.response?.data?.msg??x?.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(te,{label:"Staff",options:P,value:l,onChange:async f=>{if(d(f??null),b(""),f?.value&&R)try{await R({staff_id:f.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:Nn,children:"Shift"}),e.jsx(r.Radio.Group,{value:u,onChange:f=>b(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:Nn,children:"Date"}),e.jsx(r.DatePicker,{value:g,onChange:f=>f&&p(f),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:Nn,children:"Start Time"}),e.jsx(r.TimePicker,{value:j,onChange:f=>f&&I(f),use12Hours:!0,format:"h:mm a",style:is})]}),e.jsxs("div",{children:[e.jsx("div",{style:Nn,children:"End Time"}),e.jsx(r.TimePicker,{value:A,onChange:f=>f&&m(f),use12Hours:!0,format:"h:mm a",style:is})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(r.Button,{onClick:a,children:"Cancel"}),e.jsx(pe,{type:"button",value:"Save",color:"primary",onClick:h})]})]})})})}const Ac=({tableRef:t,excelDisabled:n})=>{const a=new Date().getTime(),s=gn.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(se.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:s})}),e.jsx(r.Col,{children:n?e.jsx(r.Button,{type:"text",icon:e.jsx(se.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>v.error("You must save attendance before download",{duration:2e3})}):e.jsx(ii.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:t?.current,children:e.jsx(r.Button,{type:"text",icon:e.jsx(se.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},Ic=(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:[]:[]},Rc=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},Dc=(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 Oc({token:t,url:n,columns:a,reload:s,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:u,type:b="staff"}){const g=i.useRef(null),[p,j]=i.useState({page:0,rowsPerPage:10}),[I,A]=i.useState(!1),[m,c]=i.useState(!1),[y,P]=i.useState(null),[R,D]=i.useState([]),[C,h]=i.useState({sunday:!1,holiday:!1}),[f,x]=i.useState(!0);i.useEffect(()=>{j(B=>({...B,page:0}))},[n]),i.useEffect(()=>{let B=!0;return(async()=>{if(!(!t||!n)){A(!0);try{const F=String(n).includes("?")?"&":"?",E=`${n}${F}page=${p.page+1}&per_page=${p.rowsPerPage}`,U=await G(E,t);if(!B)return;P(U),U?.Status==="Success"?(d?.(!1),D(Ic(U,b)),h(Dc(U,b))):(d?.(!0),D([]),h({sunday:!1,holiday:!1}))}catch{if(!B)return;d?.(!0),D([])}finally{B&&A(!1)}}})(),()=>{B=!1}},[p.page,p.rowsPerPage,s,d,t,b,n]);const _=i.useMemo(()=>Rc(y),[y]);i.useEffect(()=>{const B=(Array.isArray(R)?R:[]).find(w=>w?.attendence_type_id===null);x(!!B)},[R]);const O=async()=>{if(t){c(!0);try{if(b==="staff"){const B=(Array.isArray(R)?R:[]).map(w=>({staff_id:w?.staff_id,attendence_type_id:w?.attendence_type_id?w.attendence_type_id:"1",in_time:w?.intime,out_time:w?.outtime,date:u}));await yt(Ce.attendance.addAttendanceToStaffByBranch,B,t),v.success("Attendance saved successfully",{duration:2e3}),o?.(w=>!w)}else v.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(B){v.error(B?.response?.data?.msg??B?.message??"Failed required dates",{duration:2e3})}finally{c(!1)}}},z=i.useMemo(()=>(Array.isArray(a)?a:[]).map(w=>w?.selector==="attendence_type_id"?{title:w?.name??"Attendance",dataIndex:w.selector,key:w.selector,render:F=>F==null||F===""?e.jsx(r.Tag,{color:"orange",children:"Not Set"}):String(F)==="1"?e.jsx(r.Tag,{color:"green",children:"Present"}):String(F)==="4"?e.jsx(r.Tag,{color:"red",children:"Absent"}):String(F)==="3"?e.jsx(r.Tag,{color:"orange",children:"Late"}):e.jsx(r.Tag,{children:String(F)})}:w?.selector==="snum"?{title:w?.name??"Sl",key:w.selector,render:(F,E,U)=>U+1}:{title:w?.name??w?.selector,dataIndex:w?.selector,key:w?.selector}),[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(r.Card,{children:[e.jsx(Ac,{tableRef:g,excelDisabled:f}),e.jsx(r.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(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:g,children:e.jsx(r.Table,{bordered:!0,size:"small",rowKey:(B,w)=>String(B?.id??B?.staff_id??w),columns:z,dataSource:R,loading:I,pagination:{current:p.page+1,pageSize:p.rowsPerPage,total:_,showSizeChanger:!0,onChange:(B,w)=>j({page:B-1,rowsPerPage:w})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:O,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const Pc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Ec={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Fc({token:t}){const[n,a]=i.useState(""),[s,o]=i.useState(fe().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[u,b]=i.useState(null),[g,p]=i.useState(!1),[j,I]=i.useState(!0),[A,m]=i.useState(!1),c=i.useRef(null),{data:y}=H(t?[Cc,t]:null,([D,C])=>G(D,C)),P=i.useMemo(()=>Pc(y),[y]),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(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(te,{options:P,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:fe(),onChange:D=>D&&o(D.format("YYYY-MM-DD")),style:Ec,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!s||(b(`${_c.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:g?"primary":"default",onClick:()=>p(D=>!D),children:g?"Marked":"Mark As Holiday"}),e.jsx(r.Button,{size:"small",type:"default",disabled:j,onClick:()=>m(!0),children:"Give Attendance"})]}),u?e.jsx(Oc,{token:t,url:u,columns:R,reload:l,setReload:d,saveBtnRef:c,setSaveBtnDisabled:I,date:s,type:"staff",holidayChecked:g}):null]}),e.jsx(Tc,{token:t,open:A,onClose:()=>m(!1),roleId:n,onSaved:()=>d(D=>!D)})]})}const kc=({token:t})=>e.jsx(Fc,{token:t}),os=Ce.attendanceReport.monthlyStaffReport,Mc=Ce.roleDropdown,$c=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Uc({token:t}){const n=i.useRef(null),[a,s]=i.useState(!1),[o,l]=i.useState([]),[d,u]=i.useState({role:"",rolllabel:"",year:"",month:""}),b=i.useMemo(()=>ni(5),[]),{data:g}=H(t?[Mc,t]:null,([B,w])=>G(B,w)),p=i.useMemo(()=>$c(g),[g]),[j,I]=i.useState([]),[A,m]=i.useState(1),[c,y]=i.useState(!1),[P,R]=i.useState(!1),[D,C]=i.useState(null),h=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:f}=Ke(t&&os?`${os}?page=${A}&per_page=3`:null,(B,{arg:w})=>Dt(B,{arg:w},t),{onSuccess:B=>{y(!1);const w=Array.isArray(B)?B:[];w.length>0&&I(F=>[...F||[],...w]),w.length>1?m(F=>F+1):R(!1)},onError:()=>{y(!1),R(!1)}});i.useEffect(()=>{P&&f&&D&&f(D)},[P,A,D,f]);const x=i.useMemo(()=>{const B=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(w,F)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:F?.full_name??""})}];return Array.isArray(j)&&j.length>0&&((j[0]?.monthly_data??[]).forEach((F,E)=>{B.push({title:E+1,align:"center",key:String(E+1),render:(U,k)=>{const N=k?.monthly_data?.[E]?.[0]?.data?.[0]??{},V=N?.intime??"",q=N?.outtime??"",T=N?.attendance_type??"";return e.jsx(r.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",V]}),e.jsxs("div",{children:["Out Time ",q]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:Ut(T)})})}})}),B.push({title:"Total",key:"Total",render:(F,E)=>{const U=E?.monthly_data??[],k=U.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="A").length,N=U.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",k," P : ",N]})})}})),B},[j]),_=i.useMemo(()=>[{label:"Present",el:Ut("P")},{label:"Absent",el:Ut("A")},{label:"Leave",el:Ut("L")},{label:"Weekly Off",el:Ut("W")},{label:"Holiday",el:Ut("H")}],[]),O=i.useMemo(()=>d.month?o.find(B=>B?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),z=async B=>{if(B.preventDefault(),!d.role||!d.year||!d.month)return;m(1),y(!0),I([]);const w={session:h,year:d.year,month:d.month,day:"01",role:d.role};C(w),R(!0),await f?.(w)};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:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:B=>u(w=>({...w,role:B?.value??"",rolllabel:B?.label??""}))}),e.jsx(te,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:B=>{const w=ai(B?.value);l(w),s(F=>!F),u(F=>({...F,year:B?.label??""}))}}),e.jsx(te,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:B=>u(w=>({...w,month:B?.value??""}))},`month-${a}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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(vn,{})}),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(ma,{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:_.map(B=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[B.label," :"]}),e.jsx("div",{children:B.el})]},B.label))})})]}),e.jsx(r.Skeleton,{active:!0,loading:c,paragraph:{rows:10},children:e.jsx(r.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:x,dataSource:j,pagination:!1,scroll:{x:"max-content"},rowKey:(B,w)=>String(B?.staff_id??B?.id??w)})})]})})]})}const Bc=({token:t})=>e.jsx(Uc,{token:t}),ls=Ce.payroll,Nc=Ce.roleDropdown,qc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Lc=t=>t?.data?.data??t?.data??t??[];function zc({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:a}){const[s,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[u,b]=i.useState([]),[g,p]=i.useState({role:"",roleLabel:"",year:"",month:""}),[j,I]=i.useState(null),A=x=>{if(!x)return;if(typeof a=="function"){a(x);return}const _=`${n}?id=${encodeURIComponent(String(x))}`;typeof window<"u"&&window?.location&&(window.location.href=_)},{data:m}=H(t?[Nc,t]:null,([x,_])=>G(x,_)),c=i.useMemo(()=>qc(m),[m]),y=i.useMemo(()=>ni(5),[]),{isLoading:P,error:R,data:D}=H(t&&j?[j,t]:null,([x,_])=>G(x,_)),C=i.useMemo(()=>{const x=Lc(D);return Array.isArray(x)?x:[]},[D]),h=i.useMemo(()=>{const x=D?.pagination?.total_rows??D?.data?.pagination?.total_rows??D?.total??D?.total_rows,_=Number(x);return Number.isFinite(_)&&_>=0?_:C.length},[D,C.length]),f=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(x,_,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:(x,_)=>{const O=_?.id??_?.staff_id??_?.staffId;return e.jsx(r.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{A(O)},children:ri(_?.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:x=>{if(x.preventDefault(),!g.role||!g.year||!g.month)return;const _=`${ls.payrollByRole}?page=${encodeURIComponent(String(s.page))}&per_page=${encodeURIComponent(String(s.rowsPerPage))}&role=${encodeURIComponent(String(g.role))}&year=${encodeURIComponent(String(g.year))}&month=${encodeURIComponent(String(g.month))}`;I(_)},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(te,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:x=>p(_=>({..._,role:x?.value??"",roleLabel:x?.label??""}))}),e.jsx(te,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:x=>{const _=ai(x?.value);b(_),d(O=>!O),p(O=>({...O,year:x?.label??"",month:""}))}}),e.jsx(te,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:x=>p(_=>({..._,month:x?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Search",color:"primary",onClick:()=>o(x=>({...x,page:1}))})})]})}),e.jsx(r.Table,{bordered:!0,size:"small",loading:P,rowKey:(x,_)=>String(x?.id??x?.staff_id??_),columns:f,dataSource:C,pagination:{current:s.page,pageSize:s.rowsPerPage,total:h,showSizeChanger:!0,onChange:(x,_)=>{o({page:x,rowsPerPage:_}),!(!g.role||!g.year||!g.month)&&I(`${ls.payrollByRole}?page=${encodeURIComponent(String(x))}&per_page=${encodeURIComponent(String(_))}&role=${encodeURIComponent(String(g.role))}&year=${encodeURIComponent(String(g.year))}&month=${encodeURIComponent(String(g.month))}`)}},scroll:{x:"max-content"}})]})})}const Vc=({token:t})=>e.jsx(zc,{token:t}),pi=Ce.leave,Jt=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>H(s&&t?[t,n,a,s]:null,([l,d,u,b])=>sc({baseUrl:l,page:d,perPage:u},b)),Yc=({token:t,page:n=1,perPage:a=10})=>Jt({token:t,baseUrl:pi.requestTable,page:n,perPage:a}),Wc=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Hc=(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 Kc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),{isLoading:s,error:o,data:l,mutate:d}=Yc({token:t,page:n.page,perPage:n.rowsPerPage}),u=i.useMemo(()=>Wc(l),[l]),b=async(p,j)=>{try{const I=Hc(p,j),A=await _t(pi.approveRequest,I,t);A?.Status==="Success"?v.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):v.error(A?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(I){v.error(I?.response?.data?.msg??I?.message??"Failed to update request.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(p,j)=>j?.full_name??j?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(p,j)=>j?.leave_from??j?.from_date??""},{title:"To",key:"leave_to",width:120,render:(p,j)=>j?.leave_to??j?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(p,j)=>j?.leavetype??j?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(p,j)=>j?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(p,j)=>j?.employee_remark??j?.reason??""},{title:"View",key:"document_file",width:140,render:(p,j)=>{const I=j?.document_file;return I?e.jsx(r.Button,{size:"small",onClick:()=>window.open(I,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(p,j)=>{const I=String(j?.status??"").toLowerCase();return I==="approved"?e.jsx(r.Tag,{color:"green",children:"Approved"}):I==="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:()=>b(j,"approved"),icon:e.jsx(se.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(r.Button,{type:"text",size:"small",onClick:()=>b(j,"declined"),icon:e.jsx(se.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(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:(p,j)=>String(p?.id??p?.leave_id??j),columns:g,dataSource:u,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(p,j)=>a({page:p,rowsPerPage:j}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Gc=({token:t})=>e.jsx(Kc,{token:t}),Jc=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Qc=({token:t,value:n,onChange:a})=>{const s=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(r.Upload,{maxCount:1,action:ui(),headers:s,onChange:o=>{if(o?.file?.status==="done"){const l=Jc(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},mi=Ce.leave,Xc=Ce.master.leaveType.dropdown,Zc=({token:t,page:n=1,perPage:a=10})=>Jt({token:t,baseUrl:mi.table,page:n,perPage:a}),eu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Ma={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function tu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(""),[u]=r.Form.useForm(),{isLoading:b,error:g,data:p,mutate:j}=Zc({token:t,page:n.page,perPage:n.rowsPerPage}),{data:I}=H(t?[Xc,t]:null,([C,h])=>G(C,h)),A=i.useMemo(()=>eu(I),[I]),m=(C,h)=>a({page:C,rowsPerPage:parseInt(h,10)}),c=()=>{d(""),u.resetFields(),u.setFieldsValue({apply_date:fe()}),o(!0)},y=()=>{o(!1),d(""),u.resetFields()},P=async C=>{const h=new FormData;h.set("apply_date",C?.apply_date?C.apply_date.format("YYYY-MM-DD"):""),h.set("leave_type",C?.leave_type?.value??C?.leave_type??""),h.set("from_date",C?.from_date?C.from_date.format("YYYY-MM-DD"):""),h.set("to_date",C?.to_date?C.to_date.format("YYYY-MM-DD"):""),h.set("reason",C?.reason??""),l&&h.set("file",l);try{await yt(mi.apply,h,t),v.success("Success! Leave request submitted.",{duration:1e3}),y(),await j()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to submit leave request.",{duration:1e3})}},R=i.useMemo(()=>{const C=p?.data??p??[];return Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[]},[p]),D=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(C,h)=>h?.leavetype??h?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(C,h)=>h?.date??h?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(C,h)=>h?.leave_from??h?.from_date??""},{title:"To",key:"leave_to",width:130,render:(C,h)=>h?.leave_to??h?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(C,h)=>h?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:s,title:"Add Leave Request",onCancel:y,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:u,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(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:Ma})]})}),e.jsx(r.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(te,{options:A,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:Ma})]})}),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:Ma})]})}),e.jsx(r.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(Z,{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(Qc,{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:y,children:"Cancel"}),e.jsx(pe,{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(pe,{type:"button",value:"Add Leave Request",onClick:c})}),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:b,rowKey:(C,h)=>String(C?.id??C?.leave_id??h),columns:D,dataSource:R,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(C,h)=>m(C,h),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const nu=({token:t})=>e.jsx(tu,{token:t}),Zn=Ce.master.leaveType,au=({token:t,page:n=1,perPage:a=10})=>Jt({token:t,baseUrl:Zn.table,page:n,perPage:a});function ru({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[u,b]=i.useState(null),{isLoading:g,error:p,data:j,mutate:I}=au({token:t,page:n.page,perPage:n.rowsPerPage}),A=(C,h)=>{a({page:C,rowsPerPage:parseInt(h,10)})},m=async C=>{const h=new FormData;h.set("title",C?.title??"");try{await I(yt(Zn.add,h,t),et(h)),v.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add leave type.",{duration:1e3})}},c=C=>{b(C??null),o.setFieldsValue({title:C?.leave_type_name??C?.name??""}),d(!0)},y=()=>{d(!1),b(null),o.resetFields()},P=async C=>{const h=u?.id??u?.leave_type_id;if(!h){v.error("Missing leave type id.",{duration:1e3});return}const f=new FormData;f.set("id",String(h)),f.set("title",C?.title??"");try{await _t(Zn.edit,f,t),await I(),v.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),y()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to update leave type.",{duration:1e3})}},R=async C=>{const h=C?.id??C?.leave_type_id;if(h)try{await I(An(Zn.remove,h,t),Ge(h)),v.success("Success! Deleted leave type.",{duration:1e3})}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete leave type.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,h)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>c(h)}),e.jsx(r.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>R(h),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(se.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Leave Type",onCancel:y,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:P,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Z,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:y,children:"Cancel"}),e.jsx(pe,{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:m,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Z,{type:"text",label:"Name"})}),e.jsx(pe,{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(Ue,{parentCallback:A,data:{newData:j,columns:D,columnstype:"antd",action:!1,Loading:g,error:p}})})]})}const su=({token:t})=>e.jsx(ru,{token:t}),ea=Ce.master.department,iu=({token:t,page:n=1,perPage:a=10})=>Jt({token:t,baseUrl:ea.table,page:n,perPage:a});function ou({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[u,b]=i.useState(null),{isLoading:g,error:p,data:j,mutate:I}=iu({token:t,page:n.page,perPage:n.rowsPerPage}),A=(C,h)=>{a({page:C,rowsPerPage:parseInt(h,10)})},m=async C=>{const h=new FormData;h.set("title",C?.title??"");try{await I(yt(ea.add,h,t),et(h)),v.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add department.",{duration:1e3})}},c=C=>{b(C??null),o.setFieldsValue({title:C?.department_name??C?.name??""}),d(!0)},y=()=>{d(!1),b(null),o.resetFields()},P=async C=>{const h=u?.id??u?.department_id;if(!h){v.error("Missing department id.",{duration:1e3});return}const f=new FormData;f.set("id",String(h)),f.set("title",C?.title??"");try{await _t(ea.edit,f,t),await I(),v.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),y()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to update department.",{duration:1e3})}},R=async C=>{const h=C?.id??C?.department_id;if(h)try{await I(An(ea.remove,h,t),Ge(h)),v.success("Success! Deleted department.",{duration:1e3})}catch(f){v.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,h)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>c(h)}),e.jsx(r.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>R(h),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(se.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Department",onCancel:y,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:P,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Z,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:y,children:"Cancel"}),e.jsx(pe,{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:m,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Z,{type:"text",label:"Name"})}),e.jsx(pe,{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(Ue,{parentCallback:A,data:{newData:j,columns:D,columnstype:"antd",action:!1,Loading:g,error:p}})})]})}const lu=({token:t})=>e.jsx(ou,{token:t}),ta=Ce.master.designation,du=({token:t,page:n=1,perPage:a=10})=>Jt({token:t,baseUrl:ta.table,page:n,perPage:a});function cu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[u,b]=i.useState(null),{isLoading:g,error:p,data:j,mutate:I}=du({token:t,page:n.page,perPage:n.rowsPerPage}),A=(C,h)=>{a({page:C,rowsPerPage:parseInt(h,10)})},m=async C=>{const h=new FormData;h.set("title",C?.title??"");try{await I(yt(ta.add,h,t),et(h)),v.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add designation.",{duration:1e3})}},c=C=>{b(C??null),o.setFieldsValue({title:C?.designation??""}),d(!0)},y=()=>{d(!1),b(null),o.resetFields()},P=async C=>{const h=u?.id??u?.designation_id;if(!h){v.error("Missing designation id.",{duration:1e3});return}const f=new FormData;f.set("id",String(h)),f.set("title",C?.title??"");try{await _t(ta.edit,f,t),await I(),v.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),y()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to update designation.",{duration:1e3})}},R=async C=>{const h=C?.id??C?.designation_id;if(h)try{await I(An(ta.remove,h,t),Ge(h)),v.success("Success! Deleted designation.",{duration:1e3})}catch(f){v.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,h)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>c(h)}),e.jsx(r.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>R(h),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(se.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Designation",onCancel:y,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:P,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Z,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:y,children:"Cancel"}),e.jsx(pe,{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:m,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Z,{type:"text",label:"Name"})}),e.jsx(pe,{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(Ue,{parentCallback:A,data:{newData:j,columns:D,columnstype:"antd",action:!1,Loading:g,error:p}})})]})}const uu=({token:t})=>e.jsx(cu,{token:t}),na=Ce.master.shift,pu=({token:t,page:n=1,perPage:a=10})=>Jt({token:t,baseUrl:na.table,page:n,perPage:a}),Qe="hh:mm A",Lt=t=>{const n=String(t??"");if(!n)return null;const a=fe(n,[Qe,"HH:mm","HH:mm:ss"],!0);return a.isValid()?a:null},zt=t=>t?t.format(Qe):"",it={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function mu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[u,b]=i.useState(null),{isLoading:g,error:p,data:j,mutate:I}=pu({token:t,page:n.page,perPage:n.rowsPerPage}),A=(f,x)=>{a({page:f,rowsPerPage:parseInt(x,10)})},m=(f,x)=>{const _=new FormData;return x&&_.set("id",String(x)),_.set("name",f?.name??""),_.set("start_time",zt(f?.start_time)),_.set("end_time",zt(f?.end_time)),_.set("shift_start_from",zt(f?.shift_start_from)),_.set("shift_start_to",zt(f?.shift_start_to)),_.set("shift_end_from",zt(f?.shift_end_from)),_.set("shift_end_to",zt(f?.shift_end_to)),_},c=async f=>{try{const x=m(f);await I(yt(na.add,x,t),et(x)),v.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to add shift.",{duration:1e3})}},y=f=>{b(f??null),o.setFieldsValue({name:f?.shift_name??f?.name??"",start_time:Lt(f?.start_time),end_time:Lt(f?.end_time),shift_start_from:Lt(f?.shift_start_from),shift_start_to:Lt(f?.shift_start_to),shift_end_from:Lt(f?.shift_end_from),shift_end_to:Lt(f?.shift_end_to)}),d(!0)},P=()=>{d(!1),b(null),o.resetFields()},R=async f=>{const x=u?.id??u?.shift_id;if(!x){v.error("Missing shift id.",{duration:1e3});return}try{const _=m(f,x);await _t(na.edit,_,t),await I(),v.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),P()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to update shift.",{duration:1e3})}},D=async f=>{const x=f?.id??f?.shift_id;if(x)try{await I(An(na.remove,x,t),Ge(x)),v.success("Success! Deleted shift.",{duration:1e3})}catch(_){v.error(_?.response?.data?.msg??_?.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,x)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(se.EditOutlined,{}),onClick:()=>y(x)}),e.jsx(r.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>D(x),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(se.DeleteOutlined,{})})})]})}],[]),h=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Shift",onCancel:P,footer:null,destroyOnClose:!0,children:e.jsxs(r.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(r.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Z,{type:"text",label:"Name"})}),e.jsx(r.Form.Item,{name:"start_time",label:"Start Time",rules:h,children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"end_time",label:"End Time",rules:h,children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:P,children:"Cancel"}),e.jsx(pe,{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: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",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Z,{type:"text",label:"Name"})}),e.jsx(r.Form.Item,{name:"start_time",label:"Start Time",rules:h,children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"end_time",label:"End Time",rules:h,children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(r.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(r.TimePicker,{format:Qe,use12Hours:!0,style:it})}),e.jsx(pe,{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(Ue,{parentCallback:A,data:{newData:j,columns:C,columnstype:"antd",action:!1,Loading:g,error:p}})})]})}const fu=({token:t})=>e.jsx(mu,{token:t}),ds=Ce.attendance;function yu({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 hu=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},gu=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 xu({token:t}){const[n,a]=i.useState(fe()),[s,o]=i.useState(!1),[l,d]=i.useState(0),u=i.useMemo(()=>`${s?ds.dailyAttendanceMultipleShift:ds.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,s,l]),{isLoading:b,error:g,data:p}=H(t?[u,t]:null,([c,y])=>G(c,y)),j=i.useMemo(()=>hu(p),[p]),I=i.useMemo(()=>s?p?.data?.data??p?.data??p??null:null,[p,s]),A=gn.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),m=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(c,y,P)=>P+1},{title:"Name",key:"name",render:(c,y)=>`${y?.name??""} ${y?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(c,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[gu(y?.attendance),y?.late_time?e.jsx(r.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(c,y)=>y?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(c,y)=>y?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(c,y)=>y?.late_time?e.jsx(r.Tag,{color:"red",children:y.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:c=>c&&a(c),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(pe,{type:"button",value:"Search",onClick:()=>d(c=>c+1)})})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(se.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:A}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(vn,{})}),s?e.jsx(yu,{data:I}):e.jsx(r.Table,{bordered:!0,size:"small",loading:b,rowKey:(c,y)=>String(c?.id??c?.staff_id??y),columns:m,dataSource:j,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const bu=({token:t})=>e.jsx(xu,{token:t}),cs=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},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:"":"";function ju({token:t,staffId:n}){const[a,s]=i.useState(!1),[o,l]=i.useState(null),[d,u]=i.useState({value:"Cash",label:"Cash"}),[b,g]=i.useState(""),[p,j]=i.useState(""),I=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),A=O=>{const z=Number(O??0),B=Number.isFinite(z)?z.toLocaleString("en-IN"):"0";return`${I?`${I} `:""}${B}`},m=i.useMemo(()=>n?`${Ce.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),c=i.useMemo(()=>n?`${Ce.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:y}=H(t&&m?[m,t]:null,([O,z])=>G(O,z)),{data:P,isLoading:R,mutate:D}=H(t&&c?[c,t]:null,([O,z])=>G(O,z)),C=i.useMemo(()=>cs(y)[0]??y?.data??y??null,[y]),h=i.useMemo(()=>cs(P),[P]),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:(O,z)=>e.jsx("div",{style:{fontSize:11},children:mt(z?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(O,z)=>e.jsx("div",{style:{fontSize:11},children:mt(z?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(O,z)=>e.jsx("div",{style:{fontSize:11},children:mt(z?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(O,z)=>e.jsx("div",{style:{fontSize:11},children:mt(z?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(O,z)=>e.jsx("div",{style:{cursor:z?.status==="due"?"pointer":"default"},onClick:()=>{z?.status==="due"&&(l(z),s(!0))},children:ri(z?.status)})}],[]),x=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"}],[]),_=async()=>{if(!o)return;const O={...o,staff_id:n,payment_type:d?.value??"",notes:b,attchement:p};try{await We(Ce.payroll.generatePayslip,{arg:O},t),v.success("Success!",{duration:1e3}),s(!1),l(null),g(""),j(""),await D()}catch(z){v.error(z?.response?.data?.msg??z?.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:R,rowKey:(O,z)=>String(O?.id??`${O?.month}-${z}`),columns:f,dataSource:h,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(te,{label:"Pay",options:x,value:d,onChange:O=>u(O??x[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:b,onChange:O=>g(O.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:ui(),headers:t?{Authorization:t}:void 0,onChange:O=>{if(O?.file?.status==="done"){const z=Su(O?.file?.response);z&&j(z)}O?.file?.status==="removed"&&j("")},children:e.jsx(r.Button,{icon:e.jsx(se.UploadOutlined,{}),children:"Upload"})}),!!p&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:p})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(r.Button,{onClick:()=>s(!1),children:"Cancel"}),e.jsx(pe,{type:"button",value:o?.Total_Payable_Amount?`Pay ${A(o.Total_Payable_Amount)}`:"Pay",onClick:_})]})]})})]})}function wu({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(ju,{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 vu(){return null}const ha=t=>t??localStorage.getItem("authToken")??"",_u=(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},fi=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",_e={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"}},Cu=()=>_u(ot(),_e.uploadNotes),Tu=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 G(l,ha(s))},dt=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",fi()),We(t,o,ha(a))},wt=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",fi()),ut(t,o,ha(a))},vt=async(t,n,a)=>nt(t,n,ha(a)),aa=_e.master.sections,In=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>H(s&&t?[t,n,a,s]:null,([l,d,u,b])=>Tu({baseUrl:l,page:d,perPage:u},b)),Au=({token:t,page:n=1,perPage:a=10})=>In({token:t,baseUrl:aa.table,page:n,perPage:a}),Iu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Ru({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),{data:b,isLoading:g,mutate:p}=Au({token:t,page:n.page,perPage:n.perPage}),j=i.useMemo(()=>Iu(b),[b]),I=i.useMemo(()=>b?.pagination?.total_rows??b?.pagination?.total??j.length??0,[b,j]),A=async R=>{R.preventDefault();const D=new FormData(R.target);try{await dt(aa.add,D,t),v.success("Success! Added new item.",{duration:1e3}),R.target.reset(),p()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},m=async R=>{try{await vt(aa.remove,R,t),v.success("Success! Deleted item.",{duration:1e3}),p()}catch(D){v.error(D?.response?.data?.msg??D?.message??"Failed to delete the item.",{duration:1500})}},c=R=>{d(R),o(!0),u.setFieldsValue({section:R?.section??""})},y=async R=>{const D=new FormData;D.append("id",String(l?.id??"")),D.append("section",R.section??"");try{await wt(aa.edit,D,t),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to update the item.",{duration:1500})}},P=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(R,D)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(se.EditOutlined,{}),onClick:()=>c(D)}),e.jsx(r.Popconfirm,{title:"Delete this section?",onConfirm:()=>m(D?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(se.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.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:u,layout:"vertical",onFinish:y,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(pe,{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:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(pe,{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:R=>R.id,columns:P,dataSource:j,loading:g,pagination:{current:n.page,pageSize:n.perPage,total:I,showSizeChanger:!0,onChange:(R,D)=>a({page:R,perPage:D})}})})]})}function Du({token:t}){return e.jsx(Ru,{token:t})}const pn=_e.master.classes,Ou=({token:t,page:n=1,perPage:a=10})=>In({token:t,baseUrl:pn.table,page:n,perPage:a}),Pu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Eu=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function Fu({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),[b]=r.Form.useForm(),{data:g}=H(t?[_e.master.sections.list,t]:null,([_,O])=>G(_,O)),p=i.useMemo(()=>Eu(g),[g]),j=i.useMemo(()=>p.map(_=>({label:_.label??_.section??String(_.value??""),value:String(_.value??_.id??"")})),[p]),{data:I,isLoading:A,mutate:m}=Ou({token:t,page:n.page,perPage:n.perPage}),c=i.useMemo(()=>Pu(I),[I]),y=i.useMemo(()=>I?.pagination?.total_rows??I?.pagination?.total??c.length??0,[I,c]),{data:P}=H(t&&l?[`${pn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([_,O])=>G(_,O)),R=i.useMemo(()=>{const _=P?.data??P;return Array.isArray(_)?_:Array.isArray(_?.data)?_.data:_?[_]:[]},[P]),D=_=>{const O=_?.id??_?.class_id;O&&(d(O),o(!0))};i.useEffect(()=>{if(!s||!R.length)return;const _=R[0],O=R.map(w=>w?.section_id??w?.fk_sectionId??w?.sectionId??w?.section).filter(w=>w!=null&&String(w).trim()!=="").map(w=>String(w)),z=Array.isArray(_?.section_ids)?_.section_ids.map(w=>String(w)):typeof _?.section_ids=="string"?_.section_ids.split(",").map(w=>w.trim()).filter(Boolean):Array.isArray(_?.section)?_.section.map(w=>String(w)):[],B=O.length?O:z;b.setFieldsValue({name:_?.class??_?.name??"",section:B})},[s,R,b]);const C=async _=>{const O=new FormData;O.append("name",_.name??""),(_.section??[]).forEach(z=>O.append("section[]",String(z)));try{await dt(pn.add,O,t),v.success("Success! Added new item.",{duration:1e3}),u.resetFields(),m()}catch(z){v.error(z?.response?.data?.msg??z?.message??"Failed to add the new item.",{duration:1500})}},h=async _=>{const O=new FormData;O.append("id",String(l??"")),O.append("name",_.name??""),(_.section??[]).forEach(z=>O.append("section[]",String(z)));try{await wt(pn.edit,O,t),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),m()}catch(z){v.error(z?.response?.data?.msg??z?.message??"Failed to update the item.",{duration:1500})}},f=async _=>{try{await vt(pn.remove,_,t),v.success("Success! Deleted item.",{duration:1e3}),m()}catch(O){v.error(O?.response?.data?.msg??O?.message??"Failed to delete the item.",{duration:1500})}},x=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(_,O)=>_??O?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:_=>_??""},{title:"Actions",key:"actions",width:120,render:(_,O)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(se.EditOutlined,{}),onClick:()=>D(O)}),e.jsx(r.Popconfirm,{title:"Delete this class?",onConfirm:()=>f(O?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(se.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.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:b,layout:"vertical",onFinish:h,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:j})}),e.jsxs(r.Space,{children:[e.jsx(pe,{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:u,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:j})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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:_=>_.id,columns:x,dataSource:c,loading:A,pagination:{current:n.page,pageSize:n.perPage,total:y,showSizeChanger:!0,onChange:(_,O)=>a({page:_,perPage:O})}})})]})}function ku({token:t}){return e.jsx(Fu,{token:t})}function Et({onAdd:t,onExport:n,onPrint:a,onDownload:s,onFilter:o,actions:l}){const d=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(se.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(se.FileExcelOutlined,{}),onClick:n},{key:"print",title:"Print",icon:e.jsx(se.PrinterOutlined,{}),onClick:a},{key:"download",title:"Download",icon:e.jsx(se.DownloadOutlined,{}),onClick:s},{key:"filter",title:"Filter",icon:e.jsx(se.FilterOutlined,{}),onClick:o}],[t,n,a,s,o]),u=i.useMemo(()=>{const b=Array.isArray(l)&&l.length?new Set(l):null;return b?d.filter(g=>b.has(g.key)):d},[d,l]);return e.jsx(r.Space,{size:8,children:u.map(b=>e.jsx(r.Tooltip,{title:b.title,children:e.jsx(r.Button,{type:"text",icon:b.icon,onClick:b.onClick,disabled:!b.onClick})},b.key))})}const mn=_e.master.subjects,Mu=({token:t,page:n=1,perPage:a=10})=>In({token:t,baseUrl:mn.table,page:n,perPage:a}),$u=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},us=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],ps=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function Uu({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),[b]=r.Form.useForm(),{data:g,isLoading:p,mutate:j}=Mu({token:t,page:n.page,perPage:n.perPage}),I=i.useMemo(()=>$u(g),[g]),A=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??I.length??0,[g,I]),{data:m}=H(t&&l?[`${mn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([h,f])=>G(h,f)),c=i.useMemo(()=>{const h=m?.data??m;return Array.isArray(h)?h[0]:h??null},[m]);i.useEffect(()=>{s&&c&&b.setFieldsValue({name:c?.name??"",subject_type:c?.subject_type??c?.type??"",type:"",subject_types:Array.isArray(c?.subject_types)?c.subject_types:typeof c?.subject_types=="string"?c.subject_types.split(",").map(h=>h.trim()).filter(Boolean):[],code:c?.code??""})},[s,c,b]);const y=async h=>{const f=h?.type??h?.subject_type??"",x={name:h?.name??"",subject_type:f,type:f,subject_types:Array.isArray(h?.subject_types)?h.subject_types:[],code:h?.code??""};try{await We(mn.add,x,t),v.success("Success! Added new item.",{duration:1e3}),u.resetFields(),j()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to add the new item.",{duration:1500})}},P=async h=>{const f=new FormData,x=h?.type??h?.subject_type??"";f.append("id",String(l??"")),f.append("name",h.name??""),f.append("subject_type",h.subject_type??""),f.append("subject_type",x),f.append("type",x),f.append("code",h.code??"");try{await wt(mn.edit,f,t),v.success("Success! Updated item.",{duration:1e3}),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),j()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to update the item.",{duration:1500})}},R=async h=>{try{await vt(mn.remove,h,t),v.success("Success! Deleted item.",{duration:1e3}),j()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},D=h=>{const f=h?.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:(h,f)=>{const x=[],_=f?.subject_types;Array.isArray(_)?_.forEach(F=>{const E=String(F??"").trim();E&&x.push(E)}):typeof _=="string"&&_.split(",").map(F=>F.trim()).filter(Boolean).forEach(F=>x.push(F));const O=["yes","1","true"].includes(String(f?.is_practical??"").toLowerCase()),z=["yes","1","true"].includes(String(f?.is_theory??"").toLowerCase());O&&x.push("Practical"),z&&x.push("Theory");const B=x.map(F=>String(F??"").trim()).filter(Boolean).map(F=>F.toLowerCase()==="practical"?"Practical":F.toLowerCase()==="theory"?"Theory":F),w=Array.from(new Set(B));return w.length?w.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(h,f)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(se.EditOutlined,{}),onClick:()=>D(f)}),e.jsx(r.Popconfirm,{title:"Delete this subject?",onConfirm:()=>R(f?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(se.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.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:b,layout:"vertical",onFinish:P,children:[e.jsx(r.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Z,{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:ps})}),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:us})}),e.jsx(r.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(Z,{placeholder:"Subject Code"})}),e.jsxs(r.Space,{children:[e.jsx(pe,{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:u,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",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Z,{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:ps})}),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:us})}),e.jsx(r.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(Z,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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:h=>h.id,columns:C,dataSource:I,loading:p,pagination:{current:n.page,pageSize:n.perPage,total:A,showSizeChanger:!0,onChange:(h,f)=>a({page:h,perPage:f})}})})]})}function Bu({token:t}){return e.jsx(Uu,{token:t})}const fn=_e.master.holidays,Nu=({token:t,page:n=1,perPage:a=10})=>In({token:t,baseUrl:fn.table,page:n,perPage:a}),qu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},qn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Lu({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),[b]=r.Form.useForm(),{data:g,isLoading:p,mutate:j}=Nu({token:t,page:n.page,perPage:n.perPage}),I=i.useMemo(()=>qu(g),[g]),A=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??I.length??0,[g,I]),{data:m}=H(t&&l?[`${fn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([h,f])=>G(h,f)),c=i.useMemo(()=>{const h=m?.data??m;return Array.isArray(h)?h[0]:h??null},[m]);i.useEffect(()=>{s&&c&&b.setFieldsValue({title:c?.holiday_title??"",description:c?.holiday_description??"",from:c?.start_date?fe(c.start_date):null,to:c?.end_date?fe(c.end_date):null})},[s,c,b]);const y=async h=>{const f=new FormData;f.append("title",h.title??""),f.append("description",h.description??""),f.append("from",h.from?fe(h.from).format("YYYY-MM-DD"):""),f.append("to",h.to?fe(h.to).format("YYYY-MM-DD"):"");try{await dt(fn.add,f,t,{includeSession:!0}),v.success("Success! Added new item.",{duration:1e3}),u.resetFields(),j()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to add the new item.",{duration:1500})}},P=async h=>{const f=new FormData;f.append("id",String(l??"")),f.append("title",h.title??""),f.append("description",h.description??""),f.append("from",h.from?fe(h.from).format("YYYY-MM-DD"):""),f.append("to",h.to?fe(h.to).format("YYYY-MM-DD"):"");try{await wt(fn.edit,f,t,{includeSession:!0}),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),j()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to update the item.",{duration:1500})}},R=async h=>{try{await vt(fn.remove,h,t),v.success("Success! Deleted item.",{duration:1e3}),j()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},D=h=>{const f=h?.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:(h,f)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(se.EditOutlined,{}),onClick:()=>D(f)}),e.jsx(r.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>R(f?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(se.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.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:b,layout:"vertical",onFinish:P,children:[e.jsx(r.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Z,{placeholder:"Holiday Title"})}),e.jsx(r.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(Z,{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:qn})}),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:qn})}),e.jsxs(r.Space,{children:[e.jsx(pe,{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:u,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:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Z,{placeholder:"Holiday Title"})}),e.jsx(r.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(hn,{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:qn})}),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:qn})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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:h=>h.id,columns:C,dataSource:I,loading:p,pagination:{current:n.page,pageSize:n.perPage,total:A,showSizeChanger:!0,onChange:(h,f)=>a({page:h,perPage:f})}})})]})}function zu({token:t}){return e.jsx(Lu,{token:t})}const ra=_e.assignSubjects,Vu=({token:t,page:n=1,perPage:a=50})=>In({token:t,baseUrl:ra.list,page:n,perPage:a}),ms=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Yu=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,a]=i.useState({page:1,perPage:50}),[s,o]=i.useState(null),[l,d]=i.useState([]),[u,b]=i.useState(!1),[g,p]=i.useState(!1),[j,I]=i.useState(null),[A,m]=i.useState([]),{data:c}=H(t?[_e.master.classes.dropdown,t]:null,([E,U])=>G(E,U)),{data:y}=H(t?[_e.master.subjects.dropdown,t]:null,([E,U])=>G(E,U)),P=i.useMemo(()=>ms(c),[c]),R=i.useMemo(()=>ms(y),[y]),D=i.useMemo(()=>R.map(E=>({label:E.label??E.subject??String(E.value??""),value:E.value??E.id})),[R]),{data:C,isLoading:h,mutate:f}=Vu({token:t,page:n.page,perPage:n.perPage}),x=i.useMemo(()=>Yu(C),[C]),_=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??x.length??0,[C,x]),{data:O}=H(t&&j?[`${ra.editByClass}?class_id=${encodeURIComponent(String(j))}`,t]:null,([E,U])=>G(E,U));i.useEffect(()=>{if(!g)return;const E=O?.data??O,U=Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[];m(U.map(k=>k.subject_id).filter(Boolean))},[g,O]);const z=async E=>{if(E.preventDefault(),!s?.value){v.error("Please select class",{duration:1200});return}if(!l.length){v.error("Please select subjects",{duration:1200});return}const U=new FormData;U.append("class_id",String(s.value)),l.forEach(k=>U.append("subject[]",String(k)));try{b(!0),await wt(ra.assign,U,t),v.success("Success! Updated item.",{duration:1e3}),o(null),d([]),f()}catch(k){v.error(k?.response?.data?.msg??k?.message??"Failed to update the item.",{duration:1500})}finally{b(!1)}},B=E=>{E&&(I(E),p(!0))},w=async()=>{if(!j)return;if(!A.length){v.error("Please select subjects",{duration:1200});return}const E=new FormData;E.append("class_id",String(j)),A.forEach(U=>E.append("subject[]",String(U)));try{await wt(ra.update,E,t),v.success("Success! Updated item.",{duration:1e3}),p(!1),I(null),f()}catch(U){v.error(U?.response?.data?.msg??U?.message??"Failed to update the item.",{duration:1500})}},F=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(E,U)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(U?.subject_name??E??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(E,U)=>e.jsx(r.Button,{type:"text",icon:e.jsx(se.EditOutlined,{}),onClick:()=>B(U?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Assigned Subjects",open:g,onClose:()=>{p(!1),I(null)},width:520,extra:e.jsxs(r.Space,{children:[e.jsx(r.Button,{onClick:()=>p(!1),children:"Cancel"}),e.jsx(r.Button,{type:"primary",onClick:w,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:P.find(E=>String(E.value)===String(j))??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:A,onChange:m})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:s,onChange:E=>o(E??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(pe,{type:"submit",value:u?"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:E=>E.id,columns:F,dataSource:x,loading:h,pagination:{current:n.page,pageSize:n.perPage,total:_,showSizeChanger:!0,onChange:(E,U)=>a({page:E,perPage:U})}})})]})}function Hu({token:t}){return e.jsx(Wu,{token:t})}const Vt=_e.assignByClass,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(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[]},on=t=>yi(t),Ku=t=>yi(t),ln=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Gu({token:t}){const[n,a]=i.useState(null),[s,o]=i.useState(null),[l,d]=i.useState(null),[u,b]=i.useState("No"),[g,p]=i.useState([]),[j,I]=i.useState([]),[A,m]=i.useState(null),[c,y]=i.useState(null),[P,R]=i.useState(!1),[D,C]=i.useState(""),{data:h}=H(t?[Vt.teacherDropdown,t]:null,([re,X])=>G(re,X)),{data:f}=H(t?[_e.master.classes.dropdown,t]:null,([re,X])=>G(re,X)),{data:x}=H(t&&c?[c,t]:null,([re,X])=>G(re,X)),{data:_}=H(t&&A?[A,t]:null,([re,X])=>G(re,X)),O=i.useMemo(()=>on(h),[h]),z=i.useMemo(()=>on(f),[f]),B=i.useMemo(()=>on(x),[x]),w=i.useMemo(()=>on(_),[_]),{data:F}=H(t&&n&&s&&l?[`${Vt.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(n))}&class_id=${encodeURIComponent(String(s))}§ion_id=${encodeURIComponent(String(l))}`,t]:null,([re,X])=>G(re,X)),E=F?.data??F??null;i.useEffect(()=>{E&&(p(Array.isArray(E?.subject_ids)?E.subject_ids:[]),b(E?.isClassTeacher||"No"),I([]))},[E]);const{data:U}=H(t?[Vt.classWithSection,t]:null,([re,X])=>G(re,X)),k=i.useMemo(()=>on(U),[U]),[N,V]=i.useState(null),[q,T]=i.useState({page:1,perPage:25});i.useEffect(()=>{N||k?.[0]&&V(`${k[0].class_id}val${k[0].section_id}`)},[k,N]);const S=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),$=i.useMemo(()=>{if(!N)return null;const[re,X]=String(N).split("val");if(!re||!X)return null;const xe=q.page??1,De=q.perPage??25;return`${Vt.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(xe))}&per_page=${encodeURIComponent(String(De))}&session_id=${encodeURIComponent(String(S))}&class_id=${encodeURIComponent(String(re))}§ion_id=${encodeURIComponent(String(X))}`},[N,q.page,q.perPage,S]),{data:M,isLoading:L,mutate:ee}=H(t&&$?[$,t]:null,([re,X])=>G(re,X),{revalidateOnFocus:!1}),W=i.useMemo(()=>Ku(M),[M]),K=i.useMemo(()=>{const re=M?.pagination??M?.data?.pagination??M?.data?.data?.pagination;return re?.total_rows??re?.total??W.length??0},[M,W]),Q=async re=>{if(re.preventDefault(),C(""),!n||!s||!l){v.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(g)||g.length===0){C("error"),v.error("Please Select Subject",{duration:1200});return}const X=new FormData;X.append("teacher_id",String(n)),X.append("class_id",String(s)),X.append("section_id",String(l)),X.append("isClassTeacher",String(u??"No")),ln(g).forEach(xe=>X.append("subject_ids[]",String(xe))),ln(j).forEach(xe=>X.append("delete_subject[]",String(xe)));try{await dt(Vt.assignClassToTeacher,X,t,{includeSession:!0}),v.success("Success! Added new item.",{duration:1e3}),C(""),ee()}catch(xe){v.error(xe?.response?.data?.msg??xe?.message??"Failed to add the new item.",{duration:1500})}},ne=async re=>{try{await vt(Vt.deleteTeacherSub,re,t),v.success("Success! Deleted item.",{duration:1e3}),ee()}catch(X){v.error(X?.response?.data?.msg??X?.message??"Failed to delete the item.",{duration:1500})}},le=re=>{const X=Array.isArray(re?.child)?re.child:[],xe=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(De,qe)=>e.jsx(r.Popconfirm,{title:"Delete this subject?",onConfirm:()=>ne(qe?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(se.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(r.Table,{columns:xe,bordered:!0,size:"small",dataSource:X,pagination:!1,rowKey:De=>De.id})})},je=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(re,X)=>e.jsxs("div",{children:[X.teacher_name,X.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],ae=i.useMemo(()=>(k??[]).map(re=>({label:re.label??`${re.class_name??""} ${re.section_name??""}`.trim(),key:`${re.class_id}val${re.section_id}`,children:e.jsx(r.Table,{size:"small",columns:je,bordered:!0,dataSource:Array.isArray(W)?W:[],loading:L,rowKey:X=>X.id,expandable:{expandedRowRender:le},pagination:{current:q.page,pageSize:q.perPage,total:K,showSizeChanger:!0,onChange:(X,xe)=>T({page:X,perPage:xe})}})})),[k,q.page,q.perPage,W,L,K]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(320px, 380px) 1fr",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:Q,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:O.find(re=>String(re.value)===String(n))??null,onChange:re=>a(re?.value??null)}),e.jsx(te,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:z.find(re=>String(re.value)===String(s))??null,onChange:re=>{const X=re?.value??null;o(X),d(null),m(X?`${_e.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(X))}`:null),y(X?`${_e.master.sections.byClass}?class_id=${encodeURIComponent(String(X))}`:null),R(xe=>!xe)}}),e.jsx(te,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:B.find(re=>String(re.value)===String(l))??null,onChange:re=>d(re?.value??null)},`section_${P}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const re=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(te,{style:{width:"100%"},options:re,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:re.find(X=>String(X.value)===String(u??"No"))??re[1],onChange:X=>b(X?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(te,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:w,value:(w??[]).filter(re=>ln(g).some(X=>String(X)===String(re.value))),onChange:(re,X)=>{const De=(Array.isArray(re)?re:[]).map(Oe=>Oe?.value).filter(Oe=>Oe!=null&&Oe!=="");p(De);const qe=Array.isArray(E?.subject_ids)?E.subject_ids.map(String):[],Be=X?.removedValue?.value,$e=X?.option?.value;(X?.action==="remove-value"||X?.action==="pop-value")&&Be!=null&&qe.includes(String(Be))&&I(Oe=>Array.from(new Set([...ln(Oe).map(String),String(Be)]))),X?.action==="select-option"&&$e!=null&&qe.includes(String($e))&&I(Oe=>ln(Oe).filter(ze=>String(ze)!==String($e)))}},`subjects_${P}`),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(pe,{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:N??void 0,onChange:re=>{V(re),T(X=>({...X,page:1}))},items:ae,type:"card",size:"small"})})]})]})}function Ju({token:t}){return e.jsx(Gu,{token:t})}const dn=_e.timeGroup,Qu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},St={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ln(t){if(!t)return null;const n=fe(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return n.isValid()?n:null}function jt(t){return t?fe(t).format("h:mm a"):""}function Xu({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),[b]=r.Form.useForm(),g=`${dn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:p,isLoading:j,mutate:I}=H(t?[g,t]:null,([f,x])=>G(f,x)),A=i.useMemo(()=>Qu(p),[p]),m=i.useMemo(()=>p?.pagination?.total_rows??p?.pagination?.total??A.length??0,[p,A]),{data:c}=H(t&&l?[`${dn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,x])=>G(f,x)),y=i.useMemo(()=>{const f=c?.data??c;return Array.isArray(f)?f[0]:f??null},[c]);i.useEffect(()=>{s&&y&&b.setFieldsValue({title:y?.title??"",start_time_from:Ln(y?.start_time_from),start_time_to:Ln(y?.start_time_to),end_time_from:Ln(y?.end_time_from),end_time_to:Ln(y?.end_time_to)})},[s,y,b]);const P=async f=>{const x=new FormData;x.append("title",f.title??""),x.append("start_time_from",jt(f.start_time_from)),x.append("start_time_to",jt(f.start_time_to)),x.append("end_time_from",jt(f.end_time_from)),x.append("end_time_to",jt(f.end_time_to));try{await dt(dn.add,x,t),v.success("Success! Added new item.",{duration:1e3}),u.resetFields(),I()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to add the new item.",{duration:1500})}},R=async f=>{const x=new FormData;x.append("id",String(l??"")),x.append("title",f.title??""),x.append("start_time_from",jt(f.start_time_from)),x.append("start_time_to",jt(f.start_time_to)),x.append("end_time_from",jt(f.end_time_from)),x.append("end_time_to",jt(f.end_time_to));try{await wt(dn.edit,x,t),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),I()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to update the item.",{duration:1500})}},D=async f=>{try{await vt(dn.remove,f,t),v.success("Success! Deleted item.",{duration:1e3}),I()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to delete the item.",{duration:1500})}},C=f=>{f?.id&&(d(f.id),o(!0))},h=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,x)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(se.EditOutlined,{}),onClick:()=>C(x)}),e.jsx(r.Popconfirm,{title:"Delete this time group?",onConfirm:()=>D(x?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(se.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.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:b,layout:"vertical",onFinish:R,children:[e.jsx(r.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Z,{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:St})}),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:St})}),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:St})}),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:St})}),e.jsxs(r.Space,{children:[e.jsx(pe,{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:u,layout:"vertical",onFinish:P,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(Z,{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:St})}),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:St})}),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:St})}),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:St})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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:h,dataSource:A,loading:j,pagination:{current:n.page,pageSize:n.perPage,total:m,showSizeChanger:!0,onChange:(f,x)=>a({page:f,perPage:x})}})})]})}function Zu({token:t}){return e.jsx(Xu,{token:t})}const cn=_e.assignTimeGroup,ep=_e.timeGroup.dropdown,tp=_e.master.classes.dropdown,fs=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],np=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function ap({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[s,o]=i.useState(null),[l,d]=i.useState([]),[u,b]=i.useState(""),[g,p]=i.useState(""),[j,I]=i.useState(null),[A,m]=i.useState(!1),[c,y]=i.useState(!1),[P,R]=i.useState(null),[D,C]=i.useState([]),[h,f]=i.useState(""),[x,_]=i.useState(""),{data:O}=H(t?[ep,t]:null,([W,K])=>G(W,K)),{data:z}=H(t?[tp,t]:null,([W,K])=>G(W,K)),B=i.useMemo(()=>fs(O?.data??O),[O]),w=i.useMemo(()=>fs(z),[z]),{data:F}=H(t&&j?[j,t]:null,([W,K])=>G(W,K));i.useEffect(()=>{const W=Array.isArray(F?.data)?F.data.map(K=>K.fk_classId):[];W.length&&d(W)},[F]);const E=`${cn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:U,isLoading:k,mutate:N}=H(t?[E,t]:null,([W,K])=>G(W,K)),V=i.useMemo(()=>np(U),[U]),q=i.useMemo(()=>U?.pagination?.total_rows??U?.pagination?.total??V.length??0,[U,V]),{data:T}=H(t&&P?[`${cn.show}?id=${encodeURIComponent(String(P))}`,t]:null,([W,K])=>G(W,K)),S=T?.data??T??null;i.useEffect(()=>{if(!c||!S)return;const W=Array.isArray(S?.class_ids)?S.class_ids:[];C(W);const K=Array.isArray(B)?B.find(Q=>String(Q.value)===String(S?.timegroup_id)):null;K&&_(`${K.start_time_from} -> ${K.end_time_from}`)},[c,S,B]);const $=async W=>{if(W.preventDefault(),b(""),!s?.value){v.error("Select Time Group",{duration:1200});return}if(!l.length){b("error"),v.error("Please Select Classes",{duration:1200});return}const K=new FormData;K.append("timegroup_id",String(s.value)),l.forEach(Q=>K.append("class_ids[]",String(Q)));try{await dt(cn.assign,K,t),v.success("Success! Added new item.",{duration:1e3}),d([]),o(null),p(""),N()}catch(Q){v.error(Q?.response?.data?.msg??Q?.message??"Failed to add the new item.",{duration:1500})}},M=async()=>{if(f(""),!P)return;if(!D.length){f("error"),v.error("Please Select Classes",{duration:1200});return}const W=new FormData;W.append("id",String(P)),W.append("timegroup_id",String(S?.timegroup_id??"")),D.forEach(K=>W.append("class_ids[]",String(K)));try{await wt(cn.assign,W,t),v.success("Success! Updated item.",{duration:1e3}),y(!1),R(null),N()}catch(K){v.error(K?.response?.data?.msg??K?.message??"Failed to update the item.",{duration:1500})}},L=W=>{W&&(R(W),y(!0))},ee=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Class Names",dataIndex:"class_names",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:90,render:(W,K)=>K?.class_names?e.jsx(r.Button,{type:"text",icon:e.jsx(se.EditOutlined,{}),onClick:()=>L(K?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Assigned Time Group",open:c,onClose:()=>{y(!1),R(null)},width:520,extra:e.jsxs(r.Space,{children:[e.jsx(r.Button,{onClick:()=>y(!1),children:"Cancel"}),e.jsx(r.Button,{type:"primary",onClick:M,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{options:Array.isArray(B)?B:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:B.find(W=>String(W.value)===String(S?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:x}),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:h,value:D,placeholder:"Select Classes",onChange:W=>C(W),options:Array.isArray(w)?w:[]})]})]})}),e.jsx(r.Card,{title:e.jsx(r.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(te,{options:Array.isArray(B)?B:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:s,onChange:W=>{o(W??null),d([]),b(""),W?.value?(I(`${cn.classIdByTimeGroup}?id=${encodeURIComponent(String(W.value))}`),p(`${W.start_time_from} -> ${W.end_time_from}`)):(I(null),p("")),m(K=>!K)}}),e.jsx("div",{style:{marginTop:6},children:g})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(te,{mode:"multiple",style:{width:"100%"},status:u,value:l,placeholder:"Select Classes",onChange:W=>d(W),options:Array.isArray(w)?w:[]},`class_${A}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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:W=>W.id,columns:ee,dataSource:V,loading:k,pagination:{current:n.page,pageSize:n.perPage,total:q,showSizeChanger:!0,onChange:(W,K)=>a({page:W,perPage:K})}})})]})}function rp({token:t}){return e.jsx(ap,{token:t})}const Va=_e.promoteStudents,sp=({token:t})=>H(t?[Va.sessionDropdown,t]:null,([n,a])=>G(n,a)),zn=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[]},ip=(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 op({token:t}){const[n]=r.Form.useForm(),[a,s]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,u]=i.useState({sessionId:null,classId:null}),[b,g]=i.useState(!1),[p,j]=i.useState([]),I=i.useMemo(()=>new Set(p),[p]),[A,m]=i.useState({}),[c,y]=i.useState({}),{data:P}=H(t?[_e.master.classes.dropdown,t]:null,([M,L])=>G(M,L)),R=i.useMemo(()=>zn(P),[P]),D=i.useMemo(()=>o.classId?`${_e.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:C}=H(t&&D?[D,t]:null,([M,L])=>G(M,L)),h=i.useMemo(()=>zn(C),[C]),f=i.useMemo(()=>d.classId?`${_e.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:x}=H(t&&f?[f,t]:null,([M,L])=>G(M,L),{revalidateOnFocus:!1}),_=i.useMemo(()=>zn(x),[x]),{data:O}=sp({token:t}),z=i.useMemo(()=>zn(O),[O]),{trigger:B,data:w,isMutating:F}=Ke(t?Va.searchByClassSection:null,(M,{arg:L})=>Dt(M,{arg:L},t)),E=i.useMemo(()=>{const M=w?.data?.data??w?.data??w??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},[w]),U=i.useMemo(()=>ip(w,E.length??0),[w,E.length]),k=i.useMemo(()=>{const M=new Map;return(Array.isArray(E)?E:[]).forEach(L=>{L?.id!==void 0&&L?.id!==null&&M.set(String(L.id),L)}),M},[E]),N=i.useCallback((M,L)=>{const ee=String(M);y(W=>({...W,[ee]:{...W?.[ee]??{},...L}}))},[]),V=i.useCallback((M,L)=>{const ee=String(M),W=L==="Leave";m(K=>({...K,[ee]:W}))},[]),q=M=>{const L=M?.class_id?.value??M?.class_id??null,ee=M?.section_id?.value??M?.section_id??null;if(!L||!ee){v.error("Please select Class and Section",{duration:1200});return}s(W=>({...W,page:1})),l({classId:L,sectionId:ee}),j([]),m({}),y({})},T=async()=>{if(!d.sessionId||!d.classId){v.error("Please select Session and Class for promotion",{duration:1300});return}if(!Array.isArray(p)||p.length===0){v.error("Please select students to promote",{duration:1200});return}const M=p.map(K=>String(K)).map(K=>{const Q=k.get(K)??{},ne=!!A?.[K],le=c?.[K]??{},je=String(le.current_result??"Pass");if(ne){const X=String(le.leave_date??"");return{student_id:K,current_result:je,next_session_status:"Leave",leave_date:X}}const ae=String(le.roll_no??Q?.roll_no??""),re=String(le.section_id??"");return{student_id:K,roll_no:ae,section_id:re,current_result:je,next_session_status:"Continue"}});if(M.some(K=>K?.next_session_status==="Leave"&&!String(K?.leave_date??"").trim())){v.error("Leave date is required for Leave students.",{duration:1500});return}if(M.some(K=>K?.next_session_status==="Continue"&&!String(K?.section_id??"").trim())){v.error("Section is required for Continue students.",{duration:1500});return}const W={class_id:String(d.classId),session_id:String(d.sessionId),students:M};try{const K=await ut(Va.promote,W,t);if(K?.Status&&String(K.Status)!=="success")throw new Error(K?.msg||"Failed to update");v.success("Success! Updated.",{duration:1e3});const Q=Number(K?.success_count??0)+Number(K?.leave_count??0),ne=a.page===Math.ceil((Number(U)||0)/a.perPage||1),le=Q>0&&Q===E.length&&E.length===p.length,je=ne&&le&&a.page>1?a.page-1:a.page;s(ae=>({...ae,page:je})),B?.({cID:o.classId,sID:o.sectionId,page:je,per_page:a.perPage}),j([]),m({}),y({})}catch(K){v.error(K?.response?.data?.msg??K?.message??"Failed to update",{duration:1500})}},S=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:(M,L)=>{const ee=String(L?.id??""),W=I.has(ee),K=!!A?.[ee],ne=(c?.[ee]??{}).roll_no??(K?"":L?.roll_no??"");return e.jsx(r.Input,{value:W?ne:L?.roll_no,style:W?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!W||K,onChange:le=>N(ee,{roll_no:le.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(M,L)=>`${L?.firstname??""} ${L?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(M,L)=>{const ee=String(L?.id??""),W=I.has(ee),K=!!A?.[ee],ne=(c?.[ee]??{}).section_id??"",le=Array.isArray(_)?_:[];return e.jsx(r.Select,{options:le,placeholder:W&&!K?"Select Section":"Section",disabled:!W||K,value:W&&!K&&ne||void 0,style:{width:"100%"},onChange:je=>N(ee,{section_id:je})},`section_${ee}_${b}_${K?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(M,L)=>{const ee=String(L?.id??""),W=I.has(ee),K=c?.[ee]??{},Q=String(K.current_result??"Pass");return e.jsxs(r.Radio.Group,{value:Q,disabled:!W,buttonStyle:"solid",onChange:ne=>N(ee,{current_result:ne.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:(M,L)=>{const ee=String(L?.id??""),W=I.has(ee),K=!!A?.[ee],Q=c?.[ee]??{},ne=String(Q.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(r.Radio.Group,{value:K?"Leave":"Continue",disabled:!W,buttonStyle:"solid",onChange:le=>V(ee,le.target.value),children:[e.jsx(r.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(r.Radio.Button,{value:"Leave",children:"Leave"})]}),W&&K&&e.jsx(r.DatePicker,{style:{width:"100%"},value:ne?fe(ne):null,onChange:le=>N(ee,{leave_date:le?le.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[V,A,c,I,b,_,N]),$=i.useMemo(()=>({selectedRowKeys:p,onChange:M=>j((Array.isArray(M)?M:[]).map(L=>String(L)))}),[p]);return i.useEffect(()=>{!o.classId||!o.sectionId||B&&B({cID:o.classId,sID:o.sectionId,page:a.page,per_page:a.perPage})},[a.page,a.perPage,B,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.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:M=>M,children:e.jsx(te,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const L=M?.value??null;n.setFieldValue("section_id",null),l({classId:L,sectionId:null})}})}),e.jsx(r.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:M=>M,children:e.jsx(te,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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(Et,{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: ",p.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(te,{label:"Session",options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:z.find(M=>String(M.value)===String(d.sessionId))??null,onChange:M=>u(L=>({...L,sessionId:M?.value??null}))}),e.jsx(te,{label:"Class",options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(M=>String(M.value)===String(d.classId))??null,onChange:M=>{const L=M?.value??null;u(ee=>({...ee,classId:L})),g(ee=>!ee)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"button",value:"Save",color:"primary",onClick:T})})]}),e.jsx(r.Table,{rowKey:M=>String(M.id),rowSelection:$,columns:S,dataSource:E,loading:F,pagination:{current:a.page,pageSize:a.perPage,total:U,showSizeChanger:!0,onChange:(M,L)=>{s({page:M,perPage:L}),j([]),m({}),y({})}}})]})})]})}function lp({token:t}){return e.jsx(op,{token:t})}const Yt=_e.coscholastic,dp=({token:t})=>H(t?[Yt.table,t]:null,([n,a])=>G(n,a),{revalidateOnFocus:!1}),cp=({token:t})=>H(t?[Yt.categoryDropdown,t]:null,([n,a])=>G(n,a),{revalidateOnFocus:!1}),ys=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 up({token:t}){const[n,a]=i.useState(""),[s,o]=i.useState(null),[l,d]=i.useState(null),u=i.useRef(null),{data:b}=H(t?[_e.master.classes.dropdown,t]:null,([x,_])=>G(x,_)),g=i.useMemo(()=>ys(b),[b]),{data:p,isLoading:j,mutate:I}=dp({token:t}),A=i.useMemo(()=>{const x=p?.data?.data??p?.data??p??[];return Array.isArray(x)?x:Array.isArray(x?.data)?x.data:[]},[p]),{data:m,mutate:c}=cp({token:t}),y=i.useMemo(()=>ys(m),[m]),P=i.useMemo(()=>(Array.isArray(y)?y:[]).map(x=>({value:x?.value??x?.id,label:x?.label??x?.title??""})),[y]),R=async()=>{const x=String(n??"").trim();if(!x){v.error("Please enter category title",{duration:1200});return}try{await We(Yt.addCategory,{title:x},t),v.success("Success! Added category.",{duration:1e3}),a(""),c()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to add category",{duration:1500})}},D=async x=>{try{await vt(Yt.deleteCategory,x,t),v.success("Success! Deleted category.",{duration:1e3}),c()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to delete category",{duration:1500})}},C=async x=>{if(x.preventDefault(),!s){v.error("Please select Category",{duration:1200});return}if(!l){v.error("Please select Class",{duration:1200});return}if(!x?.target?.skill?.value){v.error("Please enter Skill Name",{duration:1200});return}const O=new FormData(x.target);O.append("scholastic_catid",String(s)),O.append("class_id",String(l));try{await dt(Yt.addSkill,O,t),v.success("Success! Added new item.",{duration:1e3}),x.target.reset(),d(null),I()}catch(z){v.error(z?.response?.data?.msg??z?.message??"Failed to add the new item.",{duration:1500})}},h=async x=>{try{await vt(Yt.deleteSkill,x,t),v.success("Success! Deleted item.",{duration:1e3}),I()}catch(_){v.error(_?.response?.data?.msg??_?.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:(x,_)=>e.jsx(r.Popconfirm,{title:"Delete this skill?",onConfirm:()=>h(_?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(se.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.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(te,{style:{width:"100%"},value:P.find(x=>String(x.value)===String(s))??null,placeholder:"Select Category",onChange:x=>o(x?.value??null),options:P}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(Z,{placeholder:"New category",ref:u,value:n,onChange:x=>a(x.target.value)}),e.jsx(r.Button,{type:"text",icon:e.jsx(se.PlusOutlined,{}),onClick:R}),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(se.DeleteOutlined,{}),disabled:!s})})]})]}),e.jsx(te,{label:"Class",options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:g.find(x=>String(x.value)===String(l))??null,onChange:x=>d(x?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(Z,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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(Et,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(r.Table,{rowKey:x=>x.id,columns:f,dataSource:A,loading:j,pagination:!1})})]})}function pp({token:t}){return e.jsx(up,{token:t})}const mp=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",hi=({token:t,value:n,onChange:a})=>{const s=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(r.Upload,{maxCount:1,action:Cu(),headers:s,onChange:o=>{if(o?.file?.status==="done"){const l=mp(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},hs=_e.notes,fp=({token:t,url:n})=>H(t&&n?[n,t]:null,([a,s])=>G(a,s),{revalidateOnFocus:!1}),Vn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},yp=(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 hp({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}),[u,b]=i.useState(!1),[g,p]=i.useState(""),{data:j}=H(t?[_e.master.classes.dropdown,t]:null,([$,M])=>G($,M)),I=i.useMemo(()=>Vn(j),[j]),A=i.useMemo(()=>l.classId?`${_e.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:m}=H(t&&A?[A,t]:null,([$,M])=>G($,M)),c=i.useMemo(()=>Vn(m),[m]),y=i.useMemo(()=>!l.classId||!l.sectionId?null:`${hs.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:P,isLoading:R,mutate:D}=fp({token:t,url:y}),C=i.useMemo(()=>{const $=P?.data?.data??P?.data??P??[];return Array.isArray($)?$:Array.isArray($?.data)?$.data:[]},[P]),h=i.useMemo(()=>P?.pagination?.total_rows??P?.pagination?.total??C.length??0,[P,C.length]),[f,x]=i.useState(null),[_,O]=i.useState(null),[z,B]=i.useState(null),[w,F]=i.useState(!1),{data:E}=H(t&&z?[z,t]:null,([$,M])=>G($,M),{revalidateOnFocus:!1}),U=i.useMemo(()=>Vn(E),[E]),{data:k}=H(t&&_?[_,t]:null,([$,M])=>G($,M)),N=i.useMemo(()=>Vn(k),[k]),V=$=>{const M=$?.class_id?.value??null,L=$?.section_id?.value??null;!M||!L||(o(ee=>({...ee,page:1})),d({classId:M,sectionId:L}))},q=()=>{p(""),b(!0),x(null),O(null),B(null),F($=>!$),a.resetFields()},T=async $=>{const M=$?.class_id?.value??null,L=$?.section_id?.value??null,ee=$?.sub_id?.value??null,W=$?.status?.value??"publish",K=$?.title??"",Q=$?.remark??"";if(!M||!L||!ee||!K||!Q||!g){v.error("Please fill all fields",{duration:1200});return}const ne=new FormData;ne.append("class_id",String(M)),ne.append("section_id",String(L)),ne.append("sub_id",String(ee)),ne.append("title",String(K)),ne.append("remark",String(Q)),ne.append("status",String(W)),ne.append("file",String(g));try{await dt(hs.add,ne,t),v.success("Success! Added new item.",{duration:1e3}),b(!1),D()}catch(le){v.error(le?.response?.data?.msg??le?.message??"Failed to add the new item.",{duration:1500})}},S=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:($,M)=>{const L=String(M?.status??"").toLowerCase();return e.jsx(r.Tag,{color:L==="publish"?"green":"red",children:M?.status??"-"})}},{title:"File",key:"file",align:"center",render:($,M)=>{const L=M?.file;if(!L)return"-";const ee=yp(ot(),`/student/note/${L}`);return e.jsx("a",{href:ee,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"publish_date",key:"publish_date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:"Add Note",open:u,onCancel:()=>b(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(r.Form,{form:a,layout:"vertical",onFinish:T,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(te,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const M=$?.value??null;x(M),a.setFieldValue("section_id",null),a.setFieldValue("sub_id",null),B(M?`${_e.master.sections.byClass}?class_id=${encodeURIComponent(String(M))}`:null),O(M?`${_e.master.subjects.dropdown}?class_id=${encodeURIComponent(String(M))}`:null),F(L=>!L)}},`class_${w}`)}),e.jsx(r.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(te,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${w}_${f??"none"}`)}),e.jsx(r.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:$=>$,children:e.jsx(te,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${w}_${_??"none"}`)}),e.jsx(r.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Z,{placeholder:"Title"})}),e.jsx(r.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(Z,{placeholder:"Remark"})}),e.jsx(r.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:$=>$,children:e.jsx(te,{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(hi,{token:t,value:g,onChange:p})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>b(!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(Et,{actions:["add","export","print","download","filter"],onAdd:q,onPrint:()=>window.print()})]}),children:e.jsx(r.Form,{form:n,layout:"vertical",onFinish:V,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(te,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const M=$?.value??null;n.setFieldValue("section_id",null),d({classId:M,sectionId:null})}})}),e.jsx(r.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(te,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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:$=>$.id,columns:S,dataSource:C,loading:R,pagination:{current:s.page,pageSize:s.perPage,total:h,showSizeChanger:!0,onChange:($,M)=>o({page:$,perPage:M})}})})]})}function gp({token:t}){return e.jsx(hp,{token:t})}const xp=({token:t})=>H(t?[_e.promoteStudents.sessionDropdown,t]:null,([n,a])=>G(n,a),{revalidateOnFocus:!1}),gs=_e.transferCertificate,$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[]},bp={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Sp=(t,n)=>t.inputtype==="Select"?null:t.inputtype==="date"?fe():"",xs=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}],bs=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 jp({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}),[u,b]=i.useState({classId:null,sectionId:null,sessionId:null}),[g,p]=i.useState(null),[j,I]=i.useState(!1),{data:A}=H(t?[_e.master.classes.dropdown,t]:null,([S,$])=>G(S,$)),m=i.useMemo(()=>$a(A),[A]),{data:c}=H(t&&g?[g,t]:null,([S,$])=>G(S,$)),y=i.useMemo(()=>$a(c),[c]),{data:P}=xp({token:t}),R=i.useMemo(()=>$a(P),[P]),D=i.useMemo(()=>!u.classId||!u.sectionId||!u.sessionId?null:`${gs.studentList}?class_id=${encodeURIComponent(String(u.classId))}§ion_id=${encodeURIComponent(String(u.sectionId))}&session_id=${encodeURIComponent(String(u.sessionId))}&page=${encodeURIComponent(String(l.page))}&per_page=${encodeURIComponent(String(l.perPage))}`,[u.classId,u.sectionId,u.sessionId,l.page,l.perPage]),{data:C,isLoading:h,mutate:f}=H(t&&D?[D,t]:null,([S,$])=>G(S,$),{revalidateOnFocus:!1,onSuccess:S=>{const $=S?.data?.data??S?.data??[];Array.isArray($)&&$[0]?.transefer_certificate_id&&E(String($[0].transefer_certificate_id))}}),x=i.useMemo(()=>{const S=C?.data?.data??C?.data??C??[];return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:[]},[C]),_=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??x.length??0,[C,x.length]),[O,z]=i.useState(!1),[B,w]=i.useState(null),[F,E]=i.useState("1"),U=S=>{w(S);const $=F==="1"?xs(S):bs(S),M={};$.forEach(L=>{M[L.name]=L.value??Sp(L)}),o.setFieldsValue(M),z(!0)},k=async S=>{if(!S)return;if(typeof a=="function")return a(S);const $=`${n}?id=${encodeURIComponent(String(S))}`;window.location.href=$},N=S=>{const $=S?.class_id?.value??null,M=S?.section_id?.value??null,L=S?.session_id?.value??null;if(!$||!M||!L){v.error("Please select Class, Section and Session",{duration:1200});return}d(ee=>({...ee,page:1})),b({classId:$,sectionId:M,sessionId:L})},V=async S=>{const $=new FormData;Object.entries(S??{}).forEach(([M,L])=>{if(L!=null){if(fe.isDayjs(L)){$.append(M,L.format("YYYY-MM-DD"));return}$.append(M,String(L))}});try{await dt(gs.addData,$,t),v.success("Success! Added new item.",{duration:1e3}),z(!1),w(null),f()}catch(M){v.error(M?.response?.data?.msg??M?.message??"Failed to add the new item.",{duration:1500})}},q=i.useMemo(()=>F==="1"?xs(B):bs(B),[F,B]),T=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:(S,$)=>e.jsx(r.Button,{type:"text",icon:$?.transfer_certificate_data==="not_present"?e.jsx(se.EyeOutlined,{}):e.jsx(se.CheckOutlined,{}),onClick:()=>{$?.transfer_certificate_data==="not_present"?U($?.id):k($?.id)}})}],[F]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:"Transfer Certificate",open:O,onCancel:()=>z(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:V,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:q.map(S=>S.inputtype==="hidden"?e.jsx(r.Form.Item,{name:S.name,initialValue:S.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},S.name):S.inputtype==="date"?e.jsx(r.Form.Item,{label:S.label,name:S.name,children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:bp})},S.name):S.inputtype==="radio"?e.jsx(r.Form.Item,{label:S.label,name:S.name,children:e.jsx(r.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},S.name):S.inputtype==="Select"?e.jsx(r.Form.Item,{label:S.label,name:S.name,getValueFromEvent:$=>$,children:e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},S.name):e.jsx(r.Form.Item,{label:S.label,name:S.name,children:e.jsx(Z,{placeholder:S.label})},S.name))}),e.jsxs(r.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(pe,{type:"submit",value:"Submit",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>z(!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: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:S=>S,children:e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:S=>{const $=S?.value??null;p($?`${_e.master.sections.byClass}?class_id=${encodeURIComponent(String($))}`:null),I(M=>!M),s.setFieldValue("section_id",null)}})}),e.jsx(r.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:S=>S,children:e.jsx(te,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${j}`)}),e.jsx(r.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:S=>S,children:e.jsx(te,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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(Et,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(r.Table,{rowKey:S=>S.id,columns:T,dataSource:x,loading:h,pagination:{current:l.page,pageSize:l.perPage,total:_,showSizeChanger:!0,onChange:(S,$)=>d({page:S,perPage:$})}})})]})}function wp({token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a}){return e.jsx(jp,{token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a})}const vp=({token:t,url:n})=>H(t&&n?[n,t]:null,([a,s])=>G(a,s),{revalidateOnFocus:!1}),Ua=_e.syllabus,Ss=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[]},_p=(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 Cp({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}),[u,b]=i.useState(!1),[g,p]=i.useState(null),[j,I]=i.useState(""),{data:A}=H(t?[_e.master.classes.dropdown,t]:null,([k,N])=>G(k,N)),m=i.useMemo(()=>Ss(A),[A]),c=i.useMemo(()=>l.classId?`${Ua.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:y,isLoading:P,mutate:R}=vp({token:t,url:c}),D=i.useMemo(()=>{const k=y?.data?.data??y?.data??y??[];return Array.isArray(k)?k:Array.isArray(k?.data)?k.data:[]},[y]),C=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??D.length??0,[y,D.length]),[h,f]=i.useState(null),[x,_]=i.useState(!1),{data:O}=H(t&&h?[h,t]:null,([k,N])=>G(k,N),{revalidateOnFocus:!1}),z=i.useMemo(()=>Ss(O),[O]),B=k=>{const N=k?.class_id?.value??null;N&&(o(V=>({...V,page:1})),d({classId:N}))},w=()=>{p(null),I(""),f(null),_(k=>!k),a.resetFields(),b(!0)},F=k=>{p(k),I(k?.attchement??"");const N=k?.class_id;f(N?`${_e.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),_(V=>!V),a.setFieldsValue({class_id:m.find(V=>String(V.value)===String(N))??null,sub_id:z.find(V=>String(V.value)===String(k?.sub_id??k?.subject_id))??(k?.sub_id||k?.subject_id?{label:k?.subject_title??"Subject",value:k?.sub_id??k?.subject_id}:null),title:k?.title??"",description:k?.description??""}),b(!0)},E=async k=>{const N=k?.class_id?.value??null,V=k?.sub_id?.value??null,q=k?.title??"",T=k?.description??"";if(!N||!V||!q||!T||!j){v.error("Please fill all fields",{duration:1200});return}const S=new FormData;S.append("class_id",String(N)),S.append("sub_id",String(V)),S.append("title",String(q)),S.append("description",String(T)),S.append("file",String(j));try{g?.id?(S.append("id",String(g.id)),await dt(Ua.edit,S,t),v.success("Success! Updated item.",{duration:1e3})):(await dt(Ua.add,S,t),v.success("Success! Added new item.",{duration:1e3})),b(!1),p(null),R()}catch($){v.error($?.response?.data?.msg??$?.message??"Failed to save",{duration:1500})}},U=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:(k,N)=>{const V=N?.attchement;if(!V)return"-";const q=_p(ot(),`uploads/student/note/${V}`);return e.jsx("a",{href:q,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(k,N)=>e.jsx(r.Button,{type:"text",icon:e.jsx(se.EditOutlined,{}),onClick:()=>F(N)})}],[z,m]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:g?"Edit Syllabus":"Add Syllabus",open:u,onCancel:()=>{b(!1),p(null),I("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(r.Form,{form:a,layout:"vertical",onFinish:E,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:k=>k,children:e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:k=>{const N=k?.value??null;a.setFieldValue("sub_id",null),f(N?`${_e.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),_(V=>!V)}},`class_${g?.id??"add"}_${x}`)}),e.jsx(r.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:k=>k,children:e.jsx(te,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${g?.id??"add"}_${x}_${h??"none"}`)}),e.jsx(r.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Z,{placeholder:"Title"})}),e.jsx(r.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(hn,{placeholder:"Description"})}),e.jsx(r.Form.Item,{label:"File",required:!0,children:e.jsx(hi,{token:t,value:j,onChange:I})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>b(!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(Et,{actions:["add","export","print","download","filter"],onAdd:w,onPrint:()=>window.print()})]}),children:e.jsx(r.Form,{form:n,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:k=>k,children:e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{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:k=>k.id,columns:U,dataSource:D,loading:P,pagination:{current:s.page,pageSize:s.perPage,total:C,showSizeChanger:!0,onChange:(k,N)=>o({page:k,perPage:N})}})})]})}function Tp({token:t}){return e.jsx(Cp,{token:t})}const ga=_e.timetable,js=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[]},ws=t=>{if(!t)return"";const n=fe(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},Ap=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]},vs=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Ip=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"};function Rp({token:t}){const[n,a]=i.useState(null),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,b]=i.useState(""),[g,p]=i.useState(""),{data:j}=H(t?[_e.master.classes.dropdown,t]:null,([f,x])=>G(f,x)),I=i.useMemo(()=>js(j),[j]),{data:A}=H(t&&n?[n,t]:null,([f,x])=>G(f,x)),m=i.useMemo(()=>js(A),[A]),{data:c,isLoading:y}=H(t&&l?[l,t]:null,([f,x])=>G(f,x),{revalidateOnFocus:!1}),P=i.useMemo(()=>c?.days??c?.data?.days??c?.data?.data?.days??{},[c]),{dataSource:R,daySpanByFirstKey:D}=i.useMemo(()=>{const f=Object.entries(P||{}).slice().sort((O,z)=>vs.indexOf(String(O[0]).toLowerCase())-vs.indexOf(String(z[0]).toLowerCase())),x=new Map,_=[];for(const[O,z]of f){const B=(Array.isArray(z)?z:[]).slice().sort((F,E)=>Number(F?.order_no||0)-Number(E?.order_no||0)),w=B.length;for(let F=0;F<w;F+=1){const E=B[F],U=E?.id||`${O}-${E?.order_no}-${F}`;F===0&&x.set(U,w),_.push({key:U,_dayKey:O,...E})}}return{dataSource:_,daySpanByFirstKey:x}},[P]),C=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(f,x)=>{const _=D.get(x.key);return _===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(se.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(r.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Ip(f)})]}),props:{rowSpan:_}}}},{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,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(se.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(r.Typography.Text,{children:[ws(x?.time_from)," - ",ws(x?.time_to)]})]})},{title:"Subject",key:"subject",render:(f,x)=>{if(String(x?.is_break)==="1")return e.jsx(r.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const O=x?.subject_name||"-";return e.jsx(r.Tag,{color:Ap(O),style:{fontWeight:500},children:O})}},{title:"Teacher",key:"teacher",render:(f,x)=>{const _=String(x?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(se.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(r.Typography.Text,{children:_?"-":x?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(f,x)=>{const _=String(x?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(se.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(r.Typography.Text,{children:_?"-":x?.room_no||"-"})]})}}],[D]),h=f=>{f.preventDefault();const x=f.target.class_id?.value,_=f.target.section_id?.value;if(!x||!_)return;const O=I.find(F=>String(F.value)===String(x)),z=m.find(F=>String(F.value)===String(_));b(O?.label||""),p(z?.label||"");const w=`${ga.byClassSection}/${x}/section/${_}`;d(w)};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(Et,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),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(te,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:f=>{a(`${_e.master.sections.byClass}?class_id=${encodeURIComponent(String(f?.value??""))}`),o(x=>!x)}}),e.jsx(te,{options:m,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(pe,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:u||g?`Timetable: ${u} ${g}`:"Timetable"}),children:e.jsx(r.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:R,columns:C,rowKey:"key",loading:y,scroll:{x:"max-content"}})})]})}const Dp=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[]},_s=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Op=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"},Cs=t=>{if(!t)return"";const n=fe(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},Pp=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 Ep({token:t}){const[n,a]=i.useState(null),[s,o]=i.useState(null),{data:l}=H(t?[_e.assignByClass.teacherDropdown,t]:null,([A,m])=>G(A,m)),d=i.useMemo(()=>Dp(l),[l]),{data:u,isLoading:b}=H(t&&s?[s,t]:null,([A,m])=>G(A,m),{revalidateOnFocus:!1}),{dataSource:g,daySpanByFirstKey:p}=i.useMemo(()=>{const m=(Array.isArray(u?.data)&&u.data||Array.isArray(u?.data?.data)&&u.data.data||[]).slice().sort((R,D)=>{const C=_s.indexOf(String(R?.day_name||"").toLowerCase()),h=_s.indexOf(String(D?.day_name||"").toLowerCase());if(C!==h)return C-h;const f=Number(R?.order_no||0),x=Number(D?.order_no||0);return f!==x?f-x:String(R?.time_from||"").localeCompare(String(D?.time_from||""))}),c=new Map,y=[];let P=0;for(;P<m.length;){const R=String(m[P]?.day_name||"").toLowerCase();let D=P;for(;D<m.length&&String(m[D]?.day_name||"").toLowerCase()===R;)D+=1;const C=D-P;for(let h=P;h<D;h+=1){const f=m[h],x=f?.id||`${R}-${f?.order_no}-${h}`;h===P&&c.set(x,C),y.push({key:x,_dayKey:R,...f})}P=D}return{dataSource:y,daySpanByFirstKey:c}},[u]),j=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(A,m)=>{const c=p.get(m.key);return c===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(se.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(r.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Op(A)})]}),props:{rowSpan:c}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:A=>e.jsx(r.Tag,{color:"#5080f8",style:{fontWeight:500},children:A})},{title:"Time",key:"time",width:180,render:(A,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(se.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(r.Typography.Text,{children:[Cs(m?.time_from)," - ",Cs(m?.time_to)]})]})},{title:"Subject",key:"subject",render:(A,m)=>{if(String(m?.is_break)==="1")return e.jsx(r.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const y=m?.subject_name||"-";return e.jsx(r.Tag,{color:Pp(y),style:{fontWeight:500},children:y})}},{title:"Class",key:"class",width:160,render:(A,m)=>e.jsxs(r.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:(A,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(se.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(r.Typography.Text,{children:m?.room_no||"-"})]})}],[p]),I=A=>{A.preventDefault();const m=A.target.teacher_id?.value;if(!m)return;a(m);const y=`${ga.teacherTimetable}${encodeURIComponent(String(m))}`;o(y)};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(Et,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{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(pe,{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:g,columns:j,rowKey:"key",loading:b,scroll:{x:"max-content"}})})]})}function Ts(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 b=a.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!b)return null;o=Number.parseInt(b[1],10),l=Number.parseInt(b[2],10),d=Number.parseInt(b[3]||"0",10);const g=b[4].toLowerCase();g==="pm"&&o<12&&(o+=12),g==="am"&&o===12&&(o=0)}else{const u=n.split(":").map(b=>b.trim());if(u.length<2)return null;o=Number.parseInt(u[0],10),l=Number.parseInt(u[1],10),d=Number.parseInt(u[2]||"0",10)}return![o,l,d].every(u=>Number.isFinite(u))||o<0||o>23||l<0||l>59||d<0||d>59?null:fe().hour(o).minute(l).second(d).millisecond(0)}function un(t,n){const a=Number.parseInt(n,10);return!Number.isFinite(a)||a<=0||!t||!t.isValid?.()?null:t.add(a,"minute")}const 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[]},yn={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},Fp=t=>{const n=yn[String(t)];return n?n.charAt(0).toUpperCase()+n.slice(1):String(t)},kp=({token:t,classId:n,sectionId:a,subjectId:s,value:o,onChange:l,disabled:d})=>{const u=t&&n&&a&&s?`${ga.teachersBySubject}?subject_id=${encodeURIComponent(String(s))}&class_id=${encodeURIComponent(String(n))}§ion_id=${encodeURIComponent(String(a))}`:null,{data:b,isLoading:g}=H(u?[u,t]:null,([j,I])=>G(j,I),{revalidateOnFocus:!1}),p=i.useMemo(()=>sa(b?.data??b).map(I=>({value:I?.value??I?.id,label:I?.label??I?.name??I?.teacher_name??""})),[b]);return e.jsx(r.Select,{placeholder:d?"-":"Select Teacher",loading:g,disabled:d,style:{width:"100%"},options:p,value:o?String(o):void 0,onChange:j=>l?.(j),showSearch:!0,optionFilterProp:"label"})};function Mp({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,u]=i.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[b,g]=i.useState(!1),p=i.useMemo(()=>t?_e.master.classes.dropdown:null,[t]),{data:j}=H(p?[p,t]:null,([w,F])=>G(w,F)),I=i.useMemo(()=>sa(j).map(w=>({value:w?.value??w?.id,label:w?.label??w?.title??""})),[j]),A=i.useMemo(()=>!t||!a.classId?null:`${_e.master.sections.byClass}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:m}=H(A?[A,t]:null,([w,F])=>G(w,F)),c=i.useMemo(()=>sa(m).map(w=>({value:w?.value??w?.id,label:w?.label??w?.title??""})),[m]),y=i.useMemo(()=>!t||!a.classId?null:`${_e.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:P}=H(y?[y,t]:null,([w,F])=>G(w,F)),R=i.useMemo(()=>sa(P).map(w=>({value:w?.value??w?.id,label:w?.label??w?.title??""})),[P]),D=i.useMemo(()=>Array.isArray(d?.[a.dayKey])?d[a.dayKey]:[],[a.dayKey,d]),C=i.useCallback((w,F,E)=>{u(U=>{const k={...U},N=Array.isArray(k[w])?k[w].slice():[];return N[F]={...N[F]??{},...E},k[w]=N,k})},[]),h=i.useCallback((w,F)=>{u(E=>{const U={...E},k=Array.isArray(U[w])?U[w].slice():[];return k.splice(F,1),U[w]=k.map((N,V)=>({...N,order_no:V+1})),U})},[]),f=i.useCallback(w=>{u(F=>{const E={...F},U=Array.isArray(E[w])?E[w].slice():[];let k=null,N=null;const V=U[U.length-1];if(V?.time_to){const q=Ts(V.time_to),T=Number.parseInt(o.interval,10)||0,S=Number.parseInt(o.duration,10)||0,$=un(q,T),M=S>0?un($,S):null;k=$?.isValid?.()?$.format("HH:mm:ss"):null,N=M?.isValid?.()?M.format("HH:mm:ss"):null}return U.push({order_no:U.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:k,time_to:N,is_break:!1}),E[w]=U,E})},[o.duration,o.interval,o.roomNo]),x=i.useCallback(()=>{const w=o.startTime,F=o.endTime,E=Number.parseInt(o.duration,10),U=Number.parseInt(o.interval,10);if(!w||!w.isValid?.()){v.error("Start time is required",{duration:1500});return}if(!F||!F.isValid?.()){v.error("End time is required",{duration:1500});return}if(!F.isAfter(w)){v.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(E)||E<=0){v.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(U)||U<0){v.error("Interval must be 0 or more",{duration:1500});return}const k=()=>{const N=[];let V=w;for(let q=0;q<50;q+=1){const T=un(V,E);if(!T||!T.isValid?.()||T.isAfter(F))break;N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:V.format("HH:mm:ss"),time_to:T.format("HH:mm:ss"),is_break:!1});const S=un(T,U);if(!S||!S.isValid?.()||S.isAfter(F)||S.isSame(F))break;V=S}if(o.tiffinEnabled){const q=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),T=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),S=Math.min(q,N.length);if(S>0&&T>0){const $=N[S-1],M=$?.time_to?Ts($.time_to):null,L=M?un(M,T):null;M?.isValid?.()&&L?.isValid?.()&&!L.isAfter(F)&&N.splice(S,0,{order_no:S+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:M.format("HH:mm:ss"),time_to:L.format("HH:mm:ss"),is_break:!0})}}return N.map((q,T)=>({...q,order_no:T+1}))};u(N=>{const V={...N};return Object.keys(yn).forEach(q=>{a.daysEnabled?.[q]&&(V[q]=k())}),V}),v.success("Generated schedule",{duration:1e3})},[o,a.daysEnabled]),_=i.useCallback(()=>{const w=localStorage.getItem("genrall_settings"),E=(w?JSON.parse(w):{})?.session_id??"1",U=a.classId,k=a.sectionId,N=Object.keys(yn).map(V=>{const q=(Array.isArray(d?.[V])?d[V]:[]).map((T,S)=>({order_no:S+1,subject_id:T?.is_break?0:T?.subject_id??null,teacher_id:T?.is_break?0:T?.teacher_id??null,room_no:T?.room_no??"",time_from:T?.time_from??null,time_to:T?.time_to??null,is_break:T?.is_break?1:0}));return{day:yn[V],class_id:U,section_id:k,session_id:E,args:q}});return{class_id:U,section_id:k,session_id:E,days:N}},[a.classId,a.sectionId,d]),O=i.useCallback(async()=>{if(!a.classId||!a.sectionId){v.error("Please select Class and Section",{duration:1500});return}const w=_(),F=Array.isArray(w?.days)?w.days:[];if(!F.some(k=>Array.isArray(k?.args)&&k.args.length>0)){v.error("No timetable rows to submit",{duration:1500});return}const U=k=>{const N=k?.is_break;return N===1||N==="1"||N===!0?!0:String(N??"").toLowerCase()==="true"};F.some(k=>(Array.isArray(k?.args)?k.args:[]).some(N=>String(N?.time_from??"").trim()&&String(N?.time_to??"").trim()?U(N)?!1:!String(N?.subject_id??"").trim()||!String(N?.teacher_id??"").trim():!0)),g(!0);try{const k=ga.save,N=k==="api/timetable/save"?"timetable/save":null,V=async S=>{const $=await Ja(S,w,t);if($&&typeof $=="object")return $;throw new Error("No response from server")};let q;try{q=await V(k)}catch{q=await V(N)}const T=String(q?.msg??"");if(String(q?.Status)==="Success"){if(Array.isArray(q?.data)&&q.data.length===0&&T){v.error(T,{duration:3e3});return}v.success(T||"Weekly Time Table added successfully!",{duration:1200});return}v.error(T||"Failed to add time table",{duration:3e3})}catch(k){v.error(k?.response?.data?.msg??k?.message??"Failed to add time table",{duration:3e3})}finally{g(!1)}},[_,a.classId,a.sectionId,t]),z=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:w=>w?fe(w,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:w=>w?fe(w,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(w,F,E)=>e.jsx(r.Switch,{checked:!!F?.is_break,onChange:U=>{C(a.dayKey,E,{is_break:U,subject_id:U?"":F?.subject_id??"",teacher_id:U?"":F?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(w,F,E)=>e.jsx(r.Select,{placeholder:F?.is_break?"-":"Select Subject",disabled:!!F?.is_break,style:{width:"100%"},options:R,value:F?.subject_id?String(F.subject_id):void 0,onChange:U=>C(a.dayKey,E,{subject_id:U,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(w,F,E)=>e.jsx(kp,{token:t,classId:a.classId,sectionId:a.sectionId,subjectId:F?.subject_id,disabled:!!F?.is_break||!F?.subject_id,value:F?.teacher_id,onChange:U=>C(a.dayKey,E,{teacher_id:U})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(w,F,E)=>e.jsx(r.Input,{value:F?.room_no??"",onChange:U=>C(a.dayKey,E,{room_no:U.target.value})})},{title:"Action",key:"action",width:90,render:(w,F,E)=>e.jsx(r.Popconfirm,{title:"Delete this row?",onConfirm:()=>h(a.dayKey,E),children:e.jsx(r.Button,{danger:!0,type:"text",children:"Delete"})})}],[a.classId,a.dayKey,a.sectionId,h,R,t,C]),B=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(v.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:I,value:a.classId?String(a.classId):void 0,onChange:w=>{s(F=>({...F,classId:w,sectionId:null})),u({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:c,value:a.sectionId?String(a.sectionId):void 0,onChange:w=>s(F=>({...F,sectionId:w})),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:w=>l(F=>({...F,startTime:w})),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:w=>l(F=>({...F,endTime:w})),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:w=>l(F=>({...F,duration:w})),style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"Interval (min)",children:e.jsx(r.InputNumber,{min:0,value:o.interval,onChange:w=>l(F=>({...F,interval:w})),style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"Room No",children:e.jsx(r.Input,{value:o.roomNo,onChange:w=>l(F=>({...F,roomNo:w.target.value}))})}),e.jsx(r.Form.Item,{label:"Tiffin Break",children:e.jsxs(r.Space,{children:[e.jsx(r.Switch,{checked:o.tiffinEnabled,onChange:w=>l(F=>({...F,tiffinEnabled:w}))}),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:w=>l(F=>({...F,tiffinAfterPeriod:w})),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:w=>l(F=>({...F,tiffinDuration:w})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(r.Button,{onClick:x,children:"Generate"}),e.jsx(r.Button,{type:"primary",loading:b,onClick:O,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:w=>s(F=>({...F,dayKey:w})),options:Object.keys(yn).map(w=>({value:String(w),label:Fp(w)}))}),e.jsx(r.Button,{onClick:()=>f(a.dayKey),children:"Add Row"})]}),children:e.jsx(r.Table,{rowKey:(w,F)=>`${a.dayKey}_${F}`,columns:z,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:B},{key:"routine",label:"Routine",children:e.jsx(Rp,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(Ep,{token:t})}]})]})}function $p({token:t}){return e.jsx(Mp,{token:t})}const Up=({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(ue,{children:e.jsx(Rs,{icon:a?.icon??"",title:a?.title??"",path:a?.path??"",onClick:n})})},`${s}route001`))});exports.Academics=vu;exports.AddBook=Zl;exports.AddDriver=Kl;exports.AddStaff=xc;exports.AdmissionEnquiry=Tl;exports.ApplyLeave=nu;exports.AprroveLeaveRequest=Gc;exports.AssignByClass=Ju;exports.AssignStudentToTransport=Hl;exports.AssignSubjects=Hu;exports.AssignTimeGroup=rp;exports.AssignVehicles=kl;exports.BookList=ed;exports.BuySellProduct=Ud;exports.Category=Ad;exports.Class=ku;exports.CoScholasticArea=pp;exports.CreateTimeGroup=Zu;exports.Department=lu;exports.Designation=uu;exports.ErpDashboard=bi;exports.Holidays=zu;exports.IssueReturn=nd;exports.LeaveType=su;exports.LibraryAssignStudent=ad;exports.LibraryCategory=rd;exports.LibraryReport=sd;exports.ManageStock=Qd;exports.MenuSubmenu=il;exports.Notes=gp;exports.Payroll=Vc;exports.PayrollReceiptDetails=wu;exports.Products=vd;exports.PromoteStudents=lp;exports.RoutePage=Up;exports.RouteTimeTable=Gl;exports.Sections=Du;exports.SellReports=Kd;exports.Shift=fu;exports.StaffAttendance=kc;exports.StaffAttendanceReport=Bc;exports.StaffDailyAttendance=bu;exports.StaffDirectory=vc;exports.StockReport=nc;exports.Stoppage=Ql;exports.SubCategory=Ed;exports.Subjects=Bu;exports.Syllabus=Tp;exports.TimeTable=$p;exports.TransferCertificate=wp;exports.TransportRoutes=Il;exports.TransportVehicles=Rl;exports.Unit=Ld;exports.Vendor=md;exports.setBaseUrl=al;
|