ubk.erp.webpack 1.3.2 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("antd"),W=require("swr"),w=require("react-hot-toast"),r=require("react"),tt=require("swr/mutation"),te=require("@ant-design/icons"),ae=require("dayjs"),vl=require("react-dom/server"),xa=require("react-to-print"),ho=require("react-select"),fo=require("react-barcode"),_l=()=>e.jsxs(n.Card,{style:{borderRadius:16},children:[e.jsx(n.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),v=({width:t,height:a,display:s,justifyContent:i,alignItems:o,flexDirection:l,gap:d,style:c,children:y,...h})=>{const u={width:t,height:a,display:s,justifyContent:i,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:u,...h,children:y})},ge=({variant:t,fontWeight:a,style:s,children:i,...o})=>{const l=a==="bold"?700:a==="light"?300:a;return t==="h1"?e.jsx(n.Typography.Title,{level:1,style:{fontWeight:l,...s},...o,children:i}):t==="h2"?e.jsx(n.Typography.Title,{level:2,style:{fontWeight:l,...s},...o,children:i}):t==="h3"?e.jsx(n.Typography.Title,{level:3,style:{fontWeight:l,...s},...o,children:i}):t==="h4"?e.jsx(n.Typography.Title,{level:4,style:{fontWeight:l,...s},...o,children:i}):t==="h5"?e.jsx(n.Typography.Title,{level:5,style:{fontWeight:l,...s},...o,children:i}):e.jsx(n.Typography.Text,{style:{fontWeight:l,...s},...o,children:i})};function yo({title:t="",icon:a="",path:s="",onClick:i}){const o=()=>{if(i){i(s);return}typeof window<"u"&&typeof s=="string"&&s.length>0&&window.location.assign(s)};return e.jsxs(n.Card,{hoverable:!0,onClick:o,style:{borderRadius:12,overflow:"hidden",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.10)"},bodyStyle:{padding:0,cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[e.jsx(v,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:a,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(v,{style:{padding:"0 12px"},children:e.jsx(n.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(v,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(ge,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function go(t,a){return function(){return t.apply(a,arguments)}}const{toString:Cl}=Object.prototype,{getPrototypeOf:Gn}=Object,{iterator:Jn,toStringTag:xo}=Symbol,Qn=(t=>a=>{const s=Cl.call(a);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Ct=t=>(t=t.toLowerCase(),a=>Qn(a)===t),Xn=t=>a=>typeof a===t,{isArray:ba}=Array,fa=Xn("undefined");function Ha(t){return t!==null&&!fa(t)&&t.constructor!==null&&!fa(t.constructor)&&ut(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const bo=Ct("ArrayBuffer");function Al(t){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(t):a=t&&t.buffer&&bo(t.buffer),a}const Dl=Xn("string"),ut=Xn("function"),jo=Xn("number"),Ka=t=>t!==null&&typeof t=="object",Tl=t=>t===!0||t===!1,kn=t=>{if(Qn(t)!=="object")return!1;const a=Gn(t);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(xo in t)&&!(Jn in t)},Rl=t=>{if(!Ka(t)||Ha(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Il=Ct("Date"),kl=Ct("File"),Pl=t=>!!(t&&typeof t.uri<"u"),Ol=t=>t&&typeof t.getParts<"u",Ml=Ct("Blob"),El=Ct("FileList"),Fl=t=>Ka(t)&&ut(t.pipe);function Ul(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const gr=Ul(),xr=typeof gr.FormData<"u"?gr.FormData:void 0,$l=t=>{if(!t)return!1;if(xr&&t instanceof xr)return!0;const a=Gn(t);if(!a||a===Object.prototype||!ut(t.append))return!1;const s=Qn(t);return s==="formdata"||s==="object"&&ut(t.toString)&&t.toString()==="[object FormData]"},Nl=Ct("URLSearchParams"),[Ll,Bl,ql,zl]=["ReadableStream","Request","Response","Headers"].map(Ct),Yl=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ga(t,a,{allOwnKeys:s=!1}={}){if(t===null||typeof t>"u")return;let i,o;if(typeof t!="object"&&(t=[t]),ba(t))for(i=0,o=t.length;i<o;i++)a.call(null,t[i],i,t);else{if(Ha(t))return;const l=s?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(i=0;i<d;i++)c=l[i],a.call(null,t[c],c,t)}}function So(t,a){if(Ha(t))return null;a=a.toLowerCase();const s=Object.keys(t);let i=s.length,o;for(;i-- >0;)if(o=s[i],a===o.toLowerCase())return o;return null}const Ht=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,wo=t=>!fa(t)&&t!==Ht;function qs(){const{caseless:t,skipUndefined:a}=wo(this)&&this||{},s={},i=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&So(s,l)||l;kn(s[d])&&kn(o)?s[d]=qs(s[d],o):kn(o)?s[d]=qs({},o):ba(o)?s[d]=o.slice():(!a||!fa(o))&&(s[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&Ga(arguments[o],i);return s}const Vl=(t,a,s,{allOwnKeys:i}={})=>(Ga(a,(o,l)=>{s&&ut(o)?Object.defineProperty(t,l,{value:go(o,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),t),Wl=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Hl=(t,a,s,i)=>{t.prototype=Object.create(a.prototype,i),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:a.prototype}),s&&Object.assign(t.prototype,s)},Kl=(t,a,s,i)=>{let o,l,d;const c={};if(a=a||{},t==null)return a;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!i||i(d,t,a))&&!c[d]&&(a[d]=t[d],c[d]=!0);t=s!==!1&&Gn(t)}while(t&&(!s||s(t,a))&&t!==Object.prototype);return a},Gl=(t,a,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=a.length;const i=t.indexOf(a,s);return i!==-1&&i===s},Jl=t=>{if(!t)return null;if(ba(t))return t;let a=t.length;if(!jo(a))return null;const s=new Array(a);for(;a-- >0;)s[a]=t[a];return s},Ql=(t=>a=>t&&a instanceof t)(typeof Uint8Array<"u"&&Gn(Uint8Array)),Xl=(t,a)=>{const i=(t&&t[Jn]).call(t);let o;for(;(o=i.next())&&!o.done;){const l=o.value;a.call(t,l[0],l[1])}},Zl=(t,a)=>{let s;const i=[];for(;(s=t.exec(a))!==null;)i.push(s);return i},ed=Ct("HTMLFormElement"),td=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,i,o){return i.toUpperCase()+o}),br=(({hasOwnProperty:t})=>(a,s)=>t.call(a,s))(Object.prototype),ad=Ct("RegExp"),vo=(t,a)=>{const s=Object.getOwnPropertyDescriptors(t),i={};Ga(s,(o,l)=>{let d;(d=a(o,l,t))!==!1&&(i[l]=d||o)}),Object.defineProperties(t,i)},nd=t=>{vo(t,(a,s)=>{if(ut(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const i=t[s];if(ut(i)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},sd=(t,a)=>{const s={},i=o=>{o.forEach(l=>{s[l]=!0})};return ba(t)?i(t):i(String(t).split(a)),s},rd=()=>{},id=(t,a)=>t!=null&&Number.isFinite(t=+t)?t:a;function od(t){return!!(t&&ut(t.append)&&t[xo]==="FormData"&&t[Jn])}const ld=t=>{const a=new Array(10),s=(i,o)=>{if(Ka(i)){if(a.indexOf(i)>=0)return;if(Ha(i))return i;if(!("toJSON"in i)){a[o]=i;const l=ba(i)?[]:{};return Ga(i,(d,c)=>{const y=s(d,o+1);!fa(y)&&(l[c]=y)}),a[o]=void 0,l}}return i};return s(t,0)},dd=Ct("AsyncFunction"),cd=t=>t&&(Ka(t)||ut(t))&&ut(t.then)&&ut(t.catch),_o=((t,a)=>t?setImmediate:a?((s,i)=>(Ht.addEventListener("message",({source:o,data:l})=>{o===Ht&&l===s&&i.length&&i.shift()()},!1),o=>{i.push(o),Ht.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",ut(Ht.postMessage)),ud=typeof queueMicrotask<"u"?queueMicrotask.bind(Ht):typeof process<"u"&&process.nextTick||_o,pd=t=>t!=null&&ut(t[Jn]),Z={isArray:ba,isArrayBuffer:bo,isBuffer:Ha,isFormData:$l,isArrayBufferView:Al,isString:Dl,isNumber:jo,isBoolean:Tl,isObject:Ka,isPlainObject:kn,isEmptyObject:Rl,isReadableStream:Ll,isRequest:Bl,isResponse:ql,isHeaders:zl,isUndefined:fa,isDate:Il,isFile:kl,isReactNativeBlob:Pl,isReactNative:Ol,isBlob:Ml,isRegExp:ad,isFunction:ut,isStream:Fl,isURLSearchParams:Nl,isTypedArray:Ql,isFileList:El,forEach:Ga,merge:qs,extend:Vl,trim:Yl,stripBOM:Wl,inherits:Hl,toFlatObject:Kl,kindOf:Qn,kindOfTest:Ct,endsWith:Gl,toArray:Jl,forEachEntry:Xl,matchAll:Zl,isHTMLForm:ed,hasOwnProperty:br,hasOwnProp:br,reduceDescriptors:vo,freezeMethods:nd,toObjectSet:sd,toCamelCase:td,noop:rd,toFiniteNumber:id,findKey:So,global:Ht,isContextDefined:wo,isSpecCompliantForm:od,toJSONObject:ld,isAsyncFn:dd,isThenable:cd,setImmediate:_o,asap:ud,isIterable:pd};let Ae=class Co extends Error{static from(a,s,i,o,l,d){const c=new Co(a.message,s||a.code,i,o,l);return c.cause=a,c.name=a.name,a.status!=null&&c.status==null&&(c.status=a.status),d&&Object.assign(c,d),c}constructor(a,s,i,o,l){super(a),Object.defineProperty(this,"message",{value:a,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,s&&(this.code=s),i&&(this.config=i),o&&(this.request=o),l&&(this.response=l,this.status=l.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Z.toJSONObject(this.config),code:this.code,status:this.status}}};Ae.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Ae.ERR_BAD_OPTION="ERR_BAD_OPTION";Ae.ECONNABORTED="ECONNABORTED";Ae.ETIMEDOUT="ETIMEDOUT";Ae.ERR_NETWORK="ERR_NETWORK";Ae.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Ae.ERR_DEPRECATED="ERR_DEPRECATED";Ae.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Ae.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Ae.ERR_CANCELED="ERR_CANCELED";Ae.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Ae.ERR_INVALID_URL="ERR_INVALID_URL";Ae.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const md=null;function zs(t){return Z.isPlainObject(t)||Z.isArray(t)}function Ao(t){return Z.endsWith(t,"[]")?t.slice(0,-2):t}function ps(t,a,s){return t?t.concat(a).map(function(o,l){return o=Ao(o),!s&&l?"["+o+"]":o}).join(s?".":""):a}function hd(t){return Z.isArray(t)&&!t.some(zs)}const fd=Z.toFlatObject(Z,{},null,function(a){return/^is[A-Z]/.test(a)});function Zn(t,a,s){if(!Z.isObject(t))throw new TypeError("target must be an object");a=a||new FormData,s=Z.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(j,T){return!Z.isUndefined(T[j])});const i=s.metaTokens,o=s.visitor||p,l=s.dots,d=s.indexes,c=s.Blob||typeof Blob<"u"&&Blob,y=s.maxDepth===void 0?100:s.maxDepth,h=c&&Z.isSpecCompliantForm(a);if(!Z.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(Z.isDate(m))return m.toISOString();if(Z.isBoolean(m))return m.toString();if(!h&&Z.isBlob(m))throw new Ae("Blob is not supported. Use a Buffer instead.");return Z.isArrayBuffer(m)||Z.isTypedArray(m)?h&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function p(m,j,T){let R=m;if(Z.isReactNative(a)&&Z.isReactNativeBlob(m))return a.append(ps(T,j,l),u(m)),!1;if(m&&!T&&typeof m=="object"){if(Z.endsWith(j,"{}"))j=i?j:j.slice(0,-2),m=JSON.stringify(m);else if(Z.isArray(m)&&hd(m)||(Z.isFileList(m)||Z.endsWith(j,"[]"))&&(R=Z.toArray(m)))return j=Ao(j),R.forEach(function(_,A){!(Z.isUndefined(_)||_===null)&&a.append(d===!0?ps([j],A,l):d===null?j:j+"[]",u(_))}),!1}return zs(m)?!0:(a.append(ps(T,j,l),u(m)),!1)}const C=[],S=Object.assign(fd,{defaultVisitor:p,convertValue:u,isVisitable:zs});function x(m,j,T=0){if(!Z.isUndefined(m)){if(T>y)throw new Ae("Object is too deeply nested ("+T+" levels). Max depth: "+y,Ae.ERR_FORM_DATA_DEPTH_EXCEEDED);if(C.indexOf(m)!==-1)throw Error("Circular reference detected in "+j.join("."));C.push(m),Z.forEach(m,function(I,_){(!(Z.isUndefined(I)||I===null)&&o.call(a,I,Z.isString(_)?_.trim():_,j,S))===!0&&x(I,j?j.concat(_):[_],T+1)}),C.pop()}}if(!Z.isObject(t))throw new TypeError("data must be an object");return x(t),a}function jr(t){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(i){return a[i]})}function Js(t,a){this._pairs=[],t&&Zn(t,this,a)}const Do=Js.prototype;Do.append=function(a,s){this._pairs.push([a,s])};Do.toString=function(a){const s=a?function(i){return a.call(this,i,jr)}:jr;return this._pairs.map(function(o){return s(o[0])+"="+s(o[1])},"").join("&")};function yd(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function To(t,a,s){if(!a)return t;const i=s&&s.encode||yd,o=Z.isFunction(s)?{serialize:s}:s,l=o&&o.serialize;let d;if(l?d=l(a,o):d=Z.isURLSearchParams(a)?a.toString():new Js(a,o).toString(i),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class Sr{constructor(){this.handlers=[]}use(a,s,i){return this.handlers.push({fulfilled:a,rejected:s,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){Z.forEach(this.handlers,function(i){i!==null&&a(i)})}}const Qs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},gd=typeof URLSearchParams<"u"?URLSearchParams:Js,xd=typeof FormData<"u"?FormData:null,bd=typeof Blob<"u"?Blob:null,jd={isBrowser:!0,classes:{URLSearchParams:gd,FormData:xd,Blob:bd},protocols:["http","https","file","blob","url","data"]},Xs=typeof window<"u"&&typeof document<"u",Ys=typeof navigator=="object"&&navigator||void 0,Sd=Xs&&(!Ys||["ReactNative","NativeScript","NS"].indexOf(Ys.product)<0),wd=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",vd=Xs&&window.location.href||"http://localhost",_d=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Xs,hasStandardBrowserEnv:Sd,hasStandardBrowserWebWorkerEnv:wd,navigator:Ys,origin:vd},Symbol.toStringTag,{value:"Module"})),nt={..._d,...jd};function Cd(t,a){return Zn(t,new nt.classes.URLSearchParams,{visitor:function(s,i,o,l){return nt.isNode&&Z.isBuffer(s)?(this.append(i,s.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...a})}function Ad(t){return Z.matchAll(/\w+|\[(\w*)]/g,t).map(a=>a[0]==="[]"?"":a[1]||a[0])}function Dd(t){const a={},s=Object.keys(t);let i;const o=s.length;let l;for(i=0;i<o;i++)l=s[i],a[l]=t[l];return a}function Ro(t){function a(s,i,o,l){let d=s[l++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),y=l>=s.length;return d=!d&&Z.isArray(o)?o.length:d,y?(Z.hasOwnProp(o,d)?o[d]=Z.isArray(o[d])?o[d].concat(i):[o[d],i]:o[d]=i,!c):((!o[d]||!Z.isObject(o[d]))&&(o[d]=[]),a(s,i,o[d],l)&&Z.isArray(o[d])&&(o[d]=Dd(o[d])),!c)}if(Z.isFormData(t)&&Z.isFunction(t.entries)){const s={};return Z.forEachEntry(t,(i,o)=>{a(Ad(i),o,s,0)}),s}return null}const ea=(t,a)=>t!=null&&Z.hasOwnProp(t,a)?t[a]:void 0;function Td(t,a,s){if(Z.isString(t))try{return(a||JSON.parse)(t),Z.trim(t)}catch(i){if(i.name!=="SyntaxError")throw i}return(s||JSON.stringify)(t)}const Ja={transitional:Qs,adapter:["xhr","http","fetch"],transformRequest:[function(a,s){const i=s.getContentType()||"",o=i.indexOf("application/json")>-1,l=Z.isObject(a);if(l&&Z.isHTMLForm(a)&&(a=new FormData(a)),Z.isFormData(a))return o?JSON.stringify(Ro(a)):a;if(Z.isArrayBuffer(a)||Z.isBuffer(a)||Z.isStream(a)||Z.isFile(a)||Z.isBlob(a)||Z.isReadableStream(a))return a;if(Z.isArrayBufferView(a))return a.buffer;if(Z.isURLSearchParams(a))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let c;if(l){const y=ea(this,"formSerializer");if(i.indexOf("application/x-www-form-urlencoded")>-1)return Cd(a,y).toString();if((c=Z.isFileList(a))||i.indexOf("multipart/form-data")>-1){const h=ea(this,"env"),u=h&&h.FormData;return Zn(c?{"files[]":a}:a,u&&new u,y)}}return l||o?(s.setContentType("application/json",!1),Td(a)):a}],transformResponse:[function(a){const s=ea(this,"transitional")||Ja.transitional,i=s&&s.forcedJSONParsing,o=ea(this,"responseType"),l=o==="json";if(Z.isResponse(a)||Z.isReadableStream(a))return a;if(a&&Z.isString(a)&&(i&&!o||l)){const c=!(s&&s.silentJSONParsing)&&l;try{return JSON.parse(a,ea(this,"parseReviver"))}catch(y){if(c)throw y.name==="SyntaxError"?Ae.from(y,Ae.ERR_BAD_RESPONSE,this,null,ea(this,"response")):y}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:nt.classes.FormData,Blob:nt.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Z.forEach(["delete","get","head","post","put","patch"],t=>{Ja.headers[t]={}});const Rd=Z.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Id=t=>{const a={};let s,i,o;return t&&t.split(`
2
- `).forEach(function(d){o=d.indexOf(":"),s=d.substring(0,o).trim().toLowerCase(),i=d.substring(o+1).trim(),!(!s||a[s]&&Rd[s])&&(s==="set-cookie"?a[s]?a[s].push(i):a[s]=[i]:a[s]=a[s]?a[s]+", "+i:i)}),a},wr=Symbol("internals"),kd=/[^\x09\x20-\x7E\x80-\xFF]/g;function Pd(t){let a=0,s=t.length;for(;a<s;){const i=t.charCodeAt(a);if(i!==9&&i!==32)break;a+=1}for(;s>a;){const i=t.charCodeAt(s-1);if(i!==9&&i!==32)break;s-=1}return a===0&&s===t.length?t:t.slice(a,s)}function _a(t){return t&&String(t).trim().toLowerCase()}function Od(t){return Pd(t.replace(kd,""))}function Pn(t){return t===!1||t==null?t:Z.isArray(t)?t.map(Pn):Od(String(t))}function Md(t){const a=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=s.exec(t);)a[i[1]]=i[2];return a}const Ed=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function ms(t,a,s,i,o){if(Z.isFunction(i))return i.call(this,a,s);if(o&&(a=s),!!Z.isString(a)){if(Z.isString(i))return a.indexOf(i)!==-1;if(Z.isRegExp(i))return i.test(a)}}function Fd(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,s,i)=>s.toUpperCase()+i)}function Ud(t,a){const s=Z.toCamelCase(" "+a);["get","set","has"].forEach(i=>{Object.defineProperty(t,i+s,{value:function(o,l,d){return this[i].call(this,a,o,l,d)},configurable:!0})})}let pt=class{constructor(a){a&&this.set(a)}set(a,s,i){const o=this;function l(c,y,h){const u=_a(y);if(!u)throw new Error("header name must be a non-empty string");const p=Z.findKey(o,u);(!p||o[p]===void 0||h===!0||h===void 0&&o[p]!==!1)&&(o[p||y]=Pn(c))}const d=(c,y)=>Z.forEach(c,(h,u)=>l(h,u,y));if(Z.isPlainObject(a)||a instanceof this.constructor)d(a,s);else if(Z.isString(a)&&(a=a.trim())&&!Ed(a))d(Id(a),s);else if(Z.isObject(a)&&Z.isIterable(a)){let c={},y,h;for(const u of a){if(!Z.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[h=u[0]]=(y=c[h])?Z.isArray(y)?[...y,u[1]]:[y,u[1]]:u[1]}d(c,s)}else a!=null&&l(s,a,i);return this}get(a,s){if(a=_a(a),a){const i=Z.findKey(this,a);if(i){const o=this[i];if(!s)return o;if(s===!0)return Md(o);if(Z.isFunction(s))return s.call(this,o,i);if(Z.isRegExp(s))return s.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,s){if(a=_a(a),a){const i=Z.findKey(this,a);return!!(i&&this[i]!==void 0&&(!s||ms(this,this[i],i,s)))}return!1}delete(a,s){const i=this;let o=!1;function l(d){if(d=_a(d),d){const c=Z.findKey(i,d);c&&(!s||ms(i,i[c],c,s))&&(delete i[c],o=!0)}}return Z.isArray(a)?a.forEach(l):l(a),o}clear(a){const s=Object.keys(this);let i=s.length,o=!1;for(;i--;){const l=s[i];(!a||ms(this,this[l],l,a,!0))&&(delete this[l],o=!0)}return o}normalize(a){const s=this,i={};return Z.forEach(this,(o,l)=>{const d=Z.findKey(i,l);if(d){s[d]=Pn(o),delete s[l];return}const c=a?Fd(l):String(l).trim();c!==l&&delete s[l],s[c]=Pn(o),i[c]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const s=Object.create(null);return Z.forEach(this,(i,o)=>{i!=null&&i!==!1&&(s[o]=a&&Z.isArray(i)?i.join(", "):i)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,s])=>a+": "+s).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...s){const i=new this(a);return s.forEach(o=>i.set(o)),i}static accessor(a){const i=(this[wr]=this[wr]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=_a(d);i[c]||(Ud(o,d),i[c]=!0)}return Z.isArray(a)?a.forEach(l):l(a),this}};pt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Z.reduceDescriptors(pt.prototype,({value:t},a)=>{let s=a[0].toUpperCase()+a.slice(1);return{get:()=>t,set(i){this[s]=i}}});Z.freezeMethods(pt);function hs(t,a){const s=this||Ja,i=a||s,o=pt.from(i.headers);let l=i.data;return Z.forEach(t,function(c){l=c.call(s,l,o.normalize(),a?a.status:void 0)}),o.normalize(),l}function Io(t){return!!(t&&t.__CANCEL__)}let Qa=class extends Ae{constructor(a,s,i){super(a??"canceled",Ae.ERR_CANCELED,s,i),this.name="CanceledError",this.__CANCEL__=!0}};function ko(t,a,s){const i=s.config.validateStatus;!s.status||!i||i(s.status)?t(s):a(new Ae("Request failed with status code "+s.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function $d(t){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return a&&a[1]||""}function Nd(t,a){t=t||10;const s=new Array(t),i=new Array(t);let o=0,l=0,d;return a=a!==void 0?a:1e3,function(y){const h=Date.now(),u=i[l];d||(d=h),s[o]=y,i[o]=h;let p=l,C=0;for(;p!==o;)C+=s[p++],p=p%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),h-d<a)return;const S=u&&h-u;return S?Math.round(C*1e3/S):void 0}}function Ld(t,a){let s=0,i=1e3/a,o,l;const d=(h,u=Date.now())=>{s=u,o=null,l&&(clearTimeout(l),l=null),t(...h)};return[(...h)=>{const u=Date.now(),p=u-s;p>=i?d(h,u):(o=h,l||(l=setTimeout(()=>{l=null,d(o)},i-p)))},()=>o&&d(o)]}const Kn=(t,a,s=3)=>{let i=0;const o=Nd(50,250);return Ld(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,y=c!=null?Math.min(d,c):d,h=Math.max(0,y-i),u=o(h);i=Math.max(i,y);const p={loaded:y,total:c,progress:c?y/c:void 0,bytes:h,rate:u||void 0,estimated:u&&c?(c-y)/u:void 0,event:l,lengthComputable:c!=null,[a?"download":"upload"]:!0};t(p)},s)},vr=(t,a)=>{const s=t!=null;return[i=>a[0]({lengthComputable:s,total:t,loaded:i}),a[1]]},_r=t=>(...a)=>Z.asap(()=>t(...a)),Bd=nt.hasStandardBrowserEnv?((t,a)=>s=>(s=new URL(s,nt.origin),t.protocol===s.protocol&&t.host===s.host&&(a||t.port===s.port)))(new URL(nt.origin),nt.navigator&&/(msie|trident)/i.test(nt.navigator.userAgent)):()=>!0,qd=nt.hasStandardBrowserEnv?{write(t,a,s,i,o,l,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(a)}`];Z.isNumber(s)&&c.push(`expires=${new Date(s).toUTCString()}`),Z.isString(i)&&c.push(`path=${i}`),Z.isString(o)&&c.push(`domain=${o}`),l===!0&&c.push("secure"),Z.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const a=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return a?decodeURIComponent(a[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function zd(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Yd(t,a){return a?t.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):t}function Po(t,a,s){let i=!zd(a);return t&&(i||s===!1)?Yd(t,a):a}const Cr=t=>t instanceof pt?{...t}:t;function Qt(t,a){a=a||{};const s=Object.create(null);Object.defineProperty(s,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function i(h,u,p,C){return Z.isPlainObject(h)&&Z.isPlainObject(u)?Z.merge.call({caseless:C},h,u):Z.isPlainObject(u)?Z.merge({},u):Z.isArray(u)?u.slice():u}function o(h,u,p,C){if(Z.isUndefined(u)){if(!Z.isUndefined(h))return i(void 0,h,p,C)}else return i(h,u,p,C)}function l(h,u){if(!Z.isUndefined(u))return i(void 0,u)}function d(h,u){if(Z.isUndefined(u)){if(!Z.isUndefined(h))return i(void 0,h)}else return i(void 0,u)}function c(h,u,p){if(Z.hasOwnProp(a,p))return i(h,u);if(Z.hasOwnProp(t,p))return i(void 0,h)}const y={url:l,method:l,data:l,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:c,headers:(h,u,p)=>o(Cr(h),Cr(u),p,!0)};return Z.forEach(Object.keys({...t,...a}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const p=Z.hasOwnProp(y,u)?y[u]:o,C=Z.hasOwnProp(t,u)?t[u]:void 0,S=Z.hasOwnProp(a,u)?a[u]:void 0,x=p(C,S,u);Z.isUndefined(x)&&p!==c||(s[u]=x)}),s}const Oo=t=>{const a=Qt({},t),s=C=>Z.hasOwnProp(a,C)?a[C]:void 0,i=s("data");let o=s("withXSRFToken");const l=s("xsrfHeaderName"),d=s("xsrfCookieName");let c=s("headers");const y=s("auth"),h=s("baseURL"),u=s("allowAbsoluteUrls"),p=s("url");if(a.headers=c=pt.from(c),a.url=To(Po(h,p,u),t.params,t.paramsSerializer),y&&c.set("Authorization","Basic "+btoa((y.username||"")+":"+(y.password?unescape(encodeURIComponent(y.password)):""))),Z.isFormData(i)){if(nt.hasStandardBrowserEnv||nt.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(Z.isFunction(i.getHeaders)){const C=i.getHeaders(),S=["content-type","content-length"];Object.entries(C).forEach(([x,m])=>{S.includes(x.toLowerCase())&&c.set(x,m)})}}if(nt.hasStandardBrowserEnv&&(Z.isFunction(o)&&(o=o(a)),o===!0||o==null&&Bd(a.url))){const S=l&&d&&qd.read(d);S&&c.set(l,S)}return a},Vd=typeof XMLHttpRequest<"u",Wd=Vd&&function(t){return new Promise(function(s,i){const o=Oo(t);let l=o.data;const d=pt.from(o.headers).normalize();let{responseType:c,onUploadProgress:y,onDownloadProgress:h}=o,u,p,C,S,x;function m(){S&&S(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let j=new XMLHttpRequest;j.open(o.method.toUpperCase(),o.url,!0),j.timeout=o.timeout;function T(){if(!j)return;const I=pt.from("getAllResponseHeaders"in j&&j.getAllResponseHeaders()),A={data:!c||c==="text"||c==="json"?j.responseText:j.response,status:j.status,statusText:j.statusText,headers:I,config:t,request:j};ko(function(g){s(g),m()},function(g){i(g),m()},A),j=null}"onloadend"in j?j.onloadend=T:j.onreadystatechange=function(){!j||j.readyState!==4||j.status===0&&!(j.responseURL&&j.responseURL.indexOf("file:")===0)||setTimeout(T)},j.onabort=function(){j&&(i(new Ae("Request aborted",Ae.ECONNABORTED,t,j)),j=null)},j.onerror=function(_){const A=_&&_.message?_.message:"Network Error",f=new Ae(A,Ae.ERR_NETWORK,t,j);f.event=_||null,i(f),j=null},j.ontimeout=function(){let _=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const A=o.transitional||Qs;o.timeoutErrorMessage&&(_=o.timeoutErrorMessage),i(new Ae(_,A.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,t,j)),j=null},l===void 0&&d.setContentType(null),"setRequestHeader"in j&&Z.forEach(d.toJSON(),function(_,A){j.setRequestHeader(A,_)}),Z.isUndefined(o.withCredentials)||(j.withCredentials=!!o.withCredentials),c&&c!=="json"&&(j.responseType=o.responseType),h&&([C,x]=Kn(h,!0),j.addEventListener("progress",C)),y&&j.upload&&([p,S]=Kn(y),j.upload.addEventListener("progress",p),j.upload.addEventListener("loadend",S)),(o.cancelToken||o.signal)&&(u=I=>{j&&(i(!I||I.type?new Qa(null,t,j):I),j.abort(),j=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const R=$d(o.url);if(R&&nt.protocols.indexOf(R)===-1){i(new Ae("Unsupported protocol "+R+":",Ae.ERR_BAD_REQUEST,t));return}j.send(l||null)})},Hd=(t,a)=>{const{length:s}=t=t?t.filter(Boolean):[];if(a||s){let i=new AbortController,o;const l=function(h){if(!o){o=!0,c();const u=h instanceof Error?h:this.reason;i.abort(u instanceof Ae?u:new Qa(u instanceof Error?u.message:u))}};let d=a&&setTimeout(()=>{d=null,l(new Ae(`timeout of ${a}ms exceeded`,Ae.ETIMEDOUT))},a);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(h=>{h.unsubscribe?h.unsubscribe(l):h.removeEventListener("abort",l)}),t=null)};t.forEach(h=>h.addEventListener("abort",l));const{signal:y}=i;return y.unsubscribe=()=>Z.asap(c),y}},Kd=function*(t,a){let s=t.byteLength;if(s<a){yield t;return}let i=0,o;for(;i<s;)o=i+a,yield t.slice(i,o),i=o},Gd=async function*(t,a){for await(const s of Jd(t))yield*Kd(s,a)},Jd=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const a=t.getReader();try{for(;;){const{done:s,value:i}=await a.read();if(s)break;yield i}}finally{await a.cancel()}},Ar=(t,a,s,i)=>{const o=Gd(t,a);let l=0,d,c=y=>{d||(d=!0,i&&i(y))};return new ReadableStream({async pull(y){try{const{done:h,value:u}=await o.next();if(h){c(),y.close();return}let p=u.byteLength;if(s){let C=l+=p;s(C)}y.enqueue(new Uint8Array(u))}catch(h){throw c(h),h}},cancel(y){return c(y),o.return()}},{highWaterMark:2})},Dr=64*1024,{isFunction:pn}=Z,Qd=(({Request:t,Response:a})=>({Request:t,Response:a}))(Z.global),{ReadableStream:Tr,TextEncoder:Rr}=Z.global,Ir=(t,...a)=>{try{return!!t(...a)}catch{return!1}},Xd=t=>{t=Z.merge.call({skipUndefined:!0},Qd,t);const{fetch:a,Request:s,Response:i}=t,o=a?pn(a):typeof fetch=="function",l=pn(s),d=pn(i);if(!o)return!1;const c=o&&pn(Tr),y=o&&(typeof Rr=="function"?(x=>m=>x.encode(m))(new Rr):async x=>new Uint8Array(await new s(x).arrayBuffer())),h=l&&c&&Ir(()=>{let x=!1;const m=new s(nt.origin,{body:new Tr,method:"POST",get duplex(){return x=!0,"half"}}),j=m.headers.has("Content-Type");return m.body!=null&&m.body.cancel(),x&&!j}),u=d&&c&&Ir(()=>Z.isReadableStream(new i("").body)),p={stream:u&&(x=>x.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!p[x]&&(p[x]=(m,j)=>{let T=m&&m[x];if(T)return T.call(m);throw new Ae(`Response type '${x}' is not supported`,Ae.ERR_NOT_SUPPORT,j)})});const C=async x=>{if(x==null)return 0;if(Z.isBlob(x))return x.size;if(Z.isSpecCompliantForm(x))return(await new s(nt.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(Z.isArrayBufferView(x)||Z.isArrayBuffer(x))return x.byteLength;if(Z.isURLSearchParams(x)&&(x=x+""),Z.isString(x))return(await y(x)).byteLength},S=async(x,m)=>{const j=Z.toFiniteNumber(x.getContentLength());return j??C(m)};return async x=>{let{url:m,method:j,data:T,signal:R,cancelToken:I,timeout:_,onDownloadProgress:A,onUploadProgress:f,responseType:g,headers:D,withCredentials:k="same-origin",fetchOptions:L}=Oo(x),B=a||fetch;g=g?(g+"").toLowerCase():"text";let b=Hd([R,I&&I.toAbortSignal()],_),P=null;const O=b&&b.unsubscribe&&(()=>{b.unsubscribe()});let F;try{if(f&&h&&j!=="get"&&j!=="head"&&(F=await S(D,T))!==0){let M=new s(m,{method:"POST",body:T,duplex:"half"}),$;if(Z.isFormData(T)&&($=M.headers.get("content-type"))&&D.setContentType($),M.body){const[q,H]=vr(F,Kn(_r(f)));T=Ar(M.body,Dr,q,H)}}Z.isString(k)||(k=k?"include":"omit");const U=l&&"credentials"in s.prototype;if(Z.isFormData(T)){const M=D.getContentType();M&&/^multipart\/form-data/i.test(M)&&!/boundary=/i.test(M)&&D.delete("content-type")}const N={...L,signal:b,method:j.toUpperCase(),headers:D.normalize().toJSON(),body:T,duplex:"half",credentials:U?k:void 0};P=l&&new s(m,N);let Y=await(l?B(P,L):B(m,N));const z=u&&(g==="stream"||g==="response");if(u&&(A||z&&O)){const M={};["status","statusText","headers"].forEach(re=>{M[re]=Y[re]});const $=Z.toFiniteNumber(Y.headers.get("content-length")),[q,H]=A&&vr($,Kn(_r(A),!0))||[];Y=new i(Ar(Y.body,Dr,q,()=>{H&&H(),O&&O()}),M)}g=g||"text";let E=await p[Z.findKey(p,g)||"text"](Y,x);return!z&&O&&O(),await new Promise((M,$)=>{ko(M,$,{data:E,headers:pt.from(Y.headers),status:Y.status,statusText:Y.statusText,config:x,request:P})})}catch(U){throw O&&O(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,x,P,U&&U.response),{cause:U.cause||U}):Ae.from(U,U&&U.code,x,P,U&&U.response)}}},Zd=new Map,Mo=t=>{let a=t&&t.env||{};const{fetch:s,Request:i,Response:o}=a,l=[i,o,s];let d=l.length,c=d,y,h,u=Zd;for(;c--;)y=l[c],h=u.get(y),h===void 0&&u.set(y,h=c?new Map:Xd(a)),u=h;return h};Mo();const Zs={http:md,xhr:Wd,fetch:{get:Mo}};Z.forEach(Zs,(t,a)=>{if(t){try{Object.defineProperty(t,"name",{value:a})}catch{}Object.defineProperty(t,"adapterName",{value:a})}});const kr=t=>`- ${t}`,ec=t=>Z.isFunction(t)||t===null||t===!1;function tc(t,a){t=Z.isArray(t)?t:[t];const{length:s}=t;let i,o;const l={};for(let d=0;d<s;d++){i=t[d];let c;if(o=i,!ec(i)&&(o=Zs[(c=String(i)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${c}'`);if(o&&(Z.isFunction(o)||(o=o.get(a))))break;l[c||"#"+d]=o}if(!o){const d=Object.entries(l).map(([y,h])=>`adapter ${y} `+(h===!1?"is not supported by the environment":"is not available in the build"));let c=s?d.length>1?`since :
4
- `+d.map(kr).join(`
5
- `):" "+kr(d[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o}const Eo={getAdapter:tc,adapters:Zs};function fs(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Qa(null,t)}function Pr(t){return fs(t),t.headers=pt.from(t.headers),t.data=hs.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Eo.getAdapter(t.adapter||Ja.adapter,t)(t).then(function(i){return fs(t),i.data=hs.call(t,t.transformResponse,i),i.headers=pt.from(i.headers),i},function(i){return Io(i)||(fs(t),i&&i.response&&(i.response.data=hs.call(t,t.transformResponse,i.response),i.response.headers=pt.from(i.response.headers))),Promise.reject(i)})}const Fo="1.15.2",es={};["object","boolean","number","function","string","symbol"].forEach((t,a)=>{es[t]=function(i){return typeof i===t||"a"+(a<1?"n ":" ")+t}});const Or={};es.transitional=function(a,s,i){function o(l,d){return"[Axios v"+Fo+"] Transitional option '"+l+"'"+d+(i?". "+i:"")}return(l,d,c)=>{if(a===!1)throw new Ae(o(d," has been removed"+(s?" in "+s:"")),Ae.ERR_DEPRECATED);return s&&!Or[d]&&(Or[d]=!0,console.warn(o(d," has been deprecated since v"+s+" and will be removed in the near future"))),a?a(l,d,c):!0}};es.spelling=function(a){return(s,i)=>(console.warn(`${i} is likely a misspelling of ${a}`),!0)};function ac(t,a,s){if(typeof t!="object")throw new Ae("options must be an object",Ae.ERR_BAD_OPTION_VALUE);const i=Object.keys(t);let o=i.length;for(;o-- >0;){const l=i[o],d=Object.prototype.hasOwnProperty.call(a,l)?a[l]:void 0;if(d){const c=t[l],y=c===void 0||d(c,l,t);if(y!==!0)throw new Ae("option "+l+" must be "+y,Ae.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new Ae("Unknown option "+l,Ae.ERR_BAD_OPTION)}}const On={assertOptions:ac,validators:es},jt=On.validators;let Kt=class{constructor(a){this.defaults=a||{},this.interceptors={request:new Sr,response:new Sr}}async request(a,s){try{return await this._request(a,s)}catch(i){if(i instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const l=(()=>{if(!o.stack)return"";const d=o.stack.indexOf(`
6
- `);return d===-1?"":o.stack.slice(d+1)})();try{if(!i.stack)i.stack=l;else if(l){const d=l.indexOf(`
7
- `),c=d===-1?-1:l.indexOf(`
8
- `,d+1),y=c===-1?"":l.slice(c+1);String(i.stack).endsWith(y)||(i.stack+=`
9
- `+l)}}catch{}}throw i}}_request(a,s){typeof a=="string"?(s=s||{},s.url=a):s=a||{},s=Qt(this.defaults,s);const{transitional:i,paramsSerializer:o,headers:l}=s;i!==void 0&&On.assertOptions(i,{silentJSONParsing:jt.transitional(jt.boolean),forcedJSONParsing:jt.transitional(jt.boolean),clarifyTimeoutError:jt.transitional(jt.boolean),legacyInterceptorReqResOrdering:jt.transitional(jt.boolean)},!1),o!=null&&(Z.isFunction(o)?s.paramsSerializer={serialize:o}:On.assertOptions(o,{encode:jt.function,serialize:jt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),On.assertOptions(s,{baseUrl:jt.spelling("baseURL"),withXsrfToken:jt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let d=l&&Z.merge(l.common,l[s.method]);l&&Z.forEach(["delete","get","head","post","put","patch","common"],x=>{delete l[x]}),s.headers=pt.concat(d,l);const c=[];let y=!0;this.interceptors.request.forEach(function(m){if(typeof m.runWhen=="function"&&m.runWhen(s)===!1)return;y=y&&m.synchronous;const j=s.transitional||Qs;j&&j.legacyInterceptorReqResOrdering?c.unshift(m.fulfilled,m.rejected):c.push(m.fulfilled,m.rejected)});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let u,p=0,C;if(!y){const x=[Pr.bind(this),void 0];for(x.unshift(...c),x.push(...h),C=x.length,u=Promise.resolve(s);p<C;)u=u.then(x[p++],x[p++]);return u}C=c.length;let S=s;for(;p<C;){const x=c[p++],m=c[p++];try{S=x(S)}catch(j){m.call(this,j);break}}try{u=Pr.call(this,S)}catch(x){return Promise.reject(x)}for(p=0,C=h.length;p<C;)u=u.then(h[p++],h[p++]);return u}getUri(a){a=Qt(this.defaults,a);const s=Po(a.baseURL,a.url,a.allowAbsoluteUrls);return To(s,a.params,a.paramsSerializer)}};Z.forEach(["delete","get","head","options"],function(a){Kt.prototype[a]=function(s,i){return this.request(Qt(i||{},{method:a,url:s,data:(i||{}).data}))}});Z.forEach(["post","put","patch"],function(a){function s(i){return function(l,d,c){return this.request(Qt(c||{},{method:a,headers:i?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Kt.prototype[a]=s(),Kt.prototype[a+"Form"]=s(!0)});let nc=class Uo{constructor(a){if(typeof a!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(l){s=l});const i=this;this.promise.then(o=>{if(!i._listeners)return;let l=i._listeners.length;for(;l-- >0;)i._listeners[l](o);i._listeners=null}),this.promise.then=o=>{let l;const d=new Promise(c=>{i.subscribe(c),l=c}).then(o);return d.cancel=function(){i.unsubscribe(l)},d},a(function(l,d,c){i.reason||(i.reason=new Qa(l,d,c),s(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const s=this._listeners.indexOf(a);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const a=new AbortController,s=i=>{a.abort(i)};return this.subscribe(s),a.signal.unsubscribe=()=>this.unsubscribe(s),a.signal}static source(){let a;return{token:new Uo(function(o){a=o}),cancel:a}}};function sc(t){return function(s){return t.apply(null,s)}}function rc(t){return Z.isObject(t)&&t.isAxiosError===!0}const Vs={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(Vs).forEach(([t,a])=>{Vs[a]=t});function $o(t){const a=new Kt(t),s=go(Kt.prototype.request,a);return Z.extend(s,Kt.prototype,a,{allOwnKeys:!0}),Z.extend(s,a,null,{allOwnKeys:!0}),s.create=function(o){return $o(Qt(t,o))},s}const We=$o(Ja);We.Axios=Kt;We.CanceledError=Qa;We.CancelToken=nc;We.isCancel=Io;We.VERSION=Fo;We.toFormData=Zn;We.AxiosError=Ae;We.Cancel=We.CanceledError;We.all=function(a){return Promise.all(a)};We.spread=sc;We.isAxiosError=rc;We.mergeConfig=Qt;We.AxiosHeaders=pt;We.formToJSON=t=>Ro(Z.isHTMLForm(t)?new FormData(t):t);We.getAdapter=Eo.getAdapter;We.HttpStatusCode=Vs;We.default=We;const{Axios:Qx,AxiosError:Xx,CanceledError:Zx,isCancel:eb,CancelToken:tb,VERSION:ab,all:nb,Cancel:sb,isAxiosError:rb,spread:ib,toFormData:ob,AxiosHeaders:lb,HttpStatusCode:db,formToJSON:cb,getAdapter:ub,mergeConfig:pb}=We,ic=()=>new Promise(t=>setTimeout(()=>t(),800));let Ws=null;const oc=t=>{Ws=t,rt.defaults.baseURL=er()},er=()=>Ws||"https://npmapi.ubkerp.com/",rt=We.create({baseURL:er()}),He=()=>er();let Hs=null;const lc=t=>{Hs=t},tr=()=>Hs||"https://image.ubkerp.com",Ee=async(t,a,s)=>{const i=await rt.post(t,a,{headers:{Authorization:s}});if(console.log("ddddfdfdfd",i.data?.Status),i.data?.Status=="Success")return i?.data?.data||i?.data;throw new Error(i.data?.msg)},dc=async(t,a,s)=>{const i=a instanceof FormData;return(await rt.post(t,a,{headers:{Authorization:s,...i?{"Content-type":"multipart/form-data"}:{}}})).data},K=async(t,a)=>{try{let i=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";i=`${t}${l}session_id=1`}return(await rt.get(i,{headers:{Authorization:a}})).data}catch(s){throw s.response?.status===401&&console.error("401 Unauthorized"),s}},cc=async(t,a)=>{const s=await rt.post(t,"",{headers:{Authorization:a}});if(s.data?.Status=="Success")return s?.data?.data||s?.data;throw new Error(s.data?.msg)},ts=async(t,a,s)=>{try{const i=await rt.post(t,a,{headers:{Authorization:s,"Content-Type":"application/json"}});return i.data?.Status==="Success"?i.data:(w.error(i.data?.msg||"Unable to issue library book",{duration:2e3}),!1)}catch(i){throw w.error(i.response?.data?.msg||i.response?.data?.message||"Request failed",{duration:2e3}),i}},Ya=async(t,a,s)=>{const i=a?.arg;return(await rt.post(t,i,{headers:{Authorization:s}}))?.data},Gt=async(t,a,s)=>{const i=a?.arg,o=t.includes("?")?"&":"?";return(await rt.get(t+o,{params:i,headers:{Authorization:s}}))?.data},uc="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",ar=async(t,a,s)=>{const i=a?.arg,o=t.includes("?")?"&":"?",l=await rt.get(t+o,{params:i,headers:{Authorization:s}});if(console.log("ddddfdfdfd",l.data?.Status),l.data?.Status=="Success")return l?.data?.data||l?.data;throw new Error(l.data?.msg)},Be=async(t,a,s)=>(await ic(),(await rt.post(t,a,{headers:{Authorization:s}}))?.data),ja=async(t,a,s)=>(await rt.post(t,a,{headers:{Authorization:s}})).data,qe=async(t,a,s)=>(await rt.delete(`${t}/${a}`,{headers:{Authorization:s}})).data,pc="api/report/LibraryRenewalReport/renewalHistory",mc="api/report/LibraryRenewalReport/renewalFineReport",hc="api/report/LibraryRenewalReport/currentlyRenewedBooks",fc="api/report/LibraryRenewalReport/upcomingRenewalDue",yc="api/report/LibraryRenewalReport/overdueRenewalReport",gc="api/report/LibraryRenewalReport/renewalLimitReport",xc="api/report/LibraryRenewalReport/renewalStatusReport",bc="api/report/LibraryRenewalReport/studentWiseReport",jc="api/report/LibraryRenewalReport/bookWiseReport",Sc="api/report/LibraryRenewalReport/classWiseReport",wc="api/report/LibraryRenewalReport/staffWiseReport",vc="api/report/LibraryRenewalReport/renewalStatisticsByDate",_c="/sample_templates/route_upload.xlsx",Xa="api/branchapi/academy/classdropdownlist",Za="api/branchapi/academy/sectionoftheClass",Cc="/sample_templates/student_transport_upload.xlsx",Ac="api/branchapi/income/incomeTableList",Dc="api/branchapi/income/addincome",Tc="api/branchapi/income/editincome",Rc="api/branchapi/income/deleteincome",No="api/branchapi/income/incomeheadDropdown",Ic="api/branchapi/income/incomeheadTableList",kc="api/branchapi/income/addincomehead",Pc="api/branchapi/income/editincomehead",Oc="api/branchapi/income/deleteincomehead",Mc="api/branchapi/income/incomeShowdata",Ec="api/branchapi/income/incomeheadShowdata",Fc="api/branchapi/income/searchincomebydates",Uc="api/branchapi/expense/expenseTableList",$c="api/branchapi/expense/addexpense",Nc="api/branchapi/expense/editexpense",Lc="api/branchapi/expense/deleteExpense",Lo="api/branchapi/expense/expenseheadDropdown",Bc="api/branchapi/expense/expenseheadTableList",qc="api/branchapi/expense/addexpensehead",zc="api/branchapi/expense/editexpensehead",Yc="api/branchapi/expense/deleteexpensehead",Vc="api/branchapi/expense/expenseShowdata",Wc="api/branchapi/expense/expenseheadShowdata",Hc="api/branchapi/expense/searchexpensebydates",Bo="api/accounts/vendor/vendorlist",Kc="api/student/studentDetails/studentLoginCredentialList",qo="/branchapi/student/studentlist",zo="api/branchapi/student/studentsearchbyKeywords",Yo="api/branchapi/student/studentsearchbyClassSection",Gc="/branchapi/student/addStudentMedicineDetails",Jc="/branchapi/student/StudentMedicineDetails",Vo="/branchapi/academy/getstudentClasssubjectByStudentId",Qc="/branchapi/academy/removeAssignStudentSubject",Ks="/branchapi/feesCollection/extraCurricularActivitiesFess",Xc="/branchapi/academy/unAssigneStudentSubject",Zc="/branchapi/student/uploadstudentbyCSV",eu="api/branchapi/academy/categorytableList",tu="api/branchapi/transport/downloadBulkTemplate",au="api/branchapi/transport/validateBulkUpload",nu="api/branchapi/transport/confirmBulkImport",su="api/branchapi/transport/downloadBulkErrorReport",ru=async({class_id:t,section_id:a}={},s)=>{const i=new URLSearchParams;t&&i.append("class_id",t),a&&i.append("section_id",a);const o=`${tu}${i.toString()?`?${i.toString()}`:""}`;return(await rt.get(o,{headers:{Authorization:s},responseType:"blob"})).data},iu=async(t,a)=>{const s=new FormData;return s.append("file",t),(await rt.post(au,s,{headers:{Authorization:a,"Content-Type":"multipart/form-data"}})).data},ou=async(t,a,s="skip")=>(await rt.post(nu,{rows:t,duplicate_action:s},{headers:{Authorization:a,"Content-Type":"application/json"}})).data,lu=async(t,a)=>(await rt.post(su,{rows:t},{headers:{Authorization:a,"Content-Type":"application/json"},responseType:"blob"})).data,du=({token:t,menu:a})=>{const{isLoading:s,data:i}=W(t?["api/sdk/Menus",t]:null,([l,d])=>cc(l,d)),o=i?.find(l=>l.path===a)?.sub_menu??[];return console.log("menuData",i),e.jsx(n.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(v,{children:e.jsx(yo,{icon:`${He()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function Wo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ze={},ys,Mr;function cu(){return Mr||(Mr=1,ys=function t(a,s){if(a===s)return!0;if(a&&s&&typeof a=="object"&&typeof s=="object"){if(a.constructor!==s.constructor)return!1;var i,o,l;if(Array.isArray(a)){if(i=a.length,i!=s.length)return!1;for(o=i;o--!==0;)if(!t(a[o],s[o]))return!1;return!0}if(a.constructor===RegExp)return a.source===s.source&&a.flags===s.flags;if(a.valueOf!==Object.prototype.valueOf)return a.valueOf()===s.valueOf();if(a.toString!==Object.prototype.toString)return a.toString()===s.toString();if(l=Object.keys(a),i=l.length,i!==Object.keys(s).length)return!1;for(o=i;o--!==0;)if(!Object.prototype.hasOwnProperty.call(s,l[o]))return!1;for(o=i;o--!==0;){var d=l[o];if(!t(a[d],s[d]))return!1}return!0}return a!==a&&s!==s}),ys}var mn={exports:{}},hn={exports:{}},Pe={};var Er;function uu(){if(Er)return Pe;Er=1;var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,y=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,C=t?Symbol.for("react.suspense_list"):60120,S=t?Symbol.for("react.memo"):60115,x=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,T=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function I(A){if(typeof A=="object"&&A!==null){var f=A.$$typeof;switch(f){case a:switch(A=A.type,A){case y:case h:case i:case l:case o:case p:return A;default:switch(A=A&&A.$$typeof,A){case c:case u:case x:case S:case d:return A;default:return f}}case s:return f}}}function _(A){return I(A)===h}return Pe.AsyncMode=y,Pe.ConcurrentMode=h,Pe.ContextConsumer=c,Pe.ContextProvider=d,Pe.Element=a,Pe.ForwardRef=u,Pe.Fragment=i,Pe.Lazy=x,Pe.Memo=S,Pe.Portal=s,Pe.Profiler=l,Pe.StrictMode=o,Pe.Suspense=p,Pe.isAsyncMode=function(A){return _(A)||I(A)===y},Pe.isConcurrentMode=_,Pe.isContextConsumer=function(A){return I(A)===c},Pe.isContextProvider=function(A){return I(A)===d},Pe.isElement=function(A){return typeof A=="object"&&A!==null&&A.$$typeof===a},Pe.isForwardRef=function(A){return I(A)===u},Pe.isFragment=function(A){return I(A)===i},Pe.isLazy=function(A){return I(A)===x},Pe.isMemo=function(A){return I(A)===S},Pe.isPortal=function(A){return I(A)===s},Pe.isProfiler=function(A){return I(A)===l},Pe.isStrictMode=function(A){return I(A)===o},Pe.isSuspense=function(A){return I(A)===p},Pe.isValidElementType=function(A){return typeof A=="string"||typeof A=="function"||A===i||A===h||A===l||A===o||A===p||A===C||typeof A=="object"&&A!==null&&(A.$$typeof===x||A.$$typeof===S||A.$$typeof===d||A.$$typeof===c||A.$$typeof===u||A.$$typeof===j||A.$$typeof===T||A.$$typeof===R||A.$$typeof===m)},Pe.typeOf=I,Pe}var Oe={};var Fr;function pu(){return Fr||(Fr=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,y=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,C=t?Symbol.for("react.suspense_list"):60120,S=t?Symbol.for("react.memo"):60115,x=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,T=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function I(le){return typeof le=="string"||typeof le=="function"||le===i||le===h||le===l||le===o||le===p||le===C||typeof le=="object"&&le!==null&&(le.$$typeof===x||le.$$typeof===S||le.$$typeof===d||le.$$typeof===c||le.$$typeof===u||le.$$typeof===j||le.$$typeof===T||le.$$typeof===R||le.$$typeof===m)}function _(le){if(typeof le=="object"&&le!==null){var de=le.$$typeof;switch(de){case a:var X=le.type;switch(X){case y:case h:case i:case l:case o:case p:return X;default:var ce=X&&X.$$typeof;switch(ce){case c:case u:case x:case S:case d:return ce;default:return de}}case s:return de}}}var A=y,f=h,g=c,D=d,k=a,L=u,B=i,b=x,P=S,O=s,F=l,U=o,N=p,Y=!1;function z(le){return Y||(Y=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),E(le)||_(le)===y}function E(le){return _(le)===h}function M(le){return _(le)===c}function $(le){return _(le)===d}function q(le){return typeof le=="object"&&le!==null&&le.$$typeof===a}function H(le){return _(le)===u}function re(le){return _(le)===i}function ee(le){return _(le)===x}function G(le){return _(le)===S}function J(le){return _(le)===s}function ie(le){return _(le)===l}function pe(le){return _(le)===o}function _e(le){return _(le)===p}Oe.AsyncMode=A,Oe.ConcurrentMode=f,Oe.ContextConsumer=g,Oe.ContextProvider=D,Oe.Element=k,Oe.ForwardRef=L,Oe.Fragment=B,Oe.Lazy=b,Oe.Memo=P,Oe.Portal=O,Oe.Profiler=F,Oe.StrictMode=U,Oe.Suspense=N,Oe.isAsyncMode=z,Oe.isConcurrentMode=E,Oe.isContextConsumer=M,Oe.isContextProvider=$,Oe.isElement=q,Oe.isForwardRef=H,Oe.isFragment=re,Oe.isLazy=ee,Oe.isMemo=G,Oe.isPortal=J,Oe.isProfiler=ie,Oe.isStrictMode=pe,Oe.isSuspense=_e,Oe.isValidElementType=I,Oe.typeOf=_})()),Oe}var Ur;function Ho(){return Ur||(Ur=1,process.env.NODE_ENV==="production"?hn.exports=uu():hn.exports=pu()),hn.exports}var gs,$r;function mu(){if($r)return gs;$r=1;var t=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function i(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function o(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var y=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(y.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(u){h[u]=u}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return gs=o()?Object.assign:function(l,d){for(var c,y=i(l),h,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var p in c)a.call(c,p)&&(y[p]=c[p]);if(t){h=t(c);for(var C=0;C<h.length;C++)s.call(c,h[C])&&(y[h[C]]=c[h[C]])}}return y},gs}var xs,Nr;function nr(){if(Nr)return xs;Nr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return xs=t,xs}var bs,Lr;function Ko(){return Lr||(Lr=1,bs=Function.call.bind(Object.prototype.hasOwnProperty)),bs}var js,Br;function hu(){if(Br)return js;Br=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var a=nr(),s={},i=Ko();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,y,h){if(process.env.NODE_ENV!=="production"){for(var u in l)if(i(l,u)){var p;try{if(typeof l[u]!="function"){var C=Error((y||"React class")+": "+c+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw C.name="Invariant Violation",C}p=l[u](d,u,y,c,null,a)}catch(x){p=x}if(p&&!(p instanceof Error)&&t((y||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof p+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),p instanceof Error&&!(p.message in s)){s[p.message]=!0;var S=h?h():"";t("Failed "+c+" type: "+p.message+(S??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(s={})},js=o,js}var Ss,qr;function fu(){if(qr)return Ss;qr=1;var t=Ho(),a=mu(),s=nr(),i=Ko(),o=hu(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var y="Warning: "+c;typeof console<"u"&&console.error(y);try{throw new Error(y)}catch{}});function d(){return null}return Ss=function(c,y){var h=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function p(E){var M=E&&(h&&E[h]||E[u]);if(typeof M=="function")return M}var C="<<anonymous>>",S={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:R(),arrayOf:I,element:_(),elementType:A(),instanceOf:f,node:L(),objectOf:D,oneOf:g,oneOfType:k,shape:b,exact:P};function x(E,M){return E===M?E!==0||1/E===1/M:E!==E&&M!==M}function m(E,M){this.message=E,this.data=M&&typeof M=="object"?M:{},this.stack=""}m.prototype=Error.prototype;function j(E){if(process.env.NODE_ENV!=="production")var M={},$=0;function q(re,ee,G,J,ie,pe,_e){if(J=J||C,pe=pe||G,_e!==s){if(y){var le=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw le.name="Invariant Violation",le}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var de=J+":"+G;!M[de]&&$<3&&(l("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+J+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),M[de]=!0,$++)}}return ee[G]==null?re?ee[G]===null?new m("The "+ie+" `"+pe+"` is marked as required "+("in `"+J+"`, but its value is `null`.")):new m("The "+ie+" `"+pe+"` is marked as required in "+("`"+J+"`, but its value is `undefined`.")):null:E(ee,G,J,ie,pe)}var H=q.bind(null,!1);return H.isRequired=q.bind(null,!0),H}function T(E){function M($,q,H,re,ee,G){var J=$[q],ie=U(J);if(ie!==E){var pe=N(J);return new m("Invalid "+re+" `"+ee+"` of type "+("`"+pe+"` supplied to `"+H+"`, expected ")+("`"+E+"`."),{expectedType:E})}return null}return j(M)}function R(){return j(d)}function I(E){function M($,q,H,re,ee){if(typeof E!="function")return new m("Property `"+ee+"` of component `"+H+"` has invalid PropType notation inside arrayOf.");var G=$[q];if(!Array.isArray(G)){var J=U(G);return new m("Invalid "+re+" `"+ee+"` of type "+("`"+J+"` supplied to `"+H+"`, expected an array."))}for(var ie=0;ie<G.length;ie++){var pe=E(G,ie,H,re,ee+"["+ie+"]",s);if(pe instanceof Error)return pe}return null}return j(M)}function _(){function E(M,$,q,H,re){var ee=M[$];if(!c(ee)){var G=U(ee);return new m("Invalid "+H+" `"+re+"` of type "+("`"+G+"` supplied to `"+q+"`, expected a single ReactElement."))}return null}return j(E)}function A(){function E(M,$,q,H,re){var ee=M[$];if(!t.isValidElementType(ee)){var G=U(ee);return new m("Invalid "+H+" `"+re+"` of type "+("`"+G+"` supplied to `"+q+"`, expected a single ReactElement type."))}return null}return j(E)}function f(E){function M($,q,H,re,ee){if(!($[q]instanceof E)){var G=E.name||C,J=z($[q]);return new m("Invalid "+re+" `"+ee+"` of type "+("`"+J+"` supplied to `"+H+"`, expected ")+("instance of `"+G+"`."))}return null}return j(M)}function g(E){if(!Array.isArray(E))return process.env.NODE_ENV!=="production"&&(arguments.length>1?l("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):l("Invalid argument supplied to oneOf, expected an array.")),d;function M($,q,H,re,ee){for(var G=$[q],J=0;J<E.length;J++)if(x(G,E[J]))return null;var ie=JSON.stringify(E,function(_e,le){var de=N(le);return de==="symbol"?String(le):le});return new m("Invalid "+re+" `"+ee+"` of value `"+String(G)+"` "+("supplied to `"+H+"`, expected one of "+ie+"."))}return j(M)}function D(E){function M($,q,H,re,ee){if(typeof E!="function")return new m("Property `"+ee+"` of component `"+H+"` has invalid PropType notation inside objectOf.");var G=$[q],J=U(G);if(J!=="object")return new m("Invalid "+re+" `"+ee+"` of type "+("`"+J+"` supplied to `"+H+"`, expected an object."));for(var ie in G)if(i(G,ie)){var pe=E(G,ie,H,re,ee+"."+ie,s);if(pe instanceof Error)return pe}return null}return j(M)}function k(E){if(!Array.isArray(E))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var M=0;M<E.length;M++){var $=E[M];if(typeof $!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Y($)+" at index "+M+"."),d}function q(H,re,ee,G,J){for(var ie=[],pe=0;pe<E.length;pe++){var _e=E[pe],le=_e(H,re,ee,G,J,s);if(le==null)return null;le.data&&i(le.data,"expectedType")&&ie.push(le.data.expectedType)}var de=ie.length>0?", expected one of type ["+ie.join(", ")+"]":"";return new m("Invalid "+G+" `"+J+"` supplied to "+("`"+ee+"`"+de+"."))}return j(q)}function L(){function E(M,$,q,H,re){return O(M[$])?null:new m("Invalid "+H+" `"+re+"` supplied to "+("`"+q+"`, expected a ReactNode."))}return j(E)}function B(E,M,$,q,H){return new m((E||"React class")+": "+M+" type `"+$+"."+q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+H+"`.")}function b(E){function M($,q,H,re,ee){var G=$[q],J=U(G);if(J!=="object")return new m("Invalid "+re+" `"+ee+"` of type `"+J+"` "+("supplied to `"+H+"`, expected `object`."));for(var ie in E){var pe=E[ie];if(typeof pe!="function")return B(H,re,ee,ie,N(pe));var _e=pe(G,ie,H,re,ee+"."+ie,s);if(_e)return _e}return null}return j(M)}function P(E){function M($,q,H,re,ee){var G=$[q],J=U(G);if(J!=="object")return new m("Invalid "+re+" `"+ee+"` of type `"+J+"` "+("supplied to `"+H+"`, expected `object`."));var ie=a({},$[q],E);for(var pe in ie){var _e=E[pe];if(i(E,pe)&&typeof _e!="function")return B(H,re,ee,pe,N(_e));if(!_e)return new m("Invalid "+re+" `"+ee+"` key `"+pe+"` supplied to `"+H+"`.\nBad object: "+JSON.stringify($[q],null," ")+`
10
- Valid keys: `+JSON.stringify(Object.keys(E),null," "));var le=_e(G,pe,H,re,ee+"."+pe,s);if(le)return le}return null}return j(M)}function O(E){switch(typeof E){case"number":case"string":case"undefined":return!0;case"boolean":return!E;case"object":if(Array.isArray(E))return E.every(O);if(E===null||c(E))return!0;var M=p(E);if(M){var $=M.call(E),q;if(M!==E.entries){for(;!(q=$.next()).done;)if(!O(q.value))return!1}else for(;!(q=$.next()).done;){var H=q.value;if(H&&!O(H[1]))return!1}}else return!1;return!0;default:return!1}}function F(E,M){return E==="symbol"?!0:M?M["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&M instanceof Symbol:!1}function U(E){var M=typeof E;return Array.isArray(E)?"array":E instanceof RegExp?"object":F(M,E)?"symbol":M}function N(E){if(typeof E>"u"||E===null)return""+E;var M=U(E);if(M==="object"){if(E instanceof Date)return"date";if(E instanceof RegExp)return"regexp"}return M}function Y(E){var M=N(E);switch(M){case"array":case"object":return"an "+M;case"boolean":case"date":case"regexp":return"a "+M;default:return M}}function z(E){return!E.constructor||!E.constructor.name?C:E.constructor.name}return S.checkPropTypes=o,S.resetWarningCache=o.resetWarningCache,S.PropTypes=S,S},Ss}var ws,zr;function yu(){if(zr)return ws;zr=1;var t=nr();function a(){}function s(){}return s.resetWarningCache=a,ws=function(){function i(d,c,y,h,u,p){if(p!==t){var C=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 C.name="Invariant Violation",C}}i.isRequired=i;function o(){return i}var l={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:o,element:i,elementType:i,instanceOf:o,node:i,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:s,resetWarningCache:a};return l.PropTypes=l,l},ws}var Yr;function Go(){if(Yr)return mn.exports;if(Yr=1,process.env.NODE_ENV!=="production"){var t=Ho(),a=!0;mn.exports=fu()(t.isElement,a)}else mn.exports=yu()();return mn.exports}var Vr;function gu(){if(Vr)return Ze;Vr=1;var t=Ze&&Ze.__extends||(function(){var S=function(x,m){return S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(j,T){j.__proto__=T}||function(j,T){for(var R in T)Object.prototype.hasOwnProperty.call(T,R)&&(j[R]=T[R])},S(x,m)};return function(x,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");S(x,m);function j(){this.constructor=x}x.prototype=m===null?Object.create(m):(j.prototype=m.prototype,new j)}})(),a=Ze&&Ze.__assign||function(){return a=Object.assign||function(S){for(var x,m=1,j=arguments.length;m<j;m++){x=arguments[m];for(var T in x)Object.prototype.hasOwnProperty.call(x,T)&&(S[T]=x[T])}return S},a.apply(this,arguments)},s=Ze&&Ze.__createBinding||(Object.create?(function(S,x,m,j){j===void 0&&(j=m);var T=Object.getOwnPropertyDescriptor(x,m);(!T||("get"in T?!x.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return x[m]}}),Object.defineProperty(S,j,T)}):(function(S,x,m,j){j===void 0&&(j=m),S[j]=x[m]})),i=Ze&&Ze.__setModuleDefault||(Object.create?(function(S,x){Object.defineProperty(S,"default",{enumerable:!0,value:x})}):function(S,x){S.default=x}),o=Ze&&Ze.__importStar||function(S){if(S&&S.__esModule)return S;var x={};if(S!=null)for(var m in S)m!=="default"&&Object.prototype.hasOwnProperty.call(S,m)&&s(x,S,m);return i(x,S),x},l=Ze&&Ze.__rest||function(S,x){var m={};for(var j in S)Object.prototype.hasOwnProperty.call(S,j)&&x.indexOf(j)<0&&(m[j]=S[j]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function")for(var T=0,j=Object.getOwnPropertySymbols(S);T<j.length;T++)x.indexOf(j[T])<0&&Object.prototype.propertyIsEnumerable.call(S,j[T])&&(m[j[T]]=S[j[T]]);return m},d=Ze&&Ze.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(Ze,"__esModule",{value:!0});var c=o(r),y=d(cu()),h=o(Go());function u(S){return S&&S.replace(/&nbsp;|\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function p(S){var x=document.createTextNode("");S.appendChild(x);var m=document.activeElement===S;if(x!==null&&x.nodeValue!==null&&m){var j=window.getSelection();if(j!==null){var T=document.createRange();T.setStart(x,x.nodeValue.length),T.collapse(!0),j.removeAllRanges(),j.addRange(T)}S instanceof HTMLElement&&S.focus()}}var C=(function(S){t(x,S);function x(){var m=S!==null&&S.apply(this,arguments)||this;return m.lastHtml=m.props.html,m.el=typeof m.props.innerRef=="function"?{current:null}:c.createRef(),m.getEl=function(){return(m.props.innerRef&&typeof m.props.innerRef!="function"?m.props.innerRef:m.el).current},m.emitChange=function(j){var T=m.getEl();if(T){var R=T.innerHTML;if(m.props.onChange&&R!==m.lastHtml){var I=Object.assign({},j,{target:{value:R}});m.props.onChange(I)}m.lastHtml=R}},m}return x.prototype.render=function(){var m=this,j=this.props,T=j.tagName,R=j.html,I=j.innerRef,_=l(j,["tagName","html","innerRef"]);return c.createElement(T||"div",a(a({},_),{ref:typeof I=="function"?function(A){I(A),m.el.current=A}:I||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)},x.prototype.shouldComponentUpdate=function(m){var j=this.props,T=this.getEl();return!T||u(m.html)!==u(T.innerHTML)?!0:j.disabled!==m.disabled||j.tagName!==m.tagName||j.className!==m.className||j.innerRef!==m.innerRef||j.placeholder!==m.placeholder||!(0,y.default)(j.style,m.style)},x.prototype.componentDidUpdate=function(){var m=this.getEl();m&&(this.props.html!==m.innerHTML&&(m.innerHTML=this.props.html),this.lastHtml=this.props.html,p(m))},x.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])},x})(c.Component);return Ze.default=C,Ze}var xu=gu();const Jo=Wo(xu),bu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ju={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"},V=r.forwardRef(({style:t,onFocus:a,onBlur:s,...i},o)=>{const[l,d]=r.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[i.label&&e.jsx("label",{className:"labelfont",style:bu,children:i.label}),e.jsx("input",{placeholder:i.placeholder||i.label,...i,ref:o,onFocus:c=>{d(!0),a?.(c)},onBlur:c=>{d(!1),s?.(c)},style:{...ju,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),Wr=[{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 sr(t){const a=ae().year(),s=[];for(let i=a;i>=a-t;i--)s.push({label:String(i),value:i});return s}function et(t){switch(t){case"late":return e.jsx("span",{className:"label label-late",children:"L"});case"present":return e.jsx("span",{className:"label label-success",children:"P"});case"absent":return e.jsx("span",{className:"label label-danger",children:"A"});case"P":return e.jsx("span",{className:"monthlyLabel label-success",children:"P"});case"A":return e.jsx("span",{className:"monthlyLabel label-danger",children:"A"});case"L":return e.jsx("span",{className:"monthlyLabel label-late",children:"L"});case"W":return e.jsx("span",{className:"monthlyLabel sunday",children:"W"});case"H":return e.jsx("span",{className:"monthlyLabel holiday",children:"H"});default:return e.jsx("span",{className:"label",children:t})}}function rr(t){const a=ae().year(),s=ae().month();return t<a?Wr:Wr.slice(0,s+1)}function Hr(t,a){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:a});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:a});default:return e.jsx("span",{className:"monthlyLabel",children:a})}}function Su(){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 Qo=t=>{switch(t){case"paid":return e.jsx("div",{style:{background:"#3cb371",color:"white",textAlign:"center"},children:"PAID"});case"due":return e.jsx("div",{style:{background:"red",color:"white",textAlign:"center"},children:"DUE"});case"partially_paid":return e.jsx("div",{style:{background:"#ff8d00",color:"white",textAlign:"center"},children:"Partially Paid"});case"Present":return e.jsx(n.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(n.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(n.Tag,{color:"error",children:"No Attendance"});case"one_time":return"ONETIME";case"monthly":return"MONTHLY";case"half_yearly":return"HALF YEARLY";case"quarterly":return"QUARTERLY";default:return""}},Tt=t=>{const a=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[a?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var Ca={},Aa={},ft={},Da={},ta={},Kr;function wu(){if(Kr)return ta;Kr=1;var t=ta&&ta.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(ta,"__esModule",{value:!0});const a=t(r),s=vl,i=["string","number","boolean"];function o({header:l,body:d}){const c=a.default.createElement("tr",null,l.map(h=>a.default.createElement("th",{key:h},h))),y=d.map((h,u)=>Array.isArray(h)?a.default.createElement("tr",{key:u},h.map((p,C)=>a.default.createElement("th",{key:C}," ",p," "))):h!==null&&typeof h=="object"?a.default.createElement("tr",{key:u},Object.entries(h).map(([p,C],S)=>typeof C=="object"?(console.error(`typeof ${p} is incorrect, only accept ${i.join(", ")} `),a.default.createElement("th",{key:S})):a.default.createElement("th",{key:S},a.default.createElement(a.default.Fragment,null,C)))):(console.error(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("antd"),H=require("swr"),w=require("react-hot-toast"),i=require("react"),rt=require("swr/mutation"),ee=require("@ant-design/icons"),te=require("dayjs"),Mo=require("react-dom/server"),ea=require("react-to-print"),yl=require("react-select"),gl=require("react-barcode"),Eo=()=>e.jsxs(n.Card,{style:{borderRadius:16},children:[e.jsx(n.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),v=({width:t,height:a,display:s,justifyContent:r,alignItems:l,flexDirection:o,gap:d,style:c,children:g,...y})=>{const p={width:t,height:a,display:s,justifyContent:r,alignItems:l,flexDirection:o,gap:d,...c};return e.jsx("div",{style:p,...y,children:g})},pe=({variant:t,fontWeight:a,style:s,children:r,...l})=>{const o=a==="bold"?700:a==="light"?300:a;return t==="h1"?e.jsx(n.Typography.Title,{level:1,style:{fontWeight:o,...s},...l,children:r}):t==="h2"?e.jsx(n.Typography.Title,{level:2,style:{fontWeight:o,...s},...l,children:r}):t==="h3"?e.jsx(n.Typography.Title,{level:3,style:{fontWeight:o,...s},...l,children:r}):t==="h4"?e.jsx(n.Typography.Title,{level:4,style:{fontWeight:o,...s},...l,children:r}):t==="h5"?e.jsx(n.Typography.Title,{level:5,style:{fontWeight:o,...s},...l,children:r}):e.jsx(n.Typography.Text,{style:{fontWeight:o,...s},...l,children:r})};function xl({title:t="",icon:a="",path:s="",onClick:r}){const l=()=>{if(r){r(s);return}typeof window<"u"&&typeof s=="string"&&s.length>0&&window.location.assign(s)};return e.jsxs(n.Card,{hoverable:!0,onClick:l,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(v,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:a,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(v,{style:{padding:"0 12px"},children:e.jsx(n.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(v,{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 bl(t,a){return function(){return t.apply(a,arguments)}}const{toString:$o}=Object.prototype,{getPrototypeOf:Xn}=Object,{iterator:Zn,toStringTag:jl}=Symbol,es=(t=>a=>{const s=$o.call(a);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Dt=t=>(t=t.toLowerCase(),a=>es(a)===t),ts=t=>a=>typeof a===t,{isArray:ja}=Array,ga=ts("undefined");function Ja(t){return t!==null&&!ga(t)&&t.constructor!==null&&!ga(t.constructor)&&ht(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Sl=Dt("ArrayBuffer");function Fo(t){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(t):a=t&&t.buffer&&Sl(t.buffer),a}const Uo=ts("string"),ht=ts("function"),vl=ts("number"),Qa=t=>t!==null&&typeof t=="object",No=t=>t===!0||t===!1,On=t=>{if(es(t)!=="object")return!1;const a=Xn(t);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(jl in t)&&!(Zn in t)},Bo=t=>{if(!Qa(t)||Ja(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Lo=Dt("Date"),qo=Dt("File"),zo=t=>!!(t&&typeof t.uri<"u"),Yo=t=>t&&typeof t.getParts<"u",Vo=Dt("Blob"),Wo=Dt("FileList"),Ho=t=>Qa(t)&&ht(t.pipe);function Ko(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const fr=Ko(),yr=typeof fr.FormData<"u"?fr.FormData:void 0,Go=t=>{if(!t)return!1;if(yr&&t instanceof yr)return!0;const a=Xn(t);if(!a||a===Object.prototype||!ht(t.append))return!1;const s=es(t);return s==="formdata"||s==="object"&&ht(t.toString)&&t.toString()==="[object FormData]"},Jo=Dt("URLSearchParams"),[Qo,Xo,Zo,ed]=["ReadableStream","Request","Response","Headers"].map(Dt),td=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Xa(t,a,{allOwnKeys:s=!1}={}){if(t===null||typeof t>"u")return;let r,l;if(typeof t!="object"&&(t=[t]),ja(t))for(r=0,l=t.length;r<l;r++)a.call(null,t[r],r,t);else{if(Ja(t))return;const o=s?Object.getOwnPropertyNames(t):Object.keys(t),d=o.length;let c;for(r=0;r<d;r++)c=o[r],a.call(null,t[c],c,t)}}function wl(t,a){if(Ja(t))return null;a=a.toLowerCase();const s=Object.keys(t);let r=s.length,l;for(;r-- >0;)if(l=s[r],a===l.toLowerCase())return l;return null}const Gt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,_l=t=>!ga(t)&&t!==Gt;function Ys(){const{caseless:t,skipUndefined:a}=_l(this)&&this||{},s={},r=(l,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const d=t&&wl(s,o)||o;On(s[d])&&On(l)?s[d]=Ys(s[d],l):On(l)?s[d]=Ys({},l):ja(l)?s[d]=l.slice():(!a||!ga(l))&&(s[d]=l)};for(let l=0,o=arguments.length;l<o;l++)arguments[l]&&Xa(arguments[l],r);return s}const ad=(t,a,s,{allOwnKeys:r}={})=>(Xa(a,(l,o)=>{s&&ht(l)?Object.defineProperty(t,o,{value:bl(l,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,o,{value:l,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),nd=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),sd=(t,a,s,r)=>{t.prototype=Object.create(a.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:a.prototype}),s&&Object.assign(t.prototype,s)},rd=(t,a,s,r)=>{let l,o,d;const c={};if(a=a||{},t==null)return a;do{for(l=Object.getOwnPropertyNames(t),o=l.length;o-- >0;)d=l[o],(!r||r(d,t,a))&&!c[d]&&(a[d]=t[d],c[d]=!0);t=s!==!1&&Xn(t)}while(t&&(!s||s(t,a))&&t!==Object.prototype);return a},id=(t,a,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=a.length;const r=t.indexOf(a,s);return r!==-1&&r===s},ld=t=>{if(!t)return null;if(ja(t))return t;let a=t.length;if(!vl(a))return null;const s=new Array(a);for(;a-- >0;)s[a]=t[a];return s},od=(t=>a=>t&&a instanceof t)(typeof Uint8Array<"u"&&Xn(Uint8Array)),dd=(t,a)=>{const r=(t&&t[Zn]).call(t);let l;for(;(l=r.next())&&!l.done;){const o=l.value;a.call(t,o[0],o[1])}},cd=(t,a)=>{let s;const r=[];for(;(s=t.exec(a))!==null;)r.push(s);return r},ud=Dt("HTMLFormElement"),pd=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,r,l){return r.toUpperCase()+l}),gr=(({hasOwnProperty:t})=>(a,s)=>t.call(a,s))(Object.prototype),md=Dt("RegExp"),Cl=(t,a)=>{const s=Object.getOwnPropertyDescriptors(t),r={};Xa(s,(l,o)=>{let d;(d=a(l,o,t))!==!1&&(r[o]=d||l)}),Object.defineProperties(t,r)},hd=t=>{Cl(t,(a,s)=>{if(ht(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const r=t[s];if(ht(r)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},fd=(t,a)=>{const s={},r=l=>{l.forEach(o=>{s[o]=!0})};return ja(t)?r(t):r(String(t).split(a)),s},yd=()=>{},gd=(t,a)=>t!=null&&Number.isFinite(t=+t)?t:a;function xd(t){return!!(t&&ht(t.append)&&t[jl]==="FormData"&&t[Zn])}const bd=t=>{const a=new Array(10),s=(r,l)=>{if(Qa(r)){if(a.indexOf(r)>=0)return;if(Ja(r))return r;if(!("toJSON"in r)){a[l]=r;const o=ja(r)?[]:{};return Xa(r,(d,c)=>{const g=s(d,l+1);!ga(g)&&(o[c]=g)}),a[l]=void 0,o}}return r};return s(t,0)},jd=Dt("AsyncFunction"),Sd=t=>t&&(Qa(t)||ht(t))&&ht(t.then)&&ht(t.catch),Al=((t,a)=>t?setImmediate:a?((s,r)=>(Gt.addEventListener("message",({source:l,data:o})=>{l===Gt&&o===s&&r.length&&r.shift()()},!1),l=>{r.push(l),Gt.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",ht(Gt.postMessage)),vd=typeof queueMicrotask<"u"?queueMicrotask.bind(Gt):typeof process<"u"&&process.nextTick||Al,wd=t=>t!=null&&ht(t[Zn]),Z={isArray:ja,isArrayBuffer:Sl,isBuffer:Ja,isFormData:Go,isArrayBufferView:Fo,isString:Uo,isNumber:vl,isBoolean:No,isObject:Qa,isPlainObject:On,isEmptyObject:Bo,isReadableStream:Qo,isRequest:Xo,isResponse:Zo,isHeaders:ed,isUndefined:ga,isDate:Lo,isFile:qo,isReactNativeBlob:zo,isReactNative:Yo,isBlob:Vo,isRegExp:md,isFunction:ht,isStream:Ho,isURLSearchParams:Jo,isTypedArray:od,isFileList:Wo,forEach:Xa,merge:Ys,extend:ad,trim:td,stripBOM:nd,inherits:sd,toFlatObject:rd,kindOf:es,kindOfTest:Dt,endsWith:id,toArray:ld,forEachEntry:dd,matchAll:cd,isHTMLForm:ud,hasOwnProperty:gr,hasOwnProp:gr,reduceDescriptors:Cl,freezeMethods:hd,toObjectSet:fd,toCamelCase:pd,noop:yd,toFiniteNumber:gd,findKey:wl,global:Gt,isContextDefined:_l,isSpecCompliantForm:xd,toJSONObject:bd,isAsyncFn:jd,isThenable:Sd,setImmediate:Al,asap:vd,isIterable:wd};let Te=class Dl extends Error{static from(a,s,r,l,o,d){const c=new Dl(a.message,s||a.code,r,l,o);return c.cause=a,c.name=a.name,a.status!=null&&c.status==null&&(c.status=a.status),d&&Object.assign(c,d),c}constructor(a,s,r,l,o){super(a),Object.defineProperty(this,"message",{value:a,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,s&&(this.code=s),r&&(this.config=r),l&&(this.request=l),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Z.toJSONObject(this.config),code:this.code,status:this.status}}};Te.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Te.ERR_BAD_OPTION="ERR_BAD_OPTION";Te.ECONNABORTED="ECONNABORTED";Te.ETIMEDOUT="ETIMEDOUT";Te.ERR_NETWORK="ERR_NETWORK";Te.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Te.ERR_DEPRECATED="ERR_DEPRECATED";Te.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Te.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Te.ERR_CANCELED="ERR_CANCELED";Te.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Te.ERR_INVALID_URL="ERR_INVALID_URL";Te.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const _d=null;function Vs(t){return Z.isPlainObject(t)||Z.isArray(t)}function Tl(t){return Z.endsWith(t,"[]")?t.slice(0,-2):t}function fs(t,a,s){return t?t.concat(a).map(function(l,o){return l=Tl(l),!s&&o?"["+l+"]":l}).join(s?".":""):a}function Cd(t){return Z.isArray(t)&&!t.some(Vs)}const Ad=Z.toFlatObject(Z,{},null,function(a){return/^is[A-Z]/.test(a)});function as(t,a,s){if(!Z.isObject(t))throw new TypeError("target must be an object");a=a||new FormData,s=Z.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,R){return!Z.isUndefined(R[x])});const r=s.metaTokens,l=s.visitor||m,o=s.dots,d=s.indexes,c=s.Blob||typeof Blob<"u"&&Blob,g=s.maxDepth===void 0?100:s.maxDepth,y=c&&Z.isSpecCompliantForm(a);if(!Z.isFunction(l))throw new TypeError("visitor must be a function");function p(f){if(f===null)return"";if(Z.isDate(f))return f.toISOString();if(Z.isBoolean(f))return f.toString();if(!y&&Z.isBlob(f))throw new Te("Blob is not supported. Use a Buffer instead.");return Z.isArrayBuffer(f)||Z.isTypedArray(f)?y&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function m(f,x,R){let k=f;if(Z.isReactNative(a)&&Z.isReactNativeBlob(f))return a.append(fs(R,x,o),p(f)),!1;if(f&&!R&&typeof f=="object"){if(Z.endsWith(x,"{}"))x=r?x:x.slice(0,-2),f=JSON.stringify(f);else if(Z.isArray(f)&&Cd(f)||(Z.isFileList(f)||Z.endsWith(x,"[]"))&&(k=Z.toArray(f)))return x=Tl(x),k.forEach(function(D,_){!(Z.isUndefined(D)||D===null)&&a.append(d===!0?fs([x],_,o):d===null?x:x+"[]",p(D))}),!1}return Vs(f)?!0:(a.append(fs(R,x,o),p(f)),!1)}const A=[],C=Object.assign(Ad,{defaultVisitor:m,convertValue:p,isVisitable:Vs});function b(f,x,R=0){if(!Z.isUndefined(f)){if(R>g)throw new Te("Object is too deeply nested ("+R+" levels). Max depth: "+g,Te.ERR_FORM_DATA_DEPTH_EXCEEDED);if(A.indexOf(f)!==-1)throw Error("Circular reference detected in "+x.join("."));A.push(f),Z.forEach(f,function(O,D){(!(Z.isUndefined(O)||O===null)&&l.call(a,O,Z.isString(D)?D.trim():D,x,C))===!0&&b(O,x?x.concat(D):[D],R+1)}),A.pop()}}if(!Z.isObject(t))throw new TypeError("data must be an object");return b(t),a}function xr(t){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return a[r]})}function Xs(t,a){this._pairs=[],t&&as(t,this,a)}const Rl=Xs.prototype;Rl.append=function(a,s){this._pairs.push([a,s])};Rl.toString=function(a){const s=a?function(r){return a.call(this,r,xr)}:xr;return this._pairs.map(function(l){return s(l[0])+"="+s(l[1])},"").join("&")};function Dd(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Il(t,a,s){if(!a)return t;const r=s&&s.encode||Dd,l=Z.isFunction(s)?{serialize:s}:s,o=l&&l.serialize;let d;if(o?d=o(a,l):d=Z.isURLSearchParams(a)?a.toString():new Xs(a,l).toString(r),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class br{constructor(){this.handlers=[]}use(a,s,r){return this.handlers.push({fulfilled:a,rejected:s,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){Z.forEach(this.handlers,function(r){r!==null&&a(r)})}}const Zs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Td=typeof URLSearchParams<"u"?URLSearchParams:Xs,Rd=typeof FormData<"u"?FormData:null,Id=typeof Blob<"u"?Blob:null,kd={isBrowser:!0,classes:{URLSearchParams:Td,FormData:Rd,Blob:Id},protocols:["http","https","file","blob","url","data"]},er=typeof window<"u"&&typeof document<"u",Ws=typeof navigator=="object"&&navigator||void 0,Pd=er&&(!Ws||["ReactNative","NativeScript","NS"].indexOf(Ws.product)<0),Od=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Md=er&&window.location.href||"http://localhost",Ed=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:er,hasStandardBrowserEnv:Pd,hasStandardBrowserWebWorkerEnv:Od,navigator:Ws,origin:Md},Symbol.toStringTag,{value:"Module"})),it={...Ed,...kd};function $d(t,a){return as(t,new it.classes.URLSearchParams,{visitor:function(s,r,l,o){return it.isNode&&Z.isBuffer(s)?(this.append(r,s.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...a})}function Fd(t){return Z.matchAll(/\w+|\[(\w*)]/g,t).map(a=>a[0]==="[]"?"":a[1]||a[0])}function Ud(t){const a={},s=Object.keys(t);let r;const l=s.length;let o;for(r=0;r<l;r++)o=s[r],a[o]=t[o];return a}function kl(t){function a(s,r,l,o){let d=s[o++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),g=o>=s.length;return d=!d&&Z.isArray(l)?l.length:d,g?(Z.hasOwnProp(l,d)?l[d]=Z.isArray(l[d])?l[d].concat(r):[l[d],r]:l[d]=r,!c):((!l[d]||!Z.isObject(l[d]))&&(l[d]=[]),a(s,r,l[d],o)&&Z.isArray(l[d])&&(l[d]=Ud(l[d])),!c)}if(Z.isFormData(t)&&Z.isFunction(t.entries)){const s={};return Z.forEachEntry(t,(r,l)=>{a(Fd(r),l,s,0)}),s}return null}const na=(t,a)=>t!=null&&Z.hasOwnProp(t,a)?t[a]:void 0;function Nd(t,a,s){if(Z.isString(t))try{return(a||JSON.parse)(t),Z.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(s||JSON.stringify)(t)}const Za={transitional:Zs,adapter:["xhr","http","fetch"],transformRequest:[function(a,s){const r=s.getContentType()||"",l=r.indexOf("application/json")>-1,o=Z.isObject(a);if(o&&Z.isHTMLForm(a)&&(a=new FormData(a)),Z.isFormData(a))return l?JSON.stringify(kl(a)):a;if(Z.isArrayBuffer(a)||Z.isBuffer(a)||Z.isStream(a)||Z.isFile(a)||Z.isBlob(a)||Z.isReadableStream(a))return a;if(Z.isArrayBufferView(a))return a.buffer;if(Z.isURLSearchParams(a))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let c;if(o){const g=na(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return $d(a,g).toString();if((c=Z.isFileList(a))||r.indexOf("multipart/form-data")>-1){const y=na(this,"env"),p=y&&y.FormData;return as(c?{"files[]":a}:a,p&&new p,g)}}return o||l?(s.setContentType("application/json",!1),Nd(a)):a}],transformResponse:[function(a){const s=na(this,"transitional")||Za.transitional,r=s&&s.forcedJSONParsing,l=na(this,"responseType"),o=l==="json";if(Z.isResponse(a)||Z.isReadableStream(a))return a;if(a&&Z.isString(a)&&(r&&!l||o)){const c=!(s&&s.silentJSONParsing)&&o;try{return JSON.parse(a,na(this,"parseReviver"))}catch(g){if(c)throw g.name==="SyntaxError"?Te.from(g,Te.ERR_BAD_RESPONSE,this,null,na(this,"response")):g}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:it.classes.FormData,Blob:it.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Z.forEach(["delete","get","head","post","put","patch"],t=>{Za.headers[t]={}});const Bd=Z.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Ld=t=>{const a={};let s,r,l;return t&&t.split(`
2
+ `).forEach(function(d){l=d.indexOf(":"),s=d.substring(0,l).trim().toLowerCase(),r=d.substring(l+1).trim(),!(!s||a[s]&&Bd[s])&&(s==="set-cookie"?a[s]?a[s].push(r):a[s]=[r]:a[s]=a[s]?a[s]+", "+r:r)}),a},jr=Symbol("internals"),qd=/[^\x09\x20-\x7E\x80-\xFF]/g;function zd(t){let a=0,s=t.length;for(;a<s;){const r=t.charCodeAt(a);if(r!==9&&r!==32)break;a+=1}for(;s>a;){const r=t.charCodeAt(s-1);if(r!==9&&r!==32)break;s-=1}return a===0&&s===t.length?t:t.slice(a,s)}function Ca(t){return t&&String(t).trim().toLowerCase()}function Yd(t){return zd(t.replace(qd,""))}function Mn(t){return t===!1||t==null?t:Z.isArray(t)?t.map(Mn):Yd(String(t))}function Vd(t){const a=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=s.exec(t);)a[r[1]]=r[2];return a}const Wd=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function ys(t,a,s,r,l){if(Z.isFunction(r))return r.call(this,a,s);if(l&&(a=s),!!Z.isString(a)){if(Z.isString(r))return a.indexOf(r)!==-1;if(Z.isRegExp(r))return r.test(a)}}function Hd(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,s,r)=>s.toUpperCase()+r)}function Kd(t,a){const s=Z.toCamelCase(" "+a);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+s,{value:function(l,o,d){return this[r].call(this,a,l,o,d)},configurable:!0})})}let ft=class{constructor(a){a&&this.set(a)}set(a,s,r){const l=this;function o(c,g,y){const p=Ca(g);if(!p)throw new Error("header name must be a non-empty string");const m=Z.findKey(l,p);(!m||l[m]===void 0||y===!0||y===void 0&&l[m]!==!1)&&(l[m||g]=Mn(c))}const d=(c,g)=>Z.forEach(c,(y,p)=>o(y,p,g));if(Z.isPlainObject(a)||a instanceof this.constructor)d(a,s);else if(Z.isString(a)&&(a=a.trim())&&!Wd(a))d(Ld(a),s);else if(Z.isObject(a)&&Z.isIterable(a)){let c={},g,y;for(const p of a){if(!Z.isArray(p))throw TypeError("Object iterator must return a key-value pair");c[y=p[0]]=(g=c[y])?Z.isArray(g)?[...g,p[1]]:[g,p[1]]:p[1]}d(c,s)}else a!=null&&o(s,a,r);return this}get(a,s){if(a=Ca(a),a){const r=Z.findKey(this,a);if(r){const l=this[r];if(!s)return l;if(s===!0)return Vd(l);if(Z.isFunction(s))return s.call(this,l,r);if(Z.isRegExp(s))return s.exec(l);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,s){if(a=Ca(a),a){const r=Z.findKey(this,a);return!!(r&&this[r]!==void 0&&(!s||ys(this,this[r],r,s)))}return!1}delete(a,s){const r=this;let l=!1;function o(d){if(d=Ca(d),d){const c=Z.findKey(r,d);c&&(!s||ys(r,r[c],c,s))&&(delete r[c],l=!0)}}return Z.isArray(a)?a.forEach(o):o(a),l}clear(a){const s=Object.keys(this);let r=s.length,l=!1;for(;r--;){const o=s[r];(!a||ys(this,this[o],o,a,!0))&&(delete this[o],l=!0)}return l}normalize(a){const s=this,r={};return Z.forEach(this,(l,o)=>{const d=Z.findKey(r,o);if(d){s[d]=Mn(l),delete s[o];return}const c=a?Hd(o):String(o).trim();c!==o&&delete s[o],s[c]=Mn(l),r[c]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const s=Object.create(null);return Z.forEach(this,(r,l)=>{r!=null&&r!==!1&&(s[l]=a&&Z.isArray(r)?r.join(", "):r)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,s])=>a+": "+s).join(`
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...s){const r=new this(a);return s.forEach(l=>r.set(l)),r}static accessor(a){const r=(this[jr]=this[jr]={accessors:{}}).accessors,l=this.prototype;function o(d){const c=Ca(d);r[c]||(Kd(l,d),r[c]=!0)}return Z.isArray(a)?a.forEach(o):o(a),this}};ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Z.reduceDescriptors(ft.prototype,({value:t},a)=>{let s=a[0].toUpperCase()+a.slice(1);return{get:()=>t,set(r){this[s]=r}}});Z.freezeMethods(ft);function gs(t,a){const s=this||Za,r=a||s,l=ft.from(r.headers);let o=r.data;return Z.forEach(t,function(c){o=c.call(s,o,l.normalize(),a?a.status:void 0)}),l.normalize(),o}function Pl(t){return!!(t&&t.__CANCEL__)}let en=class extends Te{constructor(a,s,r){super(a??"canceled",Te.ERR_CANCELED,s,r),this.name="CanceledError",this.__CANCEL__=!0}};function Ol(t,a,s){const r=s.config.validateStatus;!s.status||!r||r(s.status)?t(s):a(new Te("Request failed with status code "+s.status,[Te.ERR_BAD_REQUEST,Te.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function Gd(t){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return a&&a[1]||""}function Jd(t,a){t=t||10;const s=new Array(t),r=new Array(t);let l=0,o=0,d;return a=a!==void 0?a:1e3,function(g){const y=Date.now(),p=r[o];d||(d=y),s[l]=g,r[l]=y;let m=o,A=0;for(;m!==l;)A+=s[m++],m=m%t;if(l=(l+1)%t,l===o&&(o=(o+1)%t),y-d<a)return;const C=p&&y-p;return C?Math.round(A*1e3/C):void 0}}function Qd(t,a){let s=0,r=1e3/a,l,o;const d=(y,p=Date.now())=>{s=p,l=null,o&&(clearTimeout(o),o=null),t(...y)};return[(...y)=>{const p=Date.now(),m=p-s;m>=r?d(y,p):(l=y,o||(o=setTimeout(()=>{o=null,d(l)},r-m)))},()=>l&&d(l)]}const Qn=(t,a,s=3)=>{let r=0;const l=Jd(50,250);return Qd(o=>{const d=o.loaded,c=o.lengthComputable?o.total:void 0,g=c!=null?Math.min(d,c):d,y=Math.max(0,g-r),p=l(y);r=Math.max(r,g);const m={loaded:g,total:c,progress:c?g/c:void 0,bytes:y,rate:p||void 0,estimated:p&&c?(c-g)/p:void 0,event:o,lengthComputable:c!=null,[a?"download":"upload"]:!0};t(m)},s)},Sr=(t,a)=>{const s=t!=null;return[r=>a[0]({lengthComputable:s,total:t,loaded:r}),a[1]]},vr=t=>(...a)=>Z.asap(()=>t(...a)),Xd=it.hasStandardBrowserEnv?((t,a)=>s=>(s=new URL(s,it.origin),t.protocol===s.protocol&&t.host===s.host&&(a||t.port===s.port)))(new URL(it.origin),it.navigator&&/(msie|trident)/i.test(it.navigator.userAgent)):()=>!0,Zd=it.hasStandardBrowserEnv?{write(t,a,s,r,l,o,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(a)}`];Z.isNumber(s)&&c.push(`expires=${new Date(s).toUTCString()}`),Z.isString(r)&&c.push(`path=${r}`),Z.isString(l)&&c.push(`domain=${l}`),o===!0&&c.push("secure"),Z.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const a=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return a?decodeURIComponent(a[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function ec(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function tc(t,a){return a?t.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):t}function Ml(t,a,s){let r=!ec(a);return t&&(r||s===!1)?tc(t,a):a}const wr=t=>t instanceof ft?{...t}:t;function Zt(t,a){a=a||{};const s=Object.create(null);Object.defineProperty(s,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(y,p,m,A){return Z.isPlainObject(y)&&Z.isPlainObject(p)?Z.merge.call({caseless:A},y,p):Z.isPlainObject(p)?Z.merge({},p):Z.isArray(p)?p.slice():p}function l(y,p,m,A){if(Z.isUndefined(p)){if(!Z.isUndefined(y))return r(void 0,y,m,A)}else return r(y,p,m,A)}function o(y,p){if(!Z.isUndefined(p))return r(void 0,p)}function d(y,p){if(Z.isUndefined(p)){if(!Z.isUndefined(y))return r(void 0,y)}else return r(void 0,p)}function c(y,p,m){if(Z.hasOwnProp(a,m))return r(y,p);if(Z.hasOwnProp(t,m))return r(void 0,y)}const g={url:o,method:o,data:o,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:c,headers:(y,p,m)=>l(wr(y),wr(p),m,!0)};return Z.forEach(Object.keys({...t,...a}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const m=Z.hasOwnProp(g,p)?g[p]:l,A=Z.hasOwnProp(t,p)?t[p]:void 0,C=Z.hasOwnProp(a,p)?a[p]:void 0,b=m(A,C,p);Z.isUndefined(b)&&m!==c||(s[p]=b)}),s}const El=t=>{const a=Zt({},t),s=A=>Z.hasOwnProp(a,A)?a[A]:void 0,r=s("data");let l=s("withXSRFToken");const o=s("xsrfHeaderName"),d=s("xsrfCookieName");let c=s("headers");const g=s("auth"),y=s("baseURL"),p=s("allowAbsoluteUrls"),m=s("url");if(a.headers=c=ft.from(c),a.url=Il(Ml(y,m,p),t.params,t.paramsSerializer),g&&c.set("Authorization","Basic "+btoa((g.username||"")+":"+(g.password?unescape(encodeURIComponent(g.password)):""))),Z.isFormData(r)){if(it.hasStandardBrowserEnv||it.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(Z.isFunction(r.getHeaders)){const A=r.getHeaders(),C=["content-type","content-length"];Object.entries(A).forEach(([b,f])=>{C.includes(b.toLowerCase())&&c.set(b,f)})}}if(it.hasStandardBrowserEnv&&(Z.isFunction(l)&&(l=l(a)),l===!0||l==null&&Xd(a.url))){const C=o&&d&&Zd.read(d);C&&c.set(o,C)}return a},ac=typeof XMLHttpRequest<"u",nc=ac&&function(t){return new Promise(function(s,r){const l=El(t);let o=l.data;const d=ft.from(l.headers).normalize();let{responseType:c,onUploadProgress:g,onDownloadProgress:y}=l,p,m,A,C,b;function f(){C&&C(),b&&b(),l.cancelToken&&l.cancelToken.unsubscribe(p),l.signal&&l.signal.removeEventListener("abort",p)}let x=new XMLHttpRequest;x.open(l.method.toUpperCase(),l.url,!0),x.timeout=l.timeout;function R(){if(!x)return;const O=ft.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),_={data:!c||c==="text"||c==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:O,config:t,request:x};Ol(function(h){s(h),f()},function(h){r(h),f()},_),x=null}"onloadend"in x?x.onloadend=R:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(R)},x.onabort=function(){x&&(r(new Te("Request aborted",Te.ECONNABORTED,t,x)),x=null)},x.onerror=function(D){const _=D&&D.message?D.message:"Network Error",u=new Te(_,Te.ERR_NETWORK,t,x);u.event=D||null,r(u),x=null},x.ontimeout=function(){let D=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded";const _=l.transitional||Zs;l.timeoutErrorMessage&&(D=l.timeoutErrorMessage),r(new Te(D,_.clarifyTimeoutError?Te.ETIMEDOUT:Te.ECONNABORTED,t,x)),x=null},o===void 0&&d.setContentType(null),"setRequestHeader"in x&&Z.forEach(d.toJSON(),function(D,_){x.setRequestHeader(_,D)}),Z.isUndefined(l.withCredentials)||(x.withCredentials=!!l.withCredentials),c&&c!=="json"&&(x.responseType=l.responseType),y&&([A,b]=Qn(y,!0),x.addEventListener("progress",A)),g&&x.upload&&([m,C]=Qn(g),x.upload.addEventListener("progress",m),x.upload.addEventListener("loadend",C)),(l.cancelToken||l.signal)&&(p=O=>{x&&(r(!O||O.type?new en(null,t,x):O),x.abort(),x=null)},l.cancelToken&&l.cancelToken.subscribe(p),l.signal&&(l.signal.aborted?p():l.signal.addEventListener("abort",p)));const k=Gd(l.url);if(k&&it.protocols.indexOf(k)===-1){r(new Te("Unsupported protocol "+k+":",Te.ERR_BAD_REQUEST,t));return}x.send(o||null)})},sc=(t,a)=>{const{length:s}=t=t?t.filter(Boolean):[];if(a||s){let r=new AbortController,l;const o=function(y){if(!l){l=!0,c();const p=y instanceof Error?y:this.reason;r.abort(p instanceof Te?p:new en(p instanceof Error?p.message:p))}};let d=a&&setTimeout(()=>{d=null,o(new Te(`timeout of ${a}ms exceeded`,Te.ETIMEDOUT))},a);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(y=>{y.unsubscribe?y.unsubscribe(o):y.removeEventListener("abort",o)}),t=null)};t.forEach(y=>y.addEventListener("abort",o));const{signal:g}=r;return g.unsubscribe=()=>Z.asap(c),g}},rc=function*(t,a){let s=t.byteLength;if(s<a){yield t;return}let r=0,l;for(;r<s;)l=r+a,yield t.slice(r,l),r=l},ic=async function*(t,a){for await(const s of lc(t))yield*rc(s,a)},lc=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const a=t.getReader();try{for(;;){const{done:s,value:r}=await a.read();if(s)break;yield r}}finally{await a.cancel()}},_r=(t,a,s,r)=>{const l=ic(t,a);let o=0,d,c=g=>{d||(d=!0,r&&r(g))};return new ReadableStream({async pull(g){try{const{done:y,value:p}=await l.next();if(y){c(),g.close();return}let m=p.byteLength;if(s){let A=o+=m;s(A)}g.enqueue(new Uint8Array(p))}catch(y){throw c(y),y}},cancel(g){return c(g),l.return()}},{highWaterMark:2})},Cr=64*1024,{isFunction:fn}=Z,oc=(({Request:t,Response:a})=>({Request:t,Response:a}))(Z.global),{ReadableStream:Ar,TextEncoder:Dr}=Z.global,Tr=(t,...a)=>{try{return!!t(...a)}catch{return!1}},dc=t=>{t=Z.merge.call({skipUndefined:!0},oc,t);const{fetch:a,Request:s,Response:r}=t,l=a?fn(a):typeof fetch=="function",o=fn(s),d=fn(r);if(!l)return!1;const c=l&&fn(Ar),g=l&&(typeof Dr=="function"?(b=>f=>b.encode(f))(new Dr):async b=>new Uint8Array(await new s(b).arrayBuffer())),y=o&&c&&Tr(()=>{let b=!1;const f=new s(it.origin,{body:new Ar,method:"POST",get duplex(){return b=!0,"half"}}),x=f.headers.has("Content-Type");return f.body!=null&&f.body.cancel(),b&&!x}),p=d&&c&&Tr(()=>Z.isReadableStream(new r("").body)),m={stream:p&&(b=>b.body)};l&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!m[b]&&(m[b]=(f,x)=>{let R=f&&f[b];if(R)return R.call(f);throw new Te(`Response type '${b}' is not supported`,Te.ERR_NOT_SUPPORT,x)})});const A=async b=>{if(b==null)return 0;if(Z.isBlob(b))return b.size;if(Z.isSpecCompliantForm(b))return(await new s(it.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(Z.isArrayBufferView(b)||Z.isArrayBuffer(b))return b.byteLength;if(Z.isURLSearchParams(b)&&(b=b+""),Z.isString(b))return(await g(b)).byteLength},C=async(b,f)=>{const x=Z.toFiniteNumber(b.getContentLength());return x??A(f)};return async b=>{let{url:f,method:x,data:R,signal:k,cancelToken:O,timeout:D,onDownloadProgress:_,onUploadProgress:u,responseType:h,headers:S,withCredentials:E="same-origin",fetchOptions:F}=El(b),q=a||fetch;h=h?(h+"").toLowerCase():"text";let T=sc([k,O&&O.toAbortSignal()],D),U=null;const j=T&&T.unsubscribe&&(()=>{T.unsubscribe()});let P;try{if(u&&y&&x!=="get"&&x!=="head"&&(P=await C(S,R))!==0){let $=new s(f,{method:"POST",body:R,duplex:"half"}),M;if(Z.isFormData(R)&&(M=$.headers.get("content-type"))&&S.setContentType(M),$.body){const[L,Y]=Sr(P,Qn(vr(u)));R=_r($.body,Cr,L,Y)}}Z.isString(E)||(E=E?"include":"omit");const I=o&&"credentials"in s.prototype;if(Z.isFormData(R)){const $=S.getContentType();$&&/^multipart\/form-data/i.test($)&&!/boundary=/i.test($)&&S.delete("content-type")}const N={...F,signal:T,method:x.toUpperCase(),headers:S.normalize().toJSON(),body:R,duplex:"half",credentials:I?E:void 0};U=o&&new s(f,N);let V=await(o?q(U,F):q(f,N));const W=p&&(h==="stream"||h==="response");if(p&&(_||W&&j)){const $={};["status","statusText","headers"].forEach(se=>{$[se]=V[se]});const M=Z.toFiniteNumber(V.headers.get("content-length")),[L,Y]=_&&Sr(M,Qn(vr(_),!0))||[];V=new r(_r(V.body,Cr,L,()=>{Y&&Y(),j&&j()}),$)}h=h||"text";let B=await m[Z.findKey(m,h)||"text"](V,b);return!W&&j&&j(),await new Promise(($,M)=>{Ol($,M,{data:B,headers:ft.from(V.headers),status:V.status,statusText:V.statusText,config:b,request:U})})}catch(I){throw j&&j(),I&&I.name==="TypeError"&&/Load failed|fetch/i.test(I.message)?Object.assign(new Te("Network Error",Te.ERR_NETWORK,b,U,I&&I.response),{cause:I.cause||I}):Te.from(I,I&&I.code,b,U,I&&I.response)}}},cc=new Map,$l=t=>{let a=t&&t.env||{};const{fetch:s,Request:r,Response:l}=a,o=[r,l,s];let d=o.length,c=d,g,y,p=cc;for(;c--;)g=o[c],y=p.get(g),y===void 0&&p.set(g,y=c?new Map:dc(a)),p=y;return y};$l();const tr={http:_d,xhr:nc,fetch:{get:$l}};Z.forEach(tr,(t,a)=>{if(t){try{Object.defineProperty(t,"name",{value:a})}catch{}Object.defineProperty(t,"adapterName",{value:a})}});const Rr=t=>`- ${t}`,uc=t=>Z.isFunction(t)||t===null||t===!1;function pc(t,a){t=Z.isArray(t)?t:[t];const{length:s}=t;let r,l;const o={};for(let d=0;d<s;d++){r=t[d];let c;if(l=r,!uc(r)&&(l=tr[(c=String(r)).toLowerCase()],l===void 0))throw new Te(`Unknown adapter '${c}'`);if(l&&(Z.isFunction(l)||(l=l.get(a))))break;o[c||"#"+d]=l}if(!l){const d=Object.entries(o).map(([g,y])=>`adapter ${g} `+(y===!1?"is not supported by the environment":"is not available in the build"));let c=s?d.length>1?`since :
4
+ `+d.map(Rr).join(`
5
+ `):" "+Rr(d[0]):"as no adapter specified";throw new Te("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return l}const Fl={getAdapter:pc,adapters:tr};function xs(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new en(null,t)}function Ir(t){return xs(t),t.headers=ft.from(t.headers),t.data=gs.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Fl.getAdapter(t.adapter||Za.adapter,t)(t).then(function(r){return xs(t),r.data=gs.call(t,t.transformResponse,r),r.headers=ft.from(r.headers),r},function(r){return Pl(r)||(xs(t),r&&r.response&&(r.response.data=gs.call(t,t.transformResponse,r.response),r.response.headers=ft.from(r.response.headers))),Promise.reject(r)})}const Ul="1.15.2",ns={};["object","boolean","number","function","string","symbol"].forEach((t,a)=>{ns[t]=function(r){return typeof r===t||"a"+(a<1?"n ":" ")+t}});const kr={};ns.transitional=function(a,s,r){function l(o,d){return"[Axios v"+Ul+"] Transitional option '"+o+"'"+d+(r?". "+r:"")}return(o,d,c)=>{if(a===!1)throw new Te(l(d," has been removed"+(s?" in "+s:"")),Te.ERR_DEPRECATED);return s&&!kr[d]&&(kr[d]=!0,console.warn(l(d," has been deprecated since v"+s+" and will be removed in the near future"))),a?a(o,d,c):!0}};ns.spelling=function(a){return(s,r)=>(console.warn(`${r} is likely a misspelling of ${a}`),!0)};function mc(t,a,s){if(typeof t!="object")throw new Te("options must be an object",Te.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let l=r.length;for(;l-- >0;){const o=r[l],d=Object.prototype.hasOwnProperty.call(a,o)?a[o]:void 0;if(d){const c=t[o],g=c===void 0||d(c,o,t);if(g!==!0)throw new Te("option "+o+" must be "+g,Te.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new Te("Unknown option "+o,Te.ERR_BAD_OPTION)}}const En={assertOptions:mc,validators:ns},wt=En.validators;let Jt=class{constructor(a){this.defaults=a||{},this.interceptors={request:new br,response:new br}}async request(a,s){try{return await this._request(a,s)}catch(r){if(r instanceof Error){let l={};Error.captureStackTrace?Error.captureStackTrace(l):l=new Error;const o=(()=>{if(!l.stack)return"";const d=l.stack.indexOf(`
6
+ `);return d===-1?"":l.stack.slice(d+1)})();try{if(!r.stack)r.stack=o;else if(o){const d=o.indexOf(`
7
+ `),c=d===-1?-1:o.indexOf(`
8
+ `,d+1),g=c===-1?"":o.slice(c+1);String(r.stack).endsWith(g)||(r.stack+=`
9
+ `+o)}}catch{}}throw r}}_request(a,s){typeof a=="string"?(s=s||{},s.url=a):s=a||{},s=Zt(this.defaults,s);const{transitional:r,paramsSerializer:l,headers:o}=s;r!==void 0&&En.assertOptions(r,{silentJSONParsing:wt.transitional(wt.boolean),forcedJSONParsing:wt.transitional(wt.boolean),clarifyTimeoutError:wt.transitional(wt.boolean),legacyInterceptorReqResOrdering:wt.transitional(wt.boolean)},!1),l!=null&&(Z.isFunction(l)?s.paramsSerializer={serialize:l}:En.assertOptions(l,{encode:wt.function,serialize:wt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),En.assertOptions(s,{baseUrl:wt.spelling("baseURL"),withXsrfToken:wt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let d=o&&Z.merge(o.common,o[s.method]);o&&Z.forEach(["delete","get","head","post","put","patch","common"],b=>{delete o[b]}),s.headers=ft.concat(d,o);const c=[];let g=!0;this.interceptors.request.forEach(function(f){if(typeof f.runWhen=="function"&&f.runWhen(s)===!1)return;g=g&&f.synchronous;const x=s.transitional||Zs;x&&x.legacyInterceptorReqResOrdering?c.unshift(f.fulfilled,f.rejected):c.push(f.fulfilled,f.rejected)});const y=[];this.interceptors.response.forEach(function(f){y.push(f.fulfilled,f.rejected)});let p,m=0,A;if(!g){const b=[Ir.bind(this),void 0];for(b.unshift(...c),b.push(...y),A=b.length,p=Promise.resolve(s);m<A;)p=p.then(b[m++],b[m++]);return p}A=c.length;let C=s;for(;m<A;){const b=c[m++],f=c[m++];try{C=b(C)}catch(x){f.call(this,x);break}}try{p=Ir.call(this,C)}catch(b){return Promise.reject(b)}for(m=0,A=y.length;m<A;)p=p.then(y[m++],y[m++]);return p}getUri(a){a=Zt(this.defaults,a);const s=Ml(a.baseURL,a.url,a.allowAbsoluteUrls);return Il(s,a.params,a.paramsSerializer)}};Z.forEach(["delete","get","head","options"],function(a){Jt.prototype[a]=function(s,r){return this.request(Zt(r||{},{method:a,url:s,data:(r||{}).data}))}});Z.forEach(["post","put","patch"],function(a){function s(r){return function(o,d,c){return this.request(Zt(c||{},{method:a,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:d}))}}Jt.prototype[a]=s(),Jt.prototype[a+"Form"]=s(!0)});let hc=class Nl{constructor(a){if(typeof a!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(o){s=o});const r=this;this.promise.then(l=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](l);r._listeners=null}),this.promise.then=l=>{let o;const d=new Promise(c=>{r.subscribe(c),o=c}).then(l);return d.cancel=function(){r.unsubscribe(o)},d},a(function(o,d,c){r.reason||(r.reason=new en(o,d,c),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const s=this._listeners.indexOf(a);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const a=new AbortController,s=r=>{a.abort(r)};return this.subscribe(s),a.signal.unsubscribe=()=>this.unsubscribe(s),a.signal}static source(){let a;return{token:new Nl(function(l){a=l}),cancel:a}}};function fc(t){return function(s){return t.apply(null,s)}}function yc(t){return Z.isObject(t)&&t.isAxiosError===!0}const Hs={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(Hs).forEach(([t,a])=>{Hs[a]=t});function Bl(t){const a=new Jt(t),s=bl(Jt.prototype.request,a);return Z.extend(s,Jt.prototype,a,{allOwnKeys:!0}),Z.extend(s,a,null,{allOwnKeys:!0}),s.create=function(l){return Bl(Zt(t,l))},s}const Je=Bl(Za);Je.Axios=Jt;Je.CanceledError=en;Je.CancelToken=hc;Je.isCancel=Pl;Je.VERSION=Ul;Je.toFormData=as;Je.AxiosError=Te;Je.Cancel=Je.CanceledError;Je.all=function(a){return Promise.all(a)};Je.spread=fc;Je.isAxiosError=yc;Je.mergeConfig=Zt;Je.AxiosHeaders=ft;Je.formToJSON=t=>kl(Z.isHTMLForm(t)?new FormData(t):t);Je.getAdapter=Fl.getAdapter;Je.HttpStatusCode=Hs;Je.default=Je;const{Axios:Ib,AxiosError:kb,CanceledError:Pb,isCancel:Ob,CancelToken:Mb,VERSION:Eb,all:$b,Cancel:Fb,isAxiosError:Ub,spread:Nb,toFormData:Bb,AxiosHeaders:Lb,HttpStatusCode:qb,formToJSON:zb,getAdapter:Yb,mergeConfig:Vb}=Je,gc=()=>new Promise(t=>setTimeout(()=>t(),800));let Ks=null;const xc=t=>{Ks=t,ot.defaults.baseURL=ar()},ar=()=>Ks||"https://npmapi.ubkerp.com/",ot=Je.create({baseURL:ar()}),bt=()=>ar();let Gs=null;const bc=t=>{Gs=t},Ke=()=>Gs||"https://image.ubkerp.com",jc=t=>{if(!t||typeof t!="string")return null;const a=t.split(".");if(a.length<2)return null;try{let s=a[1];s=s.replace(/-/g,"+").replace(/_/g,"/");const r=(4-s.length%4)%4;s+="=".repeat(r);const l=typeof atob=="function"?atob(s):Buffer.from(s,"base64").toString("binary");return JSON.parse(l)}catch{return null}},$t=t=>{const a=jc(t);return a?a?.branch_id??a?.branchID??a?.fk_branchID??a?.branch??null:null},Ne=async(t,a,s)=>{const r=await ot.post(t,a,{headers:{Authorization:s}});if(console.log("ddddfdfdfd",r.data?.Status),r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},Sc=async(t,a,s)=>{const r=a instanceof FormData;return(await ot.post(t,a,{headers:{Authorization:s,...r?{"Content-type":"multipart/form-data"}:{}}})).data},K=async(t,a)=>{try{const s=(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}})();let r=t;if(!t.includes("session_id")&&s){const o=t.includes("?")?"&":"?";r=`${t}${o}session_id=${s}`}return(await ot.get(r,{headers:{Authorization:a}})).data}catch(s){throw s.response?.status===401&&console.error("401 Unauthorized"),s}},vc=async(t,a)=>{const s=await ot.post(t,"",{headers:{Authorization:a}});if(s.data?.Status=="Success")return s?.data?.data||s?.data;throw new Error(s.data?.msg)},ss=async(t,a,s)=>{try{const r=await ot.post(t,a,{headers:{Authorization:s,"Content-Type":"application/json"}});return r.data?.Status==="Success"?r.data:(w.error(r.data?.msg||"Unable to issue library book",{duration:2e3}),!1)}catch(r){throw w.error(r.response?.data?.msg||r.response?.data?.message||"Request failed",{duration:2e3}),r}},Ha=async(t,a,s)=>{const r=a?.arg;return(await ot.post(t,r,{headers:{Authorization:s}}))?.data},Qt=async(t,a,s)=>{const r=a?.arg,l=t.includes("?")?"&":"?";return(await ot.get(t+l,{params:r,headers:{Authorization:s}}))?.data},wc="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",nr=async(t,a,s)=>{const r=a?.arg,l=t.includes("?")?"&":"?",o=await ot.get(t+l,{params:r,headers:{Authorization:s}});if(console.log("ddddfdfdfd",o.data?.Status),o.data?.Status=="Success")return o?.data?.data||o?.data;throw new Error(o.data?.msg)},We=async(t,a,s)=>(await gc(),(await ot.post(t,a,{headers:{Authorization:s}}))?.data),Sa=async(t,a,s)=>(await ot.post(t,a,{headers:{Authorization:s}})).data,He=async(t,a,s)=>(await ot.delete(`${t}/${a}`,{headers:{Authorization:s}})).data,_c="api/report/LibraryRenewalReport/renewalHistory",Cc="api/report/LibraryRenewalReport/renewalFineReport",Ac="api/report/LibraryRenewalReport/currentlyRenewedBooks",Dc="api/report/LibraryRenewalReport/upcomingRenewalDue",Tc="api/report/LibraryRenewalReport/overdueRenewalReport",Rc="api/report/LibraryRenewalReport/renewalLimitReport",Ic="api/report/LibraryRenewalReport/renewalStatusReport",kc="api/report/LibraryRenewalReport/studentWiseReport",Pc="api/report/LibraryRenewalReport/bookWiseReport",Oc="api/report/LibraryRenewalReport/classWiseReport",Mc="api/report/LibraryRenewalReport/staffWiseReport",Ec="api/report/LibraryRenewalReport/renewalStatisticsByDate",$c="/sample_templates/route_upload.xlsx",tn="api/branchapi/academy/classdropdownlist",an="api/branchapi/academy/sectionoftheClass",Fc="/sample_templates/student_transport_upload.xlsx",Uc="api/branchapi/income/incomeTableList",Nc="api/branchapi/income/addincome",Bc="api/branchapi/income/editincome",Lc="api/branchapi/income/deleteincome",Ll="api/branchapi/income/incomeheadDropdown",qc="api/branchapi/income/incomeheadTableList",zc="api/branchapi/income/addincomehead",Yc="api/branchapi/income/editincomehead",Vc="api/branchapi/income/deleteincomehead",Wc="api/branchapi/income/incomeShowdata",Hc="api/branchapi/income/incomeheadShowdata",Kc="api/branchapi/income/searchincomebydates",Gc="api/branchapi/expense/expenseTableList",Jc="api/branchapi/expense/addexpense",Qc="api/branchapi/expense/editexpense",Xc="api/branchapi/expense/deleteExpense",ql="api/branchapi/expense/expenseheadDropdown",Zc="api/branchapi/expense/expenseheadTableList",eu="api/branchapi/expense/addexpensehead",tu="api/branchapi/expense/editexpensehead",au="api/branchapi/expense/deleteexpensehead",nu="api/branchapi/expense/expenseShowdata",su="api/branchapi/expense/expenseVoucherbyID",ru="api/branchapi/expense/expenseheadShowdata",iu="api/branchapi/expense/searchexpensebydates",zl="api/accounts/vendor/vendorlist",lu="api/student/studentDetails/studentLoginCredentialList",Yl="/branchapi/student/studentlist",Vl="api/branchapi/student/studentsearchbyKeywords",Wl="api/branchapi/student/studentsearchbyClassSection",ou="/branchapi/student/addStudentMedicineDetails",du="/branchapi/student/StudentMedicineDetails",Hl="/branchapi/academy/getstudentClasssubjectByStudentId",cu="/branchapi/academy/removeAssignStudentSubject",Js="/branchapi/feesCollection/extraCurricularActivitiesFess",uu="/branchapi/academy/unAssigneStudentSubject",pu="/branchapi/student/uploadstudentbyCSV",mu="api/branchapi/academy/categorytableList",hu="api/branchapi/transport/downloadBulkTemplate",fu="api/branchapi/transport/validateBulkUpload",yu="api/branchapi/transport/confirmBulkImport",gu="api/branchapi/transport/downloadBulkErrorReport",xu=async({class_id:t,section_id:a}={},s)=>{const r=new URLSearchParams;t&&r.append("class_id",t),a&&r.append("section_id",a);const l=`${hu}${r.toString()?`?${r.toString()}`:""}`;return(await ot.get(l,{headers:{Authorization:s},responseType:"blob"})).data},bu=async(t,a)=>{const s=new FormData;return s.append("file",t),(await ot.post(fu,s,{headers:{Authorization:a,"Content-Type":"multipart/form-data"}})).data},ju=async(t,a,s="skip")=>(await ot.post(yu,{rows:t,duplicate_action:s},{headers:{Authorization:a,"Content-Type":"application/json"}})).data,Su=async(t,a)=>(await ot.post(gu,{rows:t},{headers:{Authorization:a,"Content-Type":"application/json"},responseType:"blob"})).data,vu=({token:t,menu:a})=>{const{isLoading:s,data:r}=H(t?["api/sdk/Menus",t]:null,([o,d])=>vc(o,d)),l=r?.find(o=>o.path===a)?.sub_menu??[];return console.log("menuData",r),e.jsx(n.Row,{gutter:[16,16],children:l?.map((o,d)=>o.dashboard_show==="YES"?e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(v,{children:e.jsx(xl,{icon:`${bt()}icons/frontoffice/${o.icons}`,title:o.submenu_name,path:o.menu_key})})},`${d}office001`):null)})};function Kl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var nt={},bs,Pr;function wu(){return Pr||(Pr=1,bs=function t(a,s){if(a===s)return!0;if(a&&s&&typeof a=="object"&&typeof s=="object"){if(a.constructor!==s.constructor)return!1;var r,l,o;if(Array.isArray(a)){if(r=a.length,r!=s.length)return!1;for(l=r;l--!==0;)if(!t(a[l],s[l]))return!1;return!0}if(a.constructor===RegExp)return a.source===s.source&&a.flags===s.flags;if(a.valueOf!==Object.prototype.valueOf)return a.valueOf()===s.valueOf();if(a.toString!==Object.prototype.toString)return a.toString()===s.toString();if(o=Object.keys(a),r=o.length,r!==Object.keys(s).length)return!1;for(l=r;l--!==0;)if(!Object.prototype.hasOwnProperty.call(s,o[l]))return!1;for(l=r;l--!==0;){var d=o[l];if(!t(a[d],s[d]))return!1}return!0}return a!==a&&s!==s}),bs}var yn={exports:{}},gn={exports:{}},$e={};var Or;function _u(){if(Or)return $e;Or=1;var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,l=t?Symbol.for("react.strict_mode"):60108,o=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,m=t?Symbol.for("react.suspense"):60113,A=t?Symbol.for("react.suspense_list"):60120,C=t?Symbol.for("react.memo"):60115,b=t?Symbol.for("react.lazy"):60116,f=t?Symbol.for("react.block"):60121,x=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,k=t?Symbol.for("react.scope"):60119;function O(_){if(typeof _=="object"&&_!==null){var u=_.$$typeof;switch(u){case a:switch(_=_.type,_){case g:case y:case r:case o:case l:case m:return _;default:switch(_=_&&_.$$typeof,_){case c:case p:case b:case C:case d:return _;default:return u}}case s:return u}}}function D(_){return O(_)===y}return $e.AsyncMode=g,$e.ConcurrentMode=y,$e.ContextConsumer=c,$e.ContextProvider=d,$e.Element=a,$e.ForwardRef=p,$e.Fragment=r,$e.Lazy=b,$e.Memo=C,$e.Portal=s,$e.Profiler=o,$e.StrictMode=l,$e.Suspense=m,$e.isAsyncMode=function(_){return D(_)||O(_)===g},$e.isConcurrentMode=D,$e.isContextConsumer=function(_){return O(_)===c},$e.isContextProvider=function(_){return O(_)===d},$e.isElement=function(_){return typeof _=="object"&&_!==null&&_.$$typeof===a},$e.isForwardRef=function(_){return O(_)===p},$e.isFragment=function(_){return O(_)===r},$e.isLazy=function(_){return O(_)===b},$e.isMemo=function(_){return O(_)===C},$e.isPortal=function(_){return O(_)===s},$e.isProfiler=function(_){return O(_)===o},$e.isStrictMode=function(_){return O(_)===l},$e.isSuspense=function(_){return O(_)===m},$e.isValidElementType=function(_){return typeof _=="string"||typeof _=="function"||_===r||_===y||_===o||_===l||_===m||_===A||typeof _=="object"&&_!==null&&(_.$$typeof===b||_.$$typeof===C||_.$$typeof===d||_.$$typeof===c||_.$$typeof===p||_.$$typeof===x||_.$$typeof===R||_.$$typeof===k||_.$$typeof===f)},$e.typeOf=O,$e}var Fe={};var Mr;function Cu(){return Mr||(Mr=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,l=t?Symbol.for("react.strict_mode"):60108,o=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,m=t?Symbol.for("react.suspense"):60113,A=t?Symbol.for("react.suspense_list"):60120,C=t?Symbol.for("react.memo"):60115,b=t?Symbol.for("react.lazy"):60116,f=t?Symbol.for("react.block"):60121,x=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,k=t?Symbol.for("react.scope"):60119;function O(le){return typeof le=="string"||typeof le=="function"||le===r||le===y||le===o||le===l||le===m||le===A||typeof le=="object"&&le!==null&&(le.$$typeof===b||le.$$typeof===C||le.$$typeof===d||le.$$typeof===c||le.$$typeof===p||le.$$typeof===x||le.$$typeof===R||le.$$typeof===k||le.$$typeof===f)}function D(le){if(typeof le=="object"&&le!==null){var oe=le.$$typeof;switch(oe){case a:var ie=le.type;switch(ie){case g:case y:case r:case o:case l:case m:return ie;default:var Se=ie&&ie.$$typeof;switch(Se){case c:case p:case b:case C:case d:return Se;default:return oe}}case s:return oe}}}var _=g,u=y,h=c,S=d,E=a,F=p,q=r,T=b,U=C,j=s,P=o,I=l,N=m,V=!1;function W(le){return V||(V=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),B(le)||D(le)===g}function B(le){return D(le)===y}function $(le){return D(le)===c}function M(le){return D(le)===d}function L(le){return typeof le=="object"&&le!==null&&le.$$typeof===a}function Y(le){return D(le)===p}function se(le){return D(le)===r}function X(le){return D(le)===b}function G(le){return D(le)===C}function J(le){return D(le)===s}function re(le){return D(le)===o}function de(le){return D(le)===l}function Ce(le){return D(le)===m}Fe.AsyncMode=_,Fe.ConcurrentMode=u,Fe.ContextConsumer=h,Fe.ContextProvider=S,Fe.Element=E,Fe.ForwardRef=F,Fe.Fragment=q,Fe.Lazy=T,Fe.Memo=U,Fe.Portal=j,Fe.Profiler=P,Fe.StrictMode=I,Fe.Suspense=N,Fe.isAsyncMode=W,Fe.isConcurrentMode=B,Fe.isContextConsumer=$,Fe.isContextProvider=M,Fe.isElement=L,Fe.isForwardRef=Y,Fe.isFragment=se,Fe.isLazy=X,Fe.isMemo=G,Fe.isPortal=J,Fe.isProfiler=re,Fe.isStrictMode=de,Fe.isSuspense=Ce,Fe.isValidElementType=O,Fe.typeOf=D})()),Fe}var Er;function Gl(){return Er||(Er=1,process.env.NODE_ENV==="production"?gn.exports=_u():gn.exports=Cu()),gn.exports}var js,$r;function Au(){if($r)return js;$r=1;var t=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function r(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function l(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var g=Object.getOwnPropertyNames(d).map(function(p){return d[p]});if(g.join("")!=="0123456789")return!1;var y={};return"abcdefghijklmnopqrst".split("").forEach(function(p){y[p]=p}),Object.keys(Object.assign({},y)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return js=l()?Object.assign:function(o,d){for(var c,g=r(o),y,p=1;p<arguments.length;p++){c=Object(arguments[p]);for(var m in c)a.call(c,m)&&(g[m]=c[m]);if(t){y=t(c);for(var A=0;A<y.length;A++)s.call(c,y[A])&&(g[y[A]]=c[y[A]])}}return g},js}var Ss,Fr;function sr(){if(Fr)return Ss;Fr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Ss=t,Ss}var vs,Ur;function Jl(){return Ur||(Ur=1,vs=Function.call.bind(Object.prototype.hasOwnProperty)),vs}var ws,Nr;function Du(){if(Nr)return ws;Nr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var a=sr(),s={},r=Jl();t=function(o){var d="Warning: "+o;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function l(o,d,c,g,y){if(process.env.NODE_ENV!=="production"){for(var p in o)if(r(o,p)){var m;try{if(typeof o[p]!="function"){var A=Error((g||"React class")+": "+c+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw A.name="Invariant Violation",A}m=o[p](d,p,g,c,null,a)}catch(b){m=b}if(m&&!(m instanceof Error)&&t((g||"React class")+": type specification of "+c+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in s)){s[m.message]=!0;var C=y?y():"";t("Failed "+c+" type: "+m.message+(C??""))}}}}return l.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(s={})},ws=l,ws}var _s,Br;function Tu(){if(Br)return _s;Br=1;var t=Gl(),a=Au(),s=sr(),r=Jl(),l=Du(),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(c){var g="Warning: "+c;typeof console<"u"&&console.error(g);try{throw new Error(g)}catch{}});function d(){return null}return _s=function(c,g){var y=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function m(B){var $=B&&(y&&B[y]||B[p]);if(typeof $=="function")return $}var A="<<anonymous>>",C={array:R("array"),bigint:R("bigint"),bool:R("boolean"),func:R("function"),number:R("number"),object:R("object"),string:R("string"),symbol:R("symbol"),any:k(),arrayOf:O,element:D(),elementType:_(),instanceOf:u,node:F(),objectOf:S,oneOf:h,oneOfType:E,shape:T,exact:U};function b(B,$){return B===$?B!==0||1/B===1/$:B!==B&&$!==$}function f(B,$){this.message=B,this.data=$&&typeof $=="object"?$:{},this.stack=""}f.prototype=Error.prototype;function x(B){if(process.env.NODE_ENV!=="production")var $={},M=0;function L(se,X,G,J,re,de,Ce){if(J=J||A,de=de||G,Ce!==s){if(g){var le=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw le.name="Invariant Violation",le}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var oe=J+":"+G;!$[oe]&&M<3&&(o("You are manually calling a React.PropTypes validation function for the `"+de+"` prop on `"+J+"`. 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."),$[oe]=!0,M++)}}return X[G]==null?se?X[G]===null?new f("The "+re+" `"+de+"` is marked as required "+("in `"+J+"`, but its value is `null`.")):new f("The "+re+" `"+de+"` is marked as required in "+("`"+J+"`, but its value is `undefined`.")):null:B(X,G,J,re,de)}var Y=L.bind(null,!1);return Y.isRequired=L.bind(null,!0),Y}function R(B){function $(M,L,Y,se,X,G){var J=M[L],re=I(J);if(re!==B){var de=N(J);return new f("Invalid "+se+" `"+X+"` of type "+("`"+de+"` supplied to `"+Y+"`, expected ")+("`"+B+"`."),{expectedType:B})}return null}return x($)}function k(){return x(d)}function O(B){function $(M,L,Y,se,X){if(typeof B!="function")return new f("Property `"+X+"` of component `"+Y+"` has invalid PropType notation inside arrayOf.");var G=M[L];if(!Array.isArray(G)){var J=I(G);return new f("Invalid "+se+" `"+X+"` of type "+("`"+J+"` supplied to `"+Y+"`, expected an array."))}for(var re=0;re<G.length;re++){var de=B(G,re,Y,se,X+"["+re+"]",s);if(de instanceof Error)return de}return null}return x($)}function D(){function B($,M,L,Y,se){var X=$[M];if(!c(X)){var G=I(X);return new f("Invalid "+Y+" `"+se+"` of type "+("`"+G+"` supplied to `"+L+"`, expected a single ReactElement."))}return null}return x(B)}function _(){function B($,M,L,Y,se){var X=$[M];if(!t.isValidElementType(X)){var G=I(X);return new f("Invalid "+Y+" `"+se+"` of type "+("`"+G+"` supplied to `"+L+"`, expected a single ReactElement type."))}return null}return x(B)}function u(B){function $(M,L,Y,se,X){if(!(M[L]instanceof B)){var G=B.name||A,J=W(M[L]);return new f("Invalid "+se+" `"+X+"` of type "+("`"+J+"` supplied to `"+Y+"`, expected ")+("instance of `"+G+"`."))}return null}return x($)}function h(B){if(!Array.isArray(B))return process.env.NODE_ENV!=="production"&&(arguments.length>1?o("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])."):o("Invalid argument supplied to oneOf, expected an array.")),d;function $(M,L,Y,se,X){for(var G=M[L],J=0;J<B.length;J++)if(b(G,B[J]))return null;var re=JSON.stringify(B,function(Ce,le){var oe=N(le);return oe==="symbol"?String(le):le});return new f("Invalid "+se+" `"+X+"` of value `"+String(G)+"` "+("supplied to `"+Y+"`, expected one of "+re+"."))}return x($)}function S(B){function $(M,L,Y,se,X){if(typeof B!="function")return new f("Property `"+X+"` of component `"+Y+"` has invalid PropType notation inside objectOf.");var G=M[L],J=I(G);if(J!=="object")return new f("Invalid "+se+" `"+X+"` of type "+("`"+J+"` supplied to `"+Y+"`, expected an object."));for(var re in G)if(r(G,re)){var de=B(G,re,Y,se,X+"."+re,s);if(de instanceof Error)return de}return null}return x($)}function E(B){if(!Array.isArray(B))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var $=0;$<B.length;$++){var M=B[$];if(typeof M!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+V(M)+" at index "+$+"."),d}function L(Y,se,X,G,J){for(var re=[],de=0;de<B.length;de++){var Ce=B[de],le=Ce(Y,se,X,G,J,s);if(le==null)return null;le.data&&r(le.data,"expectedType")&&re.push(le.data.expectedType)}var oe=re.length>0?", expected one of type ["+re.join(", ")+"]":"";return new f("Invalid "+G+" `"+J+"` supplied to "+("`"+X+"`"+oe+"."))}return x(L)}function F(){function B($,M,L,Y,se){return j($[M])?null:new f("Invalid "+Y+" `"+se+"` supplied to "+("`"+L+"`, expected a ReactNode."))}return x(B)}function q(B,$,M,L,Y){return new f((B||"React class")+": "+$+" type `"+M+"."+L+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Y+"`.")}function T(B){function $(M,L,Y,se,X){var G=M[L],J=I(G);if(J!=="object")return new f("Invalid "+se+" `"+X+"` of type `"+J+"` "+("supplied to `"+Y+"`, expected `object`."));for(var re in B){var de=B[re];if(typeof de!="function")return q(Y,se,X,re,N(de));var Ce=de(G,re,Y,se,X+"."+re,s);if(Ce)return Ce}return null}return x($)}function U(B){function $(M,L,Y,se,X){var G=M[L],J=I(G);if(J!=="object")return new f("Invalid "+se+" `"+X+"` of type `"+J+"` "+("supplied to `"+Y+"`, expected `object`."));var re=a({},M[L],B);for(var de in re){var Ce=B[de];if(r(B,de)&&typeof Ce!="function")return q(Y,se,X,de,N(Ce));if(!Ce)return new f("Invalid "+se+" `"+X+"` key `"+de+"` supplied to `"+Y+"`.\nBad object: "+JSON.stringify(M[L],null," ")+`
10
+ Valid keys: `+JSON.stringify(Object.keys(B),null," "));var le=Ce(G,de,Y,se,X+"."+de,s);if(le)return le}return null}return x($)}function j(B){switch(typeof B){case"number":case"string":case"undefined":return!0;case"boolean":return!B;case"object":if(Array.isArray(B))return B.every(j);if(B===null||c(B))return!0;var $=m(B);if($){var M=$.call(B),L;if($!==B.entries){for(;!(L=M.next()).done;)if(!j(L.value))return!1}else for(;!(L=M.next()).done;){var Y=L.value;if(Y&&!j(Y[1]))return!1}}else return!1;return!0;default:return!1}}function P(B,$){return B==="symbol"?!0:$?$["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&$ instanceof Symbol:!1}function I(B){var $=typeof B;return Array.isArray(B)?"array":B instanceof RegExp?"object":P($,B)?"symbol":$}function N(B){if(typeof B>"u"||B===null)return""+B;var $=I(B);if($==="object"){if(B instanceof Date)return"date";if(B instanceof RegExp)return"regexp"}return $}function V(B){var $=N(B);switch($){case"array":case"object":return"an "+$;case"boolean":case"date":case"regexp":return"a "+$;default:return $}}function W(B){return!B.constructor||!B.constructor.name?A:B.constructor.name}return C.checkPropTypes=l,C.resetWarningCache=l.resetWarningCache,C.PropTypes=C,C},_s}var Cs,Lr;function Ru(){if(Lr)return Cs;Lr=1;var t=sr();function a(){}function s(){}return s.resetWarningCache=a,Cs=function(){function r(d,c,g,y,p,m){if(m!==t){var A=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw A.name="Invariant Violation",A}}r.isRequired=r;function l(){return r}var o={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:l,element:r,elementType:r,instanceOf:l,node:r,objectOf:l,oneOf:l,oneOfType:l,shape:l,exact:l,checkPropTypes:s,resetWarningCache:a};return o.PropTypes=o,o},Cs}var qr;function Ql(){if(qr)return yn.exports;if(qr=1,process.env.NODE_ENV!=="production"){var t=Gl(),a=!0;yn.exports=Tu()(t.isElement,a)}else yn.exports=Ru()();return yn.exports}var zr;function Iu(){if(zr)return nt;zr=1;var t=nt&&nt.__extends||(function(){var C=function(b,f){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,R){x.__proto__=R}||function(x,R){for(var k in R)Object.prototype.hasOwnProperty.call(R,k)&&(x[k]=R[k])},C(b,f)};return function(b,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");C(b,f);function x(){this.constructor=b}b.prototype=f===null?Object.create(f):(x.prototype=f.prototype,new x)}})(),a=nt&&nt.__assign||function(){return a=Object.assign||function(C){for(var b,f=1,x=arguments.length;f<x;f++){b=arguments[f];for(var R in b)Object.prototype.hasOwnProperty.call(b,R)&&(C[R]=b[R])}return C},a.apply(this,arguments)},s=nt&&nt.__createBinding||(Object.create?(function(C,b,f,x){x===void 0&&(x=f);var R=Object.getOwnPropertyDescriptor(b,f);(!R||("get"in R?!b.__esModule:R.writable||R.configurable))&&(R={enumerable:!0,get:function(){return b[f]}}),Object.defineProperty(C,x,R)}):(function(C,b,f,x){x===void 0&&(x=f),C[x]=b[f]})),r=nt&&nt.__setModuleDefault||(Object.create?(function(C,b){Object.defineProperty(C,"default",{enumerable:!0,value:b})}):function(C,b){C.default=b}),l=nt&&nt.__importStar||function(C){if(C&&C.__esModule)return C;var b={};if(C!=null)for(var f in C)f!=="default"&&Object.prototype.hasOwnProperty.call(C,f)&&s(b,C,f);return r(b,C),b},o=nt&&nt.__rest||function(C,b){var f={};for(var x in C)Object.prototype.hasOwnProperty.call(C,x)&&b.indexOf(x)<0&&(f[x]=C[x]);if(C!=null&&typeof Object.getOwnPropertySymbols=="function")for(var R=0,x=Object.getOwnPropertySymbols(C);R<x.length;R++)b.indexOf(x[R])<0&&Object.prototype.propertyIsEnumerable.call(C,x[R])&&(f[x[R]]=C[x[R]]);return f},d=nt&&nt.__importDefault||function(C){return C&&C.__esModule?C:{default:C}};Object.defineProperty(nt,"__esModule",{value:!0});var c=l(i),g=d(wu()),y=l(Ql());function p(C){return C&&C.replace(/&nbsp;|\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function m(C){var b=document.createTextNode("");C.appendChild(b);var f=document.activeElement===C;if(b!==null&&b.nodeValue!==null&&f){var x=window.getSelection();if(x!==null){var R=document.createRange();R.setStart(b,b.nodeValue.length),R.collapse(!0),x.removeAllRanges(),x.addRange(R)}C instanceof HTMLElement&&C.focus()}}var A=(function(C){t(b,C);function b(){var f=C!==null&&C.apply(this,arguments)||this;return f.lastHtml=f.props.html,f.el=typeof f.props.innerRef=="function"?{current:null}:c.createRef(),f.getEl=function(){return(f.props.innerRef&&typeof f.props.innerRef!="function"?f.props.innerRef:f.el).current},f.emitChange=function(x){var R=f.getEl();if(R){var k=R.innerHTML;if(f.props.onChange&&k!==f.lastHtml){var O=Object.assign({},x,{target:{value:k}});f.props.onChange(O)}f.lastHtml=k}},f}return b.prototype.render=function(){var f=this,x=this.props,R=x.tagName,k=x.html,O=x.innerRef,D=o(x,["tagName","html","innerRef"]);return c.createElement(R||"div",a(a({},D),{ref:typeof O=="function"?function(_){O(_),f.el.current=_}:O||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:k}}),this.props.children)},b.prototype.shouldComponentUpdate=function(f){var x=this.props,R=this.getEl();return!R||p(f.html)!==p(R.innerHTML)?!0:x.disabled!==f.disabled||x.tagName!==f.tagName||x.className!==f.className||x.innerRef!==f.innerRef||x.placeholder!==f.placeholder||!(0,g.default)(x.style,f.style)},b.prototype.componentDidUpdate=function(){var f=this.getEl();f&&(this.props.html!==f.innerHTML&&(f.innerHTML=this.props.html),this.lastHtml=this.props.html,m(f))},b.propTypes={html:y.string.isRequired,onChange:y.func,disabled:y.bool,tagName:y.string,className:y.string,style:y.object,innerRef:y.oneOfType([y.object,y.func])},b})(c.Component);return nt.default=A,nt}var ku=Iu();const Xl=Kl(ku),Pu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ou={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:a,onBlur:s,...r},l)=>{const[o,d]=i.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:Pu,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:l,onFocus:c=>{d(!0),a?.(c)},onBlur:c=>{d(!1),s?.(c)},style:{...Ou,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})}),Yr=[{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 rr(t){const a=te().year(),s=[];for(let r=a;r>=a-t;r--)s.push({label:String(r),value:r});return s}function st(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 ir(t){const a=te().year(),s=te().month();return t<a?Yr:Yr.slice(0,s+1)}function Vr(t,a){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:a});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:a});default:return e.jsx("span",{className:"monthlyLabel",children:a})}}function Mu(){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 Zl=t=>{switch(t){case"paid":return e.jsx("div",{style:{background:"#3cb371",color:"white",textAlign:"center"},children:"PAID"});case"due":return e.jsx("div",{style:{background:"red",color:"white",textAlign:"center"},children:"DUE"});case"partially_paid":return e.jsx("div",{style:{background:"#ff8d00",color:"white",textAlign:"center"},children:"Partially Paid"});case"Present":return e.jsx(n.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(n.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(n.Tag,{color:"error",children:"No Attendance"});case"one_time":return"ONETIME";case"monthly":return"MONTHLY";case"half_yearly":return"HALF YEARLY";case"quarterly":return"QUARTERLY";default:return""}},Rt=t=>{const a=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[a?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var Aa={},Da={},xt={},Ta={},sa={},Wr;function Eu(){if(Wr)return sa;Wr=1;var t=sa&&sa.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(sa,"__esModule",{value:!0});const a=t(i),s=Mo,r=["string","number","boolean"];function l({header:o,body:d}){const c=a.default.createElement("tr",null,o.map(y=>a.default.createElement("th",{key:y},y))),g=d.map((y,p)=>Array.isArray(y)?a.default.createElement("tr",{key:p},y.map((m,A)=>a.default.createElement("th",{key:A}," ",m," "))):y!==null&&typeof y=="object"?a.default.createElement("tr",{key:p},Object.entries(y).map(([m,A],C)=>typeof A=="object"?(console.error(`typeof ${m} is incorrect, only accept ${r.join(", ")} `),a.default.createElement("th",{key:C})):a.default.createElement("th",{key:C},a.default.createElement(a.default.Fragment,null,A)))):(console.error(`
11
11
  data structure is incorrect,
12
12
  data structure type ->
13
13
  " type data = Array<{ [key: string]: string | number | boolean }>
14
14
  or
15
15
  type data = Array<(string | number | boolean)[]>"
16
- `),null));return(0,s.renderToString)(a.default.createElement("table",null,a.default.createElement("tbody",null,c,y)))}return ta.default=o,ta}var Gr;function vu(){return Gr||(Gr=1,(function(t){var a=Da&&Da.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(t,"__esModule",{value:!0}),t.createTable=t.template=t.uri=t.format=t.base64=void 0;function s(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=s;function i(l,d){return l.replace(/{(\w+)}/g,(c,y)=>d[y])}t.format=i,t.uri="data:application/vnd.ms-excel;base64,",t.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var o=wu();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return a(o).default}})})(Da)),Da}var Jr;function Xo(){if(Jr)return ft;Jr=1;var t=ft&&ft.__createBinding||(Object.create?(function(h,u,p,C){C===void 0&&(C=p);var S=Object.getOwnPropertyDescriptor(u,p);(!S||("get"in S?!u.__esModule:S.writable||S.configurable))&&(S={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(h,C,S)}):(function(h,u,p,C){C===void 0&&(C=p),h[C]=u[p]})),a=ft&&ft.__setModuleDefault||(Object.create?(function(h,u){Object.defineProperty(h,"default",{enumerable:!0,value:u})}):function(h,u){h.default=u}),s=ft&&ft.__importStar||function(h){if(h&&h.__esModule)return h;var u={};if(h!=null)for(var p in h)p!=="default"&&Object.prototype.hasOwnProperty.call(h,p)&&t(u,h,p);return a(u,h),u};Object.defineProperty(ft,"__esModule",{value:!0}),ft.downloadExcel=ft.excel=void 0;const i=s(vu());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(h,u){const p=window.document.createElement("a");return p.href=i.uri+i.base64(i.format(i.template,u)),p.download=h,document.body.appendChild(p),p.click(),document.body.removeChild(p),!0}function d(h,u){if(h)return h.cloneNode(!0).outerHTML;if(u)return i.createTable(u);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:h,sheet:u,tablePayload:p},C){if(!o())return!1;const S=d(C,p);return l(h,{worksheet:u||"Worksheet",table:S})}ft.downloadExcel=c;function y({currentTableRef:h,filename:u,sheet:p}){function C(){if(!o())return!1;const S=d(h),x=`${u}.xls`;return l(x,{worksheet:p||"Worksheet",table:S})}return{onDownload:C}}return ft.excel=y,ft}var Qr;function _u(){if(Qr)return Aa;Qr=1,Object.defineProperty(Aa,"__esModule",{value:!0}),Aa.useDownloadExcel=void 0;const t=r,a=Xo();function s({currentTableRef:i,filename:o,sheet:l}){const[d,c]=(0,t.useState)({});return(0,t.useEffect)(()=>{c({currentTableRef:i,filename:o,sheet:l})},[i,o,l]),(0,t.useMemo)(()=>(0,a.excel)(d),[d])}return Aa.useDownloadExcel=s,Aa}var Xr;function Cu(){return Xr||(Xr=1,(function(t){var a=Ca&&Ca.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadExcel=t.useDownloadExcel=t.DownloadTableExcel=void 0;const s=a(r),i=_u();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return i.useDownloadExcel}});const o=Xo();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:y,children:h})=>{const{onDownload:u}=(0,i.useDownloadExcel)({currentTableRef:d,filename:c,sheet:y});return s.default.createElement("span",{onClick:u},h)};t.DownloadTableExcel=l})(Ca)),Ca}var Zo=Cu();const wt=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:a}=t.data;t?.tableRef;const s=new Date().getTime(),i=xa.useReactToPrint({content:()=>a.current});return e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:i})}),e.jsx(n.Col,{children:e.jsx(Zo.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:a.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},Ot=t=>{const{tableRef:a}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},At=r.createContext(),Au=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Te=t=>{const{columns:a,action:s,DrawerUpdate:i,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:y,open:h,ActionView:u,viewDetails:p,myType:C,type:S,urlkey:x,columnstype:m,rowSelection:j}=t.data,T=Au(),[R,I]=r.useState(!1),[_,A]=r.useState(null),[f,g]=r.useState("false"),[D,k]=r.useState(!1),[L,B]=r.useState(!1),[b,P]=r.useState(),[O,F]=r.useState(""),U=()=>I(!1),N=se=>{g(se),I(!0)},[Y,z]=r.useState(),[E,M]=r.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),$=r.useRef(null),q=(se,me)=>{t.parentCallback?.(se,me),M({rowsPerPage:me,page:se})},H=(se,me)=>{A(me),k(!0),P(se)},re=(se,me)=>{A(me),B(!0),P(se)},ee=t?.data?.onNavigate??t?.onNavigate,G=(se,me)=>{if(typeof ee=="function"){ee(se,me);return}typeof window<"u"&&typeof se=="string"&&se.length>0&&window.location.assign(se)},J=se=>{if(S==="staff"){G(`/HumanResourceDashboard/StaffFullInformation?id=${se.fk_staffID}`,se);return}G(`/StudentInformation/StudentFullInformation?id=${se.id}`,se)},ie=(se,me)=>{z(se),i?.(me)},pe=async(se,me,xe,oe)=>{i?.(!0),xe!==""&&((await oe({id:se,admission_no:me,ec_no:xe}))?.Status==="Success"?n.message.success("Ec No updated successfully"):n.message.error("Failed to Update Ec No."))},_e=()=>e.jsx(At.Provider,{value:Y,children:o}),{trigger:le}=tt("branchapi/staff/updateStaffPassword",Ya),{trigger:de}=tt("branchapi/Student/updateEcNo",Ya),{trigger:X}=tt(x,(se,me)=>Ya("student/studentDetails/editStudentLogInCredential",me)),ce=async se=>{se.preventDefault(),k(!1);try{(await le({staff_id:b,new_passwod:se.target.password.value}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch{n.message.error("Failed to update password")}},Re=async se=>{se.preventDefault(),B(!1);try{(await X({edit_id:_?.edit_id,new_passwod:se.target.password.value,username:se.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch(me){n.message.error(me?.response?.data?.msg??"Failed to update password")}},Ue=(Array.isArray(a)?a:[]).some(se=>se?.fixed==="left"),ke=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:m==="antd"&&Ue?"left":void 0,sorter:(se,me)=>(se.__serialNumber??0)-(me.__serialNumber??0),render:se=>se},...m==="antd"?a:(Array.isArray(a)?a:[]).map(se=>({title:se.name,dataIndex:se.selector,key:se.selector,sorter:se.sorter||(se.sortable?(me,xe)=>{const oe=me[se.selector]??"",ye=xe[se.selector]??"";return typeof oe=="number"&&typeof ye=="number"?oe-ye:String(oe).localeCompare(String(ye))}:!1),render:(me,xe)=>{switch(se.selector){case"my_staff":return xe.staff_id!=="0"?xe.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(n.Image,{width:50,src:`undefined/branch/gallery/${xe.gallery_cat_logo}`});case"file01":return xe.documents?e.jsx("div",{onClick:()=>N(`undefined/branch/frontoffice/${xe.documents}`),style:{textDecoration:"underline",color:"blue",cursor:"pointer"},children:"view file"}):"Not Uploaded";case"amount":case"fine_amount":case"basic_pay":case"net_amount":return Tt(me);case"full_name":return e.jsx("span",{onClick:()=>J(xe),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:me||`${xe.firstname} ${xe.lastname}`});case"extra_curricular_activity":return me==="Yes"?"Extra Subject":"Fees Master";case"is_active":return me==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return xe?.current_status==="Active"?e.jsx(n.Progress,{percent:xe.steps==="1"?30:xe.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:xe?.current_status});case"Password":return e.jsx("span",{onClick:()=>H(xe.id,xe),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>re(xe.id,xe),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(n.Tag,{onClick:()=>p?.(xe.id),color:me==="paid"?"#66aa18":me==="partially_paid"?"#ff5722":"#DC143C",children:me==="paid"?"Paid":me==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return Su().find(oe=>oe.value===me)?.label;case"status":return e.jsx("span",{onClick:()=>p?.(xe?.fk_staffID,xe?.total_leave),className:`label ${me==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:me==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[xe.is_theory==="yes"&&"Theory, ",xe.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(Jo,{html:xe.ec_no,onBlur:oe=>pe(xe.id,xe.admission_no,oe.target.innerHTML,de)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(n.Button,{type:"primary",icon:e.jsx(te.SendOutlined,{}),size:"small",onClick:()=>ie(xe.id,!0,se.name),children:se.name});case"Button":return e.jsx(n.Tag,{color:"cyan",onClick:()=>p?.(xe),children:se.name});default:return typeof se.render=="function"?se.render(me,xe):me}}})),...s?[{title:"Action",key:"action",render:(se,me)=>{const xe=me?.current_status==="Promoted",oe=()=>{if(C=="sameAddUpdate"){ie(me,!0);return}if(C?.type==="examEdit"){C.editFunc(me.id);return}ie(me.id||me,!0)},ye=()=>{if(C==="student_result"){p?.(me);return}if(C==="student"){p?.(me.id,me.class_id);return}p?.(me.id)},Ye=()=>{y?.(me?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[u?.[0]?.status&&e.jsx(n.Button,{icon:e.jsx(te.EditOutlined,{}),size:"small",disabled:xe,onClick:oe}),u?.[1]?.status&&e.jsx(n.Button,{icon:e.jsx(te.DeleteOutlined,{}),size:"small",danger:!0,disabled:xe,onClick:Ye}),u?.[2]?.status&&e.jsx(n.Button,{icon:e.jsx(te.EyeOutlined,{}),size:"small",onClick:ye})]})}}]:[]],Ve=r.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Le=r.useMemo(()=>{const se=O.trim().toLowerCase();return se?Ve.filter(me=>Object.values(me??{}).some(xe=>String(xe??"").toLowerCase().includes(se))):Ve},[Ve,O]),at=!!t.parentCallback,Ge=O?Le.length:l?.pagination?.total_rows??Le.length,Fe=(E.page-1)*E.rowsPerPage,Je=at?Le:Le.slice(Fe,Fe+E.rowsPerPage),it=r.useMemo(()=>(Je??[]).map((se,me)=>({...se??{},__serialNumber:Fe+me+1})),[Fe,Je]),fe=Ge===0?0:Math.min(Fe+1,Ge),Se=Ge===0?0:Math.min(Fe+Je.length,Ge);let je;return d?je=e.jsx("p",{children:"Loading..."}):c?je=e.jsx("p",{children:c.message}):Je.length?je=e.jsx(n.Table,{dataSource:it,columns:ke,size:"small",bordered:!0,pagination:!1,rowSelection:j,rowKey:(se,me)=>se?.id??se?._id??me,scroll:{x:"max-content"}}):je=e.jsx(n.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(n.Drawer,{open:h,placement:"right",onClose:()=>i?.(!1),width:720,children:_e()}),e.jsx(n.Modal,{title:"Update Password",open:D,onCancel:()=>k(!1),footer:null,children:e.jsx("form",{onSubmit:ce,children:e.jsxs(v,{children:[e.jsx(v,{style:{marginBottom:12},children:e.jsx(V,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(v,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{title:" Update Credential",open:L,onCancel:()=>B(!1),footer:null,children:e.jsx("form",{onSubmit:Re,children:e.jsxs(v,{children:[e.jsx(v,{style:{marginBottom:12},children:e.jsx(V,{type:"text",label:"User Name",name:"username",required:"required",value:_?.username?_?.username:"",onChange:se=>A({..._,username:se.target.value})})}),e.jsx(v,{style:{marginBottom:12},children:e.jsx(V,{label:"Password",name:"password",required:"required",value:_?.password?_?.password:"",onChange:se=>A({..._,password:se.target.value})})}),e.jsx(v,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{open:R,onCancel:U,footer:null,centered:!0,width:"80%",className:T.modal,children:e.jsxs("div",{style:{position:"relative"},className:T.img,children:[e.jsx(n.Image,{src:f,alt:"",style:{width:"100%"},preview:!1}),e.jsx(n.Button,{type:"text",icon:e.jsx(te.CloseOutlined,{}),onClick:U,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(n.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
16
+ `),null));return(0,s.renderToString)(a.default.createElement("table",null,a.default.createElement("tbody",null,c,g)))}return sa.default=l,sa}var Hr;function $u(){return Hr||(Hr=1,(function(t){var a=Ta&&Ta.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(t,"__esModule",{value:!0}),t.createTable=t.template=t.uri=t.format=t.base64=void 0;function s(o){return window.btoa(unescape(encodeURIComponent(o)))}t.base64=s;function r(o,d){return o.replace(/{(\w+)}/g,(c,g)=>d[g])}t.format=r,t.uri="data:application/vnd.ms-excel;base64,",t.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var l=Eu();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return a(l).default}})})(Ta)),Ta}var Kr;function eo(){if(Kr)return xt;Kr=1;var t=xt&&xt.__createBinding||(Object.create?(function(y,p,m,A){A===void 0&&(A=m);var C=Object.getOwnPropertyDescriptor(p,m);(!C||("get"in C?!p.__esModule:C.writable||C.configurable))&&(C={enumerable:!0,get:function(){return p[m]}}),Object.defineProperty(y,A,C)}):(function(y,p,m,A){A===void 0&&(A=m),y[A]=p[m]})),a=xt&&xt.__setModuleDefault||(Object.create?(function(y,p){Object.defineProperty(y,"default",{enumerable:!0,value:p})}):function(y,p){y.default=p}),s=xt&&xt.__importStar||function(y){if(y&&y.__esModule)return y;var p={};if(y!=null)for(var m in y)m!=="default"&&Object.prototype.hasOwnProperty.call(y,m)&&t(p,y,m);return a(p,y),p};Object.defineProperty(xt,"__esModule",{value:!0}),xt.downloadExcel=xt.excel=void 0;const r=s($u());function l(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function o(y,p){const m=window.document.createElement("a");return m.href=r.uri+r.base64(r.format(r.template,p)),m.download=y,document.body.appendChild(m),m.click(),document.body.removeChild(m),!0}function d(y,p){if(y)return y.cloneNode(!0).outerHTML;if(p)return r.createTable(p);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:y,sheet:p,tablePayload:m},A){if(!l())return!1;const C=d(A,m);return o(y,{worksheet:p||"Worksheet",table:C})}xt.downloadExcel=c;function g({currentTableRef:y,filename:p,sheet:m}){function A(){if(!l())return!1;const C=d(y),b=`${p}.xls`;return o(b,{worksheet:m||"Worksheet",table:C})}return{onDownload:A}}return xt.excel=g,xt}var Gr;function Fu(){if(Gr)return Da;Gr=1,Object.defineProperty(Da,"__esModule",{value:!0}),Da.useDownloadExcel=void 0;const t=i,a=eo();function s({currentTableRef:r,filename:l,sheet:o}){const[d,c]=(0,t.useState)({});return(0,t.useEffect)(()=>{c({currentTableRef:r,filename:l,sheet:o})},[r,l,o]),(0,t.useMemo)(()=>(0,a.excel)(d),[d])}return Da.useDownloadExcel=s,Da}var Jr;function Uu(){return Jr||(Jr=1,(function(t){var a=Aa&&Aa.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadExcel=t.useDownloadExcel=t.DownloadTableExcel=void 0;const s=a(i),r=Fu();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const l=eo();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return l.downloadExcel}});const o=({currentTableRef:d,filename:c,sheet:g,children:y})=>{const{onDownload:p}=(0,r.useDownloadExcel)({currentTableRef:d,filename:c,sheet:g});return s.default.createElement("span",{onClick:p},y)};t.DownloadTableExcel=o})(Aa)),Aa}var to=Uu();const Ct=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:a}=t.data;t?.tableRef;const s=new Date().getTime(),r=ea.useReactToPrint({content:()=>a.current});return e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(n.Col,{children:e.jsx(to.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:a.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},It=t=>{const{tableRef:a}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},Tt=i.createContext(),Nu=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Ie=t=>{const{columns:a,action:s,DrawerUpdate:r,editDesign:l,newData:o,Loading:d,error:c,deleteTodoMutation:g,open:y,ActionView:p,viewDetails:m,myType:A,type:C,urlkey:b,columnstype:f,rowSelection:x}=t.data,R=Nu(),[k,O]=i.useState(!1),[D,_]=i.useState(null),[u,h]=i.useState("false"),[S,E]=i.useState(!1),[F,q]=i.useState(!1),[T,U]=i.useState(),[j,P]=i.useState(""),I=()=>O(!1),N=ae=>{h(ae),O(!0)},[V,W]=i.useState(),[B,$]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),M=i.useRef(null),L=(ae,he)=>{t.parentCallback?.(ae,he),$({rowsPerPage:he,page:ae})},Y=(ae,he)=>{_(he),E(!0),U(ae)},se=(ae,he)=>{_(he),q(!0),U(ae)},X=t?.data?.onNavigate??t?.onNavigate,G=(ae,he)=>{if(typeof X=="function"){X(ae,he);return}typeof window<"u"&&typeof ae=="string"&&ae.length>0&&window.location.assign(ae)},J=ae=>{if(C==="staff"){G(`/HumanResourceDashboard/StaffFullInformation?id=${ae.fk_staffID}`,ae);return}G(`/StudentInformation/StudentFullInformation?id=${ae.id}`,ae)},re=(ae,he)=>{W(ae),r?.(he)},de=async(ae,he,ye,ke)=>{r?.(!0),ye!==""&&((await ke({id:ae,admission_no:he,ec_no:ye}))?.Status==="Success"?n.message.success("Ec No updated successfully"):n.message.error("Failed to Update Ec No."))},Ce=()=>e.jsx(Tt.Provider,{value:V,children:l}),{trigger:le}=rt("branchapi/staff/updateStaffPassword",Ha),{trigger:oe}=rt("branchapi/Student/updateEcNo",Ha),{trigger:ie}=rt(b,(ae,he)=>Ha("student/studentDetails/editStudentLogInCredential",he)),Se=async ae=>{ae.preventDefault(),E(!1);try{(await le({staff_id:T,new_passwod:ae.target.password.value}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch{n.message.error("Failed to update password")}},Ee=async ae=>{ae.preventDefault(),q(!1);try{(await ie({edit_id:D?.edit_id,new_passwod:ae.target.password.value,username:ae.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch(he){n.message.error(he?.response?.data?.msg??"Failed to update password")}},Xe=(Array.isArray(a)?a:[]).some(ae=>ae?.fixed==="left"),be=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:f==="antd"&&Xe?"left":void 0,sorter:(ae,he)=>(ae.__serialNumber??0)-(he.__serialNumber??0),render:ae=>ae},...f==="antd"?a:(Array.isArray(a)?a:[]).map(ae=>({title:ae.name,dataIndex:ae.selector,key:ae.selector,sorter:ae.sorter||(ae.sortable?(he,ye)=>{const ke=he[ae.selector]??"",Pe=ye[ae.selector]??"";return typeof ke=="number"&&typeof Pe=="number"?ke-Pe:String(ke).localeCompare(String(Pe))}:!1),render:(he,ye)=>{switch(ae.selector){case"my_staff":return ye.staff_id!=="0"?ye.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(n.Image,{width:50,src:`undefined/branch/gallery/${ye.gallery_cat_logo}`});case"file01":return ye.documents?e.jsx("div",{onClick:()=>N(`undefined/branch/frontoffice/${ye.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 Rt(he);case"full_name":return e.jsx("span",{onClick:()=>J(ye),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:he||`${ye.firstname} ${ye.lastname}`});case"extra_curricular_activity":return he==="Yes"?"Extra Subject":"Fees Master";case"is_active":return he==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return ye?.current_status==="Active"?e.jsx(n.Progress,{percent:ye.steps==="1"?30:ye.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:ye?.current_status});case"Password":return e.jsx("span",{onClick:()=>Y(ye.id,ye),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>se(ye.id,ye),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(n.Tag,{onClick:()=>m?.(ye.id),color:he==="paid"?"#66aa18":he==="partially_paid"?"#ff5722":"#DC143C",children:he==="paid"?"Paid":he==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return Mu().find(ke=>ke.value===he)?.label;case"status":return e.jsx("span",{onClick:()=>m?.(ye?.fk_staffID,ye?.total_leave),className:`label ${he==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:he==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[ye.is_theory==="yes"&&"Theory, ",ye.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(Xl,{html:ye.ec_no,onBlur:ke=>de(ye.id,ye.admission_no,ke.target.innerHTML,oe)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(n.Button,{type:"primary",icon:e.jsx(ee.SendOutlined,{}),size:"small",onClick:()=>re(ye.id,!0,ae.name),children:ae.name});case"Button":return e.jsx(n.Tag,{color:"cyan",onClick:()=>m?.(ye),children:ae.name});default:return typeof ae.render=="function"?ae.render(he,ye):he}}})),...s?[{title:"Action",key:"action",render:(ae,he)=>{const ye=he?.current_status==="Promoted",ke=()=>{if(A=="sameAddUpdate"){re(he,!0);return}if(A?.type==="examEdit"){A.editFunc(he.id);return}re(he.id||he,!0)},Pe=()=>{if(A==="student_result"){m?.(he);return}if(A==="student"){m?.(he.id,he.class_id);return}m?.(he.id)},ue=()=>{g?.(he?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[p?.[0]?.status&&e.jsx(n.Button,{icon:e.jsx(ee.EditOutlined,{}),size:"small",disabled:ye,onClick:ke}),p?.[1]?.status&&e.jsx(n.Button,{icon:e.jsx(ee.DeleteOutlined,{}),size:"small",danger:!0,disabled:ye,onClick:ue}),p?.[2]?.status&&e.jsx(n.Button,{icon:e.jsx(ee.EyeOutlined,{}),size:"small",onClick:Pe})]})}}]:[]],ve=i.useMemo(()=>{if(!o)return[];const ae=o?.data?.data??o?.data??o??{};return Array.isArray(ae)?ae:Array.isArray(ae?.data)?ae.data:Array.isArray(ae?.resultlist)?ae.resultlist:Array.isArray(ae?.students)?ae.students:Array.isArray(ae?.report)?ae.report:[]},[o]),Oe=i.useMemo(()=>{const ae=j.trim().toLowerCase();return ae?ve.filter(he=>Object.values(he??{}).some(ye=>String(ye??"").toLowerCase().includes(ae))):ve},[ve,j]),Ye=!!t.parentCallback,Be=j?Oe.length:o?.pagination?.total_rows??Oe.length,Le=(B.page-1)*B.rowsPerPage,Ze=Ye?Oe:Oe.slice(Le,Le+B.rowsPerPage),at=i.useMemo(()=>(Ze??[]).map((ae,he)=>({...ae??{},__serialNumber:Le+he+1})),[Le,Ze]),fe=Be===0?0:Math.min(Le+1,Be),je=Be===0?0:Math.min(Le+Ze.length,Be);let xe;return d?xe=e.jsx("p",{children:"Loading..."}):c?xe=e.jsx("p",{children:c.message}):Ze.length?xe=e.jsx(n.Table,{dataSource:at,columns:be,size:"small",bordered:!0,pagination:!1,rowSelection:x,rowKey:(ae,he)=>ae?.id??ae?._id??he,scroll:{x:"max-content"}}):xe=e.jsx(n.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(n.Drawer,{open:y,placement:"right",onClose:()=>r?.(!1),width:720,children:Ce()}),e.jsx(n.Modal,{title:"Update Password",open:S,onCancel:()=>E(!1),footer:null,children:e.jsx("form",{onSubmit:Se,children:e.jsxs(v,{children:[e.jsx(v,{style:{marginBottom:12},children:e.jsx(z,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(v,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{title:" Update Credential",open:F,onCancel:()=>q(!1),footer:null,children:e.jsx("form",{onSubmit:Ee,children:e.jsxs(v,{children:[e.jsx(v,{style:{marginBottom:12},children:e.jsx(z,{type:"text",label:"User Name",name:"username",required:"required",value:D?.username?D?.username:"",onChange:ae=>_({...D,username:ae.target.value})})}),e.jsx(v,{style:{marginBottom:12},children:e.jsx(z,{label:"Password",name:"password",required:"required",value:D?.password?D?.password:"",onChange:ae=>_({...D,password:ae.target.value})})}),e.jsx(v,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{open:k,onCancel:I,footer:null,centered:!0,width:"80%",className:R.modal,children:e.jsxs("div",{style:{position:"relative"},className:R.img,children:[e.jsx(n.Image,{src:u,alt:"",style:{width:"100%"},preview:!1}),e.jsx(n.Button,{type:"text",icon:e.jsx(ee.CloseOutlined,{}),onClick:I,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(n.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
17
17
  .ubk-table-shell .ant-table-wrapper {
18
18
  background: #fff;
19
19
  border: 1px solid #e7e8f2;
@@ -56,7 +56,7 @@ Valid keys: `+JSON.stringify(Object.keys(E),null," "));var le=_e(G,pe,H,re,ee+"
56
56
  .ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
57
57
  color: #8f99ff;
58
58
  }
59
- `}),e.jsx(v,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(wt,{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(n.Select,{size:"small",value:E.rowsPerPage,onChange:se=>q(1,se),options:[10,25,50,100].map(se=>({label:se,value:se})),style:{width:72}}),e.jsx("span",{children:"entries"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:12,color:"#222"},children:"Search:"}),e.jsx(n.Input,{size:"small",allowClear:!0,value:O,onChange:se=>{F(se.target.value),M(me=>({...me,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(te.SearchOutlined,{style:{color:"#a3a8cf"}}),style:{width:220,borderWidth:"0 0 1px 0",borderRadius:0,background:"transparent"}})]})]}),e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),je]}),l&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,marginTop:16,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:`Showing ${fe} to ${Se} of ${Ge} entries`}),e.jsx(n.Pagination,{current:E.page,pageSize:E.rowsPerPage,total:Ge||0,showSizeChanger:!1,onChange:q})]})]})]})},Du=({token:t,type:a})=>{const[s,i]=r.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${s.page}&per_page=${s.rowsPerPage}`,{isLoading:c,data:y,error:h}=W(t?[d,t]:null,([R,I])=>K(R,I)),[u,p]=r.useState(!1),C=(R,I)=>{i({page:R,rowsPerPage:parseInt(I)})},S=async R=>{},x=R=>{console.log("dsdsdsdsd",R),p(R)},m=()=>{},j=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],T=r.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(R,I)=>R.name.localeCompare(I.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(R,I)=>(R.contact||"").localeCompare(I.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(R,I)=>(R.description||"").localeCompare(I.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(R,I)=>(R.source_name||"").localeCompare(I.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(R,I)=>new Date(R.date)-new Date(I.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(R,I)=>new Date(R.follow_up_date)-new Date(I.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Te,{parentCallback:C,data:{newData:y,columns:T,action:!0,Loading:c,error:h,open:u,viewDetails:m,deleteTodoMutation:S,DrawerUpdate:x,ActionView:j}})})};var Tu=Go();const vs=Wo(Tu),el=()=>{};class ir extends r.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=a=>{this.selectRef=a};componentDidUpdate(a){a.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(a,s)=>{this.props.onChange(a,s),this.setState({value:a})};getValue=()=>{const{value:a}=this.state;return a?Array.isArray(a)?a.length?"valid":"":typeof a=="object"?a.value||"":a:""};render(){const{SelectComponent:a,required:s,...i}=this.props;console.log("sdsdsfsdddddddd",{...i});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(a,{...i,ref:this.setSelectRef,onChange:this.onChange}),l&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:el,onFocus:()=>this.selectRef.focus(),required:s})]})}}ir.defaultProps={onChange:el};ir.protoTypes={selectComponent:vs.func.isRequired,onChange:vs.func,required:vs.bool};const Ru={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Iu={menuPortal:t=>({...t,zIndex:9999}),control:(t,a)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#a8a8a8"}`}}),valueContainer:t=>({...t,height:40,padding:"0 0",display:"flex",alignItems:"center"}),input:t=>({...t,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),indicatorsContainer:t=>({...t,height:40}),dropdownIndicator:(t,a)=>({...t,padding:"0 0 0 8px",color:a.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,a)=>({...t,fontSize:"14px",backgroundColor:a.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},tl=t=>e.jsx(ho.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),ku=t=>e.jsx(ir,{...t,SelectComponent:ho,components:{Input:tl},options:t.options}),Q=r.forwardRef(({...t},a)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:Ru,children:t?.label}),e.jsx(ku,{components:{Input:tl},menuPortalTarget:document.body,styles:Iu,className:"input-cont",...t,ref:a})]})),Pu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ou={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Mu=(t,a,s)=>a?t>ae(s).endOf("day")||t<ae(a).endOf("day"):!1,Me=r.forwardRef(function(a,s){const{...i}=a;return e.jsxs("div",{className:"form-group",children:[i.Desplay&&e.jsx("label",{className:`labelfont ${i.classnme?i.classnme:""}`,style:Pu,children:i.Desplay}),e.jsx(n.DatePicker,{...i,style:{...Ou,...i.style||{}},className:"form-group",disabledDate:o=>Mu(o,i.sessionStart||i.minDate?.subtract(1,"day").format("YYYY-MM-DD"),i.sessionEnd||i.maxDate?.format("YYYY-MM-DD")),required:!0,ref:s})]})}),Eu={minWidth:160,height:36,padding:"0 28px",border:"none",borderRadius:999,background:"linear-gradient(90deg, #f59b1c 0%, #ef3e7b 100%)",color:"#fff",fontSize:14,fontWeight:700,textTransform:"uppercase",cursor:"pointer",boxShadow:"none"},ne=r.forwardRef(({error:t,success:a,disabled:s,style:i,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:s,style:{...Eu,opacity:s?.7:1,cursor:s?"not-allowed":"pointer",...i||{}}})})),Fu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Uu={width:"100%",minHeight:80,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",resize:"vertical",transition:"border-color 0.2s ease"},st=({style:t,onFocus:a,onBlur:s,...i})=>{const[o,l]=r.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[i.label&&e.jsx("label",{className:"labelfont",style:Fu,children:i.label}),e.jsx("textarea",{placeholder:i.placeholder||i.label,...i,onFocus:d=>{l(!0),a?.(d)},onBlur:d=>{l(!1),s?.(d)},style:{...Uu,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},ze=t=>({optimisticData:a=>[...a.data,t],populateCache:(a,s)=>[...s.data,a]}),Ne=t=>({optimisticData:a=>a.data.filter(s=>s.id!==t),populateCache:(a,s)=>s.data.filter(i=>i.id!==t)}),$u=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Nu="api/branchapi/Frontoffice/visitorbookShowdata",Lu="api/branchapi/Frontoffice/purposedropdown";function Bu({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=Nu.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([m,j,T])=>ja(m,{id:j},T)),{isLoading:c,data:y}=W(s?[Lu,s]:null,([m,j])=>K(m,j)),h=r.useMemo(()=>$u(y),[y]),u=d?.data?.[0],[p,C]=r.useState({purpose:void 0,name:"",phone:"",id_card:"",number_of_person:1,date:null,in_time:null,out_time:null,note:"",address:"",image:""});r.useEffect(()=>{u&&C({purpose:u?.purpose,name:u?.name||"",phone:u?.contact||"",id_card:u?.id_proof||"",number_of_person:u?.no_of_pepple||1,date:u?.date?ae(u.date):null,in_time:u?.in_time?ae(u.in_time,"h:mm a"):null,out_time:u?.out_time?ae(u.out_time,"h:mm a"):null,note:u?.note||"",address:u?.address||"",image:u?.image||""})},[u]);const S=(m,j)=>{C(T=>({...T,[m]:j}))},x=`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`;return l||c?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,i),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Visitor"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",allowSelectAll:!1,value:p.purpose,onChange:m=>S("purpose",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0,value:p.name,onChange:m=>S("name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"phone",type:"text",label:"Phone No.",required:!0,value:p.phone,onChange:m=>S("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"id_card",type:"text",label:"ID Card",value:p.id_card,onChange:m=>S("id_card",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"number_of_person",type:"number",label:"Number of Person",value:p.number_of_person,onChange:m=>S("number_of_person",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:p.date,Desplay:"Date",id:"date",name:"date",required:!0,onChange:m=>S("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.in_time,onChange:m=>S("in_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:p.in_time?p.in_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.out_time,onChange:m=>S("out_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time",value:p.out_time?p.out_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>S("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(st,{type:"text",label:"Address",name:"address",rows:3,required:!0,value:p.address,onChange:m=>S("address",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:x,headers:{Authorization:s},maxCount:1,onChange:m=>{if(m.file.status==="removed"&&S("image",""),m.file.status==="done"){const j=m.file.response?.data??m.file.response?.file??"";S("image",String(j??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:p.image?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:p.image||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; }"})]})}const qu=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},aa="api/branchapi/Frontoffice/visitortablelist",zu="api/branchapi/Frontoffice/purposedropdown",Yu="api/branchapi/frontoffice/addvisitors",Vu="api/branchapi/frontoffice/editvisitorsdata",Wu="api/branchapi/frontoffice/deletevisitors",Hu=`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`;function Ku({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,y]=r.useState(""),[h,u]=r.useState("03:30 PM"),p=(b,P)=>{s({page:b,rowsPerPage:Number.parseInt(P,10)})},C=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],S=r.useMemo(()=>{const b=aa.includes("?")?aa.endsWith("?")||aa.endsWith("&")?"":"&":"?";return`${aa}${b}page=${a.page}&per_page=${a.rowsPerPage}`},[aa,a.page,a.rowsPerPage]),{isLoading:x,error:m,data:j,mutate:T}=W(t?[S,t]:null,([b,P])=>K(b,P)),{isLoading:R,data:I}=W(t?[zu,t]:null,([b,P])=>K(b,P)),_=r.useMemo(()=>qu(I),[I]),A=async(b,P)=>{try{await T(Ee(b,P,t),ze(P)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},f=async b=>{try{await T(qe(Wu,b,t),Ne(b)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},g=async(b,P,O)=>{try{const F=await Be(b,P,t);T(F),Array.isArray(F?.data)&&T(`${aa.replace(/\?.*$/,"")}?id=${O}`,F),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},D=async(b,P)=>{b.preventDefault();const O=new FormData(b.target);await g(Vu,O,P),b.target.reset(),d(""),o(!1)},k=async b=>{if(b.preventDefault(),!b.target?.date?.value)w.error("Select required dates"),b.target?.date?.focus(),y("textDanger");else{const P=new FormData(b.target);await A(Yu,P),b.target.reset(),y(""),d(""),u("03:30 PM")}},L=b=>{o(b)},B=r.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Address",selector:"address",sortable:!0},{id:"5",name:"In Time",selector:"in_time",sortable:!0},{id:"6",name:"Out Time",selector:"out_time",sortable:!0}],[]);return e.jsxs("div",{children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Visitor"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:k,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone No.",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"id_card",type:"text",label:"ID Card"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{defaultValue:1,name:"number_of_person",type:"number",label:"Number of Person"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.TimePicker,{defaultValue:ae("2022-04-17T15:30","h:mm a"),id:"in_time",use12Hours:!0,format:"h:mm a",onChange:(b,P)=>u(P),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:h,readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(st,{type:"text",label:"Address*",name:"address",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:Hu,headers:{Authorization:t},maxCount:1,onChange:b=>{if(b.file.status==="removed"&&d(""),b.file.status==="done"){const P=b.file.response?.data??b.file.response?.file??"";d(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:l?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Visitor List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:p,data:{newData:j,columns:B,action:!0,ActionView:C,Loading:x,error:m,editDesign:e.jsx(Bu,{data:{handleUpdate:D,token:t}}),deleteTodoMutation:f,open:i,DrawerUpdate:L,viewDetails:""}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Gu="api/branchapi/frontoffice/generalcallsShowdata",Ju=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}];function Qu({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=Gu.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([p,C,S])=>ja(p,{id:C},S)),c=d?.data?.[0],[y,h]=r.useState({name:"",phone:"",description:"",date:null,next_follow_up_date:null,call_duration:"",note:"",call_type:""});r.useEffect(()=>{c&&h({name:c?.name||"",phone:c?.contact||"",description:c?.description||"",date:c?.date?ae(c.date):null,next_follow_up_date:c?.follow_up_date?ae(c.follow_up_date):null,call_duration:c?.call_dureation||"",note:c?.note||"",call_type:c?.call_type||""})},[c]);const u=(p,C)=>{h(S=>({...S,[p]:C}))};return l?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,i),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Call Log"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0,value:y.name,onChange:p=>u("name",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",value:y.phone,onChange:p=>u("phone",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description",value:y.description,onChange:p=>u("description",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:y.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:y.next_follow_up_date,Desplay:"Next Follow Up Date",id:"fdate",name:"next_follow_up_date",onChange:p=>u("next_follow_up_date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"call_duration",type:"text",label:"Call Duration",value:y.call_duration,onChange:p=>u("call_duration",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:y.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:Ju,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:y.call_type?{value:y.call_type,label:y.call_type}:null,onChange:p=>u("call_type",p?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const na="api/branchapi/frontoffice/generalcalltablelist",Xu="api/branchapi/frontoffice/addgenaralcalls",Zu="api/branchapi/frontoffice/editgeneralcall",ep="api/branchapi/frontoffice/deletegeneralcall",tp=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}],ap=[{key:"all",label:"All Calls"},{key:"Incoming",label:"Incoming"},{key:"Outgoing",label:"Outgoing"}];function np({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,y]=r.useState(""),[h,u]=r.useState("all"),[p,C]=r.useState(""),S=r.useRef(null),x=(b,P)=>{s({page:b,rowsPerPage:Number.parseInt(P,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],j=r.useMemo(()=>{const b=na.includes("?")?na.endsWith("?")||na.endsWith("&")?"":"&":"?",P=new URLSearchParams;return P.set("page",String(a.page)),P.set("per_page",String(a.rowsPerPage)),h!=="all"&&P.set("call_type",h),`${na}${b}${P.toString()}`},[na,a.page,a.rowsPerPage,h]),{isLoading:T,error:R,data:I,mutate:_}=W(t?[j,t]:null,([b,P])=>K(b,P)),A=async(b,P)=>{try{await _(Ee(b,P,t),ze(P)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},f=async b=>{try{await _(qe(ep,b,t),Ne(b)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},g=async(b,P,O)=>{try{const F=await Be(b,P,t);_(F),Array.isArray(F?.data)&&_(`${na.replace(/\?.*$/,"")}?id=${O}`,F),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},D=async(b,P)=>{b.preventDefault();const O=new FormData(b.target);await g(Zu,O,P),b.target.reset(),d(""),o(!1)},k=async b=>{if(b.preventDefault(),!b.target?.date?.value)w.error("Select required dates"),b.target?.date?.focus(),y("textDanger");else{const P=new FormData(b.target);await A(Xu,P),b.target.reset(),y(""),d(""),C("")}},L=b=>{o(b)},B=r.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Phone",selector:"contact",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Follow Up Date",selector:"follow_up_date",sortable:!0},{id:"6",name:"Call Duration",selector:"call_dureation",sortable:!0}],[]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Phone Call Log"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:k,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",Desplay:"Next Follow Up Date",id:"fdate",name:"follow_up_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"call_dureation",type:"text",label:"Call Duration"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:tp,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:p?{value:p,label:p}:null,onChange:b=>C(b?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Phone Call Log List"})}),e.jsxs(v,{pt:3,children:[e.jsx(n.Tabs,{activeKey:h,onChange:u,items:ap}),e.jsx(wt,{data:{tableRef:S}}),e.jsx(Te,{parentCallback:x,data:{newData:I,columns:B,action:!0,ActionView:m,Loading:T,error:R,editDesign:e.jsx(Qu,{data:{handleUpdate:D,token:t}}),deleteTodoMutation:f,open:i,DrawerUpdate:L,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const sp="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function rp({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=sp.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([p,C,S])=>ja(p,{id:C},S)),c=d?.data?.[0],[y,h]=r.useState({to_title:"",refernce:"",address:"",note:"",from_title:"",date:null,image:""});r.useEffect(()=>{c&&h({to_title:c?.to_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",from_title:c?.from_title||"",date:c?.date?ae(c.date):null,image:c?.image||""})},[c]);const u=(p,C)=>{h(S=>({...S,[p]:C}))};return l?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,i),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Dispatch"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"title",type:"text",label:"To Title *",required:!0,value:y.to_title,onChange:p=>u("to_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"refernce",type:"text",label:"Reference No",value:y.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"address",type:"text",label:"Address",required:!0,value:y.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:y.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"from_title",type:"text",label:"From Title",required:!0,value:y.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:y.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const sa="api/branchapi/frontoffice/postaldispatchtablelist",ip="api/branchapi/frontoffice/addpostaldispatch",op="api/branchapi/frontoffice/editpostaldispatch",lp="api/branchapi/frontoffice/deletepostalreceivedispatch";function dp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,y]=r.useState(""),h=r.useRef(null),u=(D,k)=>{s({page:D,rowsPerPage:Number.parseInt(k,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],C=r.useMemo(()=>{const D=sa.includes("?")?sa.endsWith("?")||sa.endsWith("&")?"":"&":"?";return`${sa}${D}page=${a.page}&per_page=${a.rowsPerPage}`},[sa,a.page,a.rowsPerPage]),{isLoading:S,error:x,data:m,mutate:j}=W(t?[C,t]:null,([D,k])=>K(D,k)),T=async(D,k)=>{try{await j(Ee(D,k,t),ze(k)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},R=async D=>{try{await j(qe(lp,D,t),Ne(D)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},I=async(D,k,L)=>{try{const B=await Be(D,k,t);j(B),Array.isArray(B?.data)&&j(`${sa.replace(/\?.*$/,"")}?id=${L}`,B),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},_=async(D,k)=>{D.preventDefault();const L=new FormData(D.target);await I(op,L,k),D.target.reset(),d(""),o(!1)},A=async D=>{if(D.preventDefault(),!D.target?.date?.value)w.error("Select required dates"),D.target?.date?.focus(),y("textDanger");else{const k=new FormData(D.target);await T(ip,k),D.target.reset(),y(""),d("")}},f=D=>{o(D)},g=r.useMemo(()=>[{id:"1",name:"To Title",selector:"to_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"From Title",selector:"from_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Dispatch"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:A,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:"title",type:"text",label:"To Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:"from_title",type:"text",label:"From Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Dispatch List"})}),e.jsxs(v,{pt:3,children:[e.jsx(wt,{data:{tableRef:h}}),e.jsx(Te,{parentCallback:u,data:{newData:m,columns:g,action:!0,ActionView:p,Loading:S,error:x,editDesign:e.jsx(rp,{data:{handleUpdate:_,token:t}}),deleteTodoMutation:R,open:i,DrawerUpdate:f,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const cp="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function up({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=cp.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([p,C,S])=>ja(p,{id:C},S)),c=d?.data?.[0],[y,h]=r.useState({from_title:"",refernce:"",address:"",note:"",title:"",date:null,image:""});r.useEffect(()=>{c&&h({from_title:c?.from_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",title:c?.to_title||"",date:c?.date?ae(c.date):null,image:c?.image||""})},[c]);const u=(p,C)=>{h(S=>({...S,[p]:C}))};return l?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,i),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Receive"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"from_title",type:"text",label:"From Title *",required:!0,value:y.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"refernce",type:"text",label:"Reference No",required:!0,value:y.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"address",type:"text",label:"Address",required:!0,value:y.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:y.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"title",type:"text",label:"To Title",required:!0,value:y.title,onChange:p=>u("title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:y.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ra="api/branchapi/frontoffice/postalrecivetablelist",pp="api/branchapi/frontoffice/addpostalrecive",mp="api/branchapi/frontoffice/editpostalrecive",hp="api/branchapi/frontoffice/deletepostalreceivedispatch";function fp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,y]=r.useState(""),h=r.useRef(null),u=(D,k)=>{s({page:D,rowsPerPage:Number.parseInt(k,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],C=r.useMemo(()=>{const D=ra.includes("?")?ra.endsWith("?")||ra.endsWith("&")?"":"&":"?";return`${ra}${D}page=${a.page}&per_page=${a.rowsPerPage}`},[ra,a.page,a.rowsPerPage]),{isLoading:S,error:x,data:m,mutate:j}=W(t?[C,t]:null,([D,k])=>K(D,k)),T=async(D,k)=>{try{await j(Ee(D,k,t),ze(k)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},R=async D=>{try{await j(qe(hp,D,t),Ne(D)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},I=async(D,k,L)=>{try{const B=await Be(D,k,t);j(B),Array.isArray(B?.data)&&j(`${ra.replace(/\?.*$/,"")}?id=${L}`,B),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},_=async(D,k)=>{D.preventDefault();const L=new FormData(D.target);await I(mp,L,k),D.target.reset(),d(""),o(!1)},A=async D=>{if(D.preventDefault(),!D.target?.date?.value)w.error("Select required dates"),D.target?.date?.focus(),y("textDanger");else{const k=new FormData(D.target);await T(pp,k),D.target.reset(),y(""),d("")}},f=D=>{o(D)},g=r.useMemo(()=>[{id:"1",name:"From Title",selector:"from_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"To Title",selector:"to_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Receive"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:A,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:"from_title",type:"text",label:"From Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:"title",type:"text",label:"To Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Receive List"})}),e.jsxs(v,{pt:3,children:[e.jsx(wt,{data:{tableRef:h}}),e.jsx(Te,{parentCallback:u,data:{newData:m,columns:g,action:!0,ActionView:p,Loading:S,error:x,editDesign:e.jsx(up,{data:{handleUpdate:_,token:t}}),deleteTodoMutation:R,open:i,DrawerUpdate:f,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const yp="api/branchapi/frontoffice/complaintShowdata",gp="api/branchapi/frontoffice/complainttypedropdown",xp=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function bp({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=yp.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([m,j,T])=>ja(m,{id:j},T)),{isLoading:c,data:y}=W(s?[gp,s]:null,([m,j])=>K(m,j)),h=r.useMemo(()=>xp(y).map(j=>({value:j?.value??j?.id??j?.complaint_type??"",label:j?.complaint_type??j?.label??""})),[y]),u=d?.data?.[0],[p,C]=r.useState({complain_type:"",complain_by_name:"",phone:"",date:null,description:"",action_token:"",assigned:"",note:"",file:""});r.useEffect(()=>{u&&C({complain_type:u?.complaint_type??"",complain_by_name:u?.name??"",phone:u?.contact??"",date:u?.date?ae(u.date):null,description:u?.description??"",action_token:u?.action_taken??"",assigned:u?.assigned??"",note:u?.note??"",file:u?.image??""})},[u]);const S=(m,j)=>{C(T=>({...T,[m]:j}))},x=r.useMemo(()=>h.find(m=>m.value===p.complain_type)||null,[h,p.complain_type]);return l||c?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsxs("form",{onSubmit:m=>a(m,i),children:[e.jsx("input",{type:"hidden",name:"id",value:i??""}),e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Complaint"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",allowSelectAll:!1,value:x,onChange:m=>S("complain_type",m?.value??"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0,value:p.complain_by_name,onChange:m=>S("complain_by_name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{10}",value:p.phone,onChange:m=>S("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:p.date,Desplay:"Enquiry Date",id:"date",name:"date",onChange:m=>S("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description",value:p.description,onChange:m=>S("description",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"action_token",type:"text",label:"Action Taken",value:p.action_token,onChange:m=>S("action_token",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"assigned",type:"text",label:"Assigned",value:p.assigned,onChange:m=>S("assigned",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>S("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})]})})}const ia="api/branchapi/frontoffice/complainttablelist",jp="api/branchapi/frontoffice/complainttypedropdown",Sp="api/branchapi/frontoffice/addcomplaint",wp="api/branchapi/frontoffice/editcomplaint",vp="api/branchapi/frontoffice/deletecomplaint",_p=[{key:"all",label:"All Complaints"},{key:"pending",label:"Pending"},{key:"resolved",label:"Resolved"}];function Cp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,y]=r.useState(""),[h,u]=r.useState("all"),p=r.useRef(null),C=(P,O)=>{s({page:P,rowsPerPage:Number.parseInt(O,10)})},S=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],x=r.useMemo(()=>{const P=ia.includes("?")?ia.endsWith("?")||ia.endsWith("&")?"":"&":"?",O=new URLSearchParams;return O.set("page",String(a.page)),O.set("per_page",String(a.rowsPerPage)),h!=="all"&&O.set("status",h),`${ia}${P}${O.toString()}`},[ia,a.page,a.rowsPerPage,h]),{isLoading:m,error:j,data:T,mutate:R}=W(t?[x,t]:null,([P,O])=>K(P,O)),{isLoading:I,data:_}=W(t?[jp,t]:null,([P,O])=>K(P,O)),A=r.useMemo(()=>{const P=_?.data??_??[];return Array.isArray(P)?P:Array.isArray(P?.data)?P.data:[]},[_]),f=async(P,O)=>{try{await R(Ee(P,O,t),ze(O)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},g=async P=>{try{await R(qe(vp,P,t),Ne(P)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},D=async(P,O,F)=>{try{const U=await Be(P,O,t);R(U),Array.isArray(U?.data)&&R(`${ia.replace(/\?.*$/,"")}?id=${F}`,U),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},k=async(P,O)=>{P.preventDefault();const F=new FormData(P.target);await D(wp,F,O),P.target.reset(),d(""),o(!1)},L=async P=>{if(P.preventDefault(),!P.target?.date?.value)w.error("Select required dates"),P.target?.date?.focus(),y("textDanger");else{const O=new FormData(P.target);await f(Sp,O),P.target.reset(),y(""),d("")}},B=P=>{o(P)},b=r.useMemo(()=>[{id:"1",name:"Complain Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Action Taken",selector:"action_taken",sortable:!0},{id:"6",name:"Assigned",selector:"assigned",sortable:!0}],[]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Complaint"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:L,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Complain Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"action_token",type:"text",label:"Action Taken"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"assigned",type:"text",label:"Assigned"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx("input",{type:"hidden",name:"file",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Complaint List"})}),e.jsxs(v,{pt:3,children:[e.jsx(n.Tabs,{activeKey:h,onChange:u,items:_p}),e.jsx(wt,{data:{tableRef:p}}),e.jsx(Te,{parentCallback:C,data:{newData:T,columns:b,action:!0,ActionView:S,Loading:m,error:j,editDesign:e.jsx(bp,{data:{handleUpdate:k,token:t}}),deleteTodoMutation:g,open:i,DrawerUpdate:B,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Zr="api/branchapi/Frontoffice/purposetablelist",Ap="api/branchapi/Frontoffice/complaint_typetablelist",Dp="api/branchapi/Frontoffice/sourcetablelist",Tp="api/branchapi/Frontoffice/referencetablelist",ei="api/branchapi/frontoffice/visitorpurposeShowdata",Rp="api/branchapi/frontoffice/complaintTypeShowdata",Ip="api/branchapi/frontoffice/sourceShowdata",kp="api/branchapi/frontoffice/referenceShowdata",pa=[{key:"purpose",label:"Purpose"},{key:"complainType",label:"Complain Type"},{key:"source",label:"Source"},{key:"reference",label:"Reference"}],ti={purpose:[{id:"1",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],complainType:[{id:"1",name:"Complaint Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],source:[{id:"1",name:"Source",selector:"source",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],reference:[{id:"1",name:"Reference",selector:"reference",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}]};function Pp({token:t}){const[a,s]=r.useState("purpose"),[i,o]=r.useState({page:1,rowsPerPage:10}),[l,d]=r.useState(!1),c=r.useRef(null),y=(L,B)=>{o({page:L,rowsPerPage:Number.parseInt(B,10)})},h=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],u=()=>{switch(a){case"purpose":return Zr;case"complainType":return Ap;case"source":return Dp;case"reference":return Tp;default:return Zr}},p=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/addvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/addcomplaint_type";case"source":return"api/branchapi/frontoffice/addsource";case"reference":return"api/branchapi/frontoffice/addreference";default:return"api/branchapi/frontoffice/addvisitors_purpose"}},C=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/editvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/editcomplaint_type";case"source":return"api/branchapi/frontoffice/editsource";case"reference":return"api/branchapi/frontoffice/editreference";default:return"api/branchapi/frontoffice/editvisitors_purpose"}},S=L=>{switch(a){case"purpose":return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:L};case"complainType":return{url:"api/branchapi/frontoffice/deletecomplaint_type",id:L};case"source":return{url:"api/branchapi/frontoffice/deletesource",id:L};case"reference":return{url:"api/branchapi/frontoffice/deletereference",id:L};default:return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:L}}},x=r.useMemo(()=>{const L=u(),B=L.includes("?")?L.endsWith("?")||L.endsWith("&")?"":"&":"?";return`${L}${B}page=${i.page}&per_page=${i.rowsPerPage}`},[a,i.page,i.rowsPerPage]),{isLoading:m,error:j,data:T,mutate:R}=W(t?[x,t]:null,([L,B])=>K(L,B)),I=async(L,B)=>{try{await R(Ee(L,B,t),ze(B)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},_=async L=>{const{url:B,id:b}=S(L);try{await R(qe(B,b,t),Ne(b)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},A=async(L,B,b)=>{try{const P=await Be(L,B,t);R(P),Array.isArray(P?.data)&&R(`${u().replace(/\?.*$/,"")}?id=${b}`,P),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},f=async(L,B)=>{L.preventDefault();const b=new FormData(L.target),P=C();await A(P,b,B),L.target.reset(),d(!1)},g=async L=>{L.preventDefault();const B=new FormData(L.target),b=p();await I(b,B),L.target.reset()},D=L=>{d(L)},k=r.useMemo(()=>ti[a]||ti.purpose,[a]);return e.jsx(v,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Setup Front Office"})}),e.jsxs(v,{p:3,children:[e.jsx(n.Tabs,{activeKey:a,onChange:L=>{s(L),o({page:1,rowsPerPage:10})},items:pa}),e.jsxs(n.Row,{gutter:[16,16],mt:3,children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx("form",{onSubmit:g,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Add ",pa.find(L=>L.key===a)?.label]})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{required:!0,name:a==="reference"?"title":"name",type:"text",label:pa.find(L=>L.key===a)?.label+" *"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})})})]})})]})})}),e.jsx(n.Col,{xs:24,md:16,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:[pa.find(L=>L.key===a)?.label," List"]})}),e.jsxs(v,{pt:3,children:[e.jsx(wt,{data:{tableRef:c}}),e.jsx(Te,{parentCallback:y,data:{newData:T,columns:k,action:!0,ActionView:h,Loading:m,error:j,editDesign:e.jsx(Op,{data:{handleUpdate:f,token:t,activeTab:a}}),deleteTodoMutation:_,open:l,DrawerUpdate:D,viewDetails:""}})]})]})})]})]})]})})})})}function Op({data:t}){const{handleUpdate:a,token:s,activeTab:i}=t||{},o=r.useContext(At),d=(m=>{switch(m){case"purpose":return ei;case"complainType":return Rp;case"source":return Ip;case"reference":return kp;default:return ei}})(i).replace(/\?.*$/,""),{isLoading:c,data:y}=W(s&&o?[d,o,s]:null,([m,j,T])=>ja(m,{id:j},T)),h=y?.data?.[0],[u,p]=r.useState({name:"",description:""});r.useEffect(()=>{h&&p({name:h?.visitors_purpose||h?.complaint_type||h?.source||h?.reference||"",description:h?.description||""})},[h]);const C=(m,j)=>{p(T=>({...T,[m]:j}))};if(c)return e.jsx(v,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})});const x={purpose:"title",complainType:"title",source:"title",reference:"title"}[i]||"name";return e.jsxs(v,{pt:4,pb:1,style:{width:350},children:[e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Edit ",pa.find(m=>m.key===i)?.label]})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:m=>a(m,o),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{type:"text",value:o,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{name:x,type:"text",label:pa.find(m=>m.key===i)?.label+" *",required:!0,value:u.name,onChange:m=>C("name",m.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description",value:u.description,onChange:m=>C("description",m.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})]})})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Mp="api/branchapi/Student/studentGatePass",Ta="api/branchapi/Student/studentGatePassList";function Ep({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:25}),[i,o]=r.useState(!1),l=r.useRef(null),d=(I,_)=>{s({page:I,rowsPerPage:Number.parseInt(_,10)})},c=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],{data:y,mutate:h}=W(t?[Mp,t]:null,([I,_])=>K(I,_)),u=r.useMemo(()=>{const I=Ta.includes("?")?Ta.endsWith("?")||Ta.endsWith("&")?"":"&":"?";return`${Ta}${I}page=${a.page}&per_page=${a.rowsPerPage}`},[Ta,a.page,a.rowsPerPage]),{isLoading:p,error:C,data:S,mutate:x}=W(t?[u,t]:null,([I,_])=>K(I,_)),m=async I=>{const _="api/branchapi/frontoffice/deletevisitors";try{await x(deleteData(_,I,t),Ne(I)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},j=I=>{o(I)},T=()=>{},R=[{title:"Name",dataIndex:"lastname",key:"lastname",render:(I,_)=>`${_?.lastname||""} ${_?.firstname||""}`.trim()},{title:"Class",dataIndex:"class_name",key:"class_name",render:(I,_)=>`${_?.class_name||""}-${_?.section_name||""}`},{title:"Father Name",dataIndex:"father_name",key:"father_name"},{title:"Authorized Persons",dataIndex:"authorized_persons_fullname",key:"authorized_persons_fullname"},{title:"Relation",dataIndex:"authorized_persons_relation",key:"authorized_persons_relation"},{title:"Generated Date",dataIndex:"genrated_date_time",key:"genrated_date_time"},{title:"Return Date",dataIndex:"expected_return_date_time",key:"expected_return_date_time"},{title:"Reason",dataIndex:"reason",key:"reason"},{title:"Action",key:"action",render:(I,_)=>e.jsx(n.Tag,{color:_?.status==="Generated"?"green":"blue",children:_?.status||"Pending"})},{title:"Print",key:"print",render:(I,_)=>e.jsx(te.PrinterOutlined,{style:{color:"#3892ee",cursor:"pointer"},onClick:()=>window.print()})}];return e.jsx(v,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Today Gate Pass"})}),e.jsx(v,{pt:3,children:e.jsx(n.List,{grid:{column:4,gutter:16},dataSource:y?.data||[],style:{padding:0},renderItem:I=>e.jsx(n.List.Item,{style:{padding:0},children:e.jsx(n.Card,{size:"small",style:{marginBottom:8,width:"100%"},children:e.jsxs(v,{children:[e.jsxs(n.Typography.Text,{strong:!0,children:[I?.lastname," ",I?.firstname]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:[I?.class_name,"-",I?.section_name]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:["Return: ",I?.expected_return_date_time]}),e.jsx("br",{}),e.jsx(ne,{type:"button",value:"Print",color:"primary",size:"small",onClick:()=>window.print(),style:{marginTop:4}})]})})})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Gate Pass List"})}),e.jsxs(v,{pt:3,children:[e.jsx(wt,{data:{tableRef:l}}),e.jsx(Te,{parentCallback:d,data:{newData:S,columns:R,action:!1,ActionView:c,Loading:p,error:C,editDesign:"",deleteTodoMutation:m,open:i,DrawerUpdate:j,viewDetails:T}})]})]})})]})})}const mt=({id:t,funcName:a,disabled:s=!1})=>{const i="Data",[o,l]=r.useState(!1),d=()=>{l(!0),a(t),n.message.success(`${i} deleted successfully!`)},c=()=>{n.message.info(`Deletion of ${i} cancelled`)};return e.jsx(n.Popconfirm,{title:`Delete ${i}?`,description:`Are you sure you want to delete ${i}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:s||o,children:e.jsx(n.Button,{danger:!0,disabled:s,loading:o,icon:e.jsx(te.DeleteOutlined,{}),size:"small"})})},ai={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Fp({token:t,sampleTemplateUrl:a=_c}){const[s,i]=r.useState({pagination:{current:1,pageSize:10}}),[o,l]=r.useState(!1),[d,c]=r.useState(null),[y,h]=r.useState(null),[u,p]=r.useState(!1),[C,S]=r.useState([]),x=`api/branchapi/Transport/routeTableList?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,m="api/branchapi/Transport/addroute",j="api/branchapi/Transport/editroute",T="api/branchapi/Transport/deleteroute",R=void 0,{isLoading:I,data:_,error:A,mutate:f}=W(t?[x,t]:null,([z,E])=>K(z,E)),g=r.useMemo(()=>!_?.data||Array.isArray(_.data)?[]:_.data?.rows||[],[_]),D=_?.data?.pagination?.total_rows||_?.pagination?.total_rows||0,k=async(z,E)=>{try{await f(Ee(z,E,t),ze(E)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},L=z=>{z.preventDefault();const E=new FormData(z.target);k(m,E),z.target.reset()},B=(z,E)=>{i(M=>({...M,pagination:{current:z,pageSize:parseInt(E,10)}}))},b=async z=>{try{await f(qe(T,z,t),Ne(z)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},P=z=>{c(z),l(!0)},O=async z=>{try{const E=await Be(j,z,t);f(E),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),c(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},F=async z=>{z.preventDefault();const E=new FormData(z.target);E.append("id",d?.id),O(E)},U=async()=>{if(!y){w.error("Please select an Excel file to upload.",{duration:1e3});return}p(!0),S([]);try{const z=new FormData;z.append("file",y);const M=await(await fetch(`${R}`,{method:"POST",headers:{Authorization:t},body:z})).json();if(M.Status==="Success"){const $=M.data?.rows||[];S($);const q=M.data?.success_count||0,H=M.data?.failed_count||0;w.success(M.message||`Route bulk upload completed. ${q} succeeded, ${H} failed.`,{duration:1e3}),q>0&&f()}else w.error(M.message||"Failed to upload routes.",{duration:1e3})}catch(z){w.error(z?.message||"Something went wrong.",{duration:1e3})}finally{p(!1),h(null)}},N=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(z,E)=>(z.route_title||"").localeCompare(E.route_title||"")}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(z,E)=>Number(z.fare||0)-Number(E.fare||0)}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(z,E)=>(z.note||"").localeCompare(E.note||"")}},{title:"Action",key:"action",render:(z,E)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>P(E),style:{padding:2}}),e.jsx(mt,{id:E?.id,funcName:b})]})}],Y=d?.route_title?`Edit ${d.route_title}`:"Edit Route";return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Routes"})}),e.jsxs(v,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:z=>(h(z),!1),children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),disabled:u,children:y?y.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(n.Button,{type:"primary",onClick:U,disabled:u||!y,loading:u,children:u?"Uploading...":"Upload Routes"})})})]}),C.length>0&&e.jsxs(v,{mt:3,children:[e.jsx(ge,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:C.map((z,E)=>({...z,key:E})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Title",dataIndex:"title"},{title:"Status",dataIndex:"status",render:z=>e.jsx("span",{style:{color:z==="Success"?"green":"red",fontWeight:500},children:z})},{title:"Message",dataIndex:"message"}]})]}),a&&e.jsx(v,{mt:2,children:e.jsx("a",{href:a,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Add Route"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:L,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(V,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(V,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(V,{type:"text",name:"note",label:"Note"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(v,{children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:ai,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Route List"})}),e.jsx(v,{p:3,children:e.jsx(Te,{parentCallback:B,data:{newData:{data:g,pagination:{total_rows:D}},columns:N,columnstype:"antd",action:!1,Loading:I,error:A,deleteTodoMutation:b}})})]})})]}),e.jsx(n.Drawer,{open:o,title:Y,placement:"right",width:420,onClose:()=>{l(!1),c(null)},children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"title",label:"Title",defaultValue:d?.route_title||"",required:"required"}),e.jsx(V,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:d?.fare||"",required:"required"}),e.jsx(V,{type:"text",name:"note",label:"Note",defaultValue:d?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(V,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),c(null)},style:ai,children:"Cancel"})]})]})})})]})}const ni={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Up({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${a.page}&per_page=${a.rowsPerPage}`,y="api/branchapi/Transport/addvehicles",h="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:p,data:C,error:S,mutate:x}=W(t?[c,t]:null,([D,k])=>K(D,k)),m=async(D,k)=>{try{await x(Ee(D,k,t),ze(k)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},j=D=>{D.preventDefault();const k=new FormData(D.target);m(y,k),D.target.reset()},T=async D=>{try{await x(qe(u,D,t),Ne(D)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},R=D=>{d(D),o(!0)},I=async D=>{try{await Be(h,D,t),await x(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},_=async D=>{D.preventDefault();const k=new FormData(D.target);k.append("id",l?.id),I(k)},A=(D,k)=>{s({page:D,rowsPerPage:parseInt(k,10)})},f=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(D,k)=>D.vehicle_no.localeCompare(k.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(D,k)=>D.vehicle_model.localeCompare(k.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(D,k)=>D.seating_capacity-k.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(D,k)=>D.manufacture_year-k.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(D,k)=>D.gps_url.localeCompare(k.gps_url)},render:(D,k)=>e.jsx("span",{title:k?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:k?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(D,k)=>D.note.localeCompare(k.note)}},{title:"Action",key:"action",render:(D,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>R(k),style:{padding:2}}),e.jsx(mt,{id:k?.id,funcName:T})]})}],g=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:i,title:g,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(V,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(V,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(V,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(V,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(V,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:ni,children:"Cancel"})]})]})})}),e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(v,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(V,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(V,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(V,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(V,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(V,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:ni,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(v,{children:e.jsx(Te,{parentCallback:A,data:{newData:C,columns:f,columnstype:"antd",action:!1,Loading:p,error:S,deleteTodoMutation:T}})})]})})]})})]})}const $p={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},si=({dataIndex:t,title:a,record:s,children:i,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:i}):i});function Np({token:t}){const[a,s]=r.useState(!1),[i,o]=r.useState({pagination:{current:1,pageSize:50}}),[l,d]=r.useState(null),[c,y]=r.useState([]),h="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",p="api/branchapi/Transport/getchechkedVehicleData",C="api/branchapi/Transport/assignedVehicleTable",S="api/branchapi/transport/assignvehicle",x="api/branchapi/Transport/deleteassignvehicle",m=l?`${p}?route_id=${l}`:null,{isLoading:j,data:T,mutate:R}=W(t?[`${C}?page=${i.pagination.current}&per_page=${i.pagination.pageSize}`,t]:null,([M,$])=>K(M,$)),{data:I}=W(t&&h?[h,t]:null,([M,$])=>K(M,$)),{data:_}=W(t&&u?[u,t]:null,([M,$])=>K(M,$)),A=t&&m?[m,t]:null,{isLoading:f,data:g}=W(A,([M,$])=>K(M,$)),{Status:D="Failed",pagination:{total_rows:k=0}={}}=T||{},{data:L=[]}=D==="Success"?T:{},B=r.useMemo(()=>{const M=I?.data??I??[];return Array.isArray(M)?M:[]},[I]),b=r.useMemo(()=>{const M=_?.data??_??[];return(Array.isArray(M)?M:[]).map(q=>{if(q==null)return null;if(typeof q=="string"||typeof q=="number")return{label:String(q),value:q};const H=q.value??q.vehicle_id??q.id??q.vehicleID,re=q.label??q.vehicle_name??q.vehicle_no??q.vehicle_number??q.name??String(H??"");return H==null||re===""?null:{label:String(re),value:H}}).filter(Boolean)},[_]),P=r.useMemo(()=>{const M=g?.data??g??[];return(Array.isArray(M)?M:[]).map(q=>q?.value??q?.vehicle_id??q?.id??q).filter(q=>q!=null)},[g]);r.useEffect(()=>{y(P)},[P,a]);const O=async(M,$,q)=>{try{await R(Ee(M,$,t),ze($)),m&&W.mutate(A),s(H=>!H),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(H){w.error(H?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},F=M=>{M.preventDefault();const $=new FormData;$.append("route_id",l??""),c.length?c.forEach(q=>$.append("vehicle_ids[]",q)):$.append("vehicle_ids[]",""),O(S,$)},U=M=>{o($=>({...$,pagination:{current:M,pageSize:$.pagination.pageSize}}))},N=async M=>{try{await R(qe(x,M,t),Ne(M)),m&&W.mutate(A),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},Y=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(M,$,q)=>e.jsx(e.Fragment,{children:$.children.map((H,re,ee)=>e.jsx("span",{children:`${H.vehicle_name} ${re+1===ee.length?"":","}`},`${re}vehicle001`))})},{title:"Action",render:(M,$,q)=>e.jsx(e.Fragment,{children:e.jsx(mt,{id:$?.route_id,funcName:N})})}],z=M=>{const $=["route_id","index"];for(let q=0;q<$.length;q++)if(M[$[q]])return M[$[q]]},E=M=>{const{children:$=[]}=M||{},q=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:H=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:H=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:H=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:H=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:H=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:H=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:H=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:si}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:q,rowKey:H=>z(H)+"cell01",dataSource:$,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(v,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:M=>{d(M?.value??null),s($=>!$)}})}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:e.jsx(n.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:b,value:c,onChange:M=>y(M),disabled:!l||f})},`check001${a}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),y([]),s(M=>!M)},style:$p,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(v,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:si}},columns:Y,bordered:!0,rowKey:M=>z(M),dataSource:Array.isArray(L)?L:[],loading:j,expandable:{expandedRowRender:E,childrenColumnName:"changed"},pagination:{current:i.pagination.current,pageSize:i.pagination.pageSize,total:k,showSizeChanger:!0,onChange:U,onShowSizeChange:(M,$)=>{o(q=>({...q,pagination:{current:1,pageSize:$}}))},showTotal:(M,$)=>`${$[0]}-${$[1]} of ${M} items`}})})]})})]})})]})}const ri={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},_s=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},oa=(t,a,s)=>{if(a==null||a==="")return null;const i=t.find(o=>String(o.value)===String(a));return i||(s?{label:String(s),value:a}:{label:String(a),value:a})},Lp=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Bp=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(s=>s!=null&&s!==""&&String(s).toLowerCase()!=="null"&&String(s).toLowerCase()!=="undefined").join(", ");const a=String(t).trim();return!a||a.toLowerCase()==="null"||a.toLowerCase()==="undefined"?"":a};function qp({token:t,assignmentId:a,studentName:s,onClose:i,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",y="api/branchapi/Transport/getvehicleListByRouteIdwithCount",h="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[p,C]=r.useState(null),[S,x]=r.useState(null),[m,j]=r.useState(null),[T,R]=r.useState(ae()),[I,_]=r.useState(""),[A,f]=r.useState(0),[g,D]=r.useState(0),{data:k,isLoading:L}=W(t&&a?[`${l}?id=${a}`,t]:null,([X,ce])=>K(X,ce)),B=r.useMemo(()=>{if(!k||k?.Status&&k.Status!=="Success")return null;const X=k?.data??k;return Array.isArray(X)?X[0]??null:X},[k]);r.useEffect(()=>{const X=B?.fk_route_id??B?.route_id;X!=null&&C(X),B?.vehicle_id!=null&&x(B.vehicle_id),B?.stop_id!=null&&j(B.stop_id),R(B?.start_date?ae(B.start_date):ae()),_(Bp(B?.service_push))},[B]);const b=t&&p?`${y}?route_id=${p}`:null,P=t&&p?`${u}?id=${p}`:null,O=t&&p?`${h}?route_id=${p}`:null,{data:F}=W(t&&c?[c,t]:null,([X,ce])=>K(X,ce)),{data:U,isLoading:N}=W(b?[b,t]:null,([X,ce])=>K(X,ce)),{data:Y,isLoading:z}=W(O?[O,t]:null,([X,ce])=>K(X,ce)),{data:E}=W(P?[P,t]:null,([X,ce])=>K(X,ce)),M=r.useMemo(()=>_s(F),[F]),$=r.useMemo(()=>_s(U),[U]),q=r.useMemo(()=>_s(Y),[Y]),H=k?.data[0]?.rootCost,re=Lp(),ee=s||[B?.firstname,B?.lastname].filter(Boolean).join(" ")||"",G=(X,ce)=>{switch(ce){case"route_id":C(X?.value??null),x(null),j(null),f(Re=>Re+1),D(Re=>Re+1);break;case"vehicle_id":x(X?.value??null),j(null),D(Re=>Re+1);break;case"stop_id":j(X?.value??null);break}},J=async X=>{if(X.preventDefault(),!p||!S||!m){w.error("Please select Route, Vehicle and Stop",{duration:1200});return}const ce=new FormData;ce.append("id",String(a)),ce.append("student_id",String(B?.fk_student_id??B?.student_id??"")),ce.append("fk_route_id",String(p)),ce.append("vehicle_id",String(S)),ce.append("stop_id",String(m)),ce.append("rootCost",String(H??"")),ce.append("start_date",T?.isValid?.()?T.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),ce.append("puse_service",String(I??""));try{await Be(d,ce,t),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),i?.()}catch(Re){w.error(Re?.message??"Failed to update the item.",{duration:1e3})}};if(L||!(B&&!L&&(!p||!N&&!z)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(n.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(n.Button,{type:"text",onClick:i,style:ri,children:"Close"})]});const pe=B.fk_route_id??B.route_id,_e=oa(M,pe,B.route_title),le=oa($,B.vehicle_id,B.vehicle_name??B.vehicle_no),de=oa(q,B.stop_id,B.stop_name??B.stoppage_name);return e.jsx("form",{onSubmit:J,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"title",label:"Student",defaultValue:ee,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:B.fk_student_id??B.student_id??""}),e.jsx(Q,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:oa(M,p,_e?.label)??null,onChange:X=>G(X,"route_id")}),e.jsx(Q,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:oa($,S,le?.label)??null,onChange:X=>G(X,"vehicle_id")},`edit-vehicle-${A}`),e.jsx(Q,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:oa(q,m,de?.label)??null,onChange:X=>G(X,"stop_id")},`edit-stop-${g}`),e.jsx(V,{type:"text",label:"Route Cost",value:H!=null?`${re}${H}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:H??""}),e.jsx(Me,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:T,onChange:X=>R(X)}),e.jsx(V,{type:"text",label:"Pause Service",value:I,onChange:X=>_(X?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:i,style:ri,children:"Cancel"})]})]})},`edit-${a}-${A}`)}const ii={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},zp=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[]},Ra=t=>zp(t),Yp=t=>t||"",Vp=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Wp=t=>{const a=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return a==="page"||a==="sendpage"?"page":"drawer"},Hp=(t,a)=>{const s=a||"/TransportDashboard/EditAssignStudentTransport?id={id}",i=t?.id??"",o=encodeURIComponent(String(i));if(s.includes("{id}"))return s.replaceAll("{id}",o);if(s.includes(":id"))return s.replace(":id",o);try{const d=new URL(s,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(i)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=s.includes("?")?"&":"?";return`${s}${l}id=${o}`};function Kp({token:t,editType:a,onNavigate:s,editPagePath:i,sampleTemplateUrl:o=Cc}){const d=Wp(a)==="drawer",c="api/branchapi/academy/classdropdownlist",y="api/branchapi/academy/sectionoftheClass",h="api/branchapi/Transport/routeStudentList",u="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleListByRouteIdwithCount",C="api/branchapi/Transport/getStoppageDropdown",S="api/branchapi/Transport/routeShowdata",x="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",j="api/branchapi/transport/assignTransportRoutesStudentBulk",[T,R]=r.useState(null),[I,_]=r.useState(!1),[A,f]=r.useState(!1),[g,D]=r.useState(null),[k,L]=r.useState(null),[B,b]=r.useState(null),[P,O]=r.useState(null),[F,U]=r.useState(!1),[N,Y]=r.useState(!1),[z,E]=r.useState({page:1,rowsPerPage:50}),[M,$]=r.useState(null),[q,H]=r.useState(!1),[re,ee]=r.useState(null),[G,J]=r.useState(null),[ie,pe]=r.useState(null),[_e,le]=r.useState(null),[de,X]=r.useState(null),[ce,Re]=r.useState(null),[Ue,ke]=r.useState(null),[Ve,Le]=r.useState(ae()),[at,Ge]=r.useState(""),[Fe,Je]=r.useState(null),[it,fe]=r.useState(!1),[Se,je]=r.useState([]),se=(be,Ce)=>{const Xe=be?.value??null;switch(Ce){case"class_id":pe(Xe),le(null),$(Xe?`${y}?class_id=${encodeURIComponent(String(Xe))}`:null),_(It=>!It);break;case"route_id":X(Xe),Re(null),ke(null),J(Xe),L(Xe?`${p}?route_id=${encodeURIComponent(String(Xe))}`:null),b(Xe?`${S}?id=${encodeURIComponent(String(Xe))}`:null),O(null),U(It=>!It),Y(It=>!It);break;case"vehicle_id":Re(Xe),ke(null),O(de?`${C}?route_id=${encodeURIComponent(String(de))}`:null),Y(It=>!It);break;case"stop_id":ke(Xe);break}},me=be=>{if(d){D(be),f(!0);return}const Ce=Hp(be,i);if(typeof s=="function"){s(Ce,be);return}typeof window<"u"&&Ce&&window.location.assign(Ce)},xe=()=>{f(!1),D(null)},oe=g?`Edit — ${g.firstname??""} ${g.lastname??""}`.trim():"Edit Student Transport",{data:ye}=W(t&&c?[c,t]:null,([be,Ce])=>K(be,Ce)),{data:Ye}=W(t&&M?[M,t]:null,([be,Ce])=>K(be,Ce)),{data:vt}=W(t&&k?[k,t]:null,([be,Ce])=>K(be,Ce)),{data:Dt}=W(t&&P?[P,t]:null,([be,Ce])=>K(be,Ce)),{data:xt}=W(t&&B?[B,t]:null,([be,Ce])=>K(be,Ce)),{data:Et}=W(t&&u?[u,t]:null,([be,Ce])=>K(be,Ce)),Zt=t&&T?`${T}&page=${z.page}&per_page=${z.rowsPerPage}`:null,{isLoading:he,error:ve,data:lt,mutate:bt}=W(Zt?[Zt,t]:null,([be,Ce])=>K(be,Ce)),on=r.useMemo(()=>Ra(ye),[ye]),ln=r.useMemo(()=>Ra(Ye),[Ye]),dn=r.useMemo(()=>Ra(vt),[vt]),cn=r.useMemo(()=>Ra(Dt),[Dt]),un=r.useMemo(()=>Ra(Et),[Et]),ue=xt?.data?.[0]?.fare??xt?.data?.fare??xt?.fare??xt?.data?.data?.[0]?.fare??xt?.data?.data?.fare;r.useEffect(()=>{ue==null||ue===""||Ge(String(ue))},[ue]);const we=async be=>{try{await bt(qe(m,be,t),Ne(be)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},$e=async()=>{if(!Fe){w.error("Please select an Excel file to upload.",{duration:1e3});return}fe(!0),je([]);try{const be=new FormData;be.append("file",Fe);const Xe=await(await fetch(`${j}`,{method:"POST",headers:{Authorization:t},body:be})).json();if(Xe.Status==="Success"){const It=Xe.data?.rows||[];je(It);const yr=Xe.data?.success_count||0,wl=Xe.data?.failed_count||0;w.success(Xe.message||`Transport bulk upload completed. ${yr} succeeded, ${wl} failed.`,{duration:1e3}),yr>0&&bt()}else w.error(Xe.message||"Failed to upload student transport assignments.",{duration:1e3})}catch(be){w.error(be?.message||"Something went wrong.",{duration:1e3})}finally{fe(!1),Je(null)}},Qe=[{title:"Route Status",key:"route_status",render:(be,Ce)=>Ce.fk_route_id?e.jsx("span",{children:Ce.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(be,Ce)=>Yp(Ce.start_date)},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Roll No",dataIndex:"roll_no",key:"roll_no"},{title:"Name",key:"name",render:(be,Ce)=>`${Ce.firstname} ${Ce.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(be,Ce)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:Ce.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(mt,{id:Ce?.id,funcName:we}),e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>me(Ce),style:{padding:2}})]}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.PlusOutlined,{}),onClick:()=>cs(Ce.student_id),style:{padding:2}})})}],ot=async(be,Ce)=>{try{await bt(Ee(be,Ce,t),ze(Ce)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),H(!1),us()}catch{w.error("Failed to add the new item.",{duration:1e3})}},ht=be=>{if(be.preventDefault(),!ie||!_e){w.error("Please select Class and Section",{duration:1200});return}R(`${h}?cID=${encodeURIComponent(String(ie))}&sID=${encodeURIComponent(String(_e))}`),E(Ce=>({...Ce,page:1}))},ds=(be,Ce)=>{E({page:be,rowsPerPage:parseInt(Ce,10)})},cs=be=>{ee(be),H(!0)},va=be=>{if(be.preventDefault(),!re){w.error("Student is required",{duration:1200});return}if(!de||!ce||!Ue){w.error("Please select Route, Vehicle and Stop",{duration:1300});return}const Ce=new FormData;Ce.append("student_id",String(re)),Ce.append("fk_route_id",String(de)),Ce.append("vehicle_id",String(ce)),Ce.append("stop_id",String(Ue)),Ce.append("start_date",Ve?.isValid?.()?Ve.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),Ce.append("rootCost",String(at??"")),ot(x,Ce)},us=()=>{H(!1),L(null),b(null),O(null),J(null),X(null),Re(null),ke(null),Le(ae()),Ge(""),U(be=>!be),Y(be=>!be)},Sl=Vp();return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Assign Students to Transport"})}),e.jsxs(v,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:be=>(Je(be),!1),children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),disabled:it,children:Fe?Fe.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(n.Button,{type:"primary",onClick:$e,disabled:it||!Fe,loading:it,children:it?"Uploading...":"Upload Students"})})})]}),o&&e.jsx(v,{mt:2,children:e.jsx("a",{href:o,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})}),Se.length>0&&e.jsxs(v,{mt:3,children:[e.jsx(ge,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:Se.map((be,Ce)=>({...be,key:Ce})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Student ID",dataIndex:"student_id"},{title:"Status",dataIndex:"status",render:be=>e.jsx("span",{style:{color:be==="Success"?"green":"red",fontWeight:500},children:be})},{title:"Message",dataIndex:"message"}]})]})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Search Students"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:ht,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{options:on,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:be=>se(be,"class_id"),required:!0,allowSelectAll:!1,value:on.find(be=>String(be.value)===String(ie))??null})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{options:ln,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:ln.find(be=>String(be.value)===String(_e))??null,onChange:be=>le(be?.value??null)},`section1${I}`)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{display:"flex",alignItems:"center",height:"100%",mt:2,children:[e.jsx(ne,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{R(null),$(null),pe(null),le(null),_(be=>!be)},style:ii,children:"Cancel"})]})})]})})})]})}),T&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(v,{p:3,children:e.jsx(Te,{parentCallback:ds,data:{newData:lt,columns:Qe,columnstype:"antd",action:!1,Loading:he,error:ve,deleteTodoMutation:we,pageController:z}})})]})})]}),e.jsx(n.Drawer,{open:A,title:oe,placement:"right",width:420,destroyOnClose:!0,onClose:xe,children:g?.id&&e.jsx(qp,{token:t,assignmentId:g.id,studentName:`${g.firstname??""} ${g.lastname??""}`.trim(),onClose:xe,onSuccess:()=>bt()})}),e.jsx(n.Modal,{open:q,title:"Assign Student to Transport",onCancel:us,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:va,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:un,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:un.find(be=>String(be.value)===String(de))??null,onChange:be=>se(be,"route_id")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:dn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:dn.find(be=>String(be.value)===String(ce))??null,onChange:be=>se(be,"vehicle_id")},`vehicle001${F}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:cn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:cn.find(be=>String(be.value)===String(Ue))??null,onChange:be=>se(be,"stop_id")},`stop001${N}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Ve,onChange:be=>Le(be)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{type:"text",name:"rootCost",label:"Route Cost",value:at,onChange:be=>Ge(be?.target?.value??"")})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(v,{display:"flex",alignItems:"center",gap:12,children:[e.jsx(ne,{type:"submit",value:String(at??"").trim()?`${Sl}${at} — Assign`:"Assign",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:us,style:ii,children:"Cancel"})]})})]})})})]})}const oi={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},fn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Gp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:50}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,y]=r.useState(""),[h,u]=r.useState(""),[p,C]=r.useState(""),[S,x]=r.useState(!1),m=`api/branchapi/Transport/getdriverTable?page=${a.page}&per_page=${a.rowsPerPage}`,j="api/branchapi/Transport/add_driver",T="api/branchapi/Transport/edit_driver",R="api/branchapi/Transport/deletedriver",I="api/branchapi/staff/uploadDocuments",_=r.useMemo(()=>String(I).startsWith("http")?I:`${He()??""}${String(I).replace(/^\/+/,"")}`,[I]),A=He()??"",{isLoading:f,data:g,error:D,mutate:k}=W(t?[m,t]:null,([z,E])=>K(z,E)),L=async(z,E)=>{try{await Ee(z,E,t),await k(),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),y("")}catch(M){w.error(M?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},B=z=>{z.preventDefault();const E=new FormData(z.target);L(j,E),z.target.reset()},b=async z=>{try{await k(qe(R,z,t),Ne(z)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},P=z=>{d(z),y(z?.image??""),o(!0)},O=async z=>{try{await Be(T,z,t),await k(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),y("")}catch(E){w.error(E?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},F=z=>{z.preventDefault();const E=new FormData(z.target);E.append("id",l?.id??""),O(E)},U=(z,E)=>{s({page:z,rowsPerPage:parseInt(E,10)})},N=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(z,E)=>String(z?.name??"").localeCompare(String(E?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(z,E)=>String(z?.Driver_licence??"").localeCompare(String(E?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(z,E)=>Number(z?.contact_number??0)-Number(E?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(z,E)=>String(z?.address??"").localeCompare(String(E?.address??""))}},{title:"Image",key:"image",width:100,render:(z,E)=>{const M=E?.image?`${A}staff/document/${E.image}`:"";return M?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(n.Image,{width:80,src:M,preview:{visible:!1,onVisibleChange:()=>{x(!0),u(M),C(E?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(z,E)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>P(E),style:{padding:2}}),e.jsx(mt,{id:E?.id,funcName:b})]})}],Y=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:i,title:Y,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),y("")},children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(V,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(V,{type:"number",name:"contact_number",label:"Driver Contact",defaultValue:l?.contact_number??"",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:fn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",defaultValue:l?.address??"",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:fn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:_,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const E=z?.file?.response,M=E?.data??E?.filename??E?.file??E?.path??"";M&&y(String(M))},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),disabled:!_,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),y("")},style:oi,children:"Cancel"})]})]})})}),e.jsx(n.Modal,{zIndex:9999,open:S,title:p,footer:null,onCancel:()=>x(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:h})}),e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(v,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(v,{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(V,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(V,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(V,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:fn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:fn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:_,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const E=z?.file?.response,M=E?.data??E?.filename??E?.file??E?.path??"";M&&y(String(M))},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),disabled:!_,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>y(""),style:oi,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(v,{children:e.jsx(Te,{parentCallback:U,data:{newData:g,columns:N,columnstype:"antd",action:!1,Loading:f,error:D,deleteTodoMutation:b}})})]})})]})})]})}const li={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},la={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},yn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},di=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],gn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Jp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:50}),[i,o]=r.useState(!1),[l,d]=r.useState(!1),[c,y]=r.useState(null),[h,u]=r.useState(null),[p,C]=r.useState(null),[S,x]=r.useState(null),[m,j]=r.useState(ae()),[T,R]=r.useState(ae()),[I,_]=r.useState("pick"),[A,f]=r.useState(!1),[g,D]=r.useState(null),[k,L]=r.useState(null),[B,b]=r.useState(!1),[P,O]=r.useState(null),[F,U]=r.useState(null),[N,Y]=r.useState(null),[z,E]=r.useState(null),[M,$]=r.useState(ae()),[q,H]=r.useState(ae()),[re,ee]=r.useState("pick"),G=`api/branchapi/Transport/assignRouteTimeList?page=${a.page}&per_page=${a.rowsPerPage}`,J="api/branchapi/Transport/assignRouteTime",ie="api/branchapi/Transport/editAssignRouteTime",pe="api/branchapi/Transport/deleteAssignRouteTime",_e="api/branchapi/Transport/driverDropdown",le="api/branchapi/transport/routeTimetableShowdata",de="api/branchapi/Transport/getrouteDropdown",X="api/branchapi/Transport/getvehicleDropdown",{isLoading:ce,data:Re,error:Ue,mutate:ke}=W(t?[G,t]:null,([he,ve])=>K(he,ve)),{data:Ve}=W(t&&de?[de,t]:null,([he,ve])=>K(he,ve)),{data:Le}=W(t&&_e?[_e,t]:null,([he,ve])=>K(he,ve)),at=r.useMemo(()=>c?`${X}?route_id=${c}`:null,[c,X]),{data:Ge}=W(t&&at?[at,t]:null,([he,ve])=>K(he,ve)),Fe=r.useMemo(()=>gn(Ve),[Ve]),Je=r.useMemo(()=>gn(Le),[Le]),it=r.useMemo(()=>gn(Ge),[Ge]),fe=(he,ve)=>{s({page:he,rowsPerPage:parseInt(ve,10)})},Se=async he=>{he.preventDefault();const ve=new FormData(he.target);ve.set("route_id",h?.value??c??""),ve.set("driver_id",p?.value??""),ve.set("vehicle_id",S?.value??""),ve.set("start_time",m?m.format("h:mm a"):""),ve.set("drop_time",T?T.format("h:mm a"):""),ve.set("type",I);try{await Ee(J,ve,t),await ke(),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),he.target.reset(),y(null),u(null),C(null),x(null),d(lt=>!lt),j(ae()),R(ae()),_("pick"),o(lt=>!lt)}catch(lt){w.error(lt?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},je=async he=>{try{await qe(pe,he,t),await ke(),w.success("Success! Deleted item.",{duration:1e3})}catch(ve){w.error(ve?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},se=he=>{D(he),f(!0);const ve=he?.id??he?.route_time_id??he?.routeId??null;L(ve);const lt=he?.route_id??he?.routeId??he?.fk_route_id;O(lt??null),U(Fe.find(bt=>bt?.value===(lt??he?.route_id))??null),Y(Je.find(bt=>bt?.value===(he?.driver_id??he?.driverId))??null),E(null),b(bt=>!bt),$(he?.start_time?ae(he.start_time,["h:mm a","HH:mm"]):ae()),H(he?.drop_time?ae(he.drop_time,["h:mm a","HH:mm"]):ae()),ee(he?.type??"pick")},me=r.useMemo(()=>{if(!k)return null;const he=String(le).includes("?")?"&":"?";return`${le}${he}id=${encodeURIComponent(String(k))}`},[k,le]),{data:xe,isLoading:oe}=W(t&&me?[me,t]:null,([he,ve])=>K(he,ve)),ye=r.useMemo(()=>{const he=xe?.data??xe;return Array.isArray(he)?he[0]??null:Array.isArray(he?.data)?he.data[0]??null:he??null},[xe]),Ye=r.useMemo(()=>P?`${X}?route_id=${P}`:null,[P,X]),{data:vt}=W(t&&Ye?[Ye,t]:null,([he,ve])=>K(he,ve)),Dt=r.useMemo(()=>gn(vt),[vt]);r.useEffect(()=>{if(!ye)return;const he=ye?.route_id??ye?.fk_route_id??ye?.routeId;O(he??null),U(Fe.find(ve=>ve?.value===he)??null),Y(Je.find(ve=>ve?.value===ye?.driver_id)??null),E(null),$(ye?.start_time?ae(ye.start_time,["h:mm a","HH:mm"]):ae()),H(ye?.drop_time?ae(ye.drop_time,["h:mm a","HH:mm"]):ae()),ee(ye?.type??"pick"),b(ve=>!ve)},[Je,ye,Fe]),r.useEffect(()=>{if(!ye)return;const he=ye?.vehicle_id??ye?.vehicleId;he&&E(Dt.find(ve=>ve?.value===he)??null)},[ye,Dt]);const xt=async he=>{if(he.preventDefault(),!k)return;const ve=new FormData(he.target);ve.set("id",String(k)),ve.set("route_id",F?.value??P??""),ve.set("driver_id",N?.value??""),ve.set("vehicle_id",z?.value??""),ve.set("start_time",M?M.format("h:mm a"):""),ve.set("drop_time",q?q.format("h:mm a"):""),ve.set("type",re);try{await Be(ie,ve,t),await ke(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),f(!1),D(null)}catch(lt){w.error(lt?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Et=[{title:"Route Name",dataIndex:"route_title",key:"route_title"},{title:"Driver Name",dataIndex:"driver_name",key:"driver_name"},{title:"Vehicle Name",dataIndex:"vehicle_name",key:"vehicle_name"},{title:"Start Time",dataIndex:"start_time",key:"start_time"},{title:"End Time",dataIndex:"drop_time",key:"drop_time"},{title:"Type",dataIndex:"type",key:"type"},{title:"Action",key:"action",render:(he,ve)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>se(ve),style:{padding:2}}),e.jsx(mt,{id:ve?.id??ve?.routeId??ve?.route_time_id,funcName:je})]})}],Zt=g?.route_title?`Edit ${g.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:A,title:Zt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{f(!1),D(null),L(null),O(null),U(null),Y(null),E(null)},children:e.jsx("form",{onSubmit:xt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:oe?.6:1},children:[e.jsx(Q,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:F,onChange:he=>{O(he?.value??null),U(he??null),E(null),b(ve=>!ve)}}),e.jsx(Q,{options:Je,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:N,onChange:he=>Y(he??null)}),e.jsx(Q,{options:Dt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:z,onChange:he=>E(he??null)},`edit-vehicle-${B}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:M,onChange:he=>$(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:yn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:q,onChange:he=>H(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:yn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:di,optionType:"button",buttonStyle:"solid",value:re,onChange:he=>ee(he.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{f(!1),D(null)},style:li,children:"Cancel"})]})]})})}),e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(v,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:Se,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:h,onChange:he=>{y(he?.value??null),u(he??null),x(null),d(ve=>!ve)},allowSelectAll:!1,required:!0}),e.jsx(Q,{options:Je,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:p,onChange:he=>C(he??null),allowSelectAll:!1,required:!0}),e.jsx(Q,{options:it,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:S,onChange:he=>x(he??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:m,onChange:he=>j(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:yn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:T,onChange:he=>R(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:yn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:di,optionType:"button",buttonStyle:"solid",value:I,onChange:he=>_(he.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>{y(null),u(null),C(null),x(null),d(he=>!he),j(ae()),R(ae()),_("pick"),o(he=>!he)},style:li,children:"Cancel"})]})]})},`form-${i}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(v,{children:e.jsx(Te,{parentCallback:fe,data:{newData:Re,columns:Et,columnstype:"antd",action:!1,Loading:ce,error:Ue,deleteTodoMutation:je}})})]})})]})})]})}const Qp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ci={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ui={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},pi=({dataIndex:t,title:a,record:s,children:i,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:i}):i});let mi=2;function Xp({token:t}){const[a,s]=r.useState([]),[i,o]=r.useState(null),[l,d]=r.useState([]),[c,y]=r.useState({pagination:{current:1,pageSize:50}}),{isLoading:h,data:u,mutate:p}=W(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([O,F])=>K(O,F)),{Status:C="Failed",pagination:{total_rows:S=0}={}}=u||{},{data:x=[]}=C==="Success"?u:{},{data:m}=W(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([O,F])=>K(O,F)),j=r.useMemo(()=>{const O=m?.data??m??[];if(Array.isArray(O))return O;if(O&&typeof O=="object"){if(Array.isArray(O?.data))return O.data;if(Array.isArray(O?.data?.data))return O.data.data}return[]},[m]),{data:T}=W(t&&i?["api/branchapi/transport/getrouteStoppageData?route_id="+i,t]:null,([O,F])=>K(O,F)),{Status:R="Failed"}=T||{},I=async(O,F)=>{try{await p(Ee(O,F,t),ze(F)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},_=O=>O?typeof O=="string"?O:O?.isValid?.()?O.format("h:mm a"):"":"",A=(O,F=[])=>{const U=(Array.isArray(O)?O:[]).map(z=>({id:z?.id??"",name:String(z?.stop_name??z?.name??"").trim(),pickTime:_(z?.pickup_time??z?.pickTime??z?.pickupTime),drop_time:_(z?.drop_time??z?.dropTime)})),N=U.filter(z=>z?.id!=null&&String(z.id).trim()!==""),Y=U.filter(z=>!(z?.id!=null&&String(z.id).trim()!==""));return{route_id:i??"",edit_stoppage:N,add_stoppage:Y,delete_stoppage:Array.isArray(F)?F:[]}},f=O=>{O.preventDefault();const F="/api/branchapi/transport/addstoppageToRoute",U=A(a,l);I(F,U)},g=()=>{s(O=>[...Array.isArray(O)?O:[],{idKey:mi++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}])},D=O=>{if(a.length===1)return;const F=a[O];F?.id!=null&&String(F.id).trim()!==""&&!F?.idKey&&d(U=>{const N=Array.isArray(U)?U:[];return N.some(z=>String(z)===String(F.id))?N:[...N,F.id]}),s(U=>{const N=[...U];return N.splice(O,1),N})},k=O=>{y(F=>({...F,pagination:{current:O,pageSize:F.pagination.pageSize}}))},L=async O=>{const F="/api/branchapi/Transport/deletevehicle";try{await p(qe(F,O,t),Ne(O)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}};r.useEffect(()=>{if(R==="Success"){const O=Array.isArray(T?.data)?T.data:[];O.length>0?(s(O),d([])):i&&(s([{idKey:mi++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}]),d([]))}},[R,T,i]);const B=O=>{const{children:F=[]}=O||{},U=[{title:"Stop Name",dataIndex:"stop_name",onCell:N=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:N=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:N=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:pi}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:U,rowKey:N=>b(N)+"cell01",dataSource:F,pagination:!1})})})},b=O=>{const F=["id","index"];for(let U=0;U<F.length;U++)if(O[F[U]])return O[F[U]]},P=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(O,F,U)=>e.jsx(e.Fragment,{children:(Array.isArray(F.children)?F.children:[]).map((N,Y,z)=>e.jsx("span",{children:`${N.stop_name} ${Y+1===z.length?"":","}`},`${Y}vehicle001`))})},{title:"Action",render:(O,F,U)=>e.jsx(e.Fragment,{children:e.jsx(mt,{id:F?.route_id,funcName:L})})}];return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(v,{pt:5,pb:1,children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(v,{px:3,pb:2,children:e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Q,{options:j,value:j.find(O=>String(O.value)===String(i))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:O=>{o(O?.value??null),s([]),d([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:i&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:g,children:e.jsx(te.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(ne,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),s([]),d([])},style:Qp,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:a.length>0&&a.map((O,F)=>{const U=O.pickup_time?ae(O.pickup_time,"h:mm a"):null,N=O.drop_time?ae(O.drop_time,"h:mm a"):null;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx(V,{value:O.stop_name??"",type:"text",name:`stoppage[${F}][name]`,label:"Place Name*",required:"required",onChange:Y=>{const z=Y?.target?.value??"";s(E=>{const M=[...E];return M[F]={...M[F]??{},stop_name:z},M})}}),O?.id!=null&&String(O.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${F}][id]`,value:String(O.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ci,children:"Pick Time"}),e.jsx(n.TimePicker,{value:U,use12Hours:!0,format:"h:mm a",name:`stoppage[${F}][pickTime]`,allowClear:!1,style:ui,onChange:Y=>{const z=Y?Y.format("h:mm a"):"";s(E=>{const M=[...E];return M[F]={...M[F]??{},pickup_time:z},M})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ci,children:"Drop Time"}),e.jsx(n.TimePicker,{value:N,use12Hours:!0,format:"h:mm a",name:`stoppage[${F}][drop_time]`,allowClear:!1,style:ui,onChange:Y=>{const z=Y?Y.format("h:mm a"):"";s(E=>{const M=[...E];return M[F]={...M[F]??{},drop_time:z},M})}})]}),e.jsx("div",{style:{marginBottom:8},children:a.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>D(F),children:e.jsx(te.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},O.idKey?O.idKey+"exp":O.id+"exp")})})]})}),e.jsx(v,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(v,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:pi}},columns:P,bordered:!0,size:"small",rowKey:O=>b(O),dataSource:x,loading:h,expandable:{expandedRowRender:B,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:S,showSizeChanger:!0,onChange:k,onShowSizeChange:(O,F)=>{y(U=>({...U,pagination:{current:1,pageSize:F}}))},showTotal:(O,F)=>`${F[0]}-${F[1]} of ${O} items`}})})]})]})}const{Step:xn}=n.Steps;function Zp({token:t}){const[a,s]=r.useState(0),[i,o]=r.useState(void 0),[l,d]=r.useState(void 0),[c,y]=r.useState(!1),[h,u]=r.useState(null),[p,C]=r.useState(!1),[S,x]=r.useState(!1),[m,j]=r.useState(!1),[T,R]=r.useState([]),[I,_]=r.useState(null),[A,f]=r.useState(null),[g,D]=r.useState(!1),{isLoading:k,data:L}=W(t?[Xa,t]:null,([$,q])=>K($,q)),{isLoading:B,data:b}=W(g?[g,t]:null,([$,q])=>K($,q)),{data:P}=W(c?[c,t]:null,([$,q])=>K($,q)),O=r.useMemo(()=>[{title:"Excel Row",dataIndex:"row",width:90,render:$=>$??"-"},{title:"Student Name",dataIndex:"student_name_system",render:$=>$?e.jsx("span",{style:{color:"#d97706"},children:$}):"-"},{title:"Route",dataIndex:"route",render:$=>$||"-"},{title:"Vehicle",dataIndex:"vehicle",render:$=>$||"-"},{title:"Stop",dataIndex:"stop",render:$=>$||"-"},{title:"Start Date",dataIndex:"start_date",render:$=>$||"-"},{title:"Transport Fee",dataIndex:"transport_fee",render:$=>$??"-"},{title:"Status",dataIndex:"status",width:110,render:$=>{const H={Valid:"success",Invalid:"error",Duplicate:"warning",Imported:"success",Skipped:"warning",Failed:"error"}[$]||"default";return e.jsx("span",{style:{color:H,fontWeight:500},children:$})}},{title:"Message",dataIndex:"message",render:$=>$?e.jsx("span",{style:{color:"#dc2626"},children:$}):"-"}],[]),F=()=>{u(null),C(!1),x(!1),j(!1),R([]),_(null),f(null),o(void 0),d(void 0),y(!1),s(0)},U=async()=>{try{const $=await ru({class_id:i?.value,section_id:l?.value},t),q=window.URL.createObjectURL($),H=document.createElement("a");H.href=q,H.download="transport-bulk-template.xlsx",document.body.appendChild(H),H.click(),document.body.removeChild(H),window.URL.revokeObjectURL(q),w.success("Template downloaded.",{duration:1e3})}catch($){w.error($?.message||"Failed to download template.",{duration:1e3})}},N=async()=>{if(!h){w.error("Please select an Excel file to upload.",{duration:1e3});return}x(!0),R([]),_(null),f(null);try{const $=await iu(h,t);if($.Status!=="Success"){w.error($.msg||"Validation failed.",{duration:1e3}),x(!1);return}_($.data?.summary||null),R($.data?.rows||[]),s(2),w.success($.msg||"Validation complete.",{duration:1e3})}catch($){w.error($?.message||"Validation failed.",{duration:1e3})}finally{x(!1)}},Y=async()=>{if(!T.length){w.error("No rows provided to import.",{duration:1e3});return}j(!0),f(null);try{const $=await ou(T,t,"skip");if($.Status!=="Success"){w.error($.msg||"Import failed.",{duration:1e3}),j(!1);return}f($.data||null),s(3),w.success($.msg||"Import completed.",{duration:1e3})}catch($){w.error($?.message||"Import failed.",{duration:1e3})}finally{j(!1)}},z=async $=>{if(!$||!$.length){w.error("No rows provided.",{duration:1e3});return}try{const q=await lu($,t),H=window.URL.createObjectURL(q),re=document.createElement("a");re.href=H,re.download="transport-bulk-error-report.xlsx",document.body.appendChild(re),re.click(),document.body.removeChild(re),window.URL.revokeObjectURL(H),w.success("Error report downloaded.",{duration:1e3})}catch(q){w.error(q?.message||"Failed to download error report.",{duration:1e3})}},E=r.useMemo(()=>T.length?(A?A.rows:T).filter(q=>!["Valid","Imported"].includes(q.status)):[],[T,A]),M={background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"};return e.jsx(v,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:M,children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Transport / Bulk Upload"})}),e.jsxs(v,{p:3,children:[e.jsxs(n.Steps,{current:a,style:{marginBottom:16},children:[e.jsx(xn,{title:"Download Template"}),e.jsx(xn,{title:"Upload & Validate"}),e.jsx(xn,{title:"Review"}),e.jsx(xn,{title:"Import Result"})]}),a===0&&e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:4,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:Array.isArray(L)?L:[],value:i,onChange:$=>{o($),$?y(`${Za}?class_id=${$.value}`):(d(void 0),y(!1))},showSearch:!0,allowClear:!0})})}),e.jsx(n.Col,{xs:24,md:4,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:Array.isArray(P)?P:[],value:l,onChange:d,showSearch:!0,allowClear:!0})})}),e.jsx(n.Col,{xs:24,md:4,style:{marginTop:20},children:e.jsx(v,{children:e.jsx(n.Button,{type:"primary",onClick:U,block:!0,children:"Download Excel Template"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{mt:1,children:e.jsx(n.Button,{type:"primary",onClick:()=>s(1),children:"Next: Upload Excel"})})})]}),a===1&&e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsxs(v,{children:[e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:$=>(u($),!1),children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),block:!0,disabled:p||S,children:h?h.name:"Choose Excel File (.xlsx)"})}),h&&e.jsxs(v,{mt:.5,display:"flex",alignItems:"center",gap:1,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:[(h.size/1024).toFixed(1)," KB"]}),e.jsx(n.Button,{size:"small",danger:!0,onClick:()=>u(null),children:"Remove"})]})]})}),e.jsx(n.Col,{xs:24,md:3,children:e.jsx(v,{children:e.jsx(ne,{type:"button",value:S?"Validating...":"Validate & Preview",color:"primary",onClick:N,disabled:S||!h})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Button,{type:"text",size:"small",onClick:()=>{F(),s(0)},children:"Back"})})]}),a===2&&e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsx(ge,{level:6,color:"textSecondary",children:"Total"}),e.jsx(ge,{level:4,children:I?.total??T.length})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsx(ge,{level:6,color:"textSecondary",children:"Valid"}),e.jsx(ge,{level:4,style:{color:"#52c41a"},children:I?.valid??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsx(ge,{level:6,color:"textSecondary",children:"Invalid"}),e.jsx(ge,{level:4,style:{color:"#ff4d4f"},children:I?.invalid??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsx(ge,{level:6,color:"textSecondary",children:"Duplicate"}),e.jsx(ge,{level:4,style:{color:"#faad14"},children:I?.duplicate??0})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(n.Table,{dataSource:T.map(($,q)=>({...$,key:`${$.row}-${q}`})),columns:O,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:($,q)=>`${q[0]}-${q[1]} of ${$} items`}})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[8,8],align:"middle",children:[e.jsx(n.Col,{children:e.jsx(ne,{type:"button",value:m?"Importing...":"Import Valid Rows",color:"primary",onClick:Y,disabled:m})}),e.jsx(n.Col,{children:e.jsx(n.Button,{size:"small",onClick:()=>z(E),disabled:!E.length,children:"Download Error Report"})}),e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",size:"small",onClick:()=>{F(),s(1)},children:"Upload Another File"})})]})})]}),a===3&&e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:["Total "," "]}),e.jsx(ge,{level:4,children:A?.total??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:["Imported "," "]}),e.jsx(ge,{level:4,style:{color:"#52c41a"},children:A?.imported??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:["Skipped "," "]}),e.jsx(ge,{level:4,style:{color:"#faad14"},children:A?.skipped??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:["Failed "," "]}),e.jsx(ge,{level:4,style:{color:"#ff4d4f"},children:A?.failed??0})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(n.Table,{dataSource:(A?.rows||[]).map(($,q)=>({...$,key:`${$.row}-${q}`})),columns:O,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:($,q)=>`${q[0]}-${q[1]} of ${$} items`}})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[8,8],align:"middle",children:[e.jsx(n.Col,{children:e.jsx(n.Button,{size:"small",onClick:()=>z(E),disabled:!E.length,children:"Download Error Report"})}),e.jsx(n.Col,{children:e.jsx(n.Button,{type:"primary",size:"small",onClick:F,children:"Upload Another File"})})]})})]})]})]})})})})}const hi={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ia=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function em({token:t}){const[a,s]=r.useState("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),[i,o]=r.useState({page:1,rowsPerPage:10}),[l,d]=r.useState(null),[c,y]=r.useState(null),[h,u]=r.useState(null),[p,C]=r.useState(null),[S,x]=r.useState(!1),[m,j]=r.useState(null),[T,R]=r.useState(null),[I,_]=r.useState(null),[A,f]=r.useState(null),[g,D]=r.useState(null),[k,L]=r.useState(null),[B,b]=r.useState(!1),[P,O]=r.useState(""),[F,U]=r.useState(""),[N,Y]=r.useState(""),z=(oe,ye)=>{const Ye=oe?.value??null;switch(ye){case"class_id":d(Ye),y(null),u(null);break;case"section_id":y(Ye);break;case"subject_id":u(Ye);break}},{data:E}=W(t?["api/branchapi/academy/classdropdownlist",t]:null,([oe,ye])=>K(oe,ye)),{data:M}=W(t&&g?[g,t]:null,([oe,ye])=>K(oe,ye)),{data:$}=W(t&&k?[k,t]:null,([oe,ye])=>K(oe,ye)),q=l?`api/branchapi/academy/sectionoftheClass?class_id=${l}`:null,{data:H}=W(t&&q?[q,t]:null,([oe,ye])=>K(oe,ye)),re=l?`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${l}`:null,{data:ee}=W(t&&re?[re,t]:null,([oe,ye])=>K(oe,ye)),G=r.useMemo(()=>Ia(E),[E]),J=r.useMemo(()=>Ia(M),[M]),ie=r.useMemo(()=>Ia($),[$]),pe=r.useMemo(()=>Ia(H),[H]),_e=r.useMemo(()=>Ia(ee),[ee]),le=t&&a?`${a}class_id=${l||""}&subject_id=${h||""}&section_id=${c||""}&date=${p?.format("YYYY-MM-DD")||""}&page=${i.page}&per_page=${i.rowsPerPage}`:null,{isLoading:de,error:X,data:ce,mutate:Re}=W(le?[le,t]:null,([oe,ye])=>K(oe,ye)),Ue=async(oe,ye)=>{try{await Re(Ee(oe,ye,t),ze(ye)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),Fe()}catch(Ye){console.error(Ye),w.error("Failed to add the new item.",{duration:1e3})}},ke=async oe=>{try{await Re(qe("api/student/Homework/deleteHomework",oe,t),Ne(oe)),w.success("Success! Deleted item.",{duration:1e3})}catch(ye){console.error(ye),w.error("Failed to delete the item.",{duration:1e3})}},Ve=async oe=>{try{const ye=await Be("api/student/Homework/updateHomework",oe,t);Re(ye),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),Fe()}catch(ye){console.error(ye),w.error("Failed to update the item.",{duration:1e3})}},Le=oe=>{oe.preventDefault();const ye=new FormData(oe.target),Ye=ye.get("class_id")||l,vt=ye.get("section_id")||c,Dt=ye.get("subject_id")||h,xt=p?.format("YYYY-MM-DD");s(`api/branchapi/homeworks/gethomeworklistByClassSectionBranch?class_id=${Ye||""}&subject_id=${Dt||""}&section_id=${vt||""}${xt?`&date=${xt}`:""}&`),o(Et=>({...Et,page:1}))},at=oe=>{oe.preventDefault();const ye=new FormData(oe.target);Ue("api/branchapi/homeworks/addHomework",ye),Y("")},Ge=async(oe,ye)=>{oe.preventDefault();const Ye=new FormData(oe.target);Ye.append("id",ye),await Ve(Ye)},Fe=()=>{x(!1),j(null),R(null),_(null),f(null),D(null),L(null),Y("")},Je=oe=>{j(oe);const ye=oe?.class_id??oe?.classId??null,Ye=oe?.section_id??oe?.sectionId??null,vt=oe?.subject_id??oe?.subjectId??null;R(ye),_(Ye),f(vt),ye?(D(`api/branchapi/academy/sectionoftheClass?class_id=${ye}`),L(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${ye}`)):(D(null),L(null)),Y(oe?.file||oe?.document||""),x(!0)},it=oe=>{const ye=oe?.value??null;R(ye),_(null),f(null),ye?(D(`api/branchapi/academy/sectionoftheClass?class_id=${ye}`),L(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${ye}`)):(D(null),L(null))},fe=oe=>{_(oe?.value??null)},Se=oe=>{f(oe?.value??null)},je=(oe,ye)=>{o({page:oe,rowsPerPage:parseInt(ye,10)})},se=()=>{b(!1),O(""),U("")},me=(oe,ye)=>{if(!oe){w.error("No document found.",{duration:1e3});return}O(oe),U(ye||"Document"),b(!0)},xe=[{title:"Date",dataIndex:"homework_date",key:"homework_date"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission Date",dataIndex:"submit_date",key:"submit_date"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Document",key:"document",render:(oe,ye)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>me(ye?.document_url,ye?.document),children:"View"})},{title:"Action",key:"action",render:(oe,ye)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>Je(ye),style:{padding:2}}),e.jsx(mt,{id:ye?.id,funcName:ke})]})}];return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Search Homework"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:Le,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:G,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:G.find(oe=>String(oe.value)===String(l))??null,onChange:oe=>z(oe,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:pe.find(oe=>String(oe.value)===String(c))??null,onChange:oe=>z(oe,"section_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:_e,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:_e.find(oe=>String(oe.value)===String(h))??null,onChange:oe=>z(oe,"subject_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Me,{Desplay:"Date",format:"YYYY-MM-DD",allowClear:!1,value:p,onChange:oe=>C(oe)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(v,{children:[e.jsx(ne,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{s("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),d(null),y(null),u(null),C(null)},style:hi,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Homework List"})}),e.jsx(v,{p:3,children:e.jsx(Te,{parentCallback:je,data:{newData:ce,columns:xe,columnstype:"antd",action:!1,Loading:de,error:X,deleteTodoMutation:ke,pageController:i}})})]})})]}),e.jsx(n.Drawer,{open:S,title:m?"Edit Homework":"Add Homework",placement:"right",width:600,destroyOnClose:!0,onClose:Fe,children:e.jsx("form",{onSubmit:m?oe=>Ge(oe,m.id):at,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:G,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,placeholder:"Select Class",value:G.find(oe=>String(oe.value)===String(T))??null,onChange:it})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:J,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,placeholder:T?"Select Section":"Select Class First",value:J.find(oe=>String(oe.value)===String(I))??null,onChange:fe,isDisabled:!T})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:ie,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"sub_id",required:!0,allowSelectAll:!1,placeholder:T?"Select Subject":"Select Class First",value:ie.find(oe=>String(oe.value)===String(A))??null,onChange:Se,isDisabled:!T})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"From",name:"homew_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Deadline",name:"submission_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{type:"text",label:"Title",name:"title",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(st,{type:"text",label:"Description",name:"description",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:"https://npmapi.ubkerp.com//SuperAdmin/uploadFile",headers:{Authorization:t},maxCount:1,onChange:oe=>{if(oe.file.status==="removed"&&Y(""),oe.file.status==="done"){const ye=oe.file.response?.data??oe.file.response?.file??"";Y(String(ye??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:N?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:N||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(v,{children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:Fe,style:hi,children:"Cancel"})]})})})})]})})}),e.jsx(n.Modal,{open:B,onCancel:se,footer:null,width:900,closable:!0,children:e.jsxs(v,{p:3,children:[e.jsx(v,{mb:2,children:e.jsx(ge,{level:5,children:F||"View Document"})}),P?P.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:P,title:F||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:P,alt:F||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(ge,{children:"No document found"})]})}),e.jsx(v,{style:{position:"fixed",bottom:24,right:24,zIndex:1e3},children:e.jsx(n.Button,{type:"primary",size:"large",onClick:()=>{j(null),R(null),_(null),f(null),D(null),L(null),Y(""),x(!0)},style:{borderRadius:"50%",width:56,height:56,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24},children:"+"})})]})}const Cs=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function tm({token:t}){const[a,s]=r.useState(!1),[i,o]=r.useState(null),[l,d]=r.useState(null),[c,y]=r.useState({page:1,rowsPerPage:10}),[h,u]=r.useState(!1),[p,C]=r.useState(""),[S,x]=r.useState(""),[m,j]=r.useState({label:"",value:""}),[T,R]=r.useState({label:"",value:""}),[I,_]=r.useState({label:"",value:""}),[A,f]=r.useState(!1),[g,D]=r.useState(!1),{data:k}=W(t?["api/branchapi/academy/classdropdownlist",t]:null,([ee,G])=>K(ee,G)),{data:L}=W(t&&a?[a,t]:null,([ee,G])=>K(ee,G)),{data:B}=W(t&&(i||!0)?[i||"api/branchapi/academy/subjecttableList",t]:null,([ee,G])=>K(ee,G)),b=r.useMemo(()=>Cs(k),[k]),P=r.useMemo(()=>Cs(L),[L]),O=r.useMemo(()=>Cs(B),[B]),F=t&&l?`${l}page=${c.page}&per_page=${c.rowsPerPage}`:null,{isLoading:U,error:N,data:Y,mutate:z}=W(F?[F,t]:null,([ee,G])=>K(ee,G)),E=(ee,G)=>{switch(G){case"class_id":j(ee||{label:"",value:""}),R({label:"",value:""}),_({label:"",value:""}),o(`/api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${ee?.value??""}`),s(`/api/branchapi/academy/sectionoftheClass?class_id=${ee?.value??""}`),f(J=>!J),D(J=>!J);break;case"section_id":R(ee||{label:"",value:""});break;case"subject_id":_(ee||{label:"",value:""});break}},M=async ee=>{ee.preventDefault();const G="/api/branchapi/homeworks/gethomeworklistByClassSectionBranch",J=new URLSearchParams;m.value&&J.append("class_id",String(m.value)),T.value&&J.append("section_id",String(T.value)),I.value&&J.append("subject_id",String(I.value));const ie=J.toString(),pe=ie?`${G}?${ie}&`:`${G}?`;y(_e=>({..._e,page:1})),d(pe),await z()},$=(ee,G)=>{y({page:ee,rowsPerPage:parseInt(G,10)})},q=()=>{u(!1),C(""),x("")},H=(ee,G)=>{C(ee),x(G||"Document"),u(!0)},re=[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Assign By",dataIndex:"staff_name",key:"staff_name"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission",dataIndex:"total_submission",key:"total_submission"},{title:"View Document",key:"document",render:(ee,G)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>H(G.document_url,G.document),children:"View"})}];return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Submission Details"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:M,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:b.find(ee=>String(ee.value)===String(m.value))??null,onChange:ee=>E(ee,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:P.find(ee=>String(ee.value)===String(T.value))??null,onChange:ee=>R(ee||{label:"",value:""})},`sections1${A}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:O.find(ee=>String(ee.value)===String(I.value))??null,onChange:ee=>_(ee||{label:"",value:""})},`subjects1${g}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})})]})})})]})}),l&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Students List"})}),e.jsx(v,{p:3,children:e.jsx(Te,{parentCallback:$,data:{newData:Y,columns:re,columnstype:"antd",action:!1,Loading:U,error:N,pageController:c}})})]})})]}),e.jsx(n.Modal,{open:h,onClose:q,footer:null,width:900,children:e.jsxs(v,{p:3,children:[e.jsxs(v,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(ge,{level:5,children:S||"View Document"}),e.jsx(ne,{type:"button",value:"Close",color:"primary",onClick:q})]}),p?p.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:p,title:S||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:p,alt:S||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(ge,{children:"No document found"})]})})]})}const am=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),i=String(a).replace(/^\/+/,"");return`${s}/${i}`};function nm({token:t,sampleFileUrl:a}){const s=t??localStorage.getItem("authToken")??"",[i,o]=r.useState(null),[l,d]=r.useState(null),[c,y]=r.useState(null),[h,u]=r.useState(null),[p,C]=r.useState(null),[S,x]=r.useState(null),[m,j]=r.useState(null),T="api/branchapi/library/bookCategorydropdown",R="api/branchapi/academy/classdropdownlist",I="api/branchapi/Academy/getClassSubjectdropdown",_="api/branchapi/library/addBook",A="api/branchapi/library/uploadcsv",{data:f}=W(s?[T,s]:null,([F,U])=>K(F,U)),{data:g}=W(s&&R?[R,s]:null,([F,U])=>K(F,U)),{data:D}=W(s&&I?[I,s]:null,([F,U])=>K(F,U)),k=r.useMemo(()=>am(He(),A),[A]),L=async F=>{F.preventDefault();const U=new FormData(F.target);U.set("cat_id",p?.value??""),U.set("class_id",S?.value??""),U.set("subject_id",m?.value??"");try{await Ee(_,U,s),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),F.target.reset(),C(null),x(null),j(null)}catch(N){w.error(N?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},B=async F=>{if(F.preventDefault(),!i){w.error("Please select a CSV file.",{duration:1e3});return}const U=new FormData;U.append("file",i),U.append("cat_id",l?.value??""),U.append("class_id",c?.value??""),U.append("subject_id",h?.value??"");try{const N=await We.post(k,U,{headers:{Authorization:s,"Content-type":"multipart/form-data"}});N?.data?.Status==="Failed"?w.error(String(N?.data?.msg??"Upload failed."),{duration:1e3}):(w.success(String(N?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),o(null),F.target.reset(),d(null),y(null),u(null))}catch(N){w.error(N?.response?.data?.msg??"Upload failed.",{duration:1e3})}},b=()=>["title,author,publisher,quantity,price,fine,subject_id,barcode,class_id",...["Advanced Chemistry,Rahul Mondal,RM PUBLISHER,10,210,20,1,,1","Advanced Chemistry,Rahul Mondal,RM PUBLISHER,10,210,20,1,123321,1"]].join(`
60
- `),P=()=>{if(a)return a;const F=He();return F?`${F.replace(/\/+$/,"")}/books.csv`:"/books.csv"},O=()=>{const F=P();fetch(F).then(U=>{if(!U.ok)throw new Error("Sample file not found");const N=U.headers.get("content-type")||"";return!N.includes("csv")&&!N.includes("text/plain")&&!N.includes("application/octet-stream")?U.text().then(Y=>{if(Y.trim().startsWith("<")||Y.includes("<!doctype")||Y.includes("<html"))throw new Error("Sample file URL returned HTML. Host the CSV at a public URL and pass it via sampleFileUrl prop.");return new Blob([Y],{type:"text/csv"})}):U.blob()}).then(U=>{const N=window.URL.createObjectURL(U),Y=document.createElement("a");Y.href=N,Y.download="books.csv",Y.click(),window.URL.revokeObjectURL(N)}).catch(()=>{const U=b(),N=new Blob([U],{type:"text/csv"}),Y=window.URL.createObjectURL(N),z=document.createElement("a");z.href=Y,z.download="books.csv",z.click(),window.URL.revokeObjectURL(Y)})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(n.Button,{type:"link",icon:e.jsx(te.DownloadOutlined,{}),onClick:O,children:"Download Sample"}),children:[e.jsx(n.Divider,{children:"Information"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:16},children:"1. Your CSV data should be in the format below. The first line of your CSV file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("form",{onSubmit:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:l,onChange:F=>d(F??null)}),e.jsx(Q,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:c,onChange:F=>y(F??null)}),e.jsx(Q,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:h,onChange:F=>u(F??null)}),e.jsx(V,{type:"file",label:"Upload CSV/Excel",name:"csv",accept:".csv,.xlsx,.xls",onChange:F=>o(F.target.files?.[0]??null),required:!0}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(V,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(V,{type:"text",label:"Publication",name:"publisher"}),e.jsx(V,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(V,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(V,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(V,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(Q,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:p,onChange:F=>C(F??null)}),e.jsx(Q,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:S,onChange:F=>x(F??null)}),e.jsx(Q,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:m,onChange:F=>j(F??null)}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})})]})}const As={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ds=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function sm({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,i]=r.useState([]),[o,l]=r.useState([]),d=r.useRef(),c={selectedRowKeys:s,onChange:(J,ie)=>{i(J),l(ie)}},y=xa.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),h=()=>{if(!(typeof window>"u")){if(!o.length){w.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){w.error("Nothing to print.",{duration:1e3});return}y?.()}},[u,p]=r.useState(!1),[C,S]=r.useState(null),[x,m]=r.useState(null),[j,T]=r.useState(null),[R,I]=r.useState(null),[_,A]=r.useState({page:1,rowsPerPage:10}),f=(J,ie)=>{A({page:J,rowsPerPage:parseInt(ie,10)})},g="api/branchapi/library/booktable",D="api/branchapi/library/deletebooks",k="api/branchapi/library/editbook",L=`${g}?page=${_.page}&per_page=${_.rowsPerPage}`,{isLoading:B,error:b,data:P,mutate:O}=W(a?[L,a]:null,([J,ie])=>K(J,ie)),F="api/branchapi/library/bookCategorydropdown",U="api/branchapi/academy/classdropdownlist",N="api/branchapi/Academy/getClassSubjectdropdown",{data:Y}=W(a?[F,a]:null,([J,ie])=>K(J,ie)),{data:z}=W(a&&U?[U,a]:null,([J,ie])=>K(J,ie)),{data:E}=W(a&&N?[N,a]:null,([J,ie])=>K(J,ie)),M=r.useMemo(()=>Ds(Y),[Y]),$=r.useMemo(()=>Ds(z),[z]),q=r.useMemo(()=>Ds(E),[E]),H=async J=>{try{await qe(D,J,a),await O(),w.success("Success! Deleted item.",{duration:1e3})}catch(ie){w.error(ie?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},re=J=>{S(J??null);const ie=J?.cat_id??J?.fk_cat_id??J?.category_id,pe=J?.class_id??J?.fk_class_id,_e=J?.subject_id??J?.fk_subject_id;m(M.find(le=>le?.value===ie)??null),T($.find(le=>le?.value===pe)??null),I(q.find(le=>le?.value===_e)??null),p(!0)},ee=async J=>{J.preventDefault();const ie=C?.id??C?.book_id??C?._id;if(!ie)return;const pe=new FormData(J.target);pe.set("id",String(ie)),pe.set("cat_id",x?.value??""),pe.set("class_id",j?.value??""),pe.set("subject_id",R?.value??"");try{await Be(k,pe,a),await O(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),p(!1),S(null)}catch(_e){w.error(_e?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},G=r.useMemo(()=>[{title:"Name",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Publisher",dataIndex:"publish",key:"publish",width:160,responsive:["lg"]},{title:"Author",dataIndex:"author",key:"author",width:160,responsive:["lg"]},{title:"Class",dataIndex:"class_name",key:"class_name",width:140,responsive:["xl"]},{title:"Subject",dataIndex:"subject_name",key:"subject_name",width:160,responsive:["xl"]},{title:"Avl Qty",dataIndex:"available_qty",key:"available_qty",width:90},{title:"Book Price",dataIndex:"perunitcost",key:"perunitcost",width:120,responsive:["xl"]},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",width:120,responsive:["xl"]},{title:"Category",dataIndex:"cat_name",key:"cat_name",width:160,responsive:["xl"]},{title:"Action",key:"action",width:140,fixed:"right",render:(J,ie)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>re(ie),style:{padding:2}}),e.jsx(n.Button,{type:"text",size:"small",danger:!0,onClick:()=>H(ie?.id??ie?.book_id??ie?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[M,$,H,q]);return e.jsxs("div",{style:{},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:u,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{p(!1),S(null)},children:e.jsx("form",{onSubmit:ee,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(V,{label:"Book Name",name:"title",defaultValue:C?.book_title??"",required:!0}),e.jsx(V,{label:"Author",name:"author",defaultValue:C?.author??"",required:!0}),e.jsx(V,{label:"Publication",name:"publish",defaultValue:C?.publish??""}),e.jsx(V,{label:"Qty",name:"quantity",type:"number",defaultValue:C?.quantity??""}),e.jsx(V,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:C?.perunitcost??""}),e.jsx(V,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:C?.fine_amount??""}),e.jsx(V,{label:"Barcode",name:"barcode",defaultValue:C?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:As,children:"Category"}),e.jsx(Q,{options:M,value:x,onChange:J=>m(J??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:As,children:"Class"}),e.jsx(Q,{options:$,value:j,onChange:J=>T(J??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:As,children:"Subject"}),e.jsx(Q,{options:q,value:R,onChange:J=>I(J??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{p(!1),S(null)},children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(n.Button,{type:"primary",onClick:h,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Te,{parentCallback:f,data:{newData:P,columns:G,columnstype:"antd",action:!1,Loading:B,error:b,rowSelection:c}})}),e.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:e.jsx("div",{ref:d,style:{padding:"20px"},children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:o.map((J,ie)=>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:J.book_title}),e.jsx(fo,{value:J.barcode?String(J.barcode):String(J.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},ie))})})})]})}const rm=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),i=String(a).replace(/^\/+/,"");return`${s}/${i}`},Ft=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},bn=t=>ae(t).add(1,"month").format("YYYY-MM-DD"),im=r.forwardRef(({token:t,onReturn:a},s)=>{const i=t??localStorage.getItem("authToken")??"",[o,l]=r.useState("issue"),d=o==="return",[c,y]=r.useState(!1),[h,u]=r.useState(!1),[p,C]=r.useState(null),[S,x]=r.useState([]),[m,j]=r.useState([]),[T,R]=r.useState([]),[I,_]=r.useState(0),[A,f]=r.useState(!1),[g,D]=r.useState(null),[k,L]=r.useState(null),[B,b]=r.useState(null),[P,O]=r.useState(!1),[F,U]=r.useState("Cash"),[N,Y]=r.useState(""),[z,E]=r.useState(""),[M,$]=r.useState(0),[q,H]=r.useState("NO_FINE"),re=r.useRef(null),[ee]=n.Form.useForm(),[G]=n.Form.useForm(),J="api/branchapi/library/bookCategorydropdown",ie="api/branchapi/academy/classdropdownlist",pe="api/branchapi/Academy/getClassSubjectdropdown",{data:_e}=W(i?[J,i]:null,([ue,we])=>K(ue,we)),{data:le}=W(i&&ie?[ie,i]:null,([ue,we])=>K(ue,we)),{data:de}=W(i&&pe?[pe,i]:null,([ue,we])=>K(ue,we)),X=r.useMemo(()=>Ft(_e),[_e]),ce=r.useMemo(()=>Ft(le),[le]),Re=r.useMemo(()=>Ft(de),[de]),Ue="api/branchapi/library/studentsearchByNameID",ke="api/branchapi/library/booksearchBybookname",Ve="api/branchapi/library/issuedBookList",Le="api/branchapi/library/issueLibrarybook",at="api/branchapi/library/returnedLibrarybook",{trigger:Ge,data:Fe}=tt(Ue,(ue,we)=>Gt(ue,we,i)),{trigger:Je,data:it}=tt(ke,(ue,we)=>Gt(ue,we,i)),{trigger:fe,data:Se}=tt(Ve,(ue,we)=>Gt(ue,we,i)),{trigger:je}=tt(d?at:Le,(ue,we)=>ts(ue,we,i)),se=r.useMemo(()=>Ft(Fe),[Fe]),me=r.useMemo(()=>Ft(it),[it]),xe=r.useMemo(()=>Ft(Se),[Se]),oe=ue=>{const we=bn(ae());x($e=>$e.some(Qe=>String(Qe?.id)===String(ue?.id))?$e:[...$e,{...ue,return_date:ue?.return_date?ue.return_date:we}])},ye=async()=>{console.log("Reloading IssueReturn..."),w.success("Success",{duration:1e3}),j([]),R([]),_(0),H("FINE_PAY_LATER"),await fe({id:p?.student_id})};r.useImperativeHandle(s,()=>({reloadPayLater:ye}));const Ye=ue=>{x(we=>we.filter($e=>String($e?.id)!==String(ue)))},vt=async ue=>{if(i){if(!ue){C(null);return}c||await Ge({id:ue})}},Dt=async({search:ue})=>{if(!i||!c)return;const we=await Ge({id:ue}),$e=Ft(we);$e.length===1&&(C($e[0]),await fe({id:$e[0]?.student_id}),ee.resetFields())},xt=async(ue,we)=>{C(we??null),x([]),j([]),R([]),_(0),H("NO_FINE"),$(0),we?.student_id&&await fe({id:we.student_id}),ee.resetFields()},Et=async ue=>{i&&ue&&(h||await Je({book:ue}))},Zt=async({search_book:ue})=>{if(!i||!h)return;const we=await Je({book:ue,catID:g?.value??"",sID:B?.value??"",cID:k?.value??""}),$e=Ft(we);$e.length&&(oe($e[0]),G.resetFields())},he=(ue,we)=>{oe(we),G.resetFields()},ve=async()=>{if(!p?.member_id){w.error("Select a student first.",{duration:1e3});return}if(!S.length){w.error("Select at least one book.",{duration:1e3});return}const ue=await je({member_id:p.member_id,fine:!1,books:S});ue?.Status==="Success"&&(w.success(String(ue?.msg??"Success"),{duration:1e3}),x([]),C(null),j([]),R([]),_(0))},lt=async()=>{if(!p?.member_id){w.error("Select a student first.",{duration:1e3});return}if(!T.length){w.error("Select at least one book to return.",{duration:1e3});return}if(Number(I)>0){H("FINE_PAID"),O(!0);return}const ue=await je({member_id:p.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(T)});ue?.Status==="Success"?(w.success(String(ue?.msg??"Success"),{duration:1e3}),j([]),R([]),_(0),await fe({id:p?.student_id})):w.error(String(ue?.msg??"Failed"),{duration:1e3})},bt=async()=>{if(!p?.member_id)return;const ue=Math.max(0,Number(I)-Number(M||0)),we={member_id:p.member_id,collection_type:q,amount:q==="FINE_PAID"?ue:0,payment_type:F,notes:N,attchement:z,discount:M||0,books:JSON.stringify(T)},$e=await je(we);O(!1),$e?.Status==="Success"?(w.success(String($e?.msg??"Success"),{duration:1e3}),j([]),R([]),_(0),$(0),Y(""),E(""),H("NO_FINE"),await fe({id:p?.student_id})):w.error(String($e?.msg??"Failed"),{duration:1e3})},on=async()=>{if(!p?.member_id){w.error("Select a student first.",{duration:1e3});return}if(!T.length){w.error("Select at least one book to return.",{duration:1e3});return}const ue={member_id:p.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(T)};a(ue)},ln=r.useMemo(()=>rm(He(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),dn=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Author",dataIndex:"author",key:"author",width:180,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ue,we)=>e.jsx(Me,{defaultValue:ae(we?.return_date||ae().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:($e,Qe)=>{x(ot=>ot.map(ht=>String(ht?.id)===String(we?.id)?{...ht,return_date:Qe}:ht))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(ue,we)=>e.jsx(n.Button,{type:"text",danger:!0,onClick:()=>Ye(we?.id),children:"Remove"})}],cn={selectedRowKeys:m,onChange:(ue,we)=>{j(ue),R(we);const $e=(we??[]).reduce((Qe,ot)=>Qe+Number(ot?.totalfine??0),0);_($e)},onSelect:(ue,we,$e)=>{if(we){const Qe=$e.map(ot=>({...ot,return_date:ot?.return_date?ot.return_date:bn(ot?.issue_date||ae())}));R(Qe)}},onSelectAll:(ue,we)=>{if(ue){const $e=we.map(Qe=>({...Qe,return_date:Qe?.return_date?Qe.return_date:bn(Qe?.issue_date||ae())}));R($e)}}},un=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ue,we)=>{const Qe=T.find(ht=>String(ht?.id)===String(we?.id))?.return_date||we?.return_date,ot=bn(we?.issue_date||ae());return e.jsx(Me,{defaultValue:ae(Qe||ot),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(ht,ds)=>{R(cs=>cs.map(va=>String(va?.id)===String(we?.id)?{...va,return_date:ds}:va))}})}},{title:"Days",key:"days",width:100,render:(ue,we)=>{const Qe=T.find(ht=>String(ht?.id)===String(we?.id))?.return_date||we?.return_date,ot=we?.issue_date;if(ot&&Qe){const ht=ae(Qe).diff(ae(ot),"day");return ht>=0?ht:0}return"-"}},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:ue=>e.jsxs("span",{children:["₹ ",ue]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:P,onCancel:()=>O(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(n.Radio.Group,{value:F,onChange:ue=>U(ue.target.value),options:[{label:"Cash",value:"Cash"},{label:"UPI",value:"UPI"},{label:"DD",value:"DD"},{label:"Bank",value:"Bank"},{label:"Internet Banking",value:"Internet Banking"},{label:"Cheque",value:"Cheque"}]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Note"}),e.jsx(n.Input.TextArea,{rows:3,value:N,onChange:ue=>Y(ue.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(n.Upload,{action:ln,headers:{Authorization:i},maxCount:1,onChange:ue=>{if(ue.file.status==="done"){const we=ue.file.response?.data??ue.file.response?.file??"";E(String(we??""))}},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(n.Input,{type:"number",value:M,onChange:ue=>$(ue.target.value),placeholder:"0"})]}),e.jsxs(n.Button,{type:"primary",onClick:bt,children:["Collect ₹",Math.max(0,Number(I)-Number(M||0))]}),e.jsx(n.Button,{onClick:()=>O(!1),children:"Cancel"})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:10,children:e.jsx(n.Radio.Group,{value:o,onChange:ue=>{const we=ue.target.value;l(we),x([]),j([]),R([]),_(0),H("NO_FINE"),$(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(n.Col,{xs:24,md:14,children:e.jsx(n.Form,{form:ee,onFinish:Dt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search",label:"Search Student",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:c?e.jsx(n.Input,{autoFocus:!0,addonBefore:e.jsxs(n.Space,{children:[e.jsx(te.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ue=>y(ue.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{options:se,onSelect:xt,onSearch:vt,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(te.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ue=>y(ue.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),p?e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{}),e.jsxs(n.Row,{gutter:[12,12],children:[e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Name:"})," ",p?.value??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Card No:"})," ",p?.library_card_no??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Member ID:"})," ",p?.member_id??""]})]})]}):null,e.jsx(n.Divider,{}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(n.Table,{dataSource:xe,columns:un,rowSelection:cn,pagination:!1,rowKey:ue=>ue?.id??ue?.issue_id??ue?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(n.Typography.Text,{strong:!0,children:["Total Fine: ₹",I]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(n.Button,{type:"primary",onClick:lt,disabled:!T.length,children:I>0?`Pay Now ₹ ${Math.max(0,Number(I)-Number(M||0))}`:"Return Selected"}),I>0?e.jsx(n.Button,{onClick:on,disabled:!T.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:18,children:e.jsx(n.Form,{form:G,onFinish:Zt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:h?e.jsx(n.Input,{autoFocus:!0,disabled:!p,addonBefore:e.jsxs(n.Space,{children:[e.jsx(te.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:h,onChange:ue=>u(ue.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{disabled:!p,options:me,onSelect:he,onSearch:Et,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(te.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:h,onChange:ue=>u(ue.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(n.Button,{style:{width:"100%"},icon:e.jsx(te.FilterOutlined,{}),onClick:()=>f(!0),children:"Filter"})})]}),e.jsx(n.Drawer,{open:A,onClose:()=>f(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{label:"Category",options:X,value:g,onChange:ue=>D(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(Q,{label:"Class",options:ce,value:k,onChange:ue=>L(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(Q,{label:"Subjects",options:Re,value:B,onChange:ue=>b(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(n.Button,{type:"primary",onClick:()=>f(!1),children:"Apply"})]})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(n.Table,{dataSource:S,columns:dn,pagination:!1,rowKey:ue=>ue?.id??ue?.book_id??ue?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Issue",onClick:ve})})]})]}),e.jsx("div",{ref:re,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}),fi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function om({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,i]=r.useState({page:1,rowsPerPage:10}),[o,l]=r.useState(null),[d,c]=r.useState(null),[y,h]=r.useState(!1),[u,p]=r.useState(!1),[C,S]=r.useState(null),[x,m]=r.useState(!1),j="api/branchapi/academy/classdropdownlist",T="api/branchapi/academy/sectionoftheClass",R="api/branchapi/library/studenttableForLibrary",I="api/branchapi/library/addmembershipforStudent",_="api/branchapi/library/removemembershipforStudent",A=r.useMemo(()=>{if(!o?.value)return null;const E=T.includes("?")?"&":"?";return`${T}${E}class_id=${encodeURIComponent(String(o.value))}`},[T,o?.value]),f=r.useMemo(()=>{if(!o?.value||!d?.value)return null;const E=R.includes("?")?"&":"?";return`${R}${E}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${s.page}&per_page=${s.rowsPerPage}`},[s.page,s.rowsPerPage,o?.value,d?.value,R]),{data:g}=W(a&&j?[j,a]:null,([E,M])=>K(E,M)),{data:D}=W(a&&A?[A,a]:null,([E,M])=>K(E,M)),{isLoading:k,error:L,data:B,mutate:b}=W(a&&f?[f,a]:null,([E,M])=>K(E,M)),P=r.useMemo(()=>fi(g),[g]),O=r.useMemo(()=>fi(D),[D]),F=(E,M)=>{i({page:E,rowsPerPage:parseInt(M,10)})},U=E=>{const M=E?.id??E?.student_id??E?.member_id;S(M??null),p(!0),m($=>!$)},N=async E=>{if(E.preventDefault(),!C)return;const M=new FormData(E.target);M.set("id",String(C));try{await Ee(I,M,a),w.success("Success! Added member.",{duration:1e3,icon:"🎉"}),p(!1),S(null),await b()}catch($){w.error($?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},Y=async E=>{try{await qe(_,E,a),w.success("Success! Removed member.",{duration:1e3}),await b()}catch(M){w.error(M?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},z=r.useMemo(()=>[{title:"Library Card No",dataIndex:"library_card_no",key:"library_card_no",width:180,ellipsis:!0,fixed:"left"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140,responsive:["sm"]},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,responsive:["lg"]},{title:"First Name",dataIndex:"firstname",key:"firstname",width:140,responsive:["sm"]},{title:"Last Name",dataIndex:"lastname",key:"lastname",width:140,responsive:["lg"]},{title:"Class",dataIndex:"class",key:"class",width:120,responsive:["xl"]},{title:"Section",dataIndex:"section",key:"section",width:120,responsive:["xl"]},{title:"Mobile",dataIndex:"mobileno",key:"mobileno",width:140,responsive:["lg"]},{title:"Action",key:"action",width:80,fixed:"right",render:(E,M)=>(console.log("data______________",M),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:M?.library_card_no==null?e.jsx(n.Button,{type:"primary",size:"small",icon:e.jsx(te.UserAddOutlined,{}),onClick:()=>U(M)}):e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{}),onClick:()=>Y(M?.id??M?.student_id??M?.member_id)})}))}],[Y]);return e.jsxs("div",{style:{},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:u,title:"Add Member",onCancel:()=>{p(!1),S(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(V,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})]})},`add-${x}`)}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Student"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:E=>{l(E??null),c(null),h(M=>!M)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(Q,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:E=>c(E??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${y}`),e.jsx(ne,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){w.error("Select class and section.",{duration:1e3});return}i(E=>({...E,page:1}))}})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Te,{parentCallback:F,data:{newData:B,columns:z,columnstype:"antd",action:!1,Loading:k,error:L}})})]})}function lm({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,i]=r.useState({page:1,rowsPerPage:10}),[o]=n.Form.useForm(),[l]=n.Form.useForm(),[d,c]=r.useState(!1),[y,h]=r.useState(null),u="api/branchapi/library/BookCategorytable",p="api/branchapi/library/addBookCategory",C="api/branchapi/library/editBookCategory",S="api/branchapi/library/deleteBookCategory",x=r.useMemo(()=>{const L=u.includes("?")?"&":"?";return`${u}${L}page=${s.page}&per_page=${s.rowsPerPage}`},[u,s.page,s.rowsPerPage]),{isLoading:m,error:j,data:T,mutate:R}=W(a&&x?[x,a]:null,([L,B])=>K(L,B)),I=(L,B)=>{i({page:L,rowsPerPage:parseInt(B,10)})},_=async L=>{const B=new FormData;B.set("title",L?.title??"");try{await Ee(p,B,a),w.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await R()}catch(b){w.error(b?.response?.data?.msg??b?.message??"Failed to add category.",{duration:1e3})}},A=L=>{h(L??null),l.setFieldsValue({title:L?.name??""}),c(!0)},f=()=>{c(!1),h(null),l.resetFields()},g=async L=>{const B=y?.id??y?.category_id??y?.cat_id;if(!B){w.error("Missing category id.",{duration:1e3});return}const b=new FormData;b.set("id",String(B)),b.set("title",L?.title??"");try{await Be(C,b,a),w.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),f(),await R()}catch(P){w.error(P?.response?.data?.msg??P?.message??"Failed to update category.",{duration:1e3})}},D=async L=>{const B=L?.id??L?.category_id??L?.cat_id;if(!B){w.error("Missing category id.",{duration:1e3});return}try{await qe(S,B,a),w.success("Success! Deleted category.",{duration:1e3}),await R()}catch(b){w.error(b?.response?.data?.msg??b?.message??"Failed to delete category.",{duration:1e3})}},k=r.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(L,B)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>A(B)}),e.jsx(n.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>D(B),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[D]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:d,title:"Edit Category",onCancel:f,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:g,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:f,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:_,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsx(ne,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Te,{parentCallback:I,data:{newData:T,columns:k,columnstype:"antd",action:!1,Loading:m,error:j}})})})]})]})}const Ts=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function dm({token:t}){const[a,s]=r.useState([ae().format("YYYY-MM-DD"),ae().format("YYYY-MM-DD")]),[i,o]=r.useState(null),[l,d]=r.useState(null),[c,y]=r.useState(null),[h,u]=r.useState(!1),[p,C]=r.useState(!1),S="api/branchapi/academy/classdropdownlist",x="api/branchapi/academy/sectionoftheClass",m="api/branchapi/library/memberDropdown",j="api/report/libraryReport/libraryReport",T=r.useMemo(()=>{if(!i?.value)return null;const U=x.includes("?")?"&":"?";return`${x}${U}class_id=${encodeURIComponent(String(i.value))}`},[x,i?.value]),R=r.useMemo(()=>{if(!i?.value)return null;const U=m.includes("?")?"&":"?",N=`${m}${U}class=${encodeURIComponent(String(i.value))}`;return l?.value?`${N}&section=${encodeURIComponent(String(l.value))}`:N},[m,i?.value,l?.value]),{isLoading:I,error:_,data:A,mutate:f}=W(t&&S?[S,t]:null,([U,N])=>K(U,N)),{data:g}=W(t&&T?[T,t]:null,([U,N])=>K(U,N)),{data:D}=W(t&&R?[R,t]:null,([U,N])=>K(U,N)),k=r.useMemo(()=>Ts(A),[A]),L=r.useMemo(()=>Ts(g),[g]),B=r.useMemo(()=>Ts(D),[D]),{trigger:b,data:P}=tt(j,(U,N)=>ar(U,N,t));r.useEffect(()=>{(async()=>{C(!0);try{await b({duration:a})}finally{C(!1)}})()},[]);const O=async()=>{C(!0);try{await b({duration:a,class:i?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{C(!1)}},F=[{title:"Name",dataIndex:"full_name",render:(U,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(U,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(U,N)=>e.jsxs(n.Typography.Text,{style:{fontSize:12},children:[N?.class??"","(",N?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(U,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.book_title??""})},{title:"Issue Date",key:"date",render:(U,N,Y)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.issue_date??""})},{title:"Due Return Date",key:"date",render:(U,N,Y)=>e.jsx(n.Tag,{color:"orange",children:N?.return_date??""})},{title:"Return Date",key:"date",render:(U,N,Y)=>N?.retured_by_user?e.jsx(n.Tag,{color:"green",children:N?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(U,N,Y)=>String(N?.is_returned??"")==="1"?e.jsx(n.Tag,{color:"green",children:"Return"}):e.jsx(n.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(U,N,Y)=>{const z=N?.late_fine?Number(N.late_fine):0;return z?e.jsx(n.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:z}):null}}];return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{style:{width:"100%"},value:[ae(a[0],"YYYY-MM-DD"),ae(a[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(U,N)=>{Array.isArray(N)&&N.length===2&&s([N[0],N[1]])}})]})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Q,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:i,onChange:U=>{o(U??null),d(null),y(null),u(N=>!N)},allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:U=>{d(U??null),y(null)},allowSelectAll:!1},`section1${h}`)}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:U=>y(U??null),allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:1,children:e.jsx(n.Button,{type:"primary",icon:e.jsx(te.SearchOutlined,{}),onClick:O,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(n.Table,{columns:F,pagination:!1,dataSource:Array.isArray(P?.data)?P.data:[],size:"small",rowKey:(U,N)=>U?.id??U?.issue_id??U?.fees_receipt_id??N,loading:p,scroll:{x:"max-content"},summary:U=>{const N=U.reduce((z,E)=>z+Number(E?.late_fine??0),0),Y=U.reduce((z,E)=>z+Number(E?.is_returned??0),0);return e.jsxs(n.Table.Summary.Row,{children:[e.jsx(n.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",U.length]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(U.length-Y)]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",Y]})}),e.jsx(n.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",N.toLocaleString("en-IN")]})})]})}})})]})]})}const yi=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],gi=[{key:"renewalHistory",label:"Renewal History"},{key:"renewalFineReport",label:"Renewal + Fine"},{key:"currentlyRenewedBooks",label:"Currently Renewed"},{key:"upcomingRenewalDue",label:"Upcoming Due"},{key:"overdueRenewalReport",label:"Overdue"},{key:"renewalLimitReport",label:"Renewal Limit"},{key:"renewalStatusReport",label:"Renewal Status"},{key:"studentWiseReport",label:"Student-wise"},{key:"bookWiseReport",label:"Book-wise"},{key:"classWiseReport",label:"Class-wise"},{key:"staffWiseReport",label:"Staff-wise"},{key:"renewalStatisticsByDate",label:"Statistics by Date"}];function cm({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,i]=r.useState("renewalHistory"),[o,l]=r.useState("This Month"),[d,c]=r.useState(""),[y,h]=r.useState(""),[u,p]=r.useState(7),[C,S]=r.useState(1),[x,m]=r.useState(20),[j,T]=r.useState(""),[R,I]=r.useState("DESC"),_=r.useRef(null),A=N=>{const Y=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s)&&(Y.set("date_range",o),o==="Custom"&&d&&y&&(Y.set("from_date",d),Y.set("to_date",y))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(s)&&(Y.set("page",String(C)),Y.set("per_page",String(x))),s==="upcomingRenewalDue"&&Y.set("days_ahead",String(u)),j&&Y.set("sort_by",j),R&&Y.set("sort_dir",R),`${N}?${Y.toString()}`},f=r.useMemo(()=>{switch(s){case"renewalHistory":return A(pc);case"renewalFineReport":return A(mc);case"currentlyRenewedBooks":return A(hc);case"upcomingRenewalDue":return A(fc);case"overdueRenewalReport":return A(yc);case"renewalLimitReport":return A(gc);case"renewalStatusReport":return A(xc);case"studentWiseReport":return A(bc);case"bookWiseReport":return A(jc);case"classWiseReport":return A(Sc);case"staffWiseReport":return A(wc);case"renewalStatisticsByDate":return A(vc);default:return null}},[s,o,d,y,u,C,x]),{data:g,isLoading:D}=W(a?[f,a]:null,([N,Y])=>K(N,Y)),k=g?.data||{},L=k?.rows||[],B=k?.pagination||{},b=N=>{i(N),S(1),m(20)},P=()=>{S(1)},O=()=>{switch(s){case"renewalHistory":case"renewalFineReport":return[{title:"Renewal ID",dataIndex:"renewal_id",key:"renewal_id"},{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Renewal No",dataIndex:"renewal_no",key:"renewal_no"},{title:"Old Due Date",dataIndex:"old_due_date",key:"old_due_date"},{title:"New Due Date",dataIndex:"new_due_date",key:"new_due_date"},{title:"Renewal Date",dataIndex:"renewal_date",key:"renewal_date"},{title:"Status",dataIndex:"status",key:"status",render:N=>e.jsx(n.Tag,{color:N==="renewed"?"green":"red",children:N})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:N=>N??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:N=>N?e.jsx(n.Tag,{color:N==="paid"?"green":N==="partial"?"orange":"red",children:N}):"-"}];case"currentlyRenewedBooks":case"upcomingRenewalDue":case"overdueRenewalReport":case"renewalLimitReport":case"renewalStatusReport":return[{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Due Date",dataIndex:"return_date",key:"return_date"},{title:"Renewal Count",dataIndex:"renewal_count",key:"renewal_count"},{title:"Max Renewal",dataIndex:"maximum_renewal",key:"maximum_renewal"},{title:"Days Remaining",dataIndex:"days_remaining",key:"days_remaining",render:N=>N??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:N=>N??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:N=>e.jsx(n.Tag,{color:N?"green":"red",children:N?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:N=>Array.isArray(N)?N.join("; "):"-"}];case"studentWiseReport":return[{title:"Student ID",dataIndex:"student_id",key:"student_id"},{title:"Student Name",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Books",dataIndex:"unique_books_renewed",key:"unique_books_renewed"},{title:"First Renewal",dataIndex:"first_renewal_date",key:"first_renewal_date"},{title:"Last Renewal",dataIndex:"last_renewal_date",key:"last_renewal_date"}];case"bookWiseReport":return[{title:"Book ID",dataIndex:"book_id",key:"book_id"},{title:"Title",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Category",dataIndex:"category",key:"category"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"classWiseReport":return[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"staffWiseReport":return[{title:"Staff",dataIndex:"renewed_by",key:"renewed_by"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];case"renewalStatisticsByDate":return[{title:"Period",dataIndex:"period",key:"period"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];default:return[]}},F=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s),U=r.useMemo(()=>O(),[s]);return e.jsx(v,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,padding:"4px 8px",color:"#fff",display:"inline-block"}}),e.jsxs(v,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[F&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Q,{options:yi,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:yi.find(N=>N.value===o)||null,onChange:N=>l(N?.value||"This Month")})}),o==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:N=>c(N?N.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:N=>h(N?N.format("YYYY-MM-DD"):"")})})]})]}),s==="upcomingRenewalDue"&&e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Q,{options:[{label:"7 Days",value:7},{label:"14 Days",value:14},{label:"30 Days",value:30}],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Days Ahead",allowSelectAll:!1,value:{label:u+" Days",value:u},onChange:N=>p(N?.value||7)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:P})})})]}),e.jsx(n.Tabs,{activeKey:s,onChange:b,items:gi})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:gi.find(N=>N.key===s)?.label||"Report"})}),e.jsxs(v,{p:3,children:[e.jsx(wt,{data:{tableRef:_}}),D?e.jsx(v,{py:8,textAlign:"center",children:e.jsx(n.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(n.Table,{size:"small",dataSource:L,columns:U,loading:D,pagination:!1,bordered:!0,rowKey:N=>N.renewal_id||N.id||JSON.stringify(N),ref:_}),L.length>0&&e.jsx(n.Pagination,{current:C,pageSize:x,total:B.total_rows||L.length,onChange:(N,Y)=>{S(N),m(Y)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const as=t=>t??localStorage.getItem("authToken")??"",um=(t,a)=>{const s=String(t??""),i=String(a);return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i},Ke={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",academy:{classes:"api/branchapi/academy/classdropdownlist",sections:"api/branchapi/academy/sectionoftheClass"},student:{dropdown:"api/branchapi/student/studentDropdown"},vendor:{list:"api/accounts/vendor/vendorTable",add:"api/accounts/vendor/addvendor",edit:"api/accounts/vendor/editVendor",remove:"api/accounts/vendor/removecategory",dropdown:"api/accounts/vendor/vendorlist"},category:{list:"api/accounts/category/fetchcategorytable",add:"api/accounts/category/addcategory",edit:"api/accounts/category/editcategory",remove:"api/accounts/category/removecategory",dropdown:"api/accounts/category/categoryDropdown"},subCategory:{list:"api/accounts/category/fetchsubcategorytable",add:"api/accounts/category/addsubcategory",edit:"api/accounts/category/editsubcategory",remove:"api/accounts/category/removesubcategory",dropdown:"api/accounts/category/subcategoryDropdown"},unit:{list:"api/accounts/category/fetchunit",add:"api/accounts/category/addunit",edit:"api/accounts/category/editunit",remove:"api/accounts/category/removeunit",dropdown:"api/accounts/category/unitDropdown"},product:{list:"api/accounts/product/fetchproducttable",add:"api/accounts/product/addproduct",edit:"api/accounts/product/editproduct",remove:"api/accounts/product/removeproduct",dropdown:"api/accounts/product/productdropdown",search:"api/accounts/product/searchproductbyNameandBarcode",addStock:"api/accounts/product/addStock",sellProduct:"api/accounts/product/sellproduct",sellReports:"api/accounts/product/getstoreSellReports"},report:{stock:"api/report/StoreReport/stock_report"}},pm=()=>um(He(),Ke.upload),mm=async({baseUrl:t,page:a=1,perPage:s=10},i)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(l,as(i))},en=async(t,a,s)=>Ee(t,a,as(s)),Sa=async(t,a,s)=>Be(t,a,as(s)),tn=async(t,a,s)=>qe(t,a,as(s)),hm=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ya=({token:t,value:a,onChange:s})=>{const i=r.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:pm(),headers:i,onChange:o=>{if(o?.file?.status==="done"){const l=hm(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},Mn=Ke.vendor,an=({baseUrl:t,page:a=1,perPage:s=10,token:i})=>W(i&&t?[t,a,s,i]:null,([l,d,c,y])=>mm({baseUrl:l,page:d,perPage:c},y)),fm=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:Mn.list,page:a,perPage:s,token:t}),ym={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},xi=[{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 gm({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,y]=r.useState(""),{isLoading:h,error:u,data:p,mutate:C}=fm({token:t,page:a.page,perPage:a.rowsPerPage}),S=async _=>{try{await C(en(Mn.add,_,t),ze(_)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(A){w.error(A?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},x=_=>{_.preventDefault();const A=new FormData(_.target);c&&A.set("image",c),S(A),_.target.reset(),y("")},m=(_,A)=>{s({page:_,rowsPerPage:parseInt(A,10)})},j=async _=>{try{await C(tn(Mn.remove,_,t),Ne(_)),w.success("Success! Deleted item.",{duration:1e3})}catch(A){w.error(A?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},T=_=>{d(_),o(!0),y("")},R=async _=>{_.preventDefault();const A=new FormData(_.target);A.set("id",String(l?.id??"")),c&&A.set("image",c);try{await Sa(Mn.edit,A,t),await C(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),y("")}catch(f){w.error(f?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},I=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["md"]},{title:"Address",dataIndex:"address",key:"address",ellipsis:!0,responsive:["lg"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Branch Name",dataIndex:"business_name",key:"business_name",ellipsis:!0,responsive:["lg"]},{title:"Account Holder",dataIndex:"acc_holder_name",key:"acc_holder_name",ellipsis:!0,responsive:["xl"]},{title:"Account Number",dataIndex:"acc_number",key:"acc_number",ellipsis:!0,responsive:["xl"]},{title:"UPI ID",dataIndex:"upi_id",key:"upi_id",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(_,A)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>T(A),style:{padding:2}}),e.jsx(mt,{id:A?.id,funcName:j})]})}],[j]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),y("")},children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[xi.map(_=>e.jsx(V,{type:_.type,name:_.name,label:_.label,defaultValue:l?.[_.name]??"",required:_.required?"required":void 0},_.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),y("")},style:ym,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[xi.map(_=>e.jsx(V,{type:_.type,name:_.name,label:_.label,required:_.required?"required":void 0},_.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:m,data:{newData:p,columns:I,columnstype:"antd",action:!1,Loading:h,error:u}})})]})]})]})}const xm=({token:t})=>e.jsx(gm,{token:t}),En=Ke.product,bi=Ke.vendor.dropdown,ji=Ke.category.dropdown,bm=Ke.subCategory.dropdown,Si=Ke.unit.dropdown,al=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:En.list,page:a,perPage:s,token:t}),jm=({token:t})=>W(t&&bi?[bi,t]:null,([s,i])=>K(s,i)),Sm=({token:t})=>W(t&&ji?[ji,t]:null,([s,i])=>K(s,i)),wm=({token:t})=>W(t&&Si?[Si,t]:null,([s,i])=>K(s,i)),vm=({token:t,categoryId:a})=>{const s=t&&a?`${bm}?category_id=${encodeURIComponent(String(a))}`:null;return W(s?[s,t]:null,([o,l])=>K(o,l))},jn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},_m={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Cm({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,y]=r.useState(""),[h,u]=r.useState(""),[p,C]=r.useState(""),[S,x]=r.useState(""),[m,j]=r.useState(""),{isLoading:T,error:R,data:I,mutate:_}=al({token:t,page:a.page,perPage:a.rowsPerPage}),{data:A}=jm({token:t}),{data:f}=Sm({token:t}),{data:g}=wm({token:t}),{data:D}=vm({token:t,categoryId:h}),k=r.useMemo(()=>jn(A),[A]),L=r.useMemo(()=>jn(f),[f]),B=r.useMemo(()=>jn(g),[g]),b=r.useMemo(()=>jn(D),[D]),P=async E=>{try{await _(en(En.add,E,t),ze(E)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(M){w.error(M?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},O=E=>{E.preventDefault();const M=new FormData(E.target);h&&M.set("fk_categoryID",String(h)),p&&M.set("fk_sub_categoryID",String(p)),S&&M.set("vendor_id",String(S)),m&&M.set("unit",String(m)),c&&M.set("image",c),P(M),E.target.reset(),y(""),u(""),C(""),x(""),j("")},F=(E,M)=>{s({page:E,rowsPerPage:parseInt(M,10)})},U=async E=>{try{await _(tn(En.remove,E,t),Ne(E)),w.success("Success! Deleted item.",{duration:1e3})}catch(M){w.error(M?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},N=E=>{d(E),o(!0),y(""),u(E?.fk_categoryID??E?.category_id??""),C(E?.fk_sub_categoryID??E?.sub_category_id??""),x(E?.vendor_id??""),j(E?.unit??E?.unit_id??"")},Y=async E=>{E.preventDefault();const M=new FormData(E.target);M.set("id",String(l?.id??"")),h&&M.set("fk_categoryID",String(h)),p&&M.set("fk_sub_categoryID",String(p)),S&&M.set("vendor_id",String(S)),m&&M.set("unit",String(m)),c&&M.set("image",c);try{await Sa(En.edit,M,t),await _(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),y("")}catch($){w.error($?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},z=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["lg"]},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",ellipsis:!0,width:100,responsive:["md"]},{title:"Unit",dataIndex:"unit_name",key:"unit_name",ellipsis:!0,width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",ellipsis:!0,width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["xl"]},{title:"Hsn Code",dataIndex:"hsn_code",key:"hsn_code",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(E,M)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>N(M),style:{padding:2}}),e.jsx(mt,{id:M?.id,funcName:U})]})}],[U]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),y("")},children:e.jsx("form",{onSubmit:Y,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(V,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:E=>{const M=E?.value??"";u(M),C("")},defaultValue:h?L.find(E=>String(E?.value)===String(h)):null}),e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:E=>C(E?.value??""),defaultValue:p?b.find(E=>String(E?.value)===String(p)):null}),e.jsx(V,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:E=>j(E?.value??""),defaultValue:m?B.find(E=>String(E?.value)===String(m)):null}),e.jsx(V,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(V,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(Q,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:E=>x(E?.value??""),defaultValue:S?k.find(E=>String(E?.value)===String(S)):null}),e.jsx(V,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(st,{type:"text",label:"Description",name:"description",rows:3,defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),y("")},style:_m,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(V,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:E=>{const M=E?.value??"";u(M),C("")}}),e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:E=>C(E?.value??"")},`subcat_${h}`),e.jsx(V,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:E=>j(E?.value??"")}),e.jsx(V,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(V,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(Q,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:E=>x(E?.value??"")}),e.jsx(V,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(st,{type:"text",label:"Description",name:"description",rows:3}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:F,data:{newData:I,columns:z,columnstype:"antd",action:!1,Loading:T,error:R}})})]})]})]})}const Am=({token:t})=>e.jsx(Cm,{token:t}),Fn=Ke.category,Dm=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:Fn.list,page:a,perPage:s,token:t}),Tm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Rm({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),{isLoading:c,error:y,data:h,mutate:u}=Dm({token:t,page:a.page,perPage:a.rowsPerPage}),p=async R=>{try{await u(en(Fn.add,R,t),ze(R)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(I){w.error(I?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},C=R=>{R.preventDefault();const I=new FormData(R.target);p(I),R.target.reset()},S=(R,I)=>{s({page:R,rowsPerPage:parseInt(I,10)})},x=async R=>{try{await u(tn(Fn.remove,R,t),Ne(R)),w.success("Success! Deleted item.",{duration:1e3})}catch(I){w.error(I?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=R=>{d(R),o(!0)},j=async R=>{R.preventDefault();const I=new FormData(R.target);I.set("id",String(l?.id??""));try{await Sa(Fn.edit,I,t),await u(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(_){w.error(_?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},T=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,I)=>String(R?.name??"").localeCompare(String(I?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,I)=>String(R?.description??"").localeCompare(String(I?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,I)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(I),style:{padding:2}}),e.jsx(mt,{id:I?.id,funcName:x})]})}],[x]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Tm,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(v,{px:3,pb:2,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.jsx(V,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:S,data:{newData:h,columns:T,columnstype:"antd",action:!1,Loading:c,error:y}})})]})]})]})}const Im=({token:t})=>e.jsx(Rm,{token:t}),Un=Ke.subCategory,wi=Ke.category.dropdown,km=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:Un.list,page:a,perPage:s,token:t}),Pm=({token:t})=>W(t&&wi?[wi,t]:null,([s,i])=>K(s,i)),Om=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},Mm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Em({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,y]=r.useState(""),{isLoading:h,error:u,data:p,mutate:C}=km({token:t,page:a.page,perPage:a.rowsPerPage}),{data:S}=Pm({token:t}),x=r.useMemo(()=>Om(S),[S]),m=async f=>{try{await C(en(Un.add,f,t),ze(f)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(g){w.error(g?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=f=>{f.preventDefault();const g=new FormData(f.target);g.set("status","active"),g.set("img",c||""),m(g),f.target.reset(),y("")},T=(f,g)=>{s({page:f,rowsPerPage:parseInt(g,10)})},R=async f=>{try{await C(tn(Un.remove,f,t),Ne(f)),w.success("Success! Deleted item.",{duration:1e3})}catch(g){w.error(g?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},I=f=>{d(f),o(!0)},_=async f=>{f.preventDefault();const g=new FormData(f.target);g.set("id",String(l?.id??"")),c&&g.set("img",c);try{await Sa(Un.edit,g,t),await C(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),y("")}catch(D){w.error(D?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},A=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(f,g)=>String(f?.name??"").localeCompare(String(g?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(f,g)=>String(f?.description??"").localeCompare(String(g?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(f,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>I(g),style:{padding:2}}),e.jsx(mt,{id:g?.id,funcName:R})]})}],[R]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),y("")},children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?x.find(f=>String(f?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(V,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),y("")},style:Mm,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(V,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:T,data:{newData:p,columns:A,columnstype:"antd",action:!1,Loading:h,error:u}})})]})]})]})}const Fm=({token:t})=>e.jsx(Em,{token:t}),Rs=Ke.product,Um=Ke.academy.classes,$m=Ke.academy.sections,Nm=Ke.student.dropdown;function ka(t){const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]}function Sn(t,a){const s=Math.trunc(Number(t)||1),i=Math.max(1,s);return!Number.isFinite(Number(a))||Number(a)<=0?i:Math.min(i,Math.trunc(Number(a)))}function dt(t){return String(t??"")}function Lm({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,y]=r.useState(!1),[h,u]=r.useState(""),[p,C]=r.useState([]),[S,x]=r.useState({}),[m,j]=r.useState({}),[T,R]=r.useState(!1),[I,_]=r.useState(""),[A,f]=r.useState(0),[g,D]=r.useState(""),[k,L]=r.useState(ae()),[B,b]=r.useState([]),P={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},O=!!(a&&i&&l),{data:F}=W(t?[Um,t]:null,([fe,Se])=>K(fe,Se)),U=r.useMemo(()=>ka(F),[F]),N=t&&a?`${$m}?class_id=${encodeURIComponent(String(a))}`:null,{data:Y}=W(N?[N,t]:null,([fe,Se])=>K(fe,Se)),z=r.useMemo(()=>ka(Y),[Y]),E=t&&a&&i?`${Nm}?class=${encodeURIComponent(String(a))}&section=${encodeURIComponent(String(i))}`:null,{data:M}=W(E?[E,t]:null,([fe,Se])=>K(fe,Se)),$=r.useMemo(()=>ka(M),[M]),q=O?`${Rs.list}?page=1&per_page=10000`:null,{data:H,isLoading:re}=W(t&&q?[q,t]:null,([fe,Se])=>K(fe,Se),{revalidateOnFocus:!1}),ee=r.useMemo(()=>ka(H),[H]),G=r.useMemo(()=>{const fe=new Map;return(Array.isArray(ee)?ee:[]).forEach(Se=>{fe.set(dt(Se?.id),Se)}),fe},[ee]),J=r.useMemo(()=>{const fe=Object.entries(m||{});return fe.length===0?[]:fe.map(([Se,je])=>{const se=G.get(dt(Se));return se?{id:se?.id,name:se?.name,barcode:se?.barcode,stock:Number(se?.quantity||0),price:Number(se?.price||0),quantity:Sn(je,Number(se?.quantity||0))}:null}).filter(Boolean)},[m,G]),ie=r.useMemo(()=>new Set(J.map(fe=>dt(fe?.id))),[J]),pe=r.useMemo(()=>(Array.isArray(J)?J:[]).reduce((Se,je)=>Se+Number(je?.price||0)*Number(je?.quantity||1),0),[J]),_e=r.useMemo(()=>{const fe=Number(A||0);return!Number.isFinite(fe)||fe<=0?0:Math.min(fe,pe)},[A,pe]),le=r.useMemo(()=>Math.max(0,pe-_e),[_e,pe]),de=r.useMemo(()=>(Array.isArray(ee)?ee:[]).slice(0,30).map(fe=>({value:dt(fe?.id),label:`${fe?.name??""}${fe?.barcode?` • ${fe.barcode}`:""}${fe?.quantity!==void 0&&fe?.quantity!==null?` • Stock: ${fe.quantity}`:""}`,product:fe})),[ee]),{trigger:X}=tt(t&&O?Rs.search:null,(fe,{arg:Se})=>Gt(fe,{arg:Se},t));r.useEffect(()=>{if(!O){C([]);return}const fe=String(h||"").trim();if(fe.length<2){C(de);return}let Se=!0;const je=setTimeout(async()=>{let se=[];try{if(X){const xe=await X({search:fe});se=ka(xe)}}catch{se=[]}if(!Array.isArray(se)||se.length===0){const xe=fe.toLowerCase();se=(Array.isArray(ee)?ee:[]).filter(oe=>{const ye=String(oe?.name??"").toLowerCase(),Ye=String(oe?.barcode??"").toLowerCase();return ye.includes(xe)||Ye.includes(xe)}).slice(0,30)}const me=se.slice(0,30).map(xe=>({value:dt(xe?.id),label:`${xe?.name??""}${xe?.barcode?` • ${xe.barcode}`:""}${xe?.quantity!==void 0&&xe?.quantity!==null?` • Stock: ${xe.quantity}`:""}`,product:xe}));Se&&C(me)},250);return()=>{Se=!1,clearTimeout(je)}},[de,O,X,ee,h]),r.useEffect(()=>{j({}),x({}),u(""),C([]),R(!1),_(""),f(0),D(""),L(ae()),b([])},[a,i,l]);const ce=r.useCallback((fe,Se=1)=>{const je=fe?.id;if(!je)return;const se=Number(fe?.quantity||0);if(se<=0){w.error("Out of stock.",{duration:1e3});return}const me=Sn(Se,se);j(xe=>{const oe=xe||{};return Object.prototype.hasOwnProperty.call(oe,dt(je))?(w.error("Product already added.",{duration:1e3}),oe):{...oe,[dt(je)]:me}})},[j]),Re=r.useCallback((fe,Se,je)=>{j(se=>{const me=se||{},xe=dt(fe);return Object.prototype.hasOwnProperty.call(me,xe)?{...me,[xe]:Sn(Se,je)}:me})},[]),Ue=r.useCallback(fe=>{j(Se=>{const je=Se||{},se=dt(fe);if(!Object.prototype.hasOwnProperty.call(je,se))return je;const me={...je};return delete me[se],me})},[]),ke=r.useCallback((fe,Se,je)=>{x(se=>({...se||{},[dt(fe)]:Sn(Se,je)}))},[]),Ve=r.useCallback((fe,Se)=>{Se?.product&&ce(Se.product,1),u(""),C(de)},[ce,de]),Le=r.useCallback(fe=>{if(fe.key!=="Enter")return;fe.preventDefault();const Se=Array.isArray(p)&&p.length>0?p[0]:null;if(Se?.product){ce(Se.product,1),u(""),C(de);return}const je=String(h||"").trim().toLowerCase();if(je.length===0)return;const se=(Array.isArray(ee)?ee:[]).find(me=>{const xe=String(me?.name??"").toLowerCase(),oe=String(me?.barcode??"").toLowerCase();return xe.includes(je)||oe.includes(je)});se&&(ce(se,1),u(""),C(de))},[ce,de,ee,p,h]),at=()=>{if(!t){w.error("Missing token.",{duration:1e3});return}if(!a){w.error("Select class.",{duration:1e3});return}if(!i){w.error("Select section.",{duration:1e3});return}if(!l){w.error("Select student.",{duration:1e3});return}if(!J||J.length===0){w.error("Add at least one product.",{duration:1e3});return}R(!0)},{trigger:Ge,isMutating:Fe}=tt(t?Rs.sellProduct:null,(fe,{arg:Se})=>ts(fe,{arg:Se},t)),Je=async()=>{if(!I){w.error("Select payment type.",{duration:1e3});return}const fe=(Array.isArray(J)?J:[]).map(je=>({id:je?.id,quantity:Number(je?.quantity||1),price:Number(je?.price||0),total_price:Number(je?.total_price||0),fk_vendor_id:je?.fk_vendor_id||"",fk_categoryID:je?.fk_categoryID||"",name:je?.name||"",class_id:je?.class_id||"",fk_sub_categoryID:je?.fk_sub_categoryID||"",description:je?.description||"",min_quantity:Number(je?.min_quantity||0),storecategory:Number(je?.storecategory||0),barcode:je?.barcode||""})),Se={amount:pe,class:a,section:i,student_id:l,payment_type:I,discount:_e,notes:g||"",receipt_date:k?ae(k).format("YYYY-MM-DD"):"",product:JSON.stringify(fe),total_payable_amount:pe,attchement:B[0]?.originFileObj||""};try{const se=Array.isArray(B)&&B.length>0&&B[0]?.originFileObj?(()=>{const xe=new FormData;return Object.entries(Se).forEach(([oe,ye])=>{if(oe==="products"){xe.append("product",JSON.stringify(ye));return}xe.append(oe,String(ye??""))}),xe.append("attachment",B[0].originFileObj),xe})():Se,me=await Ge(se);me?.Status==="Success"?(w.success("Success! Product sold.",{duration:1e3}),R(!1),j({}),x({}),u(""),C(de),_(""),f(0),D(""),L(ae()),b([])):w.error(me?.msg??"Failed to submit.",{duration:1e3})}catch{w.error("Failed to submit.",{duration:1e3})}},it=r.useMemo(()=>[{title:"Product Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:160},{title:"Stock",dataIndex:"quantity",key:"quantity",width:110},{title:"Price",dataIndex:"price",key:"price",width:120},{title:"Quantity",key:"quantity",width:160,render:(fe,Se)=>{const je=dt(Se?.id),se=Number(Se?.quantity||0),me=ie.has(je),xe=(me?m?.[je]:S?.[je])??1;return e.jsx(n.InputNumber,{min:1,max:Number.isFinite(se)&&se>0?se:void 0,value:xe,onChange:oe=>{me?Re(je,oe,se):ke(je,oe,se)},disabled:se<=0})}},{title:"Amount",key:"amount",width:140,render:(fe,Se)=>{const je=dt(Se?.id),se=(ie.has(je)?m?.[je]:S?.[je])??1;return Number(Se?.price||0)*Number(se||1)}},{title:"Action",key:"action",width:120,render:(fe,Se)=>{const je=dt(Se?.id),se=Number(Se?.quantity||0),me=ie.has(je),xe=(me?m?.[je]:S?.[je])??1;return me?e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(te.DeleteOutlined,{}),onClick:()=>Ue(je),style:{padding:2}}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.PlusOutlined,{}),disabled:se<=0,onClick:()=>ce(Se,xe),style:{padding:2}})}}],[ce,ie,m,S,Ue,ke,Re]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(v,{pt:5,pb:2,children:[e.jsxs(v,{style:{padding:"12px 16px"},children:[e.jsx(v,{children:"Sell Product"}),e.jsx(n.Card,{style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:fe=>{const Se=fe?.value??"";s(Se),o(""),d(""),y(je=>!je)}}),e.jsx(Q,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:fe=>{const Se=fe?.value??"";o(Se),d("")}},`section_${c}`),e.jsx(Q,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:fe=>d(fe?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(n.Card,{style:{borderRadius:16,marginTop:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(260px, 520px) 1fr",gap:12,alignItems:"center",marginBottom:12},children:[e.jsx(v,{style:{marginTop:12},children:"Product Section"}),e.jsx(n.AutoComplete,{value:h,options:p,onSearch:u,onFocus:()=>{O&&String(h||"").trim().length<2&&C(de)},onSelect:Ve,disabled:!O,children:e.jsx(n.Input,{placeholder:"Search by product name or barcode",onKeyDown:Le,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",Tt(pe)]})]}),e.jsx(n.Table,{rowKey:fe=>dt(fe?.id),columns:it,dataSource:ee,loading:re,size:"small",bordered:!0,pagination:{pageSize:50,showSizeChanger:!0,pageSizeOptions:[25,50,100,200]},scroll:{x:"max-content"}}),e.jsxs("div",{style:{position:"sticky",bottom:0,background:"#fff",paddingTop:12,marginTop:12,borderTop:"1px solid #f0f0f0"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Selected Items"}),e.jsx("span",{children:J.length})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700,marginTop:6},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:Tt(pe)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(ne,{type:"button",value:"Submit",disabled:!O||J.length===0,onClick:at,style:{flex:1,minWidth:140}}),e.jsx(n.Button,{type:"text",style:P,onClick:()=>{j({}),x({}),u(""),C(de)},disabled:J.length===0,children:"Clear"})]})]})]})})]}),e.jsx(n.Modal,{open:T,title:"Payment",onCancel:()=>R(!1),onOk:Je,confirmLoading:Fe,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(n.Select,{value:I||void 0,onChange:_,placeholder:"Select payment type",style:{width:"100%"},options:[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"Bank",label:"Bank"},{value:"Cheque",label:"Cheque"},{value:"DD",label:"DD"},{value:"Internet Banking",label:"Internet Banking"}]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Receipt Date"}),e.jsx(n.DatePicker,{value:k,onChange:fe=>L(fe),style:{width:"100%"},format:"YYYY-MM-DD"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Discount"}),e.jsx(n.InputNumber,{min:0,max:pe,value:A,onChange:fe=>f(Number(fe||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(n.Upload,{fileList:B,beforeUpload:()=>!1,onChange:({fileList:fe})=>b((fe||[]).slice(-1)),maxCount:1,children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(n.Input.TextArea,{value:g,onChange:fe=>D(fe.target.value),rows:3})]}),e.jsx(n.Card,{style:{borderRadius:12,background:"#fafcff"},children:e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:Tt(pe)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:Tt(_e)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:Tt(le)})]})]})})]})})]})}const Bm=({token:t})=>e.jsx(Lm,{token:t}),$n=Ke.unit,qm=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:$n.list,page:a,perPage:s,token:t}),zm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ym({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),{isLoading:c,error:y,data:h,mutate:u}=qm({token:t,page:a.page,perPage:a.rowsPerPage}),p=async R=>{try{await u(en($n.add,R,t),ze(R)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(I){w.error(I?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},C=R=>{R.preventDefault();const I=new FormData(R.target);p(I),R.target.reset()},S=(R,I)=>{s({page:R,rowsPerPage:parseInt(I,10)})},x=async R=>{try{await u(tn($n.remove,R,t),Ne(R)),w.success("Success! Deleted item.",{duration:1e3})}catch(I){w.error(I?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=R=>{d(R),o(!0)},j=async R=>{R.preventDefault();const I=new FormData(R.target);I.set("id",String(l?.id??""));try{await Sa($n.edit,I,t),await u(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(_){w.error(_?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},T=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,I)=>String(R?.name??"").localeCompare(String(I?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,I)=>String(R?.description??"").localeCompare(String(I?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,I)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(I),style:{padding:2}}),e.jsx(mt,{id:I?.id,funcName:x})]})}],[x]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:zm,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(v,{px:3,pb:2,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.jsx(V,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:S,data:{newData:h,columns:T,columnstype:"antd",action:!1,Loading:c,error:y}})})]})]})]})}const Vm=({token:t})=>e.jsx(Ym,{token:t}),Wm=Ke.product.sellReports,Hm=Ke.academy.classes,Km=Ke.academy.sections,Gm=Ke.student.dropdown,vi=t=>{const a=Number(t??0);return Number.isFinite(a)?a.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Jm({token:t}){const a=r.useRef(null),[s,i]=r.useState(null),[o,l]=r.useState(""),[d,c]=r.useState(""),[y,h]=r.useState(""),[u,p]=r.useState(!1),C=b=>{const P=b?.data?.data??b?.data??b??[];return Array.isArray(P)?P:Array.isArray(P?.data)?P.data:[]},{data:S}=W(t?[Hm,t]:null,([b,P])=>K(b,P)),x=r.useMemo(()=>C(S),[S]),m=t&&o?`${Km}?class_id=${encodeURIComponent(String(o))}`:null,{data:j}=W(m?[m,t]:null,([b,P])=>K(b,P)),T=r.useMemo(()=>C(j),[j]),R=t&&o&&d?`${Gm}?class=${encodeURIComponent(String(o))}&section=${encodeURIComponent(String(d))}`:null,{data:I}=W(R?[R,t]:null,([b,P])=>K(b,P)),_=r.useMemo(()=>C(I),[I]),{trigger:A,isMutating:f,data:g}=tt(Wm,(b,{arg:P})=>ar(b,{arg:P},t));r.useEffect(()=>{const P=new Date().toISOString().slice(0,10);A({duration:[P,P]})},[A]);const D=r.useMemo(()=>{const b=g?.data??g??[];return Array.isArray(b)?b:[]},[g]),k=b=>{const P=Array.isArray(b?.product_details)?b.product_details:[];return P.length===0?null:e.jsx(n.Table,{size:"small",bordered:!0,pagination:!1,rowKey:O=>`${b?.receipt_id??"r"}_${O?.product_name??O?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:O=>vi(O)}],dataSource:P})},L=[{title:"Receipt No",dataIndex:"receipt_no",key:"receipt_no"},{title:"Date",dataIndex:"receipt_date",key:"receipt_date"},{title:"Amount",dataIndex:"receipt_amount",key:"receipt_amount",render:b=>vi(b)}],B=async()=>{if(!s||s.length!==2)return;const[b,P]=s;await A({duration:[b.format("YYYY-MM-DD"),P.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:y||""})};return e.jsx("div",{children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Filters"}),style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{value:s,onChange:i,style:{width:"100%"}})]}),e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:b=>{const P=b?.value??"";l(P),c(""),h(""),p(O=>!O)}}),e.jsx(Q,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:b=>{const P=b?.value??"";c(P),h("")}},`section_${u}`),e.jsx(Q,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:b=>h(b?.value??"")}),e.jsx(ne,{type:"button",value:f?"Searching...":"Search",disabled:f,onClick:B,style:{width:"100%"}})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(wt,{data:{tableRef:a}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:f,rowKey:b=>String(b?.receipt_id??b?.receipt_no??Math.random()),columns:L,expandable:{expandedRowRender:k},dataSource:D,pagination:{pageSize:20}})]})})})]})})}const Qm=({token:t})=>e.jsx(Jm,{token:t}),Xm=Ke.product;function Zm({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState([]),[l,d]=r.useState([]),[c,y]=r.useState(!1),[h,u]=r.useState(!1),[p,C]=r.useState(null),[S,x]=r.useState(0),[m,j]=r.useState(null),[T,R]=r.useState(""),I=r.useRef(null),_=xa.useReactToPrint({contentRef:I,documentTitle:"Stock Barcodes"}),{isLoading:A,error:f,data:g,mutate:D}=al({token:t,page:a.page,perPage:a.rowsPerPage}),k=(F,U)=>{s({page:F,rowsPerPage:parseInt(U,10)})},L={selectedRowKeys:i,onChange:(F,U)=>{o(F),d(U)}},B=F=>{C(F),x(Number(F?.quantity??0)),j(null),R(""),y(!0)},b=()=>{y(!1),C(null),x(0),j(null),R("")},P=async()=>{if(!p?.id)return;u(!0);const F=new FormData;F.append("product_id",String(p.id)),F.append("qty",String(S??0)),m&&F.append("tran_date",m.format("YYYY-MM-DD")),T&&F.append("remarks",T);try{const U=await Sa(Xm.addStock,F,t);U?.Status==="Success"?(w.success("Success! Updated quantity.",{duration:1e3}),b(),await D()):w.error(U?.msg??"Failed to update quantity.",{duration:1e3})}catch{w.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},O=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",width:100},{title:"Unit",dataIndex:"unit_name",key:"unit_name",width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["lg"]},{title:"Action",key:"action",width:160,fixed:"right",render:(F,U)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(n.Button,{size:"small",onClick:()=>B(U),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:p?.name?`Update Stock: ${p.name}`:"Update Stock",open:c,onCancel:b,onOk:P,okButtonProps:{loading:h},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(n.InputNumber,{min:0,style:{width:"100%"},value:S,onChange:F=>x(F??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:{width:"100%"},value:m,onChange:j})]}),e.jsx(st,{label:"Remarks",name:"remarks",rows:3,value:T,onChange:F=>R(F.target.value)})]})}),e.jsxs(v,{pt:5,pb:2,children:[e.jsxs(v,{children:["Manage Stock",e.jsx(ne,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>_?.(),style:{minWidth:170}})]}),e.jsx(v,{style:{padding:"12px 16px"},children:e.jsx(n.Card,{style:{borderRadius:16},children:e.jsx(Te,{parentCallback:k,data:{newData:g,columns:O,columnstype:"antd",action:!1,Loading:A,error:f,rowSelection:L}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:I,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map(F=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:F?.name??""}),e.jsx(fo,{value:String(F?.barcode??F?.id??""),height:50,width:1.6,displayValue:!0})]},F?.id??F?.barcode??F?.name))})})})]})}const eh=({token:t})=>e.jsx(Zm,{token:t}),th=Ke.report.stock,ah=Ke.product.dropdown,nh=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function sh({token:t}){const a=r.useRef(null),[s,i]=r.useState(null),[o,l]=r.useState(""),{data:d}=W(t?[ah,t]:null,([x,m])=>K(x,m)),c=r.useMemo(()=>nh(d),[d]),{trigger:y,isMutating:h,data:u}=tt(th,(x,{arg:m})=>ar(x,{arg:m},t));r.useEffect(()=>{const m=new Date().toISOString().slice(0,10);y({duration:[m,m]})},[y]);const p=r.useMemo(()=>{const x=u?.data??u??[];return(Array.isArray(x)?x:[]).flatMap(j=>(Array.isArray(j?.ledger)?j.ledger:[]).map((T,R)=>({key:`${j.product_id??j.product_name??"p"}-${R}`,date:T?.date,product:j?.product_name,opening:T?.opening,inward:T?.inward,outward:T?.outward,closing:T?.closing})))},[u]),C=[{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:x=>e.jsx("span",{style:{color:Number(x)<0?"red":"green"},children:x})}],S=async()=>{if(!s||s.length!==2)return;const[x,m]=s;await y({duration:[x.format("YYYY-MM-DD"),m.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Stock Report"}),style:{borderRadius:16},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[e.jsx(n.DatePicker.RangePicker,{value:s,onChange:i}),e.jsxs("select",{value:o,onChange:x=>l(x.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(x=>e.jsx("option",{value:String(x?.value??""),children:String(x?.label??"")},String(x?.value??x?.id??x?.label)))]}),e.jsx(n.Button,{type:"primary",onClick:S,loading:h,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(wt,{data:{tableRef:a}})})]}),e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:h,rowKey:"key",columns:C,dataSource:p,pagination:{pageSize:50}})]})]})}const rh=({token:t})=>e.jsx(sh,{token:t}),_i=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],kt={total_packages:124,total_downloads:45892,active_packages:118,deprecated_packages:6,pending_approval:3,published_this_month:12,published_this_week:4,packages_needing_update:8,packages_with_issues:2},Ci=[{npm_id:"NPM-001",package_name:"@ubk/erp-core",version:"1.2.1",description:"Core ERP utilities and shared types",author:"UBK Infotech",repository:"https://github.com/ubk/erp-core",license:"MIT",status:"published",created_at:"2024-01-15",updated_at:"2025-06-20"},{npm_id:"NPM-002",package_name:"@ubk/erp-components",version:"2.0.0",description:"Reusable Ant Design ERP component library",author:"UBK Infotech",repository:"https://github.com/ubk/erp-components",license:"ISC",status:"published",created_at:"2024-03-10",updated_at:"2025-08-01"},{npm_id:"NPM-003",package_name:"@ubk/erp-api-client",version:"0.9.5",description:"Axios-based API client for UBK ERP backends",author:"UBK Infotech",repository:"https://github.com/ubk/erp-api-client",license:"MIT",status:"draft",created_at:"2025-05-22",updated_at:"2025-07-14"},{npm_id:"NPM-004",package_name:"@ubk/erp-hooks",version:"1.1.0",description:"Custom React hooks for ERP workflows",author:"UBK Infotech",repository:"https://github.com/ubk/erp-hooks",license:"MIT",status:"published",created_at:"2024-08-05",updated_at:"2025-04-30"},{npm_id:"NPM-005",package_name:"@ubk/erp-utils",version:"3.2.1",description:"Utility functions for date, currency, and validation",author:"UBK Infotech",repository:"https://github.com/ubk/erp-utils",license:"ISC",status:"deprecated",created_at:"2023-11-20",updated_at:"2025-02-10"}],Ai=[{key:"dashboard",label:"Dashboard"},{key:"allPackages",label:"All Packages"},{key:"published",label:"Published"},{key:"draft",label:"Draft"},{key:"deprecated",label:"Deprecated"},{key:"pendingApproval",label:"Pending Approval"}];function ih(){const[t,a]=r.useState("dashboard"),[s,i]=r.useState("This Month"),[o,l]=r.useState(""),[d,c]=r.useState(""),[y,h]=r.useState(1),[u,p]=r.useState(10),[C,S]=r.useState(""),x=r.useRef(null),m=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),j=r.useMemo(()=>{if(!C.trim())return Ci;const A=C.toLowerCase();return Ci.filter(f=>Object.values(f).some(g=>String(g??"").toLowerCase().includes(A)))},[C]),T=r.useMemo(()=>{const A=(y-1)*u;return j.slice(A,A+u)},[j,y,u]),R=()=>{h(1)},I=()=>{const A=[{title:"Total Packages",value:kt.total_packages,icon:e.jsx(te.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:kt.total_downloads.toLocaleString(),icon:e.jsx(te.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:kt.active_packages,icon:e.jsx(te.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:kt.deprecated_packages,icon:e.jsx(te.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:kt.pending_approval,icon:e.jsx(te.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:kt.published_this_month,icon:e.jsx(te.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:kt.published_this_week,icon:e.jsx(te.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:kt.packages_needing_update,icon:e.jsx(te.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:kt.packages_with_issues,icon:e.jsx(te.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(n.Row,{gutter:[16,16],children:A.map((f,g)=>e.jsx(n.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(n.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${f.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(v,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${f.color}15`,color:f.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:f.icon}),e.jsxs(v,{children:[e.jsx(n.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:f.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:f.value})]})]})},g))})},_=()=>{const A=[{title:"NPM ID",dataIndex:"npm_id",key:"npm_id",width:100},{title:"Package Name",dataIndex:"package_name",key:"package_name",ellipsis:!0},{title:"Version",dataIndex:"version",key:"version",width:100},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["md"]},{title:"Author",dataIndex:"author",key:"author",width:140,responsive:["lg"]},{title:"License",dataIndex:"license",key:"license",width:100},{title:"Status",dataIndex:"status",key:"status",width:120,render:f=>{let g="default";return f==="published"?g="green":f==="draft"?g="orange":f==="deprecated"?g="red":f==="pending"&&(g="blue"),e.jsx(n.Tag,{color:g,children:f.toUpperCase()})}},{title:"Created Date",dataIndex:"created_at",key:"created_at",width:120,responsive:["lg"]},{title:"Updated Date",dataIndex:"updated_at",key:"updated_at",width:120,responsive:["lg"]},{title:"Actions",key:"action",width:120,fixed:"right",render:(f,g)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:A};return e.jsx(v,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(v,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[m&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Q,{options:_i,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:_i.find(A=>A.value===s)||null,onChange:A=>i(A?.value||"This Month")})}),s==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:A=>l(A?A.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:A=>c(A?A.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:R})})})]}),e.jsx(n.Tabs,{activeKey:t,onChange:a,items:Ai})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:Ai.find(A=>A.key===t)?.label||"Report"})}),e.jsxs(v,{p:3,children:[t!=="dashboard"&&e.jsx(wt,{data:{tableRef:x}}),t==="dashboard"?I():e.jsx(n.Table,{size:"small",dataSource:T,columns:_(),loading:!1,pagination:!1,bordered:!0,rowKey:A=>A.npm_id||A.package_name||Math.random(),ref:x}),t!=="dashboard"&&j.length>0&&e.jsx(n.Pagination,{current:y,pageSize:u,total:j.length,onChange:(A,f)=>{h(A),p(f)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const ns=t=>t??localStorage.getItem("authToken")??"",or=(t,a)=>{const s=String(t??""),i=String(a??"");return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i},Ie={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",roleDropdown:"api/Branch/getRoledropdownforBranch",staff:{list:"api/branchapi/staff/staffsearchbyRole",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_attendance/attendance/report/daily",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"}},nl=()=>or(He(),Ie.upload),oh=()=>or(He(),Ie.staff.uploadProfile),lh=()=>or(He(),Ie.staff.uploadDocuments),dh=async({baseUrl:t,page:a=1,perPage:s=10},i)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(l,ns(i))},Rt=async(t,a,s)=>Ee(t,a,ns(s)),zt=async(t,a,s)=>Be(t,a,ns(s)),nn=async(t,a,s)=>qe(t,a,ns(s)),Jt=Ie.staff,ch=Ie.master.shift.dropdown,uh=Ie.master.department.dropdown,ph=Ie.master.designation.dropdown,mh=Ie.roleDropdown,wn=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},hh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Pa={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Di={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function fh({token:t,mode:a,staffId:s,initialValues:i,onSubmitted:o}){const l=r.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),d=String(l?.multiple_shift??"").toLowerCase()==="yes",[c,y]=r.useState(i?.roleValue??null),[h,u]=r.useState(i?.departmentValue??null),[p,C]=r.useState(i?.designationValue??null),[S,x]=r.useState(i?.genderValue??null),[m,j]=r.useState(i?.shiftValue??(d?[]:null)),[T,R]=r.useState(i?.dob?ae(i.dob):null),[I,_]=r.useState(i?.doj?ae(i.doj):null),[A,f]=r.useState(i?.file??""),{data:g}=W(t?[ch,t]:null,([Y,z])=>K(Y,z)),{data:D}=W(t?[uh,t]:null,([Y,z])=>K(Y,z)),{data:k}=W(t?[ph,t]:null,([Y,z])=>K(Y,z)),{data:L}=W(t?[mh,t]:null,([Y,z])=>K(Y,z)),{data:B}=W(t?[Jt.lastEmpNo,t]:null,([Y,z])=>K(Y,z)),b=r.useMemo(()=>wn(g),[g]),P=r.useMemo(()=>wn(D),[D]),O=r.useMemo(()=>wn(k),[k]),F=r.useMemo(()=>wn(L),[L]),U=r.useMemo(()=>{const Y=B?.data?.emp_number??B?.emp_number??B?.data??"";return String(Y??"")},[B]),N=async Y=>{Y.preventDefault();const z=new FormData(Y.target);z.set("role",c?.value??c??""),z.set("department",h?.value??h??""),z.set("designation",p?.value??p??""),z.set("gender",S?.value??S??""),z.set("dob",T?T.format("YYYY-MM-DD"):""),z.set("doj",I?I.format("YYYY-MM-DD"):""),d?(z.delete("shift_id"),(Array.isArray(m)?m:[]).forEach(M=>{z.append("shift_id[]",M?.value??M??"")})):z.set("shift_id",m?.value??m??""),A&&z.set("file",A);try{const E=a==="edit"&&s,M=E?Jt.editBasic:Jt.addBasic;E&&z.set("staff_id",String(s));const $=E?await zt(M,z,t):await Rt(M,z,t),q=$?.ID??$?.id??s??null;w.success("Success!",{duration:1e3}),o?.({staffId:q,basic:{roleValue:c,departmentValue:h,designationValue:p,genderValue:S,shiftValue:m,dob:T,doj:I,file:A}})}catch(E){w.error(E?.response?.data?.msg??E?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"number",name:"emp_number",label:"EMP No",defaultValue:i?.emp_number??U,required:!0}),e.jsx(V,{type:"text",name:"f_name",label:"First Name",defaultValue:i?.f_name??"",required:!0}),e.jsx(V,{type:"text",name:"l_name",label:"Last Name",defaultValue:i?.l_name??"",required:!0}),e.jsx(V,{type:"text",name:"pan_no",label:"PAN",defaultValue:i?.pan_no??""}),e.jsx(V,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:i?.adhar_no??""}),e.jsx(Q,{label:"Role",options:F,value:c,onChange:Y=>y(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Q,{label:"Department",options:P,value:h,onChange:Y=>u(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Q,{label:"Designation",options:O,value:p,onChange:Y=>C(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Q,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:S,onChange:Y=>x(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(V,{type:"text",name:"email",label:"Email",defaultValue:i?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:Pa,children:"DOB"}),e.jsx(n.DatePicker,{value:T,onChange:Y=>R(Y),style:Di,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:Pa,children:"DOJ"}),e.jsx(n.DatePicker,{value:I,onChange:Y=>_(Y),style:Di,placeholder:"Select DOJ"})]}),e.jsx(V,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:i?.bloodGroup??""}),e.jsx(V,{type:"text",name:"contact_no",label:"Contact No",defaultValue:i?.contact_no??"",required:!0}),e.jsx(V,{type:"text",name:"education",label:"Education",defaultValue:i?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:Pa,children:"Shift"}),e.jsx(Q,{options:b,value:m,onChange:Y=>j(Y??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:Pa,children:"Profile Picture"}),e.jsx(n.Upload,{maxCount:1,action:oh(),headers:t?{Authorization:t}:void 0,onChange:Y=>{if(Y?.file?.status==="done"){const z=hh(Y?.file?.response);z&&f(z)}Y?.file?.status==="removed"&&f("")},children:e.jsx(n.Button,{type:"link",style:{paddingLeft:0},children:A?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:Pa,children:"Address"}),e.jsx("textarea",{name:"address",rows:3,defaultValue:i?.address??"",placeholder:"Address",style:{width:"100%",resize:"vertical",padding:10,border:"1px solid #d9d9d9",borderRadius:8,outline:"none"}})]}),e.jsx("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const vn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ti={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},yh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ri=t=>{if(!t)return null;const a=ae(t);return a.isValid()?a:null};function gh({token:t,mode:a,staffId:s,initialRows:i,onSubmitted:o,onBack:l}){const[d,c]=r.useState(()=>(Array.isArray(i)&&i.length?i:[{name:"",from:null,to:null,image:""}]).map(x=>({name:x?.name??"",from:Ri(x?.from),to:Ri(x?.to),image:x?.image??""}))),y=r.useMemo(()=>t?{Authorization:t}:void 0,[t]),h=(S,x)=>{c(m=>m.map((j,T)=>T===S?{...j,...x}:j))},u=()=>c(S=>[...S,{name:"",from:null,to:null,image:""}]),p=S=>c(x=>x.length<=1?x:x.filter((m,j)=>j!==S)),C=async S=>{if(S.preventDefault(),!s){w.error("Missing staff id.",{duration:1e3});return}const x=new FormData;x.append("staff_id",String(s)),d.forEach((m,j)=>{x.append(`experience[${j}][name]`,String(m?.name??"")),x.append(`experience[${j}][from]`,m?.from?m.from.format("YYYY-MM-DD"):""),x.append(`experience[${j}][to]`,m?.to?m.to.format("YYYY-MM-DD"):""),x.append(`experience[${j}][image]`,String(m?.image??""))});try{const m=a==="edit",j=m?Jt.editExperience:Jt.addExperience,T=m?await zt(j,x,t):await Rt(j,x,t);w.success("Success!",{duration:1e3}),o?.({experience:d,result:T})}catch(m){w.error(m?.response?.data?.msg??m?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((S,x)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end",border:"1px solid #eee",borderRadius:12,padding:14},children:[e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Name"}),e.jsx("input",{value:S.name,onChange:m=>h(x,{name:m.target.value}),placeholder:"Company / School",style:{width:"100%",height:40,border:"none",borderBottom:"1px solid #d9d9d9",outline:"none",background:"transparent"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"From"}),e.jsx(n.DatePicker,{value:S.from,onChange:m=>h(x,{from:m}),style:Ti})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"To"}),e.jsx(n.DatePicker,{value:S.to,onChange:m=>h(x,{to:m}),style:Ti})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Document"}),e.jsx(n.Upload,{maxCount:1,action:lh(),headers:y,onChange:m=>{if(m?.file?.status==="done"){const j=yh(m?.file?.response);j&&h(x,{image:j})}m?.file?.status==="removed"&&h(x,{image:""})},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),children:"Upload"})}),!!S.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:S.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.DeleteOutlined,{}),danger:!0,onClick:()=>p(x),disabled:d.length<=1})})]},`exp-${x}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(n.Button,{icon:e.jsx(te.PlusOutlined,{}),onClick:u,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(n.Button,{onClick:l,children:"Back"}),e.jsx(ne,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const Ii=(t,a=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const s=a.length?a:["allowances","Allowances","dedection","Dedection","deductions","Deductions"],i=[t];t?.data&&typeof t.data=="object"&&i.push(t.data);for(const l of i)for(const d of s){const c=l?.[d]??l?.[d.toLowerCase()]??l?.[d.toUpperCase()];if(Array.isArray(c)&&c.length>0)return c}const o=t?.data;if(Array.isArray(o)&&o.length>0)return o}return[]},Oa=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function xh({token:t,mode:a,staffId:s,initialValues:i,onSubmitted:o,onBack:l}){const[d,c]=r.useState(i?.type??"Permanent"),[y,h]=r.useState(i?.salary_type??Oa[0]?.value),[u,p]=r.useState(Number(i?.amount??0)),[C,S]=r.useState(Number(i?.basic_pay)),[x,m]=r.useState(i?.declarationPERyear??""),{data:j}=W(t?[uc,t]:null,([f,g])=>K(f,g),{revalidateOnFocus:!1}),T=r.useMemo(()=>Ii(j,["allowances","Allowances"]),[j]),R=r.useMemo(()=>Ii(j,["dedection","Dedection","deductions","Deductions"]),[j]),I=r.useMemo(()=>{const f=Number(C||0),g=(Array.isArray(T)?T:[]).map(b=>{const P=b?.amount_type??b?.amountType??b?.type??"",O=Number(b?.Amount??b?.amount??0),U=String(P).trim().toLowerCase()==="flat"?O:Number(f)/100*Number(O||0);return{...b,value:Number.isFinite(U)?U:0}}),D=(Array.isArray(R)?R:[]).map(b=>{const P=b?.amount_type??b?.amountType??b?.type??"",O=Number(b?.Amount??b?.amount??0),U=String(P).trim().toLowerCase()==="flat"?O:Number(f)/100*Number(O||0);return{...b,value:Number.isFinite(U)?U:0}}),k=g.reduce((b,P)=>b+Number(P?.value||0),0),L=D.reduce((b,P)=>b+Number(P?.value||0),0),B=Math.max(0,Number(f)+k-L);return{allowances:g,deductions:D,netAmount:B}},[T,R,C]),_=async f=>{if(f.preventDefault(),!s){w.error("Missing staff id.",{duration:1e3});return}const g=new FormData;g.append("staff_id",String(s)),g.append("type",d),d==="Nonpermanent"?(g.append("salary_type",y??""),g.append("amount",String(u||"")),g.append("Allowances",JSON.stringify([])),g.append("Dedection",JSON.stringify([]))):(g.append("basic_pay",String(C||"")),g.append("declarationPERyear",String(x??"")),g.append("Allowances",JSON.stringify(I.allowances||[])),g.append("Dedection",JSON.stringify(I.deductions||[])),g.append("amount",String(I.netAmount||0)));try{const D=a==="edit",k=D?Jt.editPayroll:Jt.addPayroll,L=D?await zt(k,g,t):await Rt(k,g,t);o?.({payroll:{staffType:d,salaryType:y,amount:u,basicPay:C,declaration:x},result:L})}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed.",{duration:1e3})}},A=r.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(f,g)=>`${g?.Amount??""} / ${g?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:f=>c(f?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(Q,{label:"Type",options:Oa,value:Oa.find(f=>f.value===y)??Oa[0],onChange:f=>h(f?.value??Oa[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(V,{type:"number",label:"Amount",value:u,onChange:f=>p(Number(f.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{type:"number",label:"Basic Pay",value:C,onChange:f=>S(Number(f.target.value||0)),required:!0}),e.jsx(V,{type:"text",label:"IT Declarations/Year",value:x,onChange:f=>m(f.target.value)}),e.jsx(V,{type:"number",label:"Net Amount",value:I.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(f,g)=>`${f?.title??"a"}-${g}`,columns:A,dataSource:I.allowances,pagination:!1})}),e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(f,g)=>`${f?.title??"d"}-${g}`,columns:A,dataSource:I.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(ne,{type:"submit",value:"Finish",color:"primary"})})]})})}const bh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function jh({token:t,mode:a="add",staffId:s,onFinished:i}){const[o,l]=r.useState(0),[d,c]=r.useState(s??null),[y,h]=r.useState(null),[u,p]=r.useState(null),[C,S]=r.useState(null),x=a==="edit"?s??d:null,m=r.useMemo(()=>x?`${Ie.staff.basicById}?staff_id=${encodeURIComponent(String(x))}`:null,[x]),j=r.useMemo(()=>x?`${Ie.staff.experienceById}?staff_id=${encodeURIComponent(String(x))}`:null,[x]),T=r.useMemo(()=>x?`${Ie.staff.payrollById}?staff_id=${encodeURIComponent(String(x))}`:null,[x]),{data:R}=W(t&&m?[m,t]:null,([k,L])=>K(k,L)),{data:I}=W(t&&j?[j,t]:null,([k,L])=>K(k,L)),{data:_}=W(t&&T?[T,t]:null,([k,L])=>K(k,L)),A=r.useMemo(()=>{const k=bh(R)[0]??R?.data??R??null;return k?{emp_number:k?.emp_number??k?.empNo??"",f_name:k?.f_name??k?.firstname??k?.first_name??"",l_name:k?.l_name??k?.lastname??k?.last_name??"",pan_no:k?.pan_no??"",adhar_no:k?.adhar_no??"",email:k?.email??"",dob:k?.dob??"",doj:k?.doj??"",bloodGroup:k?.bloodGroup??k?.blood_group??"",contact_no:k?.contact_no??k?.phone??"",education:k?.education??"",address:k?.address??"",file:k?.file??k?.profile_picture??""}:null},[R]),f=r.useMemo(()=>{const k=I?.data??I??null;return(Array.isArray(k?.experience)?k.experience:Array.isArray(k)?k:[]).map(B=>({name:B?.name??"",from:B?.from??"",to:B?.to??"",image:B?.image??""}))},[I]),g=r.useMemo(()=>{const k=_?.data??_??null;return k?{type:k?.type??"Permanent",salary_type:k?.salary_type??"",amount:k?.amount??"",basic_pay:k?.basic_pay??"",declarationPERyear:k?.declarationPERyear??""}:null},[_]),D=r.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:a==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(n.Steps,{current:o,items:D}),o===0&&e.jsx(fh,{token:t,mode:a,staffId:x,initialValues:A,onSubmitted:({staffId:k})=>{k&&c(k),l(1)}}),o===1&&e.jsx(gh,{token:t,mode:a,staffId:x??d,initialRows:f,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(xh,{token:t,mode:a,staffId:x??d,initialValues:g,onBack:()=>l(1),onSubmitted:()=>{w.success("Completed.",{duration:1e3}),i?.({staffId:x??d}),l(0),a!=="edit"&&(c(null),h(null),p(null),S(null))}})]})})]})}function Sh({token:t}){return e.jsx(jh,{token:t,mode:"add"})}const wh=({token:t})=>e.jsx(Sh,{token:t}),_n=Ie.staff,vh=Ie.roleDropdown,_h=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ch=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Ah({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(""),[l,d]=r.useState(""),{data:c}=W(t?[vh,t]:null,([T,R])=>K(T,R)),y=r.useMemo(()=>_h(c),[c]),h=r.useMemo(()=>{const T=a.page,R=a.rowsPerPage,I=i&&!l?`${_n.searchByRole}?role_id=${encodeURIComponent(String(i))}`:l?`${_n.searchByKeywords}?key=${encodeURIComponent(String(l))}`:_n.list,_=I.includes("?")?"&":"?";return`${I}${_}page=${encodeURIComponent(String(T))}&per_page=${encodeURIComponent(String(R))}`},[a.page,a.rowsPerPage,l,i]),{isLoading:u,error:p,data:C,mutate:S}=W(t?[h,t]:null,([T,R])=>K(T,R)),x=r.useMemo(()=>Ch(C),[C]),m=async T=>{const R=T?.id??T?.fk_staffID??T?.staff_id;if(R)try{await nn(_n.deactivate,R,t),w.success("Success! Staff deactivated.",{duration:1e3}),await S()}catch(I){w.error(I?.response?.data?.msg??I?.message??"Failed to deactivate staff.",{duration:1e3})}},j=r.useMemo(()=>[{title:"Emp ID",dataIndex:"employee_id",key:"employee_id",width:120,responsive:["lg"]},{title:"Name",key:"name",ellipsis:!0,render:(T,R)=>`${R?.name||""} ${R?.surname||""}`.trim()},{title:"Role",dataIndex:"role",key:"role",ellipsis:!0,responsive:["md"]},{title:"Department",dataIndex:"department",key:"department",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"contact_no",key:"contact_no",ellipsis:!0,responsive:["md"]},{title:"Status",dataIndex:"status",key:"status",width:120,responsive:["lg"]},{title:"Action",key:"action",width:90,fixed:"right",render:(T,R)=>e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(te.DeleteOutlined,{}),onClick:()=>m(R),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:2,style:{margin:0},children:"Filters"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:[{value:"",label:"All Roles"},...y],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:T=>{o(T?.value??""),s(R=>({...R,page:1}))}}),e.jsx(V,{type:"text",label:"Keyword",value:l,onChange:T=>d(T.target.value),placeholder:"Search by keywords"}),e.jsx(ne,{type:"button",value:"Refresh",onClick:()=>S()})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:8,style:{margin:0},children:"Staff Directory"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:u,rowKey:T=>String(T?.id??T?.fk_staffID??T?.staff_id??Math.random()),columns:j,dataSource:x,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(T,R)=>s({page:T,rowsPerPage:R}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const Dh=({token:t})=>e.jsx(Ah,{token:t}),Th=Ie.attendance,Rh=Ie.roleDropdown,ki=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Cn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Pi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ih({token:t,open:a,onClose:s,roleId:i,onSaved:o}){const[l,d]=r.useState(null),[c,y]=r.useState(""),[h,u]=r.useState(ae()),[p,C]=r.useState(ae()),[S,x]=r.useState(ae()),m=r.useMemo(()=>i?`${Ie.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(i))}`:null,[i]),{data:j}=W(t&&m?[m,t]:null,([f,g])=>K(f,g)),T=r.useMemo(()=>ki(j),[j]),{trigger:R,data:I}=tt(t?Ie.attendance.staffShiftByStaffId:null,(f,{arg:g})=>Gt(f,{arg:g},t)),_=r.useMemo(()=>ki(I),[I]),A=async()=>{if(!l?.value){w.error("Select staff.",{duration:1e3});return}if(!c){w.error("Select shift.",{duration:1e3});return}const f=new FormData;f.set("staffID",String(l.value)),f.set("shift_id",String(c)),f.set("attendance_date",h?h.format("YYYY-MM-DD"):""),f.set("intime",p?p.format("h:mm a"):""),f.set("outime",S?S.format("h:mm a"):"");try{await Rt(Ie.attendance.manualAttendance,f,t),w.success("Success!",{duration:1e3}),o?.(),s?.(),d(null),y(""),u(ae()),C(ae()),x(ae())}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed.",{duration:1e3})}};return e.jsx(n.Modal,{open:a,onCancel:s,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(n.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{label:"Staff",options:T,value:l,onChange:async f=>{if(d(f??null),y(""),f?.value&&R)try{await R({staff_id:f.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"Shift"}),e.jsx(n.Radio.Group,{value:c,onChange:f=>y(f.target.value),style:{display:"grid",gap:8},children:_.map(f=>e.jsx(n.Radio,{value:f?.value,children:f?.label??f?.name??f?.title??String(f?.value??"")},String(f?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"Date"}),e.jsx(n.DatePicker,{value:h,onChange:f=>f&&u(f),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"Start Time"}),e.jsx(n.TimePicker,{value:p,onChange:f=>f&&C(f),use12Hours:!0,format:"h:mm a",style:Pi})]}),e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"End Time"}),e.jsx(n.TimePicker,{value:S,onChange:f=>f&&x(f),use12Hours:!0,format:"h:mm a",style:Pi})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:s,children:"Cancel"}),e.jsx(ne,{type:"button",value:"Save",color:"primary",onClick:A})]})]})})})}const kh=({tableRef:t,excelDisabled:a})=>{const s=new Date().getTime(),i=xa.useReactToPrint({content:()=>t?.current});return e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:i})}),e.jsx(n.Col,{children:a?e.jsx(n.Button,{type:"text",icon:e.jsx(te.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>w.error("You must save attendance before download",{duration:2e3})}):e.jsx(Zo.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:t?.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},Ph=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?Array.isArray(s?.student)?s.student:[]:Array.isArray(s?.staff)?s.staff:[]:[]},Oh=t=>{const a=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,s=Number(a);return Number.isFinite(s)&&s>=0?s:0},Mh=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?{sunday:String(s?.sunday??"").toLowerCase()==="yes",holiday:String(s?.holiday??"").toLowerCase()==="yes"}:{sunday:!!s?.sunday,holiday:!!s?.holiday}:{sunday:!1,holiday:!1}};function Eh({token:t,url:a,columns:s,reload:i,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:y="staff"}){const h=r.useRef(null),[u,p]=r.useState({page:0,rowsPerPage:10}),[C,S]=r.useState(!1),[x,m]=r.useState(!1),[j,T]=r.useState(null),[R,I]=r.useState([]),[_,A]=r.useState({sunday:!1,holiday:!1}),[f,g]=r.useState(!0);r.useEffect(()=>{p(B=>({...B,page:0}))},[a]),r.useEffect(()=>{let B=!0;return(async()=>{if(!(!t||!a)){S(!0);try{const P=String(a).includes("?")?"&":"?",O=`${a}${P}page=${u.page+1}&per_page=${u.rowsPerPage}`,F=await K(O,t);if(!B)return;T(F),F?.Status==="Success"?(d?.(!1),I(Ph(F,y)),A(Mh(F,y))):(d?.(!0),I([]),A({sunday:!1,holiday:!1}))}catch{if(!B)return;d?.(!0),I([])}finally{B&&S(!1)}}})(),()=>{B=!1}},[u.page,u.rowsPerPage,i,d,t,y,a]);const D=r.useMemo(()=>Oh(j),[j]);r.useEffect(()=>{const B=(Array.isArray(R)?R:[]).find(b=>b?.attendence_type_id===null);g(!!B)},[R]);const k=async()=>{if(t){m(!0);try{if(y==="staff"){const B=(Array.isArray(R)?R:[]).map(b=>({staff_id:b?.staff_id,attendence_type_id:b?.attendence_type_id?b.attendence_type_id:"1",in_time:b?.intime,out_time:b?.outtime,date:c}));await Rt(Ie.attendance.addAttendanceToStaffByBranch,B,t),w.success("Attendance saved successfully",{duration:2e3}),o?.(b=>!b)}else w.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(B){w.error(B?.response?.data?.msg??B?.message??"Failed required dates",{duration:2e3})}finally{m(!1)}}},L=r.useMemo(()=>(Array.isArray(s)?s:[]).map(b=>b?.selector==="attendence_type_id"?{title:b?.name??"Attendance",dataIndex:b.selector,key:b.selector,render:P=>P==null||P===""?e.jsx(n.Tag,{color:"orange",children:"Not Set"}):String(P)==="1"?e.jsx(n.Tag,{color:"green",children:"Present"}):String(P)==="4"?e.jsx(n.Tag,{color:"red",children:"Absent"}):String(P)==="3"?e.jsx(n.Tag,{color:"orange",children:"Late"}):e.jsx(n.Tag,{children:String(P)})}:b?.selector==="snum"?{title:b?.name??"Sl",key:b.selector,render:(P,O,F)=>F+1}:{title:b?.name??b?.selector,dataIndex:b?.selector,key:b?.selector}),[s]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{children:[e.jsx(kh,{tableRef:h,excelDisabled:f}),e.jsx(n.Modal,{open:x,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(n.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),_.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):_.holiday?e.jsx("div",{style:{textAlign:"center",padding:"16px 0"},children:e.jsx("div",{style:{fontWeight:700,marginBottom:6},children:"Holiday"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:h,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(B,b)=>String(B?.id??B?.staff_id??b),columns:L,dataSource:R,loading:C,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:D,showSizeChanger:!0,onChange:(B,b)=>p({page:B-1,rowsPerPage:b})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:k,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const Fh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Uh={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function $h({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(ae().format("YYYY-MM-DD")),[l,d]=r.useState(!1),[c,y]=r.useState(null),[h,u]=r.useState(!1),[p,C]=r.useState(!0),[S,x]=r.useState(!1),m=r.useRef(null),{data:j}=W(t?[Rh,t]:null,([I,_])=>K(I,_)),T=r.useMemo(()=>Fh(j),[j]),R=r.useMemo(()=>[{id:"1",name:"Staff Id",selector:"employee_id",sortable:!0},{id:"2",name:"Name",selector:"full_name",sortable:!0},{id:"4",name:"Contact",selector:"contact_no",sortable:!0},{id:"3",name:"Attendance",selector:"attendence_type_id",sortable:!0},{id:"5",name:"In Time",selector:"intime",sortable:!0},{id:"6",name:"Out Time",selector:"outtime",sortable:!0}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:I=>s(I?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{defaultValue:ae(),onChange:I=>I&&o(I.format("YYYY-MM-DD")),style:Uh,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>{!a||!i||(y(`${Th.staffListForAttendance}?role=${encodeURIComponent(String(a))}&date=${encodeURIComponent(String(i))}`),d(I=>!I))}})})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:12},children:[e.jsx(n.Button,{size:"small",type:h?"primary":"default",onClick:()=>u(I=>!I),children:h?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"default",disabled:p,onClick:()=>x(!0),children:"Give Attendance"})]}),c?e.jsx(Eh,{token:t,url:c,columns:R,reload:l,setReload:d,saveBtnRef:m,setSaveBtnDisabled:C,date:i,type:"staff",holidayChecked:h}):null]}),e.jsx(Ih,{token:t,open:S,onClose:()=>x(!1),roleId:a,onSaved:()=>d(I=>!I)})]})}const Nh=({token:t})=>e.jsx($h,{token:t}),Oi=Ie.attendanceReport.monthlyStaffReport,Lh=Ie.roleDropdown,Bh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function qh({token:t}){const a=r.useRef(null),[s,i]=r.useState(!1),[o,l]=r.useState([]),[d,c]=r.useState({role:"",rolllabel:"",year:"",month:""}),y=r.useMemo(()=>sr(5),[]),{data:h}=W(t?[Lh,t]:null,([B,b])=>K(B,b)),u=r.useMemo(()=>Bh(h),[h]),[p,C]=r.useState([]),[S,x]=r.useState(1),[m,j]=r.useState(!1),[T,R]=r.useState(!1),[I,_]=r.useState(null),A=r.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:f}=tt(t&&Oi?`${Oi}?page=${S}&per_page=3`:null,(B,{arg:b})=>Gt(B,{arg:b},t),{onSuccess:B=>{j(!1);const b=Array.isArray(B)?B:[];b.length>0&&C(P=>[...P||[],...b]),b.length>1?x(P=>P+1):R(!1)},onError:()=>{j(!1),R(!1)}});r.useEffect(()=>{T&&f&&I&&f(I)},[T,S,I,f]);const g=r.useMemo(()=>{const B=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(b,P)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:P?.full_name??""})}];return Array.isArray(p)&&p.length>0&&((p[0]?.monthly_data??[]).forEach((P,O)=>{B.push({title:O+1,align:"center",key:String(O+1),render:(F,U)=>{const N=U?.monthly_data?.[O]?.[0]?.data?.[0]??{},Y=N?.intime??"",z=N?.outtime??"",E=N?.attendance_type??"";return e.jsx(n.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",Y]}),e.jsxs("div",{children:["Out Time ",z]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:et(E)})})}})}),B.push({title:"Total",key:"Total",render:(P,O)=>{const F=O?.monthly_data??[],U=F.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="A").length,N=F.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",U," P : ",N]})})}})),B},[p]),D=r.useMemo(()=>[{label:"Present",el:et("P")},{label:"Absent",el:et("A")},{label:"Leave",el:et("L")},{label:"Weekly Off",el:et("W")},{label:"Holiday",el:et("H")}],[]),k=r.useMemo(()=>d.month?o.find(B=>B?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),L=async B=>{if(B.preventDefault(),!d.role||!d.year||!d.month)return;x(1),j(!0),C([]);const b={session:A,year:d.year,month:d.month,day:"01",role:d.role};_(b),R(!0),await f?.(b)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{className:"d-print-none",title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:B=>c(b=>({...b,role:B?.value??"",rolllabel:B?.label??""}))}),e.jsx(Q,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:B=>{const b=rr(B?.value);l(b),i(P=>!P),c(P=>({...P,year:B?.label??""}))}}),e.jsx(Q,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:B=>c(b=>({...b,month:B?.value??""}))},`month-${s}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),e.jsxs("div",{style:{border:"1px solid #ddd",borderRadius:8,padding:16,marginBottom:24,backgroundColor:"#f8f9fa"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:6},children:"Staff Attendance Summary"}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:10,fontSize:13},children:[e.jsxs("div",{children:["Role: ",e.jsx("span",{style:{fontWeight:700},children:d.rolllabel||"--"})]}),e.jsxs("div",{children:["Year: ",e.jsx("span",{style:{fontWeight:700},children:d.year||"--"})]}),e.jsxs("div",{children:["Month: ",e.jsx("span",{style:{fontWeight:700},children:k})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(wt,{data:{tableRef:a}})})]}),e.jsx("div",{style:{marginTop:14,paddingTop:14,borderTop:"1px solid #e0e0e0"},children:e.jsx("div",{style:{display:"flex",justifyContent:"center",flexWrap:"wrap",gap:12,fontSize:12},children:D.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(n.Skeleton,{active:!0,loading:m,paragraph:{rows:10},children:e.jsx(n.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:g,dataSource:p,pagination:!1,scroll:{x:"max-content"},rowKey:(B,b)=>String(B?.staff_id??B?.id??b)})})]})})]})}const zh=({token:t})=>e.jsx(qh,{token:t}),Mi=Ie.payroll,Yh=Ie.roleDropdown,Vh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Wh=t=>t?.data?.data??t?.data??t??[];function Hh({token:t,receiptDetailsPath:a="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:s}){const[i,o]=r.useState({page:1,rowsPerPage:10}),[l,d]=r.useState(!1),[c,y]=r.useState([]),[h,u]=r.useState({role:"",roleLabel:"",year:"",month:""}),[p,C]=r.useState(null),S=g=>{if(!g)return;if(typeof s=="function"){s(g);return}const D=`${a}?id=${encodeURIComponent(String(g))}`;typeof window<"u"&&window?.location&&(window.location.href=D)},{data:x}=W(t?[Yh,t]:null,([g,D])=>K(g,D)),m=r.useMemo(()=>Vh(x),[x]),j=r.useMemo(()=>sr(5),[]),{isLoading:T,error:R,data:I}=W(t&&p?[p,t]:null,([g,D])=>K(g,D)),_=r.useMemo(()=>{const g=Wh(I);return Array.isArray(g)?g:[]},[I]),A=r.useMemo(()=>{const g=I?.pagination?.total_rows??I?.data?.pagination?.total_rows??I?.total??I?.total_rows,D=Number(g);return Number.isFinite(D)&&D>=0?D:_.length},[I,_.length]),f=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(g,D,k)=>k+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:(g,D)=>{const k=D?.id??D?.staff_id??D?.staffId;return e.jsx(n.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{S(k)},children:Qo(D?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:g=>{if(g.preventDefault(),!h.role||!h.year||!h.month)return;const D=`${Mi.payrollByRole}?page=${encodeURIComponent(String(i.page))}&per_page=${encodeURIComponent(String(i.rowsPerPage))}&role=${encodeURIComponent(String(h.role))}&year=${encodeURIComponent(String(h.year))}&month=${encodeURIComponent(String(h.month))}`;C(D)},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",marginBottom:14,padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsx(Q,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:g=>u(D=>({...D,role:g?.value??"",roleLabel:g?.label??""}))}),e.jsx(Q,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:g=>{const D=rr(g?.value);y(D),d(k=>!k),u(k=>({...k,year:g?.label??"",month:""}))}}),e.jsx(Q,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:g=>u(D=>({...D,month:g?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary",onClick:()=>o(g=>({...g,page:1}))})})]})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:T,rowKey:(g,D)=>String(g?.id??g?.staff_id??D),columns:f,dataSource:_,pagination:{current:i.page,pageSize:i.rowsPerPage,total:A,showSizeChanger:!0,onChange:(g,D)=>{o({page:g,rowsPerPage:D}),!(!h.role||!h.year||!h.month)&&C(`${Mi.payrollByRole}?page=${encodeURIComponent(String(g))}&per_page=${encodeURIComponent(String(D))}&role=${encodeURIComponent(String(h.role))}&year=${encodeURIComponent(String(h.year))}&month=${encodeURIComponent(String(h.month))}`)}},scroll:{x:"max-content"}})]})})}const Kh=({token:t})=>e.jsx(Hh,{token:t}),sl=Ie.leave,wa=({baseUrl:t,page:a=1,perPage:s=10,token:i})=>W(i&&t?[t,a,s,i]:null,([l,d,c,y])=>dh({baseUrl:l,page:d,perPage:c},y)),Gh=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:sl.requestTable,page:a,perPage:s}),Jh=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Qh=(t,a)=>{const s=new FormData;return Object.entries(t??{}).forEach(([i,o])=>{o!=null&&s.append(i,String(o))}),s.set("status",a),s};function Xh({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),{isLoading:i,error:o,data:l,mutate:d}=Gh({token:t,page:a.page,perPage:a.rowsPerPage}),c=r.useMemo(()=>Jh(l),[l]),y=async(u,p)=>{try{const C=Qh(u,p),S=await zt(sl.approveRequest,C,t);S?.Status==="Success"?w.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):w.error(S?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(C){w.error(C?.response?.data?.msg??C?.message??"Failed to update request.",{duration:1e3})}},h=r.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,p)=>p?.full_name??p?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,p)=>p?.leave_from??p?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,p)=>p?.leave_to??p?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,p)=>p?.leavetype??p?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,p)=>p?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,p)=>p?.employee_remark??p?.reason??""},{title:"View",key:"document_file",width:140,render:(u,p)=>{const C=p?.document_file;return C?e.jsx(n.Button,{size:"small",onClick:()=>window.open(C,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,p)=>{const C=String(p?.status??"").toLowerCase();return C==="approved"?e.jsx(n.Tag,{color:"green",children:"Approved"}):C==="declined"?e.jsx(n.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(n.Button,{type:"text",size:"small",onClick:()=>y(p,"approved"),icon:e.jsx(te.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(n.Button,{type:"text",size:"small",onClick:()=>y(p,"declined"),icon:e.jsx(te.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:i,rowKey:(u,p)=>String(u?.id??u?.leave_id??p),columns:h,dataSource:c,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(u,p)=>s({page:u,rowsPerPage:p}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Zh=({token:t})=>e.jsx(Xh,{token:t}),ef=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",tf=({token:t,value:a,onChange:s})=>{const i=r.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:nl(),headers:i,onChange:o=>{if(o?.file?.status==="done"){const l=ef(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},rl=Ie.leave,af=Ie.master.leaveType.dropdown,nf=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:rl.table,page:a,perPage:s}),sf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Is={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function rf({token:t,userType:a}){const[s,i]=r.useState({page:1,rowsPerPage:10}),[o,l]=r.useState(!1),[d,c]=r.useState(""),[y]=n.Form.useForm();console.log("ApplyLeavePage render",a);const{isLoading:h,error:u,data:p,mutate:C}=nf({token:t,page:s.page,perPage:s.rowsPerPage}),{data:S}=W(t?[af,t]:null,([f,g])=>K(f,g)),x=r.useMemo(()=>sf(S),[S]),m=(f,g)=>i({page:f,rowsPerPage:parseInt(g,10)}),j=()=>{c(""),y.resetFields(),y.setFieldsValue({apply_date:ae()}),l(!0)},T=()=>{l(!1),c(""),y.resetFields()},R=async f=>{const g=new FormData;g.set("apply_date",f?.apply_date?f.apply_date.format("YYYY-MM-DD"):""),g.set("leave_type",f?.leave_type?.value??f?.leave_type??""),g.set("from_date",f?.from_date?f.from_date.format("YYYY-MM-DD"):""),g.set("to_date",f?.to_date?f.to_date.format("YYYY-MM-DD"):""),g.set("reason",f?.reason??""),d&&g.set("file",d);try{await Rt(rl.apply,g,t),w.success("Success! Leave request submitted.",{duration:1e3}),T(),await C()}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed to submit leave request.",{duration:1e3})}},I=r.useMemo(()=>{const f=p?.data??p??[];return Array.isArray(f)?f:Array.isArray(f?.data)?f.data:[]},[p]),_=r.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(f,g)=>g?.leavetype??g?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(f,g)=>g?.date??g?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(f,g)=>g?.leave_from??g?.from_date??""},{title:"To",key:"leave_to",width:130,render:(f,g)=>g?.leave_to??g?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(f,g)=>g?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]),A=a==="staff";return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:o,title:"Add Leave Request",onCancel:T,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:y,layout:"vertical",onFinish:R,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,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.Form.Item,{name:"apply_date",rules:[{required:!0,message:"Select date"}],style:{marginBottom:0},children:e.jsx(n.DatePicker,{style:Is})})]}),e.jsx(n.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From"}),e.jsx(n.Form.Item,{name:"from_date",rules:[{required:!0,message:"Select from date"}],style:{marginBottom:0},children:e.jsx(n.DatePicker,{style:Is})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To"}),e.jsx(n.Form.Item,{name:"to_date",rules:[{required:!0,message:"Select to date"}],style:{marginBottom:0},children:e.jsx(n.DatePicker,{style:Is})})]}),e.jsx(n.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(V,{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(tf,{token:t,value:d,onChange:c})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(n.Button,{onClick:T,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})]})}),A&&e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(ne,{type:"button",value:"Add Leave Request",onClick:j})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:h,rowKey:(f,g)=>String(f?.id??f?.leave_id??g),columns:_,dataSource:I,pagination:{current:s.page,pageSize:s.rowsPerPage,onChange:(f,g)=>m(f,g),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const of=({token:t,userType:a})=>e.jsx(rf,{token:t,userType:a}),Nn=Ie.master.leaveType,lf=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:Nn.table,page:a,perPage:s});function df({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState(!1),[c,y]=r.useState(null),{isLoading:h,error:u,data:p,mutate:C}=lf({token:t,page:a.page,perPage:a.rowsPerPage}),S=(_,A)=>{s({page:_,rowsPerPage:parseInt(A,10)})},x=async _=>{const A=new FormData;A.set("title",_?.title??"");try{await C(Rt(Nn.add,A,t),ze(A)),w.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),i.resetFields()}catch(f){w.error(f?.response?.data?.msg??f?.message??"Failed to add leave type.",{duration:1e3})}},m=_=>{y(_??null),o.setFieldsValue({title:_?.leave_type_name??_?.name??""}),d(!0)},j=()=>{d(!1),y(null),o.resetFields()},T=async _=>{const A=c?.id??c?.leave_type_id;if(!A){w.error("Missing leave type id.",{duration:1e3});return}const f=new FormData;f.set("id",String(A)),f.set("title",_?.title??"");try{await zt(Nn.edit,f,t),await C(),w.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),j()}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to update leave type.",{duration:1e3})}},R=async _=>{const A=_?.id??_?.leave_type_id;if(A)try{await C(nn(Nn.remove,A,t),Ne(A)),w.success("Success! Deleted leave type.",{duration:1e3})}catch(f){w.error(f?.response?.data?.msg??f?.message??"Failed to delete leave type.",{duration:1e3})}},I=r.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(_,A)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(A)}),e.jsx(n.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>R(A),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Leave Type",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(n.Form,{form:i,layout:"vertical",onFinish:x,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Te,{parentCallback:S,data:{newData:p,columns:I,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const cf=({token:t})=>e.jsx(df,{token:t}),Ln=Ie.master.department,uf=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:Ln.table,page:a,perPage:s});function pf({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState(!1),[c,y]=r.useState(null),{isLoading:h,error:u,data:p,mutate:C}=uf({token:t,page:a.page,perPage:a.rowsPerPage}),S=(_,A)=>{s({page:_,rowsPerPage:parseInt(A,10)})},x=async _=>{const A=new FormData;A.set("title",_?.title??"");try{await C(Rt(Ln.add,A,t),ze(A)),w.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),i.resetFields()}catch(f){w.error(f?.response?.data?.msg??f?.message??"Failed to add department.",{duration:1e3})}},m=_=>{y(_??null),o.setFieldsValue({title:_?.department_name??_?.name??""}),d(!0)},j=()=>{d(!1),y(null),o.resetFields()},T=async _=>{const A=c?.id??c?.department_id;if(!A){w.error("Missing department id.",{duration:1e3});return}const f=new FormData;f.set("id",String(A)),f.set("title",_?.title??"");try{await zt(Ln.edit,f,t),await C(),w.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),j()}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to update department.",{duration:1e3})}},R=async _=>{const A=_?.id??_?.department_id;if(A)try{await C(nn(Ln.remove,A,t),Ne(A)),w.success("Success! Deleted department.",{duration:1e3})}catch(f){w.error(f?.response?.data?.msg??f?.message??"Failed to delete department.",{duration:1e3})}},I=r.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(_,A)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(A)}),e.jsx(n.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>R(A),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Department",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(n.Form,{form:i,layout:"vertical",onFinish:x,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Te,{parentCallback:S,data:{newData:p,columns:I,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const mf=({token:t})=>e.jsx(pf,{token:t}),Bn=Ie.master.designation,hf=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:Bn.table,page:a,perPage:s});function ff({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState(!1),[c,y]=r.useState(null),{isLoading:h,error:u,data:p,mutate:C}=hf({token:t,page:a.page,perPage:a.rowsPerPage}),S=(_,A)=>{s({page:_,rowsPerPage:parseInt(A,10)})},x=async _=>{const A=new FormData;A.set("title",_?.title??"");try{await C(Rt(Bn.add,A,t),ze(A)),w.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),i.resetFields()}catch(f){w.error(f?.response?.data?.msg??f?.message??"Failed to add designation.",{duration:1e3})}},m=_=>{y(_??null),o.setFieldsValue({title:_?.designation??""}),d(!0)},j=()=>{d(!1),y(null),o.resetFields()},T=async _=>{const A=c?.id??c?.designation_id;if(!A){w.error("Missing designation id.",{duration:1e3});return}const f=new FormData;f.set("id",String(A)),f.set("title",_?.title??"");try{await zt(Bn.edit,f,t),await C(),w.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),j()}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to update designation.",{duration:1e3})}},R=async _=>{const A=_?.id??_?.designation_id;if(A)try{await C(nn(Bn.remove,A,t),Ne(A)),w.success("Success! Deleted designation.",{duration:1e3})}catch(f){w.error(f?.response?.data?.msg??f?.message??"Failed to delete designation.",{duration:1e3})}},I=r.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(_,A)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(A)}),e.jsx(n.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>R(A),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Designation",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(n.Form,{form:i,layout:"vertical",onFinish:x,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Te,{parentCallback:S,data:{newData:p,columns:I,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const yf=({token:t})=>e.jsx(ff,{token:t}),qn=Ie.master.shift,gf=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:qn.table,page:a,perPage:s}),ct="hh:mm A",da=t=>{const a=String(t??"");if(!a)return null;const s=ae(a,[ct,"HH:mm","HH:mm:ss"],!0);return s.isValid()?s:null},ca=t=>t?t.format(ct):"",St={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function xf({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState(!1),[c,y]=r.useState(null),{isLoading:h,error:u,data:p,mutate:C}=gf({token:t,page:a.page,perPage:a.rowsPerPage}),S=(f,g)=>{s({page:f,rowsPerPage:parseInt(g,10)})},x=(f,g)=>{const D=new FormData;return g&&D.set("id",String(g)),D.set("name",f?.name??""),D.set("start_time",ca(f?.start_time)),D.set("end_time",ca(f?.end_time)),D.set("shift_start_from",ca(f?.shift_start_from)),D.set("shift_start_to",ca(f?.shift_start_to)),D.set("shift_end_from",ca(f?.shift_end_from)),D.set("shift_end_to",ca(f?.shift_end_to)),D},m=async f=>{try{const g=x(f);await C(Rt(qn.add,g,t),ze(g)),w.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),i.resetFields()}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to add shift.",{duration:1e3})}},j=f=>{y(f??null),o.setFieldsValue({name:f?.shift_name??f?.name??"",start_time:da(f?.start_time),end_time:da(f?.end_time),shift_start_from:da(f?.shift_start_from),shift_start_to:da(f?.shift_start_to),shift_end_from:da(f?.shift_end_from),shift_end_to:da(f?.shift_end_to)}),d(!0)},T=()=>{d(!1),y(null),o.resetFields()},R=async f=>{const g=c?.id??c?.shift_id;if(!g){w.error("Missing shift id.",{duration:1e3});return}try{const D=x(f,g);await zt(qn.edit,D,t),await C(),w.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),T()}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed to update shift.",{duration:1e3})}},I=async f=>{const g=f?.id??f?.shift_id;if(g)try{await C(nn(qn.remove,g,t),Ne(g)),w.success("Success! Deleted shift.",{duration:1e3})}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed to delete shift.",{duration:1e3})}},_=r.useMemo(()=>[{title:"Name",dataIndex:"shift_name",key:"shift_name",ellipsis:!0,fixed:"left",width:160},{title:"Start Time",dataIndex:"start_time",key:"start_time",width:120},{title:"End Time",dataIndex:"end_time",key:"end_time",width:120},{title:"Start From",dataIndex:"shift_start_from",key:"shift_start_from",width:120,responsive:["md"]},{title:"Start To",dataIndex:"shift_start_to",key:"shift_start_to",width:120,responsive:["md"]},{title:"End From",dataIndex:"shift_end_from",key:"shift_end_from",width:120,responsive:["md"]},{title:"End To",dataIndex:"shift_end_to",key:"shift_end_to",width:120,responsive:["md"]},{title:"Action",key:"action",width:110,fixed:"right",render:(f,g)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>j(g)}),e.jsx(n.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]),A=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Shift",onCancel:T,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:R,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:A,children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:A,children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:T,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(n.Form,{form:i,layout:"vertical",onFinish:m,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:A,children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:A,children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Te,{parentCallback:S,data:{newData:p,columns:_,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const bf=({token:t})=>e.jsx(xf,{token:t}),jf=Ie.attendance;function Sf({data:t}){return t?e.jsx("div",{style:{margin:15,fontSize:13,padding:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{}),(t?.shifts??[]).map((a,s)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:a?.shift_name??""},`${s}heading1`))]}),e.jsxs("tr",{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Sl.No"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Teacher's Name"}),(t?.shifts??[]).map((a,s)=>e.jsxs(r.Fragment,{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"In Time"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Out Time"})]},`${s}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((a,s)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:s+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${a?.name??""} ${a?.surname??""}`.trim()})}),(t?.shifts??[]).map((i,o)=>e.jsxs(r.Fragment,{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[i?.office_shift_id]?.checkintime??"").toUpperCase():""})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[i?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${s}`))]},`${s}row`))})]})}):null}const wf=t=>{const a=t?.data??t??{},s=a?.items??a?.data??[];return Array.isArray(s)?s:[]},vf=t=>{const a=String(t??"").toLowerCase();return a==="present"?e.jsx(n.Tag,{color:"green",children:"Present"}):a==="absent"?e.jsx(n.Tag,{color:"red",children:"Absent"}):a==="leave"?e.jsx(n.Tag,{color:"orange",children:"Leave"}):e.jsx(n.Tag,{children:t??""})};function _f({token:t}){const[a,s]=r.useState(ae()),[i,o]=r.useState(!1),[l,d]=r.useState(0),c=r.useMemo(()=>`${jf.dailyAttendance}?attendance_date=${encodeURIComponent(a.format("YYYY-MM-DD"))}`,[a,i,l]),{isLoading:y,error:h,data:u}=W(t?[c,t]:null,([m,j])=>K(m,j)),p=r.useMemo(()=>wf(u),[u]),C=r.useMemo(()=>i?u?.data?.data??u?.data??u??null:null,[u,i]),S=xa.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),x=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(m,j,T)=>T+1},{title:"Name",key:"name",render:(m,j)=>j?.staff_name??"",ellipsis:!0},{title:"Department",dataIndex:"department",key:"department",ellipsis:!0,responsive:["md"]},{title:"Designation",dataIndex:"designation",key:"designation",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(m,j)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[vf(j?.attendance_status),j?.is_week_off?e.jsx(n.Tag,{color:"blue",children:"W/O"}):null]})},{title:"In Time",key:"intime",width:120,render:(m,j)=>j?.check_in??""},{title:"Out Time",key:"outtime",width:120,render:(m,j)=>j?.check_out??""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Daily Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:a,onChange:m=>m&&s(m),style:{width:"100%"},allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",onClick:()=>d(m=>m+1)})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(te.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:S}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),i?e.jsx(Sf,{data:C}):e.jsx(n.Table,{bordered:!0,size:"small",loading:y,rowKey:(m,j)=>String(m?.id??m?.staff_id??j),columns:x,dataSource:p,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const Cf=({token:t})=>e.jsx(_f,{token:t}),Ei=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Af=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 Df({token:t,staffId:a}){const[s,i]=r.useState(!1),[o,l]=r.useState(null),[d,c]=r.useState({value:"Cash",label:"Cash"}),[y,h]=r.useState(""),[u,p]=r.useState(""),C=r.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),S=k=>{const L=Number(k??0),B=Number.isFinite(L)?L.toLocaleString("en-IN"):"0";return`${C?`${C} `:""}${B}`},x=r.useMemo(()=>a?`${Ie.staff.basicById}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),m=r.useMemo(()=>a?`${Ie.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),{data:j}=W(t&&x?[x,t]:null,([k,L])=>K(k,L)),{data:T,isLoading:R,mutate:I}=W(t&&m?[m,t]:null,([k,L])=>K(k,L)),_=r.useMemo(()=>Ei(j)[0]??j?.data??j??null,[j]),A=r.useMemo(()=>Ei(T),[T]),f=r.useMemo(()=>[{title:"Month",dataIndex:"month",key:"month",width:120,align:"center"},{title:"Basic Salary",dataIndex:"basic_salary",key:"basic_salary",width:140,align:"center",render:(k,L)=>e.jsx("div",{style:{fontSize:11},children:Tt(L?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(k,L)=>e.jsx("div",{style:{fontSize:11},children:Tt(L?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(k,L)=>e.jsx("div",{style:{fontSize:11},children:Tt(L?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(k,L)=>e.jsx("div",{style:{fontSize:11},children:Tt(L?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(k,L)=>e.jsx("div",{style:{cursor:L?.status==="due"?"pointer":"default"},onClick:()=>{L?.status==="due"&&(l(L),i(!0))},children:Qo(L?.status)})}],[]),g=r.useMemo(()=>[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"DD",label:"DD"},{value:"Bank",label:"Bank"},{value:"Internet Banking",label:"Internet Banking"},{value:"Cheque",label:"Cheque"}],[]),D=async()=>{if(!o)return;const k={...o,staff_id:a,payment_type:d?.value??"",notes:y,attchement:u};try{await Ee(Ie.payroll.generatePayslip,{arg:k},t),w.success("Success!",{duration:1e3}),i(!1),l(null),h(""),p(""),await I()}catch(L){w.error(L?.response?.data?.msg??L?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("div",{style:{fontSize:13,color:"#444"},children:_?`${_?.f_name??_?.firstname??""} ${_?.l_name??_?.lastname??""}`.trim():""}),e.jsx(n.Table,{bordered:!0,size:"small",loading:R,rowKey:(k,L)=>String(k?.id??`${k?.month}-${L}`),columns:f,dataSource:A,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(n.Modal,{open:s,onCancel:()=>{i(!1),l(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{label:"Pay",options:g,value:d,onChange:k=>c(k??g[0]),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Note"}),e.jsx(n.Input.TextArea,{rows:4,placeholder:"Note",value:y,onChange:k=>h(k.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(n.Upload,{maxCount:1,action:nl(),headers:t?{Authorization:t}:void 0,onChange:k=>{if(k?.file?.status==="done"){const L=Af(k?.file?.response);L&&p(L)}k?.file?.status==="removed"&&p("")},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),children:"Upload"})}),!!u&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:u})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:()=>i(!1),children:"Cancel"}),e.jsx(ne,{type:"button",value:o?.Total_Payable_Amount?`Pay ${S(o.Total_Payable_Amount)}`:"Pay",onClick:D})]})]})})]})}function Tf({token:t,staffId:a}){const s=r.useMemo(()=>{if(a!=null&&String(a).trim()!=="")return a;if(typeof window>"u")return null;const i=new URLSearchParams(window.location.search).get("id");return i||null},[a]);return s?e.jsx(Df,{token:t,staffId:s}):e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsx("div",{style:{fontSize:13,color:"#666"},children:"Missing staff id."})})}function Yt({onAdd:t,onExport:a,onPrint:s,onDownload:i,onFilter:o,onRefresh:l,actions:d}){const c=r.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(te.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(te.FileExcelOutlined,{}),onClick:a},{key:"print",title:"Print",icon:e.jsx(te.PrinterOutlined,{}),onClick:s},{key:"download",title:"Download",icon:e.jsx(te.DownloadOutlined,{}),onClick:i},{key:"filter",title:"Filter",icon:e.jsx(te.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(te.ReloadOutlined,{}),onClick:l}],[t,a,s,i,o,l]),y=r.useMemo(()=>{const h=Array.isArray(d)&&d.length?new Set(d):null;return h?c.filter(u=>h.has(u.key)):c},[c,d]);return e.jsx(n.Space,{size:8,children:y.map(h=>e.jsx(n.Tooltip,{title:h.title,children:e.jsx(n.Button,{type:"text",icon:h.icon,onClick:h.onClick,disabled:!h.onClick})},h.key))})}const lr=t=>t??localStorage.getItem("authToken")??"",Pt={dashboard:{monthlyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentmonthlyReportgraph",weeklyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentweeklyReportgraph"},dropdowns:{classes:"api/branchapi/academy/classdropdownlist",sectionsByClass:"api/branchapi/academy/sectionoftheClass",sessions:"api/branchapi/generalSettings/sessiondropdown"},studentAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass",save:"api/studentAttendace/addattendencebyBranch",emergencyLeave:"api/StudentAttendace/emergency_leave"},dailyAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass"},monthlyReport:{table:"api/branchapi/student/studentmonthlyAttendence",byStudent:"api/branchapi/student/getStududentMonthlyByIdUrlnew"},yearlyReport:{table:"api/branchapi/student/studentyearlyAttendenceReport"}},Nt=async(t,a)=>K(t,lr(a)),Rf=async(t,a,s)=>Ee(t,a,lr(s)),If=async(t,a,s)=>Ya(t,{arg:a},lr(s)),Va=(t,a)=>{const s=new URLSearchParams;Object.entries(a??{}).forEach(([o,l])=>{l==null||l===""||s.set(o,String(l))});const i=t.includes("?")?"&":"?";return`${t}${i}${s.toString()}`},Fi=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},kf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},il=(t,a)=>{const s=t?.data?.data??t?.data??t??{},i=a?s?.[a]:s;return Array.isArray(i)?i:Array.isArray(s?.student)?s.student:Array.isArray(s?.staff)?s.staff:Array.isArray(s?.data)?s.data:[]},Pf=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],Of=t=>{const a={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(s=>{if(Array.isArray(s?.monthly_data)||Array.isArray(s?.month_data)){Pf(s).forEach(o=>{const l=o?.[0]?.data?.[0]??o?.data?.[0]??o??{},d=String(l?.attendance_type??l?.attendence_type_id??"").toUpperCase();(d==="P"||d==="1")&&(a.present+=1),(d==="A"||d==="4")&&(a.absent+=1),(d==="L"||d==="3")&&(a.late+=1),(d==="LEAVE"||d==="2")&&(a.leave+=1)});return}const i=String(s?.attendance_type??s?.attendence_type_id??"").toUpperCase();(i==="P"||i==="1")&&(a.present+=1),(i==="A"||i==="4")&&(a.absent+=1),(i==="L"||i==="3")&&(a.late+=1),(i==="LEAVE"||i==="2")&&(a.leave+=1)}),a},dr=(t,a)=>{const{data:s,isLoading:i,error:o}=W(a&&t?[t,a]:null,([l,d])=>Nt(l,d));return{isLoading:i,error:o,data:s,options:r.useMemo(()=>kf(s),[s])}},ss=t=>dr(Pt.dropdowns.classes,t),rs=(t,a)=>{const s=t?`${Pt.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return dr(s,a)},Mf=t=>dr(Pt.dropdowns.sessions,t),cr=t=>{const a=String(t??"").toUpperCase();return et(a==="1"||a==="P"||a==="PRESENT"?"P":a==="4"||a==="A"||a==="ABSENT"?"A":a==="3"||a==="L"||a==="LATE"?"L":a==="2"||a==="LEAVE"?"LEAVE":a==="W"?"W":a==="H"?"H":a||"-")},ol=(t,a,s)=>{const i=new Blob([t],{type:a}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download=s,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},Ui=t=>String(t??"").replace(/"/g,'""'),Ef=({rows:t,columns:a,fileName:s})=>{const i=Array.isArray(a)?a:[],o=Array.isArray(t)?t:[],l=i.map(c=>`"${Ui(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,y)=>i.map(h=>{const u=h?.dataIndex??h?.selector??h?.key,p=u==="sl"?y+1:c?.[u];return`"${Ui(p)}"`}).join(",")).join(`
61
- `);ol([l,d].filter(Boolean).join(`
62
- `),"text/csv;charset=utf-8;",s)},Ff=({value:t,fileName:a})=>{ol(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",a)};function ll({summary:t}){const a=[{key:"present",label:"Present",color:"#52c41a"},{key:"absent",label:"Absent",color:"#ff4d4f"},{key:"late",label:"Late",color:"#fa8c16"},{key:"leave",label:"Leave",color:"#1677ff"}];return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:16},children:a.map(s=>e.jsxs(n.Card,{size:"small",styles:{body:{padding:16}},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:8},children:s.label}),e.jsx("div",{style:{fontSize:24,fontWeight:700,color:s.color},children:t?.[s.key]??0})]},s.key))})}function ga({summary:t,title:a="Attendance Overview"}){const s=r.useMemo(()=>[{key:"present",label:"Present",value:Number(t?.present??0),color:"#52c41a"},{key:"absent",label:"Absent",value:Number(t?.absent??0),color:"#ff4d4f"},{key:"late",label:"Late",value:Number(t?.late??0),color:"#fa8c16"},{key:"leave",label:"Leave",value:Number(t?.leave??0),color:"#1677ff"}],[t]),i=Math.max(...s.map(o=>o.value),1);return e.jsx(n.Card,{size:"small",title:a,children:e.jsx("div",{style:{display:"grid",gap:12},children:s.map(o=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr 50px",gap:12,alignItems:"center"},children:[e.jsx("div",{style:{fontSize:12,color:"#444"},children:o.label}),e.jsx("div",{style:{height:12,background:"#f0f0f0",borderRadius:999},children:e.jsx("div",{style:{width:`${o.value/i*100}%`,height:"100%",background:o.color,borderRadius:999}})}),e.jsx("div",{style:{fontSize:12,fontWeight:600,textAlign:"right"},children:o.value})]},o.key))})})}function Uf(){const t=[{label:"Present",node:et("P")},{label:"Absent",node:et("A")},{label:"Late",node:et("L")},{label:"Weekly Off",node:et("W")},{label:"Holiday",node:et("H")}];return e.jsx(n.Space,{wrap:!0,size:[12,8],children:t.map(a=>e.jsxs(n.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:a.label}),a.node]},a.label))})}function Lt({items:t}){const a=Array.isArray(t)?t.filter(s=>s?.value):[];return a.length?e.jsx(n.Space,{wrap:!0,size:[8,8],children:a.map(s=>e.jsxs(n.Tag,{color:"blue",children:[s.label,": ",s.value]},s.label))}):null}function is({title:t,subtitle:a,printRef:s,exportRows:i,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:y,chartContent:h,reportTitle:u,reportExtra:p,children:C,fileBaseName:S="attendance"}){const x=xa.useReactToPrint({content:()=>s?.current});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsxs("div",{children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:t}),a?e.jsx(n.Typography.Text,{type:"secondary",style:{display:"block",marginTop:4},children:a}):null]}),extra:e.jsx(Yt,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>Ef({rows:i,columns:o,fileName:`${S}.csv`}),onPrint:x,onDownload:()=>Ff({value:i,fileName:`${S}.json`}),onRefresh:l}),children:c}),e.jsx(ll,{summary:y}),h===!1?null:h||e.jsx(ga,{summary:y}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u}),extra:p,children:C})]})}const $f=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function Nf({rows:t,loading:a,sunday:s,holiday:i,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(h,u)=>{const p=(Array.isArray(t)?t:[]).map((C,S)=>(C?.student_session_id??C?.student_id??C?.id??S)===h?{...C,...u}:C);l?.(p)},y=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(h,u,p)=>p+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(h,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(h,u,p)=>{const C=u?.student_session_id??u?.student_id??u?.id??p;return e.jsx(n.Select,{size:"small",style:{width:"100%"},options:$f,value:String(h??"1"),onChange:S=>c(C,{attendence_type_id:S})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:h=>h?ae(h).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120},{title:"Emergency Leave",key:"emergency_leave",width:140,render:(h,u)=>e.jsx(n.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(te.ClockCircleOutlined,{}),onClick:()=>d?.(u),children:"E.L"})}],[d,t]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):i?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(h,u)=>String(h?.student_session_id??h?.student_id??h?.id??u),columns:y,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function Lf({rows:t,loading:a,sunday:s,holiday:i,holidayTitle:o}){const l=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,y)=>y+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(d,c)=>c?.full_name??c?.student_name??c?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:120,render:d=>cr(d)},{title:"Date",dataIndex:"date",key:"date",width:120,render:d=>d?ae(d).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120}],[]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):i?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(d,c)=>String(d?.student_session_id??d?.student_id??d?.id??c),columns:l,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function Bf({data:t,loading:a,onViewStudent:s}){const i=t?.data??t??{},o=Array.isArray(i?.studentAttendance)?i.studentAttendance:Array.isArray(i)?i:[],l=Array.isArray(i?.monthly_holiday)?i.monthly_holiday:[],d=Array.isArray(i?.dateSun)?i.dateSun:[],c=Number(i?.totalDaysMonth??0),y=r.useMemo(()=>{const h=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,p)=>e.jsx(n.Button,{type:"link",style:{padding:0},onClick:()=>s?.(p),children:p?.student_name??p?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{h.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(p,C)=>{const x=C?.[`${C?.student_id}_${o.indexOf(C)}`]?.[u]??{},m=x?.attendance_date,j=l.find(T=>T?.date===m);return d.includes(m)?Hr("sunday","W"):j?Hr("holiday","H"):cr(x?.attendence_type_id)}})}),h.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,p)=>{let C=0,S=0,x=0;return[...new Array(c).keys()].forEach(m=>{const j=p?.[`${p?.student_id}_${o.indexOf(p)}`]?.[m]??{},T=String(j?.attendence_type_id??"");T==="1"&&(C+=1),T==="4"&&(S+=1),T==="3"&&(x+=1)}),e.jsxs("span",{children:["P: ",C," A: ",S," L: ",x]})}}),h},[l,s,o,d,c]);return e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(h,u)=>String(h?.student_id??u),columns:y,dataSource:o,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(n.Empty,{description:"No monthly report found"})}})}function qf({open:t,onClose:a,loading:s,data:i,studentName:o}){const l=Array.isArray(i?.data?.report)?i.data.report:[],d=[{title:"Date",dataIndex:"attendance_date",key:"attendance_date",render:c=>c?ae(c).format("DD-MM-YYYY"):"--"},{title:"Status",key:"status",render:(c,y)=>cr(y?.attendence_type_id??y?.attendance_type)},{title:"In Time",dataIndex:"intime",key:"intime"},{title:"Out Time",dataIndex:"outtime",key:"outtime"},{title:"Remark",dataIndex:"remark",key:"remark"}];return e.jsx(n.Modal,{open:t,onCancel:a,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(c,y)=>String(c?.attendance_date??y),columns:d,dataSource:l,loading:s,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function zf({open:t,onClose:a,onSubmit:s,loading:i}){const[o,l]=n.Modal.useModal(),[d,c]=r.useState(null),[y,h]=r.useState(""),u=async()=>{if(!d){await o.warning({title:"Select time"});return}await s?.({outtime:d.format("h:mm a"),message:y}),c(null),h("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(n.Modal,{title:"Emergency Leave",open:t,onCancel:a,onOk:u,confirmLoading:i,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Select Time"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:d,onChange:c,style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Purpose"}),e.jsx(n.Input.TextArea,{rows:4,value:y,onChange:p=>h(p.target.value)})]})]})})]})}const dl=t=>Of(t),$i=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.reduce((s,i)=>({present:s.present+Number(i?.present??i?.Present??i?.total_present??0),absent:s.absent+Number(i?.absent??i?.Absent??i?.total_absent??0),late:s.late+Number(i?.late??i?.Late??0),leave:s.leave+Number(i?.leave??i?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(a?.present??a?.Present??a?.total_present??0),absent:Number(a?.absent??a?.Absent??a?.total_absent??0),late:Number(a?.late??a?.Late??0),leave:Number(a?.leave??a?.Leave??0)}};function Yf({token:t}){const{data:a}=W(t?[Pt.dashboard.monthlyGraph,t]:null,([l,d])=>Nt(l,d)),{data:s}=W(t?[Pt.dashboard.weeklyGraph,t]:null,([l,d])=>Nt(l,d)),i=r.useMemo(()=>$i(a),[a]),o=r.useMemo(()=>$i(s),[s]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(n.Card,{children:[e.jsx(n.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(ll,{summary:i}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(ga,{summary:i,title:"Monthly Attendance Chart"}),e.jsx(ga,{summary:o,title:"Weekly Attendance Chart"})]})]})}const ks=Pt.studentAttendance,Vf={width:"100%",height:40};function Wf({token:t}){const a=r.useRef(null),[s,i]=r.useState(""),[o,l]=r.useState(""),[d,c]=r.useState(""),[y,h]=r.useState(""),[u,p]=r.useState(""),[C,S]=r.useState(""),[x,m]=r.useState(ae()),[j,T]=r.useState(0),[R,I]=r.useState([]),[_,A]=r.useState(!1),[f,g]=r.useState(null),[D,k]=r.useState(!1),[L,B]=r.useState(!1),b=ss(t),P=rs(s,t),O=r.useMemo(()=>!s||!d||j===0?null:Va(ks.list,{cID:s,sID:d,batch_id:u,date:x.format("YYYY-MM-DD")}),[u,s,x,j,d]),{data:F,isLoading:U,mutate:N}=W(t&&O?[O,t]:null,([G,J])=>Nt(G,J));r.useEffect(()=>{I(il(F,"student"))},[F]);const Y=F?.data?.data??F?.data??F??{},z=!!Y?.sunday,E=!!Y?.holiday?.holiday,M=Y?.holiday?.title??"",$=r.useMemo(()=>dl(R),[R]),q=r.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),H=async()=>{if(R.length)try{B(!0),await Rf(ks.save,{attendenceData:R,date:x.format("YYYY-MM-DD"),holiday:_?"YES":"NO"},t),w.success("Student attendance saved."),N?.()}catch(G){w.error(G?.message??"Failed to save attendance.")}finally{B(!1)}},re=async({outtime:G,message:J})=>{if(f?.attendence_id)try{k(!0),await If(ks.emergencyLeave,{outtime:G,message:J,id:f.attendence_id},t),w.success("Emergency leave updated."),g(null),N?.()}catch(ie){w.error(ie?.message??"Failed to update emergency leave.")}finally{k(!1)}},ee=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:b.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:G=>{i(G?.value??""),l(G?.label??""),c(""),h(""),p(""),S("")},required:!0}),e.jsx(Q,{options:P.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:G=>{c(G?.value??""),h(G?.label??""),p(""),S("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:x,onChange:G=>G&&m(G),style:Vf,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>T(G=>G+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Date",value:x.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{}),e.jsx(is,{title:"Student Attendance",printRef:a,exportRows:R,exportColumns:q,onRefresh:()=>N?.(),filterSection:ee,summary:$,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{size:"small",type:_?"primary":"default",onClick:()=>A(G=>!G),children:_?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"primary",onClick:H,loading:L,disabled:!R.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(n.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(n.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Date",value:x.format("DD-MM-YYYY")}]})})]}),e.jsx(Nf,{rows:R,loading:U,sunday:z,holiday:E,holidayTitle:M,onChangeRows:I,onEmergency:g})]})}),e.jsx(zf,{open:!!f,onClose:()=>g(null),onSubmit:re,loading:D})]})}const Hf=Pt.dailyAttendance,Kf={width:"100%",height:40};function Gf({token:t}){const a=r.useRef(null),[s,i]=r.useState(""),[o,l]=r.useState(""),[d,c]=r.useState(""),[y,h]=r.useState(""),[u,p]=r.useState(""),[C,S]=r.useState(ae()),[x,m]=r.useState(0),j=ss(t),T=rs(s,t),R=r.useMemo(()=>!s||!d||x===0?null:Va(Hf.list,{cID:s,sID:d,batch_id:u,date:C.format("YYYY-MM-DD")}),[u,s,C,x,d]),{data:I,isLoading:_,mutate:A}=W(t&&R?[R,t]:null,([O,F])=>Nt(O,F)),f=r.useMemo(()=>il(I,"student"),[I]),g=I?.data?.data??I?.data??I??{},D=!!g?.sunday,k=!!g?.holiday?.holiday,L=g?.holiday?.title??"",B=r.useMemo(()=>dl(f),[f]),b=r.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),P=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:j.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:O=>{i(O?.value??""),l(O?.label??""),c(""),h(""),p(""),setBatchLabel("")},required:!0}),e.jsx(Q,{options:T.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:O=>{c(O?.value??""),h(O?.label??""),p(""),setBatchLabel("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:C,onChange:O=>O&&S(O),style:Kf,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>m(O=>O+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Date",value:C.format("DD-MM-YYYY")}]})]});return e.jsx(is,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:a,exportRows:f,exportColumns:b,onRefresh:()=>A?.(),filterSection:P,summary:B,chartContent:e.jsx(ga,{summary:B,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Date",value:C.format("DD-MM-YYYY")}]})]}),e.jsx(Lf,{rows:f,loading:_,sunday:D,holiday:k,holidayTitle:L})]})})}const Ni=Pt.monthlyReport,Jf=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0),i={present:0,absent:0,late:0,leave:0};return a.forEach((o,l)=>{[...new Array(s).keys()].forEach(d=>{const c=o?.[`${o?.student_id}_${l}`]?.[d]??{},y=String(c?.attendence_type_id??"");y==="1"&&(i.present+=1),y==="4"&&(i.absent+=1),y==="3"&&(i.late+=1),y==="2"&&(i.leave+=1)})}),i},Qf=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0);return a.map((i,o)=>{let l=0,d=0,c=0;return[...new Array(s).keys()].forEach(y=>{const h=i?.[`${i?.student_id}_${o}`]?.[y]??{},u=String(h?.attendence_type_id??"");u==="1"&&(l+=1),u==="4"&&(d+=1),u==="3"&&(c+=1)}),{roll_no:i?.roll_no??"",student_name:i?.student_name??i?.full_name??"",present:l,absent:d,late:c}})};function Xf({token:t}){const a=r.useRef(null),[s,i]=r.useState(""),[o,l]=r.useState(""),[d,c]=r.useState(""),[y,h]=r.useState(""),[u,p]=r.useState(""),[C,S]=r.useState(""),[x,m]=r.useState(String(new Date().getFullYear())),[j,T]=r.useState(String(new Date().getMonth()+1).padStart(2,"0")),[R,I]=r.useState(0),[_,A]=r.useState(null),f=ss(t),g=rs(s,t),D=r.useMemo(()=>rr(Number(x)),[x]),k=r.useMemo(()=>sr(10),[]),L=r.useMemo(()=>!s||!d||!x||!j||R===0?null:Va(Ni.table,{session:Fi(),class_id:s,section_id:d,year:x,month:j,batch_id:u}),[u,s,j,R,d,x]),{data:B,isLoading:b,mutate:P}=W(t&&L?[L,t]:null,([$,q])=>Nt($,q)),O=B?.data?.data??B?.data??B??{},F=r.useMemo(()=>Jf(O),[O]),U=r.useMemo(()=>Qf(O),[O]),N=r.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Name",dataIndex:"student_name"},{title:"Present",dataIndex:"present"},{title:"Absent",dataIndex:"absent"},{title:"Late",dataIndex:"late"}],[]),Y=r.useMemo(()=>_?.student_id?Va(Ni.byStudent,{student_id:_.student_id,month:j,year:x,session:Fi()}):null,[j,_,x]),{data:z,isLoading:E}=W(t&&Y?[Y,t]:null,([$,q])=>Nt($,q)),M=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:f.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{i($?.value??""),l($?.label??""),c(""),h(""),p(""),S("")},required:!0}),e.jsx(Q,{options:g.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{c($?.value??""),h($?.label??""),p(""),S("")},required:!0},`section-${s}`),e.jsx(Q,{options:k,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:k.find($=>String($?.value)===String(x))??null,onChange:$=>m(String($?.value??"")),required:!0}),e.jsx(Q,{options:D,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:D.find($=>String($?.value)===String(j))??null,onChange:$=>T(String($?.value??"").padStart(2,"0")),required:!0},`month-${x}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>I($=>$+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Month",value:D.find($=>String($?.value)===String(j))?.label??j},{label:"Year",value:x}]}),e.jsx(Uf,{})]});return e.jsxs(e.Fragment,{children:[e.jsx(is,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:a,exportRows:U,exportColumns:N,onRefresh:()=>P?.(),filterSection:M,summary:F,chartContent:e.jsx(ga,{summary:F,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Month",value:D.find($=>String($?.value)===String(j))?.label??j},{label:"Year",value:x}]})]}),e.jsx(Bf,{data:O,loading:b,onViewStudent:A})]})}),e.jsx(qf,{open:!!_,onClose:()=>A(null),loading:E,data:z,studentName:_?.student_name??_?.full_name})]})}const Zf=Pt.yearlyReport,ey=t=>{const a=t?.data?.data??t?.data??t??{};return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:Array.isArray(a?.students)?a.students:Array.isArray(a?.report)?a.report:[]},ty=t=>(Array.isArray(t)?t:[]).reduce((a,s)=>({present:a.present+Number(s?.singleStudentPresentData??s?.present??0),absent:a.absent+Number(s?.singleStudentAbsentData??s?.absent??0),late:a.late+Number(s?.late??0),leave:a.leave+Number(s?.leave??0)}),{present:0,absent:0,late:0,leave:0});function ay({token:t}){const a=r.useRef(null),[s,i]=r.useState(""),[o,l]=r.useState(""),[d,c]=r.useState(""),[y,h]=r.useState(""),[u,p]=r.useState(""),[C,S]=r.useState(""),[x,m]=r.useState(""),[j,T]=r.useState(""),[R,I]=r.useState(0),_=ss(t),A=rs(s,t),f=Mf(t),g=r.useMemo(()=>!s||!d||R===0?null:Va(Zf.table,{class_id:s,section_id:d,session_id:u,batch_id:x}),[x,s,R,d,u]),{data:D,isLoading:k,mutate:L}=W(t&&g?[g,t]:null,([U,N])=>Nt(U,N)),B=r.useMemo(()=>ey(D),[D]),b=r.useMemo(()=>ty(B),[B]),P=r.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),O=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(U,N,Y)=>Y+1},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",dataIndex:"full_name",key:"full_name"},{title:"Total Present",dataIndex:"singleStudentPresentData",key:"singleStudentPresentData",width:130},{title:"Total Absent",dataIndex:"singleStudentAbsentData",key:"singleStudentAbsentData",width:130}],[]),F=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:_.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{i(U?.value??""),l(U?.label??""),c(""),h(""),m(""),T("")},required:!0}),e.jsx(Q,{options:A.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{c(U?.value??""),h(U?.label??""),m(""),T("")},required:!0},`section-${s}`),e.jsx(Q,{options:f.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{p(U?.value??""),S(U?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>I(U=>U+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Session",value:C}]})]});return e.jsx(is,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:a,exportRows:B,exportColumns:P,onRefresh:()=>L?.(),filterSection:F,summary:b,chartContent:e.jsx(ga,{summary:b,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Session",value:C}]})]}),e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(U,N)=>String(U?.student_id??U?.id??N),columns:O,dataSource:B,loading:k,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}const ny=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function sy({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),{isLoading:o,data:l}=W(s&&i?[`${Mc}?id=${i}`,s]:null,([S,x])=>K(S,x)),{data:d}=W(s?[No,s]:null,([S,x])=>K(S,x)),c=r.useMemo(()=>ny(d),[d]),y=l?.data?.[0],[h,u]=r.useState({income_head:"",name:"",invoice_no:"",date:ae(),amount:"",description:"",doc:""});r.useEffect(()=>{y&&u({income_head:y?.inc_head_id||"",name:y?.name||"",invoice_no:y?.invoice_no||"",date:y?.date?ae(y.date):ae(),amount:y?.amount||"",description:y?.note||"",doc:y?.documents||""})},[y]);const p=(S,x)=>{u(m=>({...m,[S]:x}))},C=c.find(S=>String(S.value)===String(h.income_head))??null;return o?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:S=>a(S,i),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Edit Income"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(V,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Q,{label:"Income Head",options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0,value:C,onChange:S=>p("income_head",S?.value||"")})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0,value:h.name,onChange:S=>p("name",S.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:h.invoice_no,onChange:S=>p("invoice_no",S.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:h.date,Desplay:"Date",name:"date",required:!0,onChange:S=>p("date",S)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"amount",type:"number",label:"Amount",required:!0,value:h.amount,onChange:S=>p("amount",S.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(st,{name:"description",label:"Description",rows:3,value:h.description,onChange:S=>p("description",S.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:s},maxCount:1,onChange:S=>{if(S.file.status==="removed"&&p("doc",""),S.file.status==="done"){const x=S.file.response?.data??S.file.response?.file??"";p("doc",String(x??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:h.doc?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:h.doc||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ry=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function iy({token:t}){const[a,s]=r.useState([]),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,y]=r.useState({income_head:"",name:"",invoice_no:"",date:ae().format("YYYY-MM-DD"),amount:"",description:"",doc:""}),[h,u]=r.useState(!1),[p,C]=r.useState({page:1,rowsPerPage:10}),S=(b,P)=>{C({...p,page:b,rowsPerPage:parseInt(P,10)})},x=async(b,P)=>{try{await R(Ee(b,P,t),ze(P)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},{isLoading:m,error:j,data:T,mutate:R}=W(t?[Ac,t,p.page,p.rowsPerPage]:null,([b,P,O,F])=>K(`${b}?page=${O}&per_page=${F}`,P)),I=r.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0},{id:"3",name:"Income Category",selector:"income_category",sortable:!0},{id:"4",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"5",name:"Date",selector:"date",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0},{id:"8",name:"File",selector:"documents",sortable:!1,render:b=>b?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>window.open(`${He()}/branch/frontoffice/${b}`,"_blank"),children:"View"}):"Not Uploaded"}],[]),_=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],A=async b=>{try{await R(qe(Rc,b,t),Ne(b)),w.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{w.error("Failed to delete the item.",{duration:1e3})}},f=async(b,P,O)=>{try{await R(Be(b,P,t)),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await O(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},g=async(b,P)=>{b.preventDefault();const O=new FormData(b.target);await f(Tc,O,P),k(!1)},D=async b=>{if(b.preventDefault(),!b.target.date.value)w.error("Select required dates",{duration:1e3}),b.target?.date?.focus(),d("textDanger");else{const P=new FormData(b.target);await x(Dc,P),b.target.reset(),o(""),y(O=>({...O,date:ae().format("YYYY-MM-DD")}))}},k=b=>{u(b)},{data:L}=W(t?[No,t]:null,([b,P])=>K(b,P)),B=r.useMemo(()=>ry(L),[L]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Add Income"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:D,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Income Head",options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",name:"date",status:l===""?"":"error",classnme:l,onChange:()=>d("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:t},maxCount:1,onChange:b=>{if(b.file.status==="removed"&&o(""),b.file.status==="done"){const P=b.file.response?.data??b.file.response?.file??"";o(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:i?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:i||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(st,{name:"description",label:"Description",rows:3})})}),e.jsx(n.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:S,data:{newData:T,columns:I,action:!0,Loading:m,ActionView:_,error:j,editDesign:e.jsx(sy,{data:{handleUpdate:g,token:t}}),deleteTodoMutation:A,open:h,DrawerUpdate:k}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const Li={width:"100%",height:40};function oy({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(null),[l,d]=r.useState(""),[c,y]=r.useState(""),[h,u]=r.useState(""),[p,C]=r.useState({page:1,rowsPerPage:10}),S=(_,A)=>{C({...p,page:_,rowsPerPage:parseInt(A,10)})},{isLoading:x,error:m,data:j,mutate:T}=W(t&&l?[l,t,p.page,p.rowsPerPage]:null,([_,A,f,g])=>K(`${_}page=${f}&per_page=${g}`,A)),R=r.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Income Category",selector:"income_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),I=()=>{if(!a){w.error("Select required dates",{duration:1e3}),y("textDanger");return}if(!i){w.error("Select required dates",{duration:1e3}),u("textDanger");return}const _=a.format("YYYY-MM-DD"),A=i.format("YYYY-MM-DD");d(`${Fc}?from_date=${_}&to_date=${A}&`),C(f=>({...f,page:1}))};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Search Income"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(n.DatePicker,{value:a,onChange:_=>{s(_),y("")},style:Li,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(n.DatePicker,{value:i,onChange:_=>{o(_),u("")},style:Li,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:I})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:S,data:{newData:j,columns:R,action:!1,Loading:x,error:m,pageController:p}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function ly({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),{isLoading:o,data:l}=W(s&&i?[`${Ec}?id=${i}`,s]:null,([u,p])=>K(u,p)),d=l?.data?.[0],[c,y]=r.useState({incomehead:"",description:""});r.useEffect(()=>{d&&y({incomehead:d?.income_category||"",description:d?.description||""})},[d]);const h=(u,p)=>{y(C=>({...C,[u]:p}))};return o?e.jsx(v,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:u=>a(u),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(v,{children:[e.jsx(V,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(V,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:c.incomehead,onChange:u=>h("incomehead",u.target.value)})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:u=>h("description",u.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function dy({token:t}){const[a,s]=r.useState({incomehead:"",description:""}),[i,o]=r.useState(!1),[l,d]=r.useState({page:1,rowsPerPage:10}),c=(_,A)=>{d({...l,page:_,rowsPerPage:parseInt(A,10)})},y=async(_,A)=>{try{await C(Ee(_,A,t),ze(A)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},{isLoading:h,error:u,data:p,mutate:C}=W(t?[Ic,t,l.page,l.rowsPerPage]:null,([_,A,f,g])=>K(`${_}?page=${f}&per_page=${g}`,A)),S=r.useMemo(()=>[{id:"1",name:"Name",selector:"income_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],m=async _=>{try{await C(qe(Oc,_,t),Ne(_)),w.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{w.error("Failed to delete the item.",{duration:1e3})}},j=async(_,A)=>{try{await C(Be(_,A,t)),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{w.error("Failed to update the item.",{duration:1e3})}},T=async _=>{_.preventDefault();const A=new FormData(_.target);await j(Pc,A),I(!1)},R=async _=>{_.preventDefault();const A=new FormData(_.target);await y(kc,A),_.target.reset()},I=_=>{o(_)};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:5,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Income Head"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:a.incomehead,onChange:_=>s(A=>({...A,incomehead:_.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:_=>s(A=>({...A,description:_.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,md:19,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Income Head List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:c,data:{newData:p,columns:S,action:!0,Loading:h,ActionView:x,error:u,editDesign:e.jsx(ly,{data:{handleUpdate:T,token:t}}),deleteTodoMutation:m,open:i,DrawerUpdate:I}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Bi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},qi=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function cy({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),{isLoading:o,data:l}=W(s&&i?[`${Vc}?id=${i}`,s]:null,([T,R])=>K(T,R)),{data:d}=W(s?[Lo,s]:null,([T,R])=>K(T,R)),{data:c}=W(s?[Bo,s]:null,([T,R])=>K(T,R)),y=r.useMemo(()=>Bi(d),[d]),h=r.useMemo(()=>Bi(c),[c]),u=l?.data?.[0],[p,C]=r.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:ae(),amount:"",payment_mode:"",note:"",doc:""});r.useEffect(()=>{u&&C({expense_head:u?.exp_head_id||"",vendor:u?.fk_vendor_id||"",name:u?.name||"",invoice_no:u?.invoice_number||"",date:u?.date?ae(u.date):ae(),amount:u?.amount||"",payment_mode:u?.payment_mode||"",note:u?.note||"",doc:u?.documents||""})},[u]);const S=(T,R)=>{C(I=>({...I,[T]:R}))},x=y.find(T=>String(T.value)===String(p.expense_head))??null,m=h.find(T=>String(T.value)===String(p.vendor))??null,j=qi.find(T=>String(T.value)===String(p.payment_mode))??null;return o?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:T=>a(T,i),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Edit Expense"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(V,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Q,{label:"Expense Head",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0,value:x,onChange:T=>S("expense_head",T?.value||"")})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Vendor",options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor",value:m,onChange:T=>S("vendor",T?.value||"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0,value:p.name,onChange:T=>S("name",T.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:p.invoice_no,onChange:T=>S("invoice_no",T.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:p.date,Desplay:"Date",name:"date",required:!0,onChange:T=>S("date",T)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"amount",type:"number",label:"Amount",required:!0,value:p.amount,onChange:T=>S("amount",T.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Payment Mode",options:qi,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0,value:j,onChange:T=>S("payment_mode",T?.value||"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(st,{name:"note",label:"Description",rows:3,value:p.note,onChange:T=>S("note",T.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:s},maxCount:1,onChange:T=>{if(T.file.status==="removed"&&S("doc",""),T.file.status==="done"){const R=T.file.response?.data??T.file.response?.file??"";S("doc",String(R??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:p.doc?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:p.doc||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const zi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},uy=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function py({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:ae(),amount:"",payment_mode:"",note:"",doc:""}),[c,y]=r.useState(!1),[h,u]=r.useState({page:1,rowsPerPage:10}),p=(b,P)=>{u({...h,page:b,rowsPerPage:parseInt(P,10)})},C=async(b,P)=>{try{await j(Ee(b,P,t),ze(P)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},{isLoading:S,error:x,data:m,mutate:j}=W(t?[Uc,t,h.page,h.rowsPerPage]:null,([b,P,O,F])=>K(`${b}?page=${O}&per_page=${F}`,P)),T=r.useMemo(()=>[{id:"1",name:"Sl No",selector:"__serialNumber",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Expense Category",selector:"exp_category",sortable:!0},{id:"5",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0},{id:"8",name:"File",selector:"documents",sortable:!1,render:b=>b?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>window.open(`${He()}/branch/frontoffice/${b}`,"_blank"),children:"View"}):"Not Uploaded"}],[]),R=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],I=async b=>{try{await j(qe(Lc,b,t),Ne(b)),w.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{w.error("Failed to delete the item.",{duration:1e3})}},_=async(b,P,O)=>{try{await j(Be(b,P,t)),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await O(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},A=async(b,P)=>{b.preventDefault();const O=new FormData(b.target);await _(Nc,O,P),g(!1)},f=async b=>{if(b.preventDefault(),!b.target.date.value)w.error("Select required dates",{duration:1e3}),b.target?.date?.focus(),o("textDanger");else{const P=new FormData(b.target);await C($c,P),b.target.reset(),s(""),d(O=>({...O,date:ae()}))}},g=b=>{y(b)},{data:D}=W(t?[Lo,t]:null,([b,P])=>K(b,P)),{data:k}=W(t?[Bo,t]:null,([b,P])=>K(b,P)),L=r.useMemo(()=>zi(D),[D]),B=r.useMemo(()=>zi(k),[k]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Add Expense"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:f,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Expense Head",options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Vendor",options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",name:"date",status:i===""?"":"error",classnme:i,onChange:()=>o("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(V,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Payment Mode",options:uy,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(st,{name:"note",label:"Description",rows:3})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:t},maxCount:1,onChange:b=>{if(b.file.status==="removed"&&s(""),b.file.status==="done"){const P=b.file.response?.data??b.file.response?.file??"";s(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:a||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:p,data:{newData:m,columns:T,action:!0,Loading:S,ActionView:R,error:x,editDesign:e.jsx(cy,{data:{handleUpdate:A,token:t}}),deleteTodoMutation:I,open:c,DrawerUpdate:g}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const Yi={width:"100%",height:40};function my({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(null),[l,d]=r.useState(""),[c,y]=r.useState(""),[h,u]=r.useState(""),[p,C]=r.useState({page:1,rowsPerPage:10}),S=(_,A)=>{C({...p,page:_,rowsPerPage:parseInt(A,10)})},{isLoading:x,error:m,data:j,mutate:T}=W(t&&l?[l,t,p.page,p.rowsPerPage]:null,([_,A,f,g])=>K(`${_}page=${f}&per_page=${g}`,A)),R=r.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Expense Category",selector:"exp_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),I=()=>{if(!a){w.error("Select required dates",{duration:1e3}),y("textDanger");return}if(!i){w.error("Select required dates",{duration:1e3}),u("textDanger");return}const _=a.format("YYYY-MM-DD"),A=i.format("YYYY-MM-DD");d(`${Hc}?from_date=${_}&to_date=${A}&`),C(f=>({...f,page:1}))};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Search Expense"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(n.DatePicker,{value:a,onChange:_=>{s(_),y("")},style:Yi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(n.DatePicker,{value:i,onChange:_=>{o(_),u("")},style:Yi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:I})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:S,data:{newData:j,columns:R,action:!1,Loading:x,error:m,pageController:p}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function hy({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),{isLoading:o,data:l}=W(s&&i?[`${Wc}?id=${i}`,s]:null,([u,p])=>K(u,p)),d=l?.data?.[0],[c,y]=r.useState({expensehead:"",description:""});r.useEffect(()=>{d&&y({expensehead:d?.exp_category||"",description:d?.description||""})},[d]);const h=(u,p)=>{y(C=>({...C,[u]:p}))};return o?e.jsx(v,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:u=>a(u),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(v,{children:[e.jsx(V,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(V,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:c.expensehead,onChange:u=>h("expensehead",u.target.value)})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:u=>h("description",u.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function fy({token:t}){const[a,s]=r.useState({expensehead:"",description:""}),[i,o]=r.useState(!1),[l,d]=r.useState({page:1,rowsPerPage:10}),c=(_,A)=>{d({...l,page:_,rowsPerPage:parseInt(A,10)})},y=async(_,A)=>{try{await C(Ee(_,A,t),ze(A)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},{isLoading:h,error:u,data:p,mutate:C}=W(t?[Bc,t,l.page,l.rowsPerPage]:null,([_,A,f,g])=>K(`${_}?page=${f}&per_page=${g}`,A)),S=r.useMemo(()=>[{id:"1",name:"Name",selector:"exp_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],m=async _=>{try{await C(qe(Yc,_,t),Ne(_)),w.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{w.error("Failed to delete the item.",{duration:1e3})}},j=async(_,A)=>{try{await C(Be(_,A,t)),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{w.error("Failed to update the item.",{duration:1e3})}},T=async _=>{_.preventDefault();const A=new FormData(_.target);await j(zc,A),I(!1)},R=async _=>{_.preventDefault();const A=new FormData(_.target);await y(qc,A),_.target.reset()},I=_=>{o(_)};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:5,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:a.expensehead,onChange:_=>s(A=>({...A,expensehead:_.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(V,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:_=>s(A=>({...A,description:_.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,md:19,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:c,data:{newData:p,columns:S,action:!0,Loading:h,ActionView:x,error:u,editDesign:e.jsx(hy,{data:{handleUpdate:T,token:t}}),deleteTodoMutation:m,open:i,DrawerUpdate:I}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function yy({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,y]=r.useState(0),[h,u]=r.useState(""),[p,C]=r.useState({page:1,rowsPerPage:10}),S=(k,L)=>{C({...p,page:k,rowsPerPage:parseInt(L,10)})},{isLoading:x,error:m,data:j,mutate:T}=W(t&&h?[h,t,p.page,p.rowsPerPage]:null,([k,L,B,b])=>K(`${k}page=${B}&per_page=${b}`,L)),{data:R}=W(t?[Xa,t]:null,([k,L])=>K(k,L)),{data:I}=W(t&&a?[`${Za}?class_id=${a}`,t]:null,([k,L])=>K(k,L)),_=r.useMemo(()=>R?Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[]:[],[R]),A=r.useMemo(()=>I?Array.isArray(I)?I:Array.isArray(I?.data)?I.data:[]:[],[I]),f=r.useMemo(()=>[{id:"1",name:"First Name",selector:"firstname",sortable:!0},{id:"2",name:"Last Name",selector:"lastname",sortable:!0},{id:"3",name:"Class",selector:"class",sortable:!0},{id:"4",name:"Section",selector:"section",sortable:!0},{id:"5",name:"ID",selector:"username",sortable:!0},{id:"6",name:"Password",selector:"password",sortable:!0}],[]),g=k=>{s(k?.value||""),o(""),y(L=>L+1)},D=k=>{if(k.preventDefault(),!a){w.error("Please select class",{duration:1e3});return}if(!i){w.error("Please select section",{duration:1e3});return}const L=`${Kc}?class_id=${a}&section_id=${i}&keyword=${l||""}&`;u(L),C(B=>({...B,page:1}))};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student Login Credential"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:_.find(k=>String(k.value)===String(a))??null,onChange:g})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:A.find(k=>String(k.value)===String(i))??null,onChange:k=>o(k?.value||"")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(V,{name:"keyword",type:"text",label:"Search By Keyword",value:l,onChange:k=>d(k.target.value)})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:D})})]})})]})}),h&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:S,data:{newData:j,columns:f,action:!1,Loading:x,error:m,pageController:p}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function gy({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,y]=r.useState(0),[h,u]=r.useState(qo),[p,C]=r.useState(!1),[S,x]=r.useState(null);console.log("Selected Student ID:",p);const[m,j]=r.useState({page:1,rowsPerPage:10}),T=(F,U)=>{j({...m,page:F,rowsPerPage:parseInt(U,10)})},{isLoading:R,error:I,data:_,mutate:A}=W(t&&h?[h,t,m.page,m.rowsPerPage]:null,([F,U,N,Y])=>K(`${F}page=${N}&per_page=${Y}`,U)),{data:f}=W(t?[Xa,t]:null,([F,U])=>K(F,U)),{data:g}=W(t&&a?[`${Za}?class_id=${a}`,t]:null,([F,U])=>K(F,U)),D=r.useMemo(()=>f?Array.isArray(f)?f:Array.isArray(f?.data)?f.data:[]:[],[f]),k=r.useMemo(()=>g?Array.isArray(g)?g:Array.isArray(g?.data)?g.data:[]:[],[g]),L=r.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Medicine",selector:"Medical",sortable:!1,render:(F,U)=>e.jsx(n.Button,{type:"primary",size:"small",onClick:()=>{x(U.id),C(!0)},children:"Medical"})}],[]),B=F=>{s(F?.value||""),o(""),y(U=>U+1)},b=F=>{if(F.preventDefault(),!a||!i){w.error("Please select class and section",{duration:1e3});return}const U=`${Yo}?cID=${a}&sID=${i}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(U),j(N=>({...N,page:1}))},P=F=>{F.preventDefault();const U=F.target.searchField?.value||"";d(U);const N=`${zo}?key=${U}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(N),j(Y=>({...Y,page:1}))},O=async F=>{F.preventDefault();const U=new FormData(F.target),N=Gc;try{await A(addData(N,U,t)),w.success("Medicine added successfully",{duration:1e3}),F.target.reset()}catch{w.error("Failed to add medicine",{duration:1e3})}};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Medical Report"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:b,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:D.find(F=>String(F.value)===String(a))??null,onChange:B})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:k.find(F=>String(F.value)===String(i))??null,onChange:F=>o(F?.value||"")})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:P,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:16,children:e.jsx(V,{name:"searchField",type:"text",label:"Search By Keyword",value:l,onChange:F=>d(F.target.value)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:T,data:{newData:_,columns:L,action:!1,Loading:R,error:I,pageController:m}})})]})})]}),e.jsx(n.Drawer,{title:"Medical Report",placement:"right",width:600,open:p,footer:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(ne,{type:"button",value:"Close",color:"default"})})}),children:e.jsx(xy,{studentId:S,token:t,onAddMedicine:O})}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function xy({studentId:t,token:a,onAddMedicine:s}){const{data:i}=W(a&&t?[`${Vo}?id=${t}`,a]:null,([y,h])=>K(y,h)),{data:o}=W(a&&t?[`${Jc}?student_id=${t}`,a]:null,([y,h])=>K(y,h)),l=i?.studentBasicDetails?.[0];let d=[];Array.isArray(o?.data)?d=o.data:Array.isArray(o)&&(d=o);const c=[{title:"Medicine",dataIndex:"medicine",key:"medicine"},{title:"Notes",dataIndex:"notes",key:"notes"},{title:"Date",dataIndex:"date_time",key:"date_time"}];return e.jsxs(v,{children:[l&&e.jsxs(v,{mb:3,children:[e.jsxs(ge,{level:4,children:["Name: ",l?.firstname," ",l?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",l?.class," (",l?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",l?.admission_no]})]}),e.jsx(ge,{level:5,style:{marginBottom:8},children:"Add Medicine"}),e.jsx("form",{onSubmit:s,style:{marginBottom:24},children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(v,{children:[e.jsx(V,{name:"medicine",type:"text",label:"Medicine Name",required:!0}),e.jsx("input",{name:"student_id",type:"hidden",value:t||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(st,{name:"notes",label:"Note",rows:3})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(Me,{format:"YYYY-MM-DD HH:mm",Desplay:"Date",name:"date_time",defaultValue:ae()})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})})})})]})}),e.jsx(ge,{level:5,style:{marginBottom:8},children:"Previous Medicine"}),e.jsx(n.Table,{size:"small",dataSource:d,pagination:!1,columns:c})]})}const{Group:Vi}=n.Checkbox;function by({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,y]=r.useState(0),[h,u]=r.useState(qo),[p,C]=r.useState(!1),[S,x]=r.useState(null),[m,j]=r.useState({page:1,rowsPerPage:10}),T=(N,Y)=>{j({...m,page:N,rowsPerPage:parseInt(Y,10)})},{isLoading:R,error:I,data:_,mutate:A}=W(t&&h?[h,t,m.page,m.rowsPerPage]:null,([N,Y,z,E])=>K(`${N}page=${z}&per_page=${E}`,Y)),{data:f}=W(t?[Xa,t]:null,([N,Y])=>K(N,Y)),{data:g}=W(t&&a?[`${Za}?class_id=${a}`,t]:null,([N,Y])=>K(N,Y)),D=r.useMemo(()=>f?Array.isArray(f)?f:Array.isArray(f?.data)?f.data:[]:[],[f]),k=r.useMemo(()=>g?Array.isArray(g)?g:Array.isArray(g?.data)?g.data:[]:[],[g]),L=r.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Assign Subject",selector:"Assign",sortable:!1,render:(N,Y)=>e.jsx(n.Button,{type:"primary",size:"small",onClick:()=>{x(Y.id),C(!0)},children:"Assign"})}],[]),B=N=>{s(N?.value||""),o(""),y(Y=>Y+1)},b=N=>{if(N.preventDefault(),!a||!i){w.error("Please select class and section",{duration:1e3});return}const Y=`${Yo}?cID=${a}&sID=${i}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(Y),j(z=>({...z,page:1}))},P=N=>{N.preventDefault();const Y=N.target.searchField?.value||"";d(Y);const z=`${zo}?key=${Y}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(z),j(E=>({...E,page:1}))},O=async N=>{N.preventDefault();const Y=new FormData(N.target),z=Xc;try{await A(Be(z,Y,t)),w.success("Subject updated successfully",{duration:1e3}),N.target.reset(),C(!1)}catch{w.error("Failed to update subject",{duration:1e3})}},F=async N=>{N.preventDefault();const Y=new FormData(N.target),z=Ks;try{await A(Be(z,Y,t)),w.success("Extra curricular updated successfully",{duration:1e3}),N.target.reset(),C(!1)}catch{w.error("Failed to update extra curricular",{duration:1e3})}},U=N=>{C(N)};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Assign Student Subject"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:b,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:D.find(N=>String(N.value)===String(a))??null,onChange:B})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:k.find(N=>String(N.value)===String(i))??null,onChange:N=>o(N?.value||"")})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:P,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:16,children:e.jsx(V,{name:"searchField",type:"text",label:"Search By Keyword",value:l,onChange:N=>d(N.target.value)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(v,{pt:3,children:e.jsx(Te,{parentCallback:T,data:{newData:_,columns:L,action:!1,Loading:R,error:I,pageController:m}})})]})})]}),p&&e.jsx(jy,{open:p,DrawerUpdate:U,studentId:S,token:t,onUpdate:O,onUpdate2:F}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function jy({open:t,DrawerUpdate:a,studentId:s,token:i,onUpdate:o,onUpdate2:l}){const[d,c]=r.useState([]),[y,h]=r.useState([]),[u,p]=r.useState([]),[C,S]=r.useState(!1),[x,m]=r.useState([]),[j,T]=r.useState([]),[R,I]=r.useState([]),{trigger:_}=tt(Vo,async(L,{arg:B})=>await K(`${L}?id=${B.id}`,i)),{trigger:A}=tt(Ks,async()=>await K(`${Ks}?student_id=${s}`,i)),{trigger:f}=tt(Qc,async(L,{arg:B})=>await K(`${L}?id=${B.id}`,i));r.useEffect(()=>{(async()=>{if(!s)return;S(!0);const B=await _({id:s});B?.studentBasicDetails?.[0];const b=await A(),P=await f({id:s});c(B),p(P),B&&h(b),S(!1)})()},[s,_,A,f]);const g=L=>{T(L);const B=d?.data?.filter(b=>!L.includes(b.value));m(JSON.stringify(B))},D=L=>{I(L)},k=d?.studentBasicDetails?.[0];return!C&&s?e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsxs(v,{p:3,children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Edit Assigned Subjects"})}),e.jsxs(v,{p:3,children:[k&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs(ge,{level:4,children:["Name: ",k?.firstname," ",k?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",k?.class," (",k?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",k?.admission_no]})]}),e.jsx("form",{onSubmit:o,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsxs(n.Col,{xs:24,children:[e.jsx(ge,{level:5,children:"Subjects"}),e.jsx(Vi,{options:d?.data?.map(L=>({label:L.label||L.name,value:L.value})),value:j,onChange:g,style:{display:"grid",gap:8}})]}),e.jsxs(n.Col,{xs:24,children:[e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0}),e.jsx("input",{name:"subjectUncheck[]",type:"hidden",value:x,readOnly:!0})]}),d?.data?.length===0?e.jsx(n.Col,{xs:24,children:e.jsx("span",{style:{cursor:"pointer",fontSize:15,color:"blue",textDecoration:"underline"},children:"Please Assign Subject"})}):e.jsx(n.Col,{xs:24,className:"buttonCoustom",children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Update",color:"primary"})})})})})]})}),y?.data?.length>0&&e.jsx("form",{onSubmit:l,style:{marginTop:24},children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsxs(n.Col,{xs:24,children:[e.jsx(ge,{level:5,children:"Extra Curricular Activities"}),e.jsx(Vi,{options:y?.data?.map(L=>({label:L.label||L.name,value:L.value})),value:R,onChange:D,style:{display:"grid",gap:8}})]}),e.jsx(n.Col,{xs:24,children:e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0})}),e.jsx(n.Col,{xs:24,className:"buttonCoustom",children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Update",color:"primary"})})})})})]})})]})]})}):e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsx(v,{p:3,children:e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})})})})}function Sy({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(0),[c,y]=r.useState(null),[h,u]=r.useState(!1),{data:p}=W(t?[Xa,t]:null,([f,g])=>K(f,g)),{data:C}=W(t&&a?[`${Za}?class_id=${a}`,t]:null,([f,g])=>K(f,g)),{data:S}=W(t?[eu,t]:null,([f,g])=>K(`${f}?page=1&per_page=10`,g)),x=r.useMemo(()=>p?Array.isArray(p)?p:Array.isArray(p?.data)?p.data:[]:[],[p]),m=r.useMemo(()=>C?Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[]:[],[C]),j=r.useMemo(()=>[{id:"1",name:"Category Id",selector:"id",sortable:!0},{id:"2",name:"Category",selector:"category",sortable:!0}],[]),T=f=>{s(f?.value||""),o(""),d(g=>g+1)},R=f=>{o(f?.value||"")},I=()=>{const f=document.createElement("a");f.href="/sample_student.xlsx",f.download="sample_student.xlsx",f.click()},_=f=>{f.fileList.length>0?y(f.fileList[0].originFileObj):y(null)},A=async f=>{if(f.preventDefault(),!a){w.error("Please select class",{duration:1e3});return}if(!i){w.error("Please select section",{duration:1e3});return}if(!c){w.error("Please select file",{duration:1e3});return}u(!0);const g=new FormData;g.append("file",c),g.append("class_id",a),g.append("section_id",i);try{const D=await dc(Zc,g,t);D?.Status==="Failed"?w.error(D?.msg||"Upload failed",{duration:2e3}):(w.success(D?.msg||"Upload successful",{duration:2e3}),y(null),s(""),o(""))}catch(D){w.error(D?.response?.data?.msg||"Upload failed",{duration:2e3})}finally{u(!1)}};return e.jsx(v,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Students"})}),e.jsxs(v,{p:3,children:[e.jsx(n.Row,{justify:"end",style:{marginBottom:16},children:e.jsx(n.Col,{children:e.jsx(n.Button,{type:"primary",icon:e.jsx(te.DownloadOutlined,{}),onClick:I,style:{background:"#368fed"},children:"Download Sample Import File"})})}),e.jsxs("div",{style:{marginBottom:16,padding:16,background:"#f5f5f5",borderRadius:8},children:[e.jsx(ge,{level:5,style:{marginBottom:8},children:"Information"}),e.jsx("div",{children:"1. Your Excel data should be in the format below. The first line of your Excel file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("div",{children:"2. If the column you are trying to import is date make sure that is formatted in format Y-m-d (2024-01-10)."}),e.jsx("div",{children:"3. Duplicate Admission Number, ec_no, aadhaar_number, (unique) rows will not be imported."}),e.jsx("div",{children:"4. For student Gender use Male, Female value."}),e.jsx("div",{children:"5. For student Blood Group use A+, A-, B+, B-, O+, O-, AB+, AB- value."}),e.jsx("div",{children:"6. * Imported field are admission_no, ec_no, firstname, lastname, roll_no, guardian_phone, aadhaar_number, category_id"})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx(ge,{level:5,style:{marginBottom:8},children:"Category Table"}),e.jsx(Te,{parentCallback:()=>{},data:{newData:S,columns:j,action:!1,Loading:!1,error:null,pageController:{page:1,rowsPerPage:10}}})]}),e.jsx("form",{onSubmit:A,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:x.find(f=>String(f.value)===String(a))??null,onChange:T})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:m.find(f=>String(f.value)===String(i))??null,onChange:R},`section-${l}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"File"}),e.jsx(n.Upload,{beforeUpload:()=>!1,onChange:_,maxCount:1,accept:".xlsx,.xls",children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),style:{width:"100%"},children:c?c.name:"Select Excel File"})})]})}),e.jsx(n.Col,{xs:24,md:6,style:{display:"flex",alignItems:"flex-end"},children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:h?"Processing...":"Save",color:"primary",loading:h})})})]})})]})]})})})})}function wy(){return null}const os=t=>t??localStorage.getItem("authToken")??"",cl=(t,a)=>{const s=String(t??""),i=String(a??"");return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i},ul=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",De={uploadNotes:"api/branchapi/Academy/uploadNotes",master:{classes:{dropdown:"api/branchapi/academy/classdropdownlist",table:"api/branchapi/academy/classestableList",add:"api/branchapi/academy/addclasses",edit:"api/branchapi/academy/editclass",remove:"api/branchapi/academy/deleteclass",show:"api/branchapi/academy/classShowdata"},sections:{list:"api/branchapi/academy/sectionlist",table:"api/branchapi/academy/sectiontableList",add:"api/branchapi/academy/addsections",edit:"api/branchapi/academy/editsection",remove:"api/branchapi/academy/deletesection",show:"api/branchapi/academy/sectionShowdata",byClass:"api/branchapi/academy/sectionoftheClass"},subjects:{dropdown:"api/branchapi/Academy/getClassSubjectdropdown",byClassLabelValue:"api/branchapi/Academy/getSubjectsbyClassaslablevalue",table:"api/branchapi/academy/subjecttableList",add:"api/branchapi/academy/addsubjects",edit:"api/branchapi/academy/editsubject",remove:"api/branchapi/academy/deletesubject",show:"api/branchapi/academy/subjectShowdata"},holidays:{table:"api/branchapi/academy/holidayList",add:"api/branchapi/academy/addholidays",edit:"api/branchapi/academy/editholidays",remove:"api/branchapi/academy/deleteholiday",show:"api/branchapi/academy/getByIdholidays"}},assignSubjects:{assign:"api/branchapi/Academy/assign_class_subjects",list:"api/branchapi/academy/getSubjectsbyClass",update:"api/branchapi/academy/updateAssignSubject",editByClass:"api/branchapi/academy/editSubjectsbyClass"},assignByClass:{teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classWithSection:"api/branchapi/academy/getClasswithSection",assignedSubjectsOfTeacher:"api/branchapi/academy/getassignedSubjectsofTeacher",subjectsOfTeacherByTeacherId:"api/branchapi/academy/getSubjectsofTeacherbyTeacherID",assignClassToTeacher:"api/branchapi/academy/assignClasstoTeacher",deleteTeacherSub:"api/branchapi/academy/deleteTeacherSub"},promoteStudents:{searchByClassSection:"api/branchapi/student/currentSessionStudentlist",sessionDropdown:"api/branchapi/generalSettings/sessiondropdown",promote:"api/branchapi/student/promotestudent"},timeGroup:{table:"api/branchapi/academy/getTimeGroupTable",add:"api/branchapi/academy/addTimeGroup",edit:"api/branchapi/academy/editTimeGroup",remove:"api/branchapi/academy/deleteTimeGroup",show:"api/branchapi/academy/getTimeGroupDataById",dropdown:"api/branchapi/academy/getTimeGroupDropDown"},assignTimeGroup:{classIdByTimeGroup:"api/branchapi/academy/getClassIdByTimeGroup",table:"api/branchapi/academy/getAssignedTimeGroupTable",show:"api/branchapi/academy/getAssignedTimeGroupDataById",assign:"api/branchapi/academy/assignTimeGroup"},timetable:{save:"api/timetable/save",byClassSection:"api/timetable/class",teacherTimetable:"api/timetable/teacher/",teachersBySubject:"api/branchapi/Academy/gettechersSubject"},notes:{table:"api/branchapi/Academy/getNotesTable",add:"api/branchapi/Academy/addNotes"},syllabus:{table:"api/branchapi/Academy/getsyllabusTable",add:"api/branchapi/Academy/addsyllabus",edit:"api/branchapi/Academy/editsyllabus",uploadFile:"api/SuperAdmin/uploadFile"},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"}},vy=()=>cl(He(),De.uploadNotes),_y=()=>cl(He(),De.syllabus.uploadFile),Cy=async({baseUrl:t,page:a=1,perPage:s=10},i)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(l,os(i))},_t=async(t,a,s,{includeSession:i=!1}={})=>{const o=a instanceof FormData?a:new FormData;return i&&!o.has("session_id")&&o.append("session_id",ul()),Ee(t,o,os(s))},Bt=async(t,a,s,{includeSession:i=!1}={})=>{const o=a instanceof FormData?a:new FormData;return i&&!o.has("session_id")&&o.append("session_id",ul()),Be(t,o,os(s))},qt=async(t,a,s)=>qe(t,a,os(s)),zn=De.master.sections,sn=({baseUrl:t,page:a=1,perPage:s=10,token:i})=>W(i&&t?[t,a,s,i]:null,([l,d,c,y])=>Cy({baseUrl:l,page:d,perPage:c},y)),Ay=({token:t,page:a=1,perPage:s=10})=>sn({token:t,baseUrl:zn.table,page:a,perPage:s}),Dy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Ty({token:t}){const[a,s]=r.useState({page:1,perPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),{data:y,isLoading:h,mutate:u}=Ay({token:t,page:a.page,perPage:a.perPage}),p=r.useMemo(()=>Dy(y),[y]),C=r.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??p.length??0,[y,p]),S=async R=>{R.preventDefault();const I=new FormData(R.target);try{await _t(zn.add,I,t),w.success("Success! Added new item.",{duration:1e3}),R.target.reset(),u()}catch(_){w.error(_?.response?.data?.msg??_?.message??"Failed to add the new item.",{duration:1500})}},x=async R=>{try{await qt(zn.remove,R,t),w.success("Success! Deleted item.",{duration:1e3}),u()}catch(I){w.error(I?.response?.data?.msg??I?.message??"Failed to delete the item.",{duration:1500})}},m=R=>{d(R),o(!0),c.setFieldsValue({section:R?.section??""})},j=async R=>{const I=new FormData;I.append("id",String(l?.id??"")),I.append("section",R.section??"");try{await Bt(zn.edit,I,t),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),u()}catch(_){w.error(_?.response?.data?.msg??_?.message??"Failed to update the item.",{duration:1500})}},T=r.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(R,I)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(I)}),e.jsx(n.Popconfirm,{title:"Delete this section?",onConfirm:()=>x(I?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Section",open:i,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:j,children:[e.jsx(n.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(n.Input,{placeholder:"Section Name"})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),children:e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(n.Space,{}),children:e.jsx(n.Table,{rowKey:R=>R.id,columns:T,dataSource:p,loading:h,pagination:{current:a.page,pageSize:a.perPage,total:C,showSizeChanger:!0,onChange:(R,I)=>s({page:R,perPage:I})}})})]})}function Ry({token:t}){return e.jsx(Ty,{token:t})}const La=De.master.classes,Iy=({token:t,page:a=1,perPage:s=10})=>sn({token:t,baseUrl:La.table,page:a,perPage:s}),ky=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Py=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function Oy({token:t}){const[a,s]=r.useState({page:1,perPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),[y]=n.Form.useForm(),{data:h}=W(t?[De.master.sections.list,t]:null,([D,k])=>K(D,k)),u=r.useMemo(()=>Py(h),[h]),p=r.useMemo(()=>u.map(D=>({label:D.label??D.section??String(D.value??""),value:String(D.value??D.id??"")})),[u]),{data:C,isLoading:S,mutate:x}=Iy({token:t,page:a.page,perPage:a.perPage}),m=r.useMemo(()=>ky(C),[C]),j=r.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??m.length??0,[C,m]),{data:T}=W(t&&l?[`${La.show}?id=${encodeURIComponent(String(l))}`,t]:null,([D,k])=>K(D,k)),R=r.useMemo(()=>{const D=T?.data??T;return Array.isArray(D)?D:Array.isArray(D?.data)?D.data:D?[D]:[]},[T]),I=D=>{const k=D?.id??D?.class_id;k&&(d(k),o(!0))};r.useEffect(()=>{if(!i||!R.length)return;const D=R[0],k=R.map(b=>b?.section_id??b?.fk_sectionId??b?.sectionId??b?.section).filter(b=>b!=null&&String(b).trim()!=="").map(b=>String(b)),L=Array.isArray(D?.section_ids)?D.section_ids.map(b=>String(b)):typeof D?.section_ids=="string"?D.section_ids.split(",").map(b=>b.trim()).filter(Boolean):Array.isArray(D?.section)?D.section.map(b=>String(b)):[],B=k.length?k:L;y.setFieldsValue({name:D?.class??D?.name??"",section:B})},[i,R,y]);const _=async D=>{const k=new FormData;k.append("name",D.name??""),(D.section??[]).forEach(L=>k.append("section[]",String(L)));try{await _t(La.add,k,t),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),x()}catch(L){w.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},A=async D=>{const k=new FormData;k.append("id",String(l??"")),k.append("name",D.name??""),(D.section??[]).forEach(L=>k.append("section[]",String(L)));try{await Bt(La.edit,k,t),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),x()}catch(L){w.error(L?.response?.data?.msg??L?.message??"Failed to update the item.",{duration:1500})}},f=async D=>{try{await qt(La.remove,D,t),w.success("Success! Deleted item.",{duration:1e3}),x()}catch(k){w.error(k?.response?.data?.msg??k?.message??"Failed to delete the item.",{duration:1500})}},g=r.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(D,k)=>D??k?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:D=>D??""},{title:"Actions",key:"actions",width:120,render:(D,k)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>I(k)}),e.jsx(n.Popconfirm,{title:"Delete this class?",onConfirm:()=>f(k?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Class",open:i,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:y,layout:"vertical",onFinish:A,children:[e.jsx(n.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:_,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(n.Table,{rowKey:D=>D.id,columns:g,dataSource:m,loading:S,pagination:{current:a.page,pageSize:a.perPage,total:j,showSizeChanger:!0,onChange:(D,k)=>s({page:D,perPage:k})}})})]})}function My({token:t}){return e.jsx(Oy,{token:t})}const Ba=De.master.subjects,Ey=({token:t,page:a=1,perPage:s=10})=>sn({token:t,baseUrl:Ba.table,page:a,perPage:s}),Fy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Wi=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],Hi=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function Uy({token:t}){const[a,s]=r.useState({page:1,perPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),[y]=n.Form.useForm(),{data:h,isLoading:u,mutate:p}=Ey({token:t,page:a.page,perPage:a.perPage}),C=r.useMemo(()=>Fy(h),[h]),S=r.useMemo(()=>h?.pagination?.total_rows??h?.pagination?.total??C.length??0,[h,C]),{data:x,isLoading:m}=W(t&&l?[`${Ba.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,g])=>K(f,g)),j=r.useMemo(()=>{const f=x?.data??x;return Array.isArray(f)?f[0]:f??null},[x]);r.useEffect(()=>{if(!i||!j)return;const f=[];["yes","1","true"].includes(String(j?.is_practical??"").toLowerCase())&&f.push("Practical"),["yes","1","true"].includes(String(j?.is_theory??"").toLowerCase())&&f.push("Theory"),y.setFieldsValue({name:j?.name??"",subject_type:j?.subject_type??j?.type??"",type:"",subject_types:f,code:j?.code??""})},[i,j,y]);const T=async f=>{const g=f?.type??f?.subject_type??"",D=Array.isArray(f?.subject_types)?f.subject_types:[],k={name:f?.name??"",subject_type:g,type:g,subject_types:D,code:f?.code??"",is_practical:D.includes("Practical")?"yes":"no",is_theory:D.includes("Theory")?"yes":"no"};try{await Ee(Ba.add,k,t),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(L){w.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},R=async f=>{const g=new FormData,D=f?.type??f?.subject_type??"",k=Array.isArray(f?.subject_types)?f.subject_types:[];g.append("id",String(l??"")),g.append("name",f.name??""),g.append("subject_type",f.subject_type??""),g.append("subject_type",D),g.append("type",D),g.append("code",f.code??""),g.append("is_practical",k.includes("Practical")?"yes":"no"),g.append("is_theory",k.includes("Theory")?"yes":"no");try{await Bt(Ba.edit,g,t),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(L){w.error(L?.response?.data?.msg??L?.message??"Failed to update the item.",{duration:1500})}},I=async f=>{try{await qt(Ba.remove,f,t),w.success("Success! Deleted item.",{duration:1e3}),p()}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to delete the item.",{duration:1500})}},_=f=>{const g=f?.id;g&&(d(g),o(!0))},A=r.useMemo(()=>[{title:"Subject Name",dataIndex:"name",key:"name"},{title:"Subject",dataIndex:"subject_type",key:"subject_type"},{title:"Subject Code",dataIndex:"code",key:"code"},{title:"Subject Type",key:"subject_types",render:(f,g)=>{const D=[],k=g?.subject_types;Array.isArray(k)?k.forEach(O=>{const F=String(O??"").trim();if(!F)return;const U=F.toLowerCase();["yes","1","true"].includes(U)||D.push(F)}):typeof k=="string"&&k.split(",").map(O=>O.trim()).filter(Boolean).forEach(O=>{const F=O.toLowerCase();["yes","1","true"].includes(F)||D.push(O)});const L=["yes","1","true"].includes(String(g?.is_practical??"").toLowerCase()),B=["yes","1","true"].includes(String(g?.is_theory??"").toLowerCase());L&&D.push("Practical"),B&&D.push("Theory");const b=D.map(O=>String(O??"").trim()).filter(Boolean).map(O=>O.toLowerCase()==="practical"?"Practical":O.toLowerCase()==="theory"?"Theory":O),P=Array.from(new Set(b));return P.length?P.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(f,g)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>_(g)}),e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>I(g?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Subject",open:i,onClose:()=>{o(!1),d(null)},width:560,children:m?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})}):e.jsxs(n.Form,{form:y,layout:"vertical",onFinish:R,children:[e.jsx(n.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(V,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(n.Radio.Group,{options:Hi})}),e.jsx(n.Form.Item,{label:"Subject Type",name:"subject_types",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:Wi})}),e.jsx(n.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(V,{placeholder:"Subject Code"})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:T,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(V,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(n.Radio.Group,{options:Hi})}),e.jsx(n.Form.Item,{name:"subject_types",label:"Subject Type",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:Wi})}),e.jsx(n.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(V,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(n.Table,{rowKey:f=>f.id,columns:A,dataSource:C,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:S,showSizeChanger:!0,onChange:(f,g)=>s({page:f,perPage:g})}})})]})}function $y({token:t}){return e.jsx(Uy,{token:t})}const qa=De.master.holidays,Ny=({token:t,page:a=1,perPage:s=10})=>sn({token:t,baseUrl:qa.table,page:a,perPage:s}),Ly=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},An={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function By({token:t}){const[a,s]=r.useState({page:1,perPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),[y]=n.Form.useForm(),{data:h,isLoading:u,mutate:p}=Ny({token:t,page:a.page,perPage:a.perPage}),C=r.useMemo(()=>Ly(h),[h]),S=r.useMemo(()=>h?.pagination?.total_rows??h?.pagination?.total??C.length??0,[h,C]),{data:x}=W(t&&l?[`${qa.show}?id=${encodeURIComponent(String(l))}`,t]:null,([A,f])=>K(A,f)),m=r.useMemo(()=>{const A=x?.data??x;return Array.isArray(A)?A[0]:A??null},[x]);r.useEffect(()=>{i&&m&&y.setFieldsValue({title:m?.holiday_title??"",description:m?.holiday_description??"",from:m?.start_date?ae(m.start_date):null,to:m?.end_date?ae(m.end_date):null})},[i,m,y]);const j=async A=>{const f=new FormData;f.append("title",A.title??""),f.append("description",A.description??""),f.append("from",A.from?ae(A.from).format("YYYY-MM-DD"):""),f.append("to",A.to?ae(A.to).format("YYYY-MM-DD"):"");try{await _t(qa.add,f,t,{includeSession:!0}),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to add the new item.",{duration:1500})}},T=async A=>{const f=new FormData;f.append("id",String(l??"")),f.append("title",A.title??""),f.append("description",A.description??""),f.append("from",A.from?ae(A.from).format("YYYY-MM-DD"):""),f.append("to",A.to?ae(A.to).format("YYYY-MM-DD"):"");try{await Bt(qa.edit,f,t,{includeSession:!0}),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to update the item.",{duration:1500})}},R=async A=>{try{await qt(qa.remove,A,t),w.success("Success! Deleted item.",{duration:1e3}),p()}catch(f){w.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},I=A=>{const f=A?.id;f&&(d(f),o(!0))},_=r.useMemo(()=>[{title:"Holiday Title",dataIndex:"holiday_title",key:"holiday_title"},{title:"Holiday Description",dataIndex:"holiday_description",key:"holiday_description"},{title:"Start From",dataIndex:"start_date",key:"start_date"},{title:"End At",dataIndex:"end_date",key:"end_date"},{title:"Actions",key:"actions",width:120,render:(A,f)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>I(f)}),e.jsx(n.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>R(f?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Holiday",open:i,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:y,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(V,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(V,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:An})}),e.jsx(n.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:An})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(V,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(st,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:An})}),e.jsx(n.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:An})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(n.Table,{rowKey:A=>A.id,columns:_,dataSource:C,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:S,showSizeChanger:!0,onChange:(A,f)=>s({page:A,perPage:f})}})})]})}function qy({token:t}){return e.jsx(By,{token:t})}const Yn=De.assignSubjects,zy=({token:t,page:a=1,perPage:s=50})=>sn({token:t,baseUrl:Yn.list,page:a,perPage:s}),Ki=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Yy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Vy({token:t}){const[a,s]=r.useState({page:1,perPage:50}),[i,o]=r.useState(null),[l,d]=r.useState([]),[c,y]=r.useState(!1),[h,u]=r.useState(!1),[p,C]=r.useState(null),[S,x]=r.useState([]),{data:m}=W(t?[De.master.classes.dropdown,t]:null,([O,F])=>K(O,F)),{data:j}=W(t?[De.master.subjects.dropdown,t]:null,([O,F])=>K(O,F)),T=r.useMemo(()=>Ki(m),[m]),R=r.useMemo(()=>Ki(j),[j]),I=r.useMemo(()=>R.map(O=>({label:O.label??O.subject??String(O.value??""),value:O.value??O.id})),[R]),{data:_,isLoading:A,mutate:f}=zy({token:t,page:a.page,perPage:a.perPage}),g=r.useMemo(()=>Yy(_),[_]),D=r.useMemo(()=>_?.pagination?.total_rows??_?.pagination?.total??g.length??0,[_,g]),{data:k}=W(t&&p?[`${Yn.editByClass}?class_id=${encodeURIComponent(String(p))}`,t]:null,([O,F])=>K(O,F));r.useEffect(()=>{if(!h)return;const O=k?.data??k,F=Array.isArray(O)?O:Array.isArray(O?.data)?O.data:[];x(F.map(U=>U.subject_id).filter(Boolean))},[h,k]);const L=async O=>{if(O.preventDefault(),!i?.value){w.error("Please select class",{duration:1200});return}if(!l.length){w.error("Please select subjects",{duration:1200});return}const F=new FormData;F.append("class_id",String(i.value)),l.forEach(U=>F.append("subject[]",String(U)));try{y(!0),await Bt(Yn.assign,F,t),w.success("Success! Updated item.",{duration:1e3}),o(null),d([]),f()}catch(U){w.error(U?.response?.data?.msg??U?.message??"Failed to update the item.",{duration:1500})}finally{y(!1)}},B=O=>{O&&(C(O),u(!0))},b=async()=>{if(!p)return;if(!S.length){w.error("Please select subjects",{duration:1200});return}const O=new FormData;O.append("class_id",String(p)),S.forEach(F=>O.append("subject[]",String(F)));try{await Bt(Yn.update,O,t),w.success("Success! Updated item.",{duration:1e3}),u(!1),C(null),f()}catch(F){w.error(F?.response?.data?.msg??F?.message??"Failed to update the item.",{duration:1500})}},P=r.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(O,F)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(F?.subject_name??O??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(O,F)=>e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>B(F?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Subjects",open:h,onClose:()=>{u(!1),C(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>u(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:b,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:T.find(O=>String(O.value)===String(p))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:I,value:S,onChange:x})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:i,onChange:O=>o(O??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:I,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(n.Table,{rowKey:O=>O.id,columns:P,dataSource:g,loading:A,pagination:{current:a.page,pageSize:a.perPage,total:D,showSizeChanger:!0,onChange:(O,F)=>s({page:O,perPage:F})}})})]})}function Wy({token:t}){return e.jsx(Vy,{token:t})}const ua=De.assignByClass,pl=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(typeof t?.data?.Status=="string"&&Array.isArray(t?.data?.data))return t.data.data;if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Ma=t=>pl(t),Hy=t=>pl(t),Ea=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Ky({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(null),[l,d]=r.useState(null),[c,y]=r.useState("No"),[h,u]=r.useState([]),[p,C]=r.useState([]),[S,x]=r.useState(null),[m,j]=r.useState(null),[T,R]=r.useState(!1),[I,_]=r.useState(""),{data:A}=W(t?[ua.teacherDropdown,t]:null,([de,X])=>K(de,X)),{data:f}=W(t?[De.master.classes.dropdown,t]:null,([de,X])=>K(de,X)),{data:g}=W(t&&m?[m,t]:null,([de,X])=>K(de,X)),{data:D}=W(t&&S?[S,t]:null,([de,X])=>K(de,X)),k=r.useMemo(()=>Ma(A),[A]),L=r.useMemo(()=>Ma(f),[f]),B=r.useMemo(()=>Ma(g),[g]),b=r.useMemo(()=>Ma(D),[D]),{data:P}=W(t&&a&&i&&l?[`${ua.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(a))}&class_id=${encodeURIComponent(String(i))}&section_id=${encodeURIComponent(String(l))}`,t]:null,([de,X])=>K(de,X)),O=P?.data??P??null;r.useEffect(()=>{O&&(u(Array.isArray(O?.subject_ids)?O.subject_ids:[]),y(O?.isClassTeacher||"No"),C([]))},[O]);const{data:F}=W(t?[ua.classWithSection,t]:null,([de,X])=>K(de,X)),U=r.useMemo(()=>Ma(F),[F]),[N,Y]=r.useState(null),[z,E]=r.useState({page:1,perPage:25});r.useEffect(()=>{N||U?.[0]&&Y(`${U[0].class_id}val${U[0].section_id}`)},[U,N]);const M=r.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),$=r.useMemo(()=>{if(!N)return null;const[de,X]=String(N).split("val");if(!de||!X)return null;const ce=z.page??1,Re=z.perPage??25;return`${ua.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(ce))}&per_page=${encodeURIComponent(String(Re))}&session_id=${encodeURIComponent(String(M))}&class_id=${encodeURIComponent(String(de))}&section_id=${encodeURIComponent(String(X))}`},[N,z.page,z.perPage,M]),{data:q,isLoading:H,mutate:re}=W(t&&$?[$,t]:null,([de,X])=>K(de,X),{revalidateOnFocus:!1}),ee=r.useMemo(()=>Hy(q),[q]),G=r.useMemo(()=>{const de=q?.pagination??q?.data?.pagination??q?.data?.data?.pagination;return de?.total_rows??de?.total??ee.length??0},[q,ee]),J=async de=>{if(de.preventDefault(),_(""),!a||!i||!l){w.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(h)||h.length===0){_("error"),w.error("Please Select Subject",{duration:1200});return}const X=new FormData;X.append("teacher_id",String(a)),X.append("class_id",String(i)),X.append("section_id",String(l)),X.append("isClassTeacher",String(c??"No")),Ea(h).forEach(ce=>X.append("subject_ids[]",String(ce))),Ea(p).forEach(ce=>X.append("delete_subject[]",String(ce)));try{await _t(ua.assignClassToTeacher,X,t,{includeSession:!0}),w.success("Success! Added new item.",{duration:1e3}),_(""),re()}catch(ce){w.error(ce?.response?.data?.msg??ce?.message??"Failed to add the new item.",{duration:1500})}},ie=async de=>{try{await qt(ua.deleteTeacherSub,de,t),w.success("Success! Deleted item.",{duration:1e3}),re(),window.location.reload()}catch(X){w.error(X?.response?.data?.msg??X?.message??"Failed to delete the item.",{duration:1500})}},pe=de=>{const X=Array.isArray(de?.child)?de.child:[],ce=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Re,Ue)=>e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>ie(Ue?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(n.Table,{columns:ce,bordered:!0,size:"small",dataSource:X,pagination:!1,rowKey:Re=>Re.id})})},_e=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(de,X)=>e.jsxs("div",{children:[X.teacher_name,X.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],le=r.useMemo(()=>(U??[]).map(de=>({label:de.label??`${de.class_name??""} ${de.section_name??""}`.trim(),key:`${de.class_id}val${de.section_id}`,children:e.jsx(n.Table,{size:"small",columns:_e,bordered:!0,dataSource:Array.isArray(ee)?ee:[],loading:H,rowKey:X=>X.id,expandable:{expandedRowRender:pe},pagination:{current:z.page,pageSize:z.perPage,total:G,showSizeChanger:!0,onChange:(X,ce)=>E({page:X,perPage:ce})}})})),[U,z.page,z.perPage,ee,H,G]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(320px, 380px) 1fr",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:J,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:k.find(de=>String(de.value)===String(a))??null,onChange:de=>s(de?.value??null)}),e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:L.find(de=>String(de.value)===String(i))??null,onChange:de=>{const X=de?.value??null;o(X),d(null),x(X?`${De.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(X))}`:null),j(X?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(X))}`:null),R(ce=>!ce)}}),e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:B.find(de=>String(de.value)===String(l))??null,onChange:de=>d(de?.value??null)},`section_${T}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const de=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(Q,{style:{width:"100%"},options:de,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:de.find(X=>String(X.value)===String(c??"No"))??de[1],onChange:X=>y(X?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(Q,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:b,value:(b??[]).filter(de=>Ea(h).some(X=>String(X)===String(de.value))),onChange:(de,X)=>{const Re=(Array.isArray(de)?de:[]).map(Le=>Le?.value).filter(Le=>Le!=null&&Le!=="");u(Re);const Ue=Array.isArray(O?.subject_ids)?O.subject_ids.map(String):[],ke=X?.removedValue?.value,Ve=X?.option?.value;(X?.action==="remove-value"||X?.action==="pop-value")&&ke!=null&&Ue.includes(String(ke))&&C(Le=>Array.from(new Set([...Ea(Le).map(String),String(ke)]))),X?.action==="select-option"&&Ve!=null&&Ue.includes(String(Ve))&&C(Le=>Ea(Le).filter(at=>String(at)!==String(Ve)))}},`subjects_${T}`),I?e.jsx("div",{style:{color:"#ff4d4f",marginTop:6,fontSize:12},children:"Please select subject"}):null]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(n.Tabs,{activeKey:N??void 0,onChange:de=>{Y(de),E(X=>({...X,page:1}))},items:le,type:"card",size:"small"})})]})]})}function Gy({token:t}){return e.jsx(Ky,{token:t})}const Fa=De.timeGroup,Jy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ut={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Dn(t){if(!t)return null;const a=ae(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return a.isValid()?a:null}function $t(t){return t?ae(t).format("h:mm a"):""}function Qy({token:t}){const[a,s]=r.useState({page:1,perPage:50}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),[y]=n.Form.useForm(),h=`${Fa.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:u,isLoading:p,mutate:C}=W(t?[h,t]:null,([g,D])=>K(g,D)),S=r.useMemo(()=>Jy(u),[u]),x=r.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??S.length??0,[u,S]),{data:m,isLoading:j}=W(t&&l?[`${Fa.show}?id=${encodeURIComponent(String(l))}`,t]:null,([g,D])=>K(g,D)),T=r.useMemo(()=>{const g=m?.data??m;return Array.isArray(g)?g[0]:g??null},[m]);r.useEffect(()=>{i&&T&&y.setFieldsValue({title:T?.title??"",start_time_from:Dn(T?.start_time_from),start_time_to:Dn(T?.start_time_to),end_time_from:Dn(T?.end_time_from),end_time_to:Dn(T?.end_time_to)})},[i,T,y]);const R=async g=>{const D=new FormData;D.append("title",g.title??""),D.append("start_time_from",$t(g.start_time_from)),D.append("start_time_to",$t(g.start_time_to)),D.append("end_time_from",$t(g.end_time_from)),D.append("end_time_to",$t(g.end_time_to));try{await _t(Fa.add,D,t),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),C()}catch(k){w.error(k?.response?.data?.msg??k?.message??"Failed to add the new item.",{duration:1500})}},I=async g=>{const D=new FormData;D.append("id",String(l??"")),D.append("title",g.title??""),D.append("start_time_from",$t(g.start_time_from)),D.append("start_time_to",$t(g.start_time_to)),D.append("end_time_from",$t(g.end_time_from)),D.append("end_time_to",$t(g.end_time_to));try{await Bt(Fa.edit,D,t),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),C()}catch(k){w.error(k?.response?.data?.msg??k?.message??"Failed to update the item.",{duration:1500})}},_=async g=>{try{await qt(Fa.remove,g,t),w.success("Success! Deleted item.",{duration:1e3}),C()}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed to delete the item.",{duration:1500})}},A=g=>{g?.id&&(d(g.id),o(!0))},f=r.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:120,render:(g,D)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>A(D)}),e.jsx(n.Popconfirm,{title:"Delete this time group?",onConfirm:()=>_(D?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Time Group",open:i,onClose:()=>{o(!1),d(null)},width:520,children:j?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})}):e.jsxs(n.Form,{form:y,layout:"vertical",onFinish:I,children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(V,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:R,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(V,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(n.Table,{rowKey:g=>g.id,columns:f,dataSource:S,loading:p,pagination:{current:a.page,pageSize:a.perPage,total:x,showSizeChanger:!0,onChange:(g,D)=>s({page:g,perPage:D})}})})]})}function Xy({token:t}){return e.jsx(Qy,{token:t})}const Ua=De.assignTimeGroup,Zy=De.timeGroup.dropdown,eg=De.master.classes.dropdown,Gi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],tg=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function ag({token:t}){const[a,s]=r.useState({page:1,perPage:50}),[i,o]=r.useState(null),[l,d]=r.useState([]),[c,y]=r.useState(""),[h,u]=r.useState(""),[p,C]=r.useState(null),[S,x]=r.useState(!1),[m,j]=r.useState(!1),[T,R]=r.useState(null),[I,_]=r.useState([]),[A,f]=r.useState(""),[g,D]=r.useState(""),{data:k}=W(t?[Zy,t]:null,([G,J])=>K(G,J)),{data:L}=W(t?[eg,t]:null,([G,J])=>K(G,J)),B=r.useMemo(()=>Gi(k?.data??k),[k]),b=r.useMemo(()=>Gi(L),[L]),{data:P}=W(t&&p?[p,t]:null,([G,J])=>K(G,J));r.useEffect(()=>{const G=Array.isArray(P?.data)?P.data.map(J=>J.fk_classId):[];G.length&&d(G)},[P]);const O=`${Ua.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:F,isLoading:U,mutate:N}=W(t?[O,t]:null,([G,J])=>K(G,J)),Y=r.useMemo(()=>tg(F),[F]),z=r.useMemo(()=>F?.pagination?.total_rows??F?.pagination?.total??Y.length??0,[F,Y]),{data:E,isLoading:M}=W(t&&T?[`${Ua.show}?id=${encodeURIComponent(String(T))}`,t]:null,([G,J])=>K(G,J)),$=E?.data??E??null;r.useEffect(()=>{if(!m||!$)return;const G=Array.isArray($?.class_ids)?$.class_ids:[];_(G);const J=Array.isArray(B)?B.find(ie=>String(ie.value)===String($?.timegroup_id)):null;J&&D(`${J.start_time_from} -> ${J.end_time_from}`)},[m,$,B]);const q=async G=>{if(G.preventDefault(),y(""),!i?.value){w.error("Select Time Group",{duration:1200});return}if(!l.length){y("error"),w.error("Please Select Classes",{duration:1200});return}const J=new FormData;J.append("timegroup_id",String(i.value)),l.forEach(ie=>J.append("class_ids[]",String(ie)));try{await _t(Ua.assign,J,t),w.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),N()}catch(ie){w.error(ie?.response?.data?.msg??ie?.message??"Failed to add the new item.",{duration:1500})}},H=async()=>{if(f(""),!T)return;if(!I.length){f("error"),w.error("Please Select Classes",{duration:1200});return}const G=new FormData;G.append("id",String(T)),G.append("timegroup_id",String($?.timegroup_id??"")),I.forEach(J=>G.append("class_ids[]",String(J)));try{await Bt(Ua.assign,G,t),w.success("Success! Updated item.",{duration:1e3}),j(!1),R(null),N()}catch(J){w.error(J?.response?.data?.msg??J?.message??"Failed to update the item.",{duration:1500})}},re=G=>{G&&(R(G),j(!0))},ee=r.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Class Names",dataIndex:"class_names",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:90,render:(G,J)=>J?.class_names?e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>re(J?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Time Group",open:m,onClose:()=>{j(!1),R(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>j(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:H,children:"Submit"})]}),children:M?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})}):e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{options:Array.isArray(B)?B:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:B.find(G=>String(G.value)===String($?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:g}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(n.Select,{mode:"multiple",style:{width:"100%"},status:A,value:I,placeholder:"Select Classes",onChange:G=>_(G),options:Array.isArray(b)?b:[]})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(Q,{options:Array.isArray(B)?B:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:i,onChange:G=>{o(G??null),d([]),y(""),G?.value?(C(`${Ua.classIdByTimeGroup}?id=${encodeURIComponent(String(G.value))}`),u(`${G.start_time_from} -> ${G.end_time_from}`)):(C(null),u("")),x(J=>!J)}}),e.jsx("div",{style:{marginTop:6},children:h})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(Q,{isMulti:!0,style:{width:"100%"},status:c,value:(b??[]).filter(G=>Array.isArray(l)&&l.some(J=>String(J)===String(G.value))),placeholder:"Select Classes",onChange:G=>{const J=Array.isArray(G)?G:[];d(J.map(ie=>ie?.value).filter(ie=>ie!=null&&ie!==""))},options:Array.isArray(b)?b:[]},`class_${S}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(n.Table,{rowKey:G=>G.id,columns:ee,dataSource:Y,loading:U,pagination:{current:a.page,pageSize:a.perPage,total:z,showSizeChanger:!0,onChange:(G,J)=>s({page:G,perPage:J})}})})]})}function ng({token:t}){return e.jsx(ag,{token:t})}const Gs=De.promoteStudents,sg=({token:t})=>W(t?[Gs.sessionDropdown,t]:null,([a,s])=>K(a,s)),Tn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},rg=(t,a)=>{const s=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,i=s?.total_rows??s?.total??s?.totalItems;return Number.isFinite(Number(i))?Number(i):a};function ig({token:t}){const[a]=n.Form.useForm(),[s,i]=r.useState({page:1,perPage:300}),[o,l]=r.useState({classId:null,sectionId:null}),[d,c]=r.useState({sessionId:null,classId:null}),[y,h]=r.useState(!1),[u,p]=r.useState([]),C=r.useMemo(()=>new Set(u),[u]),[S,x]=r.useState({}),[m,j]=r.useState({}),{data:T}=W(t?[De.master.classes.dropdown,t]:null,([q,H])=>K(q,H)),R=r.useMemo(()=>Tn(T),[T]),I=r.useMemo(()=>o.classId?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:_}=W(t&&I?[I,t]:null,([q,H])=>K(q,H)),A=r.useMemo(()=>Tn(_),[_]),f=r.useMemo(()=>d.classId?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:g}=W(t&&f?[f,t]:null,([q,H])=>K(q,H),{revalidateOnFocus:!1}),D=r.useMemo(()=>Tn(g),[g]),{data:k}=sg({token:t}),L=r.useMemo(()=>Tn(k),[k]),{trigger:B,data:b,isMutating:P}=tt(t?Gs.searchByClassSection:null,(q,{arg:H})=>Gt(q,{arg:H},t)),O=r.useMemo(()=>{const q=b?.data?.data??b?.data??b??[];return Array.isArray(q)?q:Array.isArray(q?.data)?q.data:[]},[b]),F=r.useMemo(()=>rg(b,O.length??0),[b,O.length]),U=r.useMemo(()=>{const q=new Map;return(Array.isArray(O)?O:[]).forEach(H=>{H?.id!==void 0&&H?.id!==null&&q.set(String(H.id),H)}),q},[O]),N=r.useCallback((q,H)=>{const re=String(q);j(ee=>({...ee,[re]:{...ee?.[re]??{},...H}}))},[]),Y=r.useCallback((q,H)=>{const re=String(q),ee=H==="Leave";x(G=>({...G,[re]:ee}))},[]),z=q=>{const H=q?.class_id?.value??q?.class_id??null,re=q?.section_id?.value??q?.section_id??null;if(!H||!re){w.error("Please select Class and Section",{duration:1200});return}i(ee=>({...ee,page:1})),l({classId:H,sectionId:re}),p([]),x({}),j({})},E=async()=>{if(!d.sessionId||!d.classId){w.error("Please select Session and Class for promotion",{duration:1300});return}if(!Array.isArray(u)||u.length===0){w.error("Please select students to promote",{duration:1200});return}const q=u.map(G=>String(G)).map(G=>{const J=U.get(G)??{},ie=!!S?.[G],pe=m?.[G]??{},_e=String(pe.current_result??"Pass");if(ie){const X=String(pe.leave_date??"");return{student_id:G,current_result:_e,next_session_status:"Leave",leave_date:X}}const le=String(pe.roll_no??J?.roll_no??""),de=String(pe.section_id??"");return{student_id:G,roll_no:le,section_id:de,current_result:_e,next_session_status:"Continue"}});if(q.some(G=>G?.next_session_status==="Leave"&&!String(G?.leave_date??"").trim())){w.error("Leave date is required for Leave students.",{duration:1500});return}if(q.some(G=>G?.next_session_status==="Continue"&&!String(G?.section_id??"").trim())){w.error("Section is required for Continue students.",{duration:1500});return}const ee={class_id:String(d.classId),session_id:String(d.sessionId),students:q};try{const G=await Be(Gs.promote,ee,t);if(G?.Status&&String(G.Status)!=="success")throw new Error(G?.msg||"Failed to update");w.success("Success! Updated.",{duration:1e3});const J=Number(G?.success_count??0)+Number(G?.leave_count??0),ie=s.page===Math.ceil((Number(F)||0)/s.perPage||1),pe=J>0&&J===O.length&&O.length===u.length,_e=ie&&pe&&s.page>1?s.page-1:s.page;i(le=>({...le,page:_e})),B?.({cID:o.classId,sID:o.sectionId,page:_e,per_page:s.perPage}),p([]),x({}),j({})}catch(G){w.error(G?.response?.data?.msg??G?.message??"Failed to update",{duration:1500})}},M=r.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:120,render:(q,H)=>{const re=String(H?.id??""),ee=C.has(re),G=!!S?.[re],ie=(m?.[re]??{}).roll_no??(G?"":H?.roll_no??"");return e.jsx(n.Input,{value:ee?ie:H?.roll_no,style:ee?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!ee||G,onChange:pe=>N(re,{roll_no:pe.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(q,H)=>`${H?.firstname??""} ${H?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(q,H)=>{const re=String(H?.id??""),ee=C.has(re),G=!!S?.[re],ie=(m?.[re]??{}).section_id??"",pe=Array.isArray(D)?D:[];return e.jsx(n.Select,{options:pe,placeholder:ee&&!G?"Select Section":"Section",disabled:!ee||G,value:ee&&!G&&ie||void 0,style:{width:"100%"},onChange:_e=>N(re,{section_id:_e})},`section_${re}_${y}_${G?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(q,H)=>{const re=String(H?.id??""),ee=C.has(re),G=m?.[re]??{},J=String(G.current_result??"Pass");return e.jsxs(n.Radio.Group,{value:J,disabled:!ee,buttonStyle:"solid",onChange:ie=>N(re,{current_result:ie.target.value}),children:[e.jsx(n.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(n.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(q,H)=>{const re=String(H?.id??""),ee=C.has(re),G=!!S?.[re],J=m?.[re]??{},ie=String(J.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(n.Radio.Group,{value:G?"Leave":"Continue",disabled:!ee,buttonStyle:"solid",onChange:pe=>Y(re,pe.target.value),children:[e.jsx(n.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(n.Radio.Button,{value:"Leave",children:"Leave"})]}),ee&&G&&e.jsx(n.DatePicker,{style:{width:"100%"},value:ie?ae(ie):null,onChange:pe=>N(re,{leave_date:pe?pe.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[Y,S,m,C,y,D,N]),$=r.useMemo(()=>({selectedRowKeys:u,onChange:q=>p((Array.isArray(q)?q:[]).map(H=>String(H)))}),[u]);return r.useEffect(()=>{!o.classId||!o.sectionId||B&&B({cID:o.classId,sID:o.sectionId,page:s.page,per_page:s.perPage})},[s.page,s.perPage,B,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:q=>q,children:e.jsx(Q,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:q=>{const H=q?.value??null;a.setFieldValue("section_id",null),l({classId:H,sectionId:null})}})}),e.jsx(n.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:q=>q,children:e.jsx(Q,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n.Typography.Text,{children:["Selected: ",u.length]}),e.jsx(n.Typography.Text,{type:"secondary",children:"Select students → set Continue/Leave → Save"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{label:"Session",options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:L.find(q=>String(q.value)===String(d.sessionId))??null,onChange:q=>c(H=>({...H,sessionId:q?.value??null}))}),e.jsx(Q,{label:"Class",options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(q=>String(q.value)===String(d.classId))??null,onChange:q=>{const H=q?.value??null;c(re=>({...re,classId:H})),h(re=>!re)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Save",color:"primary",onClick:E})})]}),e.jsx(n.Table,{rowKey:q=>String(q.id),rowSelection:$,columns:M,dataSource:O,loading:P,pagination:{current:s.page,pageSize:s.perPage,total:F,showSizeChanger:!0,onChange:(q,H)=>{i({page:q,perPage:H}),p([]),x({}),j({})}}})]})})]})}function og({token:t}){return e.jsx(ig,{token:t})}const ma=De.coscholastic,lg=({token:t})=>W(t?[ma.table,t]:null,([a,s])=>K(a,s),{revalidateOnFocus:!1}),dg=({token:t})=>W(t?[ma.categoryDropdown,t]:null,([a,s])=>K(a,s),{revalidateOnFocus:!1}),Ji=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]};function cg({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(null),[l,d]=r.useState(null),c=r.useRef(null),{data:y}=W(t?[De.master.classes.dropdown,t]:null,([g,D])=>K(g,D)),h=r.useMemo(()=>Ji(y),[y]),{data:u,isLoading:p,mutate:C}=lg({token:t}),S=r.useMemo(()=>{const g=u?.data?.data??u?.data??u??[];return Array.isArray(g)?g:Array.isArray(g?.data)?g.data:[]},[u]),{data:x,mutate:m}=dg({token:t}),j=r.useMemo(()=>Ji(x),[x]),T=r.useMemo(()=>(Array.isArray(j)?j:[]).map(g=>({value:g?.value??g?.id,label:g?.label??g?.title??""})),[j]),R=async()=>{const g=String(a??"").trim();if(!g){w.error("Please enter category title",{duration:1200});return}try{await Ee(ma.addCategory,{title:g},t),w.success("Success! Added category.",{duration:1e3}),s(""),m()}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed to add category",{duration:1500})}},I=async g=>{try{await qt(ma.deleteCategory,g,t),w.success("Success! Deleted category.",{duration:1e3}),m()}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed to delete category",{duration:1500})}},_=async g=>{if(g.preventDefault(),!i){w.error("Please select Category",{duration:1200});return}if(!l){w.error("Please select Class",{duration:1200});return}if(!g?.target?.skill?.value){w.error("Please enter Skill Name",{duration:1200});return}const k=new FormData(g.target);k.append("scholastic_catid",String(i)),k.append("class_id",String(l));try{await _t(ma.addSkill,k,t),w.success("Success! Added new item.",{duration:1e3}),g.target.reset(),d(null),C()}catch(L){w.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},A=async g=>{try{await qt(ma.deleteSkill,g,t),w.success("Success! Deleted item.",{duration:1e3}),C()}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed to delete the item.",{duration:1500})}},f=r.useMemo(()=>[{title:"Skill Category",dataIndex:"title",key:"title"},{title:"Class",dataIndex:"class",key:"class"},{title:"Skill Name",dataIndex:"skill",key:"skill"},{title:"Action",key:"action",width:90,render:(g,D)=>e.jsx(n.Popconfirm,{title:"Delete this skill?",onConfirm:()=>A(D?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Category"}),e.jsx(Q,{style:{width:"100%"},value:T.find(g=>String(g.value)===String(i))??null,placeholder:"Select Category",onChange:g=>o(g?.value??null),options:T}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(V,{placeholder:"New category",ref:c,value:a,onChange:g=>s(g.target.value)}),e.jsx(n.Button,{type:"text",icon:e.jsx(te.PlusOutlined,{}),onClick:R}),e.jsx(n.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{i&&(I(i),o(null))},children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{}),disabled:!i})})]})]}),e.jsx(Q,{label:"Class",options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:h.find(g=>String(g.value)===String(l))??null,onChange:g=>d(g?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(V,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:g=>g.id,columns:f,dataSource:S,loading:p,pagination:!1})})]})}function ug({token:t}){return e.jsx(cg,{token:t})}const pg=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ml=({token:t,value:a,onChange:s,action:i,filePath:o})=>{const l=r.useMemo(()=>{if(t)return{Authorization:t}},[t]),d=i??vy(),c=r.useMemo(()=>{if(!o)return d;const y=d.includes("?")?"&":"?";return`${d}${y}filepath=${encodeURIComponent(o)}`},[d,o]);return e.jsx(n.Upload,{maxCount:1,action:c,headers:l,onChange:y=>{if(y?.file?.status==="done"){const h=pg(y?.file?.response);h&&s?.(h)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},Qi=De.notes,mg=({token:t,url:a})=>W(t&&a?[a,t]:null,([s,i])=>K(s,i),{revalidateOnFocus:!1}),Rn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},hg=(t,a)=>{const s=String(t??""),i=String(a??"");return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i};function fg({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[i,o]=r.useState({page:1,perPage:50}),[l,d]=r.useState({classId:null,sectionId:null}),[c,y]=r.useState(!1),[h,u]=r.useState(""),{data:p}=W(t?[De.master.classes.dropdown,t]:null,([$,q])=>K($,q)),C=r.useMemo(()=>Rn(p),[p]),S=r.useMemo(()=>l.classId?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:x}=W(t&&S?[S,t]:null,([$,q])=>K($,q)),m=r.useMemo(()=>Rn(x),[x]),j=r.useMemo(()=>!l.classId||!l.sectionId?null:`${Qi.table}?class_id=${encodeURIComponent(String(l.classId))}&section_id=${encodeURIComponent(String(l.sectionId))}&page=${encodeURIComponent(String(i.page))}&per_page=${encodeURIComponent(String(i.perPage))}`,[l.classId,l.sectionId,i.page,i.perPage]),{data:T,isLoading:R,mutate:I}=mg({token:t,url:j}),_=r.useMemo(()=>{const $=T?.data?.data??T?.data??T??[];return Array.isArray($)?$:Array.isArray($?.data)?$.data:[]},[T]),A=r.useMemo(()=>T?.pagination?.total_rows??T?.pagination?.total??_.length??0,[T,_.length]),[f,g]=r.useState(null),[D,k]=r.useState(null),[L,B]=r.useState(null),[b,P]=r.useState(!1),{data:O}=W(t&&L?[L,t]:null,([$,q])=>K($,q),{revalidateOnFocus:!1}),F=r.useMemo(()=>Rn(O),[O]),{data:U}=W(t&&D?[D,t]:null,([$,q])=>K($,q)),N=r.useMemo(()=>Rn(U),[U]),Y=$=>{const q=$?.class_id?.value??null,H=$?.section_id?.value??null;!q||!H||(o(re=>({...re,page:1})),d({classId:q,sectionId:H}))},z=()=>{u(""),y(!0),g(null),k(null),B(null),P($=>!$),s.resetFields()},E=async $=>{const q=$?.class_id?.value??null,H=$?.section_id?.value??null,re=$?.sub_id?.value??null,ee=$?.status?.value??"publish",G=$?.title??"",J=$?.remark??"";if(!q||!H||!re||!G||!J||!h){w.error("Please fill all fields",{duration:1200});return}const ie=new FormData;ie.append("class_id",String(q)),ie.append("section_id",String(H)),ie.append("sub_id",String(re)),ie.append("title",String(G)),ie.append("remark",String(J)),ie.append("status",String(ee)),ie.append("file",String(h));try{await _t(Qi.add,ie,t),w.success("Success! Added new item.",{duration:1e3}),y(!1),I()}catch(pe){w.error(pe?.response?.data?.msg??pe?.message??"Failed to add the new item.",{duration:1500})}},M=r.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Remarks",dataIndex:"remark",key:"remark",align:"center"},{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Staff Name",dataIndex:"teacher_name",key:"teacher_name",align:"center"},{title:"Status",key:"status",align:"center",render:($,q)=>{const H=String(q?.status??"").toLowerCase();return e.jsx(n.Tag,{color:H==="publish"?"green":"red",children:q?.status??"-"})}},{title:"File",key:"file",align:"center",render:($,q)=>{const H=q?.file;if(!H)return"-";const re=hg(tr(),`uploads/school_${q?.fk_branchID}/student/note/${H}`);return e.jsx("a",{href:re,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"date",key:"date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Add Note",open:c,onCancel:()=>y(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:E,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(Q,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const q=$?.value??null;g(q),s.setFieldValue("section_id",null),s.setFieldValue("sub_id",null),B(q?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(q))}`:null),k(q?`${De.master.subjects.dropdown}?class_id=${encodeURIComponent(String(q))}`:null),P(H=>!H)}},`class_${b}`)}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(Q,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${b}_${f??"none"}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:$=>$,children:e.jsx(Q,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${b}_${D??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(V,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(V,{placeholder:"Remark"})}),e.jsx(n.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:$=>$,children:e.jsx(Q,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(ml,{token:t,value:h,onChange:u})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>y(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Yt,{actions:["add","export","print","download","filter"],onAdd:z,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:Y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(Q,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const q=$?.value??null;a.setFieldValue("section_id",null),d({classId:q,sectionId:null})}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(Q,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(n.Table,{rowKey:$=>$.id,columns:M,dataSource:_,loading:R,pagination:{current:i.page,pageSize:i.perPage,total:A,showSizeChanger:!0,onChange:($,q)=>o({page:$,perPage:q})}})})]})}function yg({token:t}){return e.jsx(fg,{token:t})}const gg=({token:t})=>W(t?[De.promoteStudents.sessionDropdown,t]:null,([a,s])=>K(a,s),{revalidateOnFocus:!1}),Xi=De.transferCertificate,Ps=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[]},xg={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},bg=(t,a)=>t.inputtype==="Select"?null:t.inputtype==="date"?ae():"",Zi=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}],eo=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 jg({token:t,transferCertificateViewPath:a="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:s}){const[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState({page:1,perPage:10}),[c,y]=r.useState({classId:null,sectionId:null,sessionId:null}),[h,u]=r.useState(null),[p,C]=r.useState(!1),{data:S}=W(t?[De.master.classes.dropdown,t]:null,([M,$])=>K(M,$)),x=r.useMemo(()=>Ps(S),[S]),{data:m}=W(t&&h?[h,t]:null,([M,$])=>K(M,$)),j=r.useMemo(()=>Ps(m),[m]),{data:T}=gg({token:t}),R=r.useMemo(()=>Ps(T),[T]),I=r.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${Xi.studentList}?class_id=${encodeURIComponent(String(c.classId))}&section_id=${encodeURIComponent(String(c.sectionId))}&session_id=${encodeURIComponent(String(c.sessionId))}&page=${encodeURIComponent(String(l.page))}&per_page=${encodeURIComponent(String(l.perPage))}`,[c.classId,c.sectionId,c.sessionId,l.page,l.perPage]),{data:_,isLoading:A,mutate:f}=W(t&&I?[I,t]:null,([M,$])=>K(M,$),{revalidateOnFocus:!1,onSuccess:M=>{const $=M?.data?.data??M?.data??[];Array.isArray($)&&$[0]?.transefer_certificate_id&&O(String($[0].transefer_certificate_id))}}),g=r.useMemo(()=>{const M=_?.data?.data??_?.data??_??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},[_]),D=r.useMemo(()=>_?.pagination?.total_rows??_?.pagination?.total??g.length??0,[_,g.length]),[k,L]=r.useState(!1),[B,b]=r.useState(null),[P,O]=r.useState("1"),F=M=>{b(M);const $=P==="1"?Zi(M):eo(M),q={};$.forEach(H=>{q[H.name]=H.value??bg(H)}),o.setFieldsValue(q),L(!0)},U=async M=>{if(!M)return;if(typeof s=="function")return s(M);const $=`${a}?id=${encodeURIComponent(String(M))}`;window.location.href=$},N=M=>{const $=M?.class_id?.value??null,q=M?.section_id?.value??null,H=M?.session_id?.value??null;if(!$||!q||!H){w.error("Please select Class, Section and Session",{duration:1200});return}d(re=>({...re,page:1})),y({classId:$,sectionId:q,sessionId:H})},Y=async M=>{const $=new FormData;Object.entries(M??{}).forEach(([q,H])=>{if(H!=null){if(ae.isDayjs(H)){$.append(q,H.format("YYYY-MM-DD"));return}$.append(q,String(H))}});try{await _t(Xi.addData,$,t),w.success("Success! Added new item.",{duration:1e3}),L(!1),b(null),f()}catch(q){w.error(q?.response?.data?.msg??q?.message??"Failed to add the new item.",{duration:1500})}},z=r.useMemo(()=>P==="1"?Zi(B):eo(B),[P,B]),E=r.useMemo(()=>[{title:"Admission no",dataIndex:"admission_no",key:"admission_no",align:"center"},{title:"Roll NO",dataIndex:"roll_no",key:"roll_no",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",align:"center"},{title:"Class",dataIndex:"class",key:"class",align:"center"},{title:"Section",dataIndex:"section",key:"section",align:"center"},{title:"Guardian Name",dataIndex:"guardian_name",key:"guardian_name",align:"center"},{title:"Mobile No",dataIndex:"mobileno",key:"mobileno",align:"center"},{title:"Action",key:"action",align:"center",width:80,render:(M,$)=>e.jsx(n.Button,{type:"text",icon:$?.transfer_certificate_data==="not_present"?e.jsx(te.EyeOutlined,{}):e.jsx(te.CheckOutlined,{}),onClick:()=>{$?.transfer_certificate_data==="not_present"?F($?.id):U($?.id)}})}],[P]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Transfer Certificate",open:k,onCancel:()=>L(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:Y,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:z.map(M=>M.inputtype==="hidden"?e.jsx(n.Form.Item,{name:M.name,initialValue:M.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},M.name):M.inputtype==="date"?e.jsx(n.Form.Item,{label:M.label,name:M.name,children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:xg})},M.name):M.inputtype==="radio"?e.jsx(n.Form.Item,{label:M.label,name:M.name,children:e.jsx(n.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},M.name):M.inputtype==="Select"?e.jsx(n.Form.Item,{label:M.label,name:M.name,getValueFromEvent:$=>$,children:e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},M.name):e.jsx(n.Form.Item,{label:M.label,name:M.name,children:e.jsx(V,{placeholder:M.label})},M.name))}),e.jsxs(n.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(ne,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>L(!1),children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(n.Form,{form:i,layout:"vertical",onFinish:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const $=M?.value??null;u($?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String($))}`:null),C(q=>!q),i.setFieldValue("section_id",null)}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:M=>M,children:e.jsx(Q,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${p}`)}),e.jsx(n.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:M=>M,children:e.jsx(Q,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:M=>M.id,columns:E,dataSource:g,loading:A,pagination:{current:l.page,pageSize:l.perPage,total:D,showSizeChanger:!0,onChange:(M,$)=>d({page:M,perPage:$})}})})]})}function Sg({token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s}){return e.jsx(jg,{token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s})}const wg=({token:t,url:a})=>W(t&&a?[a,t]:null,([s,i])=>K(s,i),{revalidateOnFocus:!1}),Os=De.syllabus,to=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[]},vg=(t,a)=>{const s=String(t??""),i=String(a??"");return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i};function _g({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[i,o]=r.useState({page:1,perPage:50}),[l,d]=r.useState({classId:null}),[c,y]=r.useState(!1),[h,u]=r.useState(null),[p,C]=r.useState(""),{data:S}=W(t?[De.master.classes.dropdown,t]:null,([U,N])=>K(U,N)),x=r.useMemo(()=>to(S),[S]),m=r.useMemo(()=>l.classId?`${Os.table}?class_id=${encodeURIComponent(String(l.classId))}&page=${encodeURIComponent(String(i.page))}&per_page=${encodeURIComponent(String(i.perPage))}`:null,[l.classId,i.page,i.perPage]),{data:j,isLoading:T,mutate:R}=wg({token:t,url:m}),I=r.useMemo(()=>{const U=j?.data?.data??j?.data??j??[];return Array.isArray(U)?U:Array.isArray(U?.data)?U.data:[]},[j]),_=r.useMemo(()=>j?.pagination?.total_rows??j?.pagination?.total??I.length??0,[j,I.length]),[A,f]=r.useState(null),[g,D]=r.useState(!1),{data:k}=W(t&&A?[A,t]:null,([U,N])=>K(U,N),{revalidateOnFocus:!1}),L=r.useMemo(()=>to(k),[k]),B=U=>{const N=U?.class_id?.value??null;N&&(o(Y=>({...Y,page:1})),d({classId:N}))},b=()=>{u(null),C(""),f(null),D(U=>!U),s.resetFields(),y(!0)},P=U=>{u(U),C(U?.attchement??"");const N=U?.class_id;f(N?`${De.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),D(Y=>!Y),s.setFieldsValue({class_id:x.find(Y=>String(Y.value)===String(N))??null,sub_id:L.find(Y=>String(Y.value)===String(U?.sub_id??U?.subject_id))??(U?.sub_id||U?.subject_id?{label:U?.subject_title??"Subject",value:U?.sub_id??U?.subject_id}:null),title:U?.title??"",description:U?.description??""}),y(!0)},O=async U=>{const N=U?.class_id?.value??null,Y=U?.sub_id?.value??null,z=U?.title??"",E=U?.description??"";if(!N||!Y||!z||!E||!p){w.error("Please fill all fields",{duration:1200});return}const M=new FormData;M.append("class_id",String(N)),M.append("sub_id",String(Y)),M.append("title",String(z)),M.append("description",String(E)),M.append("file",String(p));try{h?.id?(M.append("id",String(h.id)),await _t(Os.edit,M,t),w.success("Success! Updated item.",{duration:1e3})):(await _t(Os.add,M,t),w.success("Success! Added new item.",{duration:1e3})),y(!1),u(null),R()}catch($){w.error($?.response?.data?.msg??$?.message??"Failed to save",{duration:1500})}},F=r.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Description",dataIndex:"description",key:"description",align:"center"},{title:"Subject",dataIndex:"subject_title",key:"subject_title",align:"center"},{title:"File",key:"file",align:"center",render:(U,N)=>{const Y=N?.attchement;if(!Y)return"-";const z=vg(tr(),`uploads/school_${N?.fk_branchID}/student/syllabus/${Y}`);return e.jsx("a",{href:z,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(U,N)=>e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>P(N)})}],[L,x]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:h?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{y(!1),u(null),C("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:U=>U,children:e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{const N=U?.value??null;s.setFieldValue("sub_id",null),f(N?`${De.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),D(Y=>!Y)}},`class_${h?.id??"add"}_${g}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:U=>U,children:e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${h?.id??"add"}_${g}_${A??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(V,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(st,{placeholder:"Description"})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(ml,{token:t,value:p,onChange:C,action:_y(),filePath:"student/syllabus"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>y(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Yt,{actions:["add","export","print","download","filter"],onAdd:b,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,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(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:U=>U,children:e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(n.Table,{rowKey:U=>U.id,columns:F,dataSource:I,loading:T,pagination:{current:i.page,pageSize:i.perPage,total:_,showSizeChanger:!0,onChange:(U,N)=>o({page:U,perPage:N})}})})]})}function Cg({token:t}){return e.jsx(_g,{token:t})}const ls=De.timetable,ao=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},no=t=>{if(!t)return"";const a=ae(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},Ag=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const i=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return i[s%i.length]},so=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Dg=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"};function Tg({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,y]=r.useState(""),[h,u]=r.useState(""),{data:p}=W(t?[De.master.classes.dropdown,t]:null,([f,g])=>K(f,g)),C=r.useMemo(()=>ao(p),[p]),{data:S}=W(t&&a?[a,t]:null,([f,g])=>K(f,g)),x=r.useMemo(()=>ao(S),[S]),{data:m,isLoading:j}=W(t&&l?[l,t]:null,([f,g])=>K(f,g),{revalidateOnFocus:!1}),T=r.useMemo(()=>m?.days??m?.data?.days??m?.data?.data?.days??{},[m]),{dataSource:R,daySpanByFirstKey:I}=r.useMemo(()=>{const f=Object.entries(T||{}).slice().sort((k,L)=>so.indexOf(String(k[0]).toLowerCase())-so.indexOf(String(L[0]).toLowerCase())),g=new Map,D=[];for(const[k,L]of f){const B=(Array.isArray(L)?L:[]).slice().sort((P,O)=>Number(P?.order_no||0)-Number(O?.order_no||0)),b=B.length;for(let P=0;P<b;P+=1){const O=B[P],F=O?.id||`${k}-${O?.order_no}-${P}`;P===0&&g.set(F,b),D.push({key:F,_dayKey:k,...O})}}return{dataSource:D,daySpanByFirstKey:g}},[T]),_=r.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(f,g)=>{const D=I.get(g.key);return D===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(te.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Dg(f)})]}),props:{rowSpan:D}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:f=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:f})},{title:"Time",key:"time",width:180,render:(f,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[no(g?.time_from)," - ",no(g?.time_to)]})]})},{title:"Subject",key:"subject",render:(f,g)=>{if(String(g?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const k=g?.subject_name||"-";return e.jsx(n.Tag,{color:Ag(k),style:{fontWeight:500},children:k})}},{title:"Teacher",key:"teacher",render:(f,g)=>{const D=String(g?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:D?"-":g?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(f,g)=>{const D=String(g?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:D?"-":g?.room_no||"-"})]})}}],[I]),A=f=>{f.preventDefault();const g=f.target.class_id?.value,D=f.target.section_id?.value;if(!g||!D)return;const k=C.find(P=>String(P.value)===String(g)),L=x.find(P=>String(P.value)===String(D));y(k?.label||""),u(L?.label||"");const b=`${ls.byClassSection}/${g}/section/${D}`;d(b)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:f=>{s(`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(f?.value??""))}`),o(g=>!g)}}),e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${i}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:c||h?`Timetable: ${c} ${h}`:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:R,columns:_,rowKey:"key",loading:j,scroll:{x:"max-content"}})})]})}const Rg=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[]},ro=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Ig=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"},io=t=>{if(!t)return"";const a=ae(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},kg=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const i=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return i[s%i.length]};function Pg({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(null),{data:l}=W(t?[De.assignByClass.teacherDropdown,t]:null,([S,x])=>K(S,x)),d=r.useMemo(()=>Rg(l),[l]),{data:c,isLoading:y}=W(t&&i?[i,t]:null,([S,x])=>K(S,x),{revalidateOnFocus:!1}),{dataSource:h,daySpanByFirstKey:u}=r.useMemo(()=>{const x=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((R,I)=>{const _=ro.indexOf(String(R?.day_name||"").toLowerCase()),A=ro.indexOf(String(I?.day_name||"").toLowerCase());if(_!==A)return _-A;const f=Number(R?.order_no||0),g=Number(I?.order_no||0);return f!==g?f-g:String(R?.time_from||"").localeCompare(String(I?.time_from||""))}),m=new Map,j=[];let T=0;for(;T<x.length;){const R=String(x[T]?.day_name||"").toLowerCase();let I=T;for(;I<x.length&&String(x[I]?.day_name||"").toLowerCase()===R;)I+=1;const _=I-T;for(let A=T;A<I;A+=1){const f=x[A],g=f?.id||`${R}-${f?.order_no}-${A}`;A===T&&m.set(g,_),j.push({key:g,_dayKey:R,...f})}T=I}return{dataSource:j,daySpanByFirstKey:m}},[c]),p=r.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(S,x)=>{const m=u.get(x.key);return m===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(te.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Ig(S)})]}),props:{rowSpan:m}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:S=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:S})},{title:"Time",key:"time",width:180,render:(S,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[io(x?.time_from)," - ",io(x?.time_to)]})]})},{title:"Subject",key:"subject",render:(S,x)=>{if(String(x?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const j=x?.subject_name||"-";return e.jsx(n.Tag,{color:kg(j),style:{fontWeight:500},children:j})}},{title:"Class",key:"class",width:160,render:(S,x)=>e.jsxs(n.Tag,{color:"purple",style:{fontWeight:500},children:[x?.class_name||x?.class_id||"-"," ",x?.section_name?`(${x.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(S,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:x?.room_no||"-"})]})}],[u]),C=S=>{S.preventDefault();const x=S.target.teacher_id?.value;if(!x)return;s(x);const j=`${ls.teacherTimetable}${encodeURIComponent(String(x))}`;o(j)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:d,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teacher",name:"teacher_id",allowSelectAll:!1,required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:h,columns:p,rowKey:"key",loading:y,scroll:{x:"max-content"}})})]})}function oo(t){if(!t)return null;const a=String(t).trim().replaceAll(".",":");if(!a)return null;const s=a.toLowerCase(),i=s.includes("am")||s.includes("pm");let o=0,l=0,d=0;if(i){const y=s.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!y)return null;o=Number.parseInt(y[1],10),l=Number.parseInt(y[2],10),d=Number.parseInt(y[3]||"0",10);const h=y[4].toLowerCase();h==="pm"&&o<12&&(o+=12),h==="am"&&o===12&&(o=0)}else{const c=a.split(":").map(y=>y.trim());if(c.length<2)return null;o=Number.parseInt(c[0],10),l=Number.parseInt(c[1],10),d=Number.parseInt(c[2]||"0",10)}return![o,l,d].every(c=>Number.isFinite(c))||o<0||o>23||l<0||l>59||d<0||d>59?null:ae().hour(o).minute(l).second(d).millisecond(0)}function $a(t,a){const s=Number.parseInt(a,10);return!Number.isFinite(s)||s<=0||!t||!t.isValid?.()?null:t.add(s,"minute")}const 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[]},za={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},Og=t=>{const a=za[String(t)];return a?a.charAt(0).toUpperCase()+a.slice(1):String(t)},Mg=({token:t,classId:a,sectionId:s,subjectId:i,value:o,onChange:l,disabled:d})=>{const c=t&&a&&s&&i?`${ls.teachersBySubject}?subject_id=${encodeURIComponent(String(i))}&class_id=${encodeURIComponent(String(a))}&section_id=${encodeURIComponent(String(s))}`:null,{data:y,isLoading:h}=W(c?[c,t]:null,([p,C])=>K(p,C),{revalidateOnFocus:!1}),u=r.useMemo(()=>Vn(y?.data??y).map(C=>({value:C?.value??C?.id,label:C?.label??C?.name??C?.teacher_name??""})),[y]);return e.jsx(n.Select,{placeholder:d?"-":"Select Teacher",loading:h,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:p=>l?.(p),showSearch:!0,optionFilterProp:"label"})};function Eg({token:t}){const[a]=n.Form.useForm(),[s,i]=r.useState({classId:null,sectionId:null,dayKey:"1",daysEnabled:{0:!1,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}),[o,l]=r.useState({startTime:null,endTime:null,duration:40,interval:0,roomNo:"",tiffinEnabled:!1,tiffinAfterPeriod:3,tiffinDuration:20}),[d,c]=r.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[y,h]=r.useState(!1),u=r.useMemo(()=>t?De.master.classes.dropdown:null,[t]),{data:p}=W(u?[u,t]:null,([b,P])=>K(b,P)),C=r.useMemo(()=>Vn(p).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[p]),S=r.useMemo(()=>!t||!s.classId?null:`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:x}=W(S?[S,t]:null,([b,P])=>K(b,P)),m=r.useMemo(()=>Vn(x).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[x]),j=r.useMemo(()=>!t||!s.classId?null:`${De.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:T}=W(j?[j,t]:null,([b,P])=>K(b,P)),R=r.useMemo(()=>Vn(T).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[T]),I=r.useMemo(()=>Array.isArray(d?.[s.dayKey])?d[s.dayKey]:[],[s.dayKey,d]),_=r.useCallback((b,P,O)=>{c(F=>{const U={...F},N=Array.isArray(U[b])?U[b].slice():[];return N[P]={...N[P]??{},...O},U[b]=N,U})},[]),A=r.useCallback((b,P)=>{c(O=>{const F={...O},U=Array.isArray(F[b])?F[b].slice():[];return U.splice(P,1),F[b]=U.map((N,Y)=>({...N,order_no:Y+1})),F})},[]),f=r.useCallback(b=>{c(P=>{const O={...P},F=Array.isArray(O[b])?O[b].slice():[];let U=null,N=null;const Y=F[F.length-1];if(Y?.time_to){const z=oo(Y.time_to),E=Number.parseInt(o.interval,10)||0,M=Number.parseInt(o.duration,10)||0,$=$a(z,E),q=M>0?$a($,M):null;U=$?.isValid?.()?$.format("HH:mm:ss"):null,N=q?.isValid?.()?q.format("HH:mm:ss"):null}return F.push({order_no:F.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:U,time_to:N,is_break:!1}),O[b]=F,O})},[o.duration,o.interval,o.roomNo]),g=r.useCallback(()=>{const b=o.startTime,P=o.endTime,O=Number.parseInt(o.duration,10),F=Number.parseInt(o.interval,10);if(!b||!b.isValid?.()){w.error("Start time is required",{duration:1500});return}if(!P||!P.isValid?.()){w.error("End time is required",{duration:1500});return}if(!P.isAfter(b)){w.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(O)||O<=0){w.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(F)||F<0){w.error("Interval must be 0 or more",{duration:1500});return}const U=()=>{const N=[];let Y=b;for(let z=0;z<50;z+=1){const E=$a(Y,O);if(!E||!E.isValid?.()||E.isAfter(P))break;N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:Y.format("HH:mm:ss"),time_to:E.format("HH:mm:ss"),is_break:!1});const M=$a(E,F);if(!M||!M.isValid?.()||M.isAfter(P)||M.isSame(P))break;Y=M}if(o.tiffinEnabled){const z=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),E=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),M=Math.min(z,N.length);if(M>0&&E>0){const $=N[M-1],q=$?.time_to?oo($.time_to):null,H=q?$a(q,E):null;q?.isValid?.()&&H?.isValid?.()&&!H.isAfter(P)&&N.splice(M,0,{order_no:M+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:q.format("HH:mm:ss"),time_to:H.format("HH:mm:ss"),is_break:!0})}}return N.map((z,E)=>({...z,order_no:E+1}))};c(N=>{const Y={...N};return Object.keys(za).forEach(z=>{s.daysEnabled?.[z]&&(Y[z]=U())}),Y}),w.success("Generated schedule",{duration:1e3})},[o,s.daysEnabled]),D=r.useCallback(()=>{const b=localStorage.getItem("genrall_settings"),O=(b?JSON.parse(b):{})?.session_id??"1",F=s.classId,U=s.sectionId,N=Object.keys(za).map(Y=>{const z=(Array.isArray(d?.[Y])?d[Y]:[]).map((E,M)=>({order_no:M+1,subject_id:E?.is_break?0:E?.subject_id??null,teacher_id:E?.is_break?0:E?.teacher_id??null,room_no:E?.room_no??"",time_from:E?.time_from??null,time_to:E?.time_to??null,is_break:E?.is_break?1:0}));return{day:za[Y],class_id:F,section_id:U,session_id:O,args:z}});return{class_id:F,section_id:U,session_id:O,days:N}},[s.classId,s.sectionId,d]),k=r.useCallback(async()=>{if(!s.classId||!s.sectionId){w.error("Please select Class and Section",{duration:1500});return}const b=D(),P=Array.isArray(b?.days)?b.days:[];if(!P.some(U=>Array.isArray(U?.args)&&U.args.length>0)){w.error("No timetable rows to submit",{duration:1500});return}const F=U=>{const N=U?.is_break;return N===1||N==="1"||N===!0?!0:String(N??"").toLowerCase()==="true"};P.some(U=>(Array.isArray(U?.args)?U.args:[]).some(N=>String(N?.time_from??"").trim()&&String(N?.time_to??"").trim()?F(N)?!1:!String(N?.subject_id??"").trim()||!String(N?.teacher_id??"").trim():!0)),h(!0);try{const U=ls.save,N=U==="api/timetable/save"?"timetable/save":null,Y=async M=>{const $=await ts(M,b,t);if($&&typeof $=="object")return $;throw new Error("No response from server")};let z;try{z=await Y(U)}catch{z=await Y(N)}const E=String(z?.msg??"");if(String(z?.Status)==="Success"){if(Array.isArray(z?.data)&&z.data.length===0&&E){w.error(E,{duration:3e3});return}w.success(E||"Weekly Time Table added successfully!",{duration:1200});return}w.error(E||"Failed to add time table",{duration:3e3})}catch(U){w.error(U?.response?.data?.msg??U?.message??"Failed to add time table",{duration:3e3})}finally{h(!1)}},[D,s.classId,s.sectionId,t]),L=r.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:b=>b?ae(b,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:b=>b?ae(b,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(b,P,O)=>e.jsx(n.Switch,{checked:!!P?.is_break,onChange:F=>{_(s.dayKey,O,{is_break:F,subject_id:F?"":P?.subject_id??"",teacher_id:F?"":P?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(b,P,O)=>e.jsx(n.Select,{placeholder:P?.is_break?"-":"Select Subject",disabled:!!P?.is_break,style:{width:"100%"},options:R,value:P?.subject_id?String(P.subject_id):void 0,onChange:F=>_(s.dayKey,O,{subject_id:F,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(b,P,O)=>e.jsx(Mg,{token:t,classId:s.classId,sectionId:s.sectionId,subjectId:P?.subject_id,disabled:!!P?.is_break||!P?.subject_id,value:P?.teacher_id,onChange:F=>_(s.dayKey,O,{teacher_id:F})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(b,P,O)=>e.jsx(n.Input,{value:P?.room_no??"",onChange:F=>_(s.dayKey,O,{room_no:F.target.value})})},{title:"Action",key:"action",width:90,render:(b,P,O)=>e.jsx(n.Popconfirm,{title:"Delete this row?",onConfirm:()=>A(s.dayKey,O),children:e.jsx(n.Button,{danger:!0,type:"text",children:"Delete"})})}],[s.classId,s.dayKey,s.sectionId,A,R,t,_]),B=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(n.Form,{form:a,layout:"vertical",initialValues:{duration:o.duration,interval:o.interval,roomNo:o.roomNo,tiffinEnabled:o.tiffinEnabled,tiffinAfterPeriod:o.tiffinAfterPeriod,tiffinDuration:o.tiffinDuration},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",required:!0,children:e.jsx(n.Select,{placeholder:"Select Class",options:C,value:s.classId?String(s.classId):void 0,onChange:b=>{i(P=>({...P,classId:b,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Section",required:!0,children:e.jsx(n.Select,{placeholder:"Select Section",options:m,value:s.sectionId?String(s.sectionId):void 0,onChange:b=>i(P=>({...P,sectionId:b})),disabled:!s.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Start Time",required:!0,children:e.jsx(n.TimePicker,{value:o.startTime,onChange:b=>l(P=>({...P,startTime:b})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"End Time",required:!0,children:e.jsx(n.TimePicker,{value:o.endTime,onChange:b=>l(P=>({...P,endTime:b})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(n.InputNumber,{min:1,value:o.duration,onChange:b=>l(P=>({...P,duration:b})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Interval (min)",children:e.jsx(n.InputNumber,{min:0,value:o.interval,onChange:b=>l(P=>({...P,interval:b})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Room No",children:e.jsx(n.Input,{value:o.roomNo,onChange:b=>l(P=>({...P,roomNo:b.target.value}))})}),e.jsx(n.Form.Item,{label:"Tiffin Break",children:e.jsxs(n.Space,{children:[e.jsx(n.Switch,{checked:o.tiffinEnabled,onChange:b=>l(P=>({...P,tiffinEnabled:b}))}),e.jsx(n.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(n.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:b=>l(P=>({...P,tiffinAfterPeriod:b})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(n.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinDuration,onChange:b=>l(P=>({...P,tiffinDuration:b})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(n.Button,{onClick:g,children:"Generate"}),e.jsx(n.Button,{type:"primary",loading:y,onClick:k,children:"Save"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(n.Space,{children:[e.jsx(n.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(n.Select,{style:{width:160},value:s.dayKey,onChange:b=>i(P=>({...P,dayKey:b})),options:Object.keys(za).map(b=>({value:String(b),label:Og(b)}))}),e.jsx(n.Button,{onClick:()=>f(s.dayKey),children:"Add Row"})]}),children:e.jsx(n.Table,{rowKey:(b,P)=>`${s.dayKey}_${P}`,columns:L,dataSource:I,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(n.Tabs,{type:"card",items:[{key:"create",label:"Create",children:B},{key:"routine",label:"Routine",children:e.jsx(Tg,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(Pg,{token:t})}]})]})}function Fg({token:t}){return e.jsx(Eg,{token:t})}function Ug(){return null}const Xt=t=>t??localStorage.getItem("authToken")??"",ur=(t,a)=>{const s=String(t??""),i=String(a??"");return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i},yt={organization:{get:"api/branchapi/generalSettings/getorganizationsettingsData",save:"api/branchapi/generalSettings/addorganizationSetting",currencyDropdown:"api/branchapi/generalSettings/currencyDropdown",countryCodeDropdown:"api/branchapi/generalSettings/contrycodeDropdown",timezoneDropdown:"api/branchapi/generalSettings/timezoneDropdown",boardsDropdown:"api/branchapi/generalSettings/getAffliatedBoardsDropDown",uploadLogo:"api/superAdmin/upload_logo",uploadSignature:"api/branchapi/generalSettings/upload_signature",uploadFirebaseJson:"api/branchapi/generalSettings/firebaseJsonUpload"},academicYear:{table:"api/branchapi/generalSettings/sessiontable",add:"api/branchapi/generalSettings/addsession",setActive:"api/branchapi/generalSettings/setsession",remove:"api/branchapi/generalSettings/deletesession"},feeReceiptSetting:{get:"api/branchapi/generalSettings/feesReceiptSettingData",save:"api/branchapi/generalSettings/feesReceiptSetting"},marksheetSetting:{templateTypes:"api/branchapi/GeneralSettings/getmarkssheetTemplate",classDropdown:"api/exam/exam/getClassforAssignMarksSheetType",assignedTable:"api/branchapi/GeneralSettings/getassign_templete",assign:"api/branchapi/GeneralSettings/assign_templete",remove:"api/branchapi/GeneralSettings/deleteTemplate"},legalPages:{get:"api/branchapi/generalSettings/getlegalpage",termsSave:"api/branchapi/generalSettings/terms",privacySave:"api/branchapi/generalSettings/privacy",aboutSave:"api/branchapi/generalSettings/about_us"},feesInfo:{get:"api/branchapi/generalSettings/getFeesInfo",save:"api/branchapi/generalSettings/addFeesInfo",statesDropdown:"api/superAdmin/states"},payrollSettings:{table:"api/branchapi/GeneralSettings/getsetting_allowances_dedection",add:"api/branchapi/GeneralSettings/addsetting_allowances_dedection",edit:"api/branchapi/GeneralSettings/updatesetting_allowances_dedection",remove:"api/branchapi/GeneralSettings/deletesetting_allowances_dedection",byId:"api/branchapi/GeneralSettings/getsetting_allowances_dedectionById"},paymentGateway:{get:"api/payment_gateway/PaymentProcess/getPaymentGatewayList",save:"api/payment_gateway/PaymentProcess"}},pr=t=>ur(He(),t),$g=()=>ur(He(),"uploads"),hl=t=>ur($g(),t),Ng=async({baseUrl:t,page:a=1,perPage:s=10},i)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(l,Xt(i))},Lg=async(t,a)=>K(t,Xt(a)),rn=async(t,a,s)=>Ee(t,a,Xt(s)),fl=async(t,a,s)=>Be(t,a,Xt(s)),mr=async(t,a,s)=>qe(t,a,Xt(s)),Bg=async(t,a,s)=>ts(t,{arg:a},Xt(s)),yl=async(t,a,s)=>Ya(t,{arg:a},Xt(s)),gl=({baseUrl:t,page:a=1,perPage:s=10,token:i})=>W(i&&t?[t,a,s,i]:null,([l,d,c,y])=>Ng({baseUrl:l,page:d,perPage:c},y)),gt=({url:t,token:a})=>W(a&&t?[t,a]:null,([i,o])=>Lg(i,o)),qg={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function zg({value:t,onChange:a,placeholder:s}){const[i,o]=r.useState(t??""),l=r.useMemo(()=>typeof t=="string"?t:i,[i,t]);return e.jsx("div",{style:qg,children:e.jsx(Jo,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),a?.(c)},style:{outline:"none",minHeight:280},placeholder:s})})}function Vt({title:t,actions:a,children:s,headerExtra:i}){return e.jsx("div",{style:{display:"grid",gap:20},children:s})}const Yg=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function hr({token:t,title:a,fetchUrl:s,saveUrl:i,fieldName:o,initialHtmlFieldName:l}){const d=r.useRef(null),c=gt({url:s,token:t}),h=r.useMemo(()=>Yg(c.data),[c.data])?.[l??o]??"",[u,p]=r.useState("");r.useEffect(()=>{p(typeof h=="string"?h:"")},[h]);const C=()=>p(typeof h=="string"?h:""),S=()=>{const j=new Blob([String(u??"")],{type:"text/html"}),T=URL.createObjectURL(j),R=document.createElement("a");R.href=T,R.download=`${String(a??"legal").toLowerCase().replaceAll(" ","-")}.html`,R.click(),URL.revokeObjectURL(T)},x=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:C},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:S,disabled:!u}],[u,h]),m=async j=>{j.preventDefault();try{(await yl(i,{[o]:u??""},t))?.Status==="Success"?w.success("Updated successfully.",{duration:1e3}):w.success("Updated.",{duration:1e3}),c.mutate?.()}catch(T){w.error(T?.response?.data?.msg??T?.message??"Failed to update.",{duration:1500})}};return c.isLoading&&!c.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:a,actions:x,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:m,children:[e.jsx(zg,{value:u,onChange:p,placeholder:`Enter ${a} content...`}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Update"})})]})})})]})}const Vg=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Wg=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function ha({token:t,value:a,onChange:s,action:i,accept:o,maxCount:l=1,previewUrl:d}){const c=r.useMemo(()=>{if(t)return{Authorization:t}},[t]),y=r.useMemo(()=>a?d||(Wg(a)?a:""):"",[d,a]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[y?e.jsx("img",{src:y,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(n.Upload,{maxCount:l,action:i,accept:o,headers:c,onChange:h=>{if(h?.file?.status==="removed"&&s?.(""),h?.file?.status==="done"){const u=Vg(h?.file?.response);u&&s?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})]})}const Mt=yt.organization,xl=()=>pr(Mt.uploadLogo),Ms=()=>pr(Mt.uploadSignature),Hg=()=>pr(Mt.uploadFirebaseJson),Kg=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],Gg=({token:t})=>gt({url:Mt.get,token:t}),Jg=({token:t})=>gt({url:Mt.currencyDropdown,token:t}),Qg=({token:t})=>gt({url:Mt.countryCodeDropdown,token:t}),Xg=({token:t})=>gt({url:Mt.timezoneDropdown,token:t}),Zg=({token:t})=>gt({url:Mt.boardsDropdown,token:t}),In=t=>Kg(t?.data),lo={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},ex=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),co=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],uo=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],tx=t=>{const a=t?.data;return Array.isArray(a?.data)?a.data[0]??null:Array.isArray(a)?a[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},ax=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,nx=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function sx({token:t}){const a=r.useRef(null),s=Gg({token:t}),i=Jg({token:t}),o=Qg({token:t}),l=Xg({token:t}),d=Zg({token:t}),c=r.useMemo(()=>tx(s.data),[s.data]),y=r.useMemo(()=>ax(s.data),[s.data]),h=r.useMemo(()=>nx(s.data),[s.data]),u=r.useMemo(()=>In(i),[i.data]),p=r.useMemo(()=>In(o),[o.data]),C=r.useMemo(()=>In(l),[l.data]),S=r.useMemo(()=>In(d),[d.data]),[x,m]=r.useState(null),[j,T]=r.useState(null),[R,I]=r.useState(null),[_,A]=r.useState(null),[f,g]=r.useState([]),[D,k]=r.useState("No"),[L,B]=r.useState("yes"),[b,P]=r.useState("no"),[O,F]=r.useState("Yes"),[U,N]=r.useState(""),[Y,z]=r.useState(""),[E,M]=r.useState(null),[$,q]=r.useState(null),[H,re]=r.useState(null),[ee,G]=r.useState(null),J=()=>{const X=(()=>{try{const ce=c?.weekly_off;if(!ce)return[];const Re=Array.isArray(ce)?ce:JSON.parse(ce);return Array.isArray(Re)?Re.filter(Boolean).map(Ue=>({value:Ue,label:Ue})):[]}catch{return[]}})();g(X),m(u.find(ce=>ce?.value===c?.currency)??null),T(p.find(ce=>ce?.value===c?.country_code)??null),I(C.find(ce=>ce?.value===c?.time_zone)??null),A(S.find(ce=>ce?.value===c?.affliated_board_id)??null),N(c?.logo??""),z(c?.json_file??""),k(c?.attendance_salary_calculation??"No"),B(c?.salary_period??"yes"),P(c?.multiple_shift??"no"),F(c?.readmission_charges??"Yes"),M(y?.in_from?ae(y.in_from,"h:mm A"):null),q(y?.in_to?ae(y.in_to,"h:mm A"):null),re(y?.out_from?ae(y.out_from,"h:mm A"):null),G(y?.out_to?ae(y.out_to,"h:mm A"):null)};r.useEffect(()=>{c&&J()},[c,u,p,C,S]);const ie=()=>{a.current?.reset?.(),J()},pe=()=>{const X=new FormData(a.current??void 0),ce=Object.fromEntries(X.entries());ce.weekly_off_day=f.map(Ve=>Ve?.value).filter(Boolean);const Re=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),Ue=URL.createObjectURL(Re),ke=document.createElement("a");ke.href=Ue,ke.download="organization-setting.json",ke.click(),URL.revokeObjectURL(Ue)},_e=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:ie},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:pe,disabled:!c}],[c,f]),le=async X=>{X.preventDefault();try{const ce=new FormData(X.target);ce.set("currency",x?.value??""),ce.set("code",j?.value??""),ce.set("time_zone",R?.value??""),ce.set("affliated_board_id",_?.value??""),ce.set("board_name",_?.label??""),ce.set("attendance_salary_calculation",D),ce.set("salary_period",L),ce.set("multiple_shift",b),ce.set("readmission_charges",O),f.forEach(ke=>{ke?.value&&ce.append("weekly_off_day[]",ke.value)}),ce.set("logo",U??""),ce.set("json_file",Y??""),ce.set("server_key",h?.server_key??""),ce.set("in_time_start",E?ae(E).format("h:mm A"):""),ce.set("in_time_end",$?ae($).format("h:mm A"):""),ce.set("out_time_start",H?ae(H).format("h:mm A"):""),ce.set("out_time_end",ee?ae(ee).format("h:mm A"):""),await rn(Mt.save,ce,t);const Ue={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:U||c?.logo||"",affliated_board_id:_?.value??c?.affliated_board_id??"",board_name:_?.label??c?.board_name??"",multiple_shift:b??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(Ue)),w.success("Organization settings saved.",{duration:1e3}),s.mutate?.()}catch(ce){w.error(ce?.response?.data?.msg??ce?.message??"Failed to save settings.",{duration:1500})}},de=D==="Yes";return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Organization",actions:_e,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:a,onSubmit:le,children:[e.jsxs("div",{style:lo,children:[e.jsx(V,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(Q,{label:"Currency*",options:u,value:x,onChange:X=>m(X)}),e.jsx("input",{type:"hidden",name:"currency",value:x?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Default Country Code*",options:p,value:j,onChange:X=>T(X)}),e.jsx("input",{type:"hidden",name:"code",value:j?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Time Zone*",options:C,value:R,onChange:X=>I(X)}),e.jsx("input",{type:"hidden",name:"time_zone",value:R?.value??""})]}),e.jsx(V,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(V,{type:"number",name:"admission_start_number",label:"Admission Start Number*",required:!0,defaultValue:c?.admission_no_prefix??c?.admission_start_number??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Re-admission Charges"}),e.jsx(n.Radio.Group,{options:co,optionType:"button",buttonStyle:"solid",value:O,onChange:X=>F(X.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:O})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Weekly off Day",options:ex,isMulti:!0,value:f,onChange:X=>g(X??[])}),f.map(X=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:X.value},X.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:E,onChange:X=>M(X),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:E?ae(E).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:$,onChange:X=>q(X),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:$?ae($).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:H,onChange:X=>re(X),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:H?ae(H).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:ee,onChange:X=>G(X),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:ee?ae(ee).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Period"}),e.jsx(n.Radio.Group,{options:uo,optionType:"button",buttonStyle:"solid",value:L,onChange:X=>B(X.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:L})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(n.Radio.Group,{options:co,optionType:"button",buttonStyle:"solid",value:D,onChange:X=>k(X.target.value)}),e.jsx("input",{type:"hidden",name:"attendance_salary_calculation",value:D})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Multiple Shift"}),e.jsx(n.Radio.Group,{options:uo,optionType:"button",buttonStyle:"solid",value:b,onChange:X=>P(X.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:b})]}),de?e.jsx(V,{type:"number",name:"late_absent_day",label:"No of Late",defaultValue:c?.late_absent_day??""}):e.jsx("input",{type:"hidden",name:"late_absent_day",value:""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:lo,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(ha,{token:t,action:xl(),value:U,accept:"image/*",onChange:X=>N(X)}),e.jsx("input",{type:"hidden",name:"logo",value:U??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Select Affiliated Board",options:S,value:_,onChange:X=>A(X)}),e.jsx("input",{type:"hidden",name:"affliated_board_id",value:_?.value??""}),e.jsx("input",{type:"hidden",name:"board_name",value:_?.label??""})]}),e.jsx(st,{label:"Address",name:"address",rows:3,defaultValue:c?.location_name??c?.address??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Json for Notification"}),e.jsx(ha,{token:t,action:Hg(),value:Y,accept:".json",onChange:X=>z(X)}),e.jsx("input",{type:"hidden",name:"json_file",value:Y??""})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function rx({token:t}){return e.jsx(sx,{token:t})}const Wn=yt.academicYear,ix=({token:t,page:a=1,perPage:s=10})=>gl({baseUrl:Wn.table,token:t,page:a,perPage:s}),ox={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},lx=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[],dx=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function cx({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(()=>{const f=ae(),g=ae().add(1,"year");return`${f.format("YYYY")}-${g.format("YYYY")}`}),[c,y]=r.useState(ae()),[h,u]=r.useState(ae().add(1,"year")),{isLoading:p,data:C,mutate:S}=ix({token:t,page:a.page,perPage:a.rowsPerPage}),x=r.useMemo(()=>lx(C),[C]),m=r.useMemo(()=>dx(C,x.length),[C,x.length]),j=async()=>{if(!l){w.error("Session name is required.");return}if(h&&c&&ae(h).isBefore(c)){w.error("End date must be after start date.");return}try{const f=new FormData;f.set("name",l),f.set("start_date",c?ae(c).format("YYYY-MM-DD"):""),f.set("end_date",h?ae(h).format("YYYY-MM-DD"):""),await rn(Wn.add,f,t),w.success("Academic year added.",{duration:1e3}),o(!1),S?.()}catch(f){w.error(f?.response?.data?.msg??f?.message??"Failed to add academic year.",{duration:1500})}},T=async f=>{try{const g=new FormData;g.set("session",String(f)),await fl(Wn.setActive,g,t);const D=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...D,session_id:String(f)})),w.success("Academic year activated.",{duration:1e3}),S?.()}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to activate academic year.",{duration:1500})}},R=async f=>{try{await S(mr(Wn.remove,f,t)),w.success("Academic year deleted.",{duration:1e3})}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to delete academic year.",{duration:1500})}},I=()=>{const f=new Blob([JSON.stringify(x,null,2)],{type:"application/json"}),g=URL.createObjectURL(f),D=document.createElement("a");D.href=g,D.download="academic-years.json",D.click(),URL.revokeObjectURL(g)},_=r.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(te.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:()=>S?.()},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:I,disabled:x.length===0}],[x.length,S]),A=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name"},{title:"Start Date",dataIndex:"start_date",key:"start_date"},{title:"End Date",dataIndex:"end_date",key:"end_date"},{title:"Active",key:"active",render:(f,g)=>{const D=g.status==="Active";return e.jsxs("span",{children:[e.jsx(n.Popconfirm,{title:D?"Deactivate Academic Year?":"Activate Academic Year?",description:D?"Deactivate is not allowed. Activate another session to switch.":"This will set this year as the current academic session.",onConfirm:()=>{D?w.error("Deactivate is not allowed. Activate another session to switch."):T(g.id)},okText:"Yes",cancelText:"No",children:e.jsx(n.Switch,{checked:D})}),D&&e.jsx(n.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(f,g)=>e.jsx(n.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>R(g.id),okText:"Yes",cancelText:"No",children:e.jsx(n.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,x.length]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Academic Year",actions:_,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(n.Table,{rowKey:"id",dataSource:x,columns:A,loading:p,pagination:{current:a.page,pageSize:a.rowsPerPage,total:m,showSizeChanger:!0,onChange:(f,g)=>s({page:f,rowsPerPage:Number(g)})}})})}),e.jsx(n.Modal,{open:i,onCancel:()=>o(!1),footer:null,title:"Add Academic Year",children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:ox,children:[e.jsx(V,{label:"Session Name*",value:l,onChange:f=>d(f.target.value)}),e.jsxs("div",{children:[e.jsx(Me,{Desplay:"Start Date*",value:c,onChange:f=>y(f),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?ae(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(Me,{Desplay:"End Date*",value:h,onChange:f=>u(f),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:h?ae(h).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{value:"Submit",type:"button",onClick:j}),e.jsx(n.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function ux({token:t}){return e.jsx(cx,{token:t})}const bl=yt.feeReceiptSetting,px=({token:t})=>gt({url:bl.get,token:t}),Es={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},mx=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function hx({token:t}){const a=r.useRef(null),s=px({token:t}),i=r.useMemo(()=>mx(s.data),[s.data]),[o,l]=r.useState(""),[d,c]=r.useState(!1),[y,h]=r.useState(!1),[u,p]=r.useState(!1),[C,S]=r.useState("0"),[x,m]=r.useState("0"),[j,T]=r.useState("0"),[R,I]=r.useState(!1),[_,A]=r.useState(!1),[f,g]=r.useState(""),[D,k]=r.useState(!1),L=()=>{l(i?.number_of_receipt??""),c(String(i?.roll_number??"0")==="1"),h(String(i?.address??"0")==="1"),p(String(i?.gardian_name??"0")==="1"),S(String(i?.authorized_signatory??"0")),m(String(i?.parent_signatory??"0")),T(String(i?.dynamic_qr_code_device??"0")),I(String(i?.sequence_payment??"0")==="1"),A(String(i?.previois_fees??"0")==="1"),g(i?.upfront_payment_months??"")};r.useEffect(()=>{i&&L()},[i]);const B=()=>{a.current?.reset?.(),L()},b=()=>{const F={number_of_receipt:o,rollnumber:d?1:0,address:y?1:0,gardianname:u?1:0,authorizedsignatory:C,parentsignatory:x,dynamic_qr_code_device:j,sequence_payment:R?1:0,previois_fees:_?1:0,upfront_payment_months:f},U=new Blob([JSON.stringify(F,null,2)],{type:"application/json"}),N=URL.createObjectURL(U),Y=document.createElement("a");Y.href=N,Y.download="fee-receipt-setting.json",Y.click(),URL.revokeObjectURL(N)},P=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:B},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:b,disabled:!i}],[i,o,d,y,u,C,x,j,R,_,f]),O=async F=>{F.preventDefault(),k(!0);try{const U=new FormData;U.set("number_of_receipt",String(o??"")),U.set("rollnumber",d?"1":"0"),U.set("address",y?"1":"0"),U.set("gardianname",u?"1":"0"),U.set("authorizedsignatory",String(C??"0")),U.set("parentsignatory",String(x??"0")),U.set("dynamic_qr_code_device",String(j??"0")),U.set("sequence_payment",R?"1":"0"),U.set("previois_fees",_?"1":"0"),U.set("upfront_payment_months",String(f??"")),await rn(bl.save,U,t),w.success("Fee receipt settings updated.",{duration:1e3}),s.mutate?.()}catch(U){w.error(U?.response?.data?.msg??U?.message??"Failed to update settings.",{duration:1500})}finally{k(!1)}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Fee Receipt Setting",actions:P,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:a,onSubmit:O,children:[e.jsxs("div",{style:Es,children:[e.jsx(V,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:F=>l(F.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(n.Checkbox,{checked:d,onChange:F=>c(F.target.checked),children:"Show Roll Number in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Address"}),e.jsx(n.Checkbox,{checked:y,onChange:F=>h(F.target.checked),children:"Show address in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Guardian Name"}),e.jsx(n.Checkbox,{checked:u,onChange:F=>p(F.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Es,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(n.Radio.Group,{value:C,onChange:F=>S(F.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Parent Signatory"}),e.jsxs(n.Radio.Group,{value:x,onChange:F=>m(F.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Dynamic QR Code Device"}),e.jsxs(n.Radio.Group,{value:j,onChange:F=>T(F.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Es,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(n.Checkbox,{checked:R,onChange:F=>I(F.target.checked),children:"Student can pay in sequence"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Previous Fees"}),e.jsx(n.Checkbox,{checked:_,onChange:F=>A(F.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(V,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:f,onChange:F=>g(F.target.value)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:D?"Updating...":"Done",disabled:D})})]})})})]})}function fx({token:t}){return e.jsx(hx,{token:t})}const Wa=yt.marksheetSetting,yx=({token:t})=>gt({url:Wa.templateTypes,token:t}),gx=({token:t})=>gt({url:Wa.classDropdown,token:t}),xx=({token:t})=>gt({url:Wa.assignedTable,token:t}),bx={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},po=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],jx=Array.from({length:12},(t,a)=>({value:String(a+1),label:`Design ${a+1}`})),Sx=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function wx({token:t}){const a=r.useRef(null),s=yx({token:t}),i=gx({token:t}),o=xx({token:t}),l=r.useMemo(()=>po(s.data),[s.data]),d=r.useMemo(()=>po(i.data),[i.data]),c=r.useMemo(()=>Sx(o.data),[o.data]),[y,h]=r.useState(null),[u,p]=r.useState(null),[C,S]=r.useState([]),x=()=>{a.current?.reset?.(),h(null),p(null),S([])},m=()=>{const _=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),A=URL.createObjectURL(_),f=document.createElement("a");f.href=A,f.download="marksheet-templates.json",f.click(),URL.revokeObjectURL(A)},j=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:x},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:m,disabled:c.length===0}],[c.length]),T=async _=>{if(_.preventDefault(),!y?.value){w.error("Select marksheet type.",{duration:1200});return}if(!u?.value){w.error("Select design.",{duration:1200});return}if(!C?.length){w.error("Select at least one class.",{duration:1200});return}try{const A=new FormData;A.set("temp_id",String(y.value)),A.set("ui_id",String(u.value)),C.forEach(f=>A.append("class_id[]",String(f))),await rn(Wa.assign,A,t),w.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),x()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to assign template.",{duration:1500})}},R=async _=>{try{await mr(Wa.remove,_,t),w.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to remove template.",{duration:1500})}},I=r.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class"},{title:"Template Name",dataIndex:"name",key:"name"},{title:"Template Design",dataIndex:"ui_id",key:"ui_id"},{title:"Action",key:"action",render:(_,A)=>e.jsx(mt,{id:A?.id,funcName:R})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Marksheet Setting",actions:j,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:a,onSubmit:T,children:[e.jsxs("div",{style:bx,children:[e.jsxs("div",{children:[e.jsx(Q,{label:"Select Marksheet Type",options:l,value:y,onChange:_=>h(_)}),e.jsx("input",{type:"hidden",name:"temp_id",value:y?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Select Design",options:jx,value:u,onChange:_=>p(_)}),e.jsx("input",{type:"hidden",name:"ui_id",value:u?.value??""})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(n.Checkbox.Group,{options:d,value:C,onChange:_=>S(_)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(n.Table,{size:"small",rowKey:"id",columns:I,dataSource:c,pagination:!1})})]})})]})}function vx({token:t}){return e.jsx(wx,{token:t})}const Fs={fetch:`${yt.legalPages.get}?page_name=terms`,save:yt.legalPages.termsSave,fieldName:"terms_data"};function _x({token:t}){return e.jsx(hr,{token:t,title:"Terms",fetchUrl:Fs.fetch,saveUrl:Fs.save,fieldName:Fs.fieldName})}function Cx({token:t}){return e.jsx(_x,{token:t})}const Us={fetch:`${yt.legalPages.get}?page_name=privacy`,save:yt.legalPages.privacySave,fieldName:"privacy_data"};function Ax({token:t}){return e.jsx(hr,{token:t,title:"Privacy",fetchUrl:Us.fetch,saveUrl:Us.save,fieldName:Us.fieldName})}function Dx({token:t}){return e.jsx(Ax,{token:t})}const $s={fetch:`${yt.legalPages.get}?page_name=about_us`,save:yt.legalPages.aboutSave,fieldName:"about_data"};function Tx({token:t}){return e.jsx(hr,{token:t,title:"About",fetchUrl:$s.fetch,saveUrl:$s.save,fieldName:$s.fieldName})}function Rx({token:t}){return e.jsx(Tx,{token:t})}const fr=yt.feesInfo,Ix=({token:t})=>gt({url:fr.get,token:t}),kx=({token:t})=>gt({url:fr.statesDropdown,token:t}),Ns={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Px=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null,Ox=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],Mx=t=>t?hl(`branch/logo/${t}`):"",Ls=t=>t?hl(`branch/signature/${t}`):"";function Ex({token:t}){const a=r.useRef(null),s=Ix({token:t}),i=kx({token:t}),o=r.useMemo(()=>Px(s.data),[s.data]),l=r.useMemo(()=>Ox(i.data),[i.data]),[d,c]=r.useState(null),[y,h]=r.useState(""),[u,p]=r.useState(""),[C,S]=r.useState(""),[x,m]=r.useState(""),j=f=>{const g=new FormData(f),D=Object.fromEntries(g.entries());return D.state_id=d?.value??"",D.fees_receipt_logo=y,D.manager_signature=u,D.principal_signature=C,D.stamp=x,D},T=()=>{c(l.find(f=>String(f?.value)===String(o?.state_id??""))??null),h(o?.fees_receipt_logo??""),p(o?.manager_signature??""),S(o?.principal_signature??""),m(o?.stamp??"")};r.useEffect(()=>{o&&T()},[o,l]);const R=()=>{a.current?.reset?.(),T()},I=()=>{const f=j(a.current),g=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),D=URL.createObjectURL(g),k=document.createElement("a");k.href=D,k.download="fees-info.json",k.click(),URL.revokeObjectURL(D)},_=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:R},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:I,disabled:!o}],[o,d,y,u,C,x]),A=async f=>{f.preventDefault();try{const g=j(f.target);await Bg(fr.save,g,t),w.success("Fees info saved.",{duration:1e3}),s.mutate?.()}catch(g){w.error(g?.response?.data?.msg??g?.message??"Failed to save fees info.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Fees Info",actions:_,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:a,onSubmit:A,children:[e.jsxs("div",{style:Ns,children:[e.jsx(V,{name:"Bussiness_name",label:"Business Name*",defaultValue:o?.name??"",required:!0}),e.jsx(V,{name:"cin",label:"Sub Heading",defaultValue:o?.cin??""}),e.jsx(V,{name:"school_no",type:"number",label:"School Number",defaultValue:o?.school_no??""}),e.jsx(V,{name:"website",label:"Website",defaultValue:o?.website??""}),e.jsx(V,{name:"school_Code",label:"School Code",defaultValue:o?.school_Code??""}),e.jsx(V,{name:"offical_number",label:"Official Number",defaultValue:o?.offical_number??""}),e.jsx(V,{name:"email_id",label:"Email",defaultValue:o?.email_id??""}),e.jsx(V,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:o?.receipt_prefix??""}),e.jsx(V,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:o?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(Q,{label:"State",options:l,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(V,{name:"affiliation_no",label:"Affiliation Number",defaultValue:o?.affiliation_no??""}),e.jsx(V,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:o?.affiliation_desc??""}),e.jsx(V,{name:"udise_code",label:"UDISE Code",defaultValue:o?.udise_code??""}),e.jsx(V,{name:"color_code",label:"Primary Color",defaultValue:o?.color_code??""}),e.jsx(V,{name:"fontcolor_code",label:"Font Color",defaultValue:o?.fontcolor_code??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Ns,children:[e.jsx(st,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(st,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Ns,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(ha,{token:t,action:xl(),value:y,previewUrl:Mx(y),accept:"image/*",onChange:h}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:y})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(ha,{token:t,action:Ms(),value:u,previewUrl:Ls(u),accept:"image/*",onChange:p}),e.jsx("input",{type:"hidden",name:"manager_signature",value:u})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Principal Signature"}),e.jsx(ha,{token:t,action:Ms(),value:C,previewUrl:Ls(C),accept:"image/*",onChange:S}),e.jsx("input",{type:"hidden",name:"principal_signature",value:C})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(ha,{token:t,action:Ms(),value:x,previewUrl:Ls(x),accept:"image/*",onChange:m}),e.jsx("input",{type:"hidden",name:"stamp",value:x})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})})})]})}function Fx({token:t}){return e.jsx(Ex,{token:t})}const Hn=yt.payrollSettings,Ux=({token:t,page:a=1,perPage:s=10})=>gl({baseUrl:Hn.table,token:t,page:a,perPage:s}),$x={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Na=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],Bs=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],Nx=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Lx=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function Bx({token:t}){const a=r.useRef(null),s=r.useRef(null),[i,o]=r.useState({page:1,rowsPerPage:10}),[l,d]=r.useState(!1),[c,y]=r.useState(null),[h,u]=r.useState(Na[0]),[p,C]=r.useState(null),[S,x]=r.useState(null),[m,j]=r.useState(null),T=Ux({token:t,page:i.page,perPage:i.rowsPerPage}),R=r.useMemo(()=>Nx(T.data),[T.data]),I=r.useMemo(()=>Lx(T.data,R.length),[T.data,R.length]),_=async B=>{B.preventDefault();try{const b=new FormData(B.target);b.set("type",h?.value??""),b.set("amount_type",p?.value??""),await rn(Hn.add,b,t),w.success("Payroll setting added.",{duration:1e3}),T.mutate?.(),B.target.reset(),C(null),u(Na[0])}catch(b){w.error(b?.response?.data?.msg??b?.message??"Failed to add payroll setting.",{duration:1500})}},A=B=>{y(B),x(Na.find(b=>b.value===B?.type)??null),j(Bs.find(b=>b.value===B?.amount_type)??null),d(!0)},f=async B=>{B.preventDefault();try{const b=new FormData(B.target);b.set("id",String(c?.id??"")),b.set("type",S?.value??""),b.set("amount_type",m?.value??""),await fl(Hn.edit,b,t),w.success("Payroll setting updated.",{duration:1e3}),d(!1),T.mutate?.()}catch(b){w.error(b?.response?.data?.msg??b?.message??"Failed to update payroll setting.",{duration:1500})}},g=async B=>{try{await mr(Hn.remove,B,t),w.success("Payroll setting deleted.",{duration:1e3}),T.mutate?.()}catch(b){w.error(b?.response?.data?.msg??b?.message??"Failed to delete payroll setting.",{duration:1500})}},D=()=>{const B=new Blob([JSON.stringify(R,null,2)],{type:"application/json"}),b=URL.createObjectURL(B),P=document.createElement("a");P.href=b,P.download="payroll-settings.json",P.click(),URL.revokeObjectURL(b)},k=r.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(te.PlusOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:()=>T.mutate?.()},{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:D,disabled:R.length===0}],[R.length]),L=r.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title"},{title:"Type",dataIndex:"type",key:"type"},{title:"Amount Type",dataIndex:"amount_type",key:"amount_type"},{title:"Amount",dataIndex:"Amount",key:"Amount"},{title:"Action",key:"action",render:(B,b)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>A(b)}),e.jsx(n.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>g(b.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Payroll Settings",actions:k,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:a,onSubmit:_,children:[e.jsxs("div",{style:$x,children:[e.jsx(V,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(Q,{label:"Type",options:Na,value:h,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:h?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Amount Type",options:Bs,value:p,onChange:C}),e.jsx("input",{type:"hidden",name:"amount_type",value:p?.value??""})]}),e.jsx(V,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(ne,{type:"submit",value:"Submit"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(n.Table,{rowKey:"id",columns:L,dataSource:R,loading:T.isLoading,pagination:{current:i.page,pageSize:i.rowsPerPage,total:I,showSizeChanger:!0,onChange:(B,b)=>o({page:B,rowsPerPage:Number(b)})}})})]})}),e.jsx(n.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:s,onSubmit:f,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(Q,{label:"Type",options:Na,value:S,onChange:x}),e.jsx("input",{type:"hidden",name:"type",value:S?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Amount Type",options:Bs,value:m,onChange:j}),e.jsx("input",{type:"hidden",name:"amount_type",value:m?.value??""})]}),e.jsx(V,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Update"})})]})})})]})}function qx({token:t}){return e.jsx(Bx,{token:t})}const jl=yt.paymentGateway,zx=({token:t})=>gt({url:jl.get,token:t}),Yx=[{id:"Razorpay",title:"Razorpay",fields:["keyId","keySecret"]},{id:"PhonePe",title:"Pine Labs",fields:["merchantId","saltKey","saltIndex"]},{id:"Paytm",title:"HDFC",fields:["merchantId","merchantKey"]},{id:"SabPaisa",title:"SabPaisa",fields:["clientCode","transUserName","transUserPassword","authKey","authIV"]}],Wt={Razorpay:{keyId:"",keySecret:"",isActive:!0},PhonePe:{merchantId:"",saltKey:"",saltIndex:"1",isActive:!1},Paytm:{merchantId:"",merchantKey:"",isActive:!1},SabPaisa:{clientCode:"",transUserName:"",transUserPassword:"",authKey:"",authIV:"",isActive:!1}},mo=t=>{const a=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!a?.data)return Wt;try{const s=JSON.parse(a.data||"{}"),i=s?.data&&typeof s.data=="object"?s.data:s;return{Razorpay:{...Wt.Razorpay,...i?.Razorpay??{}},PhonePe:{...Wt.PhonePe,...i?.PhonePe??i?.PineLab??i?.PineLabs??{}},Paytm:{...Wt.Paytm,...i?.Paytm??i?.HDFC??{}},SabPaisa:{...Wt.SabPaisa,...i?.SabPaisa??{}}}}catch{return Wt}};function Vx({token:t}){const a=r.useRef(null),s=zx({token:t}),[i,o]=r.useState(Wt);r.useEffect(()=>{s.data&&o(mo(s.data))},[s.data]);const l=(u,p,C)=>{o(S=>({...S,[u]:{...S[u],[p]:C}}))},d=()=>o(mo(s.data)),c=()=>{const u=new Blob([JSON.stringify(i,null,2)],{type:"application/json"}),p=URL.createObjectURL(u),C=document.createElement("a");C.href=p,C.download="payment-gateway-settings.json",C.click(),URL.revokeObjectURL(p)},y=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:c}],[i,s.data]),h=async u=>{u.preventDefault();try{await yl(jl.save,{data:i},t),w.success("Payment gateway settings saved.",{duration:1e3}),s.mutate?.()}catch(p){w.error(p?.response?.data?.msg??p?.message??"Failed to save gateway settings.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Payment Gateway",actions:y,children:e.jsxs("form",{ref:a,onSubmit:h,style:{display:"grid",gap:20},children:[Yx.map(u=>{const p=i[u.id]??{};return e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u.title}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:500},children:["Enable ",u.title]}),e.jsx(n.Switch,{checked:!!p.isActive,onChange:C=>l(u.id,"isActive",C)})]}),e.jsx(n.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:u.fields.map(C=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:C}),e.jsx(n.Input,{value:p[C]??"",type:C.toLowerCase().includes("secret")||C.toLowerCase().includes("password")?"password":"text",onChange:S=>l(u.id,C,S.target.value)})]},C))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})})]})}function Wx({token:t}){return e.jsx(Vx,{token:t})}const Hx=({routes:t=[],onNavigate:a})=>e.jsx(n.Row,{gutter:[16,16],children:t.map((s,i)=>e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(v,{children:e.jsx(yo,{icon:s?.icon??"",title:s?.title??"",path:s?.path??"",onClick:a})})},`${i}route001`))});exports.About=Rx;exports.AcademicYear=ux;exports.Academics=wy;exports.AddBook=nm;exports.AddDriver=Gp;exports.AddExpense=py;exports.AddHomework=em;exports.AddIncome=iy;exports.AddStaff=wh;exports.AdmissionEnquiry=Du;exports.ApplyLeave=of;exports.AprroveLeaveRequest=Zh;exports.AssignByClass=Gy;exports.AssignStudentSubject=by;exports.AssignStudentToTransport=Kp;exports.AssignSubjects=Wy;exports.AssignTimeGroup=ng;exports.AssignVehicles=Np;exports.AttendanceDashboard=Yf;exports.BookList=sm;exports.BulkUpload=Sy;exports.BuySellProduct=Bm;exports.Category=Im;exports.Class=My;exports.CoScholasticArea=ug;exports.Complain=Cp;exports.CreateTimeGroup=Xy;exports.DailyAttendance=Gf;exports.Department=mf;exports.Designation=yf;exports.ErpDashboard=_l;exports.ExpenseHead=fy;exports.FeeReceiptSetting=fx;exports.FeesInfo=Fx;exports.GatePass=Ep;exports.GeneralSetting=Ug;exports.Holidays=qy;exports.IncomeHead=dy;exports.IssueReturn=im;exports.LeaveType=cf;exports.LibraryAssignStudent=om;exports.LibraryCategory=lm;exports.LibraryRenewalReport=cm;exports.LibraryReport=dm;exports.ManageStock=eh;exports.MarksheetSetting=vx;exports.MedicalReport=gy;exports.MenuSubmenu=du;exports.MonthlyReport=Xf;exports.Notes=yg;exports.NpmReport=ih;exports.Organization=rx;exports.PaymentGateway=Wx;exports.Payroll=Kh;exports.PayrollReceiptDetails=Tf;exports.PayrollSettings=qx;exports.PhoneCallLog=np;exports.PostalDispatch=dp;exports.PostalReceive=fp;exports.Privacy=Dx;exports.Products=Am;exports.PromoteStudents=og;exports.RoutePage=Hx;exports.RouteTimeTable=Jp;exports.SearchExpense=my;exports.SearchIncome=oy;exports.Sections=Ry;exports.SellReports=Qm;exports.SetupFrontOffice=Pp;exports.Shift=bf;exports.StaffAttendance=Nh;exports.StaffAttendanceReport=zh;exports.StaffDailyAttendance=Cf;exports.StaffDirectory=Dh;exports.StockReport=rh;exports.Stoppage=Xp;exports.StudentAttendance=Wf;exports.StudentLoginCredential=yy;exports.SubCategory=Fm;exports.Subjects=$y;exports.SubmissionDetails=tm;exports.Syllabus=Cg;exports.Terms=Cx;exports.TimeTable=Fg;exports.TransferCertificate=Sg;exports.TransportBulkUpload=Zp;exports.TransportRoutes=Fp;exports.TransportVehicles=Up;exports.Unit=Vm;exports.Vendor=xm;exports.VisitorBook=Ku;exports.YearlyReport=ay;exports.getImageBaseUrl=tr;exports.setBaseUrl=oc;exports.setImageBaseUrl=lc;
59
+ `}),e.jsx(v,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(Ct,{data:{tableRef:M}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:M,style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,flexWrap:"wrap",marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#222"},children:[e.jsx("span",{children:"Show"}),e.jsx(n.Select,{size:"small",value:B.rowsPerPage,onChange:ae=>L(1,ae),options:[10,25,50,100].map(ae=>({label:ae,value:ae})),style:{width:72}}),e.jsx("span",{children:"entries"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:12,color:"#222"},children:"Search:"}),e.jsx(n.Input,{size:"small",allowClear:!0,value:j,onChange:ae=>{P(ae.target.value),$(he=>({...he,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(ee.SearchOutlined,{style:{color:"#a3a8cf"}}),style:{width:220,borderWidth:"0 0 1px 0",borderRadius:0,background:"transparent"}})]})]}),e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),xe]}),o&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,marginTop:16,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:`Showing ${fe} to ${je} of ${Be} entries`}),e.jsx(n.Pagination,{current:B.page,pageSize:B.rowsPerPage,total:Be||0,showSizeChanger:!1,onChange:L})]})]})]})},Bu=({token:t,type:a})=>{const[s,r]=i.useState({page:1,rowsPerPage:10}),l="api/branchapi/frontoffice/enquirytablelist",o=l.includes("?")?l.endsWith("?")||l.endsWith("&")?"":"&":"?",d=`${l}${o}page=${s.page}&per_page=${s.rowsPerPage}`,{isLoading:c,data:g,error:y}=H(t?[d,t]:null,([k,O])=>K(k,O)),[p,m]=i.useState(!1),A=(k,O)=>{r({page:k,rowsPerPage:parseInt(O)})},C=async k=>{},b=k=>{console.log("dsdsdsdsd",k),m(k)},f=()=>{},x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],R=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(k,O)=>k.name.localeCompare(O.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(k,O)=>(k.contact||"").localeCompare(O.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(k,O)=>(k.description||"").localeCompare(O.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(k,O)=>(k.source_name||"").localeCompare(O.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(k,O)=>new Date(k.date)-new Date(O.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(k,O)=>new Date(k.follow_up_date)-new Date(O.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Ie,{parentCallback:A,data:{newData:g,columns:R,action:!0,Loading:c,error:y,open:p,viewDetails:f,deleteTodoMutation:C,DrawerUpdate:b,ActionView:x}})})};var Lu=Ql();const As=Kl(Lu),ao=()=>{};class lr extends i.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=a=>{this.selectRef=a};componentDidUpdate(a){a.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(a,s)=>{this.props.onChange(a,s),this.setState({value:a})};getValue=()=>{const{value:a}=this.state;return a?Array.isArray(a)?a.length?"valid":"":typeof a=="object"?a.value||"":a:""};render(){const{SelectComponent:a,required:s,...r}=this.props,{isDisabled:l}=this.props,o=!l;return e.jsxs("div",{children:[e.jsx(a,{...r,ref:this.setSelectRef,onChange:this.onChange}),o&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:ao,onFocus:()=>this.selectRef.focus(),required:s})]})}}lr.defaultProps={onChange:ao};lr.protoTypes={selectComponent:As.func.isRequired,onChange:As.func,required:As.bool};const qu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},zu={menuPortal:t=>({...t,zIndex:9999}),control:(t,a)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#a8a8a8"}`}}),valueContainer:t=>({...t,height:40,padding:"0 0",display:"flex",alignItems:"center"}),input:t=>({...t,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),indicatorsContainer:t=>({...t,height:40}),dropdownIndicator:(t,a)=>({...t,padding:"0 0 0 8px",color:a.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,a)=>({...t,fontSize:"14px",backgroundColor:a.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},no=t=>e.jsx(yl.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),Yu=t=>e.jsx(lr,{...t,SelectComponent:yl,components:{Input:no},options:t.options}),Q=i.forwardRef(({...t},a)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:qu,children:t?.label}),e.jsx(Yu,{components:{Input:no},menuPortalTarget:document.body,styles:zu,className:"input-cont",...t,ref:a})]})),Vu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Wu={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Hu=(t,a,s)=>a?t>te(s).endOf("day")||t<te(a).endOf("day"):!1,Ue=i.forwardRef(function(a,s){const{...r}=a;return e.jsxs("div",{className:"form-group",children:[r.Desplay&&e.jsx("label",{className:`labelfont ${r.classnme?r.classnme:""}`,style:Vu,children:r.Desplay}),e.jsx(n.DatePicker,{...r,style:{...Wu,...r.style||{}},className:"form-group",disabledDate:l=>Hu(l,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:s})]})}),Ku={minWidth:160,height:36,padding:"0 28px",border:"none",borderRadius:999,background:"linear-gradient(90deg, #f59b1c 0%, #ef3e7b 100%)",color:"#fff",fontSize:14,fontWeight:700,textTransform:"uppercase",cursor:"pointer",boxShadow:"none"},ne=i.forwardRef(({error:t,success:a,disabled:s,loading:r,style:l,...o},d)=>e.jsxs("div",{className:"form-group",style:{marginBottom:0,position:"relative"},children:[e.jsx("input",{...o,ref:d,disabled:s||r,style:{...Ku,opacity:s||r?.7:1,cursor:s||r?"not-allowed":"pointer",...l||{}}}),r?e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",opacity:.8,children:e.jsx("animateTransform",{attributeName:"transform",type:"rotate",dur:"0.8s",values:"0 0 0 0;360 0 0 0",repeatCount:"indefinite",children:e.jsx("circle",{cx:"8",cy:"8",r:"6",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeDasharray:"60",strokeLinecap:"round",children:e.jsx("animate",{attributeName:"stroke-dashoffset",type:"subtract",from:"60",to:"0",dur:"0.8s",repeatCount:"indefinite"})})})})}):null]})),Gu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ju={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"},lt=({style:t,onFocus:a,onBlur:s,...r})=>{const[l,o]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:Gu,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{o(!0),a?.(d)},onBlur:d=>{o(!1),s?.(d)},style:{...Ju,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})},Ge=t=>({optimisticData:a=>[...a.data,t],populateCache:(a,s)=>[...s.data,a]}),ze=t=>({optimisticData:a=>a.data.filter(s=>s.id!==t),populateCache:(a,s)=>s.data.filter(r=>r.id!==t)}),Qu=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Xu="api/branchapi/Frontoffice/visitorbookShowdata",Zu="api/branchapi/Frontoffice/purposedropdown";function ep({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Tt),l=Xu.replace(/\?.*$/,""),{isLoading:o,data:d}=H(s&&r?[l,r,s]:null,([f,x,R])=>Sa(f,{id:x},R)),{isLoading:c,data:g}=H(s?[Zu,s]:null,([f,x])=>K(f,x)),y=i.useMemo(()=>Qu(g),[g]),p=d?.data?.[0],[m,A]=i.useState({purpose:void 0,name:"",phone:"",id_card:"",number_of_person:1,date:null,in_time:null,out_time:null,note:"",address:"",image:""});i.useEffect(()=>{p&&A({purpose:p?.purpose,name:p?.name||"",phone:p?.contact||"",id_card:p?.id_proof||"",number_of_person:p?.no_of_pepple||1,date:p?.date?te(p.date):null,in_time:p?.in_time?te(p.in_time,"h:mm a"):null,out_time:p?.out_time?te(p.out_time,"h:mm a"):null,note:p?.note||"",address:p?.address||"",image:p?.image||""})},[p]);const C=(f,x)=>{A(R=>({...R,[f]:x}))},b=`${bt()}/branchapi/frontoffice/uploadfrontofficeDocument`;return o||c?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:f=>a(f,r),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Visitor"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",allowSelectAll:!1,value:m.purpose,onChange:f=>C("purpose",f)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"name",type:"text",label:"Name",required:!0,value:m.name,onChange:f=>C("name",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"phone",type:"text",label:"Phone No.",required:!0,value:m.phone,onChange:f=>C("phone",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"id_card",type:"text",label:"ID Card",value:m.id_card,onChange:f=>C("id_card",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"number_of_person",type:"number",label:"Number of Person",value:m.number_of_person,onChange:f=>C("number_of_person",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:m.date,Desplay:"Date",id:"date",name:"date",required:!0,onChange:f=>C("date",f)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:m.in_time,onChange:f=>C("in_time",f),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:m.in_time?m.in_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:m.out_time,onChange:f=>C("out_time",f),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time",value:m.out_time?m.out_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note",value:m.note,onChange:f=>C("note",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(lt,{type:"text",label:"Address",name:"address",rows:3,required:!0,value:m.address,onChange:f=>C("address",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:b,headers:{Authorization:s},maxCount:1,onChange:f=>{if(f.file.status==="removed"&&C("image",""),f.file.status==="done"){const x=f.file.response?.data??f.file.response?.file??"";C("image",String(x??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:m.image?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:m.image||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; }"})]})}const tp=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},ra="api/branchapi/Frontoffice/visitortablelist",ap="api/branchapi/Frontoffice/purposedropdown",np="api/branchapi/frontoffice/addvisitors",sp="api/branchapi/frontoffice/editvisitorsdata",rp="api/branchapi/frontoffice/deletevisitors",ip=`${bt()}/branchapi/frontoffice/uploadfrontofficeDocument`;function lp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState("03:30 PM"),m=(T,U)=>{s({page:T,rowsPerPage:Number.parseInt(U,10)})},A=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],C=i.useMemo(()=>{const T=ra.includes("?")?ra.endsWith("?")||ra.endsWith("&")?"":"&":"?";return`${ra}${T}page=${a.page}&per_page=${a.rowsPerPage}`},[ra,a.page,a.rowsPerPage]),{isLoading:b,error:f,data:x,mutate:R}=H(t?[C,t]:null,([T,U])=>K(T,U)),{isLoading:k,data:O}=H(t?[ap,t]:null,([T,U])=>K(T,U)),D=i.useMemo(()=>tp(O),[O]),_=async(T,U)=>{try{await R(Ne(T,U,t),Ge(U)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},u=async T=>{try{await R(He(rp,T,t),ze(T)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},h=async(T,U,j)=>{try{const P=await We(T,U,t);R(P),Array.isArray(P?.data)&&R(`${ra.replace(/\?.*$/,"")}?id=${j}`,P),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},S=async(T,U)=>{T.preventDefault();const j=new FormData(T.target);await h(sp,j,U),T.target.reset(),d(""),l(!1)},E=async T=>{if(T.preventDefault(),!T.target?.date?.value)w.error("Select required dates"),T.target?.date?.focus(),g("textDanger");else{const U=new FormData(T.target);await _(np,U),T.target.reset(),g(""),d(""),p("03:30 PM")}},F=T=>{l(T)},q=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Address",selector:"address",sortable:!0},{id:"5",name:"In Time",selector:"in_time",sortable:!0},{id:"6",name:"Out Time",selector:"out_time",sortable:!0}],[]);return e.jsxs("div",{children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Visitor"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:E,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone No.",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"id_card",type:"text",label:"ID Card"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{defaultValue:1,name:"number_of_person",type:"number",label:"Number of Person"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.TimePicker,{defaultValue:te("2022-04-17T15:30","h:mm a"),id:"in_time",use12Hours:!0,format:"h:mm a",onChange:(T,U)=>p(U),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:y,readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(lt,{type:"text",label:"Address*",name:"address",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:ip,headers:{Authorization:t},maxCount:1,onChange:T=>{if(T.file.status==="removed"&&d(""),T.file.status==="done"){const U=T.file.response?.data??T.file.response?.file??"";d(String(U??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:o?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:o||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Visitor List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:m,data:{newData:x,columns:q,action:!0,ActionView:A,Loading:b,error:f,editDesign:e.jsx(ep,{data:{handleUpdate:S,token:t}}),deleteTodoMutation:u,open:r,DrawerUpdate:F,viewDetails:""}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const op="api/branchapi/frontoffice/generalcallsShowdata",dp=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}];function cp({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Tt),l=op.replace(/\?.*$/,""),{isLoading:o,data:d}=H(s&&r?[l,r,s]:null,([m,A,C])=>Sa(m,{id:A},C)),c=d?.data?.[0],[g,y]=i.useState({name:"",phone:"",description:"",date:null,next_follow_up_date:null,call_duration:"",note:"",call_type:""});i.useEffect(()=>{c&&y({name:c?.name||"",phone:c?.contact||"",description:c?.description||"",date:c?.date?te(c.date):null,next_follow_up_date:c?.follow_up_date?te(c.follow_up_date):null,call_duration:c?.call_dureation||"",note:c?.note||"",call_type:c?.call_type||""})},[c]);const p=(m,A)=>{y(C=>({...C,[m]:A}))};return o?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,r),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Call Log"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"name",type:"text",label:"Name",required:!0,value:g.name,onChange:m=>p("name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",value:g.phone,onChange:m=>p("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description",value:g.description,onChange:m=>p("description",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:m=>p("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:g.next_follow_up_date,Desplay:"Next Follow Up Date",id:"fdate",name:"next_follow_up_date",onChange:m=>p("next_follow_up_date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"call_duration",type:"text",label:"Call Duration",value:g.call_duration,onChange:m=>p("call_duration",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note",value:g.note,onChange:m=>p("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:dp,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:g.call_type?{value:g.call_type,label:g.call_type}:null,onChange:m=>p("call_type",m?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ia="api/branchapi/frontoffice/generalcalltablelist",up="api/branchapi/frontoffice/addgenaralcalls",pp="api/branchapi/frontoffice/editgeneralcall",mp="api/branchapi/frontoffice/deletegeneralcall",hp=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}],fp=[{key:"all",label:"All Calls"},{key:"Incoming",label:"Incoming"},{key:"Outgoing",label:"Outgoing"}];function yp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState("all"),[m,A]=i.useState(""),C=i.useRef(null),b=(T,U)=>{s({page:T,rowsPerPage:Number.parseInt(U,10)})},f=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],x=i.useMemo(()=>{const T=ia.includes("?")?ia.endsWith("?")||ia.endsWith("&")?"":"&":"?",U=new URLSearchParams;return U.set("page",String(a.page)),U.set("per_page",String(a.rowsPerPage)),y!=="all"&&U.set("call_type",y),`${ia}${T}${U.toString()}`},[ia,a.page,a.rowsPerPage,y]),{isLoading:R,error:k,data:O,mutate:D}=H(t?[x,t]:null,([T,U])=>K(T,U)),_=async(T,U)=>{try{await D(Ne(T,U,t),Ge(U)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},u=async T=>{try{await D(He(mp,T,t),ze(T)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},h=async(T,U,j)=>{try{const P=await We(T,U,t);D(P),Array.isArray(P?.data)&&D(`${ia.replace(/\?.*$/,"")}?id=${j}`,P),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},S=async(T,U)=>{T.preventDefault();const j=new FormData(T.target);await h(pp,j,U),T.target.reset(),d(""),l(!1)},E=async T=>{if(T.preventDefault(),!T.target?.date?.value)w.error("Select required dates"),T.target?.date?.focus(),g("textDanger");else{const U=new FormData(T.target);await _(up,U),T.target.reset(),g(""),d(""),A("")}},F=T=>{l(T)},q=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Phone",selector:"contact",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Follow Up Date",selector:"follow_up_date",sortable:!0},{id:"6",name:"Call Duration",selector:"call_dureation",sortable:!0}],[]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Phone Call Log"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:E,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",Desplay:"Next Follow Up Date",id:"fdate",name:"follow_up_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"call_dureation",type:"text",label:"Call Duration"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:hp,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:m?{value:m,label:m}:null,onChange:T=>A(T?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Phone Call Log List"})}),e.jsxs(v,{pt:3,children:[e.jsx(n.Tabs,{activeKey:y,onChange:p,items:fp}),e.jsx(Ct,{data:{tableRef:C}}),e.jsx(Ie,{parentCallback:b,data:{newData:O,columns:q,action:!0,ActionView:f,Loading:R,error:k,editDesign:e.jsx(cp,{data:{handleUpdate:S,token:t}}),deleteTodoMutation:u,open:r,DrawerUpdate:F,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const gp="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function xp({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Tt),l=gp.replace(/\?.*$/,""),{isLoading:o,data:d}=H(s&&r?[l,r,s]:null,([m,A,C])=>Sa(m,{id:A},C)),c=d?.data?.[0],[g,y]=i.useState({to_title:"",refernce:"",address:"",note:"",from_title:"",date:null,image:""});i.useEffect(()=>{c&&y({to_title:c?.to_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",from_title:c?.from_title||"",date:c?.date?te(c.date):null,image:c?.image||""})},[c]);const p=(m,A)=>{y(C=>({...C,[m]:A}))};return o?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,r),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Dispatch"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"title",type:"text",label:"To Title *",required:!0,value:g.to_title,onChange:m=>p("to_title",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"refernce",type:"text",label:"Reference No",value:g.refernce,onChange:m=>p("refernce",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:m=>p("address",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note",value:g.note,onChange:m=>p("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"from_title",type:"text",label:"From Title",required:!0,value:g.from_title,onChange:m=>p("from_title",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:m=>p("date",m)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const la="api/branchapi/frontoffice/postaldispatchtablelist",bp="api/branchapi/frontoffice/addpostaldispatch",jp="api/branchapi/frontoffice/editpostaldispatch",Sp="api/branchapi/frontoffice/deletepostalreceivedispatch";function vp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),y=i.useRef(null),p=(S,E)=>{s({page:S,rowsPerPage:Number.parseInt(E,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],A=i.useMemo(()=>{const S=la.includes("?")?la.endsWith("?")||la.endsWith("&")?"":"&":"?";return`${la}${S}page=${a.page}&per_page=${a.rowsPerPage}`},[la,a.page,a.rowsPerPage]),{isLoading:C,error:b,data:f,mutate:x}=H(t?[A,t]:null,([S,E])=>K(S,E)),R=async(S,E)=>{try{await x(Ne(S,E,t),Ge(E)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},k=async S=>{try{await x(He(Sp,S,t),ze(S)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},O=async(S,E,F)=>{try{const q=await We(S,E,t);x(q),Array.isArray(q?.data)&&x(`${la.replace(/\?.*$/,"")}?id=${F}`,q),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},D=async(S,E)=>{S.preventDefault();const F=new FormData(S.target);await O(jp,F,E),S.target.reset(),d(""),l(!1)},_=async S=>{if(S.preventDefault(),!S.target?.date?.value)w.error("Select required dates"),S.target?.date?.focus(),g("textDanger");else{const E=new FormData(S.target);await R(bp,E),S.target.reset(),g(""),d("")}},u=S=>{l(S)},h=i.useMemo(()=>[{id:"1",name:"To Title",selector:"to_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"From Title",selector:"from_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Dispatch"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:_,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:"title",type:"text",label:"To Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:"from_title",type:"text",label:"From Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx("input",{type:"hidden",name:"image",value:o||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Dispatch List"})}),e.jsxs(v,{pt:3,children:[e.jsx(Ct,{data:{tableRef:y}}),e.jsx(Ie,{parentCallback:p,data:{newData:f,columns:h,action:!0,ActionView:m,Loading:C,error:b,editDesign:e.jsx(xp,{data:{handleUpdate:D,token:t}}),deleteTodoMutation:k,open:r,DrawerUpdate:u,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const wp="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function _p({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Tt),l=wp.replace(/\?.*$/,""),{isLoading:o,data:d}=H(s&&r?[l,r,s]:null,([m,A,C])=>Sa(m,{id:A},C)),c=d?.data?.[0],[g,y]=i.useState({from_title:"",refernce:"",address:"",note:"",title:"",date:null,image:""});i.useEffect(()=>{c&&y({from_title:c?.from_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",title:c?.to_title||"",date:c?.date?te(c.date):null,image:c?.image||""})},[c]);const p=(m,A)=>{y(C=>({...C,[m]:A}))};return o?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,r),children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Receive"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"from_title",type:"text",label:"From Title *",required:!0,value:g.from_title,onChange:m=>p("from_title",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"refernce",type:"text",label:"Reference No",required:!0,value:g.refernce,onChange:m=>p("refernce",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:m=>p("address",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note",value:g.note,onChange:m=>p("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"title",type:"text",label:"To Title",required:!0,value:g.title,onChange:m=>p("title",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:m=>p("date",m)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const oa="api/branchapi/frontoffice/postalrecivetablelist",Cp="api/branchapi/frontoffice/addpostalrecive",Ap="api/branchapi/frontoffice/editpostalrecive",Dp="api/branchapi/frontoffice/deletepostalreceivedispatch";function Tp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),y=i.useRef(null),p=(S,E)=>{s({page:S,rowsPerPage:Number.parseInt(E,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],A=i.useMemo(()=>{const S=oa.includes("?")?oa.endsWith("?")||oa.endsWith("&")?"":"&":"?";return`${oa}${S}page=${a.page}&per_page=${a.rowsPerPage}`},[oa,a.page,a.rowsPerPage]),{isLoading:C,error:b,data:f,mutate:x}=H(t?[A,t]:null,([S,E])=>K(S,E)),R=async(S,E)=>{try{await x(Ne(S,E,t),Ge(E)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},k=async S=>{try{await x(He(Dp,S,t),ze(S)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},O=async(S,E,F)=>{try{const q=await We(S,E,t);x(q),Array.isArray(q?.data)&&x(`${oa.replace(/\?.*$/,"")}?id=${F}`,q),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},D=async(S,E)=>{S.preventDefault();const F=new FormData(S.target);await O(Ap,F,E),S.target.reset(),d(""),l(!1)},_=async S=>{if(S.preventDefault(),!S.target?.date?.value)w.error("Select required dates"),S.target?.date?.focus(),g("textDanger");else{const E=new FormData(S.target);await R(Cp,E),S.target.reset(),g(""),d("")}},u=S=>{l(S)},h=i.useMemo(()=>[{id:"1",name:"From Title",selector:"from_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"To Title",selector:"to_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Receive"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:_,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:"from_title",type:"text",label:"From Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:"title",type:"text",label:"To Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx("input",{type:"hidden",name:"image",value:o||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Receive List"})}),e.jsxs(v,{pt:3,children:[e.jsx(Ct,{data:{tableRef:y}}),e.jsx(Ie,{parentCallback:p,data:{newData:f,columns:h,action:!0,ActionView:m,Loading:C,error:b,editDesign:e.jsx(_p,{data:{handleUpdate:D,token:t}}),deleteTodoMutation:k,open:r,DrawerUpdate:u,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Rp="api/branchapi/frontoffice/complaintShowdata",Ip="api/branchapi/frontoffice/complainttypedropdown",kp=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Pp({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Tt),l=Rp.replace(/\?.*$/,""),{isLoading:o,data:d}=H(s&&r?[l,r,s]:null,([f,x,R])=>Sa(f,{id:x},R)),{isLoading:c,data:g}=H(s?[Ip,s]:null,([f,x])=>K(f,x)),y=i.useMemo(()=>kp(g).map(x=>({value:x?.value??x?.id??x?.complaint_type??"",label:x?.complaint_type??x?.label??""})),[g]),p=d?.data?.[0],[m,A]=i.useState({complain_type:"",complain_by_name:"",phone:"",date:null,description:"",action_token:"",assigned:"",note:"",file:""});i.useEffect(()=>{p&&A({complain_type:p?.complaint_type??"",complain_by_name:p?.name??"",phone:p?.contact??"",date:p?.date?te(p.date):null,description:p?.description??"",action_token:p?.action_taken??"",assigned:p?.assigned??"",note:p?.note??"",file:p?.image??""})},[p]);const C=(f,x)=>{A(R=>({...R,[f]:x}))},b=i.useMemo(()=>y.find(f=>f.value===m.complain_type)||null,[y,m.complain_type]);return o||c?e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsx(v,{pt:4,pb:1,style:{width:550},children:e.jsxs("form",{onSubmit:f=>a(f,r),children:[e.jsx("input",{type:"hidden",name:"id",value:r??""}),e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Complaint"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",allowSelectAll:!1,value:b,onChange:f=>C("complain_type",f?.value??"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0,value:m.complain_by_name,onChange:f=>C("complain_by_name",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{10}",value:m.phone,onChange:f=>C("phone",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:m.date,Desplay:"Enquiry Date",id:"date",name:"date",onChange:f=>C("date",f)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description",value:m.description,onChange:f=>C("description",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"action_token",type:"text",label:"Action Taken",value:m.action_token,onChange:f=>C("action_token",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"assigned",type:"text",label:"Assigned",value:m.assigned,onChange:f=>C("assigned",f.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note",value:m.note,onChange:f=>C("note",f.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})]})})}const da="api/branchapi/frontoffice/complainttablelist",Op="api/branchapi/frontoffice/complainttypedropdown",Mp="api/branchapi/frontoffice/addcomplaint",Ep="api/branchapi/frontoffice/editcomplaint",$p="api/branchapi/frontoffice/deletecomplaint",Fp=[{key:"all",label:"All Complaints"},{key:"pending",label:"Pending"},{key:"resolved",label:"Resolved"}];function Up({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState("all"),m=i.useRef(null),A=(U,j)=>{s({page:U,rowsPerPage:Number.parseInt(j,10)})},C=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],b=i.useMemo(()=>{const U=da.includes("?")?da.endsWith("?")||da.endsWith("&")?"":"&":"?",j=new URLSearchParams;return j.set("page",String(a.page)),j.set("per_page",String(a.rowsPerPage)),y!=="all"&&j.set("status",y),`${da}${U}${j.toString()}`},[da,a.page,a.rowsPerPage,y]),{isLoading:f,error:x,data:R,mutate:k}=H(t?[b,t]:null,([U,j])=>K(U,j)),{isLoading:O,data:D}=H(t?[Op,t]:null,([U,j])=>K(U,j)),_=i.useMemo(()=>{const U=D?.data??D??[];return Array.isArray(U)?U:Array.isArray(U?.data)?U.data:[]},[D]),u=async(U,j)=>{try{await k(Ne(U,j,t),Ge(j)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},h=async U=>{try{await k(He($p,U,t),ze(U)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},S=async(U,j,P)=>{try{const I=await We(U,j,t);k(I),Array.isArray(I?.data)&&k(`${da.replace(/\?.*$/,"")}?id=${P}`,I),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},E=async(U,j)=>{U.preventDefault();const P=new FormData(U.target);await S(Ep,P,j),U.target.reset(),d(""),l(!1)},F=async U=>{if(U.preventDefault(),!U.target?.date?.value)w.error("Select required dates"),U.target?.date?.focus(),g("textDanger");else{const j=new FormData(U.target);await u(Mp,j),U.target.reset(),g(""),d("")}},q=U=>{l(U)},T=i.useMemo(()=>[{id:"1",name:"Complain Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Action Taken",selector:"action_taken",sortable:!0},{id:"6",name:"Assigned",selector:"assigned",sortable:!0}],[]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Complaint"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:F,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Complain Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"action_token",type:"text",label:"Action Taken"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"assigned",type:"text",label:"Assigned"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx("input",{type:"hidden",name:"file",value:o||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Complaint List"})}),e.jsxs(v,{pt:3,children:[e.jsx(n.Tabs,{activeKey:y,onChange:p,items:Fp}),e.jsx(Ct,{data:{tableRef:m}}),e.jsx(Ie,{parentCallback:A,data:{newData:R,columns:T,action:!0,ActionView:C,Loading:f,error:x,editDesign:e.jsx(Pp,{data:{handleUpdate:E,token:t}}),deleteTodoMutation:h,open:r,DrawerUpdate:q,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Qr="api/branchapi/Frontoffice/purposetablelist",Np="api/branchapi/Frontoffice/complaint_typetablelist",Bp="api/branchapi/Frontoffice/sourcetablelist",Lp="api/branchapi/Frontoffice/referencetablelist",Xr="api/branchapi/frontoffice/visitorpurposeShowdata",qp="api/branchapi/frontoffice/complaintTypeShowdata",zp="api/branchapi/frontoffice/sourceShowdata",Yp="api/branchapi/frontoffice/referenceShowdata",fa=[{key:"purpose",label:"Purpose"},{key:"complainType",label:"Complain Type"},{key:"source",label:"Source"},{key:"reference",label:"Reference"}],Zr={purpose:[{id:"1",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],complainType:[{id:"1",name:"Complaint Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],source:[{id:"1",name:"Source",selector:"source",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],reference:[{id:"1",name:"Reference",selector:"reference",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}]};function Vp({token:t}){const[a,s]=i.useState("purpose"),[r,l]=i.useState({page:1,rowsPerPage:10}),[o,d]=i.useState(!1),c=i.useRef(null),g=(F,q)=>{l({page:F,rowsPerPage:Number.parseInt(q,10)})},y=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],p=()=>{switch(a){case"purpose":return Qr;case"complainType":return Np;case"source":return Bp;case"reference":return Lp;default:return Qr}},m=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/addvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/addcomplaint_type";case"source":return"api/branchapi/frontoffice/addsource";case"reference":return"api/branchapi/frontoffice/addreference";default:return"api/branchapi/frontoffice/addvisitors_purpose"}},A=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/editvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/editcomplaint_type";case"source":return"api/branchapi/frontoffice/editsource";case"reference":return"api/branchapi/frontoffice/editreference";default:return"api/branchapi/frontoffice/editvisitors_purpose"}},C=F=>{switch(a){case"purpose":return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:F};case"complainType":return{url:"api/branchapi/frontoffice/deletecomplaint_type",id:F};case"source":return{url:"api/branchapi/frontoffice/deletesource",id:F};case"reference":return{url:"api/branchapi/frontoffice/deletereference",id:F};default:return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:F}}},b=i.useMemo(()=>{const F=p(),q=F.includes("?")?F.endsWith("?")||F.endsWith("&")?"":"&":"?";return`${F}${q}page=${r.page}&per_page=${r.rowsPerPage}`},[a,r.page,r.rowsPerPage]),{isLoading:f,error:x,data:R,mutate:k}=H(t?[b,t]:null,([F,q])=>K(F,q)),O=async(F,q)=>{try{await k(Ne(F,q,t),Ge(q)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},D=async F=>{const{url:q,id:T}=C(F);try{await k(He(q,T,t),ze(T)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},_=async(F,q,T)=>{try{const U=await We(F,q,t);k(U),Array.isArray(U?.data)&&k(`${p().replace(/\?.*$/,"")}?id=${T}`,U),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},u=async(F,q)=>{F.preventDefault();const T=new FormData(F.target),U=A();await _(U,T,q),F.target.reset(),d(!1)},h=async F=>{F.preventDefault();const q=new FormData(F.target),T=m();await O(T,q),F.target.reset()},S=F=>{d(F)},E=i.useMemo(()=>Zr[a]||Zr.purpose,[a]);return e.jsx(v,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Setup Front Office"})}),e.jsxs(v,{p:3,children:[e.jsx(n.Tabs,{activeKey:a,onChange:F=>{s(F),l({page:1,rowsPerPage:10})},items:fa}),e.jsxs(n.Row,{gutter:[16,16],mt:3,children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx("form",{onSubmit:h,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Add ",fa.find(F=>F.key===a)?.label]})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{required:!0,name:a==="reference"?"title":"name",type:"text",label:fa.find(F=>F.key===a)?.label+" *"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})})})]})})]})})}),e.jsx(n.Col,{xs:24,md:16,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:[fa.find(F=>F.key===a)?.label," List"]})}),e.jsxs(v,{pt:3,children:[e.jsx(Ct,{data:{tableRef:c}}),e.jsx(Ie,{parentCallback:g,data:{newData:R,columns:E,action:!0,ActionView:y,Loading:f,error:x,editDesign:e.jsx(Wp,{data:{handleUpdate:u,token:t,activeTab:a}}),deleteTodoMutation:D,open:o,DrawerUpdate:S,viewDetails:""}})]})]})})]})]})]})})})})}function Wp({data:t}){const{handleUpdate:a,token:s,activeTab:r}=t||{},l=i.useContext(Tt),d=(f=>{switch(f){case"purpose":return Xr;case"complainType":return qp;case"source":return zp;case"reference":return Yp;default:return Xr}})(r).replace(/\?.*$/,""),{isLoading:c,data:g}=H(s&&l?[d,l,s]:null,([f,x,R])=>Sa(f,{id:x},R)),y=g?.data?.[0],[p,m]=i.useState({name:"",description:""});i.useEffect(()=>{y&&m({name:y?.visitors_purpose||y?.complaint_type||y?.source||y?.reference||"",description:y?.description||""})},[y]);const A=(f,x)=>{m(R=>({...R,[f]:x}))};if(c)return e.jsx(v,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})});const b={purpose:"title",complainType:"title",source:"title",reference:"title"}[r]||"name";return e.jsxs(v,{pt:4,pb:1,style:{width:350},children:[e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Edit ",fa.find(f=>f.key===r)?.label]})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:f=>a(f,l),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{type:"text",value:l,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{name:b,type:"text",label:fa.find(f=>f.key===r)?.label+" *",required:!0,value:p.name,onChange:f=>A("name",f.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description",value:p.description,onChange:f=>A("description",f.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})]})})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Hp="api/branchapi/Student/studentGatePass",Ra="api/branchapi/Student/studentGatePassList";function Kp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:25}),[r,l]=i.useState(!1),o=i.useRef(null),d=(O,D)=>{s({page:O,rowsPerPage:Number.parseInt(D,10)})},c=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],{data:g,mutate:y}=H(t?[Hp,t]:null,([O,D])=>K(O,D)),p=i.useMemo(()=>{const O=Ra.includes("?")?Ra.endsWith("?")||Ra.endsWith("&")?"":"&":"?";return`${Ra}${O}page=${a.page}&per_page=${a.rowsPerPage}`},[Ra,a.page,a.rowsPerPage]),{isLoading:m,error:A,data:C,mutate:b}=H(t?[p,t]:null,([O,D])=>K(O,D)),f=async O=>{const D="api/branchapi/frontoffice/deletevisitors";try{await b(deleteData(D,O,t),ze(O)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},x=O=>{l(O)},R=()=>{},k=[{title:"Name",dataIndex:"lastname",key:"lastname",render:(O,D)=>`${D?.lastname||""} ${D?.firstname||""}`.trim()},{title:"Class",dataIndex:"class_name",key:"class_name",render:(O,D)=>`${D?.class_name||""}-${D?.section_name||""}`},{title:"Father Name",dataIndex:"father_name",key:"father_name"},{title:"Authorized Persons",dataIndex:"authorized_persons_fullname",key:"authorized_persons_fullname"},{title:"Relation",dataIndex:"authorized_persons_relation",key:"authorized_persons_relation"},{title:"Generated Date",dataIndex:"genrated_date_time",key:"genrated_date_time"},{title:"Return Date",dataIndex:"expected_return_date_time",key:"expected_return_date_time"},{title:"Reason",dataIndex:"reason",key:"reason"},{title:"Action",key:"action",render:(O,D)=>e.jsx(n.Tag,{color:D?.status==="Generated"?"green":"blue",children:D?.status||"Pending"})},{title:"Print",key:"print",render:(O,D)=>e.jsx(ee.PrinterOutlined,{style:{color:"#3892ee",cursor:"pointer"},onClick:()=>window.print()})}];return e.jsx(v,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Today Gate Pass"})}),e.jsx(v,{pt:3,children:e.jsx(n.List,{grid:{column:4,gutter:16},dataSource:g?.data||[],style:{padding:0},renderItem:O=>e.jsx(n.List.Item,{style:{padding:0},children:e.jsx(n.Card,{size:"small",style:{marginBottom:8,width:"100%"},children:e.jsxs(v,{children:[e.jsxs(n.Typography.Text,{strong:!0,children:[O?.lastname," ",O?.firstname]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:[O?.class_name,"-",O?.section_name]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:["Return: ",O?.expected_return_date_time]}),e.jsx("br",{}),e.jsx(ne,{type:"button",value:"Print",color:"primary",size:"small",onClick:()=>window.print(),style:{marginTop:4}})]})})})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Gate Pass List"})}),e.jsxs(v,{pt:3,children:[e.jsx(Ct,{data:{tableRef:o}}),e.jsx(Ie,{parentCallback:d,data:{newData:C,columns:k,action:!1,ActionView:c,Loading:m,error:A,editDesign:"",deleteTodoMutation:f,open:r,DrawerUpdate:x,viewDetails:R}})]})]})})]})})}const yt=({id:t,funcName:a,disabled:s=!1})=>{const r="Data",[l,o]=i.useState(!1),d=()=>{o(!0),a(t),n.message.success(`${r} deleted successfully!`)},c=()=>{n.message.info(`Deletion of ${r} cancelled`)};return e.jsx(n.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:s||l,children:e.jsx(n.Button,{danger:!0,disabled:s,loading:l,icon:e.jsx(ee.DeleteOutlined,{}),size:"small"})})},ei={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Gp({token:t,sampleTemplateUrl:a=$c}){const[s,r]=i.useState({pagination:{current:1,pageSize:10}}),[l,o]=i.useState(!1),[d,c]=i.useState(null),[g,y]=i.useState(null),[p,m]=i.useState(!1),[A,C]=i.useState([]),b=`api/branchapi/Transport/routeTableList?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,f="api/branchapi/Transport/addroute",x="api/branchapi/Transport/editroute",R="api/branchapi/Transport/deleteroute",k=void 0,{isLoading:O,data:D,error:_,mutate:u}=H(t?[b,t]:null,([W,B])=>K(W,B)),h=i.useMemo(()=>!D?.data||Array.isArray(D.data)?[]:D.data?.rows||[],[D]),S=D?.data?.pagination?.total_rows||D?.pagination?.total_rows||0,E=async(W,B)=>{try{await u(Ne(W,B,t),Ge(B)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},F=W=>{W.preventDefault();const B=new FormData(W.target);E(f,B),W.target.reset()},q=(W,B)=>{r($=>({...$,pagination:{current:W,pageSize:parseInt(B,10)}}))},T=async W=>{try{await u(He(R,W,t),ze(W)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},U=W=>{c(W),o(!0)},j=async W=>{try{const B=await We(x,W,t);u(B),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),c(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},P=async W=>{W.preventDefault();const B=new FormData(W.target);B.append("id",d?.id),j(B)},I=async()=>{if(!g){w.error("Please select an Excel file to upload.",{duration:1e3});return}m(!0),C([]);try{const W=new FormData;W.append("file",g);const $=await(await fetch(`${k}`,{method:"POST",headers:{Authorization:t},body:W})).json();if($.Status==="Success"){const M=$.data?.rows||[];C(M);const L=$.data?.success_count||0,Y=$.data?.failed_count||0;w.success($.message||`Route bulk upload completed. ${L} succeeded, ${Y} failed.`,{duration:1e3}),L>0&&u()}else w.error($.message||"Failed to upload routes.",{duration:1e3})}catch(W){w.error(W?.message||"Something went wrong.",{duration:1e3})}finally{m(!1),y(null)}},N=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(W,B)=>(W.route_title||"").localeCompare(B.route_title||"")}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(W,B)=>Number(W.fare||0)-Number(B.fare||0)}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(W,B)=>(W.note||"").localeCompare(B.note||"")}},{title:"Action",key:"action",render:(W,B)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>U(B),style:{padding:2}}),e.jsx(yt,{id:B?.id,funcName:T})]})}],V=d?.route_title?`Edit ${d.route_title}`:"Edit Route";return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Routes"})}),e.jsxs(v,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:W=>(y(W),!1),children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:p,children:g?g.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(n.Button,{type:"primary",onClick:I,disabled:p||!g,loading:p,children:p?"Uploading...":"Upload Routes"})})})]}),A.length>0&&e.jsxs(v,{mt:3,children:[e.jsx(pe,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:A.map((W,B)=>({...W,key:B})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Title",dataIndex:"title"},{title:"Status",dataIndex:"status",render:W=>e.jsx("span",{style:{color:W==="Success"?"green":"red",fontWeight:500},children:W})},{title:"Message",dataIndex:"message"}]})]}),a&&e.jsx(v,{mt:2,children:e.jsx("a",{href:a,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Add Route"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:F,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(z,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(z,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(z,{type:"text",name:"note",label:"Note"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(v,{children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:ei,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Route List"})}),e.jsx(v,{p:3,children:e.jsx(Ie,{parentCallback:q,data:{newData:{data:h,pagination:{total_rows:S}},columns:N,columnstype:"antd",action:!1,Loading:O,error:_,deleteTodoMutation:T}})})]})})]}),e.jsx(n.Drawer,{open:l,title:V,placement:"right",width:420,onClose:()=>{o(!1),c(null)},children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"title",label:"Title",defaultValue:d?.route_title||"",required:"required"}),e.jsx(z,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:d?.fare||"",required:"required"}),e.jsx(z,{type:"text",name:"note",label:"Note",defaultValue:d?.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(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),c(null)},style:ei,children:"Cancel"})]})]})})})]})}const ti={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Jp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${a.page}&per_page=${a.rowsPerPage}`,g="api/branchapi/Transport/addvehicles",y="api/branchapi/Transport/editvehicle",p="api/branchapi/Transport/deletevehicle",{isLoading:m,data:A,error:C,mutate:b}=H(t?[c,t]:null,([S,E])=>K(S,E)),f=async(S,E)=>{try{await b(Ne(S,E,t),Ge(E)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},x=S=>{S.preventDefault();const E=new FormData(S.target);f(g,E),S.target.reset()},R=async S=>{try{await b(He(p,S,t),ze(S)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},k=S=>{d(S),l(!0)},O=async S=>{try{await We(y,S,t),await b(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},D=async S=>{S.preventDefault();const E=new FormData(S.target);E.append("id",o?.id),O(E)},_=(S,E)=>{s({page:S,rowsPerPage:parseInt(E,10)})},u=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(S,E)=>S.vehicle_no.localeCompare(E.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(S,E)=>S.vehicle_model.localeCompare(E.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(S,E)=>S.seating_capacity-E.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(S,E)=>S.manufacture_year-E.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(S,E)=>S.gps_url.localeCompare(E.gps_url)},render:(S,E)=>e.jsx("span",{title:E?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(S,E)=>S.note.localeCompare(E.note)}},{title:"Action",key:"action",render:(S,E)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(E),style:{padding:2}}),e.jsx(yt,{id:E?.id,funcName:R})]})}],h=o?.vehicle_no?`Edit ${o.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:r,title:h,placement:"right",width:420,onClose:()=>{l(!1),d(null)},children:e.jsx("form",{onSubmit:D,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"number",label:"Vehicle Number",defaultValue:o?.vehicle_no||"",required:"required"}),e.jsx(z,{type:"text",name:"model",label:"Vehicle Model",defaultValue:o?.vehicle_model||""}),e.jsx(z,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:o?.manufacture_year||""}),e.jsx(z,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:o?.seating_capacity||""}),e.jsx(z,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:o?.gps_url||""}),e.jsx(z,{type:"text",name:"note",label:"Note",defaultValue:o?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null)},style:ti,children:"Cancel"})]})]})})}),e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(v,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(z,{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(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:ti,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(v,{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(v,{children:e.jsx(Ie,{parentCallback:_,data:{newData:A,columns:u,columnstype:"antd",action:!1,Loading:m,error:C,deleteTodoMutation:R}})})]})})]})})]})}const Qp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ai=({dataIndex:t,title:a,record:s,children:r,isEditable:l,...o})=>e.jsx("td",{...o,children:l?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function Xp({token:t}){const[a,s]=i.useState(!1),[r,l]=i.useState({pagination:{current:1,pageSize:50}}),[o,d]=i.useState(null),[c,g]=i.useState([]),y="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleDropdown",m="api/branchapi/Transport/getchechkedVehicleData",A="api/branchapi/Transport/assignedVehicleTable",C="api/branchapi/transport/assignvehicle",b="api/branchapi/Transport/deleteassignvehicle",f=o?`${m}?route_id=${o}`:null,{isLoading:x,data:R,mutate:k}=H(t?[`${A}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([$,M])=>K($,M)),{data:O}=H(t&&y?[y,t]:null,([$,M])=>K($,M)),{data:D}=H(t&&p?[p,t]:null,([$,M])=>K($,M)),_=t&&f?[f,t]:null,{isLoading:u,data:h}=H(_,([$,M])=>K($,M)),{Status:S="Failed",pagination:{total_rows:E=0}={}}=R||{},{data:F=[]}=S==="Success"?R:{},q=i.useMemo(()=>{const $=O?.data??O??[];return Array.isArray($)?$:[]},[O]),T=i.useMemo(()=>{const $=D?.data??D??[];return(Array.isArray($)?$:[]).map(L=>{if(L==null)return null;if(typeof L=="string"||typeof L=="number")return{label:String(L),value:L};const Y=L.value??L.vehicle_id??L.id??L.vehicleID,se=L.label??L.vehicle_name??L.vehicle_no??L.vehicle_number??L.name??String(Y??"");return Y==null||se===""?null:{label:String(se),value:Y}}).filter(Boolean)},[D]),U=i.useMemo(()=>{const $=h?.data??h??[];return(Array.isArray($)?$:[]).map(L=>L?.value??L?.vehicle_id??L?.id??L).filter(L=>L!=null)},[h]);i.useEffect(()=>{g(U)},[U,a]);const j=async($,M,L)=>{try{await k(Ne($,M,t),Ge(M)),f&&H.mutate(_),s(Y=>!Y),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(Y){w.error(Y?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},P=$=>{$.preventDefault();const M=new FormData;M.append("route_id",o??""),c.length?c.forEach(L=>M.append("vehicle_ids[]",L)):M.append("vehicle_ids[]",""),j(C,M)},I=$=>{l(M=>({...M,pagination:{current:$,pageSize:M.pagination.pageSize}}))},N=async $=>{try{await k(He(b,$,t),ze($)),f&&H.mutate(_),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},V=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:($,M,L)=>e.jsx(e.Fragment,{children:M.children.map((Y,se,X)=>e.jsx("span",{children:`${Y.vehicle_name} ${se+1===X.length?"":","}`},`${se}vehicle001`))})},{title:"Action",render:($,M,L)=>e.jsx(e.Fragment,{children:e.jsx(yt,{id:M?.route_id,funcName:N})})}],W=$=>{const M=["route_id","index"];for(let L=0;L<M.length;L++)if($[M[L]])return $[M[L]]},B=$=>{const{children:M=[]}=$||{},L=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:Y=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:Y=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:Y=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:Y=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:Y=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:Y=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:Y=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:ai}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:L,rowKey:Y=>W(Y)+"cell01",dataSource:M,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(v,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Q,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:$=>{d($?.value??null),s(M=>!M)}})}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:e.jsx(n.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:T,value:c,onChange:$=>g($),disabled:!o||u})},`check001${a}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),g([]),s($=>!$)},style:Qp,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(v,{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(v,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:ai}},columns:V,bordered:!0,rowKey:$=>W($),dataSource:Array.isArray(F)?F:[],loading:x,expandable:{expandedRowRender:B,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:E,showSizeChanger:!0,onChange:I,onShowSizeChange:($,M)=>{l(L=>({...L,pagination:{current:1,pageSize:M}}))},showTotal:($,M)=>`${M[0]}-${M[1]} of ${$} items`}})})]})})]})})]})}const ni={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ds=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},ca=(t,a,s)=>{if(a==null||a==="")return null;const r=t.find(l=>String(l.value)===String(a));return r||(s?{label:String(s),value:a}:{label:String(a),value:a})},Zp=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},em=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(s=>s!=null&&s!==""&&String(s).toLowerCase()!=="null"&&String(s).toLowerCase()!=="undefined").join(", ");const a=String(t).trim();return!a||a.toLowerCase()==="null"||a.toLowerCase()==="undefined"?"":a};function tm({token:t,assignmentId:a,studentName:s,onClose:r,onSuccess:l}){const o="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",g="api/branchapi/Transport/getvehicleListByRouteIdwithCount",y="api/branchapi/Transport/getStoppageDropdown",p="api/branchapi/Transport/routeShowdata",[m,A]=i.useState(null),[C,b]=i.useState(null),[f,x]=i.useState(null),[R,k]=i.useState(te()),[O,D]=i.useState(""),[_,u]=i.useState(0),[h,S]=i.useState(0),{data:E,isLoading:F}=H(t&&a?[`${o}?id=${a}`,t]:null,([ie,Se])=>K(ie,Se)),q=i.useMemo(()=>{if(!E||E?.Status&&E.Status!=="Success")return null;const ie=E?.data??E;return Array.isArray(ie)?ie[0]??null:ie},[E]);i.useEffect(()=>{const ie=q?.fk_route_id??q?.route_id;ie!=null&&A(ie),q?.vehicle_id!=null&&b(q.vehicle_id),q?.stop_id!=null&&x(q.stop_id),k(q?.start_date?te(q.start_date):te()),D(em(q?.service_push))},[q]);const T=t&&m?`${g}?route_id=${m}`:null,U=t&&m?`${p}?id=${m}`:null,j=t&&m?`${y}?route_id=${m}`:null,{data:P}=H(t&&c?[c,t]:null,([ie,Se])=>K(ie,Se)),{data:I,isLoading:N}=H(T?[T,t]:null,([ie,Se])=>K(ie,Se)),{data:V,isLoading:W}=H(j?[j,t]:null,([ie,Se])=>K(ie,Se)),{data:B}=H(U?[U,t]:null,([ie,Se])=>K(ie,Se)),$=i.useMemo(()=>Ds(P),[P]),M=i.useMemo(()=>Ds(I),[I]),L=i.useMemo(()=>Ds(V),[V]),Y=E?.data[0]?.rootCost,se=Zp(),X=s||[q?.firstname,q?.lastname].filter(Boolean).join(" ")||"",G=(ie,Se)=>{switch(Se){case"route_id":A(ie?.value??null),b(null),x(null),u(Ee=>Ee+1),S(Ee=>Ee+1);break;case"vehicle_id":b(ie?.value??null),x(null),S(Ee=>Ee+1);break;case"stop_id":x(ie?.value??null);break}},J=async ie=>{if(ie.preventDefault(),!m||!C||!f){w.error("Please select Route, Vehicle and Stop",{duration:1200});return}const Se=new FormData;Se.append("id",String(a)),Se.append("student_id",String(q?.fk_student_id??q?.student_id??"")),Se.append("fk_route_id",String(m)),Se.append("vehicle_id",String(C)),Se.append("stop_id",String(f)),Se.append("rootCost",String(Y??"")),Se.append("start_date",R?.isValid?.()?R.format("YYYY-MM-DD"):te().format("YYYY-MM-DD")),Se.append("puse_service",String(O??""));try{await We(d,Se,t),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l?.(),r?.()}catch(Ee){w.error(Ee?.message??"Failed to update the item.",{duration:1e3})}};if(F||!(q&&!F&&(!m||!N&&!W)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(n.Spin,{})});if(!q)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(n.Button,{type:"text",onClick:r,style:ni,children:"Close"})]});const de=q.fk_route_id??q.route_id,Ce=ca($,de,q.route_title),le=ca(M,q.vehicle_id,q.vehicle_name??q.vehicle_no),oe=ca(L,q.stop_id,q.stop_name??q.stoppage_name);return e.jsx("form",{onSubmit:J,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"title",label:"Student",defaultValue:X,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:q.fk_student_id??q.student_id??""}),e.jsx(Q,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:ca($,m,Ce?.label)??null,onChange:ie=>G(ie,"route_id")}),e.jsx(Q,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:ca(M,C,le?.label)??null,onChange:ie=>G(ie,"vehicle_id")},`edit-vehicle-${_}`),e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:ca(L,f,oe?.label)??null,onChange:ie=>G(ie,"stop_id")},`edit-stop-${h}`),e.jsx(z,{type:"text",label:"Route Cost",value:Y!=null?`${se}${Y}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:Y??""}),e.jsx(Ue,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:R,onChange:ie=>k(ie)}),e.jsx(z,{type:"text",label:"Pause Service",value:O,onChange:ie=>D(ie?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:r,style:ni,children:"Cancel"})]})]})},`edit-${a}-${_}`)}const si={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},am=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[]},Ia=t=>am(t),nm=t=>t||"",sm=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},rm=t=>{const a=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return a==="page"||a==="sendpage"?"page":"drawer"},im=(t,a)=>{const s=a||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",l=encodeURIComponent(String(r));if(s.includes("{id}"))return s.replaceAll("{id}",l);if(s.includes(":id"))return s.replace(":id",l);try{const d=new URL(s,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(r)),`${d.pathname}${d.search}${d.hash}`}catch{}const o=s.includes("?")?"&":"?";return`${s}${o}id=${l}`};function lm({token:t,editType:a,onNavigate:s,editPagePath:r,sampleTemplateUrl:l=Fc}){const d=rm(a)==="drawer",c="api/branchapi/academy/classdropdownlist",g="api/branchapi/academy/sectionoftheClass",y="api/branchapi/Transport/routeStudentList",p="api/branchapi/Transport/getrouteDropdown",m="api/branchapi/Transport/getvehicleListByRouteIdwithCount",A="api/branchapi/Transport/getStoppageDropdown",C="api/branchapi/Transport/routeShowdata",b="api/branchapi/Transport/assignTransportRoutesStudent",f="api/branchapi/transport/removeStudentTransport",x="api/branchapi/transport/assignTransportRoutesStudentBulk",[R,k]=i.useState(null),[O,D]=i.useState(!1),[_,u]=i.useState(!1),[h,S]=i.useState(null),[E,F]=i.useState(null),[q,T]=i.useState(null),[U,j]=i.useState(null),[P,I]=i.useState(!1),[N,V]=i.useState(!1),[W,B]=i.useState({page:1,rowsPerPage:50}),[$,M]=i.useState(null),[L,Y]=i.useState(!1),[se,X]=i.useState(null),[G,J]=i.useState(null),[re,de]=i.useState(null),[Ce,le]=i.useState(null),[oe,ie]=i.useState(null),[Se,Ee]=i.useState(null),[Xe,be]=i.useState(null),[ve,Oe]=i.useState(te()),[Ye,Be]=i.useState(""),[Le,Ze]=i.useState(null),[at,fe]=i.useState(!1),[je,xe]=i.useState([]),ae=(ge,De)=>{const tt=ge?.value??null;switch(De){case"class_id":de(tt),le(null),M(tt?`${g}?class_id=${encodeURIComponent(String(tt))}`:null),D(Ot=>!Ot);break;case"route_id":ie(tt),Ee(null),be(null),J(tt),F(tt?`${m}?route_id=${encodeURIComponent(String(tt))}`:null),T(tt?`${C}?id=${encodeURIComponent(String(tt))}`:null),j(null),I(Ot=>!Ot),V(Ot=>!Ot);break;case"vehicle_id":Ee(tt),be(null),j(oe?`${A}?route_id=${encodeURIComponent(String(oe))}`:null),V(Ot=>!Ot);break;case"stop_id":be(tt);break}},he=ge=>{if(d){S(ge),u(!0);return}const De=im(ge,r);if(typeof s=="function"){s(De,ge);return}typeof window<"u"&&De&&window.location.assign(De)},ye=()=>{u(!1),S(null)},ke=h?`Edit — ${h.firstname??""} ${h.lastname??""}`.trim():"Edit Student Transport",{data:Pe}=H(t&&c?[c,t]:null,([ge,De])=>K(ge,De)),{data:ue}=H(t&&$?[$,t]:null,([ge,De])=>K(ge,De)),{data:we}=H(t&&E?[E,t]:null,([ge,De])=>K(ge,De)),{data:Ve}=H(t&&U?[U,t]:null,([ge,De])=>K(ge,De)),{data:dt}=H(t&&q?[q,t]:null,([ge,De])=>K(ge,De)),{data:Ft}=H(t&&p?[p,t]:null,([ge,De])=>K(ge,De)),Pt=t&&R?`${R}&page=${W.page}&per_page=${W.rowsPerPage}`:null,{isLoading:me,error:Ae,data:ut,mutate:vt}=H(Pt?[Pt,t]:null,([ge,De])=>K(ge,De)),cn=i.useMemo(()=>Ia(Pe),[Pe]),un=i.useMemo(()=>Ia(ue),[ue]),pn=i.useMemo(()=>Ia(we),[we]),mn=i.useMemo(()=>Ia(Ve),[Ve]),hn=i.useMemo(()=>Ia(Ft),[Ft]),ce=dt?.data?.[0]?.fare??dt?.data?.fare??dt?.fare??dt?.data?.data?.[0]?.fare??dt?.data?.data?.fare;i.useEffect(()=>{ce==null||ce===""||Be(String(ce))},[ce]);const _e=async ge=>{try{await vt(He(f,ge,t),ze(ge)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},qe=async()=>{if(!Le){w.error("Please select an Excel file to upload.",{duration:1e3});return}fe(!0),xe([]);try{const ge=new FormData;ge.append("file",Le);const tt=await(await fetch(`${x}`,{method:"POST",headers:{Authorization:t},body:ge})).json();if(tt.Status==="Success"){const Ot=tt.data?.rows||[];xe(Ot);const hr=tt.data?.success_count||0,Oo=tt.data?.failed_count||0;w.success(tt.message||`Transport bulk upload completed. ${hr} succeeded, ${Oo} failed.`,{duration:1e3}),hr>0&&vt()}else w.error(tt.message||"Failed to upload student transport assignments.",{duration:1e3})}catch(ge){w.error(ge?.message||"Something went wrong.",{duration:1e3})}finally{fe(!1),Ze(null)}},et=[{title:"Route Status",key:"route_status",render:(ge,De)=>De.fk_route_id?e.jsx("span",{children:De.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(ge,De)=>nm(De.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:(ge,De)=>`${De.firstname} ${De.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(ge,De)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:De.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(yt,{id:De?.id,funcName:_e}),e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>he(De),style:{padding:2}})]}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>ms(De.student_id),style:{padding:2}})})}],ct=async(ge,De)=>{try{await vt(Ne(ge,De,t),Ge(De)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),Y(!1),hs()}catch{w.error("Failed to add the new item.",{duration:1e3})}},gt=ge=>{if(ge.preventDefault(),!re||!Ce){w.error("Please select Class and Section",{duration:1200});return}k(`${y}?cID=${encodeURIComponent(String(re))}&sID=${encodeURIComponent(String(Ce))}`),B(De=>({...De,page:1}))},ps=(ge,De)=>{B({page:ge,rowsPerPage:parseInt(De,10)})},ms=ge=>{X(ge),Y(!0)},_a=ge=>{if(ge.preventDefault(),!se){w.error("Student is required",{duration:1200});return}if(!oe||!Se||!Xe){w.error("Please select Route, Vehicle and Stop",{duration:1300});return}const De=new FormData;De.append("student_id",String(se)),De.append("fk_route_id",String(oe)),De.append("vehicle_id",String(Se)),De.append("stop_id",String(Xe)),De.append("start_date",ve?.isValid?.()?ve.format("YYYY-MM-DD"):te().format("YYYY-MM-DD")),De.append("rootCost",String(Ye??"")),ct(b,De)},hs=()=>{Y(!1),F(null),T(null),j(null),J(null),ie(null),Ee(null),be(null),Oe(te()),Be(""),I(ge=>!ge),V(ge=>!ge)},Po=sm();return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Assign Students to Transport"})}),e.jsxs(v,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:ge=>(Ze(ge),!1),children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:at,children:Le?Le.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(n.Button,{type:"primary",onClick:qe,disabled:at||!Le,loading:at,children:at?"Uploading...":"Upload Students"})})})]}),l&&e.jsx(v,{mt:2,children:e.jsx("a",{href:l,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})}),je.length>0&&e.jsxs(v,{mt:3,children:[e.jsx(pe,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:je.map((ge,De)=>({...ge,key:De})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Student ID",dataIndex:"student_id"},{title:"Status",dataIndex:"status",render:ge=>e.jsx("span",{style:{color:ge==="Success"?"green":"red",fontWeight:500},children:ge})},{title:"Message",dataIndex:"message"}]})]})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Search Students"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:gt,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{options:cn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:ge=>ae(ge,"class_id"),required:!0,allowSelectAll:!1,value:cn.find(ge=>String(ge.value)===String(re))??null})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{options:un,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:un.find(ge=>String(ge.value)===String(Ce))??null,onChange:ge=>le(ge?.value??null)},`section1${O}`)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{display:"flex",alignItems:"center",height:"100%",mt:2,children:[e.jsx(ne,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{k(null),M(null),de(null),le(null),D(ge=>!ge)},style:si,children:"Cancel"})]})})]})})})]})}),R&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(v,{p:3,children:e.jsx(Ie,{parentCallback:ps,data:{newData:ut,columns:et,columnstype:"antd",action:!1,Loading:me,error:Ae,deleteTodoMutation:_e,pageController:W}})})]})})]}),e.jsx(n.Drawer,{open:_,title:ke,placement:"right",width:420,destroyOnClose:!0,onClose:ye,children:h?.id&&e.jsx(tm,{token:t,assignmentId:h.id,studentName:`${h.firstname??""} ${h.lastname??""}`.trim(),onClose:ye,onSuccess:()=>vt()})}),e.jsx(n.Modal,{open:L,title:"Assign Student to Transport",onCancel:hs,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:_a,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:hn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:hn.find(ge=>String(ge.value)===String(oe))??null,onChange:ge=>ae(ge,"route_id")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:pn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:pn.find(ge=>String(ge.value)===String(Se))??null,onChange:ge=>ae(ge,"vehicle_id")},`vehicle001${P}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:mn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:mn.find(ge=>String(ge.value)===String(Xe))??null,onChange:ge=>ae(ge,"stop_id")},`stop001${N}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:ve,onChange:ge=>Oe(ge)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{type:"text",name:"rootCost",label:"Route Cost",value:Ye,onChange:ge=>Be(ge?.target?.value??"")})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(v,{display:"flex",alignItems:"center",gap:12,children:[e.jsx(ne,{type:"submit",value:String(Ye??"").trim()?`${Po}${Ye} — Assign`:"Assign",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:hs,style:si,children:"Cancel"})]})})]})})})]})}const ri={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},xn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function om({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:50}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState(""),[C,b]=i.useState(!1),f=`api/branchapi/Transport/getdriverTable?page=${a.page}&per_page=${a.rowsPerPage}`,x="api/branchapi/Transport/add_driver",R="api/branchapi/Transport/edit_driver",k="api/branchapi/Transport/deletedriver",O="api/branchapi/staff/uploadDocuments",D=i.useMemo(()=>String(O).startsWith("http")?O:`${bt()??""}${String(O).replace(/^\/+/,"")}`,[O]),_=bt()??"",{isLoading:u,data:h,error:S,mutate:E}=H(t?[f,t]:null,([W,B])=>K(W,B)),F=async(W,B)=>{try{await Ne(W,B,t),await E(),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),g("")}catch($){w.error($?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},q=W=>{W.preventDefault();const B=new FormData(W.target);F(x,B),W.target.reset()},T=async W=>{try{await E(He(k,W,t),ze(W)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},U=W=>{d(W),g(W?.image??""),l(!0)},j=async W=>{try{await We(R,W,t),await E(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null),g("")}catch(B){w.error(B?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},P=W=>{W.preventDefault();const B=new FormData(W.target);B.append("id",o?.id??""),j(B)},I=(W,B)=>{s({page:W,rowsPerPage:parseInt(B,10)})},N=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(W,B)=>String(W?.name??"").localeCompare(String(B?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(W,B)=>String(W?.Driver_licence??"").localeCompare(String(B?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(W,B)=>Number(W?.contact_number??0)-Number(B?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(W,B)=>String(W?.address??"").localeCompare(String(B?.address??""))}},{title:"Image",key:"image",width:100,render:(W,B)=>{const $=B?.image?`${_}staff/document/${B.image}`:"";return $?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(n.Image,{width:80,src:$,preview:{visible:!1,onVisibleChange:()=>{b(!0),p($),A(B?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(W,B)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>U(B),style:{padding:2}}),e.jsx(yt,{id:B?.id,funcName:T})]})}],V=o?.name?`Edit ${o.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:r,title:V,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{l(!1),d(null),g("")},children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"name",label:"Driver Name",defaultValue:o?.name??"",required:"required"}),e.jsx(z,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:o?.Driver_licence??"",required:"required"}),e.jsx(z,{type:"number",name:"contact_number",label:"Driver Contact",defaultValue:o?.contact_number??"",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:xn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",defaultValue:o?.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:xn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:D,headers:t?{Authorization:t}:void 0,onChange:W=>{if(W?.file?.status!=="done")return;const B=W?.file?.response,$=B?.data??B?.filename??B?.file??B?.path??"";$&&g(String($))},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:!D,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null),g("")},style:ri,children:"Cancel"})]})]})})}),e.jsx(n.Modal,{zIndex:9999,open:C,title:m,footer:null,onCancel:()=>b(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:y})}),e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(v,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(z,{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:xn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:xn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:D,headers:t?{Authorization:t}:void 0,onChange:W=>{if(W?.file?.status!=="done")return;const B=W?.file?.response,$=B?.data??B?.filename??B?.file??B?.path??"";$&&g(String($))},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:!D,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>g(""),style:ri,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(v,{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(v,{children:e.jsx(Ie,{parentCallback:I,data:{newData:h,columns:N,columnstype:"antd",action:!1,Loading:u,error:S,deleteTodoMutation:T}})})]})})]})})]})}const ii={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ua={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},bn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},li=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],jn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function dm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:50}),[r,l]=i.useState(!1),[o,d]=i.useState(!1),[c,g]=i.useState(null),[y,p]=i.useState(null),[m,A]=i.useState(null),[C,b]=i.useState(null),[f,x]=i.useState(te()),[R,k]=i.useState(te()),[O,D]=i.useState("pick"),[_,u]=i.useState(!1),[h,S]=i.useState(null),[E,F]=i.useState(null),[q,T]=i.useState(!1),[U,j]=i.useState(null),[P,I]=i.useState(null),[N,V]=i.useState(null),[W,B]=i.useState(null),[$,M]=i.useState(te()),[L,Y]=i.useState(te()),[se,X]=i.useState("pick"),G=`api/branchapi/Transport/assignRouteTimeList?page=${a.page}&per_page=${a.rowsPerPage}`,J="api/branchapi/Transport/assignRouteTime",re="api/branchapi/Transport/editAssignRouteTime",de="api/branchapi/Transport/deleteAssignRouteTime",Ce="api/branchapi/Transport/driverDropdown",le="api/branchapi/transport/routeTimetableShowdata",oe="api/branchapi/Transport/getrouteDropdown",ie="api/branchapi/Transport/getvehicleDropdown",{isLoading:Se,data:Ee,error:Xe,mutate:be}=H(t?[G,t]:null,([me,Ae])=>K(me,Ae)),{data:ve}=H(t&&oe?[oe,t]:null,([me,Ae])=>K(me,Ae)),{data:Oe}=H(t&&Ce?[Ce,t]:null,([me,Ae])=>K(me,Ae)),Ye=i.useMemo(()=>c?`${ie}?route_id=${c}`:null,[c,ie]),{data:Be}=H(t&&Ye?[Ye,t]:null,([me,Ae])=>K(me,Ae)),Le=i.useMemo(()=>jn(ve),[ve]),Ze=i.useMemo(()=>jn(Oe),[Oe]),at=i.useMemo(()=>jn(Be),[Be]),fe=(me,Ae)=>{s({page:me,rowsPerPage:parseInt(Ae,10)})},je=async me=>{me.preventDefault();const Ae=new FormData(me.target);Ae.set("route_id",y?.value??c??""),Ae.set("driver_id",m?.value??""),Ae.set("vehicle_id",C?.value??""),Ae.set("start_time",f?f.format("h:mm a"):""),Ae.set("drop_time",R?R.format("h:mm a"):""),Ae.set("type",O);try{await Ne(J,Ae,t),await be(),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),me.target.reset(),g(null),p(null),A(null),b(null),d(ut=>!ut),x(te()),k(te()),D("pick"),l(ut=>!ut)}catch(ut){w.error(ut?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},xe=async me=>{try{await He(de,me,t),await be(),w.success("Success! Deleted item.",{duration:1e3})}catch(Ae){w.error(Ae?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ae=me=>{S(me),u(!0);const Ae=me?.id??me?.route_time_id??me?.routeId??null;F(Ae);const ut=me?.route_id??me?.routeId??me?.fk_route_id;j(ut??null),I(Le.find(vt=>vt?.value===(ut??me?.route_id))??null),V(Ze.find(vt=>vt?.value===(me?.driver_id??me?.driverId))??null),B(null),T(vt=>!vt),M(me?.start_time?te(me.start_time,["h:mm a","HH:mm"]):te()),Y(me?.drop_time?te(me.drop_time,["h:mm a","HH:mm"]):te()),X(me?.type??"pick")},he=i.useMemo(()=>{if(!E)return null;const me=String(le).includes("?")?"&":"?";return`${le}${me}id=${encodeURIComponent(String(E))}`},[E,le]),{data:ye,isLoading:ke}=H(t&&he?[he,t]:null,([me,Ae])=>K(me,Ae)),Pe=i.useMemo(()=>{const me=ye?.data??ye;return Array.isArray(me)?me[0]??null:Array.isArray(me?.data)?me.data[0]??null:me??null},[ye]),ue=i.useMemo(()=>U?`${ie}?route_id=${U}`:null,[U,ie]),{data:we}=H(t&&ue?[ue,t]:null,([me,Ae])=>K(me,Ae)),Ve=i.useMemo(()=>jn(we),[we]);i.useEffect(()=>{if(!Pe)return;const me=Pe?.route_id??Pe?.fk_route_id??Pe?.routeId;j(me??null),I(Le.find(Ae=>Ae?.value===me)??null),V(Ze.find(Ae=>Ae?.value===Pe?.driver_id)??null),B(null),M(Pe?.start_time?te(Pe.start_time,["h:mm a","HH:mm"]):te()),Y(Pe?.drop_time?te(Pe.drop_time,["h:mm a","HH:mm"]):te()),X(Pe?.type??"pick"),T(Ae=>!Ae)},[Ze,Pe,Le]),i.useEffect(()=>{if(!Pe)return;const me=Pe?.vehicle_id??Pe?.vehicleId;me&&B(Ve.find(Ae=>Ae?.value===me)??null)},[Pe,Ve]);const dt=async me=>{if(me.preventDefault(),!E)return;const Ae=new FormData(me.target);Ae.set("id",String(E)),Ae.set("route_id",P?.value??U??""),Ae.set("driver_id",N?.value??""),Ae.set("vehicle_id",W?.value??""),Ae.set("start_time",$?$.format("h:mm a"):""),Ae.set("drop_time",L?L.format("h:mm a"):""),Ae.set("type",se);try{await We(re,Ae,t),await be(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),u(!1),S(null)}catch(ut){w.error(ut?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Ft=[{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:(me,Ae)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>ae(Ae),style:{padding:2}}),e.jsx(yt,{id:Ae?.id??Ae?.routeId??Ae?.route_time_id,funcName:xe})]})}],Pt=h?.route_title?`Edit ${h.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:_,title:Pt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{u(!1),S(null),F(null),j(null),I(null),V(null),B(null)},children:e.jsx("form",{onSubmit:dt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:ke?.6:1},children:[e.jsx(Q,{options:Le,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:P,onChange:me=>{j(me?.value??null),I(me??null),B(null),T(Ae=>!Ae)}}),e.jsx(Q,{options:Ze,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:N,onChange:me=>V(me??null)}),e.jsx(Q,{options:Ve,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:W,onChange:me=>B(me??null)},`edit-vehicle-${q}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ua,children:"Start Time"}),e.jsx(n.TimePicker,{value:$,onChange:me=>M(me),use12Hours:!0,format:"h:mm a",allowClear:!1,style:bn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ua,children:"Drop Time"}),e.jsx(n.TimePicker,{value:L,onChange:me=>Y(me),use12Hours:!0,format:"h:mm a",allowClear:!1,style:bn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ua,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:li,optionType:"button",buttonStyle:"solid",value:se,onChange:me=>X(me.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{u(!1),S(null)},style:ii,children:"Cancel"})]})]})})}),e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(v,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:je,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:Le,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:y,onChange:me=>{g(me?.value??null),p(me??null),b(null),d(Ae=>!Ae)},allowSelectAll:!1,required:!0}),e.jsx(Q,{options:Ze,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:m,onChange:me=>A(me??null),allowSelectAll:!1,required:!0}),e.jsx(Q,{options:at,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:C,onChange:me=>b(me??null),allowSelectAll:!1,required:!0},`vehicle-${o}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ua,children:"Start Time"}),e.jsx(n.TimePicker,{value:f,onChange:me=>x(me),use12Hours:!0,format:"h:mm a",allowClear:!1,style:bn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ua,children:"Drop Time"}),e.jsx(n.TimePicker,{value:R,onChange:me=>k(me),use12Hours:!0,format:"h:mm a",allowClear:!1,style:bn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ua,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:li,optionType:"button",buttonStyle:"solid",value:O,onChange:me=>D(me.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>{g(null),p(null),A(null),b(null),d(me=>!me),x(te()),k(te()),D("pick"),l(me=>!me)},style:ii,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(v,{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(v,{children:e.jsx(Ie,{parentCallback:fe,data:{newData:Ee,columns:Ft,columnstype:"antd",action:!1,Loading:Se,error:Xe,deleteTodoMutation:xe}})})]})})]})})]})}const cm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},oi={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},di={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ci=({dataIndex:t,title:a,record:s,children:r,isEditable:l,...o})=>e.jsx("td",{...o,children:l?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let ui=2;function um({token:t}){const[a,s]=i.useState([]),[r,l]=i.useState(null),[o,d]=i.useState([]),[c,g]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:y,data:p,mutate:m}=H(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([j,P])=>K(j,P)),{Status:A="Failed",pagination:{total_rows:C=0}={}}=p||{},{data:b=[]}=A==="Success"?p:{},{data:f}=H(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([j,P])=>K(j,P)),x=i.useMemo(()=>{const j=f?.data??f??[];if(Array.isArray(j))return j;if(j&&typeof j=="object"){if(Array.isArray(j?.data))return j.data;if(Array.isArray(j?.data?.data))return j.data.data}return[]},[f]),{data:R}=H(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([j,P])=>K(j,P)),{Status:k="Failed"}=R||{},O=async(j,P)=>{try{await m(Ne(j,P,t),Ge(P)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},D=j=>j?typeof j=="string"?j:j?.isValid?.()?j.format("h:mm a"):"":"",_=(j,P=[])=>{const I=(Array.isArray(j)?j:[]).map(W=>({id:W?.id??"",name:String(W?.stop_name??W?.name??"").trim(),pickTime:D(W?.pickup_time??W?.pickTime??W?.pickupTime),drop_time:D(W?.drop_time??W?.dropTime)})),N=I.filter(W=>W?.id!=null&&String(W.id).trim()!==""),V=I.filter(W=>!(W?.id!=null&&String(W.id).trim()!==""));return{route_id:r??"",edit_stoppage:N,add_stoppage:V,delete_stoppage:Array.isArray(P)?P:[]}},u=j=>{j.preventDefault();const P="/api/branchapi/transport/addstoppageToRoute",I=_(a,o);O(P,I)},h=()=>{s(j=>[...Array.isArray(j)?j:[],{idKey:ui++,stop_name:"",pickup_time:te().format("h:mm a"),drop_time:te().format("h:mm a")}])},S=j=>{if(a.length===1)return;const P=a[j];P?.id!=null&&String(P.id).trim()!==""&&!P?.idKey&&d(I=>{const N=Array.isArray(I)?I:[];return N.some(W=>String(W)===String(P.id))?N:[...N,P.id]}),s(I=>{const N=[...I];return N.splice(j,1),N})},E=j=>{g(P=>({...P,pagination:{current:j,pageSize:P.pagination.pageSize}}))},F=async j=>{const P="/api/branchapi/Transport/deletevehicle";try{await m(He(P,j,t),ze(j)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(k==="Success"){const j=Array.isArray(R?.data)?R.data:[];j.length>0?(s(j),d([])):r&&(s([{idKey:ui++,stop_name:"",pickup_time:te().format("h:mm a"),drop_time:te().format("h:mm a")}]),d([]))}},[k,R,r]);const q=j=>{const{children:P=[]}=j||{},I=[{title:"Stop Name",dataIndex:"stop_name",onCell:N=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:N=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:N=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:ci}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:I,rowKey:N=>T(N)+"cell01",dataSource:P,pagination:!1})})})},T=j=>{const P=["id","index"];for(let I=0;I<P.length;I++)if(j[P[I]])return j[P[I]]},U=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(j,P,I)=>e.jsx(e.Fragment,{children:(Array.isArray(P.children)?P.children:[]).map((N,V,W)=>e.jsx("span",{children:`${N.stop_name} ${V+1===W.length?"":","}`},`${V}vehicle001`))})},{title:"Action",render:(j,P,I)=>e.jsx(e.Fragment,{children:e.jsx(yt,{id:P?.route_id,funcName:F})})}];return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(v,{pt:5,pb:1,children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Q,{options:x,value:x.find(j=>String(j.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:j=>{l(j?.value??null),s([]),d([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:r&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:h,children:e.jsx(ee.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(ne,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{l(null),s([]),d([])},style:cm,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:a.length>0&&a.map((j,P)=>{const I=j.pickup_time?te(j.pickup_time,"h:mm a"):null,N=j.drop_time?te(j.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:j.stop_name??"",type:"text",name:`stoppage[${P}][name]`,label:"Place Name*",required:"required",onChange:V=>{const W=V?.target?.value??"";s(B=>{const $=[...B];return $[P]={...$[P]??{},stop_name:W},$})}}),j?.id!=null&&String(j.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${P}][id]`,value:String(j.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:oi,children:"Pick Time"}),e.jsx(n.TimePicker,{value:I,use12Hours:!0,format:"h:mm a",name:`stoppage[${P}][pickTime]`,allowClear:!1,style:di,onChange:V=>{const W=V?V.format("h:mm a"):"";s(B=>{const $=[...B];return $[P]={...$[P]??{},pickup_time:W},$})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:oi,children:"Drop Time"}),e.jsx(n.TimePicker,{value:N,use12Hours:!0,format:"h:mm a",name:`stoppage[${P}][drop_time]`,allowClear:!1,style:di,onChange:V=>{const W=V?V.format("h:mm a"):"";s(B=>{const $=[...B];return $[P]={...$[P]??{},drop_time:W},$})}})]}),e.jsx("div",{style:{marginBottom:8},children:a.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>S(P),children:e.jsx(ee.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},j.idKey?j.idKey+"exp":j.id+"exp")})})]})}),e.jsx(v,{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(v,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:ci}},columns:U,bordered:!0,size:"small",rowKey:j=>T(j),dataSource:b,loading:y,expandable:{expandedRowRender:q,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:C,showSizeChanger:!0,onChange:E,onShowSizeChange:(j,P)=>{g(I=>({...I,pagination:{current:1,pageSize:P}}))},showTotal:(j,P)=>`${P[0]}-${P[1]} of ${j} items`}})})]})]})}const{Step:Sn}=n.Steps;function pm({token:t}){const[a,s]=i.useState(0),[r,l]=i.useState(void 0),[o,d]=i.useState(void 0),[c,g]=i.useState(!1),[y,p]=i.useState(null),[m,A]=i.useState(!1),[C,b]=i.useState(!1),[f,x]=i.useState(!1),[R,k]=i.useState([]),[O,D]=i.useState(null),[_,u]=i.useState(null),[h,S]=i.useState(!1),{isLoading:E,data:F}=H(t?[tn,t]:null,([M,L])=>K(M,L)),{isLoading:q,data:T}=H(h?[h,t]:null,([M,L])=>K(M,L)),{data:U}=H(c?[c,t]:null,([M,L])=>K(M,L)),j=i.useMemo(()=>[{title:"Excel Row",dataIndex:"row",width:90,render:M=>M??"-"},{title:"Student Name",dataIndex:"student_name_system",render:M=>M?e.jsx("span",{style:{color:"#d97706"},children:M}):"-"},{title:"Route",dataIndex:"route",render:M=>M||"-"},{title:"Vehicle",dataIndex:"vehicle",render:M=>M||"-"},{title:"Stop",dataIndex:"stop",render:M=>M||"-"},{title:"Start Date",dataIndex:"start_date",render:M=>M||"-"},{title:"Transport Fee",dataIndex:"transport_fee",render:M=>M??"-"},{title:"Status",dataIndex:"status",width:110,render:M=>{const Y={Valid:"success",Invalid:"error",Duplicate:"warning",Imported:"success",Skipped:"warning",Failed:"error"}[M]||"default";return e.jsx("span",{style:{color:Y,fontWeight:500},children:M})}},{title:"Message",dataIndex:"message",render:M=>M?e.jsx("span",{style:{color:"#dc2626"},children:M}):"-"}],[]),P=()=>{p(null),A(!1),b(!1),x(!1),k([]),D(null),u(null),l(void 0),d(void 0),g(!1),s(0)},I=async()=>{try{const M=await xu({class_id:r?.value,section_id:o?.value},t),L=window.URL.createObjectURL(M),Y=document.createElement("a");Y.href=L,Y.download="transport-bulk-template.xlsx",document.body.appendChild(Y),Y.click(),document.body.removeChild(Y),window.URL.revokeObjectURL(L),w.success("Template downloaded.",{duration:1e3})}catch(M){w.error(M?.message||"Failed to download template.",{duration:1e3})}},N=async()=>{if(!y){w.error("Please select an Excel file to upload.",{duration:1e3});return}b(!0),k([]),D(null),u(null);try{const M=await bu(y,t);if(M.Status!=="Success"){w.error(M.msg||"Validation failed.",{duration:1e3}),b(!1);return}D(M.data?.summary||null),k(M.data?.rows||[]),s(2),w.success(M.msg||"Validation complete.",{duration:1e3})}catch(M){w.error(M?.message||"Validation failed.",{duration:1e3})}finally{b(!1)}},V=async()=>{if(!R.length){w.error("No rows provided to import.",{duration:1e3});return}x(!0),u(null);try{const M=await ju(R,t,"skip");if(M.Status!=="Success"){w.error(M.msg||"Import failed.",{duration:1e3}),x(!1);return}u(M.data||null),s(3),w.success(M.msg||"Import completed.",{duration:1e3})}catch(M){w.error(M?.message||"Import failed.",{duration:1e3})}finally{x(!1)}},W=async M=>{if(!M||!M.length){w.error("No rows provided.",{duration:1e3});return}try{const L=await Su(M,t),Y=window.URL.createObjectURL(L),se=document.createElement("a");se.href=Y,se.download="transport-bulk-error-report.xlsx",document.body.appendChild(se),se.click(),document.body.removeChild(se),window.URL.revokeObjectURL(Y),w.success("Error report downloaded.",{duration:1e3})}catch(L){w.error(L?.message||"Failed to download error report.",{duration:1e3})}},B=i.useMemo(()=>R.length?(_?_.rows:R).filter(L=>!["Valid","Imported"].includes(L.status)):[],[R,_]),$={background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"};return e.jsx(v,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:$,children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Transport / Bulk Upload"})}),e.jsxs(v,{p:3,children:[e.jsxs(n.Steps,{current:a,style:{marginBottom:16},children:[e.jsx(Sn,{title:"Download Template"}),e.jsx(Sn,{title:"Upload & Validate"}),e.jsx(Sn,{title:"Review"}),e.jsx(Sn,{title:"Import Result"})]}),a===0&&e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:4,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:Array.isArray(F)?F:[],value:r,onChange:M=>{l(M),M?g(`${an}?class_id=${M.value}`):(d(void 0),g(!1))},showSearch:!0,allowClear:!0})})}),e.jsx(n.Col,{xs:24,md:4,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:Array.isArray(U)?U:[],value:o,onChange:d,showSearch:!0,allowClear:!0})})}),e.jsx(n.Col,{xs:24,md:4,style:{marginTop:20},children:e.jsx(v,{children:e.jsx(n.Button,{type:"primary",onClick:I,block:!0,children:"Download Excel Template"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{mt:1,children:e.jsx(n.Button,{type:"primary",onClick:()=>s(1),children:"Next: Upload Excel"})})})]}),a===1&&e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsxs(v,{children:[e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:M=>(p(M),!1),children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),block:!0,disabled:m||C,children:y?y.name:"Choose Excel File (.xlsx)"})}),y&&e.jsxs(v,{mt:.5,display:"flex",alignItems:"center",gap:1,children:[e.jsxs(pe,{level:6,color:"textSecondary",children:[(y.size/1024).toFixed(1)," KB"]}),e.jsx(n.Button,{size:"small",danger:!0,onClick:()=>p(null),children:"Remove"})]})]})}),e.jsx(n.Col,{xs:24,md:3,children:e.jsx(v,{children:e.jsx(ne,{type:"button",value:C?"Validating...":"Validate & Preview",color:"primary",onClick:N,disabled:C||!y})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Button,{type:"text",size:"small",onClick:()=>{P(),s(0)},children:"Back"})})]}),a===2&&e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsx(pe,{level:6,color:"textSecondary",children:"Total"}),e.jsx(pe,{level:4,children:O?.total??R.length})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsx(pe,{level:6,color:"textSecondary",children:"Valid"}),e.jsx(pe,{level:4,style:{color:"#52c41a"},children:O?.valid??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsx(pe,{level:6,color:"textSecondary",children:"Invalid"}),e.jsx(pe,{level:4,style:{color:"#ff4d4f"},children:O?.invalid??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsx(pe,{level:6,color:"textSecondary",children:"Duplicate"}),e.jsx(pe,{level:4,style:{color:"#faad14"},children:O?.duplicate??0})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(n.Table,{dataSource:R.map((M,L)=>({...M,key:`${M.row}-${L}`})),columns:j,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:(M,L)=>`${L[0]}-${L[1]} of ${M} items`}})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[8,8],align:"middle",children:[e.jsx(n.Col,{children:e.jsx(ne,{type:"button",value:f?"Importing...":"Import Valid Rows",color:"primary",onClick:V,disabled:f})}),e.jsx(n.Col,{children:e.jsx(n.Button,{size:"small",onClick:()=>W(B),disabled:!B.length,children:"Download Error Report"})}),e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",size:"small",onClick:()=>{P(),s(1)},children:"Upload Another File"})})]})})]}),a===3&&e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsxs(pe,{level:6,color:"textSecondary",children:["Total "," "]}),e.jsx(pe,{level:4,children:_?.total??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsxs(pe,{level:6,color:"textSecondary",children:["Imported "," "]}),e.jsx(pe,{level:4,style:{color:"#52c41a"},children:_?.imported??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsxs(pe,{level:6,color:"textSecondary",children:["Skipped "," "]}),e.jsx(pe,{level:4,style:{color:"#faad14"},children:_?.skipped??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(v,{p:1.5,children:[e.jsxs(pe,{level:6,color:"textSecondary",children:["Failed "," "]}),e.jsx(pe,{level:4,style:{color:"#ff4d4f"},children:_?.failed??0})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(n.Table,{dataSource:(_?.rows||[]).map((M,L)=>({...M,key:`${M.row}-${L}`})),columns:j,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:(M,L)=>`${L[0]}-${L[1]} of ${M} items`}})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[8,8],align:"middle",children:[e.jsx(n.Col,{children:e.jsx(n.Button,{size:"small",onClick:()=>W(B),disabled:!B.length,children:"Download Error Report"})}),e.jsx(n.Col,{children:e.jsx(n.Button,{type:"primary",size:"small",onClick:P,children:"Upload Another File"})})]})})]})]})]})})})})}const mm=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},so=t=>{const a=$t(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},pi=(t,a,s)=>{const r=`${t||""}`.trim();if(!r)return"";if(/^https?:\/\//i.test(r))return r;const l=a?.fk_branchID??so(s),o=r.startsWith("/")?r.slice(1):r;return mm(Ke(),`uploads/school_${l}/student/homework/${o}`)},mi={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ka=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function hm({token:t}){const[a,s]=i.useState("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),[r,l]=i.useState({page:1,rowsPerPage:10}),[o,d]=i.useState(null),[c,g]=i.useState(null),[y,p]=i.useState(null),[m,A]=i.useState(null),[C,b]=i.useState(!1),[f,x]=i.useState(null),[R,k]=i.useState(null),[O,D]=i.useState(null),[_,u]=i.useState(null),[h,S]=i.useState(null),[E,F]=i.useState(null),[q,T]=i.useState(!1),[U,j]=i.useState(""),[P,I]=i.useState(""),[N,V]=i.useState(""),[W,B]=i.useState(!1),$=(ue,we)=>{const Ve=ue?.value??null;switch(we){case"class_id":d(Ve),g(null),p(null);break;case"section_id":g(Ve);break;case"subject_id":p(Ve);break}},{data:M}=H(t?["api/branchapi/academy/classdropdownlist",t]:null,([ue,we])=>K(ue,we)),{data:L}=H(t&&h?[h,t]:null,([ue,we])=>K(ue,we)),{data:Y}=H(t&&E?[E,t]:null,([ue,we])=>K(ue,we)),se=o?`api/branchapi/academy/sectionoftheClass?class_id=${o}`:null,{data:X}=H(t&&se?[se,t]:null,([ue,we])=>K(ue,we)),G=o?`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${o}`:null,{data:J}=H(t&&G?[G,t]:null,([ue,we])=>K(ue,we)),re=i.useMemo(()=>ka(M),[M]),de=i.useMemo(()=>ka(L),[L]),Ce=i.useMemo(()=>ka(Y),[Y]),le=i.useMemo(()=>ka(X),[X]),oe=i.useMemo(()=>ka(J),[J]),ie=t&&a?`${a}class_id=${o||""}&subject_id=${y||""}&section_id=${c||""}&date=${m?.format("YYYY-MM-DD")||""}&page=${r.page}&per_page=${r.rowsPerPage}`:null,{isLoading:Se,error:Ee,data:Xe,mutate:be}=H(ie?[ie,t]:null,([ue,we])=>K(ue,we)),ve=async(ue,we)=>{try{await be(Ne(ue,we,t),Ge(we)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),at()}catch(Ve){console.error(Ve),w.error("Failed to add the new item.",{duration:1e3})}},Oe=async ue=>{try{await be(He("api/student/Homework/deleteHomework",ue,t),ze(ue)),w.success("Success! Deleted item.",{duration:1e3})}catch(we){console.error(we),w.error("Failed to delete the item.",{duration:1e3})}},Ye=async ue=>{try{const we=await We("api/student/Homework/updateHomework",ue,t);be(we),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),at()}catch(we){console.error(we),w.error("Failed to update the item.",{duration:1e3})}},Be=ue=>{ue.preventDefault();const we=new FormData(ue.target),Ve=we.get("class_id")||o,dt=we.get("section_id")||c,Ft=we.get("subject_id")||y,Pt=m?.format("YYYY-MM-DD");s(`api/branchapi/homeworks/gethomeworklistByClassSectionBranch?class_id=${Ve||""}&subject_id=${Ft||""}&section_id=${dt||""}${Pt?`&date=${Pt}`:""}&`),l(me=>({...me,page:1}))},Le=ue=>{ue.preventDefault();const we=new FormData(ue.target);ve("api/branchapi/homeworks/addHomework",we),V("")},Ze=async(ue,we)=>{ue.preventDefault();const Ve=new FormData(ue.target);Ve.append("id",we),B(!0);try{await Ye(Ve)}finally{B(!1)}},at=()=>{b(!1),x(null),k(null),D(null),u(null),S(null),F(null),V("")},fe=ue=>{x(ue);const we=ue?.class_id??ue?.classId??null,Ve=ue?.section_id??ue?.sectionId??null,dt=ue?.subject_id??ue?.subjectId??null;k(we),D(Ve),u(dt),we?(S(`api/branchapi/academy/sectionoftheClass?class_id=${we}`),F(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${we}`)):(S(null),F(null)),V(ue?.file||ue?.document||""),b(!0)},je=ue=>{const we=ue?.value??null;k(we),D(null),u(null),we?(S(`api/branchapi/academy/sectionoftheClass?class_id=${we}`),F(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${we}`)):(S(null),F(null))},xe=ue=>{D(ue?.value??null)},ae=ue=>{u(ue?.value??null)},he=(ue,we)=>{l({page:ue,rowsPerPage:parseInt(we,10)})},ye=()=>{T(!1),j(""),I("")},ke=(ue,we)=>{if(!ue){w.error("No document found.",{duration:1e3});return}j(ue),I(we||"Document"),T(!0)},Pe=[{title:"Date",dataIndex:"homework_date",key:"homework_date"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission Date",dataIndex:"submit_date",key:"submit_date"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Document",key:"document",render:(ue,we)=>{const Ve=we?.document||we?.file||"";if(!Ve)return e.jsx("span",{style:{color:"#999",fontSize:12},children:"Not Uploaded"});const dt=pi(Ve,we,t);return e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>ke(dt,Ve),children:"View"})}},{title:"Action",key:"action",render:(ue,we)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>fe(we),style:{padding:2}}),e.jsx(yt,{id:we?.id,funcName:Oe})]})}];return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Search Homework"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:Be,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:re,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:re.find(ue=>String(ue.value)===String(o))??null,onChange:ue=>$(ue,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:le,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:le.find(ue=>String(ue.value)===String(c))??null,onChange:ue=>$(ue,"section_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:oe.find(ue=>String(ue.value)===String(y))??null,onChange:ue=>$(ue,"subject_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Ue,{Desplay:"Date",format:"YYYY-MM-DD",allowClear:!1,value:m,onChange:ue=>A(ue)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(v,{children:[e.jsx(ne,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{s("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),d(null),g(null),p(null),A(null)},style:mi,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Homework List"})}),e.jsx(v,{p:3,children:e.jsx(Ie,{parentCallback:he,data:{newData:Xe,columns:Pe,columnstype:"antd",action:!1,Loading:Se,error:Ee,deleteTodoMutation:Oe,pageController:r}})})]})})]}),e.jsx(n.Drawer,{open:C,title:f?"Edit Homework":"Add Homework",placement:"right",width:600,destroyOnClose:!0,onClose:at,children:e.jsx("form",{onSubmit:f?ue=>Ze(ue,f.id):Le,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:re,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,placeholder:"Select Class",value:re.find(ue=>String(ue.value)===String(R))??null,onChange:je})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:de,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,placeholder:R?"Select Section":"Select Class First",value:de.find(ue=>String(ue.value)===String(O))??null,onChange:xe,isDisabled:!R})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{options:Ce,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"sub_id",required:!0,allowSelectAll:!1,placeholder:R?"Select Subject":"Select Class First",value:Ce.find(ue=>String(ue.value)===String(_))??null,onChange:ae,isDisabled:!R})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:f?.homew_date?te(f?.homew_date):te(),Desplay:"From",name:"homew_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:f?.submission_date?te(f?.submission_date):te(),Desplay:"Deadline",name:"submission_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{type:"text",label:"Title",name:"title",defaultValue:f?.title||"",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(lt,{type:"text",label:"Description",name:"description",defaultValue:f?.description||"",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:`${Ke()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${so(t)}/student/homework`},headers:{Authorization:t},maxCount:1,onChange:ue=>{if(ue.file.status==="removed"&&V(""),ue.file.status==="done"){const we=ue.file.response?.data??ue.file.response?.file??"";V(String(we??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:N?"Change":"Upload"})}),N&&f&&e.jsx("a",{href:pi(N,f,t),target:"_blank",rel:"noreferrer",style:{display:"block",marginTop:8,fontSize:12,color:"#1677ff",textDecoration:"underline"},children:"View existing document"}),e.jsx("input",{type:"hidden",name:"file",value:N||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(v,{children:[e.jsx(ne,{type:"submit",value:W?"Saving...":"Save",color:"primary",disabled:W}),e.jsx(n.Button,{type:"text",onClick:at,style:mi,children:"Cancel"})]})})})})]})})}),e.jsx(n.Modal,{open:q,onCancel:ye,footer:null,width:900,closable:!0,children:e.jsxs(v,{p:3,children:[e.jsx(v,{mb:2,children:e.jsx(pe,{level:5,children:P||"View Document"})}),U?U.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:U,title:P||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:U,alt:P||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(pe,{children:"No document found"})]})}),e.jsx(v,{style:{position:"fixed",bottom:24,right:24,zIndex:1e3},children:e.jsx(n.Button,{type:"primary",size:"large",onClick:()=>{x(null),k(null),D(null),u(null),S(null),F(null),V(""),b(!0)},style:{borderRadius:"50%",width:56,height:56,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24},children:"+"})})]})}const Ts=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function fm({token:t}){const[a,s]=i.useState(!1),[r,l]=i.useState(null),[o,d]=i.useState(null),[c,g]=i.useState({page:1,rowsPerPage:10}),[y,p]=i.useState(!1),[m,A]=i.useState(""),[C,b]=i.useState(""),[f,x]=i.useState({label:"",value:""}),[R,k]=i.useState({label:"",value:""}),[O,D]=i.useState({label:"",value:""}),[_,u]=i.useState(!1),[h,S]=i.useState(!1),{data:E}=H(t?["api/branchapi/academy/classdropdownlist",t]:null,([X,G])=>K(X,G)),{data:F}=H(t&&a?[a,t]:null,([X,G])=>K(X,G)),{data:q}=H(t&&(r||!0)?[r||"api/branchapi/academy/subjecttableList",t]:null,([X,G])=>K(X,G)),T=i.useMemo(()=>Ts(E),[E]),U=i.useMemo(()=>Ts(F),[F]),j=i.useMemo(()=>Ts(q),[q]),P=t&&o?`${o}page=${c.page}&per_page=${c.rowsPerPage}`:null,{isLoading:I,error:N,data:V,mutate:W}=H(P?[P,t]:null,([X,G])=>K(X,G)),B=(X,G)=>{switch(G){case"class_id":x(X||{label:"",value:""}),k({label:"",value:""}),D({label:"",value:""}),l(`/api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${X?.value??""}`),s(`/api/branchapi/academy/sectionoftheClass?class_id=${X?.value??""}`),u(J=>!J),S(J=>!J);break;case"section_id":k(X||{label:"",value:""});break;case"subject_id":D(X||{label:"",value:""});break}},$=async X=>{X.preventDefault();const G="/api/branchapi/homeworks/gethomeworklistByClassSectionBranch",J=new URLSearchParams;f.value&&J.append("class_id",String(f.value)),R.value&&J.append("section_id",String(R.value)),O.value&&J.append("subject_id",String(O.value));const re=J.toString(),de=re?`${G}?${re}&`:`${G}?`;g(Ce=>({...Ce,page:1})),d(de),await W()},M=(X,G)=>{g({page:X,rowsPerPage:parseInt(G,10)})},L=()=>{p(!1),A(""),b("")},Y=(X,G)=>{A(X),b(G||"Document"),p(!0)},se=[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Assign By",dataIndex:"staff_name",key:"staff_name"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission",dataIndex:"total_submission",key:"total_submission"},{title:"View Document",key:"document",render:(X,G)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>Y(G.document_url,G.document),children:"View"})}];return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Submission Details"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:$,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:T.find(X=>String(X.value)===String(f.value))??null,onChange:X=>B(X,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:U.find(X=>String(X.value)===String(R.value))??null,onChange:X=>k(X||{label:"",value:""})},`sections1${_}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:j.find(X=>String(X.value)===String(O.value))??null,onChange:X=>D(X||{label:"",value:""})},`subjects1${h}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})})]})})})]})}),o&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Students List"})}),e.jsx(v,{p:3,children:e.jsx(Ie,{parentCallback:M,data:{newData:V,columns:se,columnstype:"antd",action:!1,Loading:I,error:N,pageController:c}})})]})})]}),e.jsx(n.Modal,{open:y,onClose:L,footer:null,width:900,children:e.jsxs(v,{p:3,children:[e.jsxs(v,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(pe,{level:5,children:C||"View Document"}),e.jsx(ne,{type:"button",value:"Close",color:"primary",onClick:L})]}),m?m.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:m,title:C||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:m,alt:C||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(pe,{children:"No document found"})]})})]})}const ym=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${s}/${r}`};function gm({token:t,sampleFileUrl:a}){const s=t??localStorage.getItem("authToken")??"",[r,l]=i.useState(null),[o,d]=i.useState(null),[c,g]=i.useState(null),[y,p]=i.useState(null),[m,A]=i.useState(null),[C,b]=i.useState(null),[f,x]=i.useState(null),R="api/branchapi/library/bookCategorydropdown",k="api/branchapi/academy/classdropdownlist",O="api/branchapi/Academy/getClassSubjectdropdown",D="api/branchapi/library/addBook",_="api/branchapi/library/uploadcsv",{data:u}=H(s?[R,s]:null,([P,I])=>K(P,I)),{data:h}=H(s&&k?[k,s]:null,([P,I])=>K(P,I)),{data:S}=H(s&&O?[O,s]:null,([P,I])=>K(P,I)),E=i.useMemo(()=>ym(bt(),_),[_]),F=async P=>{P.preventDefault();const I=new FormData(P.target);I.set("cat_id",m?.value??""),I.set("class_id",C?.value??""),I.set("subject_id",f?.value??"");try{await Ne(D,I,s),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),P.target.reset(),A(null),b(null),x(null)}catch(N){w.error(N?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},q=async P=>{if(P.preventDefault(),!r){w.error("Please select a CSV file.",{duration:1e3});return}const I=new FormData;I.append("file",r),I.append("cat_id",o?.value??""),I.append("class_id",c?.value??""),I.append("subject_id",y?.value??"");try{const N=await Je.post(E,I,{headers:{Authorization:s,"Content-type":"multipart/form-data"}});N?.data?.Status==="Failed"?w.error(String(N?.data?.msg??"Upload failed."),{duration:1e3}):(w.success(String(N?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),l(null),P.target.reset(),d(null),g(null),p(null))}catch(N){w.error(N?.response?.data?.msg??"Upload failed.",{duration:1e3})}},T=()=>["title,author,publisher,quantity,price,fine,subject_id,barcode,class_id",...["Advanced Chemistry,Rahul Mondal,RM PUBLISHER,10,210,20,1,,1","Advanced Chemistry,Rahul Mondal,RM PUBLISHER,10,210,20,1,123321,1"]].join(`
60
+ `),U=()=>{if(a)return a;const P=bt();return P?`${P.replace(/\/+$/,"")}/books.csv`:"/books.csv"},j=()=>{const P=U();fetch(P).then(I=>{if(!I.ok)throw new Error("Sample file not found");const N=I.headers.get("content-type")||"";return!N.includes("csv")&&!N.includes("text/plain")&&!N.includes("application/octet-stream")?I.text().then(V=>{if(V.trim().startsWith("<")||V.includes("<!doctype")||V.includes("<html"))throw new Error("Sample file URL returned HTML. Host the CSV at a public URL and pass it via sampleFileUrl prop.");return new Blob([V],{type:"text/csv"})}):I.blob()}).then(I=>{const N=window.URL.createObjectURL(I),V=document.createElement("a");V.href=N,V.download="books.csv",V.click(),window.URL.revokeObjectURL(N)}).catch(()=>{const I=T(),N=new Blob([I],{type:"text/csv"}),V=window.URL.createObjectURL(N),W=document.createElement("a");W.href=V,W.download="books.csv",W.click(),window.URL.revokeObjectURL(V)})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(n.Button,{type:"link",icon:e.jsx(ee.DownloadOutlined,{}),onClick:j,children:"Download Sample"}),children:[e.jsx(n.Divider,{children:"Information"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:16},children:"1. Your CSV data should be in the format below. The first line of your CSV file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:P=>d(P??null)}),e.jsx(Q,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:c,onChange:P=>g(P??null)}),e.jsx(Q,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:y,onChange:P=>p(P??null)}),e.jsx(z,{type:"file",label:"Upload CSV/Excel",name:"csv",accept:".csv,.xlsx,.xls",onChange:P=>l(P.target.files?.[0]??null),required:!0}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit: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",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(Q,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:m,onChange:P=>A(P??null)}),e.jsx(Q,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:C,onChange:P=>b(P??null)}),e.jsx(Q,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:f,onChange:P=>x(P??null)}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})})]})}const Rs={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Is=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function xm({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState([]),[l,o]=i.useState([]),d=i.useRef(),c={selectedRowKeys:s,onChange:(J,re)=>{r(J),o(re)}},g=ea.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),y=()=>{if(!(typeof window>"u")){if(!l.length){w.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){w.error("Nothing to print.",{duration:1e3});return}g?.()}},[p,m]=i.useState(!1),[A,C]=i.useState(null),[b,f]=i.useState(null),[x,R]=i.useState(null),[k,O]=i.useState(null),[D,_]=i.useState({page:1,rowsPerPage:10}),u=(J,re)=>{_({page:J,rowsPerPage:parseInt(re,10)})},h="api/branchapi/library/booktable",S="api/branchapi/library/deletebooks",E="api/branchapi/library/editbook",F=`${h}?page=${D.page}&per_page=${D.rowsPerPage}`,{isLoading:q,error:T,data:U,mutate:j}=H(a?[F,a]:null,([J,re])=>K(J,re)),P="api/branchapi/library/bookCategorydropdown",I="api/branchapi/academy/classdropdownlist",N="api/branchapi/Academy/getClassSubjectdropdown",{data:V}=H(a?[P,a]:null,([J,re])=>K(J,re)),{data:W}=H(a&&I?[I,a]:null,([J,re])=>K(J,re)),{data:B}=H(a&&N?[N,a]:null,([J,re])=>K(J,re)),$=i.useMemo(()=>Is(V),[V]),M=i.useMemo(()=>Is(W),[W]),L=i.useMemo(()=>Is(B),[B]),Y=async J=>{try{await He(S,J,a),await j(),w.success("Success! Deleted item.",{duration:1e3})}catch(re){w.error(re?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},se=J=>{C(J??null);const re=J?.cat_id??J?.fk_cat_id??J?.category_id,de=J?.class_id??J?.fk_class_id,Ce=J?.subject_id??J?.fk_subject_id;f($.find(le=>le?.value===re)??null),R(M.find(le=>le?.value===de)??null),O(L.find(le=>le?.value===Ce)??null),m(!0)},X=async J=>{J.preventDefault();const re=A?.id??A?.book_id??A?._id;if(!re)return;const de=new FormData(J.target);de.set("id",String(re)),de.set("cat_id",b?.value??""),de.set("class_id",x?.value??""),de.set("subject_id",k?.value??"");try{await We(E,de,a),await j(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),m(!1),C(null)}catch(Ce){w.error(Ce?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},G=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:(J,re)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>se(re),style:{padding:2}}),e.jsx(n.Button,{type:"text",size:"small",danger:!0,onClick:()=>Y(re?.id??re?.book_id??re?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[$,M,Y,L]);return e.jsxs("div",{style:{},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:p,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{m(!1),C(null)},children:e.jsx("form",{onSubmit:X,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(z,{label:"Book Name",name:"title",defaultValue:A?.book_title??"",required:!0}),e.jsx(z,{label:"Author",name:"author",defaultValue:A?.author??"",required:!0}),e.jsx(z,{label:"Publication",name:"publish",defaultValue:A?.publish??""}),e.jsx(z,{label:"Qty",name:"quantity",type:"number",defaultValue:A?.quantity??""}),e.jsx(z,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:A?.perunitcost??""}),e.jsx(z,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:A?.fine_amount??""}),e.jsx(z,{label:"Barcode",name:"barcode",defaultValue:A?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Rs,children:"Category"}),e.jsx(Q,{options:$,value:b,onChange:J=>f(J??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Rs,children:"Class"}),e.jsx(Q,{options:M,value:x,onChange:J=>R(J??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Rs,children:"Subject"}),e.jsx(Q,{options:L,value:k,onChange:J=>O(J??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{m(!1),C(null)},children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:l.length>0?e.jsxs(n.Button,{type:"primary",onClick:y,children:["Print Barcode (",l.length,")"]}):null,children:e.jsx(Ie,{parentCallback:u,data:{newData:U,columns:G,columnstype:"antd",action:!1,Loading:q,error:T,rowSelection:c}})}),e.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:e.jsx("div",{ref:d,style:{padding:"20px"},children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:l.map((J,re)=>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:J.book_title}),e.jsx(gl,{value:J.barcode?String(J.barcode):String(J.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},re))})})})]})}const bm=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${s}/${r}`},Ut=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},vn=t=>te(t).add(1,"month").format("YYYY-MM-DD"),jm=i.forwardRef(({token:t,onReturn:a},s)=>{const r=t??localStorage.getItem("authToken")??"",[l,o]=i.useState("issue"),d=l==="return",[c,g]=i.useState(!1),[y,p]=i.useState(!1),[m,A]=i.useState(null),[C,b]=i.useState([]),[f,x]=i.useState([]),[R,k]=i.useState([]),[O,D]=i.useState(0),[_,u]=i.useState(!1),[h,S]=i.useState(null),[E,F]=i.useState(null),[q,T]=i.useState(null),[U,j]=i.useState(!1),[P,I]=i.useState("Cash"),[N,V]=i.useState(""),[W,B]=i.useState(""),[$,M]=i.useState(0),[L,Y]=i.useState("NO_FINE"),se=i.useRef(null),[X]=n.Form.useForm(),[G]=n.Form.useForm(),J="api/branchapi/library/bookCategorydropdown",re="api/branchapi/academy/classdropdownlist",de="api/branchapi/Academy/getClassSubjectdropdown",{data:Ce}=H(r?[J,r]:null,([ce,_e])=>K(ce,_e)),{data:le}=H(r&&re?[re,r]:null,([ce,_e])=>K(ce,_e)),{data:oe}=H(r&&de?[de,r]:null,([ce,_e])=>K(ce,_e)),ie=i.useMemo(()=>Ut(Ce),[Ce]),Se=i.useMemo(()=>Ut(le),[le]),Ee=i.useMemo(()=>Ut(oe),[oe]),Xe="api/branchapi/library/studentsearchByNameID",be="api/branchapi/library/booksearchBybookname",ve="api/branchapi/library/issuedBookList",Oe="api/branchapi/library/issueLibrarybook",Ye="api/branchapi/library/returnedLibrarybook",{trigger:Be,data:Le}=rt(Xe,(ce,_e)=>Qt(ce,_e,r)),{trigger:Ze,data:at}=rt(be,(ce,_e)=>Qt(ce,_e,r)),{trigger:fe,data:je}=rt(ve,(ce,_e)=>Qt(ce,_e,r)),{trigger:xe}=rt(d?Ye:Oe,(ce,_e)=>ss(ce,_e,r)),ae=i.useMemo(()=>Ut(Le),[Le]),he=i.useMemo(()=>Ut(at),[at]),ye=i.useMemo(()=>Ut(je),[je]),ke=ce=>{const _e=vn(te());b(qe=>qe.some(et=>String(et?.id)===String(ce?.id))?qe:[...qe,{...ce,return_date:ce?.return_date?ce.return_date:_e}])},Pe=async()=>{console.log("Reloading IssueReturn..."),w.success("Success",{duration:1e3}),x([]),k([]),D(0),Y("FINE_PAY_LATER"),await fe({id:m?.student_id})};i.useImperativeHandle(s,()=>({reloadPayLater:Pe}));const ue=ce=>{b(_e=>_e.filter(qe=>String(qe?.id)!==String(ce)))},we=async ce=>{if(r){if(!ce){A(null);return}c||await Be({id:ce})}},Ve=async({search:ce})=>{if(!r||!c)return;const _e=await Be({id:ce}),qe=Ut(_e);qe.length===1&&(A(qe[0]),await fe({id:qe[0]?.student_id}),X.resetFields())},dt=async(ce,_e)=>{A(_e??null),b([]),x([]),k([]),D(0),Y("NO_FINE"),M(0),_e?.student_id&&await fe({id:_e.student_id}),X.resetFields()},Ft=async ce=>{r&&ce&&(y||await Ze({book:ce}))},Pt=async({search_book:ce})=>{if(!r||!y)return;const _e=await Ze({book:ce,catID:h?.value??"",sID:q?.value??"",cID:E?.value??""}),qe=Ut(_e);qe.length&&(ke(qe[0]),G.resetFields())},me=(ce,_e)=>{ke(_e),G.resetFields()},Ae=async()=>{if(!m?.member_id){w.error("Select a student first.",{duration:1e3});return}if(!C.length){w.error("Select at least one book.",{duration:1e3});return}const ce=await xe({member_id:m.member_id,fine:!1,books:C});ce?.Status==="Success"&&(w.success(String(ce?.msg??"Success"),{duration:1e3}),b([]),A(null),x([]),k([]),D(0))},ut=async()=>{if(!m?.member_id){w.error("Select a student first.",{duration:1e3});return}if(!R.length){w.error("Select at least one book to return.",{duration:1e3});return}if(Number(O)>0){Y("FINE_PAID"),j(!0);return}const ce=await xe({member_id:m.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(R)});ce?.Status==="Success"?(w.success(String(ce?.msg??"Success"),{duration:1e3}),x([]),k([]),D(0),await fe({id:m?.student_id})):w.error(String(ce?.msg??"Failed"),{duration:1e3})},vt=async()=>{if(!m?.member_id)return;const ce=Math.max(0,Number(O)-Number($||0)),_e={member_id:m.member_id,collection_type:L,amount:L==="FINE_PAID"?ce:0,payment_type:P,notes:N,attchement:W,discount:$||0,books:JSON.stringify(R)},qe=await xe(_e);j(!1),qe?.Status==="Success"?(w.success(String(qe?.msg??"Success"),{duration:1e3}),x([]),k([]),D(0),M(0),V(""),B(""),Y("NO_FINE"),await fe({id:m?.student_id})):w.error(String(qe?.msg??"Failed"),{duration:1e3})},cn=async()=>{if(!m?.member_id){w.error("Select a student first.",{duration:1e3});return}if(!R.length){w.error("Select at least one book to return.",{duration:1e3});return}const ce={member_id:m.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(R)};a(ce)},un=i.useMemo(()=>bm(bt(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),pn=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Author",dataIndex:"author",key:"author",width:180,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ce,_e)=>e.jsx(Ue,{defaultValue:te(_e?.return_date||te().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(qe,et)=>{b(ct=>ct.map(gt=>String(gt?.id)===String(_e?.id)?{...gt,return_date:et}:gt))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(ce,_e)=>e.jsx(n.Button,{type:"text",danger:!0,onClick:()=>ue(_e?.id),children:"Remove"})}],mn={selectedRowKeys:f,onChange:(ce,_e)=>{x(ce),k(_e);const qe=(_e??[]).reduce((et,ct)=>et+Number(ct?.totalfine??0),0);D(qe)},onSelect:(ce,_e,qe)=>{if(_e){const et=qe.map(ct=>({...ct,return_date:ct?.return_date?ct.return_date:vn(ct?.issue_date||te())}));k(et)}},onSelectAll:(ce,_e)=>{if(ce){const qe=_e.map(et=>({...et,return_date:et?.return_date?et.return_date:vn(et?.issue_date||te())}));k(qe)}}},hn=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ce,_e)=>{const et=R.find(gt=>String(gt?.id)===String(_e?.id))?.return_date||_e?.return_date,ct=vn(_e?.issue_date||te());return e.jsx(Ue,{defaultValue:te(et||ct),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(gt,ps)=>{k(ms=>ms.map(_a=>String(_a?.id)===String(_e?.id)?{..._a,return_date:ps}:_a))}})}},{title:"Days",key:"days",width:100,render:(ce,_e)=>{const et=R.find(gt=>String(gt?.id)===String(_e?.id))?.return_date||_e?.return_date,ct=_e?.issue_date;if(ct&&et){const gt=te(et).diff(te(ct),"day");return gt>=0?gt:0}return"-"}},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:ce=>e.jsxs("span",{children:["₹ ",ce]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:U,onCancel:()=>j(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(n.Radio.Group,{value:P,onChange:ce=>I(ce.target.value),options:[{label:"Cash",value:"Cash"},{label:"UPI",value:"UPI"},{label:"DD",value:"DD"},{label:"Bank",value:"Bank"},{label:"Internet Banking",value:"Internet Banking"},{label:"Cheque",value:"Cheque"}]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Note"}),e.jsx(n.Input.TextArea,{rows:3,value:N,onChange:ce=>V(ce.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(n.Upload,{action:un,headers:{Authorization:r},maxCount:1,onChange:ce=>{if(ce.file.status==="done"){const _e=ce.file.response?.data??ce.file.response?.file??"";B(String(_e??""))}},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(n.Input,{type:"number",value:$,onChange:ce=>M(ce.target.value),placeholder:"0"})]}),e.jsxs(n.Button,{type:"primary",onClick:vt,children:["Collect ₹",Math.max(0,Number(O)-Number($||0))]}),e.jsx(n.Button,{onClick:()=>j(!1),children:"Cancel"})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:10,children:e.jsx(n.Radio.Group,{value:l,onChange:ce=>{const _e=ce.target.value;o(_e),b([]),x([]),k([]),D(0),Y("NO_FINE"),M(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(n.Col,{xs:24,md:14,children:e.jsx(n.Form,{form:X,onFinish:Ve,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search",label:"Search Student",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:c?e.jsx(n.Input,{autoFocus:!0,addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ce=>g(ce.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{options:ae,onSelect:dt,onSearch:we,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ce=>g(ce.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),m?e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{}),e.jsxs(n.Row,{gutter:[12,12],children:[e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Name:"})," ",m?.value??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Card No:"})," ",m?.library_card_no??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Member ID:"})," ",m?.member_id??""]})]})]}):null,e.jsx(n.Divider,{}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(n.Table,{dataSource:ye,columns:hn,rowSelection:mn,pagination:!1,rowKey:ce=>ce?.id??ce?.issue_id??ce?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(n.Typography.Text,{strong:!0,children:["Total Fine: ₹",O]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(n.Button,{type:"primary",onClick:ut,disabled:!R.length,children:O>0?`Pay Now ₹ ${Math.max(0,Number(O)-Number($||0))}`:"Return Selected"}),O>0?e.jsx(n.Button,{onClick:cn,disabled:!R.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:18,children:e.jsx(n.Form,{form:G,onFinish:Pt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:y?e.jsx(n.Input,{autoFocus:!0,disabled:!m,addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:y,onChange:ce=>p(ce.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{disabled:!m,options:he,onSelect:me,onSearch:Ft,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:y,onChange:ce=>p(ce.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(n.Button,{style:{width:"100%"},icon:e.jsx(ee.FilterOutlined,{}),onClick:()=>u(!0),children:"Filter"})})]}),e.jsx(n.Drawer,{open:_,onClose:()=>u(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{label:"Category",options:ie,value:h,onChange:ce=>S(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(Q,{label:"Class",options:Se,value:E,onChange:ce=>F(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(Q,{label:"Subjects",options:Ee,value:q,onChange:ce=>T(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(n.Button,{type:"primary",onClick:()=>u(!1),children:"Apply"})]})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(n.Table,{dataSource:C,columns:pn,pagination:!1,rowKey:ce=>ce?.id??ce?.book_id??ce?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Issue",onClick:Ae})})]})]}),e.jsx("div",{ref:se,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}),hi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Sm({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[l,o]=i.useState(null),[d,c]=i.useState(null),[g,y]=i.useState(!1),[p,m]=i.useState(!1),[A,C]=i.useState(null),[b,f]=i.useState(!1),x="api/branchapi/academy/classdropdownlist",R="api/branchapi/academy/sectionoftheClass",k="api/branchapi/library/studenttableForLibrary",O="api/branchapi/library/addmembershipforStudent",D="api/branchapi/library/removemembershipforStudent",_=i.useMemo(()=>{if(!l?.value)return null;const B=R.includes("?")?"&":"?";return`${R}${B}class_id=${encodeURIComponent(String(l.value))}`},[R,l?.value]),u=i.useMemo(()=>{if(!l?.value||!d?.value)return null;const B=k.includes("?")?"&":"?";return`${k}${B}cID=${encodeURIComponent(String(l.value))}&sID=${encodeURIComponent(String(d.value))}&page=${s.page}&per_page=${s.rowsPerPage}`},[s.page,s.rowsPerPage,l?.value,d?.value,k]),{data:h}=H(a&&x?[x,a]:null,([B,$])=>K(B,$)),{data:S}=H(a&&_?[_,a]:null,([B,$])=>K(B,$)),{isLoading:E,error:F,data:q,mutate:T}=H(a&&u?[u,a]:null,([B,$])=>K(B,$)),U=i.useMemo(()=>hi(h),[h]),j=i.useMemo(()=>hi(S),[S]),P=(B,$)=>{r({page:B,rowsPerPage:parseInt($,10)})},I=B=>{const $=B?.id??B?.student_id??B?.member_id;C($??null),m(!0),f(M=>!M)},N=async B=>{if(B.preventDefault(),!A)return;const $=new FormData(B.target);$.set("id",String(A));try{await Ne(O,$,a),w.success("Success! Added member.",{duration:1e3,icon:"🎉"}),m(!1),C(null),await T()}catch(M){w.error(M?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},V=async B=>{try{await He(D,B,a),w.success("Success! Removed member.",{duration:1e3}),await T()}catch($){w.error($?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},W=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:(B,$)=>(console.log("data______________",$),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:$?.library_card_no==null?e.jsx(n.Button,{type:"primary",size:"small",icon:e.jsx(ee.UserAddOutlined,{}),onClick:()=>I($)}):e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>V($?.id??$?.student_id??$?.member_id)})}))}],[V]);return e.jsxs("div",{style:{},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:p,title:"Add Member",onCancel:()=>{m(!1),C(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(ne,{type:"submit",value:"Add",color:"primary"})})]})},`add-${b}`)}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Student"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:l,onChange:B=>{o(B??null),c(null),y($=>!$)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(Q,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:B=>c(B??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${g}`),e.jsx(ne,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!l?.value||!d?.value){w.error("Select class and section.",{duration:1e3});return}r(B=>({...B,page:1}))}})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Ie,{parentCallback:P,data:{newData:q,columns:W,columnstype:"antd",action:!1,Loading:E,error:F}})})]})}function vm({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[l]=n.Form.useForm(),[o]=n.Form.useForm(),[d,c]=i.useState(!1),[g,y]=i.useState(null),p="api/branchapi/library/BookCategorytable",m="api/branchapi/library/addBookCategory",A="api/branchapi/library/editBookCategory",C="api/branchapi/library/deleteBookCategory",b=i.useMemo(()=>{const F=p.includes("?")?"&":"?";return`${p}${F}page=${s.page}&per_page=${s.rowsPerPage}`},[p,s.page,s.rowsPerPage]),{isLoading:f,error:x,data:R,mutate:k}=H(a&&b?[b,a]:null,([F,q])=>K(F,q)),O=(F,q)=>{r({page:F,rowsPerPage:parseInt(q,10)})},D=async F=>{const q=new FormData;q.set("title",F?.title??"");try{await Ne(m,q,a),w.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),l.resetFields(),await k()}catch(T){w.error(T?.response?.data?.msg??T?.message??"Failed to add category.",{duration:1e3})}},_=F=>{y(F??null),o.setFieldsValue({title:F?.name??""}),c(!0)},u=()=>{c(!1),y(null),o.resetFields()},h=async F=>{const q=g?.id??g?.category_id??g?.cat_id;if(!q){w.error("Missing category id.",{duration:1e3});return}const T=new FormData;T.set("id",String(q)),T.set("title",F?.title??"");try{await We(A,T,a),w.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),u(),await k()}catch(U){w.error(U?.response?.data?.msg??U?.message??"Failed to update category.",{duration:1e3})}},S=async F=>{const q=F?.id??F?.category_id??F?.cat_id;if(!q){w.error("Missing category id.",{duration:1e3});return}try{await He(C,q,a),w.success("Success! Deleted category.",{duration:1e3}),await k()}catch(T){w.error(T?.response?.data?.msg??T?.message??"Failed to delete category.",{duration:1e3})}},E=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(F,q)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>_(q)}),e.jsx(n.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>S(q),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[S]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:d,title:"Edit Category",onCancel:u,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:h,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:u,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsx(ne,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Ie,{parentCallback:O,data:{newData:R,columns:E,columnstype:"antd",action:!1,Loading:f,error:x}})})})]})]})}const ks=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function wm({token:t}){const[a,s]=i.useState([te().format("YYYY-MM-DD"),te().format("YYYY-MM-DD")]),[r,l]=i.useState(null),[o,d]=i.useState(null),[c,g]=i.useState(null),[y,p]=i.useState(!1),[m,A]=i.useState(!1),C="api/branchapi/academy/classdropdownlist",b="api/branchapi/academy/sectionoftheClass",f="api/branchapi/library/memberDropdown",x="api/report/libraryReport/libraryReport",R=i.useMemo(()=>{if(!r?.value)return null;const I=b.includes("?")?"&":"?";return`${b}${I}class_id=${encodeURIComponent(String(r.value))}`},[b,r?.value]),k=i.useMemo(()=>{if(!r?.value)return null;const I=f.includes("?")?"&":"?",N=`${f}${I}class=${encodeURIComponent(String(r.value))}`;return o?.value?`${N}&section=${encodeURIComponent(String(o.value))}`:N},[f,r?.value,o?.value]),{isLoading:O,error:D,data:_,mutate:u}=H(t&&C?[C,t]:null,([I,N])=>K(I,N)),{data:h}=H(t&&R?[R,t]:null,([I,N])=>K(I,N)),{data:S}=H(t&&k?[k,t]:null,([I,N])=>K(I,N)),E=i.useMemo(()=>ks(_),[_]),F=i.useMemo(()=>ks(h),[h]),q=i.useMemo(()=>ks(S),[S]),{trigger:T,data:U}=rt(x,(I,N)=>nr(I,N,t));i.useEffect(()=>{(async()=>{A(!0);try{await T({duration:a})}finally{A(!1)}})()},[]);const j=async()=>{A(!0);try{await T({duration:a,class:r?.value??"",section:o?.value??"",student_id:c?.value??""})}finally{A(!1)}},P=[{title:"Name",dataIndex:"full_name",render:(I,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(I,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(I,N)=>e.jsxs(n.Typography.Text,{style:{fontSize:12},children:[N?.class??"","(",N?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(I,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.book_title??""})},{title:"Issue Date",key:"date",render:(I,N,V)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.issue_date??""})},{title:"Due Return Date",key:"date",render:(I,N,V)=>e.jsx(n.Tag,{color:"orange",children:N?.return_date??""})},{title:"Return Date",key:"date",render:(I,N,V)=>N?.retured_by_user?e.jsx(n.Tag,{color:"green",children:N?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(I,N,V)=>String(N?.is_returned??"")==="1"?e.jsx(n.Tag,{color:"green",children:"Return"}):e.jsx(n.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(I,N,V)=>{const W=N?.late_fine?Number(N.late_fine):0;return W?e.jsx(n.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:W}):null}}];return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{style:{width:"100%"},value:[te(a[0],"YYYY-MM-DD"),te(a[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(I,N)=>{Array.isArray(N)&&N.length===2&&s([N[0],N[1]])}})]})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Q,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:I=>{l(I??null),d(null),g(null),p(N=>!N)},allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Q,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:o,onChange:I=>{d(I??null),g(null)},allowSelectAll:!1},`section1${y}`)}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Q,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:I=>g(I??null),allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:1,children:e.jsx(n.Button,{type:"primary",icon:e.jsx(ee.SearchOutlined,{}),onClick:j,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(n.Table,{columns:P,pagination:!1,dataSource:Array.isArray(U?.data)?U.data:[],size:"small",rowKey:(I,N)=>I?.id??I?.issue_id??I?.fees_receipt_id??N,loading:m,scroll:{x:"max-content"},summary:I=>{const N=I.reduce((W,B)=>W+Number(B?.late_fine??0),0),V=I.reduce((W,B)=>W+Number(B?.is_returned??0),0);return e.jsxs(n.Table.Summary.Row,{children:[e.jsx(n.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",I.length]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(I.length-V)]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",V]})}),e.jsx(n.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",N.toLocaleString("en-IN")]})})]})}})})]})]})}const fi=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],yi=[{key:"renewalHistory",label:"Renewal History"},{key:"renewalFineReport",label:"Renewal + Fine"},{key:"currentlyRenewedBooks",label:"Currently Renewed"},{key:"upcomingRenewalDue",label:"Upcoming Due"},{key:"overdueRenewalReport",label:"Overdue"},{key:"renewalLimitReport",label:"Renewal Limit"},{key:"renewalStatusReport",label:"Renewal Status"},{key:"studentWiseReport",label:"Student-wise"},{key:"bookWiseReport",label:"Book-wise"},{key:"classWiseReport",label:"Class-wise"},{key:"staffWiseReport",label:"Staff-wise"},{key:"renewalStatisticsByDate",label:"Statistics by Date"}];function _m({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState("renewalHistory"),[l,o]=i.useState("This Month"),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(7),[A,C]=i.useState(1),[b,f]=i.useState(20),[x,R]=i.useState(""),[k,O]=i.useState("DESC"),D=i.useRef(null),_=N=>{const V=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s)&&(V.set("date_range",l),l==="Custom"&&d&&g&&(V.set("from_date",d),V.set("to_date",g))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(s)&&(V.set("page",String(A)),V.set("per_page",String(b))),s==="upcomingRenewalDue"&&V.set("days_ahead",String(p)),x&&V.set("sort_by",x),k&&V.set("sort_dir",k),`${N}?${V.toString()}`},u=i.useMemo(()=>{switch(s){case"renewalHistory":return _(_c);case"renewalFineReport":return _(Cc);case"currentlyRenewedBooks":return _(Ac);case"upcomingRenewalDue":return _(Dc);case"overdueRenewalReport":return _(Tc);case"renewalLimitReport":return _(Rc);case"renewalStatusReport":return _(Ic);case"studentWiseReport":return _(kc);case"bookWiseReport":return _(Pc);case"classWiseReport":return _(Oc);case"staffWiseReport":return _(Mc);case"renewalStatisticsByDate":return _(Ec);default:return null}},[s,l,d,g,p,A,b]),{data:h,isLoading:S}=H(a?[u,a]:null,([N,V])=>K(N,V)),E=h?.data||{},F=E?.rows||[],q=E?.pagination||{},T=N=>{r(N),C(1),f(20)},U=()=>{C(1)},j=()=>{switch(s){case"renewalHistory":case"renewalFineReport":return[{title:"Renewal ID",dataIndex:"renewal_id",key:"renewal_id"},{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Renewal No",dataIndex:"renewal_no",key:"renewal_no"},{title:"Old Due Date",dataIndex:"old_due_date",key:"old_due_date"},{title:"New Due Date",dataIndex:"new_due_date",key:"new_due_date"},{title:"Renewal Date",dataIndex:"renewal_date",key:"renewal_date"},{title:"Status",dataIndex:"status",key:"status",render:N=>e.jsx(n.Tag,{color:N==="renewed"?"green":"red",children:N})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:N=>N??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:N=>N?e.jsx(n.Tag,{color:N==="paid"?"green":N==="partial"?"orange":"red",children:N}):"-"}];case"currentlyRenewedBooks":case"upcomingRenewalDue":case"overdueRenewalReport":case"renewalLimitReport":case"renewalStatusReport":return[{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Due Date",dataIndex:"return_date",key:"return_date"},{title:"Renewal Count",dataIndex:"renewal_count",key:"renewal_count"},{title:"Max Renewal",dataIndex:"maximum_renewal",key:"maximum_renewal"},{title:"Days Remaining",dataIndex:"days_remaining",key:"days_remaining",render:N=>N??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:N=>N??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:N=>e.jsx(n.Tag,{color:N?"green":"red",children:N?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:N=>Array.isArray(N)?N.join("; "):"-"}];case"studentWiseReport":return[{title:"Student ID",dataIndex:"student_id",key:"student_id"},{title:"Student Name",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Books",dataIndex:"unique_books_renewed",key:"unique_books_renewed"},{title:"First Renewal",dataIndex:"first_renewal_date",key:"first_renewal_date"},{title:"Last Renewal",dataIndex:"last_renewal_date",key:"last_renewal_date"}];case"bookWiseReport":return[{title:"Book ID",dataIndex:"book_id",key:"book_id"},{title:"Title",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Category",dataIndex:"category",key:"category"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"classWiseReport":return[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"staffWiseReport":return[{title:"Staff",dataIndex:"renewed_by",key:"renewed_by"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];case"renewalStatisticsByDate":return[{title:"Period",dataIndex:"period",key:"period"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];default:return[]}},P=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s),I=i.useMemo(()=>j(),[s]);return e.jsx(v,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,padding:"4px 8px",color:"#fff",display:"inline-block"}}),e.jsxs(v,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[P&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Q,{options:fi,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:fi.find(N=>N.value===l)||null,onChange:N=>o(N?.value||"This Month")})}),l==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Ue,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:N=>c(N?N.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Ue,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:N=>y(N?N.format("YYYY-MM-DD"):"")})})]})]}),s==="upcomingRenewalDue"&&e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Q,{options:[{label:"7 Days",value:7},{label:"14 Days",value:14},{label:"30 Days",value:30}],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Days Ahead",allowSelectAll:!1,value:{label:p+" Days",value:p},onChange:N=>m(N?.value||7)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:U})})})]}),e.jsx(n.Tabs,{activeKey:s,onChange:T,items:yi})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:yi.find(N=>N.key===s)?.label||"Report"})}),e.jsxs(v,{p:3,children:[e.jsx(Ct,{data:{tableRef:D}}),S?e.jsx(v,{py:8,textAlign:"center",children:e.jsx(n.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(n.Table,{size:"small",dataSource:F,columns:I,loading:S,pagination:!1,bordered:!0,rowKey:N=>N.renewal_id||N.id||JSON.stringify(N),ref:D}),F.length>0&&e.jsx(n.Pagination,{current:A,pageSize:b,total:q.total_rows||F.length,onChange:(N,V)=>{C(N),f(V)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const rs=t=>t??localStorage.getItem("authToken")??"",Cm=(t,a)=>{const s=String(t??""),r=String(a);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Qe={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"}},Am=()=>Cm(bt(),Qe.upload),Dm=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const l=t.includes("?")?"&":"?",o=`${t}${l}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(o,rs(r))},nn=async(t,a,s)=>Ne(t,a,rs(s)),va=async(t,a,s)=>We(t,a,rs(s)),sn=async(t,a,s)=>He(t,a,rs(s)),Tm=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",xa=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:Am(),headers:r,onChange:l=>{if(l?.file?.status==="done"){const o=Tm(l?.file?.response);o&&s?.(o)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},$n=Qe.vendor,rn=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>H(r&&t?[t,a,s,r]:null,([o,d,c,g])=>Dm({baseUrl:o,page:d,perPage:c},g)),Rm=({token:t,page:a=1,perPage:s=10})=>rn({baseUrl:$n.list,page:a,perPage:s,token:t}),Im={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},gi=[{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 km({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),{isLoading:y,error:p,data:m,mutate:A}=Rm({token:t,page:a.page,perPage:a.rowsPerPage}),C=async D=>{try{await A(nn($n.add,D,t),Ge(D)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(_){w.error(_?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},b=D=>{D.preventDefault();const _=new FormData(D.target);c&&_.set("image",c),C(_),D.target.reset(),g("")},f=(D,_)=>{s({page:D,rowsPerPage:parseInt(_,10)})},x=async D=>{try{await A(sn($n.remove,D,t),ze(D)),w.success("Success! Deleted item.",{duration:1e3})}catch(_){w.error(_?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},R=D=>{d(D),l(!0),g("")},k=async D=>{D.preventDefault();const _=new FormData(D.target);_.set("id",String(o?.id??"")),c&&_.set("image",c);try{await va($n.edit,_,t),await A(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null),g("")}catch(u){w.error(u?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},O=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:(D,_)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>R(_),style:{padding:2}}),e.jsx(yt,{id:_?.id,funcName:x})]})}],[x]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{l(!1),d(null),g("")},children:e.jsx("form",{onSubmit:k,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[gi.map(D=>e.jsx(z,{type:D.type,name:D.name,label:D.label,defaultValue:o?.[D.name]??"",required:D.required?"required":void 0},D.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(xa,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null),g("")},style:Im,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[gi.map(D=>e.jsx(z,{type:D.type,name:D.name,label:D.label,required:D.required?"required":void 0},D.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(xa,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{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(v,{pt:3,children:e.jsx(Ie,{parentCallback:f,data:{newData:m,columns:O,columnstype:"antd",action:!1,Loading:y,error:p}})})]})]})]})}const Pm=({token:t})=>e.jsx(km,{token:t}),Fn=Qe.product,xi=Qe.vendor.dropdown,bi=Qe.category.dropdown,Om=Qe.subCategory.dropdown,ji=Qe.unit.dropdown,ro=({token:t,page:a=1,perPage:s=10})=>rn({baseUrl:Fn.list,page:a,perPage:s,token:t}),Mm=({token:t})=>H(t&&xi?[xi,t]:null,([s,r])=>K(s,r)),Em=({token:t})=>H(t&&bi?[bi,t]:null,([s,r])=>K(s,r)),$m=({token:t})=>H(t&&ji?[ji,t]:null,([s,r])=>K(s,r)),Fm=({token:t,categoryId:a})=>{const s=t&&a?`${Om}?category_id=${encodeURIComponent(String(a))}`:null;return H(s?[s,t]:null,([l,o])=>K(l,o))},wn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},Um={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Nm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState(""),[C,b]=i.useState(""),[f,x]=i.useState(""),{isLoading:R,error:k,data:O,mutate:D}=ro({token:t,page:a.page,perPage:a.rowsPerPage}),{data:_}=Mm({token:t}),{data:u}=Em({token:t}),{data:h}=$m({token:t}),{data:S}=Fm({token:t,categoryId:y}),E=i.useMemo(()=>wn(_),[_]),F=i.useMemo(()=>wn(u),[u]),q=i.useMemo(()=>wn(h),[h]),T=i.useMemo(()=>wn(S),[S]),U=async B=>{try{await D(nn(Fn.add,B,t),Ge(B)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch($){w.error($?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=B=>{B.preventDefault();const $=new FormData(B.target);y&&$.set("fk_categoryID",String(y)),m&&$.set("fk_sub_categoryID",String(m)),C&&$.set("vendor_id",String(C)),f&&$.set("unit",String(f)),c&&$.set("image",c),U($),B.target.reset(),g(""),p(""),A(""),b(""),x("")},P=(B,$)=>{s({page:B,rowsPerPage:parseInt($,10)})},I=async B=>{try{await D(sn(Fn.remove,B,t),ze(B)),w.success("Success! Deleted item.",{duration:1e3})}catch($){w.error($?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},N=B=>{d(B),l(!0),g(""),p(B?.fk_categoryID??B?.category_id??""),A(B?.fk_sub_categoryID??B?.sub_category_id??""),b(B?.vendor_id??""),x(B?.unit??B?.unit_id??"")},V=async B=>{B.preventDefault();const $=new FormData(B.target);$.set("id",String(o?.id??"")),y&&$.set("fk_categoryID",String(y)),m&&$.set("fk_sub_categoryID",String(m)),C&&$.set("vendor_id",String(C)),f&&$.set("unit",String(f)),c&&$.set("image",c);try{await va(Fn.edit,$,t),await D(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null),g("")}catch(M){w.error(M?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},W=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:(B,$)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>N($),style:{padding:2}}),e.jsx(yt,{id:$?.id,funcName:I})]})}],[I]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{l(!1),d(null),g("")},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:o?.name??"",required:"required"}),e.jsx(Q,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:B=>{const $=B?.value??"";p($),A("")},defaultValue:y?F.find(B=>String(B?.value)===String(y)):null}),e.jsx(Q,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:B=>A(B?.value??""),defaultValue:m?T.find(B=>String(B?.value)===String(m)):null}),e.jsx(z,{type:"text",name:"barcode",label:"Barcode",defaultValue:o?.barcode??""}),e.jsx(Q,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:B=>x(B?.value??""),defaultValue:f?q.find(B=>String(B?.value)===String(f)):null}),e.jsx(z,{type:"number",name:"quantity",label:"Quantity*",defaultValue:o?.quantity??"",required:"required"}),e.jsx(z,{type:"number",name:"price",label:"Price*",defaultValue:o?.price??"",required:"required"}),e.jsx(Q,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:B=>b(B?.value??""),defaultValue:C?E.find(B=>String(B?.value)===String(C)):null}),e.jsx(z,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:o?.hsn_code??""}),e.jsx(lt,{type:"text",label:"Description",name:"description",rows:3,defaultValue:o?.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(xa,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null),g("")},style:Um,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:j,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(Q,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:B=>{const $=B?.value??"";p($),A("")}}),e.jsx(Q,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:B=>A(B?.value??"")},`subcat_${y}`),e.jsx(z,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(Q,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:B=>x(B?.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(Q,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:B=>b(B?.value??"")}),e.jsx(z,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(lt,{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(xa,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{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(v,{pt:3,children:e.jsx(Ie,{parentCallback:P,data:{newData:O,columns:W,columnstype:"antd",action:!1,Loading:R,error:k}})})]})]})]})}const Bm=({token:t})=>e.jsx(Nm,{token:t}),Un=Qe.category,Lm=({token:t,page:a=1,perPage:s=10})=>rn({baseUrl:Un.list,page:a,perPage:s,token:t}),qm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function zm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),{isLoading:c,error:g,data:y,mutate:p}=Lm({token:t,page:a.page,perPage:a.rowsPerPage}),m=async k=>{try{await p(nn(Un.add,k,t),Ge(k)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(O){w.error(O?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},A=k=>{k.preventDefault();const O=new FormData(k.target);m(O),k.target.reset()},C=(k,O)=>{s({page:k,rowsPerPage:parseInt(O,10)})},b=async k=>{try{await p(sn(Un.remove,k,t),ze(k)),w.success("Success! Deleted item.",{duration:1e3})}catch(O){w.error(O?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},f=k=>{d(k),l(!0)},x=async k=>{k.preventDefault();const O=new FormData(k.target);O.set("id",String(o?.id??""));try{await va(Un.edit,O,t),await p(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null)}catch(D){w.error(D?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(k,O)=>String(k?.name??"").localeCompare(String(O?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(k,O)=>String(k?.description??"").localeCompare(String(O?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(k,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(O),style:{padding:2}}),e.jsx(yt,{id:O?.id,funcName:b})]})}],[b]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{l(!1),d(null)},children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"name",label:"Name",defaultValue:o?.name??"",required:"required"}),e.jsx(z,{type:"text",name:"description",label:"Description",defaultValue:o?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null)},style:qm,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(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(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{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(v,{pt:3,children:e.jsx(Ie,{parentCallback:C,data:{newData:y,columns:R,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const Ym=({token:t})=>e.jsx(zm,{token:t}),Nn=Qe.subCategory,Si=Qe.category.dropdown,Vm=({token:t,page:a=1,perPage:s=10})=>rn({baseUrl:Nn.list,page:a,perPage:s,token:t}),Wm=({token:t})=>H(t&&Si?[Si,t]:null,([s,r])=>K(s,r)),Hm=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},Km={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Gm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),{isLoading:y,error:p,data:m,mutate:A}=Vm({token:t,page:a.page,perPage:a.rowsPerPage}),{data:C}=Wm({token:t}),b=i.useMemo(()=>Hm(C),[C]),f=async u=>{try{await A(nn(Nn.add,u,t),Ge(u)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(h){w.error(h?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},x=u=>{u.preventDefault();const h=new FormData(u.target);h.set("status","active"),h.set("img",c||""),f(h),u.target.reset(),g("")},R=(u,h)=>{s({page:u,rowsPerPage:parseInt(h,10)})},k=async u=>{try{await A(sn(Nn.remove,u,t),ze(u)),w.success("Success! Deleted item.",{duration:1e3})}catch(h){w.error(h?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},O=u=>{d(u),l(!0)},D=async u=>{u.preventDefault();const h=new FormData(u.target);h.set("id",String(o?.id??"")),c&&h.set("img",c);try{await va(Nn.edit,h,t),await A(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null),g("")}catch(S){w.error(S?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},_=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(u,h)=>String(u?.name??"").localeCompare(String(h?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(u,h)=>String(u?.description??"").localeCompare(String(h?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(u,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>O(h),style:{padding:2}}),e.jsx(yt,{id:h?.id,funcName:k})]})}],[k]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{l(!1),d(null),g("")},children:e.jsx("form",{onSubmit:D,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:o?.category_id?b.find(u=>String(u?.value)===String(o.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(z,{type:"text",name:"name",label:"Name*",defaultValue:o?.name??"",required:"required"}),e.jsx(z,{type:"text",name:"description",label:"Description",defaultValue:o?.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(xa,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null),g("")},style:Km,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:b,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(xa,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{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(v,{pt:3,children:e.jsx(Ie,{parentCallback:R,data:{newData:m,columns:_,columnstype:"antd",action:!1,Loading:y,error:p}})})]})]})]})}const Jm=({token:t})=>e.jsx(Gm,{token:t}),Ps=Qe.product,Qm=Qe.academy.classes,Xm=Qe.academy.sections,Zm=Qe.student.dropdown;function Pa(t){const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]}function _n(t,a){const s=Math.trunc(Number(t)||1),r=Math.max(1,s);return!Number.isFinite(Number(a))||Number(a)<=0?r:Math.min(r,Math.trunc(Number(a)))}function pt(t){return String(t??"")}function eh({token:t}){const[a,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState(!1),[y,p]=i.useState(""),[m,A]=i.useState([]),[C,b]=i.useState({}),[f,x]=i.useState({}),[R,k]=i.useState(!1),[O,D]=i.useState(""),[_,u]=i.useState(0),[h,S]=i.useState(""),[E,F]=i.useState(te()),[q,T]=i.useState([]),U={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},j=!!(a&&r&&o),{data:P}=H(t?[Qm,t]:null,([fe,je])=>K(fe,je)),I=i.useMemo(()=>Pa(P),[P]),N=t&&a?`${Xm}?class_id=${encodeURIComponent(String(a))}`:null,{data:V}=H(N?[N,t]:null,([fe,je])=>K(fe,je)),W=i.useMemo(()=>Pa(V),[V]),B=t&&a&&r?`${Zm}?class=${encodeURIComponent(String(a))}&section=${encodeURIComponent(String(r))}`:null,{data:$}=H(B?[B,t]:null,([fe,je])=>K(fe,je)),M=i.useMemo(()=>Pa($),[$]),L=j?`${Ps.list}?page=1&per_page=10000`:null,{data:Y,isLoading:se}=H(t&&L?[L,t]:null,([fe,je])=>K(fe,je),{revalidateOnFocus:!1}),X=i.useMemo(()=>Pa(Y),[Y]),G=i.useMemo(()=>{const fe=new Map;return(Array.isArray(X)?X:[]).forEach(je=>{fe.set(pt(je?.id),je)}),fe},[X]),J=i.useMemo(()=>{const fe=Object.entries(f||{});return fe.length===0?[]:fe.map(([je,xe])=>{const ae=G.get(pt(je));return ae?{id:ae?.id,name:ae?.name,barcode:ae?.barcode,stock:Number(ae?.quantity||0),price:Number(ae?.price||0),quantity:_n(xe,Number(ae?.quantity||0))}:null}).filter(Boolean)},[f,G]),re=i.useMemo(()=>new Set(J.map(fe=>pt(fe?.id))),[J]),de=i.useMemo(()=>(Array.isArray(J)?J:[]).reduce((je,xe)=>je+Number(xe?.price||0)*Number(xe?.quantity||1),0),[J]),Ce=i.useMemo(()=>{const fe=Number(_||0);return!Number.isFinite(fe)||fe<=0?0:Math.min(fe,de)},[_,de]),le=i.useMemo(()=>Math.max(0,de-Ce),[Ce,de]),oe=i.useMemo(()=>(Array.isArray(X)?X:[]).slice(0,30).map(fe=>({value:pt(fe?.id),label:`${fe?.name??""}${fe?.barcode?` • ${fe.barcode}`:""}${fe?.quantity!==void 0&&fe?.quantity!==null?` • Stock: ${fe.quantity}`:""}`,product:fe})),[X]),{trigger:ie}=rt(t&&j?Ps.search:null,(fe,{arg:je})=>Qt(fe,{arg:je},t));i.useEffect(()=>{if(!j){A([]);return}const fe=String(y||"").trim();if(fe.length<2){A(oe);return}let je=!0;const xe=setTimeout(async()=>{let ae=[];try{if(ie){const ye=await ie({search:fe});ae=Pa(ye)}}catch{ae=[]}if(!Array.isArray(ae)||ae.length===0){const ye=fe.toLowerCase();ae=(Array.isArray(X)?X:[]).filter(ke=>{const Pe=String(ke?.name??"").toLowerCase(),ue=String(ke?.barcode??"").toLowerCase();return Pe.includes(ye)||ue.includes(ye)}).slice(0,30)}const he=ae.slice(0,30).map(ye=>({value:pt(ye?.id),label:`${ye?.name??""}${ye?.barcode?` • ${ye.barcode}`:""}${ye?.quantity!==void 0&&ye?.quantity!==null?` • Stock: ${ye.quantity}`:""}`,product:ye}));je&&A(he)},250);return()=>{je=!1,clearTimeout(xe)}},[oe,j,ie,X,y]),i.useEffect(()=>{x({}),b({}),p(""),A([]),k(!1),D(""),u(0),S(""),F(te()),T([])},[a,r,o]);const Se=i.useCallback((fe,je=1)=>{const xe=fe?.id;if(!xe)return;const ae=Number(fe?.quantity||0);if(ae<=0){w.error("Out of stock.",{duration:1e3});return}const he=_n(je,ae);x(ye=>{const ke=ye||{};return Object.prototype.hasOwnProperty.call(ke,pt(xe))?(w.error("Product already added.",{duration:1e3}),ke):{...ke,[pt(xe)]:he}})},[x]),Ee=i.useCallback((fe,je,xe)=>{x(ae=>{const he=ae||{},ye=pt(fe);return Object.prototype.hasOwnProperty.call(he,ye)?{...he,[ye]:_n(je,xe)}:he})},[]),Xe=i.useCallback(fe=>{x(je=>{const xe=je||{},ae=pt(fe);if(!Object.prototype.hasOwnProperty.call(xe,ae))return xe;const he={...xe};return delete he[ae],he})},[]),be=i.useCallback((fe,je,xe)=>{b(ae=>({...ae||{},[pt(fe)]:_n(je,xe)}))},[]),ve=i.useCallback((fe,je)=>{je?.product&&Se(je.product,1),p(""),A(oe)},[Se,oe]),Oe=i.useCallback(fe=>{if(fe.key!=="Enter")return;fe.preventDefault();const je=Array.isArray(m)&&m.length>0?m[0]:null;if(je?.product){Se(je.product,1),p(""),A(oe);return}const xe=String(y||"").trim().toLowerCase();if(xe.length===0)return;const ae=(Array.isArray(X)?X:[]).find(he=>{const ye=String(he?.name??"").toLowerCase(),ke=String(he?.barcode??"").toLowerCase();return ye.includes(xe)||ke.includes(xe)});ae&&(Se(ae,1),p(""),A(oe))},[Se,oe,X,m,y]),Ye=()=>{if(!t){w.error("Missing token.",{duration:1e3});return}if(!a){w.error("Select class.",{duration:1e3});return}if(!r){w.error("Select section.",{duration:1e3});return}if(!o){w.error("Select student.",{duration:1e3});return}if(!J||J.length===0){w.error("Add at least one product.",{duration:1e3});return}k(!0)},{trigger:Be,isMutating:Le}=rt(t?Ps.sellProduct:null,(fe,{arg:je})=>ss(fe,{arg:je},t)),Ze=async()=>{if(!O){w.error("Select payment type.",{duration:1e3});return}const fe=(Array.isArray(J)?J:[]).map(xe=>({id:xe?.id,quantity:Number(xe?.quantity||1),price:Number(xe?.price||0),total_price:Number(xe?.total_price||0),fk_vendor_id:xe?.fk_vendor_id||"",fk_categoryID:xe?.fk_categoryID||"",name:xe?.name||"",class_id:xe?.class_id||"",fk_sub_categoryID:xe?.fk_sub_categoryID||"",description:xe?.description||"",min_quantity:Number(xe?.min_quantity||0),storecategory:Number(xe?.storecategory||0),barcode:xe?.barcode||""})),je={amount:de,class:a,section:r,student_id:o,payment_type:O,discount:Ce,notes:h||"",receipt_date:E?te(E).format("YYYY-MM-DD"):"",product:JSON.stringify(fe),total_payable_amount:de,attchement:q[0]?.originFileObj||""};try{const ae=Array.isArray(q)&&q.length>0&&q[0]?.originFileObj?(()=>{const ye=new FormData;return Object.entries(je).forEach(([ke,Pe])=>{if(ke==="products"){ye.append("product",JSON.stringify(Pe));return}ye.append(ke,String(Pe??""))}),ye.append("attachment",q[0].originFileObj),ye})():je,he=await Be(ae);he?.Status==="Success"?(w.success("Success! Product sold.",{duration:1e3}),k(!1),x({}),b({}),p(""),A(oe),D(""),u(0),S(""),F(te()),T([])):w.error(he?.msg??"Failed to submit.",{duration:1e3})}catch{w.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:(fe,je)=>{const xe=pt(je?.id),ae=Number(je?.quantity||0),he=re.has(xe),ye=(he?f?.[xe]:C?.[xe])??1;return e.jsx(n.InputNumber,{min:1,max:Number.isFinite(ae)&&ae>0?ae:void 0,value:ye,onChange:ke=>{he?Ee(xe,ke,ae):be(xe,ke,ae)},disabled:ae<=0})}},{title:"Amount",key:"amount",width:140,render:(fe,je)=>{const xe=pt(je?.id),ae=(re.has(xe)?f?.[xe]:C?.[xe])??1;return Number(je?.price||0)*Number(ae||1)}},{title:"Action",key:"action",width:120,render:(fe,je)=>{const xe=pt(je?.id),ae=Number(je?.quantity||0),he=re.has(xe),ye=(he?f?.[xe]:C?.[xe])??1;return he?e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>Xe(xe),style:{padding:2}}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.PlusOutlined,{}),disabled:ae<=0,onClick:()=>Se(je,ye),style:{padding:2}})}}],[Se,re,f,C,Xe,be,Ee]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(v,{pt:5,pb:2,children:[e.jsxs(v,{style:{padding:"12px 16px"},children:[e.jsx(v,{children:"Sell Product"}),e.jsx(n.Card,{style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:fe=>{const je=fe?.value??"";s(je),l(""),d(""),g(xe=>!xe)}}),e.jsx(Q,{options:W,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:fe=>{const je=fe?.value??"";l(je),d("")}},`section_${c}`),e.jsx(Q,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:fe=>d(fe?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(n.Card,{style:{borderRadius:16,marginTop:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(260px, 520px) 1fr",gap:12,alignItems:"center",marginBottom:12},children:[e.jsx(v,{style:{marginTop:12},children:"Product Section"}),e.jsx(n.AutoComplete,{value:y,options:m,onSearch:p,onFocus:()=>{j&&String(y||"").trim().length<2&&A(oe)},onSelect:ve,disabled:!j,children:e.jsx(n.Input,{placeholder:"Search by product name or barcode",onKeyDown:Oe,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",Rt(de)]})]}),e.jsx(n.Table,{rowKey:fe=>pt(fe?.id),columns:at,dataSource:X,loading:se,size:"small",bordered:!0,pagination:{pageSize:50,showSizeChanger:!0,pageSizeOptions:[25,50,100,200]},scroll:{x:"max-content"}}),e.jsxs("div",{style:{position:"sticky",bottom:0,background:"#fff",paddingTop:12,marginTop:12,borderTop:"1px solid #f0f0f0"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Selected Items"}),e.jsx("span",{children:J.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:Rt(de)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(ne,{type:"button",value:"Submit",disabled:!j||J.length===0,onClick:Ye,style:{flex:1,minWidth:140}}),e.jsx(n.Button,{type:"text",style:U,onClick:()=>{x({}),b({}),p(""),A(oe)},disabled:J.length===0,children:"Clear"})]})]})]})})]}),e.jsx(n.Modal,{open:R,title:"Payment",onCancel:()=>k(!1),onOk:Ze,confirmLoading:Le,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(n.Select,{value:O||void 0,onChange:D,placeholder:"Select payment type",style:{width:"100%"},options:[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"Bank",label:"Bank"},{value:"Cheque",label:"Cheque"},{value:"DD",label:"DD"},{value:"Internet Banking",label:"Internet Banking"}]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Receipt Date"}),e.jsx(n.DatePicker,{value:E,onChange:fe=>F(fe),style:{width:"100%"},format:"YYYY-MM-DD"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Discount"}),e.jsx(n.InputNumber,{min:0,max:de,value:_,onChange:fe=>u(Number(fe||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(n.Upload,{fileList:q,beforeUpload:()=>!1,onChange:({fileList:fe})=>T((fe||[]).slice(-1)),maxCount:1,children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(n.Input.TextArea,{value:h,onChange:fe=>S(fe.target.value),rows:3})]}),e.jsx(n.Card,{style:{borderRadius:12,background:"#fafcff"},children:e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:Rt(de)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:Rt(Ce)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:Rt(le)})]})]})})]})})]})}const th=({token:t})=>e.jsx(eh,{token:t}),Bn=Qe.unit,ah=({token:t,page:a=1,perPage:s=10})=>rn({baseUrl:Bn.list,page:a,perPage:s,token:t}),nh={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function sh({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),{isLoading:c,error:g,data:y,mutate:p}=ah({token:t,page:a.page,perPage:a.rowsPerPage}),m=async k=>{try{await p(nn(Bn.add,k,t),Ge(k)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(O){w.error(O?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},A=k=>{k.preventDefault();const O=new FormData(k.target);m(O),k.target.reset()},C=(k,O)=>{s({page:k,rowsPerPage:parseInt(O,10)})},b=async k=>{try{await p(sn(Bn.remove,k,t),ze(k)),w.success("Success! Deleted item.",{duration:1e3})}catch(O){w.error(O?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},f=k=>{d(k),l(!0)},x=async k=>{k.preventDefault();const O=new FormData(k.target);O.set("id",String(o?.id??""));try{await va(Bn.edit,O,t),await p(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null)}catch(D){w.error(D?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(k,O)=>String(k?.name??"").localeCompare(String(O?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(k,O)=>String(k?.description??"").localeCompare(String(O?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(k,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(O),style:{padding:2}}),e.jsx(yt,{id:O?.id,funcName:b})]})}],[b]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{l(!1),d(null)},children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{type:"text",name:"name",label:"Unit Name",defaultValue:o?.name??"",required:"required"}),e.jsx(z,{type:"text",name:"description",label:"Description",defaultValue:o?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null)},style:nh,children:"Cancel"})]})]})})}),e.jsxs(v,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(v,{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(v,{px:3,pb:2,children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(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(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(v,{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(v,{pt:3,children:e.jsx(Ie,{parentCallback:C,data:{newData:y,columns:R,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const rh=({token:t})=>e.jsx(sh,{token:t}),ih=Qe.product.sellReports,lh=Qe.academy.classes,oh=Qe.academy.sections,dh=Qe.student.dropdown,vi=t=>{const a=Number(t??0);return Number.isFinite(a)?a.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function ch({token:t}){const a=i.useRef(null),[s,r]=i.useState(null),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(!1),A=T=>{const U=T?.data?.data??T?.data??T??[];return Array.isArray(U)?U:Array.isArray(U?.data)?U.data:[]},{data:C}=H(t?[lh,t]:null,([T,U])=>K(T,U)),b=i.useMemo(()=>A(C),[C]),f=t&&l?`${oh}?class_id=${encodeURIComponent(String(l))}`:null,{data:x}=H(f?[f,t]:null,([T,U])=>K(T,U)),R=i.useMemo(()=>A(x),[x]),k=t&&l&&d?`${dh}?class=${encodeURIComponent(String(l))}&section=${encodeURIComponent(String(d))}`:null,{data:O}=H(k?[k,t]:null,([T,U])=>K(T,U)),D=i.useMemo(()=>A(O),[O]),{trigger:_,isMutating:u,data:h}=rt(ih,(T,{arg:U})=>nr(T,{arg:U},t));i.useEffect(()=>{const U=new Date().toISOString().slice(0,10);_({duration:[U,U]})},[_]);const S=i.useMemo(()=>{const T=h?.data??h??[];return Array.isArray(T)?T:[]},[h]),E=T=>{const U=Array.isArray(T?.product_details)?T.product_details:[];return U.length===0?null:e.jsx(n.Table,{size:"small",bordered:!0,pagination:!1,rowKey:j=>`${T?.receipt_id??"r"}_${j?.product_name??j?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:j=>vi(j)}],dataSource:U})},F=[{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:T=>vi(T)}],q=async()=>{if(!s||s.length!==2)return;const[T,U]=s;await _({duration:[T.format("YYYY-MM-DD"),U.format("YYYY-MM-DD")],class:l||"",section:d||"",student_id:g||""})};return e.jsx("div",{children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Filters"}),style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{value:s,onChange:r,style:{width:"100%"}})]}),e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:T=>{const U=T?.value??"";o(U),c(""),y(""),m(j=>!j)}}),e.jsx(Q,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:T=>{const U=T?.value??"";c(U),y("")}},`section_${p}`),e.jsx(Q,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:T=>y(T?.value??"")}),e.jsx(ne,{type:"button",value:u?"Searching...":"Search",disabled:u,onClick:q,style:{width:"100%"}})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(Ct,{data:{tableRef:a}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:u,rowKey:T=>String(T?.receipt_id??T?.receipt_no??Math.random()),columns:F,expandable:{expandedRowRender:E},dataSource:S,pagination:{pageSize:20}})]})})})]})})}const uh=({token:t})=>e.jsx(ch,{token:t}),ph=Qe.product;function mh({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState([]),[o,d]=i.useState([]),[c,g]=i.useState(!1),[y,p]=i.useState(!1),[m,A]=i.useState(null),[C,b]=i.useState(0),[f,x]=i.useState(null),[R,k]=i.useState(""),O=i.useRef(null),D=ea.useReactToPrint({contentRef:O,documentTitle:"Stock Barcodes"}),{isLoading:_,error:u,data:h,mutate:S}=ro({token:t,page:a.page,perPage:a.rowsPerPage}),E=(P,I)=>{s({page:P,rowsPerPage:parseInt(I,10)})},F={selectedRowKeys:r,onChange:(P,I)=>{l(P),d(I)}},q=P=>{A(P),b(Number(P?.quantity??0)),x(null),k(""),g(!0)},T=()=>{g(!1),A(null),b(0),x(null),k("")},U=async()=>{if(!m?.id)return;p(!0);const P=new FormData;P.append("product_id",String(m.id)),P.append("qty",String(C??0)),f&&P.append("tran_date",f.format("YYYY-MM-DD")),R&&P.append("remarks",R);try{const I=await va(ph.addStock,P,t);I?.Status==="Success"?(w.success("Success! Updated quantity.",{duration:1e3}),T(),await S()):w.error(I?.msg??"Failed to update quantity.",{duration:1e3})}catch{w.error("Failed to update quantity.",{duration:1e3})}finally{p(!1)}},j=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:(P,I)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(n.Button,{size:"small",onClick:()=>q(I),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:m?.name?`Update Stock: ${m.name}`:"Update Stock",open:c,onCancel:T,onOk:U,okButtonProps:{loading:y},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(n.InputNumber,{min:0,style:{width:"100%"},value:C,onChange:P=>b(P??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:{width:"100%"},value:f,onChange:x})]}),e.jsx(lt,{label:"Remarks",name:"remarks",rows:3,value:R,onChange:P=>k(P.target.value)})]})}),e.jsxs(v,{pt:5,pb:2,children:[e.jsxs(v,{children:["Manage Stock",e.jsx(ne,{type:"button",value:"Print Barcodes",disabled:!o||o.length===0,onClick:()=>D?.(),style:{minWidth:170}})]}),e.jsx(v,{style:{padding:"12px 16px"},children:e.jsx(n.Card,{style:{borderRadius:16},children:e.jsx(Ie,{parentCallback:E,data:{newData:h,columns:j,columnstype:"antd",action:!1,Loading:_,error:u,rowSelection:F}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:O,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(o)?o:[]).map(P=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:P?.name??""}),e.jsx(gl,{value:String(P?.barcode??P?.id??""),height:50,width:1.6,displayValue:!0})]},P?.id??P?.barcode??P?.name))})})})]})}const hh=({token:t})=>e.jsx(mh,{token:t}),fh=Qe.report.stock,yh=Qe.product.dropdown,gh=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function xh({token:t}){const a=i.useRef(null),[s,r]=i.useState(null),[l,o]=i.useState(""),{data:d}=H(t?[yh,t]:null,([b,f])=>K(b,f)),c=i.useMemo(()=>gh(d),[d]),{trigger:g,isMutating:y,data:p}=rt(fh,(b,{arg:f})=>nr(b,{arg:f},t));i.useEffect(()=>{const f=new Date().toISOString().slice(0,10);g({duration:[f,f]})},[g]);const m=i.useMemo(()=>{const b=p?.data??p??[];return(Array.isArray(b)?b:[]).flatMap(x=>(Array.isArray(x?.ledger)?x.ledger:[]).map((R,k)=>({key:`${x.product_id??x.product_name??"p"}-${k}`,date:R?.date,product:x?.product_name,opening:R?.opening,inward:R?.inward,outward:R?.outward,closing:R?.closing})))},[p]),A=[{title:"Date",dataIndex:"date",key:"date"},{title:"Product",dataIndex:"product",key:"product"},{title:"Opening",dataIndex:"opening",key:"opening"},{title:"Inward",dataIndex:"inward",key:"inward"},{title:"Outward",dataIndex:"outward",key:"outward"},{title:"Closing",dataIndex:"closing",key:"closing",render:b=>e.jsx("span",{style:{color:Number(b)<0?"red":"green"},children:b})}],C=async()=>{if(!s||s.length!==2)return;const[b,f]=s;await g({duration:[b.format("YYYY-MM-DD"),f.format("YYYY-MM-DD")],product_id:l||""})};return e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Stock Report"}),style:{borderRadius:16},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[e.jsx(n.DatePicker.RangePicker,{value:s,onChange:r}),e.jsxs("select",{value:l,onChange:b=>o(b.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(b=>e.jsx("option",{value:String(b?.value??""),children:String(b?.label??"")},String(b?.value??b?.id??b?.label)))]}),e.jsx(n.Button,{type:"primary",onClick:C,loading:y,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(Ct,{data:{tableRef:a}})})]}),e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:y,rowKey:"key",columns:A,dataSource:m,pagination:{pageSize:50}})]})]})}const bh=({token:t})=>e.jsx(xh,{token:t}),wi=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],Mt={total_packages:124,total_downloads:45892,active_packages:118,deprecated_packages:6,pending_approval:3,published_this_month:12,published_this_week:4,packages_needing_update:8,packages_with_issues:2},_i=[{npm_id:"NPM-001",package_name:"@ubk/erp-core",version:"1.2.1",description:"Core ERP utilities and shared types",author:"UBK Infotech",repository:"https://github.com/ubk/erp-core",license:"MIT",status:"published",created_at:"2024-01-15",updated_at:"2025-06-20"},{npm_id:"NPM-002",package_name:"@ubk/erp-components",version:"2.0.0",description:"Reusable Ant Design ERP component library",author:"UBK Infotech",repository:"https://github.com/ubk/erp-components",license:"ISC",status:"published",created_at:"2024-03-10",updated_at:"2025-08-01"},{npm_id:"NPM-003",package_name:"@ubk/erp-api-client",version:"0.9.5",description:"Axios-based API client for UBK ERP backends",author:"UBK Infotech",repository:"https://github.com/ubk/erp-api-client",license:"MIT",status:"draft",created_at:"2025-05-22",updated_at:"2025-07-14"},{npm_id:"NPM-004",package_name:"@ubk/erp-hooks",version:"1.1.0",description:"Custom React hooks for ERP workflows",author:"UBK Infotech",repository:"https://github.com/ubk/erp-hooks",license:"MIT",status:"published",created_at:"2024-08-05",updated_at:"2025-04-30"},{npm_id:"NPM-005",package_name:"@ubk/erp-utils",version:"3.2.1",description:"Utility functions for date, currency, and validation",author:"UBK Infotech",repository:"https://github.com/ubk/erp-utils",license:"ISC",status:"deprecated",created_at:"2023-11-20",updated_at:"2025-02-10"}],Ci=[{key:"dashboard",label:"Dashboard"},{key:"allPackages",label:"All Packages"},{key:"published",label:"Published"},{key:"draft",label:"Draft"},{key:"deprecated",label:"Deprecated"},{key:"pendingApproval",label:"Pending Approval"}];function jh(){const[t,a]=i.useState("dashboard"),[s,r]=i.useState("This Month"),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(1),[p,m]=i.useState(10),[A,C]=i.useState(""),b=i.useRef(null),f=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),x=i.useMemo(()=>{if(!A.trim())return _i;const _=A.toLowerCase();return _i.filter(u=>Object.values(u).some(h=>String(h??"").toLowerCase().includes(_)))},[A]),R=i.useMemo(()=>{const _=(g-1)*p;return x.slice(_,_+p)},[x,g,p]),k=()=>{y(1)},O=()=>{const _=[{title:"Total Packages",value:Mt.total_packages,icon:e.jsx(ee.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:Mt.total_downloads.toLocaleString(),icon:e.jsx(ee.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:Mt.active_packages,icon:e.jsx(ee.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:Mt.deprecated_packages,icon:e.jsx(ee.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:Mt.pending_approval,icon:e.jsx(ee.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:Mt.published_this_month,icon:e.jsx(ee.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:Mt.published_this_week,icon:e.jsx(ee.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:Mt.packages_needing_update,icon:e.jsx(ee.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:Mt.packages_with_issues,icon:e.jsx(ee.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(n.Row,{gutter:[16,16],children:_.map((u,h)=>e.jsx(n.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(n.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${u.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(v,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${u.color}15`,color:u.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:u.icon}),e.jsxs(v,{children:[e.jsx(n.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:u.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:u.value})]})]})},h))})},D=()=>{const _=[{title:"NPM ID",dataIndex:"npm_id",key:"npm_id",width:100},{title:"Package Name",dataIndex:"package_name",key:"package_name",ellipsis:!0},{title:"Version",dataIndex:"version",key:"version",width:100},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["md"]},{title:"Author",dataIndex:"author",key:"author",width:140,responsive:["lg"]},{title:"License",dataIndex:"license",key:"license",width:100},{title:"Status",dataIndex:"status",key:"status",width:120,render:u=>{let h="default";return u==="published"?h="green":u==="draft"?h="orange":u==="deprecated"?h="red":u==="pending"&&(h="blue"),e.jsx(n.Tag,{color:h,children:u.toUpperCase()})}},{title:"Created Date",dataIndex:"created_at",key:"created_at",width:120,responsive:["lg"]},{title:"Updated Date",dataIndex:"updated_at",key:"updated_at",width:120,responsive:["lg"]},{title:"Actions",key:"action",width:120,fixed:"right",render:(u,h)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:_};return e.jsx(v,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(v,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[f&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Q,{options:wi,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:wi.find(_=>_.value===s)||null,onChange:_=>r(_?.value||"This Month")})}),s==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Ue,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:_=>o(_?_.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Ue,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:_=>c(_?_.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:k})})})]}),e.jsx(n.Tabs,{activeKey:t,onChange:a,items:Ci})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:Ci.find(_=>_.key===t)?.label||"Report"})}),e.jsxs(v,{p:3,children:[t!=="dashboard"&&e.jsx(Ct,{data:{tableRef:b}}),t==="dashboard"?O():e.jsx(n.Table,{size:"small",dataSource:R,columns:D(),loading:!1,pagination:!1,bordered:!0,rowKey:_=>_.npm_id||_.package_name||Math.random(),ref:b}),t!=="dashboard"&&x.length>0&&e.jsx(n.Pagination,{current:g,pageSize:p,total:x.length,onChange:(_,u)=>{y(_),m(u)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const is=t=>t??localStorage.getItem("authToken")??"",Sh=(t,a)=>{const s=String(t??""),r=String(a);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Me={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_attendance/attendance/report/daily",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"}},io=()=>Sh(bt(),Me.upload),vh=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const l=t.includes("?")?"&":"?",o=`${t}${l}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(o,is(r))},kt=async(t,a,s)=>Ne(t,a,is(s)),Vt=async(t,a,s)=>We(t,a,is(s)),ln=async(t,a,s)=>He(t,a,is(s)),Xt=Me.staff,wh=Me.master.shift.dropdown,_h=Me.master.department.dropdown,Ch=Me.master.designation.dropdown,Ah=Me.roleDropdown,Dh=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},lo=t=>{const a=$t(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Th=(t,a)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=lo(a),l=s.startsWith("/")?s.slice(1):s;return Dh(Ke(),`uploads/school_${r}/staff/Profile_picture/${l}`)},Rh=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:"),Ln=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ih=t=>Ln(t).map(s=>{if(s?.value!==void 0&&s?.label!==void 0)return{...s,value:String(s.value),label:String(s.label)};const r=String(s?.shift_id??s?.id??s?.value??""),l=String(s?.shift_name??s?.label??s?.name??s?.title??r);return{...s,value:r,label:l}}),kh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Oa={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ai=[{value:"A+",label:"A+"},{value:"A-",label:"A-"},{value:"B+",label:"B+"},{value:"B-",label:"B-"},{value:"O+",label:"O+"},{value:"O-",label:"O-"},{value:"AB+",label:"AB+"},{value:"AB-",label:"AB-"}],Di={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ph({token:t,mode:a,staffId:s,initialValues:r,onSubmitted:l}){const[o,d]=i.useState(!1),c=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),g=String(c?.multiple_shift??"").toLowerCase()==="yes",[y,p]=i.useState(r?.roleValue??null),[m,A]=i.useState(r?.departmentValue??null),[C,b]=i.useState(r?.designationValue??null),[f,x]=i.useState(r?.genderValue??null),[R,k]=i.useState(r?.shiftValue??(g?[]:null)),[O,D]=i.useState(r?.dob?te(r.dob):null),[_,u]=i.useState(r?.doj?te(r.doj):null),[h,S]=i.useState(r?.file??""),[E,F]=i.useState(r?.bloodGroup??"");i.useEffect(()=>{r&&(p(r?.roleValue??null),A(r?.departmentValue??null),b(r?.designationValue??null),x(r?.genderValue??null),k(r?.shiftValue??(g?[]:null)),D(r?.dob?te(r.dob):null),u(r?.doj?te(r.doj):null),S(r?.file??""),F(r?.bloodGroup??""))},[r,g]);const{data:q}=H(t?[wh,t]:null,([M,L])=>K(M,L)),{data:T}=H(t?[_h,t]:null,([M,L])=>K(M,L)),{data:U}=H(t?[Ch,t]:null,([M,L])=>K(M,L)),{data:j}=H(t?[Ah,t]:null,([M,L])=>K(M,L)),{data:P}=H(t?[Xt.lastEmpNo,t]:null,([M,L])=>K(M,L)),I=i.useMemo(()=>Ih(q),[q]),N=i.useMemo(()=>Ln(T),[T]),V=i.useMemo(()=>Ln(U),[U]),W=i.useMemo(()=>Ln(j),[j]),B=i.useMemo(()=>{const M=P?.data?.emp_number??P?.emp_number??P?.data??"";return String(M??"")},[P]),$=async M=>{M.preventDefault(),d(!0);const L=new FormData(M.target);L.set("role",y?.value??y??""),L.set("department",m?.value??m??""),L.set("designation",C?.value??C??""),L.set("gender",f?.value??f??""),L.set("dob",O?O.format("YYYY-MM-DD"):""),L.set("doj",_?_.format("YYYY-MM-DD"):""),log.e("Shift_Value:",R,"Multiple Shift:",g),g?(L.delete("shift_id"),(Array.isArray(R)?R:[]).forEach(se=>{L.append("shift_id[]",se?.value??se??"")})):L.set("shift_id",R?.value??R??""),h&&L.set("file",h);try{const Y=a==="edit"&&s,se=Y?Xt.editBasic:Xt.addBasic;Y&&L.set("staff_id",String(s));const X=Y?await Vt(se,L,t):await kt(se,L,t),G=X?.ID??X?.id??s??null;w.success("Success!",{duration:1e3}),l?.({staffId:G,basic:{roleValue:y,departmentValue:m,designationValue:C,genderValue:f,shiftValue:R,dob:O,doj:_,file:h}})}catch(Y){w.error(Y?.response?.data?.msg??Y?.message??"Failed.",{duration:1e3})}finally{d(!1)}};return e.jsx("form",{onSubmit:$,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??B,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??"",pattern:"[A-Z]{5}[0-9]{4}[A-Z]",title:"Enter valid PAN (e.g., ABCDE1234D)"}),e.jsx(z,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??"",pattern:"[0-9]{12}",title:"Enter 12-digit Aadhaar number"}),e.jsx(Q,{label:"Role",options:W,value:y,onChange:M=>p(M??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Q,{label:"Department",options:N,value:m,onChange:M=>A(M??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Q,{label:"Designation",options:V,value:C,onChange:M=>b(M??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Q,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:f,onChange:M=>x(M??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(z,{type:"email",name:"email",label:"Email",defaultValue:r?.email??"",title:"Enter a valid email address"}),e.jsxs("div",{children:[e.jsx("div",{style:Oa,children:"DOB"}),e.jsx(n.DatePicker,{value:O,onChange:M=>D(M),style:Di,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:Oa,children:"DOJ"}),e.jsx(n.DatePicker,{value:_,onChange:M=>u(M),style:Di,placeholder:"Select DOJ"})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Blood Group",options:Ai,value:Ai.find(M=>M.value===E)??null,onChange:M=>F(M?.value??""),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsx("input",{type:"hidden",name:"bloodGroup",value:E})]}),e.jsx(z,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0,pattern:"[0-9]{10}",title:"Enter 10-digit contact number"}),e.jsx(z,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:Oa,children:"Shift"}),e.jsx(Q,{options:I,value:Array.isArray(R)&&g?I.filter(M=>R.some(L=>String(L?.value??L)===String(M?.value??M))):I.find(M=>String(R?.value??R)===String(M?.value??M))??(R&&!g?R:null),onChange:M=>k(M??(g?[]:null)),isMulti:g,closeMenuOnSelect:!g,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:Oa,children:"Profile Picture"}),e.jsxs("div",{style:{display:"grid",gap:8},children:[h?e.jsx("img",{src:Rh(h)?h:Th(h,t),alt:"profile-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(n.Upload,{action:`${Ke()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${lo(t)}/staff/Profile_picture`},headers:t?{Authorization:t}:void 0,maxCount:1,accept:"image/*",onChange:M=>{if(M?.file?.status==="done"){const L=kh(M?.file?.response);L&&S(L)}M?.file?.status==="removed"&&S("")},children:e.jsx(n.Button,{type:"link",style:{paddingLeft:0},children:h?"Change":"Upload"})})]}),e.jsx("input",{type:"hidden",name:"file",value:h??""})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:Oa,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(ne,{type:"submit",value:o?"Saving...":"Save & Next",color:"primary",disabled:o,loading:o})})]})})}const Oh=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},oo=t=>{const a=$t(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Mh=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:"),Eh=(t,a)=>{const s=`${t||""}`.trim();if(!s)return"";if(Mh(s))return s;const r=oo(a),l=s.startsWith("/")?s.slice(1):s;return Oh(Ke(),`uploads/school_${r}/staff/document/${l}`)},Cn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ti={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},$h=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ri=t=>{if(!t)return null;const a=te(t);return a.isValid()?a:null};function Fh({token:t,mode:a,staffId:s,initialRows:r,onSubmitted:l,onBack:o}){const[d,c]=i.useState(!1),[g,y]=i.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(x=>({name:x?.name??"",from:Ri(x?.from_date??x?.from),to:Ri(x?.to_date??x?.to),image:x?.image??""}))),p=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),m=(f,x)=>{y(R=>R.map((k,O)=>O===f?{...k,...x}:k))},A=()=>y(f=>[...f,{name:"",from:null,to:null,image:""}]),C=f=>y(x=>x.length<=1?x:x.filter((R,k)=>k!==f)),b=async f=>{if(f.preventDefault(),c(!0),!s){w.error("Missing staff id.",{duration:1e3}),c(!1);return}const x=new FormData;x.append("staff_id",String(s)),g.forEach((R,k)=>{x.append(`experience[${k}][name]`,String(R?.name??"")),x.append(`experience[${k}][from]`,R?.from?R.from.format("YYYY-MM-DD"):""),x.append(`experience[${k}][to]`,R?.to?R.to.format("YYYY-MM-DD"):""),x.append(`experience[${k}][image]`,String(R?.image??""))});try{const R=a==="edit",k=R?Xt.editExperience:Xt.addExperience,O=R?await Vt(k,x,t):await kt(k,x,t);w.success("Success!",{duration:1e3}),l?.({experience:g,result:O})}catch(R){w.error(R?.response?.data?.msg??R?.message??"Failed.",{duration:1e3})}finally{c(!1)}};return e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[g.map((f,x)=>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:Cn,children:"Name"}),e.jsx("input",{value:f.name,onChange:R=>m(x,{name:R.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:Cn,children:"From"}),e.jsx(n.DatePicker,{value:f.from,onChange:R=>m(x,{from:R}),style:Ti})]}),e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"To"}),e.jsx(n.DatePicker,{value:f.to,onChange:R=>m(x,{to:R}),style:Ti})]}),e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"Document"}),e.jsx(n.Upload,{maxCount:1,action:`${Ke()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${oo(t)}/staff/document`},headers:p,onChange:R=>{if(R?.file?.status==="done"){const k=$h(R?.file?.response);k&&m(x,{image:k})}R?.file?.status==="removed"&&m(x,{image:""})},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})}),!!f.image&&e.jsx("a",{href:Eh(f.image,t),target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"#1677ff",textDecoration:"underline",cursor:"pointer"},children:"View document"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.DeleteOutlined,{}),danger:!0,onClick:()=>C(x),disabled:g.length<=1})})]},`exp-${x}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(n.Button,{icon:e.jsx(ee.PlusOutlined,{}),onClick:A,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(n.Button,{onClick:o,children:"Back"}),e.jsx(ne,{type:"submit",value:d?"Saving...":"Save & Next",color:"primary",disabled:d,loading:d})]})]})]})})}const Ii=(t,a=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const s=a.length?a:["allowances","Allowances","dedection","Dedection","deductions","Deductions"],r=[t];t?.data&&typeof t.data=="object"&&r.push(t.data);for(const o of r)for(const d of s){const c=o?.[d]??o?.[d.toLowerCase()]??o?.[d.toUpperCase()];if(Array.isArray(c)&&c.length>0)return c}const l=t?.data;if(Array.isArray(l)&&l.length>0)return l}return[]},Ma=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function Uh({token:t,mode:a,staffId:s,initialValues:r,onSubmitted:l,onBack:o}){const[d,c]=i.useState(!1),[g,y]=i.useState(r?.type??"Permanent"),[p,m]=i.useState(r?.salary_type??Ma[0]?.value),[A,C]=i.useState(Number(r?.amount??0)),[b,f]=i.useState(Number(r?.basic_pay)),[x,R]=i.useState(r?.declarationPERyear??""),{data:k}=H(t?[wc,t]:null,([S,E])=>K(S,E),{revalidateOnFocus:!1}),O=i.useMemo(()=>r?.allowances&&Array.isArray(r.allowances)&&r.allowances.length>0?r.allowances:Ii(k,["allowances","Allowances"]),[k,r]),D=i.useMemo(()=>r?.deductions&&Array.isArray(r.deductions)&&r.deductions.length>0?r.deductions:Ii(k,["dedection","Dedection","deductions","Deductions"]),[k,r]),_=i.useMemo(()=>{const S=Number(b||0),E=(Array.isArray(O)?O:[]).map(j=>{const P=j?.amount_type??j?.amountType??j?.type??"",I=Number(j?.Amount??j?.amount??0),V=String(P).trim().toLowerCase()==="flat"?I:Number(S)/100*Number(I||0);return{...j,value:Number.isFinite(V)?V:0}}),F=(Array.isArray(D)?D:[]).map(j=>{const P=j?.amount_type??j?.amountType??j?.type??"",I=Number(j?.Amount??j?.amount??0),V=String(P).trim().toLowerCase()==="flat"?I:Number(S)/100*Number(I||0);return{...j,value:Number.isFinite(V)?V:0}}),q=E.reduce((j,P)=>j+Number(P?.value||0),0),T=F.reduce((j,P)=>j+Number(P?.value||0),0),U=Math.max(0,Number(S)+q-T);return{allowances:E,deductions:F,netAmount:U}},[O,D,b]),u=async S=>{if(S.preventDefault(),c(!0),!s){w.error("Missing staff id.",{duration:1e3}),c(!1);return}const E=new FormData;E.append("staff_id",String(s)),E.append("type",g),g==="Nonpermanent"?(E.append("salary_type",p??""),E.append("amount",String(A||"")),E.append("Allowances",JSON.stringify([])),E.append("Dedection",JSON.stringify([]))):(E.append("basic_pay",String(b||"")),E.append("declarationPERyear",String(x??"")),E.append("Allowances",JSON.stringify(_.allowances||[])),E.append("Dedection",JSON.stringify(_.deductions||[])),E.append("amount",String(_.netAmount||0)));try{const F=a==="edit",q=F?Xt.editPayroll:Xt.addPayroll,T=F?await Vt(q,E,t):await kt(q,E,t);w.success("Success!",{duration:1e3}),l?.({payroll:{staffType:g,salaryType:p,amount:A,basicPay:b,declaration:x},result:T})}catch(F){w.error(F?.response?.data?.msg??F?.message??"Failed.",{duration:1e3})}finally{c(!1)}},h=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(S,E)=>`${E?.Amount??""} / ${E?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:u,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:g==="Nonpermanent"?"Non Permanent":"Permanent",value:g},onChange:S=>y(S?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),g==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(Q,{label:"Type",options:Ma,value:Ma.find(S=>S.value===p)??Ma[0],onChange:S=>m(S?.value??Ma[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(z,{type:"number",label:"Amount",value:A,onChange:S=>C(Number(S.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(z,{type:"number",label:"Basic Pay",value:b,onChange:S=>f(Number(S.target.value||0)),required:!0}),e.jsx(z,{type:"text",label:"IT Declarations/Year",value:x,onChange:S=>R(S.target.value)}),e.jsx(z,{type:"number",label:"Net Amount",value:_.netAmount,disabled:!0})]})]}),g==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(S,E)=>`${S?.title??"a"}-${E}`,columns:h,dataSource:_.allowances,pagination:!1})}),e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(S,E)=>`${S?.title??"d"}-${E}`,columns:h,dataSource:_.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(ne,{type:"submit",value:d?"Finishing...":"Finish",color:"primary",disabled:d,loading:d})})]})})}const Nh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function co({token:t,mode:a="add",staffId:s,onFinished:r}){const[l,o]=i.useState(0),[d,c]=i.useState(s??null),[g,y]=i.useState(null),[p,m]=i.useState(null),[A,C]=i.useState(null),b=a==="edit"?s??d:null,f=i.useMemo(()=>b?`${Me.staff.basicById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),x=i.useMemo(()=>b?`${Me.staff.experienceById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),R=i.useMemo(()=>b?`${Me.staff.payrollById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),k=H(t&&f?[f,t]:null,([j,P])=>K(j,P)),O=H(t&&x?[x,t]:null,([j,P])=>K(j,P)),D=H(t&&R?[R,t]:null,([j,P])=>K(j,P)),_=k?.data,u=O?.data,h=D?.data,S=!!k?.isLoading;O?.isLoading,D?.isLoading;const E=i.useMemo(()=>{try{const j=JSON.parse(localStorage.getItem("genrall_settings")??"null");return String(j?.multiple_shift??"").toLowerCase()==="yes"}catch{return!1}},[]),F=i.useMemo(()=>{const j=Nh(_)[0]??_?.data??_??null;if(!j)return null;let P=null;const I=j?.shift_id??j?.shift_ids??j?.shift;if(I)if(E){const N=String(I).split(",").map(V=>V.trim()).filter(Boolean);N.length>0&&(P=N.map(V=>({value:String(V),label:V})))}else j?.shift_id?P={value:String(j.shift_id),label:j?.shift??""}:j?.shift&&(P={value:String(j.shift),label:j.shift});return{emp_number:j?.emp_number??j?.empNo??j?.employee_id??"",f_name:j?.f_name??j?.firstname??j?.first_name??j?.name??"",l_name:j?.l_name??j?.lastname??j?.last_name??j?.surname??"",pan_no:j?.pan_no??j?.pan??"",adhar_no:j?.adhar_no??j?.aadhar_no??"",email:j?.email??j?.email_id??"",dob:j?.dob??j?.date_of_birth??"",doj:j?.doj??j?.date_of_joining??j?.joining_date??"",bloodGroup:j?.bloodGroup??j?.blood_group??"",contact_no:j?.contact_no??j?.phone??j?.contact??"",education:j?.education??j?.qualification??"",address:j?.address??j?.bussiness_address??j?.business_address??"",file:j?.file??j?.profile_picture??j?.profile_pic??j?.image??"",genderValue:j?.gender?{value:j.gender,label:j.gender}:null,roleValue:j?.role_id?{value:String(j.role_id),label:j?.role??""}:j?.fk_roleid?{value:String(j.fk_roleid),label:j?.role??""}:null,departmentValue:j?.department?{value:String(j.department),label:j?.departments??""}:null,designationValue:j?.designation?{value:String(j.designation),label:j?.designations??""}:null,shiftValue:P}},[_,E]),q=i.useMemo(()=>{const j=u?.data??u??null;return(Array.isArray(j?.experience)?j.experience:Array.isArray(j)?j:[]).map(I=>({name:I?.name??"",from:I?.from_date??I?.from??"",to:I?.to_date??I?.to??"",image:I?.image??""}))},[u]),T=i.useMemo(()=>{const j=h?.data??h??null,I=(Array.isArray(j)?j:j?.data&&Array.isArray(j.data)?j.data:[])[0]??null;if(!I)return null;const N=h?.allowances??j?.allowances??[],V=h?.dedection??j?.dedection??h?.deductions??j?.deductions??[];return{type:I?.type??"Permanent",salary_type:I?.salary_type??"Hourly",amount:Number(I?.amount??0),basic_pay:Number(I?.basic_pay??0),declarationPERyear:I?.declarationPERyear??I?.it_declarationPERyear??"",allowances:Array.isArray(N)?N:[],deductions:Array.isArray(V)?V:[]}},[h]),U=i.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:a==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(n.Steps,{current:l,items:U}),l===0&&(a==="edit"&&S?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:40},children:e.jsx(n.Spin,{tip:"Loading staff data...",size:"large"})}):e.jsx(Ph,{token:t,mode:a,staffId:b,initialValues:F,onSubmitted:({staffId:j})=>{j&&c(j),o(1)}})),l===1&&e.jsx(Fh,{token:t,mode:a,staffId:b??d,initialRows:q,onBack:()=>o(0),onSubmitted:()=>o(2)}),l===2&&e.jsx(Uh,{token:t,mode:a,staffId:b??d,initialValues:T,onBack:()=>o(1),onSubmitted:()=>{w.success("Completed.",{duration:1e3}),r?.({staffId:b??d}),o(0),a!=="edit"&&(c(null),y(null),m(null),C(null))}})]})})]})}function Bh({token:t}){return e.jsx(co,{token:t,mode:"add"})}const Lh=({token:t})=>e.jsx(Bh,{token:t}),An=Me.staff,qh=Me.roleDropdown,zh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Yh=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Vh({token:t,onNavigate:a}){const[s,r]=i.useState({page:1,rowsPerPage:10}),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(!1),[p,m]=i.useState(null),{data:A}=H(t?[qh,t]:null,([u,h])=>K(u,h)),C=i.useMemo(()=>zh(A),[A]),b=i.useMemo(()=>{const u=s.page,h=s.rowsPerPage,S=l&&!d?`${An.searchByRole}?role_id=${encodeURIComponent(String(l))}`:d?`${An.searchByKeywords}?key=${encodeURIComponent(String(d))}`:An.list,E=S.includes("?")?"&":"?";return`${S}${E}page=${encodeURIComponent(String(u))}&per_page=${encodeURIComponent(String(h))}`},[s.page,s.rowsPerPage,d,l]),{isLoading:f,error:x,data:R,mutate:k}=H(t?[b,t]:null,([u,h])=>K(u,h)),O=i.useMemo(()=>Yh(R),[R]),D=async u=>{const h=u?.id??u?.fk_staffID??u?.staff_id;if(h)try{await ln(An.deactivate,h,t),w.success("Success! Staff deactivated.",{duration:1e3}),await k()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to deactivate staff.",{duration:1e3})}},_=i.useMemo(()=>[{title:"Emp ID",dataIndex:"employee_id",key:"employee_id",width:120,responsive:["lg"]},{title:"Name",key:"name",ellipsis:!0,render:(u,h)=>`${h?.name||""} ${h?.surname||""}`.trim()},{title:"Role",dataIndex:"role",key:"role",ellipsis:!0,responsive:["md"]},{title:"Department",dataIndex:"departments",key:"departments",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"contact_no",key:"contact_no",ellipsis:!0,responsive:["md"]},{title:"Status",key:"steps",width:140,responsive:["lg"],render:(u,h)=>{const S=Number(h?.steps??h?.status??1),E=S<=1?30:S===2?60:100;return e.jsx(n.Progress,{percent:E,size:"small",format:F=>`${F}%`,style:{margin:"-4px 0"}})}},{title:"Action",key:"action",width:110,fixed:"right",render:(u,h)=>e.jsxs(n.Space,{size:"middle",children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>{typeof a=="function"?a("staff-edit",h):(m(h?.id??h?.fk_staffID??h?.staff_id??""),y(!0))}}),e.jsx(n.Popconfirm,{title:"Delete staff?",description:"Are you sure you want to deactivate this staff member?",okText:"Yes",cancelText:"No",onConfirm:()=>D(h),children:e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ee.DeleteOutlined,{}),style:{padding:2}})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:2,style:{margin:0},children:"Filters"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:[{value:"",label:"All Roles"},...C],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:u=>{o(u?.value??""),r(h=>({...h,page:1}))}}),e.jsx(z,{type:"text",label:"Keyword",value:d,onChange:u=>c(u.target.value),placeholder:"Search by keywords"}),e.jsx(ne,{type:"button",value:"Refresh",onClick:()=>k()})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:8,style:{margin:0},children:"Staff Directory"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:f,rowKey:u=>String(u?.id??u?.fk_staffID??u?.staff_id??Math.random()),columns:_,dataSource:O,pagination:{current:s.page,pageSize:s.rowsPerPage,onChange:(u,h)=>r({page:u,rowsPerPage:h}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]}),e.jsx(n.Drawer,{open:g,onClose:()=>{y(!1),m(null)},title:"Edit Staff",width:"80%",destroyOnClose:!0,footer:null,children:p!=null&&e.jsx(co,{token:t,mode:"edit",staffId:String(p),onFinished:()=>{y(!1),m(null),k()}})})]})}const Wh=({token:t,onNavigate:a})=>e.jsx(Vh,{token:t,onNavigate:a}),Hh=Me.attendance,Kh=Me.roleDropdown,ki=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Dn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Pi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Gh({token:t,open:a,onClose:s,roleId:r,onSaved:l}){const[o,d]=i.useState(null),[c,g]=i.useState(""),[y,p]=i.useState(te()),[m,A]=i.useState(te()),[C,b]=i.useState(te()),f=i.useMemo(()=>r?`${Me.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:x}=H(t&&f?[f,t]:null,([u,h])=>K(u,h)),R=i.useMemo(()=>ki(x),[x]),{trigger:k,data:O}=rt(t?Me.attendance.staffShiftByStaffId:null,(u,{arg:h})=>Qt(u,{arg:h},t)),D=i.useMemo(()=>ki(O),[O]),_=async()=>{if(!o?.value){w.error("Select staff.",{duration:1e3});return}if(!c){w.error("Select shift.",{duration:1e3});return}const u=new FormData;u.set("staffID",String(o.value)),u.set("shift_id",String(c)),u.set("attendance_date",y?y.format("YYYY-MM-DD"):""),u.set("intime",m?m.format("h:mm a"):""),u.set("outime",C?C.format("h:mm a"):"");try{await kt(Me.attendance.manualAttendance,u,t),w.success("Success!",{duration:1e3}),l?.(),s?.(),d(null),g(""),p(te()),A(te()),b(te())}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed.",{duration:1e3})}};return e.jsx(n.Modal,{open:a,onCancel:s,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(n.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{label:"Staff",options:R,value:o,onChange:async u=>{if(d(u??null),g(""),u?.value&&k)try{await k({staff_id:u.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:Dn,children:"Shift"}),e.jsx(n.Radio.Group,{value:c,onChange:u=>g(u.target.value),style:{display:"grid",gap:8},children:D.map(u=>e.jsx(n.Radio,{value:u?.value,children:u?.label??u?.name??u?.title??String(u?.value??"")},String(u?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:Dn,children:"Date"}),e.jsx(n.DatePicker,{value:y,onChange:u=>u&&p(u),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:Dn,children:"Start Time"}),e.jsx(n.TimePicker,{value:m,onChange:u=>u&&A(u),use12Hours:!0,format:"h:mm a",style:Pi})]}),e.jsxs("div",{children:[e.jsx("div",{style:Dn,children:"End Time"}),e.jsx(n.TimePicker,{value:C,onChange:u=>u&&b(u),use12Hours:!0,format:"h:mm a",style:Pi})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:s,children:"Cancel"}),e.jsx(ne,{type:"button",value:"Save",color:"primary",onClick:_})]})]})})})}const Jh=({tableRef:t,excelDisabled:a})=>{const s=new Date().getTime(),r=ea.useReactToPrint({content:()=>t?.current});return e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(n.Col,{children:a?e.jsx(n.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>w.error("You must save attendance before download",{duration:2e3})}):e.jsx(to.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:t?.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},Qh=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?Array.isArray(s?.student)?s.student:[]:Array.isArray(s?.staff)?s.staff:[]:[]},Xh=t=>{const a=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,s=Number(a);return Number.isFinite(s)&&s>=0?s:0},Zh=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?{sunday:String(s?.sunday??"").toLowerCase()==="yes",holiday:String(s?.holiday??"").toLowerCase()==="yes"}:{sunday:!!s?.sunday,holiday:!!s?.holiday}:{sunday:!1,holiday:!1}};function ef({token:t,url:a,columns:s,reload:r,setReload:l,saveBtnRef:o,setSaveBtnDisabled:d,date:c,type:g="staff"}){const y=i.useRef(null),[p,m]=i.useState({page:0,rowsPerPage:10}),[A,C]=i.useState(!1),[b,f]=i.useState(!1),[x,R]=i.useState(null),[k,O]=i.useState([]),[D,_]=i.useState({sunday:!1,holiday:!1}),[u,h]=i.useState(!0);i.useEffect(()=>{m(q=>({...q,page:0}))},[a]),i.useEffect(()=>{let q=!0;return(async()=>{if(!(!t||!a)){C(!0);try{const U=String(a).includes("?")?"&":"?",j=`${a}${U}page=${p.page+1}&per_page=${p.rowsPerPage}`,P=await K(j,t);if(!q)return;R(P),P?.Status==="Success"?(d?.(!1),O(Qh(P,g)),_(Zh(P,g))):(d?.(!0),O([]),_({sunday:!1,holiday:!1}))}catch{if(!q)return;d?.(!0),O([])}finally{q&&C(!1)}}})(),()=>{q=!1}},[p.page,p.rowsPerPage,r,d,t,g,a]);const S=i.useMemo(()=>Xh(x),[x]);i.useEffect(()=>{const q=(Array.isArray(k)?k:[]).find(T=>T?.attendence_type_id===null);h(!!q)},[k]);const E=async()=>{if(t){f(!0);try{if(g==="staff"){const q=(Array.isArray(k)?k:[]).map(T=>({staff_id:T?.staff_id,attendence_type_id:T?.attendence_type_id?T.attendence_type_id:"1",in_time:T?.intime,out_time:T?.outtime,date:c}));await kt(Me.attendance.addAttendanceToStaffByBranch,q,t),w.success("Attendance saved successfully",{duration:2e3}),l?.(T=>!T)}else w.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(q){w.error(q?.response?.data?.msg??q?.message??"Failed required dates",{duration:2e3})}finally{f(!1)}}},F=i.useMemo(()=>(Array.isArray(s)?s:[]).map(T=>T?.selector==="attendence_type_id"?{title:T?.name??"Attendance",dataIndex:T.selector,key:T.selector,render:U=>U==null||U===""?e.jsx(n.Tag,{color:"orange",children:"Not Set"}):String(U)==="1"?e.jsx(n.Tag,{color:"green",children:"Present"}):String(U)==="4"?e.jsx(n.Tag,{color:"red",children:"Absent"}):String(U)==="3"?e.jsx(n.Tag,{color:"orange",children:"Late"}):e.jsx(n.Tag,{children:String(U)})}:T?.selector==="snum"?{title:T?.name??"Sl",key:T.selector,render:(U,j,P)=>P+1}:{title:T?.name??T?.selector,dataIndex:T?.selector,key:T?.selector}),[s]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{children:[e.jsx(Jh,{tableRef:y,excelDisabled:u}),e.jsx(n.Modal,{open:b,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(n.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),D.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):D.holiday?e.jsx("div",{style:{textAlign:"center",padding:"16px 0"},children:e.jsx("div",{style:{fontWeight:700,marginBottom:6},children:"Holiday"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:y,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(q,T)=>String(q?.id??q?.staff_id??T),columns:F,dataSource:k,loading:A,pagination:{current:p.page+1,pageSize:p.rowsPerPage,total:S,showSizeChanger:!0,onChange:(q,T)=>m({page:q-1,rowsPerPage:T})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:E,ref:o,style:{display:"none"},children:"hidden"})]})]})]})}const tf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},af={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function nf({token:t}){const[a,s]=i.useState(""),[r,l]=i.useState(te().format("YYYY-MM-DD")),[o,d]=i.useState(!1),[c,g]=i.useState(null),[y,p]=i.useState(!1),[m,A]=i.useState(!0),[C,b]=i.useState(!1),f=i.useRef(null),{data:x}=H(t?[Kh,t]:null,([O,D])=>K(O,D)),R=i.useMemo(()=>tf(x),[x]),k=i.useMemo(()=>[{id:"1",name:"Staff Id",selector:"employee_id",sortable:!0},{id:"2",name:"Name",selector:"full_name",sortable:!0},{id:"4",name:"Contact",selector:"contact_no",sortable:!0},{id:"3",name:"Attendance",selector:"attendence_type_id",sortable:!0},{id:"5",name:"In Time",selector:"intime",sortable:!0},{id:"6",name:"Out Time",selector:"outtime",sortable:!0}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:O=>s(O?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{defaultValue:te(),onChange:O=>O&&l(O.format("YYYY-MM-DD")),style:af,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>{!a||!r||(g(`${Hh.staffListForAttendance}?role=${encodeURIComponent(String(a))}&date=${encodeURIComponent(String(r))}`),d(O=>!O))}})})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:12},children:[e.jsx(n.Button,{size:"small",type:y?"primary":"default",onClick:()=>p(O=>!O),children:y?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"default",disabled:m,onClick:()=>b(!0),children:"Give Attendance"})]}),c?e.jsx(ef,{token:t,url:c,columns:k,reload:o,setReload:d,saveBtnRef:f,setSaveBtnDisabled:A,date:r,type:"staff",holidayChecked:y}):null]}),e.jsx(Gh,{token:t,open:C,onClose:()=>b(!1),roleId:a,onSaved:()=>d(O=>!O)})]})}const sf=({token:t})=>e.jsx(nf,{token:t}),Oi=Me.attendanceReport.monthlyStaffReport,rf=Me.roleDropdown,lf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function of({token:t}){const a=i.useRef(null),[s,r]=i.useState(!1),[l,o]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),g=i.useMemo(()=>rr(5),[]),{data:y}=H(t?[rf,t]:null,([q,T])=>K(q,T)),p=i.useMemo(()=>lf(y),[y]),[m,A]=i.useState([]),[C,b]=i.useState(1),[f,x]=i.useState(!1),[R,k]=i.useState(!1),[O,D]=i.useState(null),_=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:u}=rt(t&&Oi?`${Oi}?page=${C}&per_page=3`:null,(q,{arg:T})=>Qt(q,{arg:T},t),{onSuccess:q=>{x(!1);const T=Array.isArray(q)?q:[];T.length>0&&A(U=>[...U||[],...T]),T.length>1?b(U=>U+1):k(!1)},onError:()=>{x(!1),k(!1)}});i.useEffect(()=>{R&&u&&O&&u(O)},[R,C,O,u]);const h=i.useMemo(()=>{const q=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(T,U)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:U?.full_name??""})}];return Array.isArray(m)&&m.length>0&&((m[0]?.monthly_data??[]).forEach((U,j)=>{q.push({title:j+1,align:"center",key:String(j+1),render:(P,I)=>{const N=I?.monthly_data?.[j]?.[0]?.data?.[0]??{},V=N?.intime??"",W=N?.outtime??"",B=N?.attendance_type??"";return e.jsx(n.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",V]}),e.jsxs("div",{children:["Out Time ",W]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:st(B)})})}})}),q.push({title:"Total",key:"Total",render:(U,j)=>{const P=j?.monthly_data??[],I=P.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="A").length,N=P.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",I," P : ",N]})})}})),q},[m]),S=i.useMemo(()=>[{label:"Present",el:st("P")},{label:"Absent",el:st("A")},{label:"Leave",el:st("L")},{label:"Weekly Off",el:st("W")},{label:"Holiday",el:st("H")}],[]),E=i.useMemo(()=>d.month?l.find(q=>q?.value==d.month)?.label??d.month??"--":"--",[d.month,l]),F=async q=>{if(q.preventDefault(),!d.role||!d.year||!d.month)return;b(1),x(!0),A([]);const T={session:_,year:d.year,month:d.month,day:"01",role:d.role};D(T),k(!0),await u?.(T)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{className:"d-print-none",title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:q=>c(T=>({...T,role:q?.value??"",rolllabel:q?.label??""}))}),e.jsx(Q,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:q=>{const T=ir(q?.value);o(T),r(U=>!U),c(U=>({...U,year:q?.label??""}))}}),e.jsx(Q,{options:l,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:q=>c(T=>({...T,month:q?.value??""}))},`month-${s}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),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:E})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(Ct,{data:{tableRef:a}})})]}),e.jsx("div",{style:{marginTop:14,paddingTop:14,borderTop:"1px solid #e0e0e0"},children:e.jsx("div",{style:{display:"flex",justifyContent:"center",flexWrap:"wrap",gap:12,fontSize:12},children:S.map(q=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[q.label," :"]}),e.jsx("div",{children:q.el})]},q.label))})})]}),e.jsx(n.Skeleton,{active:!0,loading:f,paragraph:{rows:10},children:e.jsx(n.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:h,dataSource:m,pagination:!1,scroll:{x:"max-content"},rowKey:(q,T)=>String(q?.staff_id??q?.id??T)})})]})})]})}const df=({token:t})=>e.jsx(of,{token:t}),Mi=Me.payroll,cf=Me.roleDropdown,uf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},pf=t=>t?.data?.data??t?.data??t??[];function mf({token:t,receiptDetailsPath:a="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:s}){const[r,l]=i.useState({page:1,rowsPerPage:10}),[o,d]=i.useState(!1),[c,g]=i.useState([]),[y,p]=i.useState({role:"",roleLabel:"",year:"",month:""}),[m,A]=i.useState(null),C=h=>{if(!h)return;if(typeof s=="function"){s(h);return}const S=`${a}?id=${encodeURIComponent(String(h))}`;typeof window<"u"&&window?.location&&(window.location.href=S)},{data:b}=H(t?[cf,t]:null,([h,S])=>K(h,S)),f=i.useMemo(()=>uf(b),[b]),x=i.useMemo(()=>rr(5),[]),{isLoading:R,error:k,data:O}=H(t&&m?[m,t]:null,([h,S])=>K(h,S)),D=i.useMemo(()=>{const h=pf(O);return Array.isArray(h)?h:[]},[O]),_=i.useMemo(()=>{const h=O?.pagination?.total_rows??O?.data?.pagination?.total_rows??O?.total??O?.total_rows,S=Number(h);return Number.isFinite(S)&&S>=0?S:D.length},[O,D.length]),u=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(h,S,E)=>E+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:(h,S)=>{const E=S?.id??S?.staff_id??S?.staffId;return e.jsx(n.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{C(E)},children:Zl(S?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:h=>{if(h.preventDefault(),!y.role||!y.year||!y.month)return;const S=`${Mi.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`;A(S)},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",marginBottom:14,padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsx(Q,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:h=>p(S=>({...S,role:h?.value??"",roleLabel:h?.label??""}))}),e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:h=>{const S=ir(h?.value);g(S),d(E=>!E),p(E=>({...E,year:h?.label??"",month:""}))}}),e.jsx(Q,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:h=>p(S=>({...S,month:h?.value??""}))},`month-${o}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary",onClick:()=>l(h=>({...h,page:1}))})})]})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:R,rowKey:(h,S)=>String(h?.id??h?.staff_id??S),columns:u,dataSource:D,pagination:{current:r.page,pageSize:r.rowsPerPage,total:_,showSizeChanger:!0,onChange:(h,S)=>{l({page:h,rowsPerPage:S}),!(!y.role||!y.year||!y.month)&&A(`${Mi.payrollByRole}?page=${encodeURIComponent(String(h))}&per_page=${encodeURIComponent(String(S))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`)}},scroll:{x:"max-content"}})]})})}const hf=({token:t})=>e.jsx(mf,{token:t}),uo=Me.leave,wa=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>H(r&&t?[t,a,s,r]:null,([o,d,c,g])=>vh({baseUrl:o,page:d,perPage:c},g)),ff=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:uo.requestTable,page:a,perPage:s}),yf=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},gf=(t,a)=>{const s=new FormData;return Object.entries(t??{}).forEach(([r,l])=>{l!=null&&s.append(r,String(l))}),s.set("status",a),s};function xf({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:l,data:o,mutate:d}=ff({token:t,page:a.page,perPage:a.rowsPerPage}),c=i.useMemo(()=>yf(o),[o]),g=async(p,m)=>{try{const A=gf(p,m),C=await Vt(uo.approveRequest,A,t);C?.Status==="Success"?w.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):w.error(C?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to update request.",{duration:1e3})}},y=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(p,m)=>m?.full_name??m?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(p,m)=>m?.leave_from??m?.from_date??""},{title:"To",key:"leave_to",width:120,render:(p,m)=>m?.leave_to??m?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(p,m)=>m?.leavetype??m?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(p,m)=>m?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(p,m)=>m?.employee_remark??m?.reason??""},{title:"View",key:"document_file",width:140,render:(p,m)=>{const A=m?.document_file;return A?e.jsx(n.Button,{size:"small",onClick:()=>window.open(A,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(p,m)=>{const A=String(m?.status??"").toLowerCase();return A==="approved"?e.jsx(n.Tag,{color:"green",children:"Approved"}):A==="declined"?e.jsx(n.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(n.Button,{type:"text",size:"small",onClick:()=>g(m,"approved"),icon:e.jsx(ee.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(n.Button,{type:"text",size:"small",onClick:()=>g(m,"declined"),icon:e.jsx(ee.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:r,rowKey:(p,m)=>String(p?.id??p?.leave_id??m),columns:y,dataSource:c,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(p,m)=>s({page:p,rowsPerPage:m}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const bf=({token:t})=>e.jsx(xf,{token:t}),jf=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Sf=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:io(),headers:r,onChange:l=>{if(l?.file?.status==="done"){const o=jf(l?.file?.response);o&&s?.(o)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},po=Me.leave,vf=Me.master.leaveType.dropdown,wf=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:po.table,page:a,perPage:s}),_f=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Os={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Cf({token:t,userType:a}){const[s,r]=i.useState({page:1,rowsPerPage:10}),[l,o]=i.useState(!1),[d,c]=i.useState(""),[g]=n.Form.useForm();console.log("ApplyLeavePage render",a);const{isLoading:y,error:p,data:m,mutate:A}=wf({token:t,page:s.page,perPage:s.rowsPerPage}),{data:C}=H(t?[vf,t]:null,([u,h])=>K(u,h)),b=i.useMemo(()=>_f(C),[C]),f=(u,h)=>r({page:u,rowsPerPage:parseInt(h,10)}),x=()=>{c(""),g.resetFields(),g.setFieldsValue({apply_date:te()}),o(!0)},R=()=>{o(!1),c(""),g.resetFields()},k=async u=>{const h=new FormData;h.set("apply_date",u?.apply_date?u.apply_date.format("YYYY-MM-DD"):""),h.set("leave_type",u?.leave_type?.value??u?.leave_type??""),h.set("from_date",u?.from_date?u.from_date.format("YYYY-MM-DD"):""),h.set("to_date",u?.to_date?u.to_date.format("YYYY-MM-DD"):""),h.set("reason",u?.reason??""),d&&h.set("file",d);try{await kt(po.apply,h,t),w.success("Success! Leave request submitted.",{duration:1e3}),R(),await A()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to submit leave request.",{duration:1e3})}},O=i.useMemo(()=>{const u=m?.data??m??[];return Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]},[m]),D=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(u,h)=>h?.leavetype??h?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(u,h)=>h?.date??h?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(u,h)=>h?.leave_from??h?.from_date??""},{title:"To",key:"leave_to",width:130,render:(u,h)=>h?.leave_to??h?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(u,h)=>h?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]),_=a==="staff";return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Add Leave Request",onCancel:R,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:k,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,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.Form.Item,{name:"apply_date",rules:[{required:!0,message:"Select date"}],style:{marginBottom:0},children:e.jsx(n.DatePicker,{style:Os})})]}),e.jsx(n.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From"}),e.jsx(n.Form.Item,{name:"from_date",rules:[{required:!0,message:"Select from date"}],style:{marginBottom:0},children:e.jsx(n.DatePicker,{style:Os})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To"}),e.jsx(n.Form.Item,{name:"to_date",rules:[{required:!0,message:"Select to date"}],style:{marginBottom:0},children:e.jsx(n.DatePicker,{style:Os})})]}),e.jsx(n.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(Sf,{token:t,value:d,onChange:c})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(n.Button,{onClick:R,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})]})}),_&&e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(ne,{type:"button",value:"Add Leave Request",onClick:x})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:y,rowKey:(u,h)=>String(u?.id??u?.leave_id??h),columns:D,dataSource:O,pagination:{current:s.page,pageSize:s.rowsPerPage,onChange:(u,h)=>f(u,h),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Af=({token:t,userType:a})=>e.jsx(Cf,{token:t,userType:a}),qn=Me.master.leaveType,Df=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:qn.table,page:a,perPage:s});function Tf({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[l]=n.Form.useForm(),[o,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:y,error:p,data:m,mutate:A}=Df({token:t,page:a.page,perPage:a.rowsPerPage}),C=(D,_)=>{s({page:D,rowsPerPage:parseInt(_,10)})},b=async D=>{const _=new FormData;_.set("title",D?.title??"");try{await A(kt(qn.add,_,t),Ge(_)),w.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(u){w.error(u?.response?.data?.msg??u?.message??"Failed to add leave type.",{duration:1e3})}},f=D=>{g(D??null),l.setFieldsValue({title:D?.leave_type_name??D?.name??""}),d(!0)},x=()=>{d(!1),g(null),l.resetFields()},R=async D=>{const _=c?.id??c?.leave_type_id;if(!_){w.error("Missing leave type id.",{duration:1e3});return}const u=new FormData;u.set("id",String(_)),u.set("title",D?.title??"");try{await Vt(qn.edit,u,t),await A(),w.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),x()}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to update leave type.",{duration:1e3})}},k=async D=>{const _=D?.id??D?.leave_type_id;if(_)try{await A(ln(qn.remove,_,t),ze(_)),w.success("Success! Deleted leave type.",{duration:1e3})}catch(u){w.error(u?.response?.data?.msg??u?.message??"Failed to delete leave type.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(D,_)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(_)}),e.jsx(n.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>k(_),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:o,title:"Edit Leave Type",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:R,children:[e.jsx(n.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(n.Button,{onClick:x,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Ie,{parentCallback:C,data:{newData:m,columns:O,columnstype:"antd",action:!1,Loading:y,error:p}})})]})}const Rf=({token:t})=>e.jsx(Tf,{token:t}),zn=Me.master.department,If=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:zn.table,page:a,perPage:s});function kf({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[l]=n.Form.useForm(),[o,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:y,error:p,data:m,mutate:A}=If({token:t,page:a.page,perPage:a.rowsPerPage}),C=(D,_)=>{s({page:D,rowsPerPage:parseInt(_,10)})},b=async D=>{const _=new FormData;_.set("title",D?.title??"");try{await A(kt(zn.add,_,t),Ge(_)),w.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(u){w.error(u?.response?.data?.msg??u?.message??"Failed to add department.",{duration:1e3})}},f=D=>{g(D??null),l.setFieldsValue({title:D?.department_name??D?.name??""}),d(!0)},x=()=>{d(!1),g(null),l.resetFields()},R=async D=>{const _=c?.id??c?.department_id;if(!_){w.error("Missing department id.",{duration:1e3});return}const u=new FormData;u.set("id",String(_)),u.set("title",D?.title??"");try{await Vt(zn.edit,u,t),await A(),w.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),x()}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to update department.",{duration:1e3})}},k=async D=>{const _=D?.id??D?.department_id;if(_)try{await A(ln(zn.remove,_,t),ze(_)),w.success("Success! Deleted department.",{duration:1e3})}catch(u){w.error(u?.response?.data?.msg??u?.message??"Failed to delete department.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(D,_)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(_)}),e.jsx(n.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>k(_),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:o,title:"Edit Department",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:R,children:[e.jsx(n.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(n.Button,{onClick:x,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Ie,{parentCallback:C,data:{newData:m,columns:O,columnstype:"antd",action:!1,Loading:y,error:p}})})]})}const Pf=({token:t})=>e.jsx(kf,{token:t}),Yn=Me.master.designation,Of=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:Yn.table,page:a,perPage:s});function Mf({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[l]=n.Form.useForm(),[o,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:y,error:p,data:m,mutate:A}=Of({token:t,page:a.page,perPage:a.rowsPerPage}),C=(D,_)=>{s({page:D,rowsPerPage:parseInt(_,10)})},b=async D=>{const _=new FormData;_.set("title",D?.title??"");try{await A(kt(Yn.add,_,t),Ge(_)),w.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(u){w.error(u?.response?.data?.msg??u?.message??"Failed to add designation.",{duration:1e3})}},f=D=>{g(D??null),l.setFieldsValue({title:D?.designation??""}),d(!0)},x=()=>{d(!1),g(null),l.resetFields()},R=async D=>{const _=c?.id??c?.designation_id;if(!_){w.error("Missing designation id.",{duration:1e3});return}const u=new FormData;u.set("id",String(_)),u.set("title",D?.title??"");try{await Vt(Yn.edit,u,t),await A(),w.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),x()}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to update designation.",{duration:1e3})}},k=async D=>{const _=D?.id??D?.designation_id;if(_)try{await A(ln(Yn.remove,_,t),ze(_)),w.success("Success! Deleted designation.",{duration:1e3})}catch(u){w.error(u?.response?.data?.msg??u?.message??"Failed to delete designation.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(D,_)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(_)}),e.jsx(n.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>k(_),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:o,title:"Edit Designation",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:R,children:[e.jsx(n.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(n.Button,{onClick:x,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Ie,{parentCallback:C,data:{newData:m,columns:O,columnstype:"antd",action:!1,Loading:y,error:p}})})]})}const Ef=({token:t})=>e.jsx(Mf,{token:t}),Vn=Me.master.shift,$f=({token:t,page:a=1,perPage:s=10})=>wa({token:t,baseUrl:Vn.table,page:a,perPage:s}),mt="hh:mm A",pa=t=>{const a=String(t??"");if(!a)return null;const s=te(a,[mt,"HH:mm","HH:mm:ss"],!0);return s.isValid()?s:null},ma=t=>t?t.format(mt):"",_t={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ff({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[l]=n.Form.useForm(),[o,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:y,error:p,data:m,mutate:A}=$f({token:t,page:a.page,perPage:a.rowsPerPage}),C=(u,h)=>{s({page:u,rowsPerPage:parseInt(h,10)})},b=(u,h)=>{const S=new FormData;return h&&S.set("id",String(h)),S.set("name",u?.name??""),S.set("start_time",ma(u?.start_time)),S.set("end_time",ma(u?.end_time)),S.set("shift_start_from",ma(u?.shift_start_from)),S.set("shift_start_to",ma(u?.shift_start_to)),S.set("shift_end_from",ma(u?.shift_end_from)),S.set("shift_end_to",ma(u?.shift_end_to)),S},f=async u=>{try{const h=b(u);await A(kt(Vn.add,h,t),Ge(h)),w.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to add shift.",{duration:1e3})}},x=u=>{g(u??null),l.setFieldsValue({name:u?.shift_name??u?.name??"",start_time:pa(u?.start_time),end_time:pa(u?.end_time),shift_start_from:pa(u?.shift_start_from),shift_start_to:pa(u?.shift_start_to),shift_end_from:pa(u?.shift_end_from),shift_end_to:pa(u?.shift_end_to)}),d(!0)},R=()=>{d(!1),g(null),l.resetFields()},k=async u=>{const h=c?.id??c?.shift_id;if(!h){w.error("Missing shift id.",{duration:1e3});return}try{const S=b(u,h);await Vt(Vn.edit,S,t),await A(),w.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),R()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to update shift.",{duration:1e3})}},O=async u=>{const h=u?.id??u?.shift_id;if(h)try{await A(ln(Vn.remove,h,t),ze(h)),w.success("Success! Deleted shift.",{duration:1e3})}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to delete shift.",{duration:1e3})}},D=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:(u,h)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>x(h)}),e.jsx(n.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>O(h),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]),_=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:o,title:"Edit Shift",onCancel:R,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:k,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:_,children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:_,children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:R,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(n.Form,{form:r,layout:"vertical",onFinish:f,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(z,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:_,children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:_,children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:mt,use12Hours:!0,style:_t})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Ie,{parentCallback:C,data:{newData:m,columns:D,columnstype:"antd",action:!1,Loading:y,error:p}})})]})}const Uf=({token:t})=>e.jsx(Ff,{token:t}),Nf=Me.attendance;function Bf({data:t}){return t?e.jsx("div",{style:{margin:15,fontSize:13,padding:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{}),(t?.shifts??[]).map((a,s)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:a?.shift_name??""},`${s}heading1`))]}),e.jsxs("tr",{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Sl.No"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Teacher's Name"}),(t?.shifts??[]).map((a,s)=>e.jsxs(i.Fragment,{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"In Time"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Out Time"})]},`${s}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((a,s)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:s+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${a?.name??""} ${a?.surname??""}`.trim()})}),(t?.shifts??[]).map((r,l)=>e.jsxs(i.Fragment,{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkintime??"").toUpperCase():""})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${l}cells${s}`))]},`${s}row`))})]})}):null}const Lf=t=>{const a=t?.data??t??{},s=a?.items??a?.data??[];return Array.isArray(s)?s:[]},qf=t=>{const a=String(t??"").toLowerCase();return a==="present"?e.jsx(n.Tag,{color:"green",children:"Present"}):a==="absent"?e.jsx(n.Tag,{color:"red",children:"Absent"}):a==="leave"?e.jsx(n.Tag,{color:"orange",children:"Leave"}):e.jsx(n.Tag,{children:t??""})};function zf({token:t}){const[a,s]=i.useState(te()),[r,l]=i.useState(!1),[o,d]=i.useState(0),c=i.useMemo(()=>`${Nf.dailyAttendance}?attendance_date=${encodeURIComponent(a.format("YYYY-MM-DD"))}`,[a,r,o]),{isLoading:g,error:y,data:p}=H(t?[c,t]:null,([f,x])=>K(f,x)),m=i.useMemo(()=>Lf(p),[p]),A=i.useMemo(()=>r?p?.data?.data??p?.data??p??null:null,[p,r]),C=ea.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),b=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(f,x,R)=>R+1},{title:"Name",key:"name",render:(f,x)=>x?.staff_name??"",ellipsis:!0},{title:"Department",dataIndex:"department",key:"department",ellipsis:!0,responsive:["md"]},{title:"Designation",dataIndex:"designation",key:"designation",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(f,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[qf(x?.attendance_status),x?.is_week_off?e.jsx(n.Tag,{color:"blue",children:"W/O"}):null]})},{title:"In Time",key:"intime",width:120,render:(f,x)=>x?.check_in??""},{title:"Out Time",key:"outtime",width:120,render:(f,x)=>x?.check_out??""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Daily Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:a,onChange:f=>f&&s(f),style:{width:"100%"},allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",onClick:()=>d(f=>f+1)})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:C}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),r?e.jsx(Bf,{data:A}):e.jsx(n.Table,{bordered:!0,size:"small",loading:g,rowKey:(f,x)=>String(f?.id??f?.staff_id??x),columns:b,dataSource:m,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const Yf=({token:t})=>e.jsx(zf,{token:t}),Ei=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Vf=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 Wf({token:t,staffId:a}){const[s,r]=i.useState(!1),[l,o]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[g,y]=i.useState(""),[p,m]=i.useState(""),A=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),C=E=>{const F=Number(E??0),q=Number.isFinite(F)?F.toLocaleString("en-IN"):"0";return`${A?`${A} `:""}${q}`},b=i.useMemo(()=>a?`${Me.staff.basicById}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),f=i.useMemo(()=>a?`${Me.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),{data:x}=H(t&&b?[b,t]:null,([E,F])=>K(E,F)),{data:R,isLoading:k,mutate:O}=H(t&&f?[f,t]:null,([E,F])=>K(E,F)),D=i.useMemo(()=>Ei(x)[0]??x?.data??x??null,[x]),_=i.useMemo(()=>Ei(R),[R]),u=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:(E,F)=>e.jsx("div",{style:{fontSize:11},children:Rt(F?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(E,F)=>e.jsx("div",{style:{fontSize:11},children:Rt(F?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(E,F)=>e.jsx("div",{style:{fontSize:11},children:Rt(F?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(E,F)=>e.jsx("div",{style:{fontSize:11},children:Rt(F?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(E,F)=>e.jsx("div",{style:{cursor:F?.status==="due"?"pointer":"default"},onClick:()=>{F?.status==="due"&&(o(F),r(!0))},children:Zl(F?.status)})}],[]),h=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"}],[]),S=async()=>{if(!l)return;const E={...l,staff_id:a,payment_type:d?.value??"",notes:g,attchement:p};try{await Ne(Me.payroll.generatePayslip,{arg:E},t),w.success("Success!",{duration:1e3}),r(!1),o(null),y(""),m(""),await O()}catch(F){w.error(F?.response?.data?.msg??F?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("div",{style:{fontSize:13,color:"#444"},children:D?`${D?.f_name??D?.firstname??""} ${D?.l_name??D?.lastname??""}`.trim():""}),e.jsx(n.Table,{bordered:!0,size:"small",loading:k,rowKey:(E,F)=>String(E?.id??`${E?.month}-${F}`),columns:u,dataSource:_,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(n.Modal,{open:s,onCancel:()=>{r(!1),o(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{label:"Pay",options:h,value:d,onChange:E=>c(E??h[0]),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Note"}),e.jsx(n.Input.TextArea,{rows:4,placeholder:"Note",value:g,onChange:E=>y(E.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(n.Upload,{maxCount:1,action:io(),headers:t?{Authorization:t}:void 0,onChange:E=>{if(E?.file?.status==="done"){const F=Vf(E?.file?.response);F&&m(F)}E?.file?.status==="removed"&&m("")},children:e.jsx(n.Button,{icon:e.jsx(ee.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(n.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(ne,{type:"button",value:l?.Total_Payable_Amount?`Pay ${C(l.Total_Payable_Amount)}`:"Pay",onClick:S})]})]})})]})}function Hf({token:t,staffId:a}){const s=i.useMemo(()=>{if(a!=null&&String(a).trim()!=="")return a;if(typeof window>"u")return null;const r=new URLSearchParams(window.location.search).get("id");return r||null},[a]);return s?e.jsx(Wf,{token:t,staffId:s}):e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsx("div",{style:{fontSize:13,color:"#666"},children:"Missing staff id."})})}function Wt({onAdd:t,onExport:a,onPrint:s,onDownload:r,onFilter:l,onRefresh:o,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(ee.FileExcelOutlined,{}),onClick:a},{key:"print",title:"Print",icon:e.jsx(ee.PrinterOutlined,{}),onClick:s},{key:"download",title:"Download",icon:e.jsx(ee.DownloadOutlined,{}),onClick:r},{key:"filter",title:"Filter",icon:e.jsx(ee.FilterOutlined,{}),onClick:l},{key:"refresh",title:"Refresh",icon:e.jsx(ee.ReloadOutlined,{}),onClick:o}],[t,a,s,r,l,o]),g=i.useMemo(()=>{const y=Array.isArray(d)&&d.length?new Set(d):null;return y?c.filter(p=>y.has(p.key)):c},[c,d]);return e.jsx(n.Space,{size:8,children:g.map(y=>e.jsx(n.Tooltip,{title:y.title,children:e.jsx(n.Button,{type:"text",icon:y.icon,onClick:y.onClick,disabled:!y.onClick})},y.key))})}const or=t=>t??localStorage.getItem("authToken")??"",Et={dashboard:{monthlyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentmonthlyReportgraph",weeklyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentweeklyReportgraph"},dropdowns:{classes:"api/branchapi/academy/classdropdownlist",sectionsByClass:"api/branchapi/academy/sectionoftheClass",sessions:"api/branchapi/generalSettings/sessiondropdown"},studentAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass",save:"api/studentAttendace/addattendencebyBranch",emergencyLeave:"api/StudentAttendace/emergency_leave"},dailyAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass"},monthlyReport:{table:"api/AttendenceReport/studentmonthlyAttendencebyclass",byStudent:"api/branchapi/student/getStududentMonthlyByIdUrlnew"},yearlyReport:{table:"api/AttendenceReport/studentyearlyAttendenceReport"}},Lt=async(t,a)=>K(t,or(a)),Kf=async(t,a,s)=>Ne(t,a,or(s)),Gf=async(t,a,s)=>Ha(t,{arg:a},or(s)),Ka=(t,a)=>{const s=new URLSearchParams;Object.entries(a??{}).forEach(([l,o])=>{o==null||o===""||s.set(l,String(o))});const r=t.includes("?")?"&":"?";return`${t}${r}${s.toString()}`},$i=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},Jf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},mo=(t,a)=>{const s=t?.data?.data??t?.data??t??{},r=a?s?.[a]:s;return Array.isArray(r)?r:Array.isArray(s?.student)?s.student:Array.isArray(s?.staff)?s.staff:Array.isArray(s?.data)?s.data:[]},Qf=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],Xf=t=>{const a={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(s=>{if(Array.isArray(s?.monthly_data)||Array.isArray(s?.month_data)){Qf(s).forEach(l=>{const o=l?.[0]?.data?.[0]??l?.data?.[0]??l??{},d=String(o?.attendance_type??o?.attendence_type_id??"").toUpperCase();(d==="P"||d==="1")&&(a.present+=1),(d==="A"||d==="4")&&(a.absent+=1),(d==="L"||d==="3")&&(a.late+=1),(d==="LEAVE"||d==="2")&&(a.leave+=1)});return}const r=String(s?.attendance_type??s?.attendence_type_id??"").toUpperCase();(r==="P"||r==="1")&&(a.present+=1),(r==="A"||r==="4")&&(a.absent+=1),(r==="L"||r==="3")&&(a.late+=1),(r==="LEAVE"||r==="2")&&(a.leave+=1)}),a},dr=(t,a)=>{const{data:s,isLoading:r,error:l}=H(a&&t?[t,a]:null,([o,d])=>Lt(o,d));return{isLoading:r,error:l,data:s,options:i.useMemo(()=>Jf(s),[s])}},ls=t=>dr(Et.dropdowns.classes,t),os=(t,a)=>{const s=t?`${Et.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return dr(s,a)},Zf=t=>dr(Et.dropdowns.sessions,t),cr=t=>{const a=String(t??"").toUpperCase();return st(a==="1"||a==="P"||a==="PRESENT"?"P":a==="4"||a==="A"||a==="ABSENT"?"A":a==="3"||a==="L"||a==="LATE"?"L":a==="2"||a==="LEAVE"?"LEAVE":a==="W"?"W":a==="H"?"H":a||"-")},ho=(t,a,s)=>{const r=new Blob([t],{type:a}),l=URL.createObjectURL(r),o=document.createElement("a");o.href=l,o.download=s,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(l)},Fi=t=>String(t??"").replace(/"/g,'""'),ey=({rows:t,columns:a,fileName:s})=>{const r=Array.isArray(a)?a:[],l=Array.isArray(t)?t:[],o=r.map(c=>`"${Fi(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=l.map((c,g)=>r.map(y=>{const p=y?.dataIndex??y?.selector??y?.key,m=p==="sl"?g+1:c?.[p];return`"${Fi(m)}"`}).join(",")).join(`
61
+ `);ho([o,d].filter(Boolean).join(`
62
+ `),"text/csv;charset=utf-8;",s)},ty=({value:t,fileName:a})=>{ho(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",a)};function fo({summary:t}){const a=[{key:"present",label:"Present",color:"#52c41a"},{key:"absent",label:"Absent",color:"#ff4d4f"},{key:"leave",label:"Leave",color:"#1677ff"}];return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:12},children:a.map(s=>e.jsxs(n.Card,{size:"small",styles:{body:{padding:12}},children:[e.jsx("div",{style:{fontSize:11,color:"#666",marginBottom:4},children:s.label}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:s.color},children:t?.[s.key]??0})]},s.key))})}function ba({summary:t,title:a="Attendance Overview"}){const s=i.useMemo(()=>[{key:"present",label:"Present",value:Number(t?.present??0),color:"#52c41a"},{key:"absent",label:"Absent",value:Number(t?.absent??0),color:"#ff4d4f"},{key:"leave",label:"Leave",value:Number(t?.leave??0),color:"#1677ff"}],[t]),r=Math.max(...s.map(l=>l.value),1);return e.jsx(n.Card,{size:"small",title:a,children:e.jsx("div",{style:{display:"grid",gap:8},children:s.map(l=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"80px 1fr 40px",gap:8,alignItems:"center"},children:[e.jsx("div",{style:{fontSize:11,color:"#444"},children:l.label}),e.jsx("div",{style:{height:10,background:"#f0f0f0",borderRadius:999},children:e.jsx("div",{style:{width:`${l.value/r*100}%`,height:"100%",background:l.color,borderRadius:999}})}),e.jsx("div",{style:{fontSize:11,fontWeight:600,textAlign:"right"},children:l.value})]},l.key))})})}function ay(){const t=[{label:"Present",node:st("P")},{label:"Absent",node:st("A")},{label:"Late",node:st("L")},{label:"Weekly Off",node:st("W")},{label:"Holiday",node:st("H")}];return e.jsx(n.Space,{wrap:!0,size:[12,8],children:t.map(a=>e.jsxs(n.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:a.label}),a.node]},a.label))})}function qt({items:t}){const a=Array.isArray(t)?t.filter(s=>s?.value):[];return a.length?e.jsx(n.Space,{wrap:!0,size:[8,8],children:a.map(s=>e.jsxs(n.Tag,{color:"blue",children:[s.label,": ",s.value]},s.label))}):null}function ds({title:t,subtitle:a,printRef:s,exportRows:r,exportColumns:l,onRefresh:o,onAdd:d,filterSection:c,summary:g,chartContent:y,reportTitle:p,reportExtra:m,children:A,fileBaseName:C="attendance"}){const b=ea.useReactToPrint({content:()=>s?.current});return e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(n.Card,{size:"small",title:e.jsxs("div",{children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:t}),a?e.jsx(n.Typography.Text,{type:"secondary",style:{display:"block",marginTop:2,fontSize:12},children:a}):null]}),extra:e.jsx(Wt,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>ey({rows:r,columns:l,fileName:`${C}.csv`}),onPrint:b,onDownload:()=>ty({value:r,fileName:`${C}.json`}),onRefresh:o}),children:c}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:12,alignItems:"start"},children:[e.jsx(fo,{summary:g}),y===!1?null:y||e.jsx(ba,{summary:g})]}),e.jsx(n.Card,{size:"small",title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:p}),extra:m,styles:{body:{padding:0}},children:A})]})}const ny=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function sy({rows:t,loading:a,sunday:s,holiday:r,holidayTitle:l,onChangeRows:o,onEmergency:d}){const c=(y,p)=>{const m=(Array.isArray(t)?t:[]).map((A,C)=>(A?.student_session_id??A?.student_id??A?.id??C)===y?{...A,...p}:A);o?.(m)},g=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(y,p,m)=>m+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(y,p)=>p?.full_name??p?.student_name??p?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(y,p,m)=>{const A=p?.student_session_id??p?.student_id??p?.id??m;return e.jsx(n.Select,{size:"small",style:{width:"100%"},options:ny,value:String(y??"1"),onChange:C=>c(A,{attendence_type_id:C})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:y=>y?te(y).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120},{title:"Emergency Leave",key:"emergency_leave",width:140,render:(y,p)=>e.jsx(n.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(ee.ClockCircleOutlined,{}),onClick:()=>d?.(p),children:"E.L"})}],[d,t]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:l||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(y,p)=>String(y?.student_session_id??y?.student_id??y?.id??p),columns:g,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function ry({rows:t,loading:a,sunday:s,holiday:r,holidayTitle:l}){const o=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,g)=>g+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(d,c)=>c?.full_name??c?.student_name??c?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:120,render:d=>cr(d)},{title:"Date",dataIndex:"date",key:"date",width:120,render:d=>d?te(d).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120}],[]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:l||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(d,c)=>String(d?.student_session_id??d?.student_id??d?.id??c),columns:o,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function iy({data:t,loading:a,onViewStudent:s}){const r=t?.data??t??{},l=Array.isArray(r?.studentAttendance)?r.studentAttendance:Array.isArray(r?.students)?r.students:Array.isArray(r?.report)?r.report:Array.isArray(r?.data?.resultlist)?r.data.resultlist:Array.isArray(r?.resultlist)?r.resultlist:Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[],o=Array.isArray(r?.monthly_holiday)?r.monthly_holiday:[],d=Array.isArray(r?.dateSun)?r.dateSun:[],c=Number(r?.totalDaysMonth??0),g=i.useMemo(()=>{const y=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:20,fixed:"left"},{title:"Name",key:"student_name",fixed:"left",render:(p,m)=>e.jsx(n.Button,{type:"link",style:{padding:0},onClick:()=>s?.(m),children:m?.student_name??m?.full_name??"--"})}];return[...new Array(c).keys()].forEach(p=>{y.push({title:String(p+1),key:`day-${p+1}`,align:"center",render:(m,A)=>{const b=A?.[`${A?.student_id}_${l.indexOf(A)}`]?.[p]??{},f=b?.attendance_date,x=o.find(R=>R?.date===f);return d.includes(f)?Vr("sunday","W"):x?Vr("holiday","H"):cr(b?.attendence_type_id)}})}),y.push({title:"Total",key:"total",fixed:"right",render:(p,m)=>{let A=0,C=0,b=0;return[...new Array(c).keys()].forEach(f=>{const x=m?.[`${m?.student_id}_${l.indexOf(m)}`]?.[f]??{},R=String(x?.attendence_type_id??"");R==="1"&&(A+=1),R==="4"&&(C+=1),R==="3"&&(b+=1)}),e.jsxs("span",{children:["P: ",A," A: ",C," L: ",b]})}}),y},[o,s,l,d,c]);return e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(y,p)=>String(y?.student_id??p),columns:g,dataSource:l,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(n.Empty,{description:"No monthly report found"})}})}function ly({open:t,onClose:a,loading:s,data:r,studentName:l}){const o=Array.isArray(r?.data?.report)?r.data.report:[],d=[{title:"Date",dataIndex:"attendance_date",key:"attendance_date",render:c=>c?te(c).format("DD-MM-YYYY"):"--"},{title:"Status",key:"status",render:(c,g)=>cr(g?.attendence_type_id??g?.attendance_type)},{title:"In Time",dataIndex:"intime",key:"intime"},{title:"Out Time",dataIndex:"outtime",key:"outtime"},{title:"Remark",dataIndex:"remark",key:"remark"}];return e.jsx(n.Modal,{open:t,onCancel:a,footer:null,width:900,title:`Monthly Details${l?` - ${l}`:""}`,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(c,g)=>String(c?.attendance_date??g),columns:d,dataSource:o,loading:s,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function oy({open:t,onClose:a,onSubmit:s,loading:r}){const[l,o]=n.Modal.useModal(),[d,c]=i.useState(null),[g,y]=i.useState(""),p=async()=>{if(!d){await l.warning({title:"Select time"});return}await s?.({outtime:d.format("h:mm a"),message:g}),c(null),y("")};return e.jsxs(e.Fragment,{children:[o,e.jsx(n.Modal,{title:"Emergency Leave",open:t,onCancel:a,onOk:p,confirmLoading:r,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Select Time"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:d,onChange:c,style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Purpose"}),e.jsx(n.Input.TextArea,{rows:4,value:g,onChange:m=>y(m.target.value)})]})]})})]})}const yo=t=>Xf(t),Ui=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.reduce((s,r)=>({present:s.present+Number(r?.present??r?.Present??r?.total_present??0),absent:s.absent+Number(r?.absent??r?.Absent??r?.total_absent??0),late:s.late+Number(r?.late??r?.Late??0),leave:s.leave+Number(r?.leave??r?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(a?.present??a?.Present??a?.total_present??0),absent:Number(a?.absent??a?.Absent??a?.total_absent??0),late:Number(a?.late??a?.Late??0),leave:Number(a?.leave??a?.Leave??0)}};function dy({token:t}){const{data:a}=H(t?[Et.dashboard.monthlyGraph,t]:null,([o,d])=>Lt(o,d)),{data:s}=H(t?[Et.dashboard.weeklyGraph,t]:null,([o,d])=>Lt(o,d)),r=i.useMemo(()=>Ui(a),[a]),l=i.useMemo(()=>Ui(s),[s]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(n.Card,{children:[e.jsx(n.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(fo,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(ba,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(ba,{summary:l,title:"Weekly Attendance Chart"})]})]})}const Ms=Et.studentAttendance,cy={width:"100%",height:40};function uy({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(te()),[x,R]=i.useState(0),[k,O]=i.useState([]),[D,_]=i.useState(!1),[u,h]=i.useState(null),[S,E]=i.useState(!1),[F,q]=i.useState(!1),T=ls(t),U=os(s,t),j=i.useMemo(()=>!s||!d||x===0?null:Ka(Ms.list,{cID:s,sID:d,batch_id:p,date:b.format("YYYY-MM-DD")}),[p,s,b,x,d]),{data:P,isLoading:I,mutate:N}=H(t&&j?[j,t]:null,([G,J])=>Lt(G,J));i.useEffect(()=>{O(mo(P,"student"))},[P]);const V=P?.data?.data??P?.data??P??{},W=!!V?.sunday,B=!!V?.holiday?.holiday,$=V?.holiday?.title??"",M=i.useMemo(()=>yo(k),[k]),L=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),Y=async()=>{if(k.length)try{q(!0),await Kf(Ms.save,{attendenceData:k,date:b.format("YYYY-MM-DD"),holiday:D?"YES":"NO"},t),w.success("Student attendance saved."),N?.()}catch(G){w.error(G?.message??"Failed to save attendance.")}finally{q(!1)}},se=async({outtime:G,message:J})=>{if(u?.attendence_id)try{E(!0),await Gf(Ms.emergencyLeave,{outtime:G,message:J,id:u.attendence_id},t),w.success("Emergency leave updated."),h(null),N?.()}catch(re){w.error(re?.message??"Failed to update emergency leave.")}finally{E(!1)}},X=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:T.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:G=>{r(G?.value??""),o(G?.label??""),c(""),y(""),m(""),C("")},required:!0}),e.jsx(Q,{options:U.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:G=>{c(G?.value??""),y(G?.label??""),m(""),C("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:b,onChange:G=>G&&f(G),style:cy,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>R(G=>G+1)})})]}),e.jsx(qt,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{}),e.jsx(ds,{title:"Student Attendance",printRef:a,exportRows:k,exportColumns:L,onRefresh:()=>N?.(),filterSection:X,summary:M,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{size:"small",type:D?"primary":"default",onClick:()=>_(G=>!G),children:D?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"primary",onClick:Y,loading:F,disabled:!k.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(It,{}),e.jsx(n.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(n.Card,{size:"small",style:{marginBottom:12},children:e.jsx(qt,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})})]}),e.jsx(sy,{rows:k,loading:I,sunday:W,holiday:B,holidayTitle:$,onChangeRows:O,onEmergency:h})]})}),e.jsx(oy,{open:!!u,onClose:()=>h(null),onSubmit:se,loading:S})]})}const py=Et.dailyAttendance,my={width:"100%",height:40};function hy({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(te()),[x,R]=i.useState(0),k=ls(t),O=os(s,t),D=i.useMemo(()=>!s||!d||x===0?null:Ka(py.list,{cID:s,sID:d,batch_id:p,date:b.format("YYYY-MM-DD")}),[p,s,b,x,d]),{data:_,isLoading:u,mutate:h}=H(t&&D?[D,t]:null,([I,N])=>Lt(I,N)),S=i.useMemo(()=>mo(_,"student"),[_]),E=_?.data?.data??_?.data??_??{},F=!!E?.sunday,q=!!E?.holiday?.holiday,T=E?.holiday?.title??"",U=i.useMemo(()=>yo(S),[S]),j=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),P=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:k.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{r(I?.value??""),o(I?.label??""),c(""),y(""),m(""),C("")},required:!0}),e.jsx(Q,{options:O.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{c(I?.value??""),y(I?.label??""),m(""),C("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:b,onChange:I=>I&&f(I),style:my,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>R(I=>I+1)})})]}),e.jsx(qt,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})]});return e.jsx(ds,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:a,exportRows:S,exportColumns:j,onRefresh:()=>h?.(),filterSection:P,summary:U,chartContent:e.jsx(ba,{summary:U,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(It,{}),e.jsx(qt,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})]}),e.jsx(ry,{rows:S,loading:u,sunday:F,holiday:q,holidayTitle:T})]})})}const Ni=Et.monthlyReport,go=t=>Array.isArray(t?.studentAttendance)?t.studentAttendance:Array.isArray(t?.students)?t.students:Array.isArray(t?.report)?t.report:Array.isArray(t?.data?.resultlist)?t.data.resultlist:Array.isArray(t?.resultlist)?t.resultlist:Array.isArray(t?.data)?t.data:Array.isArray(t)?t:[],fy=t=>{const a=go(t),s=Number(t?.totalDaysMonth??0),r={present:0,absent:0,late:0,leave:0};return a.forEach((l,o)=>{[...new Array(s).keys()].forEach(d=>{const c=l?.[`${l?.student_id}_${o}`]?.[d]??{},g=String(c?.attendence_type_id??"");g==="1"&&(r.present+=1),g==="4"&&(r.absent+=1),g==="3"&&(r.late+=1),g==="2"&&(r.leave+=1)})}),r},yy=t=>{const a=go(t),s=Number(t?.totalDaysMonth??0);return a.map((r,l)=>{let o=0,d=0,c=0;return[...new Array(s).keys()].forEach(g=>{const y=r?.[`${r?.student_id}_${l}`]?.[g]??{},p=String(y?.attendence_type_id??"");p==="1"&&(o+=1),p==="4"&&(d+=1),p==="3"&&(c+=1)}),{roll_no:r?.roll_no??"",student_name:r?.student_name??r?.full_name??"",present:o,absent:d,late:c}})};function gy({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(String(new Date().getFullYear())),[x,R]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[k,O]=i.useState(0),[D,_]=i.useState(null),u=ls(t),h=os(s,t),S=i.useMemo(()=>ir(Number(b)),[b]),E=i.useMemo(()=>rr(10),[]),F=i.useMemo(()=>!s||!d||!b||!x||k===0?null:Ka(Ni.table,{session:$i(),class_id:s,section_id:d,year:b,month:x,batch_id:p}),[p,s,x,k,d,b]),{data:q,isLoading:T,mutate:U}=H(t&&F?[F,t]:null,([M,L])=>Lt(M,L)),j=q?.data?.data??q?.data??q??{},P=i.useMemo(()=>fy(j),[j]),I=i.useMemo(()=>yy(j),[j]),N=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Name",dataIndex:"student_name"},{title:"Present",dataIndex:"present"},{title:"Absent",dataIndex:"absent"},{title:"Late",dataIndex:"late"}],[]),V=i.useMemo(()=>D?.student_id?Ka(Ni.byStudent,{student_id:D.student_id,month:x,year:b,session:$i()}):null,[x,D,b]),{data:W,isLoading:B}=H(t&&V?[V,t]:null,([M,L])=>Lt(M,L)),$=e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12,alignItems:"end"},children:[e.jsx(Q,{options:u.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{r(M?.value??""),o(M?.label??""),c(""),y(""),m(""),C("")},required:!0}),e.jsx(Q,{options:h.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{c(M?.value??""),y(M?.label??""),m(""),C("")},required:!0},`section-${s}`),e.jsx(Q,{options:E,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:E.find(M=>String(M?.value)===String(b))??null,onChange:M=>f(String(M?.value??"")),required:!0}),e.jsx(Q,{options:S,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:S.find(M=>String(M?.value)===String(x))??null,onChange:M=>R(String(M?.value??"").padStart(2,"0")),required:!0},`month-${b}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>O(M=>M+1)})})]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:12,alignItems:"center",justifyContent:"space-between"},children:[e.jsx(qt,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Month",value:S.find(M=>String(M?.value)===String(x))?.label??x},{label:"Year",value:b}]}),e.jsx(ay,{})]})]});return e.jsxs(e.Fragment,{children:[e.jsx(ds,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:a,exportRows:I,exportColumns:N,onRefresh:()=>U?.(),filterSection:$,summary:P,chartContent:e.jsx(ba,{summary:P,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(It,{}),e.jsx(qt,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Month",value:S.find(M=>String(M?.value)===String(x))?.label??x},{label:"Year",value:b}]})]}),e.jsx(iy,{data:j,loading:T,onViewStudent:_})]})}),e.jsx(ly,{open:!!D,onClose:()=>_(null),loading:B,data:W,studentName:D?.student_name??D?.full_name})]})}const xy=Et.yearlyReport,by=t=>{const a=t?.data?.data??t?.data??t??{};return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:Array.isArray(a?.students)?a.students:Array.isArray(a?.report)?a.report:Array.isArray(a?.resultlist)?a.resultlist:[]},jy=t=>(Array.isArray(t)?t:[]).reduce((a,s)=>({present:a.present+Number(s?.singleStudentPresentData??s?.present??0),absent:a.absent+Number(s?.singleStudentAbsentData??s?.absent??0),late:a.late+Number(s?.late??0),leave:a.leave+Number(s?.leave??0)}),{present:0,absent:0,late:0,leave:0});function Sy({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(""),[x,R]=i.useState(""),[k,O]=i.useState(0),D=ls(t),_=os(s,t),u=Zf(t),h=i.useMemo(()=>!s||!d||k===0?null:Ka(xy.table,{class_id:s,section_id:d,session_id:p,batch_id:b}),[b,s,k,d,p]),{data:S,isLoading:E,mutate:F}=H(t&&h?[h,t]:null,([I,N])=>Lt(I,N)),q=i.useMemo(()=>by(S),[S]),T=i.useMemo(()=>jy(q),[q]),U=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),j=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(I,N,V)=>V+1},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",dataIndex:"full_name",key:"full_name"},{title:"Total Present",dataIndex:"singleStudentPresentData",key:"singleStudentPresentData",width:130},{title:"Total Absent",dataIndex:"singleStudentAbsentData",key:"singleStudentAbsentData",width:130}],[]),P=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:D.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{r(I?.value??""),o(I?.label??""),c(""),y(""),f(""),R("")},required:!0}),e.jsx(Q,{options:_.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{c(I?.value??""),y(I?.label??""),f(""),R("")},required:!0},`section-${s}`),e.jsx(Q,{options:u.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{m(I?.value??""),C(I?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>O(I=>I+1)})})]}),e.jsx(qt,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Session",value:A}]})]});return e.jsx(ds,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:a,exportRows:q,exportColumns:U,onRefresh:()=>F?.(),filterSection:P,summary:T,chartContent:e.jsx(ba,{summary:T,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(It,{}),e.jsx(qt,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Session",value:A}]})]}),e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(I,N)=>String(I?.student_id??I?.id??N),columns:j,dataSource:q,loading:E,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}const vy=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},xo=t=>{const a=$t(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Bi=(t,a)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=xo(a),l=s.startsWith("/")?s.slice(1):s;return vy(Ke(),`uploads/school_${r}/branch/income/${l}`)},wy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.map(s=>({value:s?.value??s?.id??"",label:s?.label??s?.name??s?.income_category??s?.title??""})):[]};function _y({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Tt),{isLoading:l,data:o}=H(s&&r?[`${Wc}?id=${r}`,s]:null,([u,h])=>K(u,h)),{data:d}=H(s?[Ll,s]:null,([u,h])=>K(u,h)),c=i.useMemo(()=>wy(d),[d]),g=i.useMemo(()=>{if(Array.isArray(o))return o[0];const u=o?.data?.data??o?.data??o??{};return Array.isArray(u)?u[0]:u??{}},[o]),[y,p]=i.useState({income_head:"",name:"",invoice_no:"",date:te(),amount:"",description:"",doc:""}),[m,A]=i.useState(!1),[C,b]=i.useState(!1),[f,x]=i.useState(""),[R,k]=i.useState(""),O=async u=>{u.preventDefault(),A(!0);try{await a(u,r)}finally{A(!1)}};i.useEffect(()=>{g&&p({income_head:g?.inc_head_id||"",name:g?.name||"",invoice_no:g?.invoice_no||"",date:g?.date?te(g.date):te(),amount:g?.amount||"",description:g?.note||"",doc:g?.documents||""})},[g]);const D=(u,h)=>{p(S=>({...S,[u]:h}))},_=c.find(u=>String(u.value)===String(y.income_head))??null;return l?e.jsx(v,{pt:4,pb:1,style:{width:550,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(n.Spin,{tip:"Loading..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:O,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Edit Income"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(z,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Q,{label:"Income Head",options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0,value:_,onChange:u=>D("income_head",u?.value||"")})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"name",type:"text",label:"Name",required:!0,value:y.name,onChange:u=>D("name",u.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:y.invoice_no,onChange:u=>D("invoice_no",u.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:y.date,Desplay:"Date",name:"date",required:!0,onChange:u=>D("date",u)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"amount",type:"number",label:"Amount",required:!0,value:y.amount,onChange:u=>D("amount",u.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(lt,{name:"description",label:"Description",rows:3,value:y.description,onChange:u=>D("description",u.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:`${Ke()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${xo(s)}/branch/income`},headers:{Authorization:s},maxCount:1,onChange:u=>{if(u.file.status==="removed"&&D("doc",""),u.file.status==="done"){const h=u.file.response?.data??u.file.response?.file??"";D("doc",String(h??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:y.doc?"Change":"Upload"})},y.doc||"empty"),y.doc&&e.jsx("a",{href:Bi(y.doc,s),target:"_blank",rel:"noreferrer",style:{display:"block",marginTop:8,fontSize:12,color:"#1677ff",textDecoration:"underline"},onClick:u=>{u.preventDefault(),x(Bi(y.doc,s)),k(y.doc||"Document"),b(!0)},children:"View existing document"}),e.jsx("input",{type:"hidden",name:"doc",value:y.doc||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:m?"Saving...":"Submit",color:"primary",disabled:m})})})})})]})})]})}),e.jsx(n.Modal,{open:C,onCancel:()=>{b(!1),x(""),k("")},footer:null,width:900,closable:!0,children:e.jsxs(v,{p:3,children:[e.jsx(v,{mb:2,children:e.jsx(pe,{level:5,children:R||"View Document"})}),f?f.match(/\.pdf(?:[?#]|$)/i)?e.jsx("iframe",{src:f,title:R||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:f,alt:R||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(pe,{children:"No document found"})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Cy=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ay=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Li=t=>{const a=$t(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}};function Dy({token:t}){const[a,s]=i.useState([]),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState({income_head:"",name:"",invoice_no:"",date:te().format("YYYY-MM-DD"),amount:"",description:"",doc:""}),[y,p]=i.useState(!1),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(T,U)=>{A({...m,page:T,rowsPerPage:parseInt(U,10)})},b=async(T,U)=>{try{await k(Ne(T,U,t),Ge(U)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},{isLoading:f,error:x,data:R,mutate:k}=H(t?[Uc,t,m.page,m.rowsPerPage]:null,([T,U,j,P])=>K(`${T}?page=${j}&per_page=${P}`,U)),O=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0},{id:"3",name:"Income Category",selector:"income_category",sortable:!0},{id:"4",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"5",name:"Date",selector:"date",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0},{id:"8",name:"File",selector:"documents",sortable:!1,render:T=>{const U=Li(t),j=T?/^https?:\/\//i.test(T)?T:Ay(Ke(),`uploads/school_${U}/branch/income/${T}`):null;return T?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>j&&window.open(j,"_blank"),children:"View"}):"Not Uploaded"}}],[t]),D=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],_=async T=>{try{await k(He(Lc,T,t),ze(T)),w.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{w.error("Failed to delete the item.",{duration:1e3})}},u=async(T,U,j)=>{try{await k(We(T,U,t)),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await j(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},h=async(T,U)=>{T.preventDefault();const j=new FormData(T.target);await u(Bc,j,U),E(!1)},S=async T=>{if(T.preventDefault(),!T.target.date.value)w.error("Select required dates",{duration:1e3}),T.target?.date?.focus(),d("textDanger");else{const U=new FormData(T.target);await b(Nc,U),T.target.reset(),l(""),g(j=>({...j,date:te().format("YYYY-MM-DD")}))}},E=T=>{p(T)},{data:F}=H(t?[Ll,t]:null,([T,U])=>K(T,U)),q=i.useMemo(()=>Cy(F),[F]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Add Income"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:S,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Income Head",options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",name:"date",status:o===""?"":"error",classnme:o,onChange:()=>d("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:`${Ke()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${Li(t)}/branch/income`},headers:{Authorization:t},maxCount:1,onChange:T=>{if(T.file.status==="removed"&&l(""),T.file.status==="done"){const U=T.file.response?.data??T.file.response?.file??"";l(String(U??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:r?"Change":"Upload"})},r||"empty"),e.jsx("input",{type:"hidden",name:"doc",value:r||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(lt,{name:"description",label:"Description",rows:3})})}),e.jsx(n.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:C,data:{newData:R,columns:O,action:!0,Loading:f,ActionView:D,error:x,editDesign:e.jsx(_y,{data:{handleUpdate:h,token:t}}),deleteTodoMutation:_,open:y,DrawerUpdate:E}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const qi={width:"100%",height:40};function Ty({token:t}){const[a,s]=i.useState(null),[r,l]=i.useState(null),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(D,_)=>{A({...m,page:D,rowsPerPage:parseInt(_,10)})},{isLoading:b,error:f,data:x,mutate:R}=H(t&&o?[o,t,m.page,m.rowsPerPage]:null,([D,_,u,h])=>K(`${D}page=${u}&per_page=${h}`,_)),k=i.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Income Category",selector:"income_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),O=()=>{if(!a){w.error("Select required dates",{duration:1e3}),g("textDanger");return}if(!r){w.error("Select required dates",{duration:1e3}),p("textDanger");return}const D=a.format("YYYY-MM-DD"),_=r.format("YYYY-MM-DD");d(`${Kc}?from_date=${D}&to_date=${_}&`),A(u=>({...u,page:1}))};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Search Income"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(n.DatePicker,{value:a,onChange:D=>{s(D),g("")},style:qi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(n.DatePicker,{value:r,onChange:D=>{l(D),p("")},style:qi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:O})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:C,data:{newData:x,columns:k,action:!1,Loading:b,error:f,pageController:m}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function Ry({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Tt),{isLoading:l,data:o}=H(s&&r?[`${Hc}?id=${r}`,s]:null,([C,b])=>K(C,b)),d=i.useMemo(()=>{if(Array.isArray(o))return o[0];const C=o?.data?.data??o?.data??o??{};return Array.isArray(C)?C[0]:C??{}},[o]),[c,g]=i.useState({incomehead:"",description:""}),[y,p]=i.useState(!1);i.useEffect(()=>{d&&g({incomehead:d?.income_category||d?.incomehead||"",description:d?.description||""})},[d]);const m=(C,b)=>{g(f=>({...f,[C]:b}))},A=async C=>{C.preventDefault(),p(!0);try{await a(C)}finally{p(!1)}};return l?e.jsx(v,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(n.Spin,{tip:"Loading..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:A,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(v,{children:[e.jsx(z,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(z,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:c.incomehead,onChange:C=>m("incomehead",C.target.value)})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:C=>m("description",C.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:y?"Saving...":"Submit",color:"primary",disabled:y})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function Iy({token:t}){const[a,s]=i.useState({incomehead:"",description:""}),[r,l]=i.useState(!1),[o,d]=i.useState(!1),[c,g]=i.useState({page:1,rowsPerPage:10}),y=(u,h)=>{g({...c,page:u,rowsPerPage:parseInt(h,10)})},p=async(u,h)=>{try{await b(Ne(u,h,t),Ge(h)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},{isLoading:m,error:A,data:C,mutate:b}=H(t?[qc,t,c.page,c.rowsPerPage]:null,([u,h,S,E])=>K(`${u}?page=${S}&per_page=${E}`,h)),f=i.useMemo(()=>[{id:"1",name:"Name",selector:"income_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],R=async u=>{try{await b(He(Vc,u,t),ze(u)),w.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{w.error("Failed to delete the item.",{duration:1e3})}},k=async(u,h)=>{try{await b(We(u,h,t)),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{w.error("Failed to update the item.",{duration:1e3})}},O=async u=>{u.preventDefault();const h=new FormData(u.target);await k(Yc,h),_(!1)},D=async u=>{u.preventDefault(),d(!0);try{await p(zc,new FormData(u.target)),s({incomehead:"",description:""})}finally{d(!1)}},_=u=>{l(u)};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:5,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Income Head"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:D,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:a.incomehead,onChange:u=>s(h=>({...h,incomehead:u.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:u=>s(h=>({...h,description:u.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:o?"Saving...":"Save",color:"primary",disabled:o})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,md:19,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Income Head List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:y,data:{newData:C,columns:f,action:!0,Loading:m,ActionView:x,error:A,editDesign:e.jsx(Ry,{data:{handleUpdate:O,token:t}}),deleteTodoMutation:R,open:r,DrawerUpdate:_}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ky=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},bo=t=>{const a=$t(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},zi=(t,a)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=bo(a),l=s.startsWith("/")?s.slice(1):s;return ky(Ke(),`uploads/school_${r}/branch/expense/${l}`)},Yi=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.map(s=>({value:s?.value??s?.id??"",label:s?.label??s?.name??s?.exp_category??s?.vendor_name??s?.title??""})):[]},Vi=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function Py({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Tt),{isLoading:l,data:o}=H(s&&r?[`${nu}?id=${r}`,s]:null,([F,q])=>K(F,q)),{data:d}=H(s?[ql,s]:null,([F,q])=>K(F,q)),{data:c}=H(s?[zl,s]:null,([F,q])=>K(F,q)),g=i.useMemo(()=>Yi(d),[d]),y=i.useMemo(()=>Yi(c),[c]),p=i.useMemo(()=>{if(Array.isArray(o))return o[0];const F=o?.data?.data??o?.data??o??{};return Array.isArray(F)?F[0]:F??{}},[o]),[m,A]=i.useState(!1),[C,b]=i.useState(!1),[f,x]=i.useState(""),[R,k]=i.useState(""),O=async F=>{F.preventDefault(),A(!0);try{await a(F,r)}finally{A(!1)}},[D,_]=i.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:te(),amount:"",payment_mode:"",note:"",doc:""});i.useEffect(()=>{p&&_({expense_head:p?.exp_head_id||"",vendor:p?.fk_vendor_id||"",name:p?.name||"",invoice_no:p?.invoice_no||"",date:p?.date?te(p.date):te(),amount:p?.amount||"",payment_mode:p?.payment_mode||"",note:p?.note||"",doc:p?.documents||""})},[p]);const u=(F,q)=>{_(T=>({...T,[F]:q}))},h=g.find(F=>String(F.value)===String(D.expense_head))??null,S=y.find(F=>String(F.value)===String(D.vendor))??null,E=Vi.find(F=>String(F.value)===String(D.payment_mode))??null;return l?e.jsx(v,{pt:4,pb:1,style:{width:550,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(n.Spin,{tip:"Loading..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:O,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Edit Expense"})}),e.jsx(v,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(z,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Q,{label:"Expense Head",options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0,value:h,onChange:F=>u("expense_head",F?.value||"")})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Vendor",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor",value:S,onChange:F=>u("vendor",F?.value||"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"name",type:"text",label:"Name",required:!0,value:D.name,onChange:F=>u("name",F.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:D.invoice_no,onChange:F=>u("invoice_no",F.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:D.date,Desplay:"Date",name:"date",required:!0,onChange:F=>u("date",F)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"amount",type:"number",label:"Amount",required:!0,value:D.amount,onChange:F=>u("amount",F.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Payment Mode",options:Vi,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0,value:E,onChange:F=>u("payment_mode",F?.value||"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(lt,{name:"note",label:"Description",rows:3,value:D.note,onChange:F=>u("note",F.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:`${Ke()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${bo(s)}/branch/expense`},headers:{Authorization:s},maxCount:1,onChange:F=>{if(F.file.status==="removed"&&u("doc",""),F.file.status==="done"){const q=F.file.response?.data??F.file.response?.file??"";u("doc",String(q??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:D.doc?"Change":"Upload"})}),D.doc&&e.jsx("a",{href:zi(D.doc,s),target:"_blank",rel:"noreferrer",style:{display:"block",marginTop:8,fontSize:12,color:"#1677ff",textDecoration:"underline"},onClick:F=>{F.preventDefault(),x(zi(D.doc,s)),k(D.doc||"Document"),b(!0)},children:"View existing document"}),e.jsx("input",{type:"hidden",name:"doc",value:D.doc||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:m?"Saving...":"Submit",color:"primary",disabled:m})})})})})]})})]})}),e.jsx(n.Modal,{open:C,onCancel:()=>{b(!1),x(""),k("")},footer:null,width:900,closable:!0,children:e.jsxs(v,{p:3,children:[e.jsx(v,{mb:2,children:e.jsx(pe,{level:5,children:R||"View Document"})}),f?f.match(/\.pdf(?:[?#]|$)/i)?e.jsx("iframe",{src:f,title:R||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:f,alt:R||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(pe,{children:"No document found"})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Wi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Oy=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},jo=t=>{const a=$t(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},My=(t,a)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=jo(a),l=s.startsWith("/")?s.slice(1):s;return Oy(Ke(),`uploads/school_${r}/branch/expense/${l}`)},Ey=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function $y({token:t}){const[a,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:te(),amount:"",payment_mode:"",note:"",doc:""}),[c,g]=i.useState(!1),[y,p]=i.useState(!1),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(j,P)=>{A({...m,page:j,rowsPerPage:parseInt(P,10)})},b=async(j,P)=>{try{await Ne(j,P,t),k(),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},{isLoading:f,error:x,data:R,mutate:k}=H(t?[Gc,t,m.page,m.rowsPerPage]:null,([j,P,I,N])=>K(`${j}?page=${I}&per_page=${N}`,P)),O=i.useMemo(()=>[{title:"Sl No",dataIndex:"__serialNumber",key:"sl",sorter:(j,P)=>(j.__serialNumber??0)-(P.__serialNumber??0)},{title:"Name",dataIndex:"name",key:"name",sorter:(j,P)=>String(j.name??"").localeCompare(String(P.name??""))},{title:"Description",dataIndex:"description",key:"description"},{title:"Expense Category",dataIndex:"exp_category",key:"exp_category"},{title:"Invoice No",dataIndex:"invoice_no",key:"invoice_no"},{title:"Note",dataIndex:"note",key:"note"},{title:"Amount",dataIndex:"amount",key:"amount"},{title:"File",dataIndex:"documents",key:"documents",render:(j,P)=>j?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>window.open(My(j,t),"_blank"),children:"View"}):"Not Uploaded"}],[t]),D=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],_=async j=>{try{await He(Xc,j,t),k(),w.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{w.error("Failed to delete the item.",{duration:1e3})}},u=async(j,P,I)=>{try{await k(We(j,P,t)),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await I(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},h=async(j,P)=>{j.preventDefault();const I=new FormData(j.target);await u(Qc,I,P),E(!1)},S=async j=>{if(j.preventDefault(),!j.target.date.value)w.error("Select required dates",{duration:1e3}),j.target?.date?.focus(),l("textDanger");else{const P=new FormData(j.target);p(!0);try{await b(Jc,P)}finally{p(!1)}j.target.reset(),d(I=>({...I,date:te()})),s("")}},E=j=>{g(j)},{data:F}=H(t?[ql,t]:null,([j,P])=>K(j,P)),{data:q}=H(t?[zl,t]:null,([j,P])=>K(j,P)),T=i.useMemo(()=>Wi(F),[F]),U=i.useMemo(()=>Wi(q),[q]);return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Add Expense"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:S,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Expense Head",options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Vendor",options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",name:"date",status:r===""?"":"error",classnme:r,onChange:()=>l("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(z,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(Q,{label:"Payment Mode",options:Ey,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(v,{children:e.jsx(lt,{name:"note",label:"Description",rows:3})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(v,{children:[e.jsx(n.Upload,{action:`${Ke()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${jo(t)}/branch/expense`},headers:{Authorization:t},maxCount:1,onChange:j=>{if(j.file.status==="removed"&&s(""),j.file.status==="done"){const P=j.file.response?.data??j.file.response?.file??"";s(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:a||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:y?"Saving...":"Save",color:"primary",disabled:y})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:C,data:{newData:R,columns:O,columnstype:"antd",action:!0,Loading:f,ActionView:D,error:x,editDesign:e.jsx(Py,{data:{handleUpdate:h,token:t}}),deleteTodoMutation:_,open:c,DrawerUpdate:E}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const Fy=[{label:"Paid to",key:"vendor_name"},{label:"Address",key:"address"},{label:"GST Number",key:"gst"},{label:"Bussiness Name",key:"business_name"}],Uy=[{label:"Date",key:"date"},{label:"Voucher Number",key:"voucher_number"},{label:"Payment Mode",key:"payment_mode"}];function Ny({onClick:t}){return e.jsx(n.Button,{type:"primary",icon:e.jsx(ee.PrinterOutlined,{}),onClick:t,children:"Print"})}function By({data:t}){const a=i.useMemo(()=>{if(!t)return null;if(Array.isArray(t))return t[0];const s=t?.data?.data??t?.data??t??{};return Array.isArray(s)?s[0]:s},[t]);return e.jsx("div",{style:{width:"100%"},children:e.jsxs("div",{style:{border:"1px solid ",margin:"5px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",flexDirection:"column",justifyContent:"center",borderBottom:"1px solid black",fontWeight:"bold",padding:"10px",backgroundColor:"#dfdfdf",fontSize:"18px"},children:"Expense Voucher"}),e.jsx("div",{style:{width:"100%",display:"flex",justifyContent:"center",borderBottom:"1px solid black"},children:e.jsx("div",{style:{width:"90%"},children:e.jsx(It,{})})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(n.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(n.Col,{xs:12,style:{borderRight:"1px solid black",display:"flex",alignItems:"flex-start",flexDirection:"column"},children:Fy.map((s,r)=>e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("span",{style:{fontWeight:"bold"},children:s.label}),":"," ",a?.[s.key]]},`vendor${r}`))}),e.jsx(n.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:Uy.map((s,r)=>e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("span",{style:{fontWeight:"bold"},children:s.label}),":"," ",a?.[s.key]]},`payment${r}`))})]})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(n.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(n.Col,{xs:12,style:{borderRight:"1px solid black",display:"flex",alignItems:"flex-start",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:"Description"}),":"," ",a?.note]})}),e.jsx(n.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsx("div",{children:e.jsx("span",{style:{fontWeight:"bold"},children:"Amount"})})})]})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(n.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(n.Col,{xs:12,style:{borderRight:"1px solid black",display:"flex",alignItems:"flex-start",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:a?.name})," "]})}),e.jsx(n.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsx("div",{children:a?.amount})})]})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(n.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(n.Col,{xs:12,style:{paddingRight:4,borderRight:"1px solid black",display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:"Total"})," "]})}),e.jsx(n.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:a?.amount})," "]})})]})}),e.jsx("div",{style:{width:"100%",height:"75px",display:"flex",alignItems:"flex-end"},children:e.jsxs(n.Row,{style:{paddingLeft:4,paddingRight:4},justify:"flex-end",align:"flex-end",children:[e.jsx(n.Col,{xs:4,style:{borderTop:"1px solid gray",display:"flex",justifyContent:"center"},children:"Approved by"}),e.jsx(n.Col,{xs:1}),e.jsx(n.Col,{xs:4,style:{borderTop:"1px solid gray",display:"flex",justifyContent:"flex-end"},children:"Signature"})]})})]})})}function Ly({token:t}){const a=i.useMemo(()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("id")??null,[]),s=i.useRef(null),r=ea.useReactToPrint({content:()=>s.current}),{isLoading:l,data:o,error:d}=H(t&&a?[su,a,t]:null,([c,g,y])=>K(`${c}?id=${g}`,y));return e.jsx(v,{pt:4,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsx("div",{style:{width:"75%"},className:"container",children:e.jsx("div",{className:"row",children:e.jsx("div",{className:"col-lg-12",children:e.jsxs("div",{className:"card",ref:s,children:[e.jsx("div",{style:{width:"100%",display:"flex"},children:l?e.jsx("div",{style:{padding:40,textAlign:"center"},children:e.jsx(n.Spin,{tip:"Loading..."})}):d?e.jsx("div",{style:{padding:40,textAlign:"center"},children:"Error loading data"}):o?.Status==="Success"?e.jsx(By,{data:o}):e.jsx("div",{style:{padding:40,textAlign:"center"},children:"No Data Found"})}),e.jsxs("div",{className:"d-print-none mt-4",children:[e.jsx("div",{className:"float-end",children:e.jsx(Ny,{onClick:r})}),e.jsx("div",{className:"float-end",style:{marginRight:"2%"},children:e.jsx(n.Button,{type:"text",onClick:()=>window.history.back(),children:"Back"})})]})]})})})})})})})}const Hi={width:"100%",height:40};function qy({token:t}){const[a,s]=i.useState(null),[r,l]=i.useState(null),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(D,_)=>{A({...m,page:D,rowsPerPage:parseInt(_,10)})},{isLoading:b,error:f,data:x,mutate:R}=H(t&&o?[o,t,m.page,m.rowsPerPage]:null,([D,_,u,h])=>K(`${D}page=${u}&per_page=${h}`,_)),k=i.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Expense Category",selector:"exp_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),O=()=>{if(!a){w.error("Select required dates",{duration:1e3}),g("textDanger");return}if(!r){w.error("Select required dates",{duration:1e3}),p("textDanger");return}const D=a.format("YYYY-MM-DD"),_=r.format("YYYY-MM-DD");d(`${iu}?from_date=${D}&to_date=${_}&`),A(u=>({...u,page:1}))};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Search Expense"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(n.DatePicker,{value:a,onChange:D=>{s(D),g("")},style:Hi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(n.DatePicker,{value:r,onChange:D=>{l(D),p("")},style:Hi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:O})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:C,data:{newData:x,columns:k,action:!1,Loading:b,error:f,pageController:m}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function zy({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Tt),{isLoading:l,data:o}=H(s&&r?[`${ru}?id=${r}`,s]:null,([C,b])=>K(C,b)),d=i.useMemo(()=>{if(Array.isArray(o))return o[0];const C=o?.data?.data??o?.data??o??{};return Array.isArray(C)?C[0]:C??{}},[o]),[c,g]=i.useState({expensehead:"",description:""}),[y,p]=i.useState(!1);i.useEffect(()=>{d&&g({expensehead:d?.exp_category||d?.expensehead||"",description:d?.description||""})},[d]);const m=(C,b)=>{g(f=>({...f,[C]:b}))},A=async C=>{C.preventDefault(),p(!0);try{await a(C)}finally{p(!1)}};return l?e.jsx(v,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(n.Spin,{tip:"Loading..."})}):e.jsxs(v,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:A,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(v,{children:[e.jsx(z,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(z,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:c.expensehead,onChange:C=>m("expensehead",C.target.value)})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:C=>m("description",C.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:y?"Saving...":"Submit",color:"primary",disabled:y})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function Yy({token:t}){const[a,s]=i.useState({expensehead:"",description:""}),[r,l]=i.useState(!1),[o,d]=i.useState(!1),[c,g]=i.useState({page:1,rowsPerPage:10}),y=(u,h)=>{g({...c,page:u,rowsPerPage:parseInt(h,10)})},p=async(u,h)=>{try{await b(Ne(u,h,t),Ge(h)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},{isLoading:m,error:A,data:C,mutate:b}=H(t?[Zc,t,c.page,c.rowsPerPage]:null,([u,h,S,E])=>K(`${u}?page=${S}&per_page=${E}`,h)),f=i.useMemo(()=>[{id:"1",name:"Name",selector:"exp_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],R=async u=>{try{await b(He(au,u,t),ze(u)),w.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{w.error("Failed to delete the item.",{duration:1e3})}},k=async(u,h)=>{try{await b(We(u,h,t)),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{w.error("Failed to update the item.",{duration:1e3})}},O=async u=>{u.preventDefault();const h=new FormData(u.target);await k(tu,h),_(!1)},D=async u=>{u.preventDefault(),d(!0);try{await p(eu,new FormData(u.target)),s({expensehead:"",description:""})}finally{d(!1)}},_=u=>{l(u)};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:5,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head"})}),e.jsx(v,{p:3,children:e.jsx("form",{onSubmit:D,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:a.expensehead,onChange:u=>s(h=>({...h,expensehead:u.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(z,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:u=>s(h=>({...h,description:u.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:o?"Saving...":"Save",color:"primary",disabled:o})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,md:19,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:y,data:{newData:C,columns:f,action:!0,Loading:m,ActionView:x,error:A,editDesign:e.jsx(zy,{data:{handleUpdate:O,token:t}}),deleteTodoMutation:R,open:r,DrawerUpdate:_}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function Vy({token:t}){const[a,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState(0),[y,p]=i.useState(""),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(E,F)=>{A({...m,page:E,rowsPerPage:parseInt(F,10)})},{isLoading:b,error:f,data:x,mutate:R}=H(t&&y?[y,t,m.page,m.rowsPerPage]:null,([E,F,q,T])=>K(`${E}page=${q}&per_page=${T}`,F)),{data:k}=H(t?[tn,t]:null,([E,F])=>K(E,F)),{data:O}=H(t&&a?[`${an}?class_id=${a}`,t]:null,([E,F])=>K(E,F)),D=i.useMemo(()=>k?Array.isArray(k)?k:Array.isArray(k?.data)?k.data:[]:[],[k]),_=i.useMemo(()=>O?Array.isArray(O)?O:Array.isArray(O?.data)?O.data:[]:[],[O]),u=i.useMemo(()=>[{id:"1",name:"First Name",selector:"firstname",sortable:!0},{id:"2",name:"Last Name",selector:"lastname",sortable:!0},{id:"3",name:"Class",selector:"class",sortable:!0},{id:"4",name:"Section",selector:"section",sortable:!0},{id:"5",name:"ID",selector:"username",sortable:!0},{id:"6",name:"Password",selector:"password",sortable:!0}],[]),h=E=>{s(E?.value||""),l(""),g(F=>F+1)},S=E=>{if(E.preventDefault(),!a){w.error("Please select class",{duration:1e3});return}if(!r){w.error("Please select section",{duration:1e3});return}const F=`${lu}?class_id=${a}&section_id=${r}&keyword=${o||""}&`;p(F),A(q=>({...q,page:1}))};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Student Login Credential"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:D.find(E=>String(E.value)===String(a))??null,onChange:h})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:_.find(E=>String(E.value)===String(r))??null,onChange:E=>l(E?.value||"")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(z,{name:"keyword",type:"text",label:"Search By Keyword",value:o,onChange:E=>d(E.target.value)})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:S})})]})})]})}),y&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:C,data:{newData:x,columns:u,action:!1,Loading:b,error:f,pageController:m}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function Wy({token:t}){const[a,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState(0),[y,p]=i.useState(Yl),[m,A]=i.useState(!1),[C,b]=i.useState(null);console.log("Selected Student ID:",m);const[f,x]=i.useState({page:1,rowsPerPage:10}),R=(P,I)=>{x({...f,page:P,rowsPerPage:parseInt(I,10)})},{isLoading:k,error:O,data:D,mutate:_}=H(t&&y?[y,t,f.page,f.rowsPerPage]:null,([P,I,N,V])=>K(`${P}page=${N}&per_page=${V}`,I)),{data:u}=H(t?[tn,t]:null,([P,I])=>K(P,I)),{data:h}=H(t&&a?[`${an}?class_id=${a}`,t]:null,([P,I])=>K(P,I)),S=i.useMemo(()=>u?Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]:[],[u]),E=i.useMemo(()=>h?Array.isArray(h)?h:Array.isArray(h?.data)?h.data:[]:[],[h]),F=i.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Medicine",selector:"Medical",sortable:!1,render:(P,I)=>e.jsx(n.Button,{type:"primary",size:"small",onClick:()=>{b(I.id),A(!0)},children:"Medical"})}],[]),q=P=>{s(P?.value||""),l(""),g(I=>I+1)},T=P=>{if(P.preventDefault(),!a||!r){w.error("Please select class and section",{duration:1e3});return}const I=`${Wl}?cID=${a}&sID=${r}&page=${f.page}&per_page=${f.rowsPerPage}&`;p(I),x(N=>({...N,page:1}))},U=P=>{P.preventDefault();const I=P.target.searchField?.value||"";d(I);const N=`${Vl}?key=${I}&page=${f.page}&per_page=${f.rowsPerPage}&`;p(N),x(V=>({...V,page:1}))},j=async P=>{P.preventDefault();const I=new FormData(P.target),N=ou;try{await _(addData(N,I,t)),w.success("Medicine added successfully",{duration:1e3}),P.target.reset()}catch{w.error("Failed to add medicine",{duration:1e3})}};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Medical Report"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:T,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:S.find(P=>String(P.value)===String(a))??null,onChange:q})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:E.find(P=>String(P.value)===String(r))??null,onChange:P=>l(P?.value||"")})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:U,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:16,children:e.jsx(z,{name:"searchField",type:"text",label:"Search By Keyword",value:o,onChange:P=>d(P.target.value)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:R,data:{newData:D,columns:F,action:!1,Loading:k,error:O,pageController:f}})})]})})]}),e.jsx(n.Drawer,{title:"Medical Report",placement:"right",width:600,open:m,footer:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(ne,{type:"button",value:"Close",color:"default"})})}),children:e.jsx(Hy,{studentId:C,token:t,onAddMedicine:j})}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function Hy({studentId:t,token:a,onAddMedicine:s}){const{data:r}=H(a&&t?[`${Hl}?id=${t}`,a]:null,([g,y])=>K(g,y)),{data:l}=H(a&&t?[`${du}?student_id=${t}`,a]:null,([g,y])=>K(g,y)),o=r?.studentBasicDetails?.[0];let d=[];Array.isArray(l?.data)?d=l.data:Array.isArray(l)&&(d=l);const c=[{title:"Medicine",dataIndex:"medicine",key:"medicine"},{title:"Notes",dataIndex:"notes",key:"notes"},{title:"Date",dataIndex:"date_time",key:"date_time"}];return e.jsxs(v,{children:[o&&e.jsxs(v,{mb:3,children:[e.jsxs(pe,{level:4,children:["Name: ",o?.firstname," ",o?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",o?.class," (",o?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",o?.admission_no]})]}),e.jsx(pe,{level:5,style:{marginBottom:8},children:"Add Medicine"}),e.jsx("form",{onSubmit:s,style:{marginBottom:24},children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(v,{children:[e.jsx(z,{name:"medicine",type:"text",label:"Medicine Name",required:!0}),e.jsx("input",{name:"student_id",type:"hidden",value:t||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(lt,{name:"notes",label:"Note",rows:3})})}),e.jsx(n.Col,{xs:24,children:e.jsx(v,{children:e.jsx(Ue,{format:"YYYY-MM-DD HH:mm",Desplay:"Date",name:"date_time",defaultValue:te()})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})})})})]})}),e.jsx(pe,{level:5,style:{marginBottom:8},children:"Previous Medicine"}),e.jsx(n.Table,{size:"small",dataSource:d,pagination:!1,columns:c})]})}const{Group:Ki}=n.Checkbox;function Ky({token:t}){const[a,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState(0),[y,p]=i.useState(Yl),[m,A]=i.useState(!1),[C,b]=i.useState(null),[f,x]=i.useState({page:1,rowsPerPage:10}),R=(N,V)=>{x({...f,page:N,rowsPerPage:parseInt(V,10)})},{isLoading:k,error:O,data:D,mutate:_}=H(t&&y?[y,t,f.page,f.rowsPerPage]:null,([N,V,W,B])=>K(`${N}page=${W}&per_page=${B}`,V)),{data:u}=H(t?[tn,t]:null,([N,V])=>K(N,V)),{data:h}=H(t&&a?[`${an}?class_id=${a}`,t]:null,([N,V])=>K(N,V)),S=i.useMemo(()=>u?Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]:[],[u]),E=i.useMemo(()=>h?Array.isArray(h)?h:Array.isArray(h?.data)?h.data:[]:[],[h]),F=i.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Assign Subject",selector:"Assign",sortable:!1,render:(N,V)=>e.jsx(n.Button,{type:"primary",size:"small",onClick:()=>{b(V.id),A(!0)},children:"Assign"})}],[]),q=N=>{s(N?.value||""),l(""),g(V=>V+1)},T=N=>{if(N.preventDefault(),!a||!r){w.error("Please select class and section",{duration:1e3});return}const V=`${Wl}?cID=${a}&sID=${r}&page=${f.page}&per_page=${f.rowsPerPage}&`;p(V),x(W=>({...W,page:1}))},U=N=>{N.preventDefault();const V=N.target.searchField?.value||"";d(V);const W=`${Vl}?key=${V}&page=${f.page}&per_page=${f.rowsPerPage}&`;p(W),x(B=>({...B,page:1}))},j=async N=>{N.preventDefault();const V=new FormData(N.target),W=uu;try{await _(We(W,V,t)),w.success("Subject updated successfully",{duration:1e3}),N.target.reset(),A(!1)}catch{w.error("Failed to update subject",{duration:1e3})}},P=async N=>{N.preventDefault();const V=new FormData(N.target),W=Js;try{await _(We(W,V,t)),w.success("Extra curricular updated successfully",{duration:1e3}),N.target.reset(),A(!1)}catch{w.error("Failed to update extra curricular",{duration:1e3})}},I=N=>{A(N)};return e.jsxs(v,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Assign Student Subject"})}),e.jsx(v,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:T,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:S.find(N=>String(N.value)===String(a))??null,onChange:q})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:E.find(N=>String(N.value)===String(r))??null,onChange:N=>l(N?.value||"")})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:U,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:16,children:e.jsx(z,{name:"searchField",type:"text",label:"Search By Keyword",value:o,onChange:N=>d(N.target.value)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(v,{pt:3,children:e.jsx(Ie,{parentCallback:R,data:{newData:D,columns:F,action:!1,Loading:k,error:O,pageController:f}})})]})})]}),m&&e.jsx(Gy,{open:m,DrawerUpdate:I,studentId:C,token:t,onUpdate:j,onUpdate2:P}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function Gy({open:t,DrawerUpdate:a,studentId:s,token:r,onUpdate:l,onUpdate2:o}){const[d,c]=i.useState([]),[g,y]=i.useState([]),[p,m]=i.useState([]),[A,C]=i.useState(!1),[b,f]=i.useState([]),[x,R]=i.useState([]),[k,O]=i.useState([]),{trigger:D}=rt(Hl,async(F,{arg:q})=>await K(`${F}?id=${q.id}`,r)),{trigger:_}=rt(Js,async()=>await K(`${Js}?student_id=${s}`,r)),{trigger:u}=rt(cu,async(F,{arg:q})=>await K(`${F}?id=${q.id}`,r));i.useEffect(()=>{(async()=>{if(!s)return;C(!0);const q=await D({id:s});q?.studentBasicDetails?.[0];const T=await _(),U=await u({id:s});c(q),m(U),q&&y(T),C(!1)})()},[s,D,_,u]);const h=F=>{R(F);const q=d?.data?.filter(T=>!F.includes(T.value));f(JSON.stringify(q))},S=F=>{O(F)},E=d?.studentBasicDetails?.[0];return!A&&s?e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsxs(v,{p:3,children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Edit Assigned Subjects"})}),e.jsxs(v,{p:3,children:[E&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs(pe,{level:4,children:["Name: ",E?.firstname," ",E?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",E?.class," (",E?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",E?.admission_no]})]}),e.jsx("form",{onSubmit:l,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsxs(n.Col,{xs:24,children:[e.jsx(pe,{level:5,children:"Subjects"}),e.jsx(Ki,{options:d?.data?.map(F=>({label:F.label||F.name,value:F.value})),value:x,onChange:h,style:{display:"grid",gap:8}})]}),e.jsxs(n.Col,{xs:24,children:[e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0}),e.jsx("input",{name:"subjectUncheck[]",type:"hidden",value:b,readOnly:!0})]}),d?.data?.length===0?e.jsx(n.Col,{xs:24,children:e.jsx("span",{style:{cursor:"pointer",fontSize:15,color:"blue",textDecoration:"underline"},children:"Please Assign Subject"})}):e.jsx(n.Col,{xs:24,className:"buttonCoustom",children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Update",color:"primary"})})})})})]})}),g?.data?.length>0&&e.jsx("form",{onSubmit:o,style:{marginTop:24},children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsxs(n.Col,{xs:24,children:[e.jsx(pe,{level:5,children:"Extra Curricular Activities"}),e.jsx(Ki,{options:g?.data?.map(F=>({label:F.label||F.name,value:F.value})),value:k,onChange:S,style:{display:"grid",gap:8}})]}),e.jsx(n.Col,{xs:24,children:e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0})}),e.jsx(n.Col,{xs:24,className:"buttonCoustom",children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:"Update",color:"primary"})})})})})]})})]})]})}):e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsx(v,{p:3,children:e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})})})})}function Jy({token:t}){const[a,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(0),[c,g]=i.useState(null),[y,p]=i.useState(!1),{data:m}=H(t?[tn,t]:null,([u,h])=>K(u,h)),{data:A}=H(t&&a?[`${an}?class_id=${a}`,t]:null,([u,h])=>K(u,h)),{data:C}=H(t?[mu,t]:null,([u,h])=>K(`${u}?page=1&per_page=10`,h)),b=i.useMemo(()=>m?Array.isArray(m)?m:Array.isArray(m?.data)?m.data:[]:[],[m]),f=i.useMemo(()=>A?Array.isArray(A)?A:Array.isArray(A?.data)?A.data:[]:[],[A]),x=i.useMemo(()=>[{id:"1",name:"Category Id",selector:"id",sortable:!0},{id:"2",name:"Category",selector:"category",sortable:!0}],[]),R=u=>{s(u?.value||""),l(""),d(h=>h+1)},k=u=>{l(u?.value||"")},O=()=>{const u=document.createElement("a");u.href="/sample_student.xlsx",u.download="sample_student.xlsx",u.click()},D=u=>{u.fileList.length>0?g(u.fileList[0].originFileObj):g(null)},_=async u=>{if(u.preventDefault(),!a){w.error("Please select class",{duration:1e3});return}if(!r){w.error("Please select section",{duration:1e3});return}if(!c){w.error("Please select file",{duration:1e3});return}p(!0);const h=new FormData;h.append("file",c),h.append("class_id",a),h.append("section_id",r);try{const S=await Sc(pu,h,t);S?.Status==="Failed"?w.error(S?.msg||"Upload failed",{duration:2e3}):(w.success(S?.msg||"Upload successful",{duration:2e3}),g(null),s(""),l(""))}catch(S){w.error(S?.response?.data?.msg||"Upload failed",{duration:2e3})}finally{p(!1)}};return e.jsx(v,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(v,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(pe,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Students"})}),e.jsxs(v,{p:3,children:[e.jsx(n.Row,{justify:"end",style:{marginBottom:16},children:e.jsx(n.Col,{children:e.jsx(n.Button,{type:"primary",icon:e.jsx(ee.DownloadOutlined,{}),onClick:O,style:{background:"#368fed"},children:"Download Sample Import File"})})}),e.jsxs("div",{style:{marginBottom:16,padding:16,background:"#f5f5f5",borderRadius:8},children:[e.jsx(pe,{level:5,style:{marginBottom:8},children:"Information"}),e.jsx("div",{children:"1. Your Excel data should be in the format below. The first line of your Excel file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("div",{children:"2. If the column you are trying to import is date make sure that is formatted in format Y-m-d (2024-01-10)."}),e.jsx("div",{children:"3. Duplicate Admission Number, ec_no, aadhaar_number, (unique) rows will not be imported."}),e.jsx("div",{children:"4. For student Gender use Male, Female value."}),e.jsx("div",{children:"5. For student Blood Group use A+, A-, B+, B-, O+, O-, AB+, AB- value."}),e.jsx("div",{children:"6. * Imported field are admission_no, ec_no, firstname, lastname, roll_no, guardian_phone, aadhaar_number, category_id"})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx(pe,{level:5,style:{marginBottom:8},children:"Category Table"}),e.jsx(Ie,{parentCallback:()=>{},data:{newData:C,columns:x,action:!1,Loading:!1,error:null,pageController:{page:1,rowsPerPage:10}}})]}),e.jsx("form",{onSubmit:_,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{label:"Class",options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:b.find(u=>String(u.value)===String(a))??null,onChange:R})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(v,{children:e.jsx(Q,{label:"Section",options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:f.find(u=>String(u.value)===String(r))??null,onChange:k},`section-${o}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsxs(v,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"File"}),e.jsx(n.Upload,{beforeUpload:()=>!1,onChange:D,maxCount:1,accept:".xlsx,.xls",children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),style:{width:"100%"},children:c?c.name:"Select Excel File"})})]})}),e.jsx(n.Col,{xs:24,md:6,style:{display:"flex",alignItems:"flex-end"},children:e.jsx(v,{children:e.jsx(ne,{type:"submit",value:y?"Processing...":"Save",color:"primary",loading:y})})})]})})]})]})})})})}function Qy(){return null}const cs=t=>t??localStorage.getItem("authToken")??"",So=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},vo=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",Re={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",uploadFile:"api/SuperAdmin/uploadFile"},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"}},Xy=()=>So(bt(),Re.uploadNotes),Zy=()=>So(bt(),Re.syllabus.uploadFile),eg=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const l=t.includes("?")?"&":"?",o=`${t}${l}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(o,cs(r))},At=async(t,a,s,{includeSession:r=!1}={})=>{const l=a instanceof FormData?a:new FormData;return r&&!l.has("session_id")&&l.append("session_id",vo()),Ne(t,l,cs(s))},zt=async(t,a,s,{includeSession:r=!1}={})=>{const l=a instanceof FormData?a:new FormData;return r&&!l.has("session_id")&&l.append("session_id",vo()),We(t,l,cs(s))},Yt=async(t,a,s)=>He(t,a,cs(s)),Wn=Re.master.sections,on=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>H(r&&t?[t,a,s,r]:null,([o,d,c,g])=>eg({baseUrl:o,page:d,perPage:c},g)),tg=({token:t,page:a=1,perPage:s=10})=>on({token:t,baseUrl:Wn.table,page:a,perPage:s}),ag=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function ng({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=n.Form.useForm(),{data:g,isLoading:y,mutate:p}=tg({token:t,page:a.page,perPage:a.perPage}),m=i.useMemo(()=>ag(g),[g]),A=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??m.length??0,[g,m]),C=async k=>{k.preventDefault();const O=new FormData(k.target);try{await At(Wn.add,O,t),w.success("Success! Added new item.",{duration:1e3}),k.target.reset(),p()}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed to add the new item.",{duration:1500})}},b=async k=>{try{await Yt(Wn.remove,k,t),w.success("Success! Deleted item.",{duration:1e3}),p()}catch(O){w.error(O?.response?.data?.msg??O?.message??"Failed to delete the item.",{duration:1500})}},f=k=>{d(k),l(!0),c.setFieldsValue({section:k?.section??""})},x=async k=>{const O=new FormData;O.append("id",String(o?.id??"")),O.append("section",k.section??"");try{await zt(Wn.edit,O,t),w.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),p()}catch(D){w.error(D?.response?.data?.msg??D?.message??"Failed to update the item.",{duration:1500})}},R=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(k,O)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(O)}),e.jsx(n.Popconfirm,{title:"Delete this section?",onConfirm:()=>b(O?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Section",open:r,onClose:()=>{l(!1),d(null)},width:420,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:x,children:[e.jsx(n.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(n.Input,{placeholder:"Section Name"})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),children:e.jsx("form",{onSubmit:C,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(ne,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(n.Space,{}),children:e.jsx(n.Table,{rowKey:k=>k.id,columns:R,dataSource:m,loading:y,pagination:{current:a.page,pageSize:a.perPage,total:A,showSizeChanger:!0,onChange:(k,O)=>s({page:k,perPage:O})}})})]})}function sg({token:t}){return e.jsx(ng,{token:t})}const La=Re.master.classes,rg=({token:t,page:a=1,perPage:s=10})=>on({token:t,baseUrl:La.table,page:a,perPage:s}),ig=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},lg=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function og({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:y}=H(t?[Re.master.sections.list,t]:null,([S,E])=>K(S,E)),p=i.useMemo(()=>lg(y),[y]),m=i.useMemo(()=>p.map(S=>({label:S.label??S.section??String(S.value??""),value:String(S.value??S.id??"")})),[p]),{data:A,isLoading:C,mutate:b}=rg({token:t,page:a.page,perPage:a.perPage}),f=i.useMemo(()=>ig(A),[A]),x=i.useMemo(()=>A?.pagination?.total_rows??A?.pagination?.total??f.length??0,[A,f]),{data:R}=H(t&&o?[`${La.show}?id=${encodeURIComponent(String(o))}`,t]:null,([S,E])=>K(S,E)),k=i.useMemo(()=>{const S=R?.data??R;return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:S?[S]:[]},[R]),O=S=>{const E=S?.id??S?.class_id;E&&(d(E),l(!0))};i.useEffect(()=>{if(!r||!k.length)return;const S=k[0],E=k.map(T=>T?.section_id??T?.fk_sectionId??T?.sectionId??T?.section).filter(T=>T!=null&&String(T).trim()!=="").map(T=>String(T)),F=Array.isArray(S?.section_ids)?S.section_ids.map(T=>String(T)):typeof S?.section_ids=="string"?S.section_ids.split(",").map(T=>T.trim()).filter(Boolean):Array.isArray(S?.section)?S.section.map(T=>String(T)):[],q=E.length?E:F;g.setFieldsValue({name:S?.class??S?.name??"",section:q})},[r,k,g]);const D=async S=>{const E=new FormData;E.append("name",S.name??""),(S.section??[]).forEach(F=>E.append("section[]",String(F)));try{await At(La.add,E,t),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),b()}catch(F){w.error(F?.response?.data?.msg??F?.message??"Failed to add the new item.",{duration:1500})}},_=async S=>{const E=new FormData;E.append("id",String(o??"")),E.append("name",S.name??""),(S.section??[]).forEach(F=>E.append("section[]",String(F)));try{await zt(La.edit,E,t),w.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),b()}catch(F){w.error(F?.response?.data?.msg??F?.message??"Failed to update the item.",{duration:1500})}},u=async S=>{try{await Yt(La.remove,S,t),w.success("Success! Deleted item.",{duration:1e3}),b()}catch(E){w.error(E?.response?.data?.msg??E?.message??"Failed to delete the item.",{duration:1500})}},h=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(S,E)=>S??E?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:S=>S??""},{title:"Actions",key:"actions",width:120,render:(S,E)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>O(E)}),e.jsx(n.Popconfirm,{title:"Delete this class?",onConfirm:()=>u(E?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Class",open:r,onClose:()=>{l(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:_,children:[e.jsx(n.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:m})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:D,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:m})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(n.Table,{rowKey:S=>S.id,columns:h,dataSource:f,loading:C,pagination:{current:a.page,pageSize:a.perPage,total:x,showSizeChanger:!0,onChange:(S,E)=>s({page:S,perPage:E})}})})]})}function dg({token:t}){return e.jsx(og,{token:t})}const qa=Re.master.subjects,cg=({token:t,page:a=1,perPage:s=10})=>on({token:t,baseUrl:qa.table,page:a,perPage:s}),ug=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Gi=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],Ji=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function pg({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:y,isLoading:p,mutate:m}=cg({token:t,page:a.page,perPage:a.perPage}),A=i.useMemo(()=>ug(y),[y]),C=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??A.length??0,[y,A]),{data:b,isLoading:f}=H(t&&o?[`${qa.show}?id=${encodeURIComponent(String(o))}`,t]:null,([u,h])=>K(u,h)),x=i.useMemo(()=>{const u=b?.data??b;return Array.isArray(u)?u[0]:u??null},[b]);i.useEffect(()=>{if(!r||!x)return;const u=[];["yes","1","true"].includes(String(x?.is_practical??"").toLowerCase())&&u.push("Practical"),["yes","1","true"].includes(String(x?.is_theory??"").toLowerCase())&&u.push("Theory"),g.setFieldsValue({name:x?.name??"",subject_type:x?.subject_type??x?.type??"",type:"",subject_types:u,code:x?.code??""})},[r,x,g]);const R=async u=>{const h=u?.type??u?.subject_type??"",S=Array.isArray(u?.subject_types)?u.subject_types:[],E={name:u?.name??"",subject_type:h,type:h,subject_types:S,code:u?.code??"",is_practical:S.includes("Practical")?"yes":"no",is_theory:S.includes("Theory")?"yes":"no"};try{await Ne(qa.add,E,t),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),m()}catch(F){w.error(F?.response?.data?.msg??F?.message??"Failed to add the new item.",{duration:1500})}},k=async u=>{const h=new FormData,S=u?.type??u?.subject_type??"",E=Array.isArray(u?.subject_types)?u.subject_types:[];h.append("id",String(o??"")),h.append("name",u.name??""),h.append("subject_type",u.subject_type??""),h.append("subject_type",S),h.append("type",S),h.append("code",u.code??""),h.append("is_practical",E.includes("Practical")?"yes":"no"),h.append("is_theory",E.includes("Theory")?"yes":"no");try{await zt(qa.edit,h,t),w.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),m()}catch(F){w.error(F?.response?.data?.msg??F?.message??"Failed to update the item.",{duration:1500})}},O=async u=>{try{await Yt(qa.remove,u,t),w.success("Success! Deleted item.",{duration:1e3}),m()}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to delete the item.",{duration:1500})}},D=u=>{const h=u?.id;h&&(d(h),l(!0))},_=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:(u,h)=>{const S=[],E=h?.subject_types;Array.isArray(E)?E.forEach(j=>{const P=String(j??"").trim();if(!P)return;const I=P.toLowerCase();["yes","1","true"].includes(I)||S.push(P)}):typeof E=="string"&&E.split(",").map(j=>j.trim()).filter(Boolean).forEach(j=>{const P=j.toLowerCase();["yes","1","true"].includes(P)||S.push(j)});const F=["yes","1","true"].includes(String(h?.is_practical??"").toLowerCase()),q=["yes","1","true"].includes(String(h?.is_theory??"").toLowerCase());F&&S.push("Practical"),q&&S.push("Theory");const T=S.map(j=>String(j??"").trim()).filter(Boolean).map(j=>j.toLowerCase()==="practical"?"Practical":j.toLowerCase()==="theory"?"Theory":j),U=Array.from(new Set(T));return U.length?U.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(u,h)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>D(h)}),e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>O(h?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Subject",open:r,onClose:()=>{l(!1),d(null)},width:560,children:f?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})}):e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:k,children:[e.jsx(n.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(z,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(n.Radio.Group,{options:Ji})}),e.jsx(n.Form.Item,{label:"Subject Type",name:"subject_types",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:Gi})}),e.jsx(n.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(z,{placeholder:"Subject Code"})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:R,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(z,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(n.Radio.Group,{options:Ji})}),e.jsx(n.Form.Item,{name:"subject_types",label:"Subject Type",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:Gi})}),e.jsx(n.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(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(n.Table,{rowKey:u=>u.id,columns:_,dataSource:A,loading:p,pagination:{current:a.page,pageSize:a.perPage,total:C,showSizeChanger:!0,onChange:(u,h)=>s({page:u,perPage:h})}})})]})}function mg({token:t}){return e.jsx(pg,{token:t})}const za=Re.master.holidays,hg=({token:t,page:a=1,perPage:s=10})=>on({token:t,baseUrl:za.table,page:a,perPage:s}),fg=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Tn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function yg({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:y,isLoading:p,mutate:m}=hg({token:t,page:a.page,perPage:a.perPage}),A=i.useMemo(()=>fg(y),[y]),C=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??A.length??0,[y,A]),{data:b}=H(t&&o?[`${za.show}?id=${encodeURIComponent(String(o))}`,t]:null,([_,u])=>K(_,u)),f=i.useMemo(()=>{const _=b?.data??b;return Array.isArray(_)?_[0]:_??null},[b]);i.useEffect(()=>{r&&f&&g.setFieldsValue({title:f?.holiday_title??"",description:f?.holiday_description??"",from:f?.start_date?te(f.start_date):null,to:f?.end_date?te(f.end_date):null})},[r,f,g]);const x=async _=>{const u=new FormData;u.append("title",_.title??""),u.append("description",_.description??""),u.append("from",_.from?te(_.from).format("YYYY-MM-DD"):""),u.append("to",_.to?te(_.to).format("YYYY-MM-DD"):"");try{await At(za.add,u,t,{includeSession:!0}),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),m()}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to add the new item.",{duration:1500})}},R=async _=>{const u=new FormData;u.append("id",String(o??"")),u.append("title",_.title??""),u.append("description",_.description??""),u.append("from",_.from?te(_.from).format("YYYY-MM-DD"):""),u.append("to",_.to?te(_.to).format("YYYY-MM-DD"):"");try{await zt(za.edit,u,t,{includeSession:!0}),w.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),m()}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to update the item.",{duration:1500})}},k=async _=>{try{await Yt(za.remove,_,t),w.success("Success! Deleted item.",{duration:1e3}),m()}catch(u){w.error(u?.response?.data?.msg??u?.message??"Failed to delete the item.",{duration:1500})}},O=_=>{const u=_?.id;u&&(d(u),l(!0))},D=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:(_,u)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>O(u)}),e.jsx(n.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>k(u?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Holiday",open:r,onClose:()=>{l(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:R,children:[e.jsx(n.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(z,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(z,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:Tn})}),e.jsx(n.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:Tn})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(z,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(lt,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:Tn})}),e.jsx(n.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:Tn})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(n.Table,{rowKey:_=>_.id,columns:D,dataSource:A,loading:p,pagination:{current:a.page,pageSize:a.perPage,total:C,showSizeChanger:!0,onChange:(_,u)=>s({page:_,perPage:u})}})})]})}function gg({token:t}){return e.jsx(yg,{token:t})}const Hn=Re.assignSubjects,xg=({token:t,page:a=1,perPage:s=50})=>on({token:t,baseUrl:Hn.list,page:a,perPage:s}),Qi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],bg=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function jg({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,l]=i.useState(null),[o,d]=i.useState([]),[c,g]=i.useState(!1),[y,p]=i.useState(!1),[m,A]=i.useState(null),[C,b]=i.useState([]),{data:f}=H(t?[Re.master.classes.dropdown,t]:null,([j,P])=>K(j,P)),{data:x}=H(t?[Re.master.subjects.dropdown,t]:null,([j,P])=>K(j,P)),R=i.useMemo(()=>Qi(f),[f]),k=i.useMemo(()=>Qi(x),[x]),O=i.useMemo(()=>k.map(j=>({label:j.label??j.subject??String(j.value??""),value:j.value??j.id})),[k]),{data:D,isLoading:_,mutate:u}=xg({token:t,page:a.page,perPage:a.perPage}),h=i.useMemo(()=>bg(D),[D]),S=i.useMemo(()=>D?.pagination?.total_rows??D?.pagination?.total??h.length??0,[D,h]),{data:E}=H(t&&m?[`${Hn.editByClass}?class_id=${encodeURIComponent(String(m))}`,t]:null,([j,P])=>K(j,P));i.useEffect(()=>{if(!y)return;const j=E?.data??E,P=Array.isArray(j)?j:Array.isArray(j?.data)?j.data:[];b(P.map(I=>I.subject_id).filter(Boolean))},[y,E]);const F=async j=>{if(j.preventDefault(),!r?.value){w.error("Please select class",{duration:1200});return}if(!o.length){w.error("Please select subjects",{duration:1200});return}const P=new FormData;P.append("class_id",String(r.value)),o.forEach(I=>P.append("subject[]",String(I)));try{g(!0),await zt(Hn.assign,P,t),w.success("Success! Updated item.",{duration:1e3}),l(null),d([]),u()}catch(I){w.error(I?.response?.data?.msg??I?.message??"Failed to update the item.",{duration:1500})}finally{g(!1)}},q=j=>{j&&(A(j),p(!0))},T=async()=>{if(!m)return;if(!C.length){w.error("Please select subjects",{duration:1200});return}const j=new FormData;j.append("class_id",String(m)),C.forEach(P=>j.append("subject[]",String(P)));try{await zt(Hn.update,j,t),w.success("Success! Updated item.",{duration:1e3}),p(!1),A(null),u()}catch(P){w.error(P?.response?.data?.msg??P?.message??"Failed to update the item.",{duration:1500})}},U=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(j,P)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(P?.subject_name??j??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(j,P)=>e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>q(P?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Subjects",open:y,onClose:()=>{p(!1),A(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>p(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:T,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:R.find(j=>String(j.value)===String(m))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:O,value:C,onChange:b})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:j=>l(j??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:O,value:o,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(n.Table,{rowKey:j=>j.id,columns:U,dataSource:h,loading:_,pagination:{current:a.page,pageSize:a.perPage,total:S,showSizeChanger:!0,onChange:(j,P)=>s({page:j,perPage:P})}})})]})}function Sg({token:t}){return e.jsx(jg,{token:t})}const ha=Re.assignByClass,wo=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(typeof t?.data?.Status=="string"&&Array.isArray(t?.data?.data))return t.data.data;if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Ea=t=>wo(t),vg=t=>wo(t),$a=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function wg({token:t}){const[a,s]=i.useState(null),[r,l]=i.useState(null),[o,d]=i.useState(null),[c,g]=i.useState("No"),[y,p]=i.useState([]),[m,A]=i.useState([]),[C,b]=i.useState(null),[f,x]=i.useState(null),[R,k]=i.useState(!1),[O,D]=i.useState(""),{data:_}=H(t?[ha.teacherDropdown,t]:null,([oe,ie])=>K(oe,ie)),{data:u}=H(t?[Re.master.classes.dropdown,t]:null,([oe,ie])=>K(oe,ie)),{data:h}=H(t&&f?[f,t]:null,([oe,ie])=>K(oe,ie)),{data:S}=H(t&&C?[C,t]:null,([oe,ie])=>K(oe,ie)),E=i.useMemo(()=>Ea(_),[_]),F=i.useMemo(()=>Ea(u),[u]),q=i.useMemo(()=>Ea(h),[h]),T=i.useMemo(()=>Ea(S),[S]),{data:U}=H(t&&a&&r&&o?[`${ha.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(a))}&class_id=${encodeURIComponent(String(r))}&section_id=${encodeURIComponent(String(o))}`,t]:null,([oe,ie])=>K(oe,ie)),j=U?.data??U??null;i.useEffect(()=>{j&&(p(Array.isArray(j?.subject_ids)?j.subject_ids:[]),g(j?.isClassTeacher||"No"),A([]))},[j]);const{data:P}=H(t?[ha.classWithSection,t]:null,([oe,ie])=>K(oe,ie)),I=i.useMemo(()=>Ea(P),[P]),[N,V]=i.useState(null),[W,B]=i.useState({page:1,perPage:25});i.useEffect(()=>{N||I?.[0]&&V(`${I[0].class_id}val${I[0].section_id}`)},[I,N]);const $=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),M=i.useMemo(()=>{if(!N)return null;const[oe,ie]=String(N).split("val");if(!oe||!ie)return null;const Se=W.page??1,Ee=W.perPage??25;return`${ha.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(Se))}&per_page=${encodeURIComponent(String(Ee))}&session_id=${encodeURIComponent(String($))}&class_id=${encodeURIComponent(String(oe))}&section_id=${encodeURIComponent(String(ie))}`},[N,W.page,W.perPage,$]),{data:L,isLoading:Y,mutate:se}=H(t&&M?[M,t]:null,([oe,ie])=>K(oe,ie),{revalidateOnFocus:!1}),X=i.useMemo(()=>vg(L),[L]),G=i.useMemo(()=>{const oe=L?.pagination??L?.data?.pagination??L?.data?.data?.pagination;return oe?.total_rows??oe?.total??X.length??0},[L,X]),J=async oe=>{if(oe.preventDefault(),D(""),!a||!r||!o){w.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(y)||y.length===0){D("error"),w.error("Please Select Subject",{duration:1200});return}const ie=new FormData;ie.append("teacher_id",String(a)),ie.append("class_id",String(r)),ie.append("section_id",String(o)),ie.append("isClassTeacher",String(c??"No")),$a(y).forEach(Se=>ie.append("subject_ids[]",String(Se))),$a(m).forEach(Se=>ie.append("delete_subject[]",String(Se)));try{await At(ha.assignClassToTeacher,ie,t,{includeSession:!0}),w.success("Success! Added new item.",{duration:1e3}),D(""),se()}catch(Se){w.error(Se?.response?.data?.msg??Se?.message??"Failed to add the new item.",{duration:1500})}},re=async oe=>{try{await Yt(ha.deleteTeacherSub,oe,t),w.success("Success! Deleted item.",{duration:1e3}),se(),window.location.reload()}catch(ie){w.error(ie?.response?.data?.msg??ie?.message??"Failed to delete the item.",{duration:1500})}},de=oe=>{const ie=Array.isArray(oe?.child)?oe.child:[],Se=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Ee,Xe)=>e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>re(Xe?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(n.Table,{columns:Se,bordered:!0,size:"small",dataSource:ie,pagination:!1,rowKey:Ee=>Ee.id})})},Ce=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(oe,ie)=>e.jsxs("div",{children:[ie.teacher_name,ie.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],le=i.useMemo(()=>(I??[]).map(oe=>({label:oe.label??`${oe.class_name??""} ${oe.section_name??""}`.trim(),key:`${oe.class_id}val${oe.section_id}`,children:e.jsx(n.Table,{size:"small",columns:Ce,bordered:!0,dataSource:Array.isArray(X)?X:[],loading:Y,rowKey:ie=>ie.id,expandable:{expandedRowRender:de},pagination:{current:W.page,pageSize:W.perPage,total:G,showSizeChanger:!0,onChange:(ie,Se)=>B({page:ie,perPage:Se})}})})),[I,W.page,W.perPage,X,Y,G]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(320px, 380px) 1fr",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:J,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:E.find(oe=>String(oe.value)===String(a))??null,onChange:oe=>s(oe?.value??null)}),e.jsx(Q,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:F.find(oe=>String(oe.value)===String(r))??null,onChange:oe=>{const ie=oe?.value??null;l(ie),d(null),b(ie?`${Re.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(ie))}`:null),x(ie?`${Re.master.sections.byClass}?class_id=${encodeURIComponent(String(ie))}`:null),k(Se=>!Se)}}),e.jsx(Q,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:q.find(oe=>String(oe.value)===String(o))??null,onChange:oe=>d(oe?.value??null)},`section_${R}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const oe=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(Q,{style:{width:"100%"},options:oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:oe.find(ie=>String(ie.value)===String(c??"No"))??oe[1],onChange:ie=>g(ie?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(Q,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:T,value:(T??[]).filter(oe=>$a(y).some(ie=>String(ie)===String(oe.value))),onChange:(oe,ie)=>{const Ee=(Array.isArray(oe)?oe:[]).map(Oe=>Oe?.value).filter(Oe=>Oe!=null&&Oe!=="");p(Ee);const Xe=Array.isArray(j?.subject_ids)?j.subject_ids.map(String):[],be=ie?.removedValue?.value,ve=ie?.option?.value;(ie?.action==="remove-value"||ie?.action==="pop-value")&&be!=null&&Xe.includes(String(be))&&A(Oe=>Array.from(new Set([...$a(Oe).map(String),String(be)]))),ie?.action==="select-option"&&ve!=null&&Xe.includes(String(ve))&&A(Oe=>$a(Oe).filter(Ye=>String(Ye)!==String(ve)))}},`subjects_${R}`),O?e.jsx("div",{style:{color:"#ff4d4f",marginTop:6,fontSize:12},children:"Please select subject"}):null]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(n.Tabs,{activeKey:N??void 0,onChange:oe=>{V(oe),B(ie=>({...ie,page:1}))},items:le,type:"card",size:"small"})})]})]})}function _g({token:t}){return e.jsx(wg,{token:t})}const Fa=Re.timeGroup,Cg=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Nt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Rn(t){if(!t)return null;const a=te(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return a.isValid()?a:null}function Bt(t){return t?te(t).format("h:mm a"):""}function Ag({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),y=`${Fa.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:p,isLoading:m,mutate:A}=H(t?[y,t]:null,([h,S])=>K(h,S)),C=i.useMemo(()=>Cg(p),[p]),b=i.useMemo(()=>p?.pagination?.total_rows??p?.pagination?.total??C.length??0,[p,C]),{data:f,isLoading:x}=H(t&&o?[`${Fa.show}?id=${encodeURIComponent(String(o))}`,t]:null,([h,S])=>K(h,S)),R=i.useMemo(()=>{const h=f?.data??f;return Array.isArray(h)?h[0]:h??null},[f]);i.useEffect(()=>{r&&R&&g.setFieldsValue({title:R?.title??"",start_time_from:Rn(R?.start_time_from),start_time_to:Rn(R?.start_time_to),end_time_from:Rn(R?.end_time_from),end_time_to:Rn(R?.end_time_to)})},[r,R,g]);const k=async h=>{const S=new FormData;S.append("title",h.title??""),S.append("start_time_from",Bt(h.start_time_from)),S.append("start_time_to",Bt(h.start_time_to)),S.append("end_time_from",Bt(h.end_time_from)),S.append("end_time_to",Bt(h.end_time_to));try{await At(Fa.add,S,t),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),A()}catch(E){w.error(E?.response?.data?.msg??E?.message??"Failed to add the new item.",{duration:1500})}},O=async h=>{const S=new FormData;S.append("id",String(o??"")),S.append("title",h.title??""),S.append("start_time_from",Bt(h.start_time_from)),S.append("start_time_to",Bt(h.start_time_to)),S.append("end_time_from",Bt(h.end_time_from)),S.append("end_time_to",Bt(h.end_time_to));try{await zt(Fa.edit,S,t),w.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),A()}catch(E){w.error(E?.response?.data?.msg??E?.message??"Failed to update the item.",{duration:1500})}},D=async h=>{try{await Yt(Fa.remove,h,t),w.success("Success! Deleted item.",{duration:1e3}),A()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to delete the item.",{duration:1500})}},_=h=>{h?.id&&(d(h.id),l(!0))},u=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:120,render:(h,S)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>_(S)}),e.jsx(n.Popconfirm,{title:"Delete this time group?",onConfirm:()=>D(S?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Time Group",open:r,onClose:()=>{l(!1),d(null)},width:520,children:x?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})}):e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:O,children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(z,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Nt})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Nt})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Nt})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Nt})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:k,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(z,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Nt})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Nt})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Nt})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Nt})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(n.Table,{rowKey:h=>h.id,columns:u,dataSource:C,loading:m,pagination:{current:a.page,pageSize:a.perPage,total:b,showSizeChanger:!0,onChange:(h,S)=>s({page:h,perPage:S})}})})]})}function Dg({token:t}){return e.jsx(Ag,{token:t})}const Ua=Re.assignTimeGroup,Tg=Re.timeGroup.dropdown,Rg=Re.master.classes.dropdown,Xi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Ig=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function kg({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,l]=i.useState(null),[o,d]=i.useState([]),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState(null),[C,b]=i.useState(!1),[f,x]=i.useState(!1),[R,k]=i.useState(null),[O,D]=i.useState([]),[_,u]=i.useState(""),[h,S]=i.useState(""),{data:E}=H(t?[Tg,t]:null,([G,J])=>K(G,J)),{data:F}=H(t?[Rg,t]:null,([G,J])=>K(G,J)),q=i.useMemo(()=>Xi(E?.data??E),[E]),T=i.useMemo(()=>Xi(F),[F]),{data:U}=H(t&&m?[m,t]:null,([G,J])=>K(G,J));i.useEffect(()=>{const G=Array.isArray(U?.data)?U.data.map(J=>J.fk_classId):[];G.length&&d(G)},[U]);const j=`${Ua.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:P,isLoading:I,mutate:N}=H(t?[j,t]:null,([G,J])=>K(G,J)),V=i.useMemo(()=>Ig(P),[P]),W=i.useMemo(()=>P?.pagination?.total_rows??P?.pagination?.total??V.length??0,[P,V]),{data:B,isLoading:$}=H(t&&R?[`${Ua.show}?id=${encodeURIComponent(String(R))}`,t]:null,([G,J])=>K(G,J)),M=B?.data??B??null;i.useEffect(()=>{if(!f||!M)return;const G=Array.isArray(M?.class_ids)?M.class_ids:[];D(G);const J=Array.isArray(q)?q.find(re=>String(re.value)===String(M?.timegroup_id)):null;J&&S(`${J.start_time_from} -> ${J.end_time_from}`)},[f,M,q]);const L=async G=>{if(G.preventDefault(),g(""),!r?.value){w.error("Select Time Group",{duration:1200});return}if(!o.length){g("error"),w.error("Please Select Classes",{duration:1200});return}const J=new FormData;J.append("timegroup_id",String(r.value)),o.forEach(re=>J.append("class_ids[]",String(re)));try{await At(Ua.assign,J,t),w.success("Success! Added new item.",{duration:1e3}),d([]),l(null),p(""),N()}catch(re){w.error(re?.response?.data?.msg??re?.message??"Failed to add the new item.",{duration:1500})}},Y=async()=>{if(u(""),!R)return;if(!O.length){u("error"),w.error("Please Select Classes",{duration:1200});return}const G=new FormData;G.append("id",String(R)),G.append("timegroup_id",String(M?.timegroup_id??"")),O.forEach(J=>G.append("class_ids[]",String(J)));try{await zt(Ua.assign,G,t),w.success("Success! Updated item.",{duration:1e3}),x(!1),k(null),N()}catch(J){w.error(J?.response?.data?.msg??J?.message??"Failed to update the item.",{duration:1500})}},se=G=>{G&&(k(G),x(!0))},X=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:(G,J)=>J?.class_names?e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>se(J?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Time Group",open:f,onClose:()=>{x(!1),k(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>x(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:Y,children:"Submit"})]}),children:$?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(n.Spin,{size:"large"})}):e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{options:Array.isArray(q)?q:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:q.find(G=>String(G.value)===String(M?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:h}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(n.Select,{mode:"multiple",style:{width:"100%"},status:_,value:O,placeholder:"Select Classes",onChange:G=>D(G),options:Array.isArray(T)?T:[]})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(Q,{options:Array.isArray(q)?q:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:G=>{l(G??null),d([]),g(""),G?.value?(A(`${Ua.classIdByTimeGroup}?id=${encodeURIComponent(String(G.value))}`),p(`${G.start_time_from} -> ${G.end_time_from}`)):(A(null),p("")),b(J=>!J)}}),e.jsx("div",{style:{marginTop:6},children:y})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(Q,{isMulti:!0,style:{width:"100%"},status:c,value:(T??[]).filter(G=>Array.isArray(o)&&o.some(J=>String(J)===String(G.value))),placeholder:"Select Classes",onChange:G=>{const J=Array.isArray(G)?G:[];d(J.map(re=>re?.value).filter(re=>re!=null&&re!==""))},options:Array.isArray(T)?T:[]},`class_${C}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(n.Table,{rowKey:G=>G.id,columns:X,dataSource:V,loading:I,pagination:{current:a.page,pageSize:a.perPage,total:W,showSizeChanger:!0,onChange:(G,J)=>s({page:G,perPage:J})}})})]})}function Pg({token:t}){return e.jsx(kg,{token:t})}const Qs=Re.promoteStudents,Og=({token:t})=>H(t?[Qs.sessionDropdown,t]:null,([a,s])=>K(a,s)),In=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[]},Mg=(t,a)=>{const s=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,r=s?.total_rows??s?.total??s?.totalItems;return Number.isFinite(Number(r))?Number(r):a};function Eg({token:t}){const[a]=n.Form.useForm(),[s,r]=i.useState({page:1,perPage:300}),[l,o]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[g,y]=i.useState(!1),[p,m]=i.useState([]),A=i.useMemo(()=>new Set(p),[p]),[C,b]=i.useState({}),[f,x]=i.useState({}),{data:R}=H(t?[Re.master.classes.dropdown,t]:null,([L,Y])=>K(L,Y)),k=i.useMemo(()=>In(R),[R]),O=i.useMemo(()=>l.classId?`${Re.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:D}=H(t&&O?[O,t]:null,([L,Y])=>K(L,Y)),_=i.useMemo(()=>In(D),[D]),u=i.useMemo(()=>d.classId?`${Re.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:h}=H(t&&u?[u,t]:null,([L,Y])=>K(L,Y),{revalidateOnFocus:!1}),S=i.useMemo(()=>In(h),[h]),{data:E}=Og({token:t}),F=i.useMemo(()=>In(E),[E]),{trigger:q,data:T,isMutating:U}=rt(t?Qs.searchByClassSection:null,(L,{arg:Y})=>Qt(L,{arg:Y},t)),j=i.useMemo(()=>{const L=T?.data?.data??T?.data??T??[];return Array.isArray(L)?L:Array.isArray(L?.data)?L.data:[]},[T]),P=i.useMemo(()=>Mg(T,j.length??0),[T,j.length]),I=i.useMemo(()=>{const L=new Map;return(Array.isArray(j)?j:[]).forEach(Y=>{Y?.id!==void 0&&Y?.id!==null&&L.set(String(Y.id),Y)}),L},[j]),N=i.useCallback((L,Y)=>{const se=String(L);x(X=>({...X,[se]:{...X?.[se]??{},...Y}}))},[]),V=i.useCallback((L,Y)=>{const se=String(L),X=Y==="Leave";b(G=>({...G,[se]:X}))},[]),W=L=>{const Y=L?.class_id?.value??L?.class_id??null,se=L?.section_id?.value??L?.section_id??null;if(!Y||!se){w.error("Please select Class and Section",{duration:1200});return}r(X=>({...X,page:1})),o({classId:Y,sectionId:se}),m([]),b({}),x({})},B=async()=>{if(!d.sessionId||!d.classId){w.error("Please select Session and Class for promotion",{duration:1300});return}if(!Array.isArray(p)||p.length===0){w.error("Please select students to promote",{duration:1200});return}const L=p.map(G=>String(G)).map(G=>{const J=I.get(G)??{},re=!!C?.[G],de=f?.[G]??{},Ce=String(de.current_result??"Pass");if(re){const ie=String(de.leave_date??"");return{student_id:G,current_result:Ce,next_session_status:"Leave",leave_date:ie}}const le=String(de.roll_no??J?.roll_no??""),oe=String(de.section_id??"");return{student_id:G,roll_no:le,section_id:oe,current_result:Ce,next_session_status:"Continue"}});if(L.some(G=>G?.next_session_status==="Leave"&&!String(G?.leave_date??"").trim())){w.error("Leave date is required for Leave students.",{duration:1500});return}if(L.some(G=>G?.next_session_status==="Continue"&&!String(G?.section_id??"").trim())){w.error("Section is required for Continue students.",{duration:1500});return}const X={class_id:String(d.classId),session_id:String(d.sessionId),students:L};try{const G=await We(Qs.promote,X,t);if(G?.Status&&String(G.Status)!=="success")throw new Error(G?.msg||"Failed to update");w.success("Success! Updated.",{duration:1e3});const J=Number(G?.success_count??0)+Number(G?.leave_count??0),re=s.page===Math.ceil((Number(P)||0)/s.perPage||1),de=J>0&&J===j.length&&j.length===p.length,Ce=re&&de&&s.page>1?s.page-1:s.page;r(le=>({...le,page:Ce})),q?.({cID:l.classId,sID:l.sectionId,page:Ce,per_page:s.perPage}),m([]),b({}),x({})}catch(G){w.error(G?.response?.data?.msg??G?.message??"Failed to update",{duration:1500})}},$=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:120,render:(L,Y)=>{const se=String(Y?.id??""),X=A.has(se),G=!!C?.[se],re=(f?.[se]??{}).roll_no??(G?"":Y?.roll_no??"");return e.jsx(n.Input,{value:X?re:Y?.roll_no,style:X?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!X||G,onChange:de=>N(se,{roll_no:de.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(L,Y)=>`${Y?.firstname??""} ${Y?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(L,Y)=>{const se=String(Y?.id??""),X=A.has(se),G=!!C?.[se],re=(f?.[se]??{}).section_id??"",de=Array.isArray(S)?S:[];return e.jsx(n.Select,{options:de,placeholder:X&&!G?"Select Section":"Section",disabled:!X||G,value:X&&!G&&re||void 0,style:{width:"100%"},onChange:Ce=>N(se,{section_id:Ce})},`section_${se}_${g}_${G?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(L,Y)=>{const se=String(Y?.id??""),X=A.has(se),G=f?.[se]??{},J=String(G.current_result??"Pass");return e.jsxs(n.Radio.Group,{value:J,disabled:!X,buttonStyle:"solid",onChange:re=>N(se,{current_result:re.target.value}),children:[e.jsx(n.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(n.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(L,Y)=>{const se=String(Y?.id??""),X=A.has(se),G=!!C?.[se],J=f?.[se]??{},re=String(J.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(n.Radio.Group,{value:G?"Leave":"Continue",disabled:!X,buttonStyle:"solid",onChange:de=>V(se,de.target.value),children:[e.jsx(n.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(n.Radio.Button,{value:"Leave",children:"Leave"})]}),X&&G&&e.jsx(n.DatePicker,{style:{width:"100%"},value:re?te(re):null,onChange:de=>N(se,{leave_date:de?de.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[V,C,f,A,g,S,N]),M=i.useMemo(()=>({selectedRowKeys:p,onChange:L=>m((Array.isArray(L)?L:[]).map(Y=>String(Y)))}),[p]);return i.useEffect(()=>{!l.classId||!l.sectionId||q&&q({cID:l.classId,sID:l.sectionId,page:s.page,per_page:s.perPage})},[s.page,s.perPage,q,l.classId,l.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:W,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:L=>L,children:e.jsx(Q,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:L=>{const Y=L?.value??null;a.setFieldValue("section_id",null),o({classId:Y,sectionId:null})}})}),e.jsx(n.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:L=>L,children:e.jsx(Q,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Wt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n.Typography.Text,{children:["Selected: ",p.length]}),e.jsx(n.Typography.Text,{type:"secondary",children:"Select students → set Continue/Leave → Save"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{label:"Session",options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:F.find(L=>String(L.value)===String(d.sessionId))??null,onChange:L=>c(Y=>({...Y,sessionId:L?.value??null}))}),e.jsx(Q,{label:"Class",options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:k.find(L=>String(L.value)===String(d.classId))??null,onChange:L=>{const Y=L?.value??null;c(se=>({...se,classId:Y})),y(se=>!se)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Save",color:"primary",onClick:B})})]}),e.jsx(n.Table,{rowKey:L=>String(L.id),rowSelection:M,columns:$,dataSource:j,loading:U,pagination:{current:s.page,pageSize:s.perPage,total:P,showSizeChanger:!0,onChange:(L,Y)=>{r({page:L,perPage:Y}),m([]),b({}),x({})}}})]})})]})}function $g({token:t}){return e.jsx(Eg,{token:t})}const ya=Re.coscholastic,Fg=({token:t})=>H(t?[ya.table,t]:null,([a,s])=>K(a,s),{revalidateOnFocus:!1}),Ug=({token:t})=>H(t?[ya.categoryDropdown,t]:null,([a,s])=>K(a,s),{revalidateOnFocus:!1}),Zi=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]};function Ng({token:t}){const[a,s]=i.useState(""),[r,l]=i.useState(null),[o,d]=i.useState(null),c=i.useRef(null),{data:g}=H(t?[Re.master.classes.dropdown,t]:null,([h,S])=>K(h,S)),y=i.useMemo(()=>Zi(g),[g]),{data:p,isLoading:m,mutate:A}=Fg({token:t}),C=i.useMemo(()=>{const h=p?.data?.data??p?.data??p??[];return Array.isArray(h)?h:Array.isArray(h?.data)?h.data:[]},[p]),{data:b,mutate:f}=Ug({token:t}),x=i.useMemo(()=>Zi(b),[b]),R=i.useMemo(()=>(Array.isArray(x)?x:[]).map(h=>({value:h?.value??h?.id,label:h?.label??h?.title??""})),[x]),k=async()=>{const h=String(a??"").trim();if(!h){w.error("Please enter category title",{duration:1200});return}try{await Ne(ya.addCategory,{title:h},t),w.success("Success! Added category.",{duration:1e3}),s(""),f()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to add category",{duration:1500})}},O=async h=>{try{await Yt(ya.deleteCategory,h,t),w.success("Success! Deleted category.",{duration:1e3}),f()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to delete category",{duration:1500})}},D=async h=>{if(h.preventDefault(),!r){w.error("Please select Category",{duration:1200});return}if(!o){w.error("Please select Class",{duration:1200});return}if(!h?.target?.skill?.value){w.error("Please enter Skill Name",{duration:1200});return}const E=new FormData(h.target);E.append("scholastic_catid",String(r)),E.append("class_id",String(o));try{await At(ya.addSkill,E,t),w.success("Success! Added new item.",{duration:1e3}),h.target.reset(),d(null),A()}catch(F){w.error(F?.response?.data?.msg??F?.message??"Failed to add the new item.",{duration:1500})}},_=async h=>{try{await Yt(ya.deleteSkill,h,t),w.success("Success! Deleted item.",{duration:1e3}),A()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to delete the item.",{duration:1500})}},u=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:(h,S)=>e.jsx(n.Popconfirm,{title:"Delete this skill?",onConfirm:()=>_(S?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),children:e.jsx("form",{onSubmit:D,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Category"}),e.jsx(Q,{style:{width:"100%"},value:R.find(h=>String(h.value)===String(r))??null,placeholder:"Select Category",onChange:h=>l(h?.value??null),options:R}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(z,{placeholder:"New category",ref:c,value:a,onChange:h=>s(h.target.value)}),e.jsx(n.Button,{type:"text",icon:e.jsx(ee.PlusOutlined,{}),onClick:k}),e.jsx(n.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{r&&(O(r),l(null))},children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{}),disabled:!r})})]})]}),e.jsx(Q,{label:"Class",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:y.find(h=>String(h.value)===String(o))??null,onChange:h=>d(h?.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(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Wt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:h=>h.id,columns:u,dataSource:C,loading:m,pagination:!1})})]})}function Bg({token:t}){return e.jsx(Ng,{token:t})}const Lg=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",_o=({token:t,value:a,onChange:s,action:r,filePath:l})=>{const o=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),d=r??Xy(),c=i.useMemo(()=>{if(!l)return d;const g=d.includes("?")?"&":"?";return`${d}${g}filepath=${encodeURIComponent(l)}`},[d,l]);return e.jsx(n.Upload,{maxCount:1,action:c,headers:o,onChange:g=>{if(g?.file?.status==="done"){const y=Lg(g?.file?.response);y&&s?.(y)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},el=Re.notes,qg=({token:t,url:a})=>H(t&&a?[a,t]:null,([s,r])=>K(s,r),{revalidateOnFocus:!1}),kn=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[]},zg=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function Yg({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[r,l]=i.useState({page:1,perPage:50}),[o,d]=i.useState({classId:null,sectionId:null}),[c,g]=i.useState(!1),[y,p]=i.useState(""),{data:m}=H(t?[Re.master.classes.dropdown,t]:null,([M,L])=>K(M,L)),A=i.useMemo(()=>kn(m),[m]),C=i.useMemo(()=>o.classId?`${Re.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:b}=H(t&&C?[C,t]:null,([M,L])=>K(M,L)),f=i.useMemo(()=>kn(b),[b]),x=i.useMemo(()=>!o.classId||!o.sectionId?null:`${el.table}?class_id=${encodeURIComponent(String(o.classId))}&section_id=${encodeURIComponent(String(o.sectionId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`,[o.classId,o.sectionId,r.page,r.perPage]),{data:R,isLoading:k,mutate:O}=qg({token:t,url:x}),D=i.useMemo(()=>{const M=R?.data?.data??R?.data??R??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},[R]),_=i.useMemo(()=>R?.pagination?.total_rows??R?.pagination?.total??D.length??0,[R,D.length]),[u,h]=i.useState(null),[S,E]=i.useState(null),[F,q]=i.useState(null),[T,U]=i.useState(!1),{data:j}=H(t&&F?[F,t]:null,([M,L])=>K(M,L),{revalidateOnFocus:!1}),P=i.useMemo(()=>kn(j),[j]),{data:I}=H(t&&S?[S,t]:null,([M,L])=>K(M,L)),N=i.useMemo(()=>kn(I),[I]),V=M=>{const L=M?.class_id?.value??null,Y=M?.section_id?.value??null;!L||!Y||(l(se=>({...se,page:1})),d({classId:L,sectionId:Y}))},W=()=>{p(""),g(!0),h(null),E(null),q(null),U(M=>!M),s.resetFields()},B=async M=>{const L=M?.class_id?.value??null,Y=M?.section_id?.value??null,se=M?.sub_id?.value??null,X=M?.status?.value??"publish",G=M?.title??"",J=M?.remark??"";if(!L||!Y||!se||!G||!J||!y){w.error("Please fill all fields",{duration:1200});return}const re=new FormData;re.append("class_id",String(L)),re.append("section_id",String(Y)),re.append("sub_id",String(se)),re.append("title",String(G)),re.append("remark",String(J)),re.append("status",String(X)),re.append("file",String(y));try{await At(el.add,re,t),w.success("Success! Added new item.",{duration:1e3}),g(!1),O()}catch(de){w.error(de?.response?.data?.msg??de?.message??"Failed to add the new item.",{duration:1500})}},$=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,L)=>{const Y=String(L?.status??"").toLowerCase();return e.jsx(n.Tag,{color:Y==="publish"?"green":"red",children:L?.status??"-"})}},{title:"File",key:"file",align:"center",render:(M,L)=>{const Y=L?.file;if(!Y)return"-";const se=zg(Ke(),`uploads/school_${L?.fk_branchID}/student/note/${Y}`);return e.jsx("a",{href:se,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"date",key:"date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Add Note",open:c,onCancel:()=>g(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(Q,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const L=M?.value??null;h(L),s.setFieldValue("section_id",null),s.setFieldValue("sub_id",null),q(L?`${Re.master.sections.byClass}?class_id=${encodeURIComponent(String(L))}`:null),E(L?`${Re.master.subjects.dropdown}?class_id=${encodeURIComponent(String(L))}`:null),U(Y=>!Y)}},`class_${T}`)}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:M=>M,children:e.jsx(Q,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${T}_${u??"none"}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:M=>M,children:e.jsx(Q,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${T}_${S??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(z,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(z,{placeholder:"Remark"})}),e.jsx(n.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:M=>M,children:e.jsx(Q,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(_o,{token:t,value:y,onChange:p})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Wt,{actions:["add","export","print","download","filter"],onAdd:W,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:V,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(Q,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const L=M?.value??null;a.setFieldValue("section_id",null),d({classId:L,sectionId:null})}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:M=>M,children:e.jsx(Q,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(n.Table,{rowKey:M=>M.id,columns:$,dataSource:D,loading:k,pagination:{current:r.page,pageSize:r.perPage,total:_,showSizeChanger:!0,onChange:(M,L)=>l({page:M,perPage:L})}})})]})}function Vg({token:t}){return e.jsx(Yg,{token:t})}const Wg=({token:t})=>H(t?[Re.promoteStudents.sessionDropdown,t]:null,([a,s])=>K(a,s),{revalidateOnFocus:!1}),tl=Re.transferCertificate,Es=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[]},Hg={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Kg=(t,a)=>t.inputtype==="Select"?null:t.inputtype==="date"?te():"",al=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}],nl=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 Gg({token:t,transferCertificateViewPath:a="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:s}){const[r]=n.Form.useForm(),[l]=n.Form.useForm(),[o,d]=i.useState({page:1,perPage:10}),[c,g]=i.useState({classId:null,sectionId:null,sessionId:null}),[y,p]=i.useState(null),[m,A]=i.useState(!1),{data:C}=H(t?[Re.master.classes.dropdown,t]:null,([$,M])=>K($,M)),b=i.useMemo(()=>Es(C),[C]),{data:f}=H(t&&y?[y,t]:null,([$,M])=>K($,M)),x=i.useMemo(()=>Es(f),[f]),{data:R}=Wg({token:t}),k=i.useMemo(()=>Es(R),[R]),O=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${tl.studentList}?class_id=${encodeURIComponent(String(c.classId))}&section_id=${encodeURIComponent(String(c.sectionId))}&session_id=${encodeURIComponent(String(c.sessionId))}&page=${encodeURIComponent(String(o.page))}&per_page=${encodeURIComponent(String(o.perPage))}`,[c.classId,c.sectionId,c.sessionId,o.page,o.perPage]),{data:D,isLoading:_,mutate:u}=H(t&&O?[O,t]:null,([$,M])=>K($,M),{revalidateOnFocus:!1,onSuccess:$=>{const M=$?.data?.data??$?.data??[];Array.isArray(M)&&M[0]?.transefer_certificate_id&&j(String(M[0].transefer_certificate_id))}}),h=i.useMemo(()=>{const $=D?.data?.data??D?.data??D??[];return Array.isArray($)?$:Array.isArray($?.data)?$.data:[]},[D]),S=i.useMemo(()=>D?.pagination?.total_rows??D?.pagination?.total??h.length??0,[D,h.length]),[E,F]=i.useState(!1),[q,T]=i.useState(null),[U,j]=i.useState("1"),P=$=>{T($);const M=U==="1"?al($):nl($),L={};M.forEach(Y=>{L[Y.name]=Y.value??Kg(Y)}),l.setFieldsValue(L),F(!0)},I=async $=>{if(!$)return;if(typeof s=="function")return s($);const M=`${a}?id=${encodeURIComponent(String($))}`;window.location.href=M},N=$=>{const M=$?.class_id?.value??null,L=$?.section_id?.value??null,Y=$?.session_id?.value??null;if(!M||!L||!Y){w.error("Please select Class, Section and Session",{duration:1200});return}d(se=>({...se,page:1})),g({classId:M,sectionId:L,sessionId:Y})},V=async $=>{const M=new FormData;Object.entries($??{}).forEach(([L,Y])=>{if(Y!=null){if(te.isDayjs(Y)){M.append(L,Y.format("YYYY-MM-DD"));return}M.append(L,String(Y))}});try{await At(tl.addData,M,t),w.success("Success! Added new item.",{duration:1e3}),F(!1),T(null),u()}catch(L){w.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},W=i.useMemo(()=>U==="1"?al(q):nl(q),[U,q]),B=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:($,M)=>e.jsx(n.Button,{type:"text",icon:M?.transfer_certificate_data==="not_present"?e.jsx(ee.EyeOutlined,{}):e.jsx(ee.CheckOutlined,{}),onClick:()=>{M?.transfer_certificate_data==="not_present"?P(M?.id):I(M?.id)}})}],[U]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Transfer Certificate",open:E,onCancel:()=>F(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:V,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:W.map($=>$.inputtype==="hidden"?e.jsx(n.Form.Item,{name:$.name,initialValue:$.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},$.name):$.inputtype==="date"?e.jsx(n.Form.Item,{label:$.label,name:$.name,children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:Hg})},$.name):$.inputtype==="radio"?e.jsx(n.Form.Item,{label:$.label,name:$.name,children:e.jsx(n.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},$.name):$.inputtype==="Select"?e.jsx(n.Form.Item,{label:$.label,name:$.name,getValueFromEvent:M=>M,children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},$.name):e.jsx(n.Form.Item,{label:$.label,name:$.name,children:e.jsx(z,{placeholder:$.label})},$.name))}),e.jsxs(n.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(ne,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>F(!1),children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(n.Form,{form:r,layout:"vertical",onFinish:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const M=$?.value??null;p(M?`${Re.master.sections.byClass}?class_id=${encodeURIComponent(String(M))}`:null),A(L=>!L),r.setFieldValue("section_id",null)}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:$=>$,children:e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${m}`)}),e.jsx(n.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:$=>$,children:e.jsx(Q,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Wt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:$=>$.id,columns:B,dataSource:h,loading:_,pagination:{current:o.page,pageSize:o.perPage,total:S,showSizeChanger:!0,onChange:($,M)=>d({page:$,perPage:M})}})})]})}function Jg({token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s}){return e.jsx(Gg,{token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s})}const Qg=({token:t,url:a})=>H(t&&a?[a,t]:null,([s,r])=>K(s,r),{revalidateOnFocus:!1}),$s=Re.syllabus,sl=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[]},Xg=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function Zg({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[r,l]=i.useState({page:1,perPage:50}),[o,d]=i.useState({classId:null}),[c,g]=i.useState(!1),[y,p]=i.useState(null),[m,A]=i.useState(""),{data:C}=H(t?[Re.master.classes.dropdown,t]:null,([I,N])=>K(I,N)),b=i.useMemo(()=>sl(C),[C]),f=i.useMemo(()=>o.classId?`${$s.table}?class_id=${encodeURIComponent(String(o.classId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`:null,[o.classId,r.page,r.perPage]),{data:x,isLoading:R,mutate:k}=Qg({token:t,url:f}),O=i.useMemo(()=>{const I=x?.data?.data??x?.data??x??[];return Array.isArray(I)?I:Array.isArray(I?.data)?I.data:[]},[x]),D=i.useMemo(()=>x?.pagination?.total_rows??x?.pagination?.total??O.length??0,[x,O.length]),[_,u]=i.useState(null),[h,S]=i.useState(!1),{data:E}=H(t&&_?[_,t]:null,([I,N])=>K(I,N),{revalidateOnFocus:!1}),F=i.useMemo(()=>sl(E),[E]),q=I=>{const N=I?.class_id?.value??null;N&&(l(V=>({...V,page:1})),d({classId:N}))},T=()=>{p(null),A(""),u(null),S(I=>!I),s.resetFields(),g(!0)},U=I=>{p(I),A(I?.attchement??"");const N=I?.class_id;u(N?`${Re.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),S(V=>!V),s.setFieldsValue({class_id:b.find(V=>String(V.value)===String(N))??null,sub_id:F.find(V=>String(V.value)===String(I?.sub_id??I?.subject_id))??(I?.sub_id||I?.subject_id?{label:I?.subject_title??"Subject",value:I?.sub_id??I?.subject_id}:null),title:I?.title??"",description:I?.description??""}),g(!0)},j=async I=>{const N=I?.class_id?.value??null,V=I?.sub_id?.value??null,W=I?.title??"",B=I?.description??"";if(!N||!V||!W||!B||!m){w.error("Please fill all fields",{duration:1200});return}const $=new FormData;$.append("class_id",String(N)),$.append("sub_id",String(V)),$.append("title",String(W)),$.append("description",String(B)),$.append("file",String(m));try{y?.id?($.append("id",String(y.id)),await At($s.edit,$,t),w.success("Success! Updated item.",{duration:1e3})):(await At($s.add,$,t),w.success("Success! Added new item.",{duration:1e3})),g(!1),p(null),k()}catch(M){w.error(M?.response?.data?.msg??M?.message??"Failed to save",{duration:1500})}},P=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:(I,N)=>{const V=N?.attchement;if(!V)return"-";const W=Xg(Ke(),`uploads/school_${N?.fk_branchID}/student/syllabus/${V}`);return e.jsx("a",{href:W,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(I,N)=>e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>U(N)})}],[F,b]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:y?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{g(!1),p(null),A("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:I=>I,children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{const N=I?.value??null;s.setFieldValue("sub_id",null),u(N?`${Re.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),S(V=>!V)}},`class_${y?.id??"add"}_${h}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:I=>I,children:e.jsx(Q,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${y?.id??"add"}_${h}_${_??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(z,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(lt,{placeholder:"Description"})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(_o,{token:t,value:m,onChange:A,action:Zy(),filePath:"student/syllabus"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Wt,{actions:["add","export","print","download","filter"],onAdd:T,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,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(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:I=>I,children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(n.Table,{rowKey:I=>I.id,columns:P,dataSource:O,loading:R,pagination:{current:r.page,pageSize:r.perPage,total:D,showSizeChanger:!0,onChange:(I,N)=>l({page:I,perPage:N})}})})]})}function ex({token:t}){return e.jsx(Zg,{token:t})}const us=Re.timetable,rl=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[]},il=t=>{if(!t)return"";const a=te(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},tx=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let l=0;l<a.length;l+=1)s=(s*31+a.charCodeAt(l))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]},ll=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],ax=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"};function nx({token:t}){const[a,s]=i.useState(null),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),[y,p]=i.useState(""),{data:m}=H(t?[Re.master.classes.dropdown,t]:null,([u,h])=>K(u,h)),A=i.useMemo(()=>rl(m),[m]),{data:C}=H(t&&a?[a,t]:null,([u,h])=>K(u,h)),b=i.useMemo(()=>rl(C),[C]),{data:f,isLoading:x}=H(t&&o?[o,t]:null,([u,h])=>K(u,h),{revalidateOnFocus:!1}),R=i.useMemo(()=>f?.days??f?.data?.days??f?.data?.data?.days??{},[f]),{dataSource:k,daySpanByFirstKey:O}=i.useMemo(()=>{const u=Object.entries(R||{}).slice().sort((E,F)=>ll.indexOf(String(E[0]).toLowerCase())-ll.indexOf(String(F[0]).toLowerCase())),h=new Map,S=[];for(const[E,F]of u){const q=(Array.isArray(F)?F:[]).slice().sort((U,j)=>Number(U?.order_no||0)-Number(j?.order_no||0)),T=q.length;for(let U=0;U<T;U+=1){const j=q[U],P=j?.id||`${E}-${j?.order_no}-${U}`;U===0&&h.set(P,T),S.push({key:P,_dayKey:E,...j})}}return{dataSource:S,daySpanByFirstKey:h}},[R]),D=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(u,h)=>{const S=O.get(h.key);return S===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(ee.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:ax(u)})]}),props:{rowSpan:S}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:u=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:u})},{title:"Time",key:"time",width:180,render:(u,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[il(h?.time_from)," - ",il(h?.time_to)]})]})},{title:"Subject",key:"subject",render:(u,h)=>{if(String(h?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const E=h?.subject_name||"-";return e.jsx(n.Tag,{color:tx(E),style:{fontWeight:500},children:E})}},{title:"Teacher",key:"teacher",render:(u,h)=>{const S=String(h?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:S?"-":h?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(u,h)=>{const S=String(h?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:S?"-":h?.room_no||"-"})]})}}],[O]),_=u=>{u.preventDefault();const h=u.target.class_id?.value,S=u.target.section_id?.value;if(!h||!S)return;const E=A.find(U=>String(U.value)===String(h)),F=b.find(U=>String(U.value)===String(S));g(E?.label||""),p(F?.label||"");const T=`${us.byClassSection}/${h}/section/${S}`;d(T)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Wt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),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.jsx(Q,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:u=>{s(`${Re.master.sections.byClass}?class_id=${encodeURIComponent(String(u?.value??""))}`),l(h=>!h)}}),e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${r}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:c||y?`Timetable: ${c} ${y}`:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:k,columns:D,rowKey:"key",loading:x,scroll:{x:"max-content"}})})]})}const sx=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[]},ol=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],rx=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"},dl=t=>{if(!t)return"";const a=te(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},ix=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let l=0;l<a.length;l+=1)s=(s*31+a.charCodeAt(l))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]};function lx({token:t}){const[a,s]=i.useState(null),[r,l]=i.useState(null),{data:o}=H(t?[Re.assignByClass.teacherDropdown,t]:null,([C,b])=>K(C,b)),d=i.useMemo(()=>sx(o),[o]),{data:c,isLoading:g}=H(t&&r?[r,t]:null,([C,b])=>K(C,b),{revalidateOnFocus:!1}),{dataSource:y,daySpanByFirstKey:p}=i.useMemo(()=>{const b=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((k,O)=>{const D=ol.indexOf(String(k?.day_name||"").toLowerCase()),_=ol.indexOf(String(O?.day_name||"").toLowerCase());if(D!==_)return D-_;const u=Number(k?.order_no||0),h=Number(O?.order_no||0);return u!==h?u-h:String(k?.time_from||"").localeCompare(String(O?.time_from||""))}),f=new Map,x=[];let R=0;for(;R<b.length;){const k=String(b[R]?.day_name||"").toLowerCase();let O=R;for(;O<b.length&&String(b[O]?.day_name||"").toLowerCase()===k;)O+=1;const D=O-R;for(let _=R;_<O;_+=1){const u=b[_],h=u?.id||`${k}-${u?.order_no}-${_}`;_===R&&f.set(h,D),x.push({key:h,_dayKey:k,...u})}R=O}return{dataSource:x,daySpanByFirstKey:f}},[c]),m=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(C,b)=>{const f=p.get(b.key);return f===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(ee.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:rx(C)})]}),props:{rowSpan:f}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:C=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:C})},{title:"Time",key:"time",width:180,render:(C,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[dl(b?.time_from)," - ",dl(b?.time_to)]})]})},{title:"Subject",key:"subject",render:(C,b)=>{if(String(b?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const x=b?.subject_name||"-";return e.jsx(n.Tag,{color:ix(x),style:{fontWeight:500},children:x})}},{title:"Class",key:"class",width:160,render:(C,b)=>e.jsxs(n.Tag,{color:"purple",style:{fontWeight:500},children:[b?.class_name||b?.class_id||"-"," ",b?.section_name?`(${b.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(C,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:b?.room_no||"-"})]})}],[p]),A=C=>{C.preventDefault();const b=C.target.teacher_id?.value;if(!b)return;s(b);const x=`${us.teacherTimetable}${encodeURIComponent(String(b))}`;l(x)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Wt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:d,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teacher",name:"teacher_id",allowSelectAll:!1,required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:y,columns:m,rowKey:"key",loading:g,scroll:{x:"max-content"}})})]})}function cl(t){if(!t)return null;const a=String(t).trim().replaceAll(".",":");if(!a)return null;const s=a.toLowerCase(),r=s.includes("am")||s.includes("pm");let l=0,o=0,d=0;if(r){const g=s.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!g)return null;l=Number.parseInt(g[1],10),o=Number.parseInt(g[2],10),d=Number.parseInt(g[3]||"0",10);const y=g[4].toLowerCase();y==="pm"&&l<12&&(l+=12),y==="am"&&l===12&&(l=0)}else{const c=a.split(":").map(g=>g.trim());if(c.length<2)return null;l=Number.parseInt(c[0],10),o=Number.parseInt(c[1],10),d=Number.parseInt(c[2]||"0",10)}return![l,o,d].every(c=>Number.isFinite(c))||l<0||l>23||o<0||o>59||d<0||d>59?null:te().hour(l).minute(o).second(d).millisecond(0)}function Na(t,a){const s=Number.parseInt(a,10);return!Number.isFinite(s)||s<=0||!t||!t.isValid?.()?null:t.add(s,"minute")}const Kn=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[]},Ya={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},ox=t=>{const a=Ya[String(t)];return a?a.charAt(0).toUpperCase()+a.slice(1):String(t)},dx=({token:t,classId:a,sectionId:s,subjectId:r,value:l,onChange:o,disabled:d})=>{const c=t&&a&&s&&r?`${us.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(a))}&section_id=${encodeURIComponent(String(s))}`:null,{data:g,isLoading:y}=H(c?[c,t]:null,([m,A])=>K(m,A),{revalidateOnFocus:!1}),p=i.useMemo(()=>Kn(g?.data??g).map(A=>({value:A?.value??A?.id,label:A?.label??A?.name??A?.teacher_name??""})),[g]);return e.jsx(n.Select,{placeholder:d?"-":"Select Teacher",loading:y,disabled:d,style:{width:"100%"},options:p,value:l?String(l):void 0,onChange:m=>o?.(m),showSearch:!0,optionFilterProp:"label"})};function cx({token:t}){const[a]=n.Form.useForm(),[s,r]=i.useState({classId:null,sectionId:null,dayKey:"1",daysEnabled:{0:!1,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}),[l,o]=i.useState({startTime:null,endTime:null,duration:40,interval:0,roomNo:"",tiffinEnabled:!1,tiffinAfterPeriod:3,tiffinDuration:20}),[d,c]=i.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[g,y]=i.useState(!1),p=i.useMemo(()=>t?Re.master.classes.dropdown:null,[t]),{data:m}=H(p?[p,t]:null,([T,U])=>K(T,U)),A=i.useMemo(()=>Kn(m).map(T=>({value:T?.value??T?.id,label:T?.label??T?.title??""})),[m]),C=i.useMemo(()=>!t||!s.classId?null:`${Re.master.sections.byClass}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:b}=H(C?[C,t]:null,([T,U])=>K(T,U)),f=i.useMemo(()=>Kn(b).map(T=>({value:T?.value??T?.id,label:T?.label??T?.title??""})),[b]),x=i.useMemo(()=>!t||!s.classId?null:`${Re.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:R}=H(x?[x,t]:null,([T,U])=>K(T,U)),k=i.useMemo(()=>Kn(R).map(T=>({value:T?.value??T?.id,label:T?.label??T?.title??""})),[R]),O=i.useMemo(()=>Array.isArray(d?.[s.dayKey])?d[s.dayKey]:[],[s.dayKey,d]),D=i.useCallback((T,U,j)=>{c(P=>{const I={...P},N=Array.isArray(I[T])?I[T].slice():[];return N[U]={...N[U]??{},...j},I[T]=N,I})},[]),_=i.useCallback((T,U)=>{c(j=>{const P={...j},I=Array.isArray(P[T])?P[T].slice():[];return I.splice(U,1),P[T]=I.map((N,V)=>({...N,order_no:V+1})),P})},[]),u=i.useCallback(T=>{c(U=>{const j={...U},P=Array.isArray(j[T])?j[T].slice():[];let I=null,N=null;const V=P[P.length-1];if(V?.time_to){const W=cl(V.time_to),B=Number.parseInt(l.interval,10)||0,$=Number.parseInt(l.duration,10)||0,M=Na(W,B),L=$>0?Na(M,$):null;I=M?.isValid?.()?M.format("HH:mm:ss"):null,N=L?.isValid?.()?L.format("HH:mm:ss"):null}return P.push({order_no:P.length+1,subject_id:"",teacher_id:"",room_no:l.roomNo??"",time_from:I,time_to:N,is_break:!1}),j[T]=P,j})},[l.duration,l.interval,l.roomNo]),h=i.useCallback(()=>{const T=l.startTime,U=l.endTime,j=Number.parseInt(l.duration,10),P=Number.parseInt(l.interval,10);if(!T||!T.isValid?.()){w.error("Start time is required",{duration:1500});return}if(!U||!U.isValid?.()){w.error("End time is required",{duration:1500});return}if(!U.isAfter(T)){w.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(j)||j<=0){w.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(P)||P<0){w.error("Interval must be 0 or more",{duration:1500});return}const I=()=>{const N=[];let V=T;for(let W=0;W<50;W+=1){const B=Na(V,j);if(!B||!B.isValid?.()||B.isAfter(U))break;N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:l.roomNo??"",time_from:V.format("HH:mm:ss"),time_to:B.format("HH:mm:ss"),is_break:!1});const $=Na(B,P);if(!$||!$.isValid?.()||$.isAfter(U)||$.isSame(U))break;V=$}if(l.tiffinEnabled){const W=Math.max(0,Number.parseInt(l.tiffinAfterPeriod,10)||0),B=Math.max(0,Number.parseInt(l.tiffinDuration,10)||0),$=Math.min(W,N.length);if($>0&&B>0){const M=N[$-1],L=M?.time_to?cl(M.time_to):null,Y=L?Na(L,B):null;L?.isValid?.()&&Y?.isValid?.()&&!Y.isAfter(U)&&N.splice($,0,{order_no:$+1,subject_id:"",teacher_id:"",room_no:l.roomNo??"",time_from:L.format("HH:mm:ss"),time_to:Y.format("HH:mm:ss"),is_break:!0})}}return N.map((W,B)=>({...W,order_no:B+1}))};c(N=>{const V={...N};return Object.keys(Ya).forEach(W=>{s.daysEnabled?.[W]&&(V[W]=I())}),V}),w.success("Generated schedule",{duration:1e3})},[l,s.daysEnabled]),S=i.useCallback(()=>{const T=localStorage.getItem("genrall_settings"),j=(T?JSON.parse(T):{})?.session_id??"1",P=s.classId,I=s.sectionId,N=Object.keys(Ya).map(V=>{const W=(Array.isArray(d?.[V])?d[V]:[]).map((B,$)=>({order_no:$+1,subject_id:B?.is_break?0:B?.subject_id??null,teacher_id:B?.is_break?0:B?.teacher_id??null,room_no:B?.room_no??"",time_from:B?.time_from??null,time_to:B?.time_to??null,is_break:B?.is_break?1:0}));return{day:Ya[V],class_id:P,section_id:I,session_id:j,args:W}});return{class_id:P,section_id:I,session_id:j,days:N}},[s.classId,s.sectionId,d]),E=i.useCallback(async()=>{if(!s.classId||!s.sectionId){w.error("Please select Class and Section",{duration:1500});return}const T=S(),U=Array.isArray(T?.days)?T.days:[];if(!U.some(I=>Array.isArray(I?.args)&&I.args.length>0)){w.error("No timetable rows to submit",{duration:1500});return}const P=I=>{const N=I?.is_break;return N===1||N==="1"||N===!0?!0:String(N??"").toLowerCase()==="true"};U.some(I=>(Array.isArray(I?.args)?I.args:[]).some(N=>String(N?.time_from??"").trim()&&String(N?.time_to??"").trim()?P(N)?!1:!String(N?.subject_id??"").trim()||!String(N?.teacher_id??"").trim():!0)),y(!0);try{const I=us.save,N=I==="api/timetable/save"?"timetable/save":null,V=async $=>{const M=await ss($,T,t);if(M&&typeof M=="object")return M;throw new Error("No response from server")};let W;try{W=await V(I)}catch{W=await V(N)}const B=String(W?.msg??"");if(String(W?.Status)==="Success"){if(Array.isArray(W?.data)&&W.data.length===0&&B){w.error(B,{duration:3e3});return}w.success(B||"Weekly Time Table added successfully!",{duration:1200});return}w.error(B||"Failed to add time table",{duration:3e3})}catch(I){w.error(I?.response?.data?.msg??I?.message??"Failed to add time table",{duration:3e3})}finally{y(!1)}},[S,s.classId,s.sectionId,t]),F=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:T=>T?te(T,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:T=>T?te(T,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(T,U,j)=>e.jsx(n.Switch,{checked:!!U?.is_break,onChange:P=>{D(s.dayKey,j,{is_break:P,subject_id:P?"":U?.subject_id??"",teacher_id:P?"":U?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(T,U,j)=>e.jsx(n.Select,{placeholder:U?.is_break?"-":"Select Subject",disabled:!!U?.is_break,style:{width:"100%"},options:k,value:U?.subject_id?String(U.subject_id):void 0,onChange:P=>D(s.dayKey,j,{subject_id:P,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(T,U,j)=>e.jsx(dx,{token:t,classId:s.classId,sectionId:s.sectionId,subjectId:U?.subject_id,disabled:!!U?.is_break||!U?.subject_id,value:U?.teacher_id,onChange:P=>D(s.dayKey,j,{teacher_id:P})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(T,U,j)=>e.jsx(n.Input,{value:U?.room_no??"",onChange:P=>D(s.dayKey,j,{room_no:P.target.value})})},{title:"Action",key:"action",width:90,render:(T,U,j)=>e.jsx(n.Popconfirm,{title:"Delete this row?",onConfirm:()=>_(s.dayKey,j),children:e.jsx(n.Button,{danger:!0,type:"text",children:"Delete"})})}],[s.classId,s.dayKey,s.sectionId,_,k,t,D]),q=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(n.Form,{form:a,layout:"vertical",initialValues:{duration:l.duration,interval:l.interval,roomNo:l.roomNo,tiffinEnabled:l.tiffinEnabled,tiffinAfterPeriod:l.tiffinAfterPeriod,tiffinDuration:l.tiffinDuration},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",required:!0,children:e.jsx(n.Select,{placeholder:"Select Class",options:A,value:s.classId?String(s.classId):void 0,onChange:T=>{r(U=>({...U,classId:T,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Section",required:!0,children:e.jsx(n.Select,{placeholder:"Select Section",options:f,value:s.sectionId?String(s.sectionId):void 0,onChange:T=>r(U=>({...U,sectionId:T})),disabled:!s.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Start Time",required:!0,children:e.jsx(n.TimePicker,{value:l.startTime,onChange:T=>o(U=>({...U,startTime:T})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"End Time",required:!0,children:e.jsx(n.TimePicker,{value:l.endTime,onChange:T=>o(U=>({...U,endTime:T})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(n.InputNumber,{min:1,value:l.duration,onChange:T=>o(U=>({...U,duration:T})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Interval (min)",children:e.jsx(n.InputNumber,{min:0,value:l.interval,onChange:T=>o(U=>({...U,interval:T})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Room No",children:e.jsx(n.Input,{value:l.roomNo,onChange:T=>o(U=>({...U,roomNo:T.target.value}))})}),e.jsx(n.Form.Item,{label:"Tiffin Break",children:e.jsxs(n.Space,{children:[e.jsx(n.Switch,{checked:l.tiffinEnabled,onChange:T=>o(U=>({...U,tiffinEnabled:T}))}),e.jsx(n.Typography.Text,{type:"secondary",children:l.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(n.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:l.tiffinAfterPeriod,onChange:T=>o(U=>({...U,tiffinAfterPeriod:T})),style:{width:"100%"},disabled:!l.tiffinEnabled})}),e.jsx(n.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:l.tiffinDuration,onChange:T=>o(U=>({...U,tiffinDuration:T})),style:{width:"100%"},disabled:!l.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(n.Button,{onClick:h,children:"Generate"}),e.jsx(n.Button,{type:"primary",loading:g,onClick:E,children:"Save"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(n.Space,{children:[e.jsx(n.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(n.Select,{style:{width:160},value:s.dayKey,onChange:T=>r(U=>({...U,dayKey:T})),options:Object.keys(Ya).map(T=>({value:String(T),label:ox(T)}))}),e.jsx(n.Button,{onClick:()=>u(s.dayKey),children:"Add Row"})]}),children:e.jsx(n.Table,{rowKey:(T,U)=>`${s.dayKey}_${U}`,columns:F,dataSource:O,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(n.Tabs,{type:"card",items:[{key:"create",label:"Create",children:q},{key:"routine",label:"Routine",children:e.jsx(nx,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(lx,{token:t})}]})]})}function ux({token:t}){return e.jsx(cx,{token:t})}function px(){return null}const ta=t=>t??localStorage.getItem("authToken")??"",mx=(t,a)=>{const s=String(t??""),r=String(a);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},jt={organization:{get:"api/branchapi/generalSettings/getorganizationsettingsData",save:"api/branchapi/generalSettings/addorganizationSetting",currencyDropdown:"api/branchapi/generalSettings/currencyDropdown",countryCodeDropdown:"api/branchapi/generalSettings/contrycodeDropdown",timezoneDropdown:"api/branchapi/generalSettings/timezoneDropdown",boardsDropdown:"api/branchapi/generalSettings/getAffliatedBoardsDropDown",uploadLogo:"api/superAdmin/upload_logo",uploadSignature:"api/branchapi/generalSettings/upload_signature",uploadFirebaseJson:"api/branchapi/generalSettings/firebaseJsonUpload"},academicYear:{table:"api/branchapi/generalSettings/sessiontable",add:"api/branchapi/generalSettings/addsession",setActive:"api/branchapi/generalSettings/setsession",remove:"api/branchapi/generalSettings/deletesession"},feeReceiptSetting:{get:"api/branchapi/generalSettings/feesReceiptSettingData",save:"api/branchapi/generalSettings/feesReceiptSetting"},marksheetSetting:{templateTypes:"api/branchapi/GeneralSettings/getmarkssheetTemplate",classDropdown:"api/exam/exam/getClassforAssignMarksSheetType",assignedTable:"api/branchapi/GeneralSettings/getassign_templete",assign:"api/branchapi/GeneralSettings/assign_templete",remove:"api/branchapi/GeneralSettings/deleteTemplate"},legalPages:{get:"api/branchapi/generalSettings/getlegalpage",termsSave:"api/branchapi/generalSettings/terms",privacySave:"api/branchapi/generalSettings/privacy",aboutSave:"api/branchapi/generalSettings/about_us"},feesInfo:{get:"api/branchapi/generalSettings/getFeesInfo",save:"api/branchapi/generalSettings/addFeesInfo",statesDropdown:"api/superAdmin/states"},payrollSettings:{table:"api/branchapi/GeneralSettings/getsetting_allowances_dedection",add:"api/branchapi/GeneralSettings/addsetting_allowances_dedection",edit:"api/branchapi/GeneralSettings/updatesetting_allowances_dedection",remove:"api/branchapi/GeneralSettings/deletesetting_allowances_dedection",byId:"api/branchapi/GeneralSettings/getsetting_allowances_dedectionById"},paymentGateway:{get:"api/payment_gateway/PaymentProcess/getPaymentGatewayList",save:"api/payment_gateway/PaymentProcess"}},hx=t=>mx(bt(),t),fx=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const l=t.includes("?")?"&":"?",o=`${t}${l}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(o,ta(r))},yx=async(t,a)=>K(t,ta(a)),dn=async(t,a,s)=>Ne(t,a,ta(s)),Co=async(t,a,s)=>We(t,a,ta(s)),ur=async(t,a,s)=>He(t,a,ta(s)),gx=async(t,a,s)=>ss(t,{arg:a},ta(s)),Ao=async(t,a,s)=>Ha(t,{arg:a},ta(s)),Do=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>H(r&&t?[t,a,s,r]:null,([o,d,c,g])=>fx({baseUrl:o,page:d,perPage:c},g)),St=({url:t,token:a})=>H(a&&t?[t,a]:null,([r,l])=>yx(r,l)),xx={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function bx({value:t,onChange:a,placeholder:s}){const[r,l]=i.useState(t??""),o=i.useMemo(()=>typeof t=="string"?t:r,[r,t]);return e.jsx("div",{style:xx,children:e.jsx(Xl,{html:o||"",onChange:d=>{const c=d?.target?.value??"";l(c),a?.(c)},style:{outline:"none",minHeight:280},placeholder:s})})}function Ht({title:t,actions:a,children:s,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:s})}const jx=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function pr({token:t,title:a,fetchUrl:s,saveUrl:r,fieldName:l,initialHtmlFieldName:o}){const d=i.useRef(null),c=St({url:s,token:t}),y=i.useMemo(()=>jx(c.data),[c.data])?.[o??l]??"",[p,m]=i.useState("");i.useEffect(()=>{m(typeof y=="string"?y:"")},[y]);const A=()=>m(typeof y=="string"?y:""),C=()=>{const x=new Blob([String(p??"")],{type:"text/html"}),R=URL.createObjectURL(x),k=document.createElement("a");k.href=R,k.download=`${String(a??"legal").toLowerCase().replaceAll(" ","-")}.html`,k.click(),URL.revokeObjectURL(R)},b=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:A},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:C,disabled:!p}],[p,y]),f=async x=>{x.preventDefault();try{(await Ao(r,{[l]:p??""},t))?.Status==="Success"?w.success("Updated successfully.",{duration:1e3}):w.success("Updated.",{duration:1e3}),c.mutate?.()}catch(R){w.error(R?.response?.data?.msg??R?.message??"Failed to update.",{duration:1500})}};return c.isLoading&&!c.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ht,{title:a,actions:b,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:f,children:[e.jsx(bx,{value:p,onChange:m,placeholder:`Enter ${a} content...`}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Update"})})]})})})]})}const Sx=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",vx=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function Va({token:t,value:a,onChange:s,action:r,accept:l,maxCount:o=1,previewUrl:d,data:c}){const g=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),y=i.useMemo(()=>a?d||(vx(a)?a:""):"",[d,a]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[y?e.jsx("img",{src:y,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(n.Upload,{maxCount:o,action:r,data:c,accept:l,headers:g,onChange:p=>{if(p?.file?.status==="removed"&&s?.(""),p?.file?.status==="done"){const m=Sx(p?.file?.response);m&&s?.(m)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})]})}const aa=jt.organization,wx=()=>hx(aa.uploadFirebaseJson),_x=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],Cx=({token:t})=>St({url:aa.get,token:t}),Ax=({token:t})=>St({url:aa.currencyDropdown,token:t}),Dx=({token:t})=>St({url:aa.countryCodeDropdown,token:t}),Tx=({token:t})=>St({url:aa.timezoneDropdown,token:t}),Rx=({token:t})=>St({url:aa.boardsDropdown,token:t}),Pn=t=>_x(t?.data),Ix=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},To=t=>{const a=$t(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},kx=(t,a)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=To(a),l=s.startsWith("/")?s.slice(1):s;return Ix(Ke(),`uploads/school_${r}/schoolFile/${l}`)},ul={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Px=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),pl=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],ml=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],Ox=t=>{const a=t?.data;return Array.isArray(a?.data)?a.data[0]??null:Array.isArray(a)?a[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},Mx=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,Ex=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function $x({token:t}){const a=i.useRef(null),s=Cx({token:t}),r=Ax({token:t}),l=Dx({token:t}),o=Tx({token:t}),d=Rx({token:t}),c=i.useMemo(()=>Ox(s.data),[s.data]),g=i.useMemo(()=>Mx(s.data),[s.data]),y=i.useMemo(()=>Ex(s.data),[s.data]),p=i.useMemo(()=>Pn(r),[r.data]),m=i.useMemo(()=>Pn(l),[l.data]),A=i.useMemo(()=>Pn(o),[o.data]),C=i.useMemo(()=>Pn(d),[d.data]),[b,f]=i.useState(null),[x,R]=i.useState(null),[k,O]=i.useState(null),[D,_]=i.useState(null),[u,h]=i.useState([]),[S,E]=i.useState("No"),[F,q]=i.useState("yes"),[T,U]=i.useState("no"),[j,P]=i.useState("Yes"),[I,N]=i.useState(""),[V,W]=i.useState(""),[B,$]=i.useState(!1),[M,L]=i.useState(""),[Y,se]=i.useState(null),[X,G]=i.useState(null),[J,re]=i.useState(null),[de,Ce]=i.useState(null),le=()=>{const be=(()=>{try{const ve=c?.weekly_off;if(!ve)return[];const Oe=Array.isArray(ve)?ve:JSON.parse(ve);return Array.isArray(Oe)?Oe.filter(Boolean).map(Ye=>({value:Ye,label:Ye})):[]}catch{return[]}})();h(be),f(p.find(ve=>ve?.value===c?.currency)??null),R(m.find(ve=>ve?.value===c?.country_code)??null),O(A.find(ve=>ve?.value===c?.time_zone)??null),_(C.find(ve=>ve?.value===c?.affliated_board_id)??null),N(c?.logo??""),W(c?.json_file??""),E(c?.attendance_salary_calculation??"No"),q(c?.salary_period??"yes"),U(c?.multiple_shift??"no"),P(c?.readmission_charges??"Yes"),se(g?.in_from?te(g.in_from,"h:mm A"):null),G(g?.in_to?te(g.in_to,"h:mm A"):null),re(g?.out_from?te(g.out_from,"h:mm A"):null),Ce(g?.out_to?te(g.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&le()},[c,p,m,A,C]);const oe=()=>{a.current?.reset?.(),le()},ie=()=>{const be=new FormData(a.current??void 0),ve=Object.fromEntries(be.entries());ve.weekly_off_day=u.map(Le=>Le?.value).filter(Boolean);const Oe=new Blob([JSON.stringify(ve,null,2)],{type:"application/json"}),Ye=URL.createObjectURL(Oe),Be=document.createElement("a");Be.href=Ye,Be.download="organization-setting.json",Be.click(),URL.revokeObjectURL(Ye)},Se=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:oe},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:ie,disabled:!c}],[c,u]),Ee=async be=>{be.preventDefault();try{const ve=new FormData(be.target);ve.set("currency",b?.value??""),ve.set("code",x?.value??""),ve.set("time_zone",k?.value??""),ve.set("affliated_board_id",D?.value??""),ve.set("board_name",D?.label??""),ve.set("attendance_salary_calculation",S),ve.set("salary_period",F),ve.set("multiple_shift",T),ve.set("readmission_charges",j),u.forEach(Be=>{Be?.value&&ve.append("weekly_off_day[]",Be.value)}),ve.set("logo",I??""),ve.set("json_file",V??""),ve.set("server_key",y?.server_key??""),ve.set("in_time_start",Y?te(Y).format("h:mm A"):""),ve.set("in_time_end",X?te(X).format("h:mm A"):""),ve.set("out_time_start",J?te(J).format("h:mm A"):""),ve.set("out_time_end",de?te(de).format("h:mm A"):""),await dn(aa.save,ve,t);const Ye={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:I||c?.logo||"",affliated_board_id:D?.value??c?.affliated_board_id??"",board_name:D?.label??c?.board_name??"",multiple_shift:T??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(Ye)),w.success("Organization settings saved.",{duration:1e3}),s.mutate?.()}catch(ve){w.error(ve?.response?.data?.msg??ve?.message??"Failed to save settings.",{duration:1500})}},Xe=S==="Yes";return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ht,{title:"Organization",actions:Se,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:a,onSubmit:Ee,children:[e.jsxs("div",{style:ul,children:[e.jsx(z,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(Q,{label:"Currency*",options:p,value:b,onChange:be=>f(be)}),e.jsx("input",{type:"hidden",name:"currency",value:b?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Default Country Code*",options:m,value:x,onChange:be=>R(be)}),e.jsx("input",{type:"hidden",name:"code",value:x?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Time Zone*",options:A,value:k,onChange:be=>O(be)}),e.jsx("input",{type:"hidden",name:"time_zone",value:k?.value??""})]}),e.jsx(z,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(z,{type:"number",name:"admission_start_number",label:"Admission Start Number*",required:!0,defaultValue:c?.admission_no_prefix??c?.admission_start_number??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Re-admission Charges"}),e.jsx(n.Radio.Group,{options:pl,optionType:"button",buttonStyle:"solid",value:j,onChange:be=>P(be.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:j})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Weekly off Day",options:Px,isMulti:!0,value:u,onChange:be=>h(be??[])}),u.map(be=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:be.value},be.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:Y,onChange:be=>se(be),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:Y?te(Y).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:X,onChange:be=>G(be),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:X?te(X).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:J,onChange:be=>re(be),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:J?te(J).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:de,onChange:be=>Ce(be),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:de?te(de).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Period"}),e.jsx(n.Radio.Group,{options:ml,optionType:"button",buttonStyle:"solid",value:F,onChange:be=>q(be.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:F})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(n.Radio.Group,{options:pl,optionType:"button",buttonStyle:"solid",value:S,onChange:be=>E(be.target.value)}),e.jsx("input",{type:"hidden",name:"attendance_salary_calculation",value:S})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Multiple Shift"}),e.jsx(n.Radio.Group,{options:ml,optionType:"button",buttonStyle:"solid",value:T,onChange:be=>U(be.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:T})]}),Xe?e.jsx(z,{type:"number",name:"late_absent_day",label:"No of Late",defaultValue:c?.late_absent_day??""}):e.jsx("input",{type:"hidden",name:"late_absent_day",value:""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:ul,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(n.Upload,{action:`${Ke()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${To(t)}/schoolFile`},headers:{Authorization:t},maxCount:1,accept:"image/*",onChange:be=>{if(be.file.status==="removed"&&N(""),be.file.status==="done"){const ve=be.file.response?.data??be.file.response?.file??"";N(String(ve??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:I?"Change":"Upload"})}),I&&e.jsxs("div",{style:{marginTop:8,display:"flex",alignItems:"center",gap:8},children:[e.jsx("a",{style:{fontSize:12,color:"#1677ff",textDecoration:"underline",cursor:"pointer"},onClick:()=>{L(kx(I,t)),$(!0)},children:"View existing logo"}),e.jsx("a",{style:{fontSize:12,color:"#1677ff",textDecoration:"underline",cursor:"pointer"},onClick:()=>N(""),children:"Remove"})]}),e.jsx("input",{type:"hidden",name:"logo",value:I??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Select Affiliated Board",options:C,value:D,onChange:be=>_(be)}),e.jsx("input",{type:"hidden",name:"affliated_board_id",value:D?.value??""}),e.jsx("input",{type:"hidden",name:"board_name",value:D?.label??""})]}),e.jsx(lt,{label:"Address",name:"address",rows:3,defaultValue:c?.location_name??c?.address??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Json for Notification"}),e.jsx(Va,{token:t,action:wx(),value:V,accept:".json",onChange:be=>W(be)}),e.jsx("input",{type:"hidden",name:"json_file",value:V??""})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Modal,{open:B,onCancel:()=>{$(!1),L("")},footer:null,width:500,closable:!0,children:M?e.jsx("img",{src:M,alt:"Organization Logo",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(pe,{children:"No logo found"})})]})}function Fx({token:t}){return e.jsx($x,{token:t})}const Gn=jt.academicYear,Ux=({token:t,page:a=1,perPage:s=10})=>Do({baseUrl:Gn.table,token:t,page:a,perPage:s}),Nx={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Bx=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[],Lx=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function qx({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(()=>{const u=te(),h=te().add(1,"year");return`${u.format("YYYY")}-${h.format("YYYY")}`}),[c,g]=i.useState(te()),[y,p]=i.useState(te().add(1,"year")),{isLoading:m,data:A,mutate:C}=Ux({token:t,page:a.page,perPage:a.rowsPerPage}),b=i.useMemo(()=>Bx(A),[A]),f=i.useMemo(()=>Lx(A,b.length),[A,b.length]),x=async()=>{if(!o){w.error("Session name is required.");return}if(y&&c&&te(y).isBefore(c)){w.error("End date must be after start date.");return}try{const u=new FormData;u.set("name",o),u.set("start_date",c?te(c).format("YYYY-MM-DD"):""),u.set("end_date",y?te(y).format("YYYY-MM-DD"):""),await dn(Gn.add,u,t),w.success("Academic year added.",{duration:1e3}),l(!1),C?.()}catch(u){w.error(u?.response?.data?.msg??u?.message??"Failed to add academic year.",{duration:1500})}},R=async u=>{try{const h=new FormData;h.set("session",String(u)),await Co(Gn.setActive,h,t);const S=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...S,session_id:String(u)})),w.success("Academic year activated.",{duration:1e3}),C?.()}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to activate academic year.",{duration:1500})}},k=async u=>{try{await C(ur(Gn.remove,u,t)),w.success("Academic year deleted.",{duration:1e3})}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to delete academic year.",{duration:1500})}},O=()=>{const u=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),h=URL.createObjectURL(u),S=document.createElement("a");S.href=h,S.download="academic-years.json",S.click(),URL.revokeObjectURL(h)},D=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>l(!0)},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:()=>C?.()},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:O,disabled:b.length===0}],[b.length,C]),_=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name"},{title:"Start Date",dataIndex:"start_date",key:"start_date"},{title:"End Date",dataIndex:"end_date",key:"end_date"},{title:"Active",key:"active",render:(u,h)=>{const S=h.status==="Active";return e.jsxs("span",{children:[e.jsx(n.Popconfirm,{title:S?"Deactivate Academic Year?":"Activate Academic Year?",description:S?"Deactivate is not allowed. Activate another session to switch.":"This will set this year as the current academic session.",onConfirm:()=>{S?w.error("Deactivate is not allowed. Activate another session to switch."):R(h.id)},okText:"Yes",cancelText:"No",children:e.jsx(n.Switch,{checked:S})}),S&&e.jsx(n.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(u,h)=>e.jsx(n.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>k(h.id),okText:"Yes",cancelText:"No",children:e.jsx(n.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,b.length]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ht,{title:"Academic Year",actions:D,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(n.Table,{rowKey:"id",dataSource:b,columns:_,loading:m,pagination:{current:a.page,pageSize:a.rowsPerPage,total:f,showSizeChanger:!0,onChange:(u,h)=>s({page:u,rowsPerPage:Number(h)})}})})}),e.jsx(n.Modal,{open:r,onCancel:()=>l(!1),footer:null,title:"Add Academic Year",children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:Nx,children:[e.jsx(z,{label:"Session Name*",value:o,onChange:u=>d(u.target.value)}),e.jsxs("div",{children:[e.jsx(Ue,{Desplay:"Start Date*",value:c,onChange:u=>g(u),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?te(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(Ue,{Desplay:"End Date*",value:y,onChange:u=>p(u),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:y?te(y).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{value:"Submit",type:"button",onClick:x}),e.jsx(n.Button,{onClick:()=>l(!1),children:"Cancel"})]})]})})]})}function zx({token:t}){return e.jsx(qx,{token:t})}const Ro=jt.feeReceiptSetting,Yx=({token:t})=>St({url:Ro.get,token:t}),Fs={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},Vx=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function Wx({token:t}){const a=i.useRef(null),s=Yx({token:t}),r=i.useMemo(()=>Vx(s.data),[s.data]),[l,o]=i.useState(""),[d,c]=i.useState(!1),[g,y]=i.useState(!1),[p,m]=i.useState(!1),[A,C]=i.useState("0"),[b,f]=i.useState("0"),[x,R]=i.useState("0"),[k,O]=i.useState(!1),[D,_]=i.useState(!1),[u,h]=i.useState(""),[S,E]=i.useState("0"),[F,q]=i.useState("0"),[T,U]=i.useState("0"),[j,P]=i.useState(""),[I,N]=i.useState(!1),V=()=>{o(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),y(String(r?.address??"0")==="1"),m(String(r?.gardian_name??"0")==="1"),C(String(r?.authorized_signatory??"0")),f(String(r?.parent_signatory??"0")),R(String(r?.dynamic_qr_code_device??"0")),O(String(r?.sequence_payment??"0")==="1"),_(String(r?.previois_fees??"0")==="1"),h(r?.title??""),E(String(r?.class_id??"0")),q(String(r?.discount??"0")),U(String(r?.sections??"0")),P(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&V()},[r]);const W=()=>{a.current?.reset?.(),V()},B=()=>{const L={number_of_receipt:l,rollnumber:d?1:0,address:g?1:0,gardianname:p?1:0,authorizedsignatory:A,parentsignatory:b,dynamic_qr_code_device:x,sequence_payment:k?1:0,previois_fees:D?1:0,upfront_payment_months:j,title:u,class_id:S,discount:F,sections:T},Y=new Blob([JSON.stringify(L,null,2)],{type:"application/json"}),se=URL.createObjectURL(Y),X=document.createElement("a");X.href=se,X.download="fee-receipt-setting.json",X.click(),URL.revokeObjectURL(se)},$=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:W},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:B,disabled:!r}],[r,l,d,g,p,A,b,x,k,D,j,u,S,F,T]),M=async L=>{L.preventDefault(),N(!0);try{const Y=new FormData;Y.set("number_of_receipt",String(l??"")),Y.set("rollnumber",d?"1":"0"),Y.set("address",g?"1":"0"),Y.set("gardianname",p?"1":"0"),Y.set("authorizedsignatory",String(A??"0")),Y.set("parentsignatory",String(b??"0")),Y.set("dynamic_qr_code_device",String(x??"0")),Y.set("sequence_payment",k?"1":"0"),Y.set("previois_fees",D?"1":"0"),Y.set("upfront_payment_months",String(j??"")),Y.set("title",String(u??"")),Y.set("class_id",String(S??"0")),Y.set("discount",String(F??"0")),Y.set("sections",String(T??"0")),await dn(Ro.save,Y,t),w.success("Fee receipt settings updated.",{duration:1e3}),s.mutate?.()}catch(Y){w.error(Y?.response?.data?.msg??Y?.message??"Failed to update settings.",{duration:1500})}finally{N(!1)}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ht,{title:"Fee Receipt Setting",actions:$,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:a,onSubmit:M,children:[e.jsxs("div",{style:Fs,children:[e.jsx(z,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:l,onChange:L=>o(L.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(n.Checkbox,{checked:d,onChange:L=>c(L.target.checked),children:"Show Roll Number in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Address"}),e.jsx(n.Checkbox,{checked:g,onChange:L=>y(L.target.checked),children:"Show address in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Guardian Name"}),e.jsx(n.Checkbox,{checked:p,onChange:L=>m(L.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Fs,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(n.Radio.Group,{value:A,onChange:L=>C(L.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Parent Signatory"}),e.jsxs(n.Radio.Group,{value:b,onChange:L=>f(L.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Dynamic QR Code Device"}),e.jsxs(n.Radio.Group,{value:x,onChange:L=>R(L.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Fs,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(n.Checkbox,{checked:k,onChange:L=>O(L.target.checked),children:"Student can pay in sequence"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Previous Fees"}),e.jsx(n.Checkbox,{checked:D,onChange:L=>_(L.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(z,{type:"text",name:"title",label:"Title",value:u,onChange:L=>h(L.target.value)}),e.jsxs("div",{style:{display:"none"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Class"}),e.jsxs(n.Radio.Group,{value:S,onChange:L=>E(L.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Discount"}),e.jsxs(n.Radio.Group,{value:F,onChange:L=>q(L.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sections"}),e.jsxs(n.Radio.Group,{value:T,onChange:L=>U(L.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsx(z,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:j,onChange:L=>P(L.target.value)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:I?"Updating...":"Done",disabled:I})})]})})})]})}function Hx({token:t}){return e.jsx(Wx,{token:t})}const Ga=jt.marksheetSetting,Kx=({token:t})=>St({url:Ga.templateTypes,token:t}),Gx=({token:t})=>St({url:Ga.classDropdown,token:t}),Jx=({token:t})=>St({url:Ga.assignedTable,token:t}),Qx={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},hl=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],Xx=Array.from({length:12},(t,a)=>({value:String(a+1),label:`Design ${a+1}`})),Zx=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function eb({token:t}){const a=i.useRef(null),s=Kx({token:t}),r=Gx({token:t}),l=Jx({token:t}),o=i.useMemo(()=>hl(s.data),[s.data]),d=i.useMemo(()=>hl(r.data),[r.data]),c=i.useMemo(()=>Zx(l.data),[l.data]),[g,y]=i.useState(null),[p,m]=i.useState(null),[A,C]=i.useState([]),b=()=>{a.current?.reset?.(),y(null),m(null),C([])},f=()=>{const D=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),_=URL.createObjectURL(D),u=document.createElement("a");u.href=_,u.download="marksheet-templates.json",u.click(),URL.revokeObjectURL(_)},x=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:b},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:f,disabled:c.length===0}],[c.length]),R=async D=>{if(D.preventDefault(),!g?.value){w.error("Select marksheet type.",{duration:1200});return}if(!p?.value){w.error("Select design.",{duration:1200});return}if(!A?.length){w.error("Select at least one class.",{duration:1200});return}try{const _=new FormData;_.set("temp_id",String(g.value)),_.set("ui_id",String(p.value)),A.forEach(u=>_.append("class_id[]",String(u))),await dn(Ga.assign,_,t),w.success("Marksheet template assigned.",{duration:1e3}),l.mutate?.(),b()}catch(_){w.error(_?.response?.data?.msg??_?.message??"Failed to assign template.",{duration:1500})}},k=async D=>{try{await ur(Ga.remove,D,t),w.success("Template removed.",{duration:1e3}),l.mutate?.()}catch(_){w.error(_?.response?.data?.msg??_?.message??"Failed to remove template.",{duration:1500})}},O=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class"},{title:"Template Name",dataIndex:"name",key:"name"},{title:"Template Design",dataIndex:"ui_id",key:"ui_id"},{title:"Action",key:"action",render:(D,_)=>e.jsx(yt,{id:_?.id,funcName:k})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ht,{title:"Marksheet Setting",actions:x,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:a,onSubmit:R,children:[e.jsxs("div",{style:Qx,children:[e.jsxs("div",{children:[e.jsx(Q,{label:"Select Marksheet Type",options:o,value:g,onChange:D=>y(D)}),e.jsx("input",{type:"hidden",name:"temp_id",value:g?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Select Design",options:Xx,value:p,onChange:D=>m(D)}),e.jsx("input",{type:"hidden",name:"ui_id",value:p?.value??""})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(n.Checkbox.Group,{options:d,value:A,onChange:D=>C(D)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(n.Table,{size:"small",rowKey:"id",columns:O,dataSource:c,pagination:!1})})]})})]})}function tb({token:t}){return e.jsx(eb,{token:t})}const Us={fetch:`${jt.legalPages.get}?page_name=terms`,save:jt.legalPages.termsSave,fieldName:"terms_data"};function ab({token:t}){return e.jsx(pr,{token:t,title:"Terms",fetchUrl:Us.fetch,saveUrl:Us.save,fieldName:Us.fieldName})}function nb({token:t}){return e.jsx(ab,{token:t})}const Ns={fetch:`${jt.legalPages.get}?page_name=privacy`,save:jt.legalPages.privacySave,fieldName:"privacy_data"};function sb({token:t}){return e.jsx(pr,{token:t,title:"Privacy",fetchUrl:Ns.fetch,saveUrl:Ns.save,fieldName:Ns.fieldName})}function rb({token:t}){return e.jsx(sb,{token:t})}const Bs={fetch:`${jt.legalPages.get}?page_name=about_us`,save:jt.legalPages.aboutSave,fieldName:"about_data"};function ib({token:t}){return e.jsx(pr,{token:t,title:"About",fetchUrl:Bs.fetch,saveUrl:Bs.save,fieldName:Bs.fieldName})}function lb({token:t}){return e.jsx(ib,{token:t})}const mr=jt.feesInfo,ob=({token:t})=>St({url:mr.get,token:t}),db=({token:t})=>St({url:mr.statesDropdown,token:t}),cb=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Wa=t=>{const a=$t(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Io=(t,a,s)=>{const r=`${t||""}`.trim();if(!r)return"";if(/^https?:\/\//i.test(r))return r;const l=Wa(a),o=r.startsWith("/")?r.slice(1):r;return cb(Ke(),`uploads/school_${l}/${s}/${o}`)},Ls={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},ub=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null,pb=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],mb=(t,a)=>t?Io(t,a,"schoolFile"):"",qs=(t,a)=>t?Io(t,a,"schoolFile"):"";function hb({token:t}){const a=i.useRef(null),s=ob({token:t}),r=db({token:t}),l=i.useMemo(()=>ub(s.data),[s.data]),o=i.useMemo(()=>pb(r.data),[r.data]),[d,c]=i.useState(null),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(""),x=u=>{const h=new FormData(u),S=Object.fromEntries(h.entries());return S.state_id=d?.value??"",S.fees_receipt_logo=g,S.manager_signature=p,S.principal_signature=A,S.stamp=b,S},R=()=>{c(o.find(u=>String(u?.value)===String(l?.fk_state_id??l?.state_id??l?.country_code??""))??null),y(l?.logo??l?.fees_receipt_logo??""),m(l?.manager_signature??""),C(l?.principal_signature??""),f(l?.stamp??"")};i.useEffect(()=>{l&&R()},[l,o]);const k=()=>{a.current?.reset?.(),R()},O=()=>{const u=x(a.current),h=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),S=URL.createObjectURL(h),E=document.createElement("a");E.href=S,E.download="fees-info.json",E.click(),URL.revokeObjectURL(S)},D=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:k},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:O,disabled:!l}],[l,d,g,p,A,b]),_=async u=>{u.preventDefault();try{const h=x(u.target);await gx(mr.save,h,t),w.success("Fees info saved.",{duration:1e3}),s.mutate?.()}catch(h){w.error(h?.response?.data?.msg??h?.message??"Failed to save fees info.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ht,{title:"Fees Info",actions:D,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:a,onSubmit:_,children:[e.jsxs("div",{style:Ls,children:[e.jsx(z,{name:"Bussiness_name",label:"Business Name*",defaultValue:l?.name??"",required:!0}),e.jsx(z,{name:"cin",label:"Sub Heading",defaultValue:l?.cin??""}),e.jsx(z,{name:"school_no",type:"number",label:"School Number",defaultValue:l?.school_no??""}),e.jsx(z,{name:"website",label:"Website",defaultValue:l?.website??""}),e.jsx(z,{name:"school_Code",label:"School Code",defaultValue:l?.school_Code??""}),e.jsx(z,{name:"offical_number",label:"Official Number",defaultValue:l?.offical_number??""}),e.jsx(z,{name:"email_id",label:"Email",defaultValue:l?.email_id??""}),e.jsx(z,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:l?.admission_prefix??l?.receipt_prefix??""}),e.jsx(z,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:l?.admission_no_prefix??l?.admission_start_number??l?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(Q,{label:"State",options:o,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(z,{name:"affiliation_no",label:"Affiliation Number",defaultValue:l?.affiliation_no??""}),e.jsx(z,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:l?.affiliation_desc??l?.affliated_description??""}),e.jsx(z,{name:"udise_code",label:"UDISE Code",defaultValue:l?.udise_code??""}),e.jsx(z,{name:"color_code",label:"Primary Color",defaultValue:l?.color_code??""}),e.jsx(z,{name:"fontcolor_code",label:"Font Color",defaultValue:l?.fontcolor_code??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Ls,children:[e.jsx(lt,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:l?.Bussiness_address??l?.bussiness_address??l?.address??l?.location_name??""}),e.jsx(lt,{name:"note",rows:3,label:"Note",defaultValue:l?.note??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Ls,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(Va,{token:t,action:`${Ke()}/uploadfile.php`,data:{filepath:`uploads/school_${Wa(t)}/schoolFile`},value:g,previewUrl:mb(g,t),accept:"image/*",onChange:y}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:g})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(Va,{token:t,action:`${Ke()}/uploadfile.php`,data:{filepath:`uploads/school_${Wa(t)}/schoolFile`},value:p,previewUrl:qs(p,t),accept:"image/*",onChange:m}),e.jsx("input",{type:"hidden",name:"manager_signature",value:p})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Principal Signature"}),e.jsx(Va,{token:t,action:`${Ke()}/uploadfile.php`,data:{filepath:`uploads/school_${Wa(t)}/schoolFile`},value:A,previewUrl:qs(A,t),accept:"image/*",onChange:C}),e.jsx("input",{type:"hidden",name:"principal_signature",value:A})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(Va,{token:t,action:`${Ke()}/uploadfile.php`,data:{filepath:`uploads/school_${Wa(t)}/schoolFile`},value:b,previewUrl:qs(b,t),accept:"image/*",onChange:f}),e.jsx("input",{type:"hidden",name:"stamp",value:b})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})})})]})}function fb({token:t}){return e.jsx(hb,{token:t})}const Jn=jt.payrollSettings,yb=({token:t,page:a=1,perPage:s=10})=>Do({baseUrl:Jn.table,token:t,page:a,perPage:s}),gb={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Ba=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],zs=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],xb=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],bb=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function jb({token:t}){const a=i.useRef(null),s=i.useRef(null),[r,l]=i.useState({page:1,rowsPerPage:10}),[o,d]=i.useState(!1),[c,g]=i.useState(null),[y,p]=i.useState(Ba[0]),[m,A]=i.useState(null),[C,b]=i.useState(null),[f,x]=i.useState(null),[R,k]=i.useState(!1),[O,D]=i.useState(!1),_=yb({token:t,page:r.page,perPage:r.rowsPerPage}),u=i.useMemo(()=>xb(_.data),[_.data]),h=i.useMemo(()=>bb(_.data,u.length),[_.data,u.length]),S=async P=>{P.preventDefault(),D(!0);try{const I=new FormData(P.target);I.set("type",y?.value??""),I.set("amount_type",m?.value??""),await dn(Jn.add,I,t),w.success("Payroll setting added.",{duration:1e3}),_.mutate?.(),P.target.reset(),A(null),p(Ba[0])}catch(I){w.error(I?.response?.data?.msg??I?.message??"Failed to add payroll setting.",{duration:1500})}finally{D(!1)}},E=P=>{g(P),b(Ba.find(I=>I.value===P?.type)??null),x(zs.find(I=>I.value===P?.amount_type)??null),d(!0)},F=async P=>{P.preventDefault(),k(!0);try{const I=new FormData(P.target);I.set("id",String(c?.id??"")),I.set("type",C?.value??""),I.set("amount_type",f?.value??""),await Co(Jn.edit,I,t),w.success("Payroll setting updated.",{duration:1e3}),d(!1),_.mutate?.()}catch(I){w.error(I?.response?.data?.msg??I?.message??"Failed to update payroll setting.",{duration:1500})}finally{k(!1)}},q=async P=>{try{await ur(Jn.remove,P,t),w.success("Payroll setting deleted.",{duration:1e3}),_.mutate?.()}catch(I){w.error(I?.response?.data?.msg??I?.message??"Failed to delete payroll setting.",{duration:1500})}},T=()=>{const P=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),I=URL.createObjectURL(P),N=document.createElement("a");N.href=I,N.download="payroll-settings.json",N.click(),URL.revokeObjectURL(I)},U=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:()=>_.mutate?.()},{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:T,disabled:u.length===0}],[u.length]),j=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title"},{title:"Type",dataIndex:"type",key:"type"},{title:"Amount Type",dataIndex:"amount_type",key:"amount_type"},{title:"Amount",dataIndex:"Amount",key:"Amount"},{title:"Action",key:"action",render:(P,I)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>E(I)}),e.jsx(n.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>q(I.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ht,{title:"Payroll Settings",actions:U,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:a,onSubmit:S,children:[e.jsxs("div",{style:gb,children:[e.jsx(z,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(Q,{label:"Type",options:Ba,value:y,onChange:p}),e.jsx("input",{type:"hidden",name:"type",value:y?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Amount Type",options:zs,value:m,onChange:A}),e.jsx("input",{type:"hidden",name:"amount_type",value:m?.value??""})]}),e.jsx(z,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(ne,{type:"submit",value:O?"Adding...":"Submit",disabled:O,loading:O})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(n.Table,{rowKey:"id",columns:j,dataSource:u,loading:_.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:h,showSizeChanger:!0,onChange:(P,I)=>l({page:P,rowsPerPage:Number(I)})}})})]})}),e.jsx(n.Drawer,{open:o,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,destroyOnClose:!0,footer:e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:()=>d(!1),disabled:R,children:"Cancel"}),e.jsx(ne,{type:"submit",value:R?"Updating...":"Update",disabled:R,loading:R,form:"payroll-edit-form"})]}),children:e.jsx(n.Spin,{spinning:R,tip:"Updating...",children:e.jsx("form",{id:"payroll-edit-form",ref:s,onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(z,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(Q,{label:"Type",options:Ba,value:C,onChange:b}),e.jsx("input",{type:"hidden",name:"type",value:C?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Amount Type",options:zs,value:f,onChange:x}),e.jsx("input",{type:"hidden",name:"amount_type",value:f?.value??""})]}),e.jsx(z,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""})]})},c?.id??"new")})})]})}function Sb({token:t}){return e.jsx(jb,{token:t})}const ko=jt.paymentGateway,vb=({token:t})=>St({url:ko.get,token:t}),wb=[{id:"Razorpay",title:"Razorpay",fields:["keyId","keySecret"]},{id:"PhonePe",title:"Pine Labs",fields:["merchantId","saltKey","saltIndex"]},{id:"Paytm",title:"HDFC",fields:["merchantId","merchantKey"]},{id:"SabPaisa",title:"SabPaisa",fields:["clientCode","transUserName","transUserPassword","authKey","authIV"]}],Kt={Razorpay:{keyId:"",keySecret:"",isActive:!0},PhonePe:{merchantId:"",saltKey:"",saltIndex:"1",isActive:!1},Paytm:{merchantId:"",merchantKey:"",isActive:!1},SabPaisa:{clientCode:"",transUserName:"",transUserPassword:"",authKey:"",authIV:"",isActive:!1}},fl=t=>{const a=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!a?.data)return Kt;try{const s=JSON.parse(a.data||"{}"),r=s?.data&&typeof s.data=="object"?s.data:s;return{Razorpay:{...Kt.Razorpay,...r?.Razorpay??{}},PhonePe:{...Kt.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...Kt.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...Kt.SabPaisa,...r?.SabPaisa??{}}}}catch{return Kt}};function _b({token:t}){const a=i.useRef(null),s=vb({token:t}),[r,l]=i.useState(Kt);i.useEffect(()=>{s.data&&l(fl(s.data))},[s.data]);const o=(p,m,A)=>{l(C=>({...C,[p]:{...C[p],[m]:A}}))},d=()=>l(fl(s.data)),c=()=>{const p=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),m=URL.createObjectURL(p),A=document.createElement("a");A.href=m,A.download="payment-gateway-settings.json",A.click(),URL.revokeObjectURL(m)},g=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:c}],[r,s.data]),y=async p=>{p.preventDefault();try{await Ao(ko.save,{data:r},t),w.success("Payment gateway settings saved.",{duration:1e3}),s.mutate?.()}catch(m){w.error(m?.response?.data?.msg??m?.message??"Failed to save gateway settings.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ht,{title:"Payment Gateway",actions:g,children:e.jsxs("form",{ref:a,onSubmit:y,style:{display:"grid",gap:20},children:[wb.map(p=>{const m=r[p.id]??{};return e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:p.title}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:500},children:["Enable ",p.title]}),e.jsx(n.Switch,{checked:!!m.isActive,onChange:A=>o(p.id,"isActive",A)})]}),e.jsx(n.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:p.fields.map(A=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:A}),e.jsx(n.Input,{value:m[A]??"",type:A.toLowerCase().includes("secret")||A.toLowerCase().includes("password")?"password":"text",onChange:C=>o(p.id,A,C.target.value)})]},A))})]})},p.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})})]})}function Cb({token:t}){return e.jsx(_b,{token:t})}const Ab=({routes:t=[],onNavigate:a})=>e.jsx(n.Row,{gutter:[16,16],children:t.map((s,r)=>e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(v,{children:e.jsx(xl,{icon:s?.icon??"",title:s?.title??"",path:s?.path??"",onClick:a})})},`${r}route001`))});exports.About=lb;exports.AcademicYear=zx;exports.Academics=Qy;exports.AddBook=gm;exports.AddDriver=om;exports.AddExpense=$y;exports.AddHomework=hm;exports.AddIncome=Dy;exports.AddStaff=Lh;exports.AdmissionEnquiry=Bu;exports.ApplyLeave=Af;exports.AprroveLeaveRequest=bf;exports.AssignByClass=_g;exports.AssignStudentSubject=Ky;exports.AssignStudentToTransport=lm;exports.AssignSubjects=Sg;exports.AssignTimeGroup=Pg;exports.AssignVehicles=Xp;exports.AttendanceDashboard=dy;exports.BookList=xm;exports.BulkUpload=Jy;exports.BuySellProduct=th;exports.Category=Ym;exports.Class=dg;exports.CoScholasticArea=Bg;exports.Complain=Up;exports.CreateTimeGroup=Dg;exports.DailyAttendance=hy;exports.Department=Pf;exports.Designation=Ef;exports.DownloadExpense=Ly;exports.ErpDashboard=Eo;exports.ExpenseHead=Yy;exports.FeeReceiptSetting=Hx;exports.FeesInfo=fb;exports.GatePass=Kp;exports.GeneralSetting=px;exports.Holidays=gg;exports.IncomeHead=Iy;exports.IssueReturn=jm;exports.LeaveType=Rf;exports.LibraryAssignStudent=Sm;exports.LibraryCategory=vm;exports.LibraryRenewalReport=_m;exports.LibraryReport=wm;exports.ManageStock=hh;exports.MarksheetSetting=tb;exports.MedicalReport=Wy;exports.MenuSubmenu=vu;exports.MonthlyReport=gy;exports.Notes=Vg;exports.NpmReport=jh;exports.Organization=Fx;exports.PaymentGateway=Cb;exports.Payroll=hf;exports.PayrollReceiptDetails=Hf;exports.PayrollSettings=Sb;exports.PhoneCallLog=yp;exports.PostalDispatch=vp;exports.PostalReceive=Tp;exports.Privacy=rb;exports.Products=Bm;exports.PromoteStudents=$g;exports.RoutePage=Ab;exports.RouteTimeTable=dm;exports.SearchExpense=qy;exports.SearchIncome=Ty;exports.Sections=sg;exports.SellReports=uh;exports.SetupFrontOffice=Vp;exports.Shift=Uf;exports.StaffAttendance=sf;exports.StaffAttendanceReport=df;exports.StaffDailyAttendance=Yf;exports.StaffDirectory=Wh;exports.StockReport=bh;exports.Stoppage=um;exports.StudentAttendance=uy;exports.StudentLoginCredential=Vy;exports.SubCategory=Jm;exports.Subjects=mg;exports.SubmissionDetails=fm;exports.Syllabus=ex;exports.Terms=nb;exports.TimeTable=ux;exports.TransferCertificate=Jg;exports.TransportBulkUpload=pm;exports.TransportRoutes=Gp;exports.TransportVehicles=Jp;exports.Unit=rh;exports.Vendor=Pm;exports.VisitorBook=lp;exports.YearlyReport=Sy;exports.getImageBaseUrl=Ke;exports.setBaseUrl=xc;exports.setImageBaseUrl=bc;