ubk.erp.webpack 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -7
- package/dist/index.cjs +12 -12
- package/dist/index.d.ts +149 -0
- package/dist/index.js +12061 -4136
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),l=require("antd"),se=require("swr"),h=require("react"),et=require("swr/mutation"),he=require("@ant-design/icons"),ge=require("dayjs"),Qr=require("react-dom/server"),xr=require("react-to-print"),N=require("react-hot-toast"),Sr=require("react-select"),Zr=require("react-barcode"),ea=()=>t.jsxs(l.Card,{style:{borderRadius:16},children:[t.jsx(l.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),t.jsx(l.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),oe=({width:e,height:n,display:r,justifyContent:a,alignItems:s,flexDirection:o,gap:i,style:c,children:x,...p})=>{const d={width:e,height:n,display:r,justifyContent:a,alignItems:s,flexDirection:o,gap:i,...c};return t.jsx("div",{style:d,...p,children:x})},De=({variant:e,fontWeight:n,style:r,children:a,...s})=>{const o=n==="bold"?700:n==="light"?300:n;return e==="h1"?t.jsx(l.Typography.Title,{level:1,style:{fontWeight:o,...r},...s,children:a}):e==="h2"?t.jsx(l.Typography.Title,{level:2,style:{fontWeight:o,...r},...s,children:a}):e==="h3"?t.jsx(l.Typography.Title,{level:3,style:{fontWeight:o,...r},...s,children:a}):e==="h4"?t.jsx(l.Typography.Title,{level:4,style:{fontWeight:o,...r},...s,children:a}):e==="h5"?t.jsx(l.Typography.Title,{level:5,style:{fontWeight:o,...r},...s,children:a}):t.jsx(l.Typography.Text,{style:{fontWeight:o,...r},...s,children:a})};function wr({title:e="",icon:n="",path:r="",onClick:a}){const s=()=>{if(a){a(r);return}typeof window<"u"&&typeof r=="string"&&r.length>0&&window.location.assign(r)};return t.jsxs(l.Card,{hoverable:!0,onClick:s,style:{borderRadius:12,overflow:"hidden",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.10)"},bodyStyle:{padding:0,cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[t.jsx(oe,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:t.jsx("img",{src:n,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),t.jsx(oe,{style:{padding:"0 12px"},children:t.jsx(l.Divider,{style:{margin:0,minWidth:0}})}),t.jsx(oe,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:t.jsx(De,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:e})})]})}function jr(e,n){return function(){return e.apply(n,arguments)}}const{toString:ta}=Object.prototype,{getPrototypeOf:$t}=Object,{iterator:Lt,toStringTag:vr}=Symbol,qt=(e=>n=>{const r=ta.call(n);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),qe=e=>(e=e.toLowerCase(),n=>qt(n)===e),zt=e=>n=>typeof n===e,{isArray:ht}=Array,ft=zt("undefined");function _t(e){return e!==null&&!ft(e)&&e.constructor!==null&&!ft(e.constructor)&&ke(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const _r=qe("ArrayBuffer");function na(e){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(e):n=e&&e.buffer&&_r(e.buffer),n}const ra=zt("string"),ke=zt("function"),Cr=zt("number"),Ct=e=>e!==null&&typeof e=="object",aa=e=>e===!0||e===!1,Ut=e=>{if(qt(e)!=="object")return!1;const n=$t(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(vr in e)&&!(Lt in e)},sa=e=>{if(!Ct(e)||_t(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},oa=qe("Date"),ia=qe("File"),la=e=>!!(e&&typeof e.uri<"u"),ca=e=>e&&typeof e.getParts<"u",da=qe("Blob"),ua=qe("FileList"),pa=e=>Ct(e)&&ke(e.pipe);function fa(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Tn=fa(),Rn=typeof Tn.FormData<"u"?Tn.FormData:void 0,ha=e=>{if(!e)return!1;if(Rn&&e instanceof Rn)return!0;const n=$t(e);if(!n||n===Object.prototype||!ke(e.append))return!1;const r=qt(e);return r==="formdata"||r==="object"&&ke(e.toString)&&e.toString()==="[object FormData]"},ma=qe("URLSearchParams"),[ya,ga,ba,xa]=["ReadableStream","Request","Response","Headers"].map(qe),Sa=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Tt(e,n,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let a,s;if(typeof e!="object"&&(e=[e]),ht(e))for(a=0,s=e.length;a<s;a++)n.call(null,e[a],a,e);else{if(_t(e))return;const o=r?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(a=0;a<i;a++)c=o[a],n.call(null,e[c],c,e)}}function Tr(e,n){if(_t(e))return null;n=n.toLowerCase();const r=Object.keys(e);let a=r.length,s;for(;a-- >0;)if(s=r[a],n===s.toLowerCase())return s;return null}const st=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Rr=e=>!ft(e)&&e!==st;function hn(){const{caseless:e,skipUndefined:n}=Rr(this)&&this||{},r={},a=(s,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=e&&Tr(r,o)||o;Ut(r[i])&&Ut(s)?r[i]=hn(r[i],s):Ut(s)?r[i]=hn({},s):ht(s)?r[i]=s.slice():(!n||!ft(s))&&(r[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&Tt(arguments[s],a);return r}const wa=(e,n,r,{allOwnKeys:a}={})=>(Tt(n,(s,o)=>{r&&ke(s)?Object.defineProperty(e,o,{value:jr(s,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:a}),e),ja=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),va=(e,n,r,a)=>{e.prototype=Object.create(n.prototype,a),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:n.prototype}),r&&Object.assign(e.prototype,r)},_a=(e,n,r,a)=>{let s,o,i;const c={};if(n=n||{},e==null)return n;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!a||a(i,e,n))&&!c[i]&&(n[i]=e[i],c[i]=!0);e=r!==!1&&$t(e)}while(e&&(!r||r(e,n))&&e!==Object.prototype);return n},Ca=(e,n,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=n.length;const a=e.indexOf(n,r);return a!==-1&&a===r},Ta=e=>{if(!e)return null;if(ht(e))return e;let n=e.length;if(!Cr(n))return null;const r=new Array(n);for(;n-- >0;)r[n]=e[n];return r},Ra=(e=>n=>e&&n instanceof e)(typeof Uint8Array<"u"&&$t(Uint8Array)),Oa=(e,n)=>{const a=(e&&e[Lt]).call(e);let s;for(;(s=a.next())&&!s.done;){const o=s.value;n.call(e,o[0],o[1])}},Ea=(e,n)=>{let r;const a=[];for(;(r=e.exec(n))!==null;)a.push(r);return a},Da=qe("HTMLFormElement"),Aa=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,a,s){return a.toUpperCase()+s}),On=(({hasOwnProperty:e})=>(n,r)=>e.call(n,r))(Object.prototype),Pa=qe("RegExp"),Or=(e,n)=>{const r=Object.getOwnPropertyDescriptors(e),a={};Tt(r,(s,o)=>{let i;(i=n(s,o,e))!==!1&&(a[o]=i||s)}),Object.defineProperties(e,a)},ka=e=>{Or(e,(n,r)=>{if(ke(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const a=e[r];if(ke(a)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Ia=(e,n)=>{const r={},a=s=>{s.forEach(o=>{r[o]=!0})};return ht(e)?a(e):a(String(e).split(n)),r},Ma=()=>{},Ua=(e,n)=>e!=null&&Number.isFinite(e=+e)?e:n;function Ba(e){return!!(e&&ke(e.append)&&e[vr]==="FormData"&&e[Lt])}const Na=e=>{const n=new Array(10),r=(a,s)=>{if(Ct(a)){if(n.indexOf(a)>=0)return;if(_t(a))return a;if(!("toJSON"in a)){n[s]=a;const o=ht(a)?[]:{};return Tt(a,(i,c)=>{const x=r(i,s+1);!ft(x)&&(o[c]=x)}),n[s]=void 0,o}}return a};return r(e,0)},Fa=qe("AsyncFunction"),$a=e=>e&&(Ct(e)||ke(e))&&ke(e.then)&&ke(e.catch),Er=((e,n)=>e?setImmediate:n?((r,a)=>(st.addEventListener("message",({source:s,data:o})=>{s===st&&o===r&&a.length&&a.shift()()},!1),s=>{a.push(s),st.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",ke(st.postMessage)),La=typeof queueMicrotask<"u"?queueMicrotask.bind(st):typeof process<"u"&&process.nextTick||Er,qa=e=>e!=null&&ke(e[Lt]),w={isArray:ht,isArrayBuffer:_r,isBuffer:_t,isFormData:ha,isArrayBufferView:na,isString:ra,isNumber:Cr,isBoolean:aa,isObject:Ct,isPlainObject:Ut,isEmptyObject:sa,isReadableStream:ya,isRequest:ga,isResponse:ba,isHeaders:xa,isUndefined:ft,isDate:oa,isFile:ia,isReactNativeBlob:la,isReactNative:ca,isBlob:da,isRegExp:Pa,isFunction:ke,isStream:pa,isURLSearchParams:ma,isTypedArray:Ra,isFileList:ua,forEach:Tt,merge:hn,extend:wa,trim:Sa,stripBOM:ja,inherits:va,toFlatObject:_a,kindOf:qt,kindOfTest:qe,endsWith:Ca,toArray:Ta,forEachEntry:Oa,matchAll:Ea,isHTMLForm:Da,hasOwnProperty:On,hasOwnProp:On,reduceDescriptors:Or,freezeMethods:ka,toObjectSet:Ia,toCamelCase:Aa,noop:Ma,toFiniteNumber:Ua,findKey:Tr,global:st,isContextDefined:Rr,isSpecCompliantForm:Ba,toJSONObject:Na,isAsyncFn:Fa,isThenable:$a,setImmediate:Er,asap:La,isIterable:qa};let re=class Dr extends Error{static from(n,r,a,s,o,i){const c=new Dr(n.message,r||n.code,a,s,o);return c.cause=n,c.name=n.name,n.status!=null&&c.status==null&&(c.status=n.status),i&&Object.assign(c,i),c}constructor(n,r,a,s,o){super(n),Object.defineProperty(this,"message",{value:n,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),a&&(this.config=a),s&&(this.request=s),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:w.toJSONObject(this.config),code:this.code,status:this.status}}};re.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";re.ERR_BAD_OPTION="ERR_BAD_OPTION";re.ECONNABORTED="ECONNABORTED";re.ETIMEDOUT="ETIMEDOUT";re.ERR_NETWORK="ERR_NETWORK";re.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";re.ERR_DEPRECATED="ERR_DEPRECATED";re.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";re.ERR_BAD_REQUEST="ERR_BAD_REQUEST";re.ERR_CANCELED="ERR_CANCELED";re.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";re.ERR_INVALID_URL="ERR_INVALID_URL";re.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const za=null;function mn(e){return w.isPlainObject(e)||w.isArray(e)}function Ar(e){return w.endsWith(e,"[]")?e.slice(0,-2):e}function Kt(e,n,r){return e?e.concat(n).map(function(s,o){return s=Ar(s),!r&&o?"["+s+"]":s}).join(r?".":""):n}function Va(e){return w.isArray(e)&&!e.some(mn)}const Wa=w.toFlatObject(w,{},null,function(n){return/^is[A-Z]/.test(n)});function Vt(e,n,r){if(!w.isObject(e))throw new TypeError("target must be an object");n=n||new FormData,r=w.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,_){return!w.isUndefined(_[m])});const a=r.metaTokens,s=r.visitor||b,o=r.dots,i=r.indexes,c=r.Blob||typeof Blob<"u"&&Blob,x=r.maxDepth===void 0?100:r.maxDepth,p=c&&w.isSpecCompliantForm(n);if(!w.isFunction(s))throw new TypeError("visitor must be a function");function d(u){if(u===null)return"";if(w.isDate(u))return u.toISOString();if(w.isBoolean(u))return u.toString();if(!p&&w.isBlob(u))throw new re("Blob is not supported. Use a Buffer instead.");return w.isArrayBuffer(u)||w.isTypedArray(u)?p&&typeof Blob=="function"?new Blob([u]):Buffer.from(u):u}function b(u,m,_){let P=u;if(w.isReactNative(n)&&w.isReactNativeBlob(u))return n.append(Kt(_,m,o),d(u)),!1;if(u&&!_&&typeof u=="object"){if(w.endsWith(m,"{}"))m=a?m:m.slice(0,-2),u=JSON.stringify(u);else if(w.isArray(u)&&Va(u)||(w.isFileList(u)||w.endsWith(m,"[]"))&&(P=w.toArray(u)))return m=Ar(m),P.forEach(function(k,j){!(w.isUndefined(k)||k===null)&&n.append(i===!0?Kt([m],j,o):i===null?m:m+"[]",d(k))}),!1}return mn(u)?!0:(n.append(Kt(_,m,o),d(u)),!1)}const v=[],S=Object.assign(Wa,{defaultVisitor:b,convertValue:d,isVisitable:mn});function g(u,m,_=0){if(!w.isUndefined(u)){if(_>x)throw new re("Object is too deeply nested ("+_+" levels). Max depth: "+x,re.ERR_FORM_DATA_DEPTH_EXCEEDED);if(v.indexOf(u)!==-1)throw Error("Circular reference detected in "+m.join("."));v.push(u),w.forEach(u,function(C,k){(!(w.isUndefined(C)||C===null)&&s.call(n,C,w.isString(k)?k.trim():k,m,S))===!0&&g(C,m?m.concat(k):[k],_+1)}),v.pop()}}if(!w.isObject(e))throw new TypeError("data must be an object");return g(e),n}function En(e){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(a){return n[a]})}function xn(e,n){this._pairs=[],e&&Vt(e,this,n)}const Pr=xn.prototype;Pr.append=function(n,r){this._pairs.push([n,r])};Pr.toString=function(n){const r=n?function(a){return n.call(this,a,En)}:En;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function Ha(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function kr(e,n,r){if(!n)return e;const a=r&&r.encode||Ha,s=w.isFunction(r)?{serialize:r}:r,o=s&&s.serialize;let i;if(o?i=o(n,s):i=w.isURLSearchParams(n)?n.toString():new xn(n,s).toString(a),i){const c=e.indexOf("#");c!==-1&&(e=e.slice(0,c)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Dn{constructor(){this.handlers=[]}use(n,r,a){return this.handlers.push({fulfilled:n,rejected:r,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){w.forEach(this.handlers,function(a){a!==null&&n(a)})}}const Sn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Ya=typeof URLSearchParams<"u"?URLSearchParams:xn,Ka=typeof FormData<"u"?FormData:null,Ja=typeof Blob<"u"?Blob:null,Xa={isBrowser:!0,classes:{URLSearchParams:Ya,FormData:Ka,Blob:Ja},protocols:["http","https","file","blob","url","data"]},wn=typeof window<"u"&&typeof document<"u",yn=typeof navigator=="object"&&navigator||void 0,Ga=wn&&(!yn||["ReactNative","NativeScript","NS"].indexOf(yn.product)<0),Qa=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Za=wn&&window.location.href||"http://localhost",es=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:wn,hasStandardBrowserEnv:Ga,hasStandardBrowserWebWorkerEnv:Qa,navigator:yn,origin:Za},Symbol.toStringTag,{value:"Module"})),Oe={...es,...Xa};function ts(e,n){return Vt(e,new Oe.classes.URLSearchParams,{visitor:function(r,a,s,o){return Oe.isNode&&w.isBuffer(r)?(this.append(a,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...n})}function ns(e){return w.matchAll(/\w+|\[(\w*)]/g,e).map(n=>n[0]==="[]"?"":n[1]||n[0])}function rs(e){const n={},r=Object.keys(e);let a;const s=r.length;let o;for(a=0;a<s;a++)o=r[a],n[o]=e[o];return n}function Ir(e){function n(r,a,s,o){let i=r[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),x=o>=r.length;return i=!i&&w.isArray(s)?s.length:i,x?(w.hasOwnProp(s,i)?s[i]=w.isArray(s[i])?s[i].concat(a):[s[i],a]:s[i]=a,!c):((!s[i]||!w.isObject(s[i]))&&(s[i]=[]),n(r,a,s[i],o)&&w.isArray(s[i])&&(s[i]=rs(s[i])),!c)}if(w.isFormData(e)&&w.isFunction(e.entries)){const r={};return w.forEachEntry(e,(a,s)=>{n(ns(a),s,r,0)}),r}return null}const dt=(e,n)=>e!=null&&w.hasOwnProp(e,n)?e[n]:void 0;function as(e,n,r){if(w.isString(e))try{return(n||JSON.parse)(e),w.trim(e)}catch(a){if(a.name!=="SyntaxError")throw a}return(r||JSON.stringify)(e)}const Rt={transitional:Sn,adapter:["xhr","http","fetch"],transformRequest:[function(n,r){const a=r.getContentType()||"",s=a.indexOf("application/json")>-1,o=w.isObject(n);if(o&&w.isHTMLForm(n)&&(n=new FormData(n)),w.isFormData(n))return s?JSON.stringify(Ir(n)):n;if(w.isArrayBuffer(n)||w.isBuffer(n)||w.isStream(n)||w.isFile(n)||w.isBlob(n)||w.isReadableStream(n))return n;if(w.isArrayBufferView(n))return n.buffer;if(w.isURLSearchParams(n))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(o){const x=dt(this,"formSerializer");if(a.indexOf("application/x-www-form-urlencoded")>-1)return ts(n,x).toString();if((c=w.isFileList(n))||a.indexOf("multipart/form-data")>-1){const p=dt(this,"env"),d=p&&p.FormData;return Vt(c?{"files[]":n}:n,d&&new d,x)}}return o||s?(r.setContentType("application/json",!1),as(n)):n}],transformResponse:[function(n){const r=dt(this,"transitional")||Rt.transitional,a=r&&r.forcedJSONParsing,s=dt(this,"responseType"),o=s==="json";if(w.isResponse(n)||w.isReadableStream(n))return n;if(n&&w.isString(n)&&(a&&!s||o)){const c=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(n,dt(this,"parseReviver"))}catch(x){if(c)throw x.name==="SyntaxError"?re.from(x,re.ERR_BAD_RESPONSE,this,null,dt(this,"response")):x}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Oe.classes.FormData,Blob:Oe.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};w.forEach(["delete","get","head","post","put","patch"],e=>{Rt.headers[e]={}});const ss=w.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"]),os=e=>{const n={};let r,a,s;return e&&e.split(`
|
|
2
|
-
`).forEach(function(
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...r){const a=new this(n);return r.forEach(s=>a.set(s)),a}static accessor(n){const a=(this[An]=this[An]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=bt(i);a[c]||(fs(s,i),a[c]=!0)}return w.isArray(n)?n.forEach(o):o(n),this}};Ie.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);w.reduceDescriptors(Ie.prototype,({value:e},n)=>{let r=n[0].toUpperCase()+n.slice(1);return{get:()=>e,set(a){this[r]=a}}});w.freezeMethods(Ie);function Xt(e,n){const r=this||Rt,a=n||r,s=Ie.from(a.headers);let o=a.data;return w.forEach(e,function(c){o=c.call(r,o,s.normalize(),n?n.status:void 0)}),s.normalize(),o}function Mr(e){return!!(e&&e.__CANCEL__)}let Ot=class extends re{constructor(n,r,a){super(n??"canceled",re.ERR_CANCELED,r,a),this.name="CanceledError",this.__CANCEL__=!0}};function Ur(e,n,r){const a=r.config.validateStatus;!r.status||!a||a(r.status)?e(r):n(new re("Request failed with status code "+r.status,[re.ERR_BAD_REQUEST,re.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function hs(e){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return n&&n[1]||""}function ms(e,n){e=e||10;const r=new Array(e),a=new Array(e);let s=0,o=0,i;return n=n!==void 0?n:1e3,function(x){const p=Date.now(),d=a[o];i||(i=p),r[s]=x,a[s]=p;let b=o,v=0;for(;b!==s;)v+=r[b++],b=b%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),p-i<n)return;const S=d&&p-d;return S?Math.round(v*1e3/S):void 0}}function ys(e,n){let r=0,a=1e3/n,s,o;const i=(p,d=Date.now())=>{r=d,s=null,o&&(clearTimeout(o),o=null),e(...p)};return[(...p)=>{const d=Date.now(),b=d-r;b>=a?i(p,d):(s=p,o||(o=setTimeout(()=>{o=null,i(s)},a-b)))},()=>s&&i(s)]}const Ft=(e,n,r=3)=>{let a=0;const s=ms(50,250);return ys(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,x=c!=null?Math.min(i,c):i,p=Math.max(0,x-a),d=s(p);a=Math.max(a,x);const b={loaded:x,total:c,progress:c?x/c:void 0,bytes:p,rate:d||void 0,estimated:d&&c?(c-x)/d:void 0,event:o,lengthComputable:c!=null,[n?"download":"upload"]:!0};e(b)},r)},Pn=(e,n)=>{const r=e!=null;return[a=>n[0]({lengthComputable:r,total:e,loaded:a}),n[1]]},kn=e=>(...n)=>w.asap(()=>e(...n)),gs=Oe.hasStandardBrowserEnv?((e,n)=>r=>(r=new URL(r,Oe.origin),e.protocol===r.protocol&&e.host===r.host&&(n||e.port===r.port)))(new URL(Oe.origin),Oe.navigator&&/(msie|trident)/i.test(Oe.navigator.userAgent)):()=>!0,bs=Oe.hasStandardBrowserEnv?{write(e,n,r,a,s,o,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(n)}`];w.isNumber(r)&&c.push(`expires=${new Date(r).toUTCString()}`),w.isString(a)&&c.push(`path=${a}`),w.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),w.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const n=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return n?decodeURIComponent(n[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function xs(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ss(e,n){return n?e.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):e}function Br(e,n,r){let a=!xs(n);return e&&(a||r===!1)?Ss(e,n):n}const In=e=>e instanceof Ie?{...e}:e;function it(e,n){n=n||{};const r=Object.create(null);Object.defineProperty(r,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function a(p,d,b,v){return w.isPlainObject(p)&&w.isPlainObject(d)?w.merge.call({caseless:v},p,d):w.isPlainObject(d)?w.merge({},d):w.isArray(d)?d.slice():d}function s(p,d,b,v){if(w.isUndefined(d)){if(!w.isUndefined(p))return a(void 0,p,b,v)}else return a(p,d,b,v)}function o(p,d){if(!w.isUndefined(d))return a(void 0,d)}function i(p,d){if(w.isUndefined(d)){if(!w.isUndefined(p))return a(void 0,p)}else return a(void 0,d)}function c(p,d,b){if(w.hasOwnProp(n,b))return a(p,d);if(w.hasOwnProp(e,b))return a(void 0,p)}const x={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,allowedSocketPaths:i,responseEncoding:i,validateStatus:c,headers:(p,d,b)=>s(In(p),In(d),b,!0)};return w.forEach(Object.keys({...e,...n}),function(d){if(d==="__proto__"||d==="constructor"||d==="prototype")return;const b=w.hasOwnProp(x,d)?x[d]:s,v=w.hasOwnProp(e,d)?e[d]:void 0,S=w.hasOwnProp(n,d)?n[d]:void 0,g=b(v,S,d);w.isUndefined(g)&&b!==c||(r[d]=g)}),r}const Nr=e=>{const n=it({},e),r=v=>w.hasOwnProp(n,v)?n[v]:void 0,a=r("data");let s=r("withXSRFToken");const o=r("xsrfHeaderName"),i=r("xsrfCookieName");let c=r("headers");const x=r("auth"),p=r("baseURL"),d=r("allowAbsoluteUrls"),b=r("url");if(n.headers=c=Ie.from(c),n.url=kr(Br(p,b,d),e.params,e.paramsSerializer),x&&c.set("Authorization","Basic "+btoa((x.username||"")+":"+(x.password?unescape(encodeURIComponent(x.password)):""))),w.isFormData(a)){if(Oe.hasStandardBrowserEnv||Oe.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(w.isFunction(a.getHeaders)){const v=a.getHeaders(),S=["content-type","content-length"];Object.entries(v).forEach(([g,u])=>{S.includes(g.toLowerCase())&&c.set(g,u)})}}if(Oe.hasStandardBrowserEnv&&(w.isFunction(s)&&(s=s(n)),s===!0||s==null&&gs(n.url))){const S=o&&i&&bs.read(i);S&&c.set(o,S)}return n},ws=typeof XMLHttpRequest<"u",js=ws&&function(e){return new Promise(function(r,a){const s=Nr(e);let o=s.data;const i=Ie.from(s.headers).normalize();let{responseType:c,onUploadProgress:x,onDownloadProgress:p}=s,d,b,v,S,g;function u(){S&&S(),g&&g(),s.cancelToken&&s.cancelToken.unsubscribe(d),s.signal&&s.signal.removeEventListener("abort",d)}let m=new XMLHttpRequest;m.open(s.method.toUpperCase(),s.url,!0),m.timeout=s.timeout;function _(){if(!m)return;const C=Ie.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),j={data:!c||c==="text"||c==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:C,config:e,request:m};Ur(function(Z){r(Z),u()},function(Z){a(Z),u()},j),m=null}"onloadend"in m?m.onloadend=_:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(_)},m.onabort=function(){m&&(a(new re("Request aborted",re.ECONNABORTED,e,m)),m=null)},m.onerror=function(k){const j=k&&k.message?k.message:"Network Error",Q=new re(j,re.ERR_NETWORK,e,m);Q.event=k||null,a(Q),m=null},m.ontimeout=function(){let k=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const j=s.transitional||Sn;s.timeoutErrorMessage&&(k=s.timeoutErrorMessage),a(new re(k,j.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,e,m)),m=null},o===void 0&&i.setContentType(null),"setRequestHeader"in m&&w.forEach(i.toJSON(),function(k,j){m.setRequestHeader(j,k)}),w.isUndefined(s.withCredentials)||(m.withCredentials=!!s.withCredentials),c&&c!=="json"&&(m.responseType=s.responseType),p&&([v,g]=Ft(p,!0),m.addEventListener("progress",v)),x&&m.upload&&([b,S]=Ft(x),m.upload.addEventListener("progress",b),m.upload.addEventListener("loadend",S)),(s.cancelToken||s.signal)&&(d=C=>{m&&(a(!C||C.type?new Ot(null,e,m):C),m.abort(),m=null)},s.cancelToken&&s.cancelToken.subscribe(d),s.signal&&(s.signal.aborted?d():s.signal.addEventListener("abort",d)));const P=hs(s.url);if(P&&Oe.protocols.indexOf(P)===-1){a(new re("Unsupported protocol "+P+":",re.ERR_BAD_REQUEST,e));return}m.send(o||null)})},vs=(e,n)=>{const{length:r}=e=e?e.filter(Boolean):[];if(n||r){let a=new AbortController,s;const o=function(p){if(!s){s=!0,c();const d=p instanceof Error?p:this.reason;a.abort(d instanceof re?d:new Ot(d instanceof Error?d.message:d))}};let i=n&&setTimeout(()=>{i=null,o(new re(`timeout of ${n}ms exceeded`,re.ETIMEDOUT))},n);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(p=>{p.unsubscribe?p.unsubscribe(o):p.removeEventListener("abort",o)}),e=null)};e.forEach(p=>p.addEventListener("abort",o));const{signal:x}=a;return x.unsubscribe=()=>w.asap(c),x}},_s=function*(e,n){let r=e.byteLength;if(r<n){yield e;return}let a=0,s;for(;a<r;)s=a+n,yield e.slice(a,s),a=s},Cs=async function*(e,n){for await(const r of Ts(e))yield*_s(r,n)},Ts=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const n=e.getReader();try{for(;;){const{done:r,value:a}=await n.read();if(r)break;yield a}}finally{await n.cancel()}},Mn=(e,n,r,a)=>{const s=Cs(e,n);let o=0,i,c=x=>{i||(i=!0,a&&a(x))};return new ReadableStream({async pull(x){try{const{done:p,value:d}=await s.next();if(p){c(),x.close();return}let b=d.byteLength;if(r){let v=o+=b;r(v)}x.enqueue(new Uint8Array(d))}catch(p){throw c(p),p}},cancel(x){return c(x),s.return()}},{highWaterMark:2})},Un=64*1024,{isFunction:Dt}=w,Rs=(({Request:e,Response:n})=>({Request:e,Response:n}))(w.global),{ReadableStream:Bn,TextEncoder:Nn}=w.global,Fn=(e,...n)=>{try{return!!e(...n)}catch{return!1}},Os=e=>{e=w.merge.call({skipUndefined:!0},Rs,e);const{fetch:n,Request:r,Response:a}=e,s=n?Dt(n):typeof fetch=="function",o=Dt(r),i=Dt(a);if(!s)return!1;const c=s&&Dt(Bn),x=s&&(typeof Nn=="function"?(g=>u=>g.encode(u))(new Nn):async g=>new Uint8Array(await new r(g).arrayBuffer())),p=o&&c&&Fn(()=>{let g=!1;const u=new r(Oe.origin,{body:new Bn,method:"POST",get duplex(){return g=!0,"half"}}),m=u.headers.has("Content-Type");return u.body!=null&&u.body.cancel(),g&&!m}),d=i&&c&&Fn(()=>w.isReadableStream(new a("").body)),b={stream:d&&(g=>g.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!b[g]&&(b[g]=(u,m)=>{let _=u&&u[g];if(_)return _.call(u);throw new re(`Response type '${g}' is not supported`,re.ERR_NOT_SUPPORT,m)})});const v=async g=>{if(g==null)return 0;if(w.isBlob(g))return g.size;if(w.isSpecCompliantForm(g))return(await new r(Oe.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(w.isArrayBufferView(g)||w.isArrayBuffer(g))return g.byteLength;if(w.isURLSearchParams(g)&&(g=g+""),w.isString(g))return(await x(g)).byteLength},S=async(g,u)=>{const m=w.toFiniteNumber(g.getContentLength());return m??v(u)};return async g=>{let{url:u,method:m,data:_,signal:P,cancelToken:C,timeout:k,onDownloadProgress:j,onUploadProgress:Q,responseType:Z,headers:T,withCredentials:D="same-origin",fetchOptions:R}=Nr(g),U=n||fetch;Z=Z?(Z+"").toLowerCase():"text";let I=vs([P,C&&C.toAbortSignal()],k),H=null;const J=I&&I.unsubscribe&&(()=>{I.unsubscribe()});let pe;try{if(Q&&p&&m!=="get"&&m!=="head"&&(pe=await S(T,_))!==0){let y=new r(u,{method:"POST",body:_,duplex:"half"}),E;if(w.isFormData(_)&&(E=y.headers.get("content-type"))&&T.setContentType(E),y.body){const[A,q]=Pn(pe,Ft(kn(Q)));_=Mn(y.body,Un,A,q)}}w.isString(D)||(D=D?"include":"omit");const M=o&&"credentials"in r.prototype;if(w.isFormData(_)){const y=T.getContentType();y&&/^multipart\/form-data/i.test(y)&&!/boundary=/i.test(y)&&T.delete("content-type")}const z={...R,signal:I,method:m.toUpperCase(),headers:T.normalize().toJSON(),body:_,duplex:"half",credentials:M?D:void 0};H=o&&new r(u,z);let ce=await(o?U(H,R):U(u,z));const W=d&&(Z==="stream"||Z==="response");if(d&&(j||W&&J)){const y={};["status","statusText","headers"].forEach(ee=>{y[ee]=ce[ee]});const E=w.toFiniteNumber(ce.headers.get("content-length")),[A,q]=j&&Pn(E,Ft(kn(j),!0))||[];ce=new a(Mn(ce.body,Un,A,()=>{q&&q(),J&&J()}),y)}Z=Z||"text";let f=await b[w.findKey(b,Z)||"text"](ce,g);return!W&&J&&J(),await new Promise((y,E)=>{Ur(y,E,{data:f,headers:Ie.from(ce.headers),status:ce.status,statusText:ce.statusText,config:g,request:H})})}catch(M){throw J&&J(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new re("Network Error",re.ERR_NETWORK,g,H,M&&M.response),{cause:M.cause||M}):re.from(M,M&&M.code,g,H,M&&M.response)}}},Es=new Map,Fr=e=>{let n=e&&e.env||{};const{fetch:r,Request:a,Response:s}=n,o=[a,s,r];let i=o.length,c=i,x,p,d=Es;for(;c--;)x=o[c],p=d.get(x),p===void 0&&d.set(x,p=c?new Map:Os(n)),d=p;return p};Fr();const jn={http:za,xhr:js,fetch:{get:Fr}};w.forEach(jn,(e,n)=>{if(e){try{Object.defineProperty(e,"name",{value:n})}catch{}Object.defineProperty(e,"adapterName",{value:n})}});const $n=e=>`- ${e}`,Ds=e=>w.isFunction(e)||e===null||e===!1;function As(e,n){e=w.isArray(e)?e:[e];const{length:r}=e;let a,s;const o={};for(let i=0;i<r;i++){a=e[i];let c;if(s=a,!Ds(a)&&(s=jn[(c=String(a)).toLowerCase()],s===void 0))throw new re(`Unknown adapter '${c}'`);if(s&&(w.isFunction(s)||(s=s.get(n))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([x,p])=>`adapter ${x} `+(p===!1?"is not supported by the environment":"is not available in the build"));let c=r?i.length>1?`since :
|
|
4
|
-
`+
|
|
5
|
-
`):" "
|
|
6
|
-
`);return
|
|
7
|
-
`),
|
|
8
|
-
`,
|
|
9
|
-
`+o)}}catch{}}throw a}}_request(n,r){typeof n=="string"?(r=r||{},r.url=n):r=n||{},r=it(this.defaults,r);const{transitional:a,paramsSerializer:s,headers:o}=r;a!==void 0&&Nt.assertOptions(a,{silentJSONParsing:Fe.transitional(Fe.boolean),forcedJSONParsing:Fe.transitional(Fe.boolean),clarifyTimeoutError:Fe.transitional(Fe.boolean),legacyInterceptorReqResOrdering:Fe.transitional(Fe.boolean)},!1),s!=null&&(w.isFunction(s)?r.paramsSerializer={serialize:s}:Nt.assertOptions(s,{encode:Fe.function,serialize:Fe.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Nt.assertOptions(r,{baseUrl:Fe.spelling("baseURL"),withXsrfToken:Fe.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=o&&w.merge(o.common,o[r.method]);o&&w.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),r.headers=Ie.concat(i,o);const c=[];let x=!0;this.interceptors.request.forEach(function(u){if(typeof u.runWhen=="function"&&u.runWhen(r)===!1)return;x=x&&u.synchronous;const m=r.transitional||Sn;m&&m.legacyInterceptorReqResOrdering?c.unshift(u.fulfilled,u.rejected):c.push(u.fulfilled,u.rejected)});const p=[];this.interceptors.response.forEach(function(u){p.push(u.fulfilled,u.rejected)});let d,b=0,v;if(!x){const g=[Ln.bind(this),void 0];for(g.unshift(...c),g.push(...p),v=g.length,d=Promise.resolve(r);b<v;)d=d.then(g[b++],g[b++]);return d}v=c.length;let S=r;for(;b<v;){const g=c[b++],u=c[b++];try{S=g(S)}catch(m){u.call(this,m);break}}try{d=Ln.call(this,S)}catch(g){return Promise.reject(g)}for(b=0,v=p.length;b<v;)d=d.then(p[b++],p[b++]);return d}getUri(n){n=it(this.defaults,n);const r=Br(n.baseURL,n.url,n.allowAbsoluteUrls);return kr(r,n.params,n.paramsSerializer)}};w.forEach(["delete","get","head","options"],function(n){ot.prototype[n]=function(r,a){return this.request(it(a||{},{method:n,url:r,data:(a||{}).data}))}});w.forEach(["post","put","patch"],function(n){function r(a){return function(o,i,c){return this.request(it(c||{},{method:n,headers:a?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}ot.prototype[n]=r(),ot.prototype[n+"Form"]=r(!0)});let ks=class qr{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});const a=this;this.promise.then(s=>{if(!a._listeners)return;let o=a._listeners.length;for(;o-- >0;)a._listeners[o](s);a._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{a.subscribe(c),o=c}).then(s);return i.cancel=function(){a.unsubscribe(o)},i},n(function(o,i,c){a.reason||(a.reason=new Ot(o,i,c),r(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const r=this._listeners.indexOf(n);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const n=new AbortController,r=a=>{n.abort(a)};return this.subscribe(r),n.signal.unsubscribe=()=>this.unsubscribe(r),n.signal}static source(){let n;return{token:new qr(function(s){n=s}),cancel:n}}};function Is(e){return function(r){return e.apply(null,r)}}function Ms(e){return w.isObject(e)&&e.isAxiosError===!0}const gn={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(gn).forEach(([e,n])=>{gn[n]=e});function zr(e){const n=new ot(e),r=jr(ot.prototype.request,n);return w.extend(r,ot.prototype,n,{allOwnKeys:!0}),w.extend(r,n,null,{allOwnKeys:!0}),r.create=function(s){return zr(it(e,s))},r}const Se=zr(Rt);Se.Axios=ot;Se.CanceledError=Ot;Se.CancelToken=ks;Se.isCancel=Mr;Se.VERSION=Lr;Se.toFormData=Vt;Se.AxiosError=re;Se.Cancel=Se.CanceledError;Se.all=function(n){return Promise.all(n)};Se.spread=Is;Se.isAxiosError=Ms;Se.mergeConfig=it;Se.AxiosHeaders=Ie;Se.formToJSON=e=>Ir(w.isHTMLForm(e)?new FormData(e):e);Se.getAdapter=$r.getAdapter;Se.HttpStatusCode=gn;Se.default=Se;const{Axios:Jo,AxiosError:Xo,CanceledError:Go,isCancel:Qo,CancelToken:Zo,VERSION:ei,all:ti,Cancel:ni,isAxiosError:ri,spread:ai,toFormData:si,AxiosHeaders:oi,HttpStatusCode:ii,formToJSON:li,getAdapter:ci,mergeConfig:di}=Se,Us=()=>new Promise(e=>setTimeout(()=>e(),800));let bn=null;const Bs=e=>{bn=e,Ve.defaults.baseURL=vn()},vn=()=>bn||"https://npmapi.ubkerp.com/",Ve=Se.create({baseURL:vn()}),vt=()=>vn(),We=async(e,n,r)=>{const a=await Ve.post(e,n,{headers:{Authorization:r}});if(console.log("ddddfdfdfd",a.data?.Status),a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},le=async(e,n)=>{try{let a=e;if(!e.includes("session_id")){const o=e.includes("?")?"&":"?";a=`${e}${o}session_id=1`}return(await Ve.get(a,{headers:{Authorization:n}})).data}catch(r){throw r.response?.status===401&&console.error("401 Unauthorized"),r}},Ns=async(e,n)=>{const r=await Ve.post(e,"",{headers:{Authorization:n}});if(r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},Fs=async(e,n,r)=>(await Ve.post(e,n,{headers:{Authorization:r}}))?.data,Qt=async(e,n,r)=>{const a=n?.arg;return(await Ve.post(e,a,{headers:{Authorization:r}}))?.data},Zt=async(e,n,r)=>{const a=n?.arg,s=e.includes("?")?"&":"?";return(await Ve.get(e+s,{params:a,headers:{Authorization:r}}))?.data},$s=async(e,n,r)=>{const a=n?.arg,s=e.includes("?")?"&":"?";return(await Ve.get(e+s,{params:a,headers:{Authorization:r}}))?.data},lt=async(e,n,r)=>(await Us(),(await Ve.post(e,n,{headers:{Authorization:r}}))?.data),He=async(e,n,r)=>(await Ve.delete(`${e}/${n}`,{headers:{Authorization:r}})).data,Ls=({token:e,menu:n})=>{const{isLoading:r,data:a}=se(e?["api/sdk/Menus",e]:null,([o,i])=>Ns(o,i)),s=a?.find(o=>o.path===n)?.sub_menu??[];return console.log("menuData",a),t.jsx(l.Row,{gutter:[16,16],children:s?.map((o,i)=>o.dashboard_show==="YES"?t.jsx(l.Col,{xs:24,md:8,lg:8,children:t.jsx(oe,{children:t.jsx(wr,{icon:`${vt()}icons/frontoffice/${o.icons}`,title:o.submenu_name,path:o.menu_key})})},`${i}office001`):null)})};function Vr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ce={},en,zn;function qs(){return zn||(zn=1,en=function e(n,r){if(n===r)return!0;if(n&&r&&typeof n=="object"&&typeof r=="object"){if(n.constructor!==r.constructor)return!1;var a,s,o;if(Array.isArray(n)){if(a=n.length,a!=r.length)return!1;for(s=a;s--!==0;)if(!e(n[s],r[s]))return!1;return!0}if(n.constructor===RegExp)return n.source===r.source&&n.flags===r.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===r.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===r.toString();if(o=Object.keys(n),a=o.length,a!==Object.keys(r).length)return!1;for(s=a;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=a;s--!==0;){var i=o[s];if(!e(n[i],r[i]))return!1}return!0}return n!==n&&r!==r}),en}var At={exports:{}},Pt={exports:{}},me={};var Vn;function zs(){if(Vn)return me;Vn=1;var e=typeof Symbol=="function"&&Symbol.for,n=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,a=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,o=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,x=e?Symbol.for("react.async_mode"):60111,p=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,b=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,g=e?Symbol.for("react.lazy"):60116,u=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,_=e?Symbol.for("react.responder"):60118,P=e?Symbol.for("react.scope"):60119;function C(j){if(typeof j=="object"&&j!==null){var Q=j.$$typeof;switch(Q){case n:switch(j=j.type,j){case x:case p:case a:case o:case s:case b:return j;default:switch(j=j&&j.$$typeof,j){case c:case d:case g:case S:case i:return j;default:return Q}}case r:return Q}}}function k(j){return C(j)===p}return me.AsyncMode=x,me.ConcurrentMode=p,me.ContextConsumer=c,me.ContextProvider=i,me.Element=n,me.ForwardRef=d,me.Fragment=a,me.Lazy=g,me.Memo=S,me.Portal=r,me.Profiler=o,me.StrictMode=s,me.Suspense=b,me.isAsyncMode=function(j){return k(j)||C(j)===x},me.isConcurrentMode=k,me.isContextConsumer=function(j){return C(j)===c},me.isContextProvider=function(j){return C(j)===i},me.isElement=function(j){return typeof j=="object"&&j!==null&&j.$$typeof===n},me.isForwardRef=function(j){return C(j)===d},me.isFragment=function(j){return C(j)===a},me.isLazy=function(j){return C(j)===g},me.isMemo=function(j){return C(j)===S},me.isPortal=function(j){return C(j)===r},me.isProfiler=function(j){return C(j)===o},me.isStrictMode=function(j){return C(j)===s},me.isSuspense=function(j){return C(j)===b},me.isValidElementType=function(j){return typeof j=="string"||typeof j=="function"||j===a||j===p||j===o||j===s||j===b||j===v||typeof j=="object"&&j!==null&&(j.$$typeof===g||j.$$typeof===S||j.$$typeof===i||j.$$typeof===c||j.$$typeof===d||j.$$typeof===m||j.$$typeof===_||j.$$typeof===P||j.$$typeof===u)},me.typeOf=C,me}var ye={};var Wn;function Vs(){return Wn||(Wn=1,process.env.NODE_ENV!=="production"&&(function(){var e=typeof Symbol=="function"&&Symbol.for,n=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,a=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,o=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,x=e?Symbol.for("react.async_mode"):60111,p=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,b=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,g=e?Symbol.for("react.lazy"):60116,u=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,_=e?Symbol.for("react.responder"):60118,P=e?Symbol.for("react.scope"):60119;function C(F){return typeof F=="string"||typeof F=="function"||F===a||F===p||F===o||F===s||F===b||F===v||typeof F=="object"&&F!==null&&(F.$$typeof===g||F.$$typeof===S||F.$$typeof===i||F.$$typeof===c||F.$$typeof===d||F.$$typeof===m||F.$$typeof===_||F.$$typeof===P||F.$$typeof===u)}function k(F){if(typeof F=="object"&&F!==null){var je=F.$$typeof;switch(je){case n:var Re=F.type;switch(Re){case x:case p:case a:case o:case s:case b:return Re;default:var ze=Re&&Re.$$typeof;switch(ze){case c:case d:case g:case S:case i:return ze;default:return je}}case r:return je}}}var j=x,Q=p,Z=c,T=i,D=n,R=d,U=a,I=g,H=S,J=r,pe=o,M=s,z=b,ce=!1;function W(F){return ce||(ce=!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.")),f(F)||k(F)===x}function f(F){return k(F)===p}function y(F){return k(F)===c}function E(F){return k(F)===i}function A(F){return typeof F=="object"&&F!==null&&F.$$typeof===n}function q(F){return k(F)===d}function ee(F){return k(F)===a}function X(F){return k(F)===g}function ne(F){return k(F)===S}function O(F){return k(F)===r}function $(F){return k(F)===o}function K(F){return k(F)===s}function be(F){return k(F)===b}ye.AsyncMode=j,ye.ConcurrentMode=Q,ye.ContextConsumer=Z,ye.ContextProvider=T,ye.Element=D,ye.ForwardRef=R,ye.Fragment=U,ye.Lazy=I,ye.Memo=H,ye.Portal=J,ye.Profiler=pe,ye.StrictMode=M,ye.Suspense=z,ye.isAsyncMode=W,ye.isConcurrentMode=f,ye.isContextConsumer=y,ye.isContextProvider=E,ye.isElement=A,ye.isForwardRef=q,ye.isFragment=ee,ye.isLazy=X,ye.isMemo=ne,ye.isPortal=O,ye.isProfiler=$,ye.isStrictMode=K,ye.isSuspense=be,ye.isValidElementType=C,ye.typeOf=k})()),ye}var Hn;function Wr(){return Hn||(Hn=1,process.env.NODE_ENV==="production"?Pt.exports=zs():Pt.exports=Vs()),Pt.exports}var tn,Yn;function Ws(){if(Yn)return tn;Yn=1;var e=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function a(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function s(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var i={},c=0;c<10;c++)i["_"+String.fromCharCode(c)]=c;var x=Object.getOwnPropertyNames(i).map(function(d){return i[d]});if(x.join("")!=="0123456789")return!1;var p={};return"abcdefghijklmnopqrst".split("").forEach(function(d){p[d]=d}),Object.keys(Object.assign({},p)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return tn=s()?Object.assign:function(o,i){for(var c,x=a(o),p,d=1;d<arguments.length;d++){c=Object(arguments[d]);for(var b in c)n.call(c,b)&&(x[b]=c[b]);if(e){p=e(c);for(var v=0;v<p.length;v++)r.call(c,p[v])&&(x[p[v]]=c[p[v]])}}return x},tn}var nn,Kn;function _n(){if(Kn)return nn;Kn=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return nn=e,nn}var rn,Jn;function Hr(){return Jn||(Jn=1,rn=Function.call.bind(Object.prototype.hasOwnProperty)),rn}var an,Xn;function Hs(){if(Xn)return an;Xn=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var n=_n(),r={},a=Hr();e=function(o){var i="Warning: "+o;typeof console<"u"&&console.error(i);try{throw new Error(i)}catch{}}}function s(o,i,c,x,p){if(process.env.NODE_ENV!=="production"){for(var d in o)if(a(o,d)){var b;try{if(typeof o[d]!="function"){var v=Error((x||"React class")+": "+c+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}b=o[d](i,d,x,c,null,n)}catch(g){b=g}if(b&&!(b instanceof Error)&&e((x||"React class")+": type specification of "+c+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof b+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),b instanceof Error&&!(b.message in r)){r[b.message]=!0;var S=p?p():"";e("Failed "+c+" type: "+b.message+(S??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(r={})},an=s,an}var sn,Gn;function Ys(){if(Gn)return sn;Gn=1;var e=Wr(),n=Ws(),r=_n(),a=Hr(),s=Hs(),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(c){var x="Warning: "+c;typeof console<"u"&&console.error(x);try{throw new Error(x)}catch{}});function i(){return null}return sn=function(c,x){var p=typeof Symbol=="function"&&Symbol.iterator,d="@@iterator";function b(f){var y=f&&(p&&f[p]||f[d]);if(typeof y=="function")return y}var v="<<anonymous>>",S={array:_("array"),bigint:_("bigint"),bool:_("boolean"),func:_("function"),number:_("number"),object:_("object"),string:_("string"),symbol:_("symbol"),any:P(),arrayOf:C,element:k(),elementType:j(),instanceOf:Q,node:R(),objectOf:T,oneOf:Z,oneOfType:D,shape:I,exact:H};function g(f,y){return f===y?f!==0||1/f===1/y:f!==f&&y!==y}function u(f,y){this.message=f,this.data=y&&typeof y=="object"?y:{},this.stack=""}u.prototype=Error.prototype;function m(f){if(process.env.NODE_ENV!=="production")var y={},E=0;function A(ee,X,ne,O,$,K,be){if(O=O||v,K=K||ne,be!==r){if(x){var F=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 F.name="Invariant Violation",F}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var je=O+":"+ne;!y[je]&&E<3&&(o("You are manually calling a React.PropTypes validation function for the `"+K+"` prop on `"+O+"`. 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."),y[je]=!0,E++)}}return X[ne]==null?ee?X[ne]===null?new u("The "+$+" `"+K+"` is marked as required "+("in `"+O+"`, but its value is `null`.")):new u("The "+$+" `"+K+"` is marked as required in "+("`"+O+"`, but its value is `undefined`.")):null:f(X,ne,O,$,K)}var q=A.bind(null,!1);return q.isRequired=A.bind(null,!0),q}function _(f){function y(E,A,q,ee,X,ne){var O=E[A],$=M(O);if($!==f){var K=z(O);return new u("Invalid "+ee+" `"+X+"` of type "+("`"+K+"` supplied to `"+q+"`, expected ")+("`"+f+"`."),{expectedType:f})}return null}return m(y)}function P(){return m(i)}function C(f){function y(E,A,q,ee,X){if(typeof f!="function")return new u("Property `"+X+"` of component `"+q+"` has invalid PropType notation inside arrayOf.");var ne=E[A];if(!Array.isArray(ne)){var O=M(ne);return new u("Invalid "+ee+" `"+X+"` of type "+("`"+O+"` supplied to `"+q+"`, expected an array."))}for(var $=0;$<ne.length;$++){var K=f(ne,$,q,ee,X+"["+$+"]",r);if(K instanceof Error)return K}return null}return m(y)}function k(){function f(y,E,A,q,ee){var X=y[E];if(!c(X)){var ne=M(X);return new u("Invalid "+q+" `"+ee+"` of type "+("`"+ne+"` supplied to `"+A+"`, expected a single ReactElement."))}return null}return m(f)}function j(){function f(y,E,A,q,ee){var X=y[E];if(!e.isValidElementType(X)){var ne=M(X);return new u("Invalid "+q+" `"+ee+"` of type "+("`"+ne+"` supplied to `"+A+"`, expected a single ReactElement type."))}return null}return m(f)}function Q(f){function y(E,A,q,ee,X){if(!(E[A]instanceof f)){var ne=f.name||v,O=W(E[A]);return new u("Invalid "+ee+" `"+X+"` of type "+("`"+O+"` supplied to `"+q+"`, expected ")+("instance of `"+ne+"`."))}return null}return m(y)}function Z(f){if(!Array.isArray(f))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.")),i;function y(E,A,q,ee,X){for(var ne=E[A],O=0;O<f.length;O++)if(g(ne,f[O]))return null;var $=JSON.stringify(f,function(be,F){var je=z(F);return je==="symbol"?String(F):F});return new u("Invalid "+ee+" `"+X+"` of value `"+String(ne)+"` "+("supplied to `"+q+"`, expected one of "+$+"."))}return m(y)}function T(f){function y(E,A,q,ee,X){if(typeof f!="function")return new u("Property `"+X+"` of component `"+q+"` has invalid PropType notation inside objectOf.");var ne=E[A],O=M(ne);if(O!=="object")return new u("Invalid "+ee+" `"+X+"` of type "+("`"+O+"` supplied to `"+q+"`, expected an object."));for(var $ in ne)if(a(ne,$)){var K=f(ne,$,q,ee,X+"."+$,r);if(K instanceof Error)return K}return null}return m(y)}function D(f){if(!Array.isArray(f))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),i;for(var y=0;y<f.length;y++){var E=f[y];if(typeof E!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ce(E)+" at index "+y+"."),i}function A(q,ee,X,ne,O){for(var $=[],K=0;K<f.length;K++){var be=f[K],F=be(q,ee,X,ne,O,r);if(F==null)return null;F.data&&a(F.data,"expectedType")&&$.push(F.data.expectedType)}var je=$.length>0?", expected one of type ["+$.join(", ")+"]":"";return new u("Invalid "+ne+" `"+O+"` supplied to "+("`"+X+"`"+je+"."))}return m(A)}function R(){function f(y,E,A,q,ee){return J(y[E])?null:new u("Invalid "+q+" `"+ee+"` supplied to "+("`"+A+"`, expected a ReactNode."))}return m(f)}function U(f,y,E,A,q){return new u((f||"React class")+": "+y+" type `"+E+"."+A+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+q+"`.")}function I(f){function y(E,A,q,ee,X){var ne=E[A],O=M(ne);if(O!=="object")return new u("Invalid "+ee+" `"+X+"` of type `"+O+"` "+("supplied to `"+q+"`, expected `object`."));for(var $ in f){var K=f[$];if(typeof K!="function")return U(q,ee,X,$,z(K));var be=K(ne,$,q,ee,X+"."+$,r);if(be)return be}return null}return m(y)}function H(f){function y(E,A,q,ee,X){var ne=E[A],O=M(ne);if(O!=="object")return new u("Invalid "+ee+" `"+X+"` of type `"+O+"` "+("supplied to `"+q+"`, expected `object`."));var $=n({},E[A],f);for(var K in $){var be=f[K];if(a(f,K)&&typeof be!="function")return U(q,ee,X,K,z(be));if(!be)return new u("Invalid "+ee+" `"+X+"` key `"+K+"` supplied to `"+q+"`.\nBad object: "+JSON.stringify(E[A],null," ")+`
|
|
10
|
-
Valid keys: `+JSON.stringify(Object.keys(f),null," "));var F=be(ne,K,q,ee,X+"."+K,r);if(F)return F}return null}return m(y)}function J(f){switch(typeof f){case"number":case"string":case"undefined":return!0;case"boolean":return!f;case"object":if(Array.isArray(f))return f.every(J);if(f===null||c(f))return!0;var y=b(f);if(y){var E=y.call(f),A;if(y!==f.entries){for(;!(A=E.next()).done;)if(!J(A.value))return!1}else for(;!(A=E.next()).done;){var q=A.value;if(q&&!J(q[1]))return!1}}else return!1;return!0;default:return!1}}function pe(f,y){return f==="symbol"?!0:y?y["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&y instanceof Symbol:!1}function M(f){var y=typeof f;return Array.isArray(f)?"array":f instanceof RegExp?"object":pe(y,f)?"symbol":y}function z(f){if(typeof f>"u"||f===null)return""+f;var y=M(f);if(y==="object"){if(f instanceof Date)return"date";if(f instanceof RegExp)return"regexp"}return y}function ce(f){var y=z(f);switch(y){case"array":case"object":return"an "+y;case"boolean":case"date":case"regexp":return"a "+y;default:return y}}function W(f){return!f.constructor||!f.constructor.name?v:f.constructor.name}return S.checkPropTypes=s,S.resetWarningCache=s.resetWarningCache,S.PropTypes=S,S},sn}var on,Qn;function Ks(){if(Qn)return on;Qn=1;var e=_n();function n(){}function r(){}return r.resetWarningCache=n,on=function(){function a(i,c,x,p,d,b){if(b!==e){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}a.isRequired=a;function s(){return a}var o={array:a,bigint:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,any:a,arrayOf:s,element:a,elementType:a,instanceOf:s,node:a,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:r,resetWarningCache:n};return o.PropTypes=o,o},on}var Zn;function Yr(){if(Zn)return At.exports;if(Zn=1,process.env.NODE_ENV!=="production"){var e=Wr(),n=!0;At.exports=Ys()(e.isElement,n)}else At.exports=Ks()();return At.exports}var er;function Js(){if(er)return Ce;er=1;var e=Ce&&Ce.__extends||(function(){var S=function(g,u){return S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,_){m.__proto__=_}||function(m,_){for(var P in _)Object.prototype.hasOwnProperty.call(_,P)&&(m[P]=_[P])},S(g,u)};return function(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Class extends value "+String(u)+" is not a constructor or null");S(g,u);function m(){this.constructor=g}g.prototype=u===null?Object.create(u):(m.prototype=u.prototype,new m)}})(),n=Ce&&Ce.__assign||function(){return n=Object.assign||function(S){for(var g,u=1,m=arguments.length;u<m;u++){g=arguments[u];for(var _ in g)Object.prototype.hasOwnProperty.call(g,_)&&(S[_]=g[_])}return S},n.apply(this,arguments)},r=Ce&&Ce.__createBinding||(Object.create?(function(S,g,u,m){m===void 0&&(m=u);var _=Object.getOwnPropertyDescriptor(g,u);(!_||("get"in _?!g.__esModule:_.writable||_.configurable))&&(_={enumerable:!0,get:function(){return g[u]}}),Object.defineProperty(S,m,_)}):(function(S,g,u,m){m===void 0&&(m=u),S[m]=g[u]})),a=Ce&&Ce.__setModuleDefault||(Object.create?(function(S,g){Object.defineProperty(S,"default",{enumerable:!0,value:g})}):function(S,g){S.default=g}),s=Ce&&Ce.__importStar||function(S){if(S&&S.__esModule)return S;var g={};if(S!=null)for(var u in S)u!=="default"&&Object.prototype.hasOwnProperty.call(S,u)&&r(g,S,u);return a(g,S),g},o=Ce&&Ce.__rest||function(S,g){var u={};for(var m in S)Object.prototype.hasOwnProperty.call(S,m)&&g.indexOf(m)<0&&(u[m]=S[m]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function")for(var _=0,m=Object.getOwnPropertySymbols(S);_<m.length;_++)g.indexOf(m[_])<0&&Object.prototype.propertyIsEnumerable.call(S,m[_])&&(u[m[_]]=S[m[_]]);return u},i=Ce&&Ce.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(Ce,"__esModule",{value:!0});var c=s(h),x=i(qs()),p=s(Yr());function d(S){return S&&S.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function b(S){var g=document.createTextNode("");S.appendChild(g);var u=document.activeElement===S;if(g!==null&&g.nodeValue!==null&&u){var m=window.getSelection();if(m!==null){var _=document.createRange();_.setStart(g,g.nodeValue.length),_.collapse(!0),m.removeAllRanges(),m.addRange(_)}S instanceof HTMLElement&&S.focus()}}var v=(function(S){e(g,S);function g(){var u=S!==null&&S.apply(this,arguments)||this;return u.lastHtml=u.props.html,u.el=typeof u.props.innerRef=="function"?{current:null}:c.createRef(),u.getEl=function(){return(u.props.innerRef&&typeof u.props.innerRef!="function"?u.props.innerRef:u.el).current},u.emitChange=function(m){var _=u.getEl();if(_){var P=_.innerHTML;if(u.props.onChange&&P!==u.lastHtml){var C=Object.assign({},m,{target:{value:P}});u.props.onChange(C)}u.lastHtml=P}},u}return g.prototype.render=function(){var u=this,m=this.props,_=m.tagName,P=m.html,C=m.innerRef,k=o(m,["tagName","html","innerRef"]);return c.createElement(_||"div",n(n({},k),{ref:typeof C=="function"?function(j){C(j),u.el.current=j}:C||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:P}}),this.props.children)},g.prototype.shouldComponentUpdate=function(u){var m=this.props,_=this.getEl();return!_||d(u.html)!==d(_.innerHTML)?!0:m.disabled!==u.disabled||m.tagName!==u.tagName||m.className!==u.className||m.innerRef!==u.innerRef||m.placeholder!==u.placeholder||!(0,x.default)(m.style,u.style)},g.prototype.componentDidUpdate=function(){var u=this.getEl();u&&(this.props.html!==u.innerHTML&&(u.innerHTML=this.props.html),this.lastHtml=this.props.html,b(u))},g.propTypes={html:p.string.isRequired,onChange:p.func,disabled:p.bool,tagName:p.string,className:p.string,style:p.object,innerRef:p.oneOfType([p.object,p.func])},g})(c.Component);return Ce.default=v,Ce}var Xs=Js();const Gs=Vr(Xs),Qs={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Zs={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"},ae=h.forwardRef(({style:e,onFocus:n,onBlur:r,...a},s)=>{const[o,i]=h.useState(!1);return t.jsxs("div",{className:"",style:{width:"100%"},children:[a.label&&t.jsx("label",{className:"labelfont",style:Qs,children:a.label}),t.jsx("input",{placeholder:a.placeholder||a.label,...a,ref:s,onFocus:c=>{i(!0),n?.(c)},onBlur:c=>{i(!1),r?.(c)},style:{...Zs,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...e||{}}})]})});function eo(){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 to=e=>{const n=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",e),t.jsxs(t.Fragment,{children:[n?.currency_icon," ",Number(e||0).toLocaleString("en-IN")]})};var xt={},St={},Ue={},wt={},ut={},tr;function no(){if(tr)return ut;tr=1;var e=ut&&ut.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(ut,"__esModule",{value:!0});const n=e(h),r=Qr,a=["string","number","boolean"];function s({header:o,body:i}){const c=n.default.createElement("tr",null,o.map(p=>n.default.createElement("th",{key:p},p))),x=i.map((p,d)=>Array.isArray(p)?n.default.createElement("tr",{key:d},p.map((b,v)=>n.default.createElement("th",{key:v}," ",b," "))):p!==null&&typeof p=="object"?n.default.createElement("tr",{key:d},Object.entries(p).map(([b,v],S)=>typeof v=="object"?(console.error(`typeof ${b} is incorrect, only accept ${a.join(", ")} `),n.default.createElement("th",{key:S})):n.default.createElement("th",{key:S},n.default.createElement(n.default.Fragment,null,v)))):(console.error(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("antd"),K=require("swr"),i=require("react"),He=require("swr/mutation"),re=require("@ant-design/icons"),ye=require("dayjs"),mi=require("react-dom/server"),cn=require("react-to-print"),v=require("react-hot-toast"),vs=require("react-select"),_s=require("react-barcode"),fi=()=>e.jsxs(r.Card,{style:{borderRadius:16},children:[e.jsx(r.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(r.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),de=({width:t,height:n,display:a,justifyContent:s,alignItems:o,flexDirection:l,gap:d,style:u,children:S,...g})=>{const p={width:t,height:n,display:a,justifyContent:s,alignItems:o,flexDirection:l,gap:d,...u};return e.jsx("div",{style:p,...g,children:S})},De=({variant:t,fontWeight:n,style:a,children:s,...o})=>{const l=n==="bold"?700:n==="light"?300:n;return t==="h1"?e.jsx(r.Typography.Title,{level:1,style:{fontWeight:l,...a},...o,children:s}):t==="h2"?e.jsx(r.Typography.Title,{level:2,style:{fontWeight:l,...a},...o,children:s}):t==="h3"?e.jsx(r.Typography.Title,{level:3,style:{fontWeight:l,...a},...o,children:s}):t==="h4"?e.jsx(r.Typography.Title,{level:4,style:{fontWeight:l,...a},...o,children:s}):t==="h5"?e.jsx(r.Typography.Title,{level:5,style:{fontWeight:l,...a},...o,children:s}):e.jsx(r.Typography.Text,{style:{fontWeight:l,...a},...o,children:s})};function Cs({title:t="",icon:n="",path:a="",onClick:s}){const o=()=>{if(s){s(a);return}typeof window<"u"&&typeof a=="string"&&a.length>0&&window.location.assign(a)};return e.jsxs(r.Card,{hoverable:!0,onClick:o,style:{borderRadius:12,overflow:"hidden",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.10)"},bodyStyle:{padding:0,cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[e.jsx(de,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:n,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(de,{style:{padding:"0 12px"},children:e.jsx(r.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(de,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(De,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function Ts(t,n){return function(){return t.apply(n,arguments)}}const{toString:yi}=Object.prototype,{getPrototypeOf:ea}=Object,{iterator:ta,toStringTag:As}=Symbol,na=(t=>n=>{const a=yi.call(n);return t[a]||(t[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),ct=t=>(t=t.toLowerCase(),n=>na(n)===t),aa=t=>n=>typeof n===t,{isArray:Lt}=Array,Bt=aa("undefined");function un(t){return t!==null&&!Bt(t)&&t.constructor!==null&&!Bt(t.constructor)&&Qe(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Is=ct("ArrayBuffer");function hi(t){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(t):n=t&&t.buffer&&Is(t.buffer),n}const gi=aa("string"),Qe=aa("function"),Rs=aa("number"),pn=t=>t!==null&&typeof t=="object",xi=t=>t===!0||t===!1,Un=t=>{if(na(t)!=="object")return!1;const n=ea(t);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(As in t)&&!(ta in t)},bi=t=>{if(!pn(t)||un(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Si=ct("Date"),ji=ct("File"),wi=t=>!!(t&&typeof t.uri<"u"),vi=t=>t&&typeof t.getParts<"u",_i=ct("Blob"),Ci=ct("FileList"),Ti=t=>pn(t)&&Qe(t.pipe);function Ai(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Qa=Ai(),Xa=typeof Qa.FormData<"u"?Qa.FormData:void 0,Ii=t=>{if(!t)return!1;if(Xa&&t instanceof Xa)return!0;const n=ea(t);if(!n||n===Object.prototype||!Qe(t.append))return!1;const a=na(t);return a==="formdata"||a==="object"&&Qe(t.toString)&&t.toString()==="[object FormData]"},Ri=ct("URLSearchParams"),[Di,Oi,Pi,Ei]=["ReadableStream","Request","Response","Headers"].map(ct),Fi=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function mn(t,n,{allOwnKeys:a=!1}={}){if(t===null||typeof t>"u")return;let s,o;if(typeof t!="object"&&(t=[t]),Lt(t))for(s=0,o=t.length;s<o;s++)n.call(null,t[s],s,t);else{if(un(t))return;const l=a?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let u;for(s=0;s<d;s++)u=l[s],n.call(null,t[u],u,t)}}function Ds(t,n){if(un(t))return null;n=n.toLowerCase();const a=Object.keys(t);let s=a.length,o;for(;s-- >0;)if(o=a[s],n===o.toLowerCase())return o;return null}const Ct=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Os=t=>!Bt(t)&&t!==Ct;function ka(){const{caseless:t,skipUndefined:n}=Os(this)&&this||{},a={},s=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&Ds(a,l)||l;Un(a[d])&&Un(o)?a[d]=ka(a[d],o):Un(o)?a[d]=ka({},o):Lt(o)?a[d]=o.slice():(!n||!Bt(o))&&(a[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&mn(arguments[o],s);return a}const ki=(t,n,a,{allOwnKeys:s}={})=>(mn(n,(o,l)=>{a&&Qe(o)?Object.defineProperty(t,l,{value:Ts(o,a),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),t),Mi=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),$i=(t,n,a,s)=>{t.prototype=Object.create(n.prototype,s),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:n.prototype}),a&&Object.assign(t.prototype,a)},Ui=(t,n,a,s)=>{let o,l,d;const u={};if(n=n||{},t==null)return n;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!s||s(d,t,n))&&!u[d]&&(n[d]=t[d],u[d]=!0);t=a!==!1&&ea(t)}while(t&&(!a||a(t,n))&&t!==Object.prototype);return n},Bi=(t,n,a)=>{t=String(t),(a===void 0||a>t.length)&&(a=t.length),a-=n.length;const s=t.indexOf(n,a);return s!==-1&&s===a},Ni=t=>{if(!t)return null;if(Lt(t))return t;let n=t.length;if(!Rs(n))return null;const a=new Array(n);for(;n-- >0;)a[n]=t[n];return a},Li=(t=>n=>t&&n instanceof t)(typeof Uint8Array<"u"&&ea(Uint8Array)),qi=(t,n)=>{const s=(t&&t[ta]).call(t);let o;for(;(o=s.next())&&!o.done;){const l=o.value;n.call(t,l[0],l[1])}},zi=(t,n)=>{let a;const s=[];for(;(a=t.exec(n))!==null;)s.push(a);return s},Vi=ct("HTMLFormElement"),Yi=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,s,o){return s.toUpperCase()+o}),Za=(({hasOwnProperty:t})=>(n,a)=>t.call(n,a))(Object.prototype),Wi=ct("RegExp"),Ps=(t,n)=>{const a=Object.getOwnPropertyDescriptors(t),s={};mn(a,(o,l)=>{let d;(d=n(o,l,t))!==!1&&(s[l]=d||o)}),Object.defineProperties(t,s)},Hi=t=>{Ps(t,(n,a)=>{if(Qe(t)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const s=t[a];if(Qe(s)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},Ki=(t,n)=>{const a={},s=o=>{o.forEach(l=>{a[l]=!0})};return Lt(t)?s(t):s(String(t).split(n)),a},Gi=()=>{},Ji=(t,n)=>t!=null&&Number.isFinite(t=+t)?t:n;function Qi(t){return!!(t&&Qe(t.append)&&t[As]==="FormData"&&t[ta])}const Xi=t=>{const n=new Array(10),a=(s,o)=>{if(pn(s)){if(n.indexOf(s)>=0)return;if(un(s))return s;if(!("toJSON"in s)){n[o]=s;const l=Lt(s)?[]:{};return mn(s,(d,u)=>{const S=a(d,o+1);!Bt(S)&&(l[u]=S)}),n[o]=void 0,l}}return s};return a(t,0)},Zi=ct("AsyncFunction"),eo=t=>t&&(pn(t)||Qe(t))&&Qe(t.then)&&Qe(t.catch),Es=((t,n)=>t?setImmediate:n?((a,s)=>(Ct.addEventListener("message",({source:o,data:l})=>{o===Ct&&l===a&&s.length&&s.shift()()},!1),o=>{s.push(o),Ct.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",Qe(Ct.postMessage)),to=typeof queueMicrotask<"u"?queueMicrotask.bind(Ct):typeof process<"u"&&process.nextTick||Es,no=t=>t!=null&&Qe(t[ta]),z={isArray:Lt,isArrayBuffer:Is,isBuffer:un,isFormData:Ii,isArrayBufferView:hi,isString:gi,isNumber:Rs,isBoolean:xi,isObject:pn,isPlainObject:Un,isEmptyObject:bi,isReadableStream:Di,isRequest:Oi,isResponse:Pi,isHeaders:Ei,isUndefined:Bt,isDate:Si,isFile:ji,isReactNativeBlob:wi,isReactNative:vi,isBlob:_i,isRegExp:Wi,isFunction:Qe,isStream:Ti,isURLSearchParams:Ri,isTypedArray:Li,isFileList:Ci,forEach:mn,merge:ka,extend:ki,trim:Fi,stripBOM:Mi,inherits:$i,toFlatObject:Ui,kindOf:na,kindOfTest:ct,endsWith:Bi,toArray:Ni,forEachEntry:qi,matchAll:zi,isHTMLForm:Vi,hasOwnProperty:Za,hasOwnProp:Za,reduceDescriptors:Ps,freezeMethods:Hi,toObjectSet:Ki,toCamelCase:Yi,noop:Gi,toFiniteNumber:Ji,findKey:Ds,global:Ct,isContextDefined:Os,isSpecCompliantForm:Qi,toJSONObject:Xi,isAsyncFn:Zi,isThenable:eo,setImmediate:Es,asap:to,isIterable:no};let be=class Fs extends Error{static from(n,a,s,o,l,d){const u=new Fs(n.message,a||n.code,s,o,l);return u.cause=n,u.name=n.name,n.status!=null&&u.status==null&&(u.status=n.status),d&&Object.assign(u,d),u}constructor(n,a,s,o,l){super(n),Object.defineProperty(this,"message",{value:n,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,a&&(this.code=a),s&&(this.config=s),o&&(this.request=o),l&&(this.response=l,this.status=l.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:z.toJSONObject(this.config),code:this.code,status:this.status}}};be.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";be.ERR_BAD_OPTION="ERR_BAD_OPTION";be.ECONNABORTED="ECONNABORTED";be.ETIMEDOUT="ETIMEDOUT";be.ERR_NETWORK="ERR_NETWORK";be.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";be.ERR_DEPRECATED="ERR_DEPRECATED";be.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";be.ERR_BAD_REQUEST="ERR_BAD_REQUEST";be.ERR_CANCELED="ERR_CANCELED";be.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";be.ERR_INVALID_URL="ERR_INVALID_URL";be.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const ao=null;function Ma(t){return z.isPlainObject(t)||z.isArray(t)}function ks(t){return z.endsWith(t,"[]")?t.slice(0,-2):t}function ma(t,n,a){return t?t.concat(n).map(function(o,l){return o=ks(o),!a&&l?"["+o+"]":o}).join(a?".":""):n}function ro(t){return z.isArray(t)&&!t.some(Ma)}const so=z.toFlatObject(z,{},null,function(n){return/^is[A-Z]/.test(n)});function ra(t,n,a){if(!z.isObject(t))throw new TypeError("target must be an object");n=n||new FormData,a=z.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,O){return!z.isUndefined(O[y])});const s=a.metaTokens,o=a.visitor||j,l=a.dots,d=a.indexes,u=a.Blob||typeof Blob<"u"&&Blob,S=a.maxDepth===void 0?100:a.maxDepth,g=u&&z.isSpecCompliantForm(n);if(!z.isFunction(o))throw new TypeError("visitor must be a function");function p(c){if(c===null)return"";if(z.isDate(c))return c.toISOString();if(z.isBoolean(c))return c.toString();if(!g&&z.isBlob(c))throw new be("Blob is not supported. Use a Buffer instead.");return z.isArrayBuffer(c)||z.isTypedArray(c)?g&&typeof Blob=="function"?new Blob([c]):Buffer.from(c):c}function j(c,y,O){let D=c;if(z.isReactNative(n)&&z.isReactNativeBlob(c))return n.append(ma(O,y,l),p(c)),!1;if(c&&!O&&typeof c=="object"){if(z.endsWith(y,"{}"))y=s?y:y.slice(0,-2),c=JSON.stringify(c);else if(z.isArray(c)&&ro(c)||(z.isFileList(c)||z.endsWith(y,"[]"))&&(D=z.toArray(c)))return y=ks(y),D.forEach(function(A,h){!(z.isUndefined(A)||A===null)&&n.append(d===!0?ma([y],h,l):d===null?y:y+"[]",p(A))}),!1}return Ma(c)?!0:(n.append(ma(O,y,l),p(c)),!1)}const I=[],T=Object.assign(so,{defaultVisitor:j,convertValue:p,isVisitable:Ma});function m(c,y,O=0){if(!z.isUndefined(c)){if(O>S)throw new be("Object is too deeply nested ("+O+" levels). Max depth: "+S,be.ERR_FORM_DATA_DEPTH_EXCEEDED);if(I.indexOf(c)!==-1)throw Error("Circular reference detected in "+y.join("."));I.push(c),z.forEach(c,function(_,A){(!(z.isUndefined(_)||_===null)&&o.call(n,_,z.isString(A)?A.trim():A,y,T))===!0&&m(_,y?y.concat(A):[A],O+1)}),I.pop()}}if(!z.isObject(t))throw new TypeError("data must be an object");return m(t),n}function er(t){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(s){return n[s]})}function La(t,n){this._pairs=[],t&&ra(t,this,n)}const Ms=La.prototype;Ms.append=function(n,a){this._pairs.push([n,a])};Ms.toString=function(n){const a=n?function(s){return n.call(this,s,er)}:er;return this._pairs.map(function(o){return a(o[0])+"="+a(o[1])},"").join("&")};function io(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function $s(t,n,a){if(!n)return t;const s=a&&a.encode||io,o=z.isFunction(a)?{serialize:a}:a,l=o&&o.serialize;let d;if(l?d=l(n,o):d=z.isURLSearchParams(n)?n.toString():new La(n,o).toString(s),d){const u=t.indexOf("#");u!==-1&&(t=t.slice(0,u)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class tr{constructor(){this.handlers=[]}use(n,a,s){return this.handlers.push({fulfilled:n,rejected:a,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){z.forEach(this.handlers,function(s){s!==null&&n(s)})}}const qa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},oo=typeof URLSearchParams<"u"?URLSearchParams:La,lo=typeof FormData<"u"?FormData:null,co=typeof Blob<"u"?Blob:null,uo={isBrowser:!0,classes:{URLSearchParams:oo,FormData:lo,Blob:co},protocols:["http","https","file","blob","url","data"]},za=typeof window<"u"&&typeof document<"u",$a=typeof navigator=="object"&&navigator||void 0,po=za&&(!$a||["ReactNative","NativeScript","NS"].indexOf($a.product)<0),mo=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",fo=za&&window.location.href||"http://localhost",yo=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:za,hasStandardBrowserEnv:po,hasStandardBrowserWebWorkerEnv:mo,navigator:$a,origin:fo},Symbol.toStringTag,{value:"Module"})),Ve={...yo,...uo};function ho(t,n){return ra(t,new Ve.classes.URLSearchParams,{visitor:function(a,s,o,l){return Ve.isNode&&z.isBuffer(a)?(this.append(s,a.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...n})}function go(t){return z.matchAll(/\w+|\[(\w*)]/g,t).map(n=>n[0]==="[]"?"":n[1]||n[0])}function xo(t){const n={},a=Object.keys(t);let s;const o=a.length;let l;for(s=0;s<o;s++)l=a[s],n[l]=t[l];return n}function Us(t){function n(a,s,o,l){let d=a[l++];if(d==="__proto__")return!0;const u=Number.isFinite(+d),S=l>=a.length;return d=!d&&z.isArray(o)?o.length:d,S?(z.hasOwnProp(o,d)?o[d]=z.isArray(o[d])?o[d].concat(s):[o[d],s]:o[d]=s,!u):((!o[d]||!z.isObject(o[d]))&&(o[d]=[]),n(a,s,o[d],l)&&z.isArray(o[d])&&(o[d]=xo(o[d])),!u)}if(z.isFormData(t)&&z.isFunction(t.entries)){const a={};return z.forEachEntry(t,(s,o)=>{n(go(s),o,a,0)}),a}return null}const Ot=(t,n)=>t!=null&&z.hasOwnProp(t,n)?t[n]:void 0;function bo(t,n,a){if(z.isString(t))try{return(n||JSON.parse)(t),z.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(a||JSON.stringify)(t)}const fn={transitional:qa,adapter:["xhr","http","fetch"],transformRequest:[function(n,a){const s=a.getContentType()||"",o=s.indexOf("application/json")>-1,l=z.isObject(n);if(l&&z.isHTMLForm(n)&&(n=new FormData(n)),z.isFormData(n))return o?JSON.stringify(Us(n)):n;if(z.isArrayBuffer(n)||z.isBuffer(n)||z.isStream(n)||z.isFile(n)||z.isBlob(n)||z.isReadableStream(n))return n;if(z.isArrayBufferView(n))return n.buffer;if(z.isURLSearchParams(n))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let u;if(l){const S=Ot(this,"formSerializer");if(s.indexOf("application/x-www-form-urlencoded")>-1)return ho(n,S).toString();if((u=z.isFileList(n))||s.indexOf("multipart/form-data")>-1){const g=Ot(this,"env"),p=g&&g.FormData;return ra(u?{"files[]":n}:n,p&&new p,S)}}return l||o?(a.setContentType("application/json",!1),bo(n)):n}],transformResponse:[function(n){const a=Ot(this,"transitional")||fn.transitional,s=a&&a.forcedJSONParsing,o=Ot(this,"responseType"),l=o==="json";if(z.isResponse(n)||z.isReadableStream(n))return n;if(n&&z.isString(n)&&(s&&!o||l)){const u=!(a&&a.silentJSONParsing)&&l;try{return JSON.parse(n,Ot(this,"parseReviver"))}catch(S){if(u)throw S.name==="SyntaxError"?be.from(S,be.ERR_BAD_RESPONSE,this,null,Ot(this,"response")):S}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ve.classes.FormData,Blob:Ve.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};z.forEach(["delete","get","head","post","put","patch"],t=>{fn.headers[t]={}});const So=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"]),jo=t=>{const n={};let a,s,o;return t&&t.split(`
|
|
2
|
+
`).forEach(function(d){o=d.indexOf(":"),a=d.substring(0,o).trim().toLowerCase(),s=d.substring(o+1).trim(),!(!a||n[a]&&So[a])&&(a==="set-cookie"?n[a]?n[a].push(s):n[a]=[s]:n[a]=n[a]?n[a]+", "+s:s)}),n},nr=Symbol("internals"),wo=/[^\x09\x20-\x7E\x80-\xFF]/g;function vo(t){let n=0,a=t.length;for(;n<a;){const s=t.charCodeAt(n);if(s!==9&&s!==32)break;n+=1}for(;a>n;){const s=t.charCodeAt(a-1);if(s!==9&&s!==32)break;a-=1}return n===0&&a===t.length?t:t.slice(n,a)}function Yt(t){return t&&String(t).trim().toLowerCase()}function _o(t){return vo(t.replace(wo,""))}function Bn(t){return t===!1||t==null?t:z.isArray(t)?t.map(Bn):_o(String(t))}function Co(t){const n=Object.create(null),a=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=a.exec(t);)n[s[1]]=s[2];return n}const To=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function fa(t,n,a,s,o){if(z.isFunction(s))return s.call(this,n,a);if(o&&(n=a),!!z.isString(n)){if(z.isString(s))return n.indexOf(s)!==-1;if(z.isRegExp(s))return s.test(n)}}function Ao(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,a,s)=>a.toUpperCase()+s)}function Io(t,n){const a=z.toCamelCase(" "+n);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+a,{value:function(o,l,d){return this[s].call(this,n,o,l,d)},configurable:!0})})}let Xe=class{constructor(n){n&&this.set(n)}set(n,a,s){const o=this;function l(u,S,g){const p=Yt(S);if(!p)throw new Error("header name must be a non-empty string");const j=z.findKey(o,p);(!j||o[j]===void 0||g===!0||g===void 0&&o[j]!==!1)&&(o[j||S]=Bn(u))}const d=(u,S)=>z.forEach(u,(g,p)=>l(g,p,S));if(z.isPlainObject(n)||n instanceof this.constructor)d(n,a);else if(z.isString(n)&&(n=n.trim())&&!To(n))d(jo(n),a);else if(z.isObject(n)&&z.isIterable(n)){let u={},S,g;for(const p of n){if(!z.isArray(p))throw TypeError("Object iterator must return a key-value pair");u[g=p[0]]=(S=u[g])?z.isArray(S)?[...S,p[1]]:[S,p[1]]:p[1]}d(u,a)}else n!=null&&l(a,n,s);return this}get(n,a){if(n=Yt(n),n){const s=z.findKey(this,n);if(s){const o=this[s];if(!a)return o;if(a===!0)return Co(o);if(z.isFunction(a))return a.call(this,o,s);if(z.isRegExp(a))return a.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,a){if(n=Yt(n),n){const s=z.findKey(this,n);return!!(s&&this[s]!==void 0&&(!a||fa(this,this[s],s,a)))}return!1}delete(n,a){const s=this;let o=!1;function l(d){if(d=Yt(d),d){const u=z.findKey(s,d);u&&(!a||fa(s,s[u],u,a))&&(delete s[u],o=!0)}}return z.isArray(n)?n.forEach(l):l(n),o}clear(n){const a=Object.keys(this);let s=a.length,o=!1;for(;s--;){const l=a[s];(!n||fa(this,this[l],l,n,!0))&&(delete this[l],o=!0)}return o}normalize(n){const a=this,s={};return z.forEach(this,(o,l)=>{const d=z.findKey(s,l);if(d){a[d]=Bn(o),delete a[l];return}const u=n?Ao(l):String(l).trim();u!==l&&delete a[l],a[u]=Bn(o),s[u]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const a=Object.create(null);return z.forEach(this,(s,o)=>{s!=null&&s!==!1&&(a[o]=n&&z.isArray(s)?s.join(", "):s)}),a}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,a])=>n+": "+a).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...a){const s=new this(n);return a.forEach(o=>s.set(o)),s}static accessor(n){const s=(this[nr]=this[nr]={accessors:{}}).accessors,o=this.prototype;function l(d){const u=Yt(d);s[u]||(Io(o,d),s[u]=!0)}return z.isArray(n)?n.forEach(l):l(n),this}};Xe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);z.reduceDescriptors(Xe.prototype,({value:t},n)=>{let a=n[0].toUpperCase()+n.slice(1);return{get:()=>t,set(s){this[a]=s}}});z.freezeMethods(Xe);function ya(t,n){const a=this||fn,s=n||a,o=Xe.from(s.headers);let l=s.data;return z.forEach(t,function(u){l=u.call(a,l,o.normalize(),n?n.status:void 0)}),o.normalize(),l}function Bs(t){return!!(t&&t.__CANCEL__)}let yn=class extends be{constructor(n,a,s){super(n??"canceled",be.ERR_CANCELED,a,s),this.name="CanceledError",this.__CANCEL__=!0}};function Ns(t,n,a){const s=a.config.validateStatus;!a.status||!s||s(a.status)?t(a):n(new be("Request failed with status code "+a.status,[be.ERR_BAD_REQUEST,be.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function Ro(t){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return n&&n[1]||""}function Do(t,n){t=t||10;const a=new Array(t),s=new Array(t);let o=0,l=0,d;return n=n!==void 0?n:1e3,function(S){const g=Date.now(),p=s[l];d||(d=g),a[o]=S,s[o]=g;let j=l,I=0;for(;j!==o;)I+=a[j++],j=j%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),g-d<n)return;const T=p&&g-p;return T?Math.round(I*1e3/T):void 0}}function Oo(t,n){let a=0,s=1e3/n,o,l;const d=(g,p=Date.now())=>{a=p,o=null,l&&(clearTimeout(l),l=null),t(...g)};return[(...g)=>{const p=Date.now(),j=p-a;j>=s?d(g,p):(o=g,l||(l=setTimeout(()=>{l=null,d(o)},s-j)))},()=>o&&d(o)]}const Zn=(t,n,a=3)=>{let s=0;const o=Do(50,250);return Oo(l=>{const d=l.loaded,u=l.lengthComputable?l.total:void 0,S=u!=null?Math.min(d,u):d,g=Math.max(0,S-s),p=o(g);s=Math.max(s,S);const j={loaded:S,total:u,progress:u?S/u:void 0,bytes:g,rate:p||void 0,estimated:p&&u?(u-S)/p:void 0,event:l,lengthComputable:u!=null,[n?"download":"upload"]:!0};t(j)},a)},ar=(t,n)=>{const a=t!=null;return[s=>n[0]({lengthComputable:a,total:t,loaded:s}),n[1]]},rr=t=>(...n)=>z.asap(()=>t(...n)),Po=Ve.hasStandardBrowserEnv?((t,n)=>a=>(a=new URL(a,Ve.origin),t.protocol===a.protocol&&t.host===a.host&&(n||t.port===a.port)))(new URL(Ve.origin),Ve.navigator&&/(msie|trident)/i.test(Ve.navigator.userAgent)):()=>!0,Eo=Ve.hasStandardBrowserEnv?{write(t,n,a,s,o,l,d){if(typeof document>"u")return;const u=[`${t}=${encodeURIComponent(n)}`];z.isNumber(a)&&u.push(`expires=${new Date(a).toUTCString()}`),z.isString(s)&&u.push(`path=${s}`),z.isString(o)&&u.push(`domain=${o}`),l===!0&&u.push("secure"),z.isString(d)&&u.push(`SameSite=${d}`),document.cookie=u.join("; ")},read(t){if(typeof document>"u")return null;const n=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return n?decodeURIComponent(n[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Fo(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function ko(t,n){return n?t.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):t}function Ls(t,n,a){let s=!Fo(n);return t&&(s||a===!1)?ko(t,n):n}const sr=t=>t instanceof Xe?{...t}:t;function Rt(t,n){n=n||{};const a=Object.create(null);Object.defineProperty(a,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function s(g,p,j,I){return z.isPlainObject(g)&&z.isPlainObject(p)?z.merge.call({caseless:I},g,p):z.isPlainObject(p)?z.merge({},p):z.isArray(p)?p.slice():p}function o(g,p,j,I){if(z.isUndefined(p)){if(!z.isUndefined(g))return s(void 0,g,j,I)}else return s(g,p,j,I)}function l(g,p){if(!z.isUndefined(p))return s(void 0,p)}function d(g,p){if(z.isUndefined(p)){if(!z.isUndefined(g))return s(void 0,g)}else return s(void 0,p)}function u(g,p,j){if(z.hasOwnProp(n,j))return s(g,p);if(z.hasOwnProp(t,j))return s(void 0,g)}const S={url:l,method:l,data:l,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:u,headers:(g,p,j)=>o(sr(g),sr(p),j,!0)};return z.forEach(Object.keys({...t,...n}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const j=z.hasOwnProp(S,p)?S[p]:o,I=z.hasOwnProp(t,p)?t[p]:void 0,T=z.hasOwnProp(n,p)?n[p]:void 0,m=j(I,T,p);z.isUndefined(m)&&j!==u||(a[p]=m)}),a}const qs=t=>{const n=Rt({},t),a=I=>z.hasOwnProp(n,I)?n[I]:void 0,s=a("data");let o=a("withXSRFToken");const l=a("xsrfHeaderName"),d=a("xsrfCookieName");let u=a("headers");const S=a("auth"),g=a("baseURL"),p=a("allowAbsoluteUrls"),j=a("url");if(n.headers=u=Xe.from(u),n.url=$s(Ls(g,j,p),t.params,t.paramsSerializer),S&&u.set("Authorization","Basic "+btoa((S.username||"")+":"+(S.password?unescape(encodeURIComponent(S.password)):""))),z.isFormData(s)){if(Ve.hasStandardBrowserEnv||Ve.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if(z.isFunction(s.getHeaders)){const I=s.getHeaders(),T=["content-type","content-length"];Object.entries(I).forEach(([m,c])=>{T.includes(m.toLowerCase())&&u.set(m,c)})}}if(Ve.hasStandardBrowserEnv&&(z.isFunction(o)&&(o=o(n)),o===!0||o==null&&Po(n.url))){const T=l&&d&&Eo.read(d);T&&u.set(l,T)}return n},Mo=typeof XMLHttpRequest<"u",$o=Mo&&function(t){return new Promise(function(a,s){const o=qs(t);let l=o.data;const d=Xe.from(o.headers).normalize();let{responseType:u,onUploadProgress:S,onDownloadProgress:g}=o,p,j,I,T,m;function c(){T&&T(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(p),o.signal&&o.signal.removeEventListener("abort",p)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function O(){if(!y)return;const _=Xe.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),h={data:!u||u==="text"||u==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:_,config:t,request:y};Ns(function(x){a(x),c()},function(x){s(x),c()},h),y=null}"onloadend"in y?y.onloadend=O:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(O)},y.onabort=function(){y&&(s(new be("Request aborted",be.ECONNABORTED,t,y)),y=null)},y.onerror=function(A){const h=A&&A.message?A.message:"Network Error",f=new be(h,be.ERR_NETWORK,t,y);f.event=A||null,s(f),y=null},y.ontimeout=function(){let A=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const h=o.transitional||qa;o.timeoutErrorMessage&&(A=o.timeoutErrorMessage),s(new be(A,h.clarifyTimeoutError?be.ETIMEDOUT:be.ECONNABORTED,t,y)),y=null},l===void 0&&d.setContentType(null),"setRequestHeader"in y&&z.forEach(d.toJSON(),function(A,h){y.setRequestHeader(h,A)}),z.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),u&&u!=="json"&&(y.responseType=o.responseType),g&&([I,m]=Zn(g,!0),y.addEventListener("progress",I)),S&&y.upload&&([j,T]=Zn(S),y.upload.addEventListener("progress",j),y.upload.addEventListener("loadend",T)),(o.cancelToken||o.signal)&&(p=_=>{y&&(s(!_||_.type?new yn(null,t,y):_),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(p),o.signal&&(o.signal.aborted?p():o.signal.addEventListener("abort",p)));const D=Ro(o.url);if(D&&Ve.protocols.indexOf(D)===-1){s(new be("Unsupported protocol "+D+":",be.ERR_BAD_REQUEST,t));return}y.send(l||null)})},Uo=(t,n)=>{const{length:a}=t=t?t.filter(Boolean):[];if(n||a){let s=new AbortController,o;const l=function(g){if(!o){o=!0,u();const p=g instanceof Error?g:this.reason;s.abort(p instanceof be?p:new yn(p instanceof Error?p.message:p))}};let d=n&&setTimeout(()=>{d=null,l(new be(`timeout of ${n}ms exceeded`,be.ETIMEDOUT))},n);const u=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(g=>{g.unsubscribe?g.unsubscribe(l):g.removeEventListener("abort",l)}),t=null)};t.forEach(g=>g.addEventListener("abort",l));const{signal:S}=s;return S.unsubscribe=()=>z.asap(u),S}},Bo=function*(t,n){let a=t.byteLength;if(a<n){yield t;return}let s=0,o;for(;s<a;)o=s+n,yield t.slice(s,o),s=o},No=async function*(t,n){for await(const a of Lo(t))yield*Bo(a,n)},Lo=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const n=t.getReader();try{for(;;){const{done:a,value:s}=await n.read();if(a)break;yield s}}finally{await n.cancel()}},ir=(t,n,a,s)=>{const o=No(t,n);let l=0,d,u=S=>{d||(d=!0,s&&s(S))};return new ReadableStream({async pull(S){try{const{done:g,value:p}=await o.next();if(g){u(),S.close();return}let j=p.byteLength;if(a){let I=l+=j;a(I)}S.enqueue(new Uint8Array(p))}catch(g){throw u(g),g}},cancel(S){return u(S),o.return()}},{highWaterMark:2})},or=64*1024,{isFunction:wn}=z,qo=(({Request:t,Response:n})=>({Request:t,Response:n}))(z.global),{ReadableStream:lr,TextEncoder:dr}=z.global,cr=(t,...n)=>{try{return!!t(...n)}catch{return!1}},zo=t=>{t=z.merge.call({skipUndefined:!0},qo,t);const{fetch:n,Request:a,Response:s}=t,o=n?wn(n):typeof fetch=="function",l=wn(a),d=wn(s);if(!o)return!1;const u=o&&wn(lr),S=o&&(typeof dr=="function"?(m=>c=>m.encode(c))(new dr):async m=>new Uint8Array(await new a(m).arrayBuffer())),g=l&&u&&cr(()=>{let m=!1;const c=new a(Ve.origin,{body:new lr,method:"POST",get duplex(){return m=!0,"half"}}),y=c.headers.has("Content-Type");return c.body!=null&&c.body.cancel(),m&&!y}),p=d&&u&&cr(()=>z.isReadableStream(new s("").body)),j={stream:p&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!j[m]&&(j[m]=(c,y)=>{let O=c&&c[m];if(O)return O.call(c);throw new be(`Response type '${m}' is not supported`,be.ERR_NOT_SUPPORT,y)})});const I=async m=>{if(m==null)return 0;if(z.isBlob(m))return m.size;if(z.isSpecCompliantForm(m))return(await new a(Ve.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(z.isArrayBufferView(m)||z.isArrayBuffer(m))return m.byteLength;if(z.isURLSearchParams(m)&&(m=m+""),z.isString(m))return(await S(m)).byteLength},T=async(m,c)=>{const y=z.toFiniteNumber(m.getContentLength());return y??I(c)};return async m=>{let{url:c,method:y,data:O,signal:D,cancelToken:_,timeout:A,onDownloadProgress:h,onUploadProgress:f,responseType:x,headers:C,withCredentials:P="same-origin",fetchOptions:k}=qs(m),U=n||fetch;x=x?(x+"").toLowerCase():"text";let b=Uo([D,_&&_.toAbortSignal()],A),E=null;const B=b&&b.unsubscribe&&(()=>{b.unsubscribe()});let q;try{if(f&&g&&y!=="get"&&y!=="head"&&(q=await T(C,O))!==0){let w=new a(c,{method:"POST",body:O,duplex:"half"}),M;if(z.isFormData(O)&&(M=w.headers.get("content-type"))&&C.setContentType(M),w.body){const[F,L]=ar(q,Zn(rr(f)));O=ir(w.body,or,F,L)}}z.isString(P)||(P=P?"include":"omit");const $=l&&"credentials"in a.prototype;if(z.isFormData(O)){const w=C.getContentType();w&&/^multipart\/form-data/i.test(w)&&!/boundary=/i.test(w)&&C.delete("content-type")}const N={...k,signal:b,method:y.toUpperCase(),headers:C.normalize().toJSON(),body:O,duplex:"half",credentials:$?P:void 0};E=l&&new a(c,N);let H=await(l?U(E,k):U(c,N));const V=p&&(x==="stream"||x==="response");if(p&&(h||V&&B)){const w={};["status","statusText","headers"].forEach(ee=>{w[ee]=H[ee]});const M=z.toFiniteNumber(H.headers.get("content-length")),[F,L]=h&&ar(M,Zn(rr(h),!0))||[];H=new s(ir(H.body,or,F,()=>{L&&L(),B&&B()}),w)}x=x||"text";let R=await j[z.findKey(j,x)||"text"](H,m);return!V&&B&&B(),await new Promise((w,M)=>{Ns(w,M,{data:R,headers:Xe.from(H.headers),status:H.status,statusText:H.statusText,config:m,request:E})})}catch($){throw B&&B(),$&&$.name==="TypeError"&&/Load failed|fetch/i.test($.message)?Object.assign(new be("Network Error",be.ERR_NETWORK,m,E,$&&$.response),{cause:$.cause||$}):be.from($,$&&$.code,m,E,$&&$.response)}}},Vo=new Map,zs=t=>{let n=t&&t.env||{};const{fetch:a,Request:s,Response:o}=n,l=[s,o,a];let d=l.length,u=d,S,g,p=Vo;for(;u--;)S=l[u],g=p.get(S),g===void 0&&p.set(S,g=u?new Map:zo(n)),p=g;return g};zs();const Va={http:ao,xhr:$o,fetch:{get:zs}};z.forEach(Va,(t,n)=>{if(t){try{Object.defineProperty(t,"name",{value:n})}catch{}Object.defineProperty(t,"adapterName",{value:n})}});const ur=t=>`- ${t}`,Yo=t=>z.isFunction(t)||t===null||t===!1;function Wo(t,n){t=z.isArray(t)?t:[t];const{length:a}=t;let s,o;const l={};for(let d=0;d<a;d++){s=t[d];let u;if(o=s,!Yo(s)&&(o=Va[(u=String(s)).toLowerCase()],o===void 0))throw new be(`Unknown adapter '${u}'`);if(o&&(z.isFunction(o)||(o=o.get(n))))break;l[u||"#"+d]=o}if(!o){const d=Object.entries(l).map(([S,g])=>`adapter ${S} `+(g===!1?"is not supported by the environment":"is not available in the build"));let u=a?d.length>1?`since :
|
|
4
|
+
`+d.map(ur).join(`
|
|
5
|
+
`):" "+ur(d[0]):"as no adapter specified";throw new be("There is no suitable adapter to dispatch the request "+u,"ERR_NOT_SUPPORT")}return o}const Vs={getAdapter:Wo,adapters:Va};function ha(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new yn(null,t)}function pr(t){return ha(t),t.headers=Xe.from(t.headers),t.data=ya.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Vs.getAdapter(t.adapter||fn.adapter,t)(t).then(function(s){return ha(t),s.data=ya.call(t,t.transformResponse,s),s.headers=Xe.from(s.headers),s},function(s){return Bs(s)||(ha(t),s&&s.response&&(s.response.data=ya.call(t,t.transformResponse,s.response),s.response.headers=Xe.from(s.response.headers))),Promise.reject(s)})}const Ys="1.15.2",sa={};["object","boolean","number","function","string","symbol"].forEach((t,n)=>{sa[t]=function(s){return typeof s===t||"a"+(n<1?"n ":" ")+t}});const mr={};sa.transitional=function(n,a,s){function o(l,d){return"[Axios v"+Ys+"] Transitional option '"+l+"'"+d+(s?". "+s:"")}return(l,d,u)=>{if(n===!1)throw new be(o(d," has been removed"+(a?" in "+a:"")),be.ERR_DEPRECATED);return a&&!mr[d]&&(mr[d]=!0,console.warn(o(d," has been deprecated since v"+a+" and will be removed in the near future"))),n?n(l,d,u):!0}};sa.spelling=function(n){return(a,s)=>(console.warn(`${s} is likely a misspelling of ${n}`),!0)};function Ho(t,n,a){if(typeof t!="object")throw new be("options must be an object",be.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let o=s.length;for(;o-- >0;){const l=s[o],d=Object.prototype.hasOwnProperty.call(n,l)?n[l]:void 0;if(d){const u=t[l],S=u===void 0||d(u,l,t);if(S!==!0)throw new be("option "+l+" must be "+S,be.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new be("Unknown option "+l,be.ERR_BAD_OPTION)}}const Nn={assertOptions:Ho,validators:sa},rt=Nn.validators;let Tt=class{constructor(n){this.defaults=n||{},this.interceptors={request:new tr,response:new tr}}async request(n,a){try{return await this._request(n,a)}catch(s){if(s instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const l=(()=>{if(!o.stack)return"";const d=o.stack.indexOf(`
|
|
6
|
+
`);return d===-1?"":o.stack.slice(d+1)})();try{if(!s.stack)s.stack=l;else if(l){const d=l.indexOf(`
|
|
7
|
+
`),u=d===-1?-1:l.indexOf(`
|
|
8
|
+
`,d+1),S=u===-1?"":l.slice(u+1);String(s.stack).endsWith(S)||(s.stack+=`
|
|
9
|
+
`+l)}}catch{}}throw s}}_request(n,a){typeof n=="string"?(a=a||{},a.url=n):a=n||{},a=Rt(this.defaults,a);const{transitional:s,paramsSerializer:o,headers:l}=a;s!==void 0&&Nn.assertOptions(s,{silentJSONParsing:rt.transitional(rt.boolean),forcedJSONParsing:rt.transitional(rt.boolean),clarifyTimeoutError:rt.transitional(rt.boolean),legacyInterceptorReqResOrdering:rt.transitional(rt.boolean)},!1),o!=null&&(z.isFunction(o)?a.paramsSerializer={serialize:o}:Nn.assertOptions(o,{encode:rt.function,serialize:rt.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),Nn.assertOptions(a,{baseUrl:rt.spelling("baseURL"),withXsrfToken:rt.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let d=l&&z.merge(l.common,l[a.method]);l&&z.forEach(["delete","get","head","post","put","patch","common"],m=>{delete l[m]}),a.headers=Xe.concat(d,l);const u=[];let S=!0;this.interceptors.request.forEach(function(c){if(typeof c.runWhen=="function"&&c.runWhen(a)===!1)return;S=S&&c.synchronous;const y=a.transitional||qa;y&&y.legacyInterceptorReqResOrdering?u.unshift(c.fulfilled,c.rejected):u.push(c.fulfilled,c.rejected)});const g=[];this.interceptors.response.forEach(function(c){g.push(c.fulfilled,c.rejected)});let p,j=0,I;if(!S){const m=[pr.bind(this),void 0];for(m.unshift(...u),m.push(...g),I=m.length,p=Promise.resolve(a);j<I;)p=p.then(m[j++],m[j++]);return p}I=u.length;let T=a;for(;j<I;){const m=u[j++],c=u[j++];try{T=m(T)}catch(y){c.call(this,y);break}}try{p=pr.call(this,T)}catch(m){return Promise.reject(m)}for(j=0,I=g.length;j<I;)p=p.then(g[j++],g[j++]);return p}getUri(n){n=Rt(this.defaults,n);const a=Ls(n.baseURL,n.url,n.allowAbsoluteUrls);return $s(a,n.params,n.paramsSerializer)}};z.forEach(["delete","get","head","options"],function(n){Tt.prototype[n]=function(a,s){return this.request(Rt(s||{},{method:n,url:a,data:(s||{}).data}))}});z.forEach(["post","put","patch"],function(n){function a(s){return function(l,d,u){return this.request(Rt(u||{},{method:n,headers:s?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Tt.prototype[n]=a(),Tt.prototype[n+"Form"]=a(!0)});let Ko=class Ws{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(l){a=l});const s=this;this.promise.then(o=>{if(!s._listeners)return;let l=s._listeners.length;for(;l-- >0;)s._listeners[l](o);s._listeners=null}),this.promise.then=o=>{let l;const d=new Promise(u=>{s.subscribe(u),l=u}).then(o);return d.cancel=function(){s.unsubscribe(l)},d},n(function(l,d,u){s.reason||(s.reason=new yn(l,d,u),a(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const a=this._listeners.indexOf(n);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){const n=new AbortController,a=s=>{n.abort(s)};return this.subscribe(a),n.signal.unsubscribe=()=>this.unsubscribe(a),n.signal}static source(){let n;return{token:new Ws(function(o){n=o}),cancel:n}}};function Go(t){return function(a){return t.apply(null,a)}}function Jo(t){return z.isObject(t)&&t.isAxiosError===!0}const Ua={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(Ua).forEach(([t,n])=>{Ua[n]=t});function Hs(t){const n=new Tt(t),a=Ts(Tt.prototype.request,n);return z.extend(a,Tt.prototype,n,{allOwnKeys:!0}),z.extend(a,n,null,{allOwnKeys:!0}),a.create=function(o){return Hs(Rt(t,o))},a}const Pe=Hs(fn);Pe.Axios=Tt;Pe.CanceledError=yn;Pe.CancelToken=Ko;Pe.isCancel=Bs;Pe.VERSION=Ys;Pe.toFormData=ra;Pe.AxiosError=be;Pe.Cancel=Pe.CanceledError;Pe.all=function(n){return Promise.all(n)};Pe.spread=Go;Pe.isAxiosError=Jo;Pe.mergeConfig=Rt;Pe.AxiosHeaders=Xe;Pe.formToJSON=t=>Us(z.isHTMLForm(t)?new FormData(t):t);Pe.getAdapter=Vs.getAdapter;Pe.HttpStatusCode=Ua;Pe.default=Pe;const{Axios:Mp,AxiosError:$p,CanceledError:Up,isCancel:Bp,CancelToken:Np,VERSION:Lp,all:qp,Cancel:zp,isAxiosError:Vp,spread:Yp,toFormData:Wp,AxiosHeaders:Hp,HttpStatusCode:Kp,formToJSON:Gp,getAdapter:Jp,mergeConfig:Qp}=Pe,Qo=()=>new Promise(t=>setTimeout(()=>t(),800));let Ba=null;const Xo=t=>{Ba=t,ft.defaults.baseURL=Ya()},Ya=()=>Ba||"https://npmapi.ubkerp.com/",ft=Pe.create({baseURL:Ya()}),it=()=>Ya(),Ye=async(t,n,a)=>{const s=await ft.post(t,n,{headers:{Authorization:a}});if(console.log("ddddfdfdfd",s.data?.Status),s.data?.Status=="Success")return s?.data?.data||s?.data;throw new Error(s.data?.msg)},G=async(t,n)=>{try{let s=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";s=`${t}${l}session_id=1`}return(await ft.get(s,{headers:{Authorization:n}})).data}catch(a){throw a.response?.status===401&&console.error("401 Unauthorized"),a}},Zo=async(t,n)=>{const a=await ft.post(t,"",{headers:{Authorization:n}});if(a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},Wa=async(t,n,a)=>(await ft.post(t,n,{headers:{Authorization:a}}))?.data,ga=async(t,n,a)=>{const s=n?.arg;return(await ft.post(t,s,{headers:{Authorization:a}}))?.data},At=async(t,n,a)=>{const s=n?.arg,o=t.includes("?")?"&":"?";return(await ft.get(t+o,{params:s,headers:{Authorization:a}}))?.data},el="/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Ha=async(t,n,a)=>{const s=n?.arg,o=t.includes("?")?"&":"?";return(await ft.get(t+o,{params:s,headers:{Authorization:a}}))?.data},ut=async(t,n,a)=>(await Qo(),(await ft.post(t,n,{headers:{Authorization:a}}))?.data),tt=async(t,n,a)=>(await ft.delete(`${t}/${n}`,{headers:{Authorization:a}})).data,tl=({token:t,menu:n})=>{const{isLoading:a,data:s}=K(t?["api/sdk/Menus",t]:null,([l,d])=>Zo(l,d)),o=s?.find(l=>l.path===n)?.sub_menu??[];return console.log("menuData",s),e.jsx(r.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(r.Col,{xs:24,md:8,lg:8,children:e.jsx(de,{children:e.jsx(Cs,{icon:`${it()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function Ks(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Be={},xa,fr;function nl(){return fr||(fr=1,xa=function t(n,a){if(n===a)return!0;if(n&&a&&typeof n=="object"&&typeof a=="object"){if(n.constructor!==a.constructor)return!1;var s,o,l;if(Array.isArray(n)){if(s=n.length,s!=a.length)return!1;for(o=s;o--!==0;)if(!t(n[o],a[o]))return!1;return!0}if(n.constructor===RegExp)return n.source===a.source&&n.flags===a.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===a.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===a.toString();if(l=Object.keys(n),s=l.length,s!==Object.keys(a).length)return!1;for(o=s;o--!==0;)if(!Object.prototype.hasOwnProperty.call(a,l[o]))return!1;for(o=s;o--!==0;){var d=l[o];if(!t(n[d],a[d]))return!1}return!0}return n!==n&&a!==a}),xa}var vn={exports:{}},_n={exports:{}},Ie={};var yr;function al(){if(yr)return Ie;yr=1;var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,a=t?Symbol.for("react.portal"):60106,s=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,u=t?Symbol.for("react.context"):60110,S=t?Symbol.for("react.async_mode"):60111,g=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,j=t?Symbol.for("react.suspense"):60113,I=t?Symbol.for("react.suspense_list"):60120,T=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,c=t?Symbol.for("react.block"):60121,y=t?Symbol.for("react.fundamental"):60117,O=t?Symbol.for("react.responder"):60118,D=t?Symbol.for("react.scope"):60119;function _(h){if(typeof h=="object"&&h!==null){var f=h.$$typeof;switch(f){case n:switch(h=h.type,h){case S:case g:case s:case l:case o:case j:return h;default:switch(h=h&&h.$$typeof,h){case u:case p:case m:case T:case d:return h;default:return f}}case a:return f}}}function A(h){return _(h)===g}return Ie.AsyncMode=S,Ie.ConcurrentMode=g,Ie.ContextConsumer=u,Ie.ContextProvider=d,Ie.Element=n,Ie.ForwardRef=p,Ie.Fragment=s,Ie.Lazy=m,Ie.Memo=T,Ie.Portal=a,Ie.Profiler=l,Ie.StrictMode=o,Ie.Suspense=j,Ie.isAsyncMode=function(h){return A(h)||_(h)===S},Ie.isConcurrentMode=A,Ie.isContextConsumer=function(h){return _(h)===u},Ie.isContextProvider=function(h){return _(h)===d},Ie.isElement=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===n},Ie.isForwardRef=function(h){return _(h)===p},Ie.isFragment=function(h){return _(h)===s},Ie.isLazy=function(h){return _(h)===m},Ie.isMemo=function(h){return _(h)===T},Ie.isPortal=function(h){return _(h)===a},Ie.isProfiler=function(h){return _(h)===l},Ie.isStrictMode=function(h){return _(h)===o},Ie.isSuspense=function(h){return _(h)===j},Ie.isValidElementType=function(h){return typeof h=="string"||typeof h=="function"||h===s||h===g||h===l||h===o||h===j||h===I||typeof h=="object"&&h!==null&&(h.$$typeof===m||h.$$typeof===T||h.$$typeof===d||h.$$typeof===u||h.$$typeof===p||h.$$typeof===y||h.$$typeof===O||h.$$typeof===D||h.$$typeof===c)},Ie.typeOf=_,Ie}var Re={};var hr;function rl(){return hr||(hr=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,a=t?Symbol.for("react.portal"):60106,s=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,u=t?Symbol.for("react.context"):60110,S=t?Symbol.for("react.async_mode"):60111,g=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,j=t?Symbol.for("react.suspense"):60113,I=t?Symbol.for("react.suspense_list"):60120,T=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,c=t?Symbol.for("react.block"):60121,y=t?Symbol.for("react.fundamental"):60117,O=t?Symbol.for("react.responder"):60118,D=t?Symbol.for("react.scope"):60119;function _(ne){return typeof ne=="string"||typeof ne=="function"||ne===s||ne===g||ne===l||ne===o||ne===j||ne===I||typeof ne=="object"&&ne!==null&&(ne.$$typeof===m||ne.$$typeof===T||ne.$$typeof===d||ne.$$typeof===u||ne.$$typeof===p||ne.$$typeof===y||ne.$$typeof===O||ne.$$typeof===D||ne.$$typeof===c)}function A(ne){if(typeof ne=="object"&&ne!==null){var ae=ne.$$typeof;switch(ae){case n:var ce=ne.type;switch(ce){case S:case g:case s:case l:case o:case j:return ce;default:var _e=ce&&ce.$$typeof;switch(_e){case u:case p:case m:case T:case d:return _e;default:return ae}}case a:return ae}}}var h=S,f=g,x=u,C=d,P=n,k=p,U=s,b=m,E=T,B=a,q=l,$=o,N=j,H=!1;function V(ne){return H||(H=!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.")),R(ne)||A(ne)===S}function R(ne){return A(ne)===g}function w(ne){return A(ne)===u}function M(ne){return A(ne)===d}function F(ne){return typeof ne=="object"&&ne!==null&&ne.$$typeof===n}function L(ne){return A(ne)===p}function ee(ne){return A(ne)===s}function Y(ne){return A(ne)===m}function J(ne){return A(ne)===T}function W(ne){return A(ne)===a}function Z(ne){return A(ne)===l}function se(ne){return A(ne)===o}function je(ne){return A(ne)===j}Re.AsyncMode=h,Re.ConcurrentMode=f,Re.ContextConsumer=x,Re.ContextProvider=C,Re.Element=P,Re.ForwardRef=k,Re.Fragment=U,Re.Lazy=b,Re.Memo=E,Re.Portal=B,Re.Profiler=q,Re.StrictMode=$,Re.Suspense=N,Re.isAsyncMode=V,Re.isConcurrentMode=R,Re.isContextConsumer=w,Re.isContextProvider=M,Re.isElement=F,Re.isForwardRef=L,Re.isFragment=ee,Re.isLazy=Y,Re.isMemo=J,Re.isPortal=W,Re.isProfiler=Z,Re.isStrictMode=se,Re.isSuspense=je,Re.isValidElementType=_,Re.typeOf=A})()),Re}var gr;function Gs(){return gr||(gr=1,process.env.NODE_ENV==="production"?_n.exports=al():_n.exports=rl()),_n.exports}var ba,xr;function sl(){if(xr)return ba;xr=1;var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function s(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function o(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var d={},u=0;u<10;u++)d["_"+String.fromCharCode(u)]=u;var S=Object.getOwnPropertyNames(d).map(function(p){return d[p]});if(S.join("")!=="0123456789")return!1;var g={};return"abcdefghijklmnopqrst".split("").forEach(function(p){g[p]=p}),Object.keys(Object.assign({},g)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return ba=o()?Object.assign:function(l,d){for(var u,S=s(l),g,p=1;p<arguments.length;p++){u=Object(arguments[p]);for(var j in u)n.call(u,j)&&(S[j]=u[j]);if(t){g=t(u);for(var I=0;I<g.length;I++)a.call(u,g[I])&&(S[g[I]]=u[g[I]])}}return S},ba}var Sa,br;function Ka(){if(br)return Sa;br=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Sa=t,Sa}var ja,Sr;function Js(){return Sr||(Sr=1,ja=Function.call.bind(Object.prototype.hasOwnProperty)),ja}var wa,jr;function il(){if(jr)return wa;jr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=Ka(),a={},s=Js();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,u,S,g){if(process.env.NODE_ENV!=="production"){for(var p in l)if(s(l,p)){var j;try{if(typeof l[p]!="function"){var I=Error((S||"React class")+": "+u+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw I.name="Invariant Violation",I}j=l[p](d,p,S,u,null,n)}catch(m){j=m}if(j&&!(j instanceof Error)&&t((S||"React class")+": type specification of "+u+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof j+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),j instanceof Error&&!(j.message in a)){a[j.message]=!0;var T=g?g():"";t("Failed "+u+" type: "+j.message+(T??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(a={})},wa=o,wa}var va,wr;function ol(){if(wr)return va;wr=1;var t=Gs(),n=sl(),a=Ka(),s=Js(),o=il(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(u){var S="Warning: "+u;typeof console<"u"&&console.error(S);try{throw new Error(S)}catch{}});function d(){return null}return va=function(u,S){var g=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function j(R){var w=R&&(g&&R[g]||R[p]);if(typeof w=="function")return w}var I="<<anonymous>>",T={array:O("array"),bigint:O("bigint"),bool:O("boolean"),func:O("function"),number:O("number"),object:O("object"),string:O("string"),symbol:O("symbol"),any:D(),arrayOf:_,element:A(),elementType:h(),instanceOf:f,node:k(),objectOf:C,oneOf:x,oneOfType:P,shape:b,exact:E};function m(R,w){return R===w?R!==0||1/R===1/w:R!==R&&w!==w}function c(R,w){this.message=R,this.data=w&&typeof w=="object"?w:{},this.stack=""}c.prototype=Error.prototype;function y(R){if(process.env.NODE_ENV!=="production")var w={},M=0;function F(ee,Y,J,W,Z,se,je){if(W=W||I,se=se||J,je!==a){if(S){var ne=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 ne.name="Invariant Violation",ne}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ae=W+":"+J;!w[ae]&&M<3&&(l("You are manually calling a React.PropTypes validation function for the `"+se+"` prop on `"+W+"`. 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."),w[ae]=!0,M++)}}return Y[J]==null?ee?Y[J]===null?new c("The "+Z+" `"+se+"` is marked as required "+("in `"+W+"`, but its value is `null`.")):new c("The "+Z+" `"+se+"` is marked as required in "+("`"+W+"`, but its value is `undefined`.")):null:R(Y,J,W,Z,se)}var L=F.bind(null,!1);return L.isRequired=F.bind(null,!0),L}function O(R){function w(M,F,L,ee,Y,J){var W=M[F],Z=$(W);if(Z!==R){var se=N(W);return new c("Invalid "+ee+" `"+Y+"` of type "+("`"+se+"` supplied to `"+L+"`, expected ")+("`"+R+"`."),{expectedType:R})}return null}return y(w)}function D(){return y(d)}function _(R){function w(M,F,L,ee,Y){if(typeof R!="function")return new c("Property `"+Y+"` of component `"+L+"` has invalid PropType notation inside arrayOf.");var J=M[F];if(!Array.isArray(J)){var W=$(J);return new c("Invalid "+ee+" `"+Y+"` of type "+("`"+W+"` supplied to `"+L+"`, expected an array."))}for(var Z=0;Z<J.length;Z++){var se=R(J,Z,L,ee,Y+"["+Z+"]",a);if(se instanceof Error)return se}return null}return y(w)}function A(){function R(w,M,F,L,ee){var Y=w[M];if(!u(Y)){var J=$(Y);return new c("Invalid "+L+" `"+ee+"` of type "+("`"+J+"` supplied to `"+F+"`, expected a single ReactElement."))}return null}return y(R)}function h(){function R(w,M,F,L,ee){var Y=w[M];if(!t.isValidElementType(Y)){var J=$(Y);return new c("Invalid "+L+" `"+ee+"` of type "+("`"+J+"` supplied to `"+F+"`, expected a single ReactElement type."))}return null}return y(R)}function f(R){function w(M,F,L,ee,Y){if(!(M[F]instanceof R)){var J=R.name||I,W=V(M[F]);return new c("Invalid "+ee+" `"+Y+"` of type "+("`"+W+"` supplied to `"+L+"`, expected ")+("instance of `"+J+"`."))}return null}return y(w)}function x(R){if(!Array.isArray(R))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 w(M,F,L,ee,Y){for(var J=M[F],W=0;W<R.length;W++)if(m(J,R[W]))return null;var Z=JSON.stringify(R,function(je,ne){var ae=N(ne);return ae==="symbol"?String(ne):ne});return new c("Invalid "+ee+" `"+Y+"` of value `"+String(J)+"` "+("supplied to `"+L+"`, expected one of "+Z+"."))}return y(w)}function C(R){function w(M,F,L,ee,Y){if(typeof R!="function")return new c("Property `"+Y+"` of component `"+L+"` has invalid PropType notation inside objectOf.");var J=M[F],W=$(J);if(W!=="object")return new c("Invalid "+ee+" `"+Y+"` of type "+("`"+W+"` supplied to `"+L+"`, expected an object."));for(var Z in J)if(s(J,Z)){var se=R(J,Z,L,ee,Y+"."+Z,a);if(se instanceof Error)return se}return null}return y(w)}function P(R){if(!Array.isArray(R))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var w=0;w<R.length;w++){var M=R[w];if(typeof M!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+H(M)+" at index "+w+"."),d}function F(L,ee,Y,J,W){for(var Z=[],se=0;se<R.length;se++){var je=R[se],ne=je(L,ee,Y,J,W,a);if(ne==null)return null;ne.data&&s(ne.data,"expectedType")&&Z.push(ne.data.expectedType)}var ae=Z.length>0?", expected one of type ["+Z.join(", ")+"]":"";return new c("Invalid "+J+" `"+W+"` supplied to "+("`"+Y+"`"+ae+"."))}return y(F)}function k(){function R(w,M,F,L,ee){return B(w[M])?null:new c("Invalid "+L+" `"+ee+"` supplied to "+("`"+F+"`, expected a ReactNode."))}return y(R)}function U(R,w,M,F,L){return new c((R||"React class")+": "+w+" type `"+M+"."+F+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+L+"`.")}function b(R){function w(M,F,L,ee,Y){var J=M[F],W=$(J);if(W!=="object")return new c("Invalid "+ee+" `"+Y+"` of type `"+W+"` "+("supplied to `"+L+"`, expected `object`."));for(var Z in R){var se=R[Z];if(typeof se!="function")return U(L,ee,Y,Z,N(se));var je=se(J,Z,L,ee,Y+"."+Z,a);if(je)return je}return null}return y(w)}function E(R){function w(M,F,L,ee,Y){var J=M[F],W=$(J);if(W!=="object")return new c("Invalid "+ee+" `"+Y+"` of type `"+W+"` "+("supplied to `"+L+"`, expected `object`."));var Z=n({},M[F],R);for(var se in Z){var je=R[se];if(s(R,se)&&typeof je!="function")return U(L,ee,Y,se,N(je));if(!je)return new c("Invalid "+ee+" `"+Y+"` key `"+se+"` supplied to `"+L+"`.\nBad object: "+JSON.stringify(M[F],null," ")+`
|
|
10
|
+
Valid keys: `+JSON.stringify(Object.keys(R),null," "));var ne=je(J,se,L,ee,Y+"."+se,a);if(ne)return ne}return null}return y(w)}function B(R){switch(typeof R){case"number":case"string":case"undefined":return!0;case"boolean":return!R;case"object":if(Array.isArray(R))return R.every(B);if(R===null||u(R))return!0;var w=j(R);if(w){var M=w.call(R),F;if(w!==R.entries){for(;!(F=M.next()).done;)if(!B(F.value))return!1}else for(;!(F=M.next()).done;){var L=F.value;if(L&&!B(L[1]))return!1}}else return!1;return!0;default:return!1}}function q(R,w){return R==="symbol"?!0:w?w["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&w instanceof Symbol:!1}function $(R){var w=typeof R;return Array.isArray(R)?"array":R instanceof RegExp?"object":q(w,R)?"symbol":w}function N(R){if(typeof R>"u"||R===null)return""+R;var w=$(R);if(w==="object"){if(R instanceof Date)return"date";if(R instanceof RegExp)return"regexp"}return w}function H(R){var w=N(R);switch(w){case"array":case"object":return"an "+w;case"boolean":case"date":case"regexp":return"a "+w;default:return w}}function V(R){return!R.constructor||!R.constructor.name?I:R.constructor.name}return T.checkPropTypes=o,T.resetWarningCache=o.resetWarningCache,T.PropTypes=T,T},va}var _a,vr;function ll(){if(vr)return _a;vr=1;var t=Ka();function n(){}function a(){}return a.resetWarningCache=n,_a=function(){function s(d,u,S,g,p,j){if(j!==t){var I=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw I.name="Invariant Violation",I}}s.isRequired=s;function o(){return s}var l={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:o,element:s,elementType:s,instanceOf:o,node:s,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:a,resetWarningCache:n};return l.PropTypes=l,l},_a}var _r;function Qs(){if(_r)return vn.exports;if(_r=1,process.env.NODE_ENV!=="production"){var t=Gs(),n=!0;vn.exports=ol()(t.isElement,n)}else vn.exports=ll()();return vn.exports}var Cr;function dl(){if(Cr)return Be;Cr=1;var t=Be&&Be.__extends||(function(){var T=function(m,c){return T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,O){y.__proto__=O}||function(y,O){for(var D in O)Object.prototype.hasOwnProperty.call(O,D)&&(y[D]=O[D])},T(m,c)};return function(m,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");T(m,c);function y(){this.constructor=m}m.prototype=c===null?Object.create(c):(y.prototype=c.prototype,new y)}})(),n=Be&&Be.__assign||function(){return n=Object.assign||function(T){for(var m,c=1,y=arguments.length;c<y;c++){m=arguments[c];for(var O in m)Object.prototype.hasOwnProperty.call(m,O)&&(T[O]=m[O])}return T},n.apply(this,arguments)},a=Be&&Be.__createBinding||(Object.create?(function(T,m,c,y){y===void 0&&(y=c);var O=Object.getOwnPropertyDescriptor(m,c);(!O||("get"in O?!m.__esModule:O.writable||O.configurable))&&(O={enumerable:!0,get:function(){return m[c]}}),Object.defineProperty(T,y,O)}):(function(T,m,c,y){y===void 0&&(y=c),T[y]=m[c]})),s=Be&&Be.__setModuleDefault||(Object.create?(function(T,m){Object.defineProperty(T,"default",{enumerable:!0,value:m})}):function(T,m){T.default=m}),o=Be&&Be.__importStar||function(T){if(T&&T.__esModule)return T;var m={};if(T!=null)for(var c in T)c!=="default"&&Object.prototype.hasOwnProperty.call(T,c)&&a(m,T,c);return s(m,T),m},l=Be&&Be.__rest||function(T,m){var c={};for(var y in T)Object.prototype.hasOwnProperty.call(T,y)&&m.indexOf(y)<0&&(c[y]=T[y]);if(T!=null&&typeof Object.getOwnPropertySymbols=="function")for(var O=0,y=Object.getOwnPropertySymbols(T);O<y.length;O++)m.indexOf(y[O])<0&&Object.prototype.propertyIsEnumerable.call(T,y[O])&&(c[y[O]]=T[y[O]]);return c},d=Be&&Be.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(Be,"__esModule",{value:!0});var u=o(i),S=d(nl()),g=o(Qs());function p(T){return T&&T.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function j(T){var m=document.createTextNode("");T.appendChild(m);var c=document.activeElement===T;if(m!==null&&m.nodeValue!==null&&c){var y=window.getSelection();if(y!==null){var O=document.createRange();O.setStart(m,m.nodeValue.length),O.collapse(!0),y.removeAllRanges(),y.addRange(O)}T instanceof HTMLElement&&T.focus()}}var I=(function(T){t(m,T);function m(){var c=T!==null&&T.apply(this,arguments)||this;return c.lastHtml=c.props.html,c.el=typeof c.props.innerRef=="function"?{current:null}:u.createRef(),c.getEl=function(){return(c.props.innerRef&&typeof c.props.innerRef!="function"?c.props.innerRef:c.el).current},c.emitChange=function(y){var O=c.getEl();if(O){var D=O.innerHTML;if(c.props.onChange&&D!==c.lastHtml){var _=Object.assign({},y,{target:{value:D}});c.props.onChange(_)}c.lastHtml=D}},c}return m.prototype.render=function(){var c=this,y=this.props,O=y.tagName,D=y.html,_=y.innerRef,A=l(y,["tagName","html","innerRef"]);return u.createElement(O||"div",n(n({},A),{ref:typeof _=="function"?function(h){_(h),c.el.current=h}:_||this.el,onInput:this.emitChange,onBlur:this.props.onBlur||this.emitChange,onKeyUp:this.props.onKeyUp||this.emitChange,onKeyDown:this.props.onKeyDown||this.emitChange,contentEditable:!this.props.disabled,dangerouslySetInnerHTML:{__html:D}}),this.props.children)},m.prototype.shouldComponentUpdate=function(c){var y=this.props,O=this.getEl();return!O||p(c.html)!==p(O.innerHTML)?!0:y.disabled!==c.disabled||y.tagName!==c.tagName||y.className!==c.className||y.innerRef!==c.innerRef||y.placeholder!==c.placeholder||!(0,S.default)(y.style,c.style)},m.prototype.componentDidUpdate=function(){var c=this.getEl();c&&(this.props.html!==c.innerHTML&&(c.innerHTML=this.props.html),this.lastHtml=this.props.html,j(c))},m.propTypes={html:g.string.isRequired,onChange:g.func,disabled:g.bool,tagName:g.string,className:g.string,style:g.object,innerRef:g.oneOfType([g.object,g.func])},m})(u.Component);return Be.default=I,Be}var cl=dl();const ul=Ks(cl),pl={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ml={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"},X=i.forwardRef(({style:t,onFocus:n,onBlur:a,...s},o)=>{const[l,d]=i.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[s.label&&e.jsx("label",{className:"labelfont",style:pl,children:s.label}),e.jsx("input",{placeholder:s.placeholder||s.label,...s,ref:o,onFocus:u=>{d(!0),n?.(u)},onBlur:u=>{d(!1),a?.(u)},style:{...ml,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),Tr=[{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 Xs(t){const n=ye().year(),a=[];for(let s=n;s>=n-t;s--)a.push({label:String(s),value:s});return a}function Pt(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 Zs(t){const n=ye().year(),a=ye().month();return t<n?Tr:Tr.slice(0,a+1)}function fl(){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 ei=t=>{switch(t){case"paid":return e.jsx("div",{style:{background:"#3cb371",color:"white",textAlign:"center"},children:"PAID"});case"due":return e.jsx("div",{style:{background:"red",color:"white",textAlign:"center"},children:"DUE"});case"partially_paid":return e.jsx("div",{style:{background:"#ff8d00",color:"white",textAlign:"center"},children:"Partially Paid"});case"Present":return e.jsx(r.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(r.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(r.Tag,{color:"error",children:"No Attendance"});case"one_time":return"ONETIME";case"monthly":return"MONTHLY";case"half_yearly":return"HALF YEARLY";case"quarterly":return"QUARTERLY";default:return""}},mt=t=>{const n=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[n?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var Wt={},Ht={},et={},Kt={},Et={},Ar;function yl(){if(Ar)return Et;Ar=1;var t=Et&&Et.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Et,"__esModule",{value:!0});const n=t(i),a=mi,s=["string","number","boolean"];function o({header:l,body:d}){const u=n.default.createElement("tr",null,l.map(g=>n.default.createElement("th",{key:g},g))),S=d.map((g,p)=>Array.isArray(g)?n.default.createElement("tr",{key:p},g.map((j,I)=>n.default.createElement("th",{key:I}," ",j," "))):g!==null&&typeof g=="object"?n.default.createElement("tr",{key:p},Object.entries(g).map(([j,I],T)=>typeof I=="object"?(console.error(`typeof ${j} is incorrect, only accept ${s.join(", ")} `),n.default.createElement("th",{key:T})):n.default.createElement("th",{key:T},n.default.createElement(n.default.Fragment,null,I)))):(console.error(`
|
|
11
11
|
data structure is incorrect,
|
|
12
12
|
data structure type ->
|
|
13
13
|
" type data = Array<{ [key: string]: string | number | boolean }>
|
|
14
14
|
or
|
|
15
15
|
type data = Array<(string | number | boolean)[]>"
|
|
16
|
-
`),null));return(0,r.renderToString)(n.default.createElement("table",null,n.default.createElement("tbody",null,c,x)))}return ut.default=s,ut}var nr;function ro(){return nr||(nr=1,(function(e){var n=wt&&wt.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(e,"__esModule",{value:!0}),e.createTable=e.template=e.uri=e.format=e.base64=void 0;function r(o){return window.btoa(unescape(encodeURIComponent(o)))}e.base64=r;function a(o,i){return o.replace(/{(\w+)}/g,(c,x)=>i[x])}e.format=a,e.uri="data:application/vnd.ms-excel;base64,",e.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var s=no();Object.defineProperty(e,"createTable",{enumerable:!0,get:function(){return n(s).default}})})(wt)),wt}var rr;function Kr(){if(rr)return Ue;rr=1;var e=Ue&&Ue.__createBinding||(Object.create?(function(p,d,b,v){v===void 0&&(v=b);var S=Object.getOwnPropertyDescriptor(d,b);(!S||("get"in S?!d.__esModule:S.writable||S.configurable))&&(S={enumerable:!0,get:function(){return d[b]}}),Object.defineProperty(p,v,S)}):(function(p,d,b,v){v===void 0&&(v=b),p[v]=d[b]})),n=Ue&&Ue.__setModuleDefault||(Object.create?(function(p,d){Object.defineProperty(p,"default",{enumerable:!0,value:d})}):function(p,d){p.default=d}),r=Ue&&Ue.__importStar||function(p){if(p&&p.__esModule)return p;var d={};if(p!=null)for(var b in p)b!=="default"&&Object.prototype.hasOwnProperty.call(p,b)&&e(d,p,b);return n(d,p),d};Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.downloadExcel=Ue.excel=void 0;const a=r(ro());function s(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function o(p,d){const b=window.document.createElement("a");return b.href=a.uri+a.base64(a.format(a.template,d)),b.download=p,document.body.appendChild(b),b.click(),document.body.removeChild(b),!0}function i(p,d){if(p)return p.cloneNode(!0).outerHTML;if(d)return a.createTable(d);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:p,sheet:d,tablePayload:b},v){if(!s())return!1;const S=i(v,b);return o(p,{worksheet:d||"Worksheet",table:S})}Ue.downloadExcel=c;function x({currentTableRef:p,filename:d,sheet:b}){function v(){if(!s())return!1;const S=i(p),g=`${d}.xls`;return o(g,{worksheet:b||"Worksheet",table:S})}return{onDownload:v}}return Ue.excel=x,Ue}var ar;function ao(){if(ar)return St;ar=1,Object.defineProperty(St,"__esModule",{value:!0}),St.useDownloadExcel=void 0;const e=h,n=Kr();function r({currentTableRef:a,filename:s,sheet:o}){const[i,c]=(0,e.useState)({});return(0,e.useEffect)(()=>{c({currentTableRef:a,filename:s,sheet:o})},[a,s,o]),(0,e.useMemo)(()=>(0,n.excel)(i),[i])}return St.useDownloadExcel=r,St}var sr;function so(){return sr||(sr=1,(function(e){var n=xt&&xt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(e,"__esModule",{value:!0}),e.downloadExcel=e.useDownloadExcel=e.DownloadTableExcel=void 0;const r=n(h),a=ao();Object.defineProperty(e,"useDownloadExcel",{enumerable:!0,get:function(){return a.useDownloadExcel}});const s=Kr();Object.defineProperty(e,"downloadExcel",{enumerable:!0,get:function(){return s.downloadExcel}});const o=({currentTableRef:i,filename:c,sheet:x,children:p})=>{const{onDownload:d}=(0,a.useDownloadExcel)({currentTableRef:i,filename:c,sheet:x});return r.default.createElement("span",{onClick:d},p)};e.DownloadTableExcel=o})(xt)),xt}var oo=so();const io=e=>{console.log("ExportDataWithHeader______",e);const{tableRef:n}=e.data;e?.tableRef;const r=new Date().getTime(),a=xr.useReactToPrint({content:()=>n.current});return t.jsx(t.Fragment,{children:t.jsx(l.Row,{justify:"end",children:t.jsx(l.Col,{children:t.jsxs(l.Row,{gutter:8,children:[t.jsx(l.Col,{children:t.jsx(l.Button,{type:"text",icon:t.jsx(he.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:a})}),t.jsx(l.Col,{children:t.jsx(oo.DownloadTableExcel,{filename:r,sheet:"users",currentTableRef:n.current,children:t.jsx(l.Button,{type:"text",icon:t.jsx(he.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},lo=e=>{const{tableRef:n}=e;return new Date().getTime(),t.jsx(t.Fragment,{children:t.jsx(l.Row,{justify:"center",children:t.jsx(l.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},co=h.createContext(),uo=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Xe=e=>{const{columns:n,action:r,DrawerUpdate:a,editDesign:s,newData:o,Loading:i,error:c,deleteTodoMutation:x,open:p,ActionView:d,viewDetails:b,myType:v,type:S,urlkey:g,columnstype:u,rowSelection:m}=e.data,_=uo(),[P,C]=h.useState(!1),[k,j]=h.useState(null),[Q,Z]=h.useState("false"),[T,D]=h.useState(!1),[R,U]=h.useState(!1),[I,H]=h.useState(),[J,pe]=h.useState(""),M=()=>C(!1),z=V=>{Z(V),C(!0)},[ce,W]=h.useState(),[f,y]=h.useState({page:e?.data?.pageController?e.data?.pageController?.page:1,rowsPerPage:e?.data?.pageController?e.data?.pageController?.rowsPerPage:10}),E=h.useRef(null),A=(V,Y)=>{e.parentCallback?.(V,Y),y({rowsPerPage:Y,page:V})},q=(V,Y)=>{j(Y),D(!0),H(V)},ee=(V,Y)=>{j(Y),U(!0),H(V)},X=e?.data?.onNavigate??e?.onNavigate,ne=(V,Y)=>{if(typeof X=="function"){X(V,Y);return}typeof window<"u"&&typeof V=="string"&&V.length>0&&window.location.assign(V)},O=V=>{if(S==="staff"){ne(`/HumanResourceDashboard/StaffFullInformation?id=${V.fk_staffID}`,V);return}ne(`/StudentInformation/StudentFullInformation?id=${V.id}`,V)},$=(V,Y)=>{W(V),a?.(Y)},K=async(V,Y,de,Te)=>{a?.(!0),de!==""&&((await Te({id:V,admission_no:Y,ec_no:de}))?.Status==="Success"?l.message.success("Ec No updated successfully"):l.message.error("Failed to Update Ec No."))},be=()=>t.jsx(co.Provider,{value:ce,children:s}),{trigger:F}=et("branchapi/staff/updateStaffPassword",Qt),{trigger:je}=et("branchapi/Student/updateEcNo",Qt),{trigger:Re}=et(g,(V,Y)=>Qt("student/studentDetails/editStudentLogInCredential",Y)),ze=async V=>{V.preventDefault(),D(!1);try{(await F({staff_id:I,new_passwod:V.target.password.value}))?.Status==="Success"?l.message.success("Password updated successfully"):l.message.error("Failed to update password")}catch{l.message.error("Failed to update password")}},Ge=async V=>{V.preventDefault(),U(!1);try{(await Re({edit_id:k?.edit_id,new_passwod:V.target.password.value,username:V.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?l.message.success("Password updated successfully"):l.message.error("Failed to update password")}catch(Y){l.message.error(Y?.response?.data?.msg??"Failed to update password")}},Qe=(Array.isArray(n)?n:[]).some(V=>V?.fixed==="left"),Ye=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:u==="antd"&&Qe?"left":void 0,sorter:(V,Y)=>(V.__serialNumber??0)-(Y.__serialNumber??0),render:V=>V},...u==="antd"?n:(Array.isArray(n)?n:[]).map(V=>({title:V.name,dataIndex:V.selector,key:V.selector,sorter:V.sorter||(V.sortable?(Y,de)=>{const Te=Y[V.selector]??"",xe=de[V.selector]??"";return typeof Te=="number"&&typeof xe=="number"?Te-xe:String(Te).localeCompare(String(xe))}:!1),render:(Y,de)=>{switch(V.selector){case"my_staff":return de.staff_id!=="0"?de.staff_id:"Admin";case"gallery_cat_logo":return t.jsx(l.Image,{width:50,src:`undefined/branch/gallery/${de.gallery_cat_logo}`});case"file01":return de.documents?t.jsx("div",{onClick:()=>z(`undefined/branch/frontoffice/${de.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 to(Y);case"full_name":return t.jsx("span",{onClick:()=>O(de),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:Y||`${de.firstname} ${de.lastname}`});case"extra_curricular_activity":return Y==="Yes"?"Extra Subject":"Fees Master";case"is_active":return Y==="yes"?t.jsx("span",{className:"label label-success",children:"Active"}):t.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return de?.current_status==="Active"?t.jsx(l.Progress,{percent:de.steps==="1"?30:de.steps==="2"?70:100,steps:3}):t.jsx("span",{className:"label label-success",children:de?.current_status});case"Password":return t.jsx("span",{onClick:()=>q(de.id,de),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return t.jsx("span",{onClick:()=>ee(de.id,de),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return t.jsx(l.Tag,{onClick:()=>b?.(de.id),color:Y==="paid"?"#66aa18":Y==="partially_paid"?"#ff5722":"#DC143C",children:Y==="paid"?"Paid":Y==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return eo().find(Te=>Te.value===Y)?.label;case"status":return t.jsx("span",{onClick:()=>b?.(de?.fk_staffID,de?.total_leave),className:`label ${Y==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:Y==="due"?"Due":"Paid"});case"subject_type_1":return t.jsxs(t.Fragment,{children:[de.is_theory==="yes"&&"Theory, ",de.is_practical==="yes"&&"Practical"]});case"ec_no":return t.jsx(Gs,{html:de.ec_no,onBlur:Te=>K(de.id,de.admission_no,Te.target.innerHTML,je)});case"Assign":case"AssignExtCarriAci":case"Medical":return t.jsx(l.Button,{type:"primary",icon:t.jsx(he.SendOutlined,{}),size:"small",onClick:()=>$(de.id,!0,V.name),children:V.name});case"Button":return t.jsx(l.Tag,{color:"cyan",onClick:()=>b?.(de),children:V.name});default:return Y}}})),...r?[{title:"Action",key:"action",render:(V,Y)=>{const de=Y?.current_status==="Promoted",Te=()=>{if(v=="sameAddUpdate"){$(Y,!0);return}if(v?.type==="examEdit"){v.editFunc(Y.id);return}$(Y.id||Y,!0)},xe=()=>{if(v==="student_result"){b?.(Y);return}if(v==="student"){b?.(Y.id,Y.class_id);return}b?.(Y.id)},nt=()=>{x?.(Y?.id)};return t.jsxs("div",{style:{display:"flex",gap:"5px"},children:[d?.[0]?.status&&t.jsx(l.Button,{icon:t.jsx(he.EditOutlined,{}),size:"small",disabled:de,onClick:Te}),d?.[1]?.status&&t.jsx(l.Button,{icon:t.jsx(he.DeleteOutlined,{}),size:"small",danger:!0,disabled:de,onClick:nt}),d?.[2]?.status&&t.jsx(l.Button,{icon:t.jsx(he.EyeOutlined,{}),size:"small",onClick:xe})]})}}]:[]],$e=h.useMemo(()=>o?Array.isArray(o?.data)?o.data:Array.isArray(o)?o:[]:[],[o]),Be=h.useMemo(()=>{const V=J.trim().toLowerCase();return V?$e.filter(Y=>Object.values(Y??{}).some(de=>String(de??"").toLowerCase().includes(V))):$e},[$e,J]),Le=!!e.parentCallback,Ae=J?Be.length:o?.pagination?.total_rows??Be.length,_e=(f.page-1)*f.rowsPerPage,Ee=Le?Be:Be.slice(_e,_e+f.rowsPerPage),Ke=h.useMemo(()=>(Ee??[]).map((V,Y)=>({...V??{},__serialNumber:_e+Y+1})),[_e,Ee]),tt=Ae===0?0:Math.min(_e+1,Ae),Je=Ae===0?0:Math.min(_e+Ee.length,Ae);let Me;return i?Me=t.jsx("p",{children:"Loading..."}):c?Me=t.jsx("p",{children:c.message}):Ee.length?Me=t.jsx(l.Table,{dataSource:Ke,columns:Ye,size:"small",bordered:!0,pagination:!1,rowSelection:m,rowKey:(V,Y)=>V?.id??V?._id??Y,scroll:{x:"max-content"}}):Me=t.jsx(l.Empty,{}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx(l.Drawer,{open:p,placement:"right",onClose:()=>a?.(!1),width:720,children:be()}),t.jsx(l.Modal,{title:"Update Password",open:T,onCancel:()=>D(!1),footer:null,children:t.jsx("form",{onSubmit:ze,children:t.jsxs(oe,{children:[t.jsx(oe,{style:{marginBottom:12},children:t.jsx(ae,{type:"password",label:"Password",name:"password",required:"required"})}),t.jsx(oe,{style:{marginTop:16},children:t.jsx(l.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),t.jsx(l.Modal,{title:" Update Credential",open:R,onCancel:()=>U(!1),footer:null,children:t.jsx("form",{onSubmit:Ge,children:t.jsxs(oe,{children:[t.jsx(oe,{style:{marginBottom:12},children:t.jsx(ae,{type:"text",label:"User Name",name:"username",required:"required",value:k?.username?k?.username:"",onChange:V=>j({...k,username:V.target.value})})}),t.jsx(oe,{style:{marginBottom:12},children:t.jsx(ae,{label:"Password",name:"password",required:"required",value:k?.password?k?.password:"",onChange:V=>j({...k,password:V.target.value})})}),t.jsx(oe,{style:{marginTop:16},children:t.jsx(l.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),t.jsx(l.Modal,{open:P,onCancel:M,footer:null,centered:!0,width:"80%",className:_.modal,children:t.jsxs("div",{style:{position:"relative"},className:_.img,children:[t.jsx(l.Image,{src:Q,alt:"",style:{width:"100%"},preview:!1}),t.jsx(l.Button,{type:"text",icon:t.jsx(he.CloseOutlined,{}),onClick:M,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),t.jsxs(l.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[t.jsx("style",{children:`
|
|
16
|
+
`),null));return(0,a.renderToString)(n.default.createElement("table",null,n.default.createElement("tbody",null,u,S)))}return Et.default=o,Et}var Ir;function hl(){return Ir||(Ir=1,(function(t){var n=Kt&&Kt.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(t,"__esModule",{value:!0}),t.createTable=t.template=t.uri=t.format=t.base64=void 0;function a(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=a;function s(l,d){return l.replace(/{(\w+)}/g,(u,S)=>d[S])}t.format=s,t.uri="data:application/vnd.ms-excel;base64,",t.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var o=yl();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return n(o).default}})})(Kt)),Kt}var Rr;function ti(){if(Rr)return et;Rr=1;var t=et&&et.__createBinding||(Object.create?(function(g,p,j,I){I===void 0&&(I=j);var T=Object.getOwnPropertyDescriptor(p,j);(!T||("get"in T?!p.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return p[j]}}),Object.defineProperty(g,I,T)}):(function(g,p,j,I){I===void 0&&(I=j),g[I]=p[j]})),n=et&&et.__setModuleDefault||(Object.create?(function(g,p){Object.defineProperty(g,"default",{enumerable:!0,value:p})}):function(g,p){g.default=p}),a=et&&et.__importStar||function(g){if(g&&g.__esModule)return g;var p={};if(g!=null)for(var j in g)j!=="default"&&Object.prototype.hasOwnProperty.call(g,j)&&t(p,g,j);return n(p,g),p};Object.defineProperty(et,"__esModule",{value:!0}),et.downloadExcel=et.excel=void 0;const s=a(hl());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(g,p){const j=window.document.createElement("a");return j.href=s.uri+s.base64(s.format(s.template,p)),j.download=g,document.body.appendChild(j),j.click(),document.body.removeChild(j),!0}function d(g,p){if(g)return g.cloneNode(!0).outerHTML;if(p)return s.createTable(p);console.error("currentTableRef or tablePayload does not exist")}function u({fileName:g,sheet:p,tablePayload:j},I){if(!o())return!1;const T=d(I,j);return l(g,{worksheet:p||"Worksheet",table:T})}et.downloadExcel=u;function S({currentTableRef:g,filename:p,sheet:j}){function I(){if(!o())return!1;const T=d(g),m=`${p}.xls`;return l(m,{worksheet:j||"Worksheet",table:T})}return{onDownload:I}}return et.excel=S,et}var Dr;function gl(){if(Dr)return Ht;Dr=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.useDownloadExcel=void 0;const t=i,n=ti();function a({currentTableRef:s,filename:o,sheet:l}){const[d,u]=(0,t.useState)({});return(0,t.useEffect)(()=>{u({currentTableRef:s,filename:o,sheet:l})},[s,o,l]),(0,t.useMemo)(()=>(0,n.excel)(d),[d])}return Ht.useDownloadExcel=a,Ht}var Or;function xl(){return Or||(Or=1,(function(t){var n=Wt&&Wt.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadExcel=t.useDownloadExcel=t.DownloadTableExcel=void 0;const a=n(i),s=gl();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return s.useDownloadExcel}});const o=ti();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:u,sheet:S,children:g})=>{const{onDownload:p}=(0,s.useDownloadExcel)({currentTableRef:d,filename:u,sheet:S});return a.default.createElement("span",{onClick:p},g)};t.DownloadTableExcel=l})(Wt)),Wt}var ni=xl();const ia=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:n}=t.data;t?.tableRef;const a=new Date().getTime(),s=cn.useReactToPrint({content:()=>n.current});return e.jsx(e.Fragment,{children:e.jsx(r.Row,{justify:"end",children:e.jsx(r.Col,{children:e.jsxs(r.Row,{gutter:8,children:[e.jsx(r.Col,{children:e.jsx(r.Button,{type:"text",icon:e.jsx(re.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:s})}),e.jsx(r.Col,{children:e.jsx(ni.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:n.current,children:e.jsx(r.Button,{type:"text",icon:e.jsx(re.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},hn=t=>{const{tableRef:n}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(r.Row,{justify:"center",children:e.jsx(r.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},bl=i.createContext(),Sl=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Me=t=>{const{columns:n,action:a,DrawerUpdate:s,editDesign:o,newData:l,Loading:d,error:u,deleteTodoMutation:S,open:g,ActionView:p,viewDetails:j,myType:I,type:T,urlkey:m,columnstype:c,rowSelection:y}=t.data,O=Sl(),[D,_]=i.useState(!1),[A,h]=i.useState(null),[f,x]=i.useState("false"),[C,P]=i.useState(!1),[k,U]=i.useState(!1),[b,E]=i.useState(),[B,q]=i.useState(""),$=()=>_(!1),N=Q=>{x(Q),_(!0)},[H,V]=i.useState(),[R,w]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),M=i.useRef(null),F=(Q,oe)=>{t.parentCallback?.(Q,oe),w({rowsPerPage:oe,page:Q})},L=(Q,oe)=>{h(oe),P(!0),E(Q)},ee=(Q,oe)=>{h(oe),U(!0),E(Q)},Y=t?.data?.onNavigate??t?.onNavigate,J=(Q,oe)=>{if(typeof Y=="function"){Y(Q,oe);return}typeof window<"u"&&typeof Q=="string"&&Q.length>0&&window.location.assign(Q)},W=Q=>{if(T==="staff"){J(`/HumanResourceDashboard/StaffFullInformation?id=${Q.fk_staffID}`,Q);return}J(`/StudentInformation/StudentFullInformation?id=${Q.id}`,Q)},Z=(Q,oe)=>{V(Q),s?.(oe)},se=async(Q,oe,me,Te)=>{s?.(!0),me!==""&&((await Te({id:Q,admission_no:oe,ec_no:me}))?.Status==="Success"?r.message.success("Ec No updated successfully"):r.message.error("Failed to Update Ec No."))},je=()=>e.jsx(bl.Provider,{value:H,children:o}),{trigger:ne}=He("branchapi/staff/updateStaffPassword",ga),{trigger:ae}=He("branchapi/Student/updateEcNo",ga),{trigger:ce}=He(m,(Q,oe)=>ga("student/studentDetails/editStudentLogInCredential",oe)),_e=async Q=>{Q.preventDefault(),P(!1);try{(await ne({staff_id:b,new_passwod:Q.target.password.value}))?.Status==="Success"?r.message.success("Password updated successfully"):r.message.error("Failed to update password")}catch{r.message.error("Failed to update password")}},$e=async Q=>{Q.preventDefault(),U(!1);try{(await ce({edit_id:A?.edit_id,new_passwod:Q.target.password.value,username:Q.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?r.message.success("Password updated successfully"):r.message.error("Failed to update password")}catch(oe){r.message.error(oe?.response?.data?.msg??"Failed to update password")}},qe=(Array.isArray(n)?n:[]).some(Q=>Q?.fixed==="left"),Ne=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:c==="antd"&&qe?"left":void 0,sorter:(Q,oe)=>(Q.__serialNumber??0)-(oe.__serialNumber??0),render:Q=>Q},...c==="antd"?n:(Array.isArray(n)?n:[]).map(Q=>({title:Q.name,dataIndex:Q.selector,key:Q.selector,sorter:Q.sorter||(Q.sortable?(oe,me)=>{const Te=oe[Q.selector]??"",Ae=me[Q.selector]??"";return typeof Te=="number"&&typeof Ae=="number"?Te-Ae:String(Te).localeCompare(String(Ae))}:!1),render:(oe,me)=>{switch(Q.selector){case"my_staff":return me.staff_id!=="0"?me.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(r.Image,{width:50,src:`undefined/branch/gallery/${me.gallery_cat_logo}`});case"file01":return me.documents?e.jsx("div",{onClick:()=>N(`undefined/branch/frontoffice/${me.documents}`),style:{textDecoration:"underline",color:"blue",cursor:"pointer"},children:"view file"}):"Not Uploaded";case"amount":case"fine_amount":case"basic_pay":case"net_amount":return mt(oe);case"full_name":return e.jsx("span",{onClick:()=>W(me),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:oe||`${me.firstname} ${me.lastname}`});case"extra_curricular_activity":return oe==="Yes"?"Extra Subject":"Fees Master";case"is_active":return oe==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return me?.current_status==="Active"?e.jsx(r.Progress,{percent:me.steps==="1"?30:me.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:me?.current_status});case"Password":return e.jsx("span",{onClick:()=>L(me.id,me),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>ee(me.id,me),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(r.Tag,{onClick:()=>j?.(me.id),color:oe==="paid"?"#66aa18":oe==="partially_paid"?"#ff5722":"#DC143C",children:oe==="paid"?"Paid":oe==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return fl().find(Te=>Te.value===oe)?.label;case"status":return e.jsx("span",{onClick:()=>j?.(me?.fk_staffID,me?.total_leave),className:`label ${oe==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:oe==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[me.is_theory==="yes"&&"Theory, ",me.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(ul,{html:me.ec_no,onBlur:Te=>se(me.id,me.admission_no,Te.target.innerHTML,ae)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(r.Button,{type:"primary",icon:e.jsx(re.SendOutlined,{}),size:"small",onClick:()=>Z(me.id,!0,Q.name),children:Q.name});case"Button":return e.jsx(r.Tag,{color:"cyan",onClick:()=>j?.(me),children:Q.name});default:return oe}}})),...a?[{title:"Action",key:"action",render:(Q,oe)=>{const me=oe?.current_status==="Promoted",Te=()=>{if(I=="sameAddUpdate"){Z(oe,!0);return}if(I?.type==="examEdit"){I.editFunc(oe.id);return}Z(oe.id||oe,!0)},Ae=()=>{if(I==="student_result"){j?.(oe);return}if(I==="student"){j?.(oe.id,oe.class_id);return}j?.(oe.id)},pt=()=>{S?.(oe?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[p?.[0]?.status&&e.jsx(r.Button,{icon:e.jsx(re.EditOutlined,{}),size:"small",disabled:me,onClick:Te}),p?.[1]?.status&&e.jsx(r.Button,{icon:e.jsx(re.DeleteOutlined,{}),size:"small",danger:!0,disabled:me,onClick:pt}),p?.[2]?.status&&e.jsx(r.Button,{icon:e.jsx(re.EyeOutlined,{}),size:"small",onClick:Ae})]})}}]:[]],Ue=i.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Oe=i.useMemo(()=>{const Q=B.trim().toLowerCase();return Q?Ue.filter(oe=>Object.values(oe??{}).some(me=>String(me??"").toLowerCase().includes(Q))):Ue},[Ue,B]),We=!!t.parentCallback,ze=B?Oe.length:l?.pagination?.total_rows??Oe.length,Fe=(R.page-1)*R.rowsPerPage,Le=We?Oe:Oe.slice(Fe,Fe+R.rowsPerPage),lt=i.useMemo(()=>(Le??[]).map((Q,oe)=>({...Q??{},__serialNumber:Fe+oe+1})),[Fe,Le]),ue=ze===0?0:Math.min(Fe+1,ze),he=ze===0?0:Math.min(Fe+Le.length,ze);let fe;return d?fe=e.jsx("p",{children:"Loading..."}):u?fe=e.jsx("p",{children:u.message}):Le.length?fe=e.jsx(r.Table,{dataSource:lt,columns:Ne,size:"small",bordered:!0,pagination:!1,rowSelection:y,rowKey:(Q,oe)=>Q?.id??Q?._id??oe,scroll:{x:"max-content"}}):fe=e.jsx(r.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(r.Drawer,{open:g,placement:"right",onClose:()=>s?.(!1),width:720,children:je()}),e.jsx(r.Modal,{title:"Update Password",open:C,onCancel:()=>P(!1),footer:null,children:e.jsx("form",{onSubmit:_e,children:e.jsxs(de,{children:[e.jsx(de,{style:{marginBottom:12},children:e.jsx(X,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(de,{style:{marginTop:16},children:e.jsx(r.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(r.Modal,{title:" Update Credential",open:k,onCancel:()=>U(!1),footer:null,children:e.jsx("form",{onSubmit:$e,children:e.jsxs(de,{children:[e.jsx(de,{style:{marginBottom:12},children:e.jsx(X,{type:"text",label:"User Name",name:"username",required:"required",value:A?.username?A?.username:"",onChange:Q=>h({...A,username:Q.target.value})})}),e.jsx(de,{style:{marginBottom:12},children:e.jsx(X,{label:"Password",name:"password",required:"required",value:A?.password?A?.password:"",onChange:Q=>h({...A,password:Q.target.value})})}),e.jsx(de,{style:{marginTop:16},children:e.jsx(r.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(r.Modal,{open:D,onCancel:$,footer:null,centered:!0,width:"80%",className:O.modal,children:e.jsxs("div",{style:{position:"relative"},className:O.img,children:[e.jsx(r.Image,{src:f,alt:"",style:{width:"100%"},preview:!1}),e.jsx(r.Button,{type:"text",icon:e.jsx(re.CloseOutlined,{}),onClick:$,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(r.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
|
|
17
17
|
.ubk-table-shell .ant-table-wrapper {
|
|
18
18
|
background: #fff;
|
|
19
19
|
border: 1px solid #e7e8f2;
|
|
@@ -56,4 +56,4 @@ Valid keys: `+JSON.stringify(Object.keys(f),null," "));var F=be(ne,K,q,ee,X+"."
|
|
|
56
56
|
.ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
|
|
57
57
|
color: #8f99ff;
|
|
58
58
|
}
|
|
59
|
-
`}),t.jsx(oe,{children:t.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:t.jsx(io,{data:{tableRef:E}})})}),t.jsxs("div",{className:"ubk-table-shell",ref:E,style:{marginTop:12},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,flexWrap:"wrap",marginBottom:14},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#222"},children:[t.jsx("span",{children:"Show"}),t.jsx(l.Select,{size:"small",value:f.rowsPerPage,onChange:V=>A(1,V),options:[10,25,50,100].map(V=>({label:V,value:V})),style:{width:72}}),t.jsx("span",{children:"entries"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontSize:12,color:"#222"},children:"Search:"}),t.jsx(l.Input,{size:"small",allowClear:!0,value:J,onChange:V=>{pe(V.target.value),y(Y=>({...Y,page:1}))},placeholder:"Enter search keyword",prefix:t.jsx(he.SearchOutlined,{style:{color:"#a3a8cf"}}),style:{width:220,borderWidth:"0 0 1px 0",borderRadius:0,background:"transparent"}})]})]}),t.jsx("div",{className:"print-only",children:t.jsx(lo,{})}),Me]}),o&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,marginTop:16,flexWrap:"wrap"},children:[t.jsx("div",{style:{fontSize:12,color:"#222"},children:`Showing ${tt} to ${Je} of ${Ae} entries`}),t.jsx(l.Pagination,{current:f.page,pageSize:f.rowsPerPage,total:Ae||0,showSizeChanger:!1,onChange:A})]})]})]})},po=({token:e,type:n})=>{const[r,a]=h.useState({page:1,rowsPerPage:10}),s="api/branchapi/frontoffice/enquirytablelist",o=s.includes("?")?s.endsWith("?")||s.endsWith("&")?"":"&":"?",i=`${s}${o}page=${r.page}&per_page=${r.rowsPerPage}`,{isLoading:c,data:x,error:p}=se(e?[i,e]:null,([P,C])=>le(P,C)),[d,b]=h.useState(!1),v=(P,C)=>{a({page:P,rowsPerPage:parseInt(C)})},S=async P=>{},g=P=>{console.log("dsdsdsdsd",P),b(P)},u=()=>{},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],_=h.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(P,C)=>P.name.localeCompare(C.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(P,C)=>(P.contact||"").localeCompare(C.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(P,C)=>(P.description||"").localeCompare(C.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(P,C)=>(P.source_name||"").localeCompare(C.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(P,C)=>new Date(P.date)-new Date(C.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(P,C)=>new Date(P.follow_up_date)-new Date(C.follow_up_date)}]);return t.jsx("div",{children:t.jsx(Xe,{parentCallback:v,data:{newData:x,columns:_,action:!0,Loading:c,error:p,open:d,viewDetails:u,deleteTodoMutation:S,DrawerUpdate:g,ActionView:m}})})},fo={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"},we=h.forwardRef(({error:e,success:n,disabled:r,style:a,...s},o)=>t.jsx("div",{className:"form-group",style:{marginBottom:0},children:t.jsx("input",{...s,ref:o,disabled:r,style:{...fo,opacity:r?.7:1,cursor:r?"not-allowed":"pointer",...a||{}}})})),ct=({id:e,funcName:n,disabled:r=!1})=>{const a="Data",[s,o]=h.useState(!1),i=()=>{o(!0),n(e),l.message.success(`${a} deleted successfully!`)},c=()=>{l.message.info(`Deletion of ${a} cancelled`)};return t.jsx(l.Popconfirm,{title:`Delete ${a}?`,description:`Are you sure you want to delete ${a}?`,onConfirm:i,onCancel:c,okText:"Yes",cancelText:"No",disabled:r||s,children:t.jsx(l.Button,{danger:!0,disabled:r,loading:s,icon:t.jsx(he.DeleteOutlined,{}),size:"small"})})},Et=e=>({optimisticData:n=>[...n.data,e],populateCache:(n,r)=>[...r.data,n]}),mt=e=>({optimisticData:n=>n.data.filter(r=>r.id!==e),populateCache:(n,r)=>r.data.filter(a=>a.id!==e)}),or={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function ho({token:e}){const[n,r]=h.useState({pagination:{current:1,pageSize:10}}),[a,s]=h.useState(!1),[o,i]=h.useState(null),c=`api/branchapi/Transport/routeTableList?page=${n.pagination.current}&per_page=${n.pagination.pageSize}`,x="api/branchapi/Transport/addroute",p="api/branchapi/Transport/editroute",d="api/branchapi/Transport/deleteroute",{isLoading:b,data:v,error:S,mutate:g}=se(e?[c,e]:null,([T,D])=>le(T,D)),u=async(T,D)=>{try{await g(We(T,D,e),Et(D)),N.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{N.error("Failed to add the new item.",{duration:1e3})}},m=T=>{T.preventDefault();const D=new FormData(T.target);u(x,D),T.target.reset()},_=(T,D)=>{r(R=>({...R,pagination:{current:T,pageSize:parseInt(D,10)}}))},P=async T=>{try{await g(He(d,T,e),mt(T)),N.success("Success! Deleted item.",{duration:1e3})}catch{N.error("Failed to delete the item.",{duration:1e3})}},C=T=>{i(T),s(!0)},k=async T=>{try{await lt(p,T,e),await g(),N.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),i(null)}catch{N.error("Failed to update the item.",{duration:1e3})}},j=async T=>{T.preventDefault();const D=new FormData(T.target);D.append("id",o?.id),k(D)},Q=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(T,D)=>T.name.localeCompare(D.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(T,D)=>T.fare-D.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(T,D)=>T.note.localeCompare(D.note)}},{title:"Action",key:"action",render:(T,D)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(l.Button,{type:"text",size:"small",icon:t.jsx(he.EditOutlined,{}),onClick:()=>C(D),style:{padding:2}}),t.jsx(ct,{id:D?.id,funcName:P})]})}],Z=o?.route_title?`Edit ${o.route_title}`:"Edit Route";return t.jsxs("div",{children:[t.jsx(l.Drawer,{open:a,title:Z,placement:"right",width:420,onClose:()=>{s(!1),i(null)},children:t.jsx("form",{onSubmit:j,children:t.jsxs("div",{style:{display:"grid",gap:20},children:[t.jsx(ae,{type:"text",name:"title",label:"Title",defaultValue:o?.route_title||"",required:"required"}),t.jsx(ae,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:o?.fare||"",required:"required"}),t.jsx(ae,{type:"text",name:"note",label:"Note",defaultValue:o?.note||""}),t.jsx("div",{style:{display:"none"},children:t.jsx(ae,{type:"text",name:"no_of_vehicle",label:"Note"})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Update",color:"primary"}),t.jsx(l.Button,{type:"text",onClick:()=>{s(!1),i(null)},style:or,children:"Cancel"})]})]})})}),t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(oe,{pt:5,pb:1,children:t.jsxs("div",{children:[t.jsx("div",{children:t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Add Route"})}),t.jsx(oe,{px:3,pb:2,children:t.jsx("form",{onSubmit:m,children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[t.jsx(ae,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"}),t.jsx(ae,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"}),t.jsx(ae,{type:"text",name:"note",label:"Note"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Save",color:"primary"}),t.jsx(l.Button,{type:"text",htmlType:"reset",style:or,children:"Cancel"})]})]})})})]})}),t.jsx("div",{style:{marginTop:24},children:t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Route List"})}),t.jsx(oe,{children:t.jsx(Xe,{parentCallback:_,data:{newData:v,columns:Q,columnstype:"antd",action:!1,Loading:b,error:S,deleteTodoMutation:P}})})]})})]})})]})}const ir={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function mo({token:e}){const[n,r]=h.useState({page:1,rowsPerPage:10}),[a,s]=h.useState(!1),[o,i]=h.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${n.page}&per_page=${n.rowsPerPage}`,x="api/branchapi/Transport/addvehicles",p="api/branchapi/Transport/editvehicle",d="api/branchapi/Transport/deletevehicle",{isLoading:b,data:v,error:S,mutate:g}=se(e?[c,e]:null,([T,D])=>le(T,D)),u=async(T,D)=>{try{await g(We(T,D,e),Et(D)),N.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{N.error("Failed to add the new item.",{duration:1e3})}},m=T=>{T.preventDefault();const D=new FormData(T.target);u(x,D),T.target.reset()},_=async T=>{try{await g(He(d,T,e),mt(T)),N.success("Success! Deleted item.",{duration:1e3})}catch{N.error("Failed to delete the item.",{duration:1e3})}},P=T=>{i(T),s(!0)},C=async T=>{try{await lt(p,T,e),await g(),N.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),i(null)}catch{N.error("Failed to update the item.",{duration:1e3})}},k=async T=>{T.preventDefault();const D=new FormData(T.target);D.append("id",o?.id),C(D)},j=(T,D)=>{r({page:T,rowsPerPage:parseInt(D,10)})},Q=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(T,D)=>T.vehicle_no.localeCompare(D.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(T,D)=>T.vehicle_model.localeCompare(D.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(T,D)=>T.seating_capacity-D.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(T,D)=>T.manufacture_year-D.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(T,D)=>T.gps_url.localeCompare(D.gps_url)},render:(T,D)=>t.jsx("span",{title:D?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:D?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(T,D)=>T.note.localeCompare(D.note)}},{title:"Action",key:"action",render:(T,D)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(l.Button,{type:"text",size:"small",icon:t.jsx(he.EditOutlined,{}),onClick:()=>P(D),style:{padding:2}}),t.jsx(ct,{id:D?.id,funcName:_})]})}],Z=o?.vehicle_no?`Edit ${o.vehicle_no}`:"Edit Vehicle";return t.jsxs("div",{children:[t.jsx(l.Drawer,{open:a,title:Z,placement:"right",width:420,onClose:()=>{s(!1),i(null)},children:t.jsx("form",{onSubmit:k,children:t.jsxs("div",{style:{display:"grid",gap:20},children:[t.jsx(ae,{type:"text",name:"number",label:"Vehicle Number",defaultValue:o?.vehicle_no||"",required:"required"}),t.jsx(ae,{type:"text",name:"model",label:"Vehicle Model",defaultValue:o?.vehicle_model||""}),t.jsx(ae,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:o?.manufacture_year||""}),t.jsx(ae,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:o?.seating_capacity||""}),t.jsx(ae,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:o?.gps_url||""}),t.jsx(ae,{type:"text",name:"note",label:"Note",defaultValue:o?.note||""}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Update",color:"primary"}),t.jsx(l.Button,{type:"text",onClick:()=>{s(!1),i(null)},style:ir,children:"Cancel"})]})]})})}),t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(oe,{pt:5,pb:1,children:t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Add Vehicle"})}),t.jsx(oe,{px:3,pb:2,children:t.jsx("form",{onSubmit:m,children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[t.jsx(ae,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),t.jsx(ae,{type:"text",name:"model",label:"Vehicle Model"}),t.jsx(ae,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),t.jsx(ae,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),t.jsx(ae,{type:"text",name:"gps_url",label:"Gps Url"}),t.jsx(ae,{type:"text",name:"note",label:"Note"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Save",color:"primary"}),t.jsx(l.Button,{type:"text",htmlType:"reset",style:ir,children:"Cancel"})]})]})})})]}),t.jsx("div",{style:{marginTop:24},children:t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Vehicle List"})}),t.jsx(oe,{children:t.jsx(Xe,{parentCallback:j,data:{newData:v,columns:Q,columnstype:"antd",action:!1,Loading:b,error:S,deleteTodoMutation:_}})})]})})]})})]})}var yo=Yr();const ln=Vr(yo),Jr=()=>{};class Cn extends h.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=n=>{this.selectRef=n};componentDidUpdate(n){n.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(n,r)=>{this.props.onChange(n,r),this.setState({value:n})};getValue=()=>{const{value:n}=this.state;return n?Array.isArray(n)?n.length?"valid":"":typeof n=="object"?n.value||"":n:""};render(){const{SelectComponent:n,required:r,...a}=this.props;console.log("sdsdsfsdddddddd",{...a});const{isDisabled:s}=this.props,o=!s;return t.jsxs("div",{children:[t.jsx(n,{...a,ref:this.setSelectRef,onChange:this.onChange}),o&&t.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:Jr,onFocus:()=>this.selectRef.focus(),required:r})]})}}Cn.defaultProps={onChange:Jr};Cn.protoTypes={selectComponent:ln.func.isRequired,onChange:ln.func,required:ln.bool};const go={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},bo={menuPortal:e=>({...e,zIndex:9999}),control:(e,n)=>({...e,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${n.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${n.isFocused?"#222":"#a8a8a8"}`}}),valueContainer:e=>({...e,height:40,padding:"0 0",display:"flex",alignItems:"center"}),input:e=>({...e,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),indicatorsContainer:e=>({...e,height:40}),dropdownIndicator:(e,n)=>({...e,padding:"0 0 0 8px",color:n.isFocused?"#222":"#b5b5b5"}),singleValue:e=>({...e,color:"#222",marginLeft:0}),placeholder:e=>({...e,color:"#9f9f9f",marginLeft:0}),option:(e,n)=>({...e,fontSize:"14px",backgroundColor:n.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},Xr=e=>t.jsx(Sr.components.Input,{...e,className:"input-cont",required:!!e?.selectProps?.required}),xo=e=>t.jsx(Cn,{...e,SelectComponent:Sr,components:{Input:Xr},options:e.options}),fe=h.forwardRef(({...e},n)=>t.jsxs("div",{className:"form-group",style:{height:"auto"},children:[e.label&&t.jsx("label",{className:"labelfont",style:go,children:e?.label}),t.jsx(xo,{components:{Input:Xr},menuPortalTarget:document.body,styles:bo,className:"input-cont",...e,ref:n})]})),So={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},lr=({dataIndex:e,title:n,record:r,children:a,isEditable:s,...o})=>t.jsx("td",{...o,children:s?t.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:a}):a});function wo({token:e}){const[n,r]=h.useState(!1),[a,s]=h.useState({pagination:{current:1,pageSize:50}}),[o,i]=h.useState(null),[c,x]=h.useState([]),p="api/branchapi/Transport/getrouteDropdown",d="api/branchapi/Transport/getvehicleDropdown",b="api/branchapi/Transport/getchechkedVehicleData",v="api/branchapi/Transport/assignedVehicleTable",S="api/branchapi/transport/assignvehicle",g="api/branchapi/Transport/deleteassignvehicle",u=o?`${b}?route_id=${o}`:null,{isLoading:m,data:_,mutate:P}=se(e?[`${v}?page=${a.pagination.current}&per_page=${a.pagination.pageSize}`,e]:null,([y,E])=>le(y,E)),{data:C}=se(e&&p?[p,e]:null,([y,E])=>le(y,E)),{data:k}=se(e&&d?[d,e]:null,([y,E])=>le(y,E)),j=e&&u?[u,e]:null,{isLoading:Q,data:Z}=se(j,([y,E])=>le(y,E)),{Status:T="Failed",pagination:{total_rows:D=0}={}}=_||{},{data:R=[]}=T==="Success"?_:{},U=h.useMemo(()=>{const y=C?.data??C??[];return Array.isArray(y)?y:[]},[C]),I=h.useMemo(()=>{const y=k?.data??k??[];return(Array.isArray(y)?y:[]).map(A=>{if(A==null)return null;if(typeof A=="string"||typeof A=="number")return{label:String(A),value:A};const q=A.value??A.vehicle_id??A.id??A.vehicleID,ee=A.label??A.vehicle_name??A.vehicle_no??A.vehicle_number??A.name??String(q??"");return q==null||ee===""?null:{label:String(ee),value:q}}).filter(Boolean)},[k]),H=h.useMemo(()=>{const y=Z?.data??Z??[];return(Array.isArray(y)?y:[]).map(A=>A?.value??A?.vehicle_id??A?.id??A).filter(A=>A!=null)},[Z]);h.useEffect(()=>{x(H)},[H,n]);const J=async(y,E,A)=>{try{await P(We(y,E,e),Et(E)),u&&se.mutate(j),r(q=>!q),N.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(q){N.error(q?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},pe=y=>{y.preventDefault();const E=new FormData;E.append("route_id",o??""),c.length?c.forEach(A=>E.append("vehicle_ids[]",A)):E.append("vehicle_ids[]",""),J(S,E)},M=y=>{s(E=>({...E,pagination:{current:y,pageSize:E.pagination.pageSize}}))},z=async y=>{try{await P(He(g,y,e),mt(y)),u&&se.mutate(j),N.success("Success! Deleted item.",{duration:1e3})}catch{N.error("Failed to delete the item.",{duration:1e3})}},ce=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(y,E,A)=>t.jsx(t.Fragment,{children:E.children.map((q,ee,X)=>t.jsx("span",{children:`${q.vehicle_name} ${ee+1===X.length?"":","}`},`${ee}vehicle001`))})},{title:"Action",render:(y,E,A)=>t.jsx(t.Fragment,{children:t.jsx(ct,{id:E?.route_id,funcName:z})})}],W=y=>{const E=["route_id","index"];for(let A=0;A<E.length;A++)if(y[E[A]])return y[E[A]]},f=y=>{const{children:E=[]}=y||{},A=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:q=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:q=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:q=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:q=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:q=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:q=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:q=>({isEditable:!0})}];return t.jsx("div",{style:{display:"flex",justifyContent:"center"},children:t.jsx("div",{style:{width:"95%",margin:8},children:t.jsx(l.Table,{components:{body:{cell:lr}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:A,rowKey:q=>W(q)+"cell01",dataSource:E,pagination:!1})})})};return t.jsxs("div",{children:[t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(oe,{pt:5,pb:1,children:t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Assign Vehicle"})}),t.jsx(oe,{px:3,pb:2,children:t.jsx("form",{onSubmit:pe,children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[t.jsx("div",{children:t.jsx(fe,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:y=>{i(y?.value??null),r(E=>!E)}})}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),t.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:t.jsx(l.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:I,value:c,onChange:y=>x(y),disabled:!o||Q})},`check001${n}`)]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Save",color:"primary"}),t.jsx(l.Button,{type:"text",htmlType:"button",onClick:()=>{i(null),x([]),r(y=>!y)},style:So,children:"Cancel"})]})]})})})]}),t.jsx("div",{style:{marginTop:24},children:t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Vehicle List"})}),t.jsx(oe,{style:{padding:"10px 16px"},children:t.jsx(l.Table,{components:{body:{cell:lr}},columns:ce,bordered:!0,rowKey:y=>W(y),dataSource:Array.isArray(R)?R:[],loading:m,expandable:{expandedRowRender:f,childrenColumnName:"changed"},pagination:{current:a.pagination.current,pageSize:a.pagination.pageSize,total:D,showSizeChanger:!0,onChange:M,onShowSizeChange:(y,E)=>{s(A=>({...A,pagination:{current:1,pageSize:E}}))},showTotal:(y,E)=>`${E[0]}-${E[1]} of ${y} items`}})})]})})]})})]})}const jo={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},vo={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},_o=(e,n,r)=>n?e>ge(r).endOf("day")||e<ge(n).endOf("day"):!1,Gr=h.forwardRef(function(n,r){const{...a}=n;return t.jsxs("div",{className:"form-group",children:[a.Desplay&&t.jsx("label",{className:`labelfont ${a.classnme?a.classnme:""}`,style:jo,children:a.Desplay}),t.jsx(l.DatePicker,{...a,style:{...vo,...a.style||{}},className:"form-group",disabledDate:s=>_o(s,a.sessionStart||a.minDate?.subtract(1,"day").format("YYYY-MM-DD"),a.sessionEnd||a.maxDate?.format("YYYY-MM-DD")),required:!0,ref:r})]})}),cr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},cn=e=>{const n=e?.data??e??[];return Array.isArray(n)?n:[]},dn=(e,n,r)=>{if(n==null||n==="")return null;const a=e.find(s=>String(s.value)===String(n));return a||(r?{label:String(r),value:n}:{label:String(n),value:n})},Co=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},To=e=>{if(e==null||e===""||e==="null"||e==="undefined")return"";if(Array.isArray(e))return e.filter(r=>r!=null&&r!==""&&String(r).toLowerCase()!=="null"&&String(r).toLowerCase()!=="undefined").join(", ");const n=String(e).trim();return!n||n.toLowerCase()==="null"||n.toLowerCase()==="undefined"?"":n};function Ro({token:e,assignmentId:n,studentName:r,onClose:a,onSuccess:s}){const o="api/branchapi/Transport/showRouteAssignStudent",i="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",x="api/branchapi/Transport/getvehicleListByRouteIdwithCount",p="api/branchapi/Transport/getStoppageDropdown",d="api/branchapi/Transport/routeShowdata",[b,v]=h.useState(null),[S,g]=h.useState(0),[u,m]=h.useState(0),{data:_,isLoading:P}=se(e&&n?[`${o}?id=${n}`,e]:null,([O,$])=>le(O,$)),C=h.useMemo(()=>{if(!_||_?.Status&&_.Status!=="Success")return null;const O=_?.data??_;return Array.isArray(O)?O[0]??null:O},[_]);h.useEffect(()=>{const O=C?.fk_route_id??C?.route_id;O!=null&&v(O)},[C]);const k=e&&b?`${x}?route_id=${b}`:null,j=e&&b?`${d}?id=${b}`:null,Q=e&&b?`${p}?route_id=${b}`:null,{data:Z}=se(e&&c?[c,e]:null,([O,$])=>le(O,$)),{data:T,isLoading:D}=se(k?[k,e]:null,([O,$])=>le(O,$)),{data:R,isLoading:U}=se(Q?[Q,e]:null,([O,$])=>le(O,$)),{data:I}=se(j?[j,e]:null,([O,$])=>le(O,$)),H=h.useMemo(()=>cn(Z),[Z]),J=h.useMemo(()=>cn(T),[T]),pe=h.useMemo(()=>cn(R),[R]),M=I?.data?.[0]?.fare??C?.fare??C?.rootCost??C?.rootcost,z=Co(),ce=r||[C?.firstname,C?.lastname].filter(Boolean).join(" ")||"",W=(O,$)=>{switch($){case"route_id":v(O?.value??null),g(K=>K+1),m(K=>K+1);break;case"vehicle_id":m(K=>K+1);break}},f=async O=>{O.preventDefault();const $=new FormData(O.target);$.append("id",n);try{await lt(i,$,e),N.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s?.(),a?.()}catch(K){N.error(K?.message??"Failed to update the item.",{duration:1e3})}};if(P||!(C&&!P&&(!b||!D&&!U)))return t.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:t.jsx(l.Spin,{})});if(!C)return t.jsxs("div",{style:{padding:"8px 0"},children:[t.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),t.jsx(l.Button,{type:"text",onClick:a,style:cr,children:"Close"})]});const E=C.fk_route_id??C.route_id,A=dn(H,E,C.route_title),q=dn(J,C.vehicle_id,C.vehicle_name??C.vehicle_no),ee=dn(pe,C.stop_id,C.stop_name??C.stoppage_name),X=C.start_date?ge(C.start_date):ge(),ne=To(C?.service_push);return t.jsx("form",{onSubmit:f,children:t.jsxs("div",{style:{display:"grid",gap:20},children:[t.jsx(ae,{type:"text",name:"title",label:"Student",defaultValue:ce,readOnly:!0}),t.jsx("input",{type:"hidden",name:"student_id",value:C.fk_student_id??C.student_id??""}),t.jsx(fe,{options:H,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"fk_route_id",required:!0,allowSelectAll:!1,defaultValue:A,onChange:O=>W(O,"route_id")}),t.jsx(fe,{options:J,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,defaultValue:q,onChange:O=>W(O,"vehicle_id")},`edit-vehicle-${S}`),t.jsx(fe,{options:pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",name:"stop_id",required:!0,allowSelectAll:!1,defaultValue:ee},`edit-stop-${u}`),t.jsx(ae,{type:"text",label:"Route Cost",value:M!=null?`${z}${M}`:"",readOnly:!0}),t.jsx("input",{type:"hidden",name:"rootCost",value:M??""}),t.jsx(Gr,{defaultValue:X,Desplay:"Start Date",name:"start_date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1}),t.jsx(ae,{type:"text",name:"puse_service",label:"Pause Service",defaultValue:ne,placeholder:"e.g. 01, 02, 03"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[t.jsx(we,{type:"submit",value:"Update",color:"primary"}),t.jsx(l.Button,{type:"text",onClick:a,style:cr,children:"Cancel"})]})]})},`edit-${n}-${S}`)}const dr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},jt=e=>{const n=e?.data??e??[];return Array.isArray(n)?n:[]},Oo=e=>e||"",Eo=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Do=e=>{const n=String(e??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},Ao=(e,n)=>{const r=n||"/TransportDashboard/EditAssignStudentTransport?id={id}",a=e?.id??"",s=encodeURIComponent(String(a));if(r.includes("{id}"))return r.replaceAll("{id}",s);if(r.includes(":id"))return r.replace(":id",s);try{const i=new URL(r,"http://localhost");if(i.searchParams.has("id"))return i.searchParams.set("id",String(a)),`${i.pathname}${i.search}${i.hash}`}catch{}const o=r.includes("?")?"&":"?";return`${r}${o}id=${s}`};function Po({token:e,editType:n,onNavigate:r,editPagePath:a}){const o=Do(n)==="drawer",i="api/branchapi/academy/classdropdownlist",c="api/branchapi/academy/sectionoftheClass",x="api/branchapi/Transport/routeStudentList",p="api/branchapi/Transport/getrouteDropdown",d="api/branchapi/Transport/getvehicleListByRouteIdwithCount",b="api/branchapi/Transport/getStoppageDropdown",v="api/branchapi/Transport/routeShowdata",S="api/branchapi/Transport/assignTransportRoutesStudent",g="api/branchapi/transport/removeStudentTransport",[u,m]=h.useState(null),[_,P]=h.useState(!1),[C,k]=h.useState(!1),[j,Q]=h.useState(null),[Z,T]=h.useState(null),[D,R]=h.useState(null),[U,I]=h.useState(null),[H,J]=h.useState(!1),[pe,M]=h.useState(!1),[z,ce]=h.useState({page:1,rowsPerPage:50}),[W,f]=h.useState(null),[y,E]=h.useState(!1),[A,q]=h.useState(null),[ee,X]=h.useState(null),ne=(G,ie)=>{switch(ie){case"class_id":f(`${c}?class_id=${G.value}`),P(Pe=>!Pe);break;case"route_id":T(`${d}?route_id=${G.value}`),R(`${v}?id=${G.value}`),X(G.value),J(Pe=>!Pe);break;case"vehicle_id":I(`${b}?route_id=${ee}`),M(Pe=>!Pe);break}},O=G=>{if(o){Q(G),k(!0);return}const ie=Ao(G,a);if(typeof r=="function"){r(ie,G);return}typeof window<"u"&&ie&&window.location.assign(ie)},$=()=>{k(!1),Q(null)},K=j?`Edit — ${j.firstname??""} ${j.lastname??""}`.trim():"Edit Student Transport",{data:be}=se(e&&i?[i,e]:null,([G,ie])=>le(G,ie)),{data:F}=se(e&&W?[W,e]:null,([G,ie])=>le(G,ie)),{data:je}=se(e&&Z?[Z,e]:null,([G,ie])=>le(G,ie)),{data:Re}=se(e&&U?[U,e]:null,([G,ie])=>le(G,ie)),{data:ze}=se(e&&D?[D,e]:null,([G,ie])=>le(G,ie)),{data:Ge}=se(e&&p?[p,e]:null,([G,ie])=>le(G,ie)),Qe=e&&u?`${u}&page=${z.page}&per_page=${z.rowsPerPage}`:null,{isLoading:Ye,error:$e,data:Be,mutate:Le}=se(Qe?[Qe,e]:null,([G,ie])=>le(G,ie)),Ae=h.useMemo(()=>jt(be),[be]),_e=h.useMemo(()=>jt(F),[F]),Ee=h.useMemo(()=>jt(je),[je]),Ke=h.useMemo(()=>jt(Re),[Re]),tt=h.useMemo(()=>jt(Ge),[Ge]),Je=ze?.data?.[0]?.fare,Me=async G=>{try{await Le(He(g,G,e),mt(G)),N.success("Success! Deleted item.",{duration:1e3})}catch{N.error("Failed to delete the item.",{duration:1e3})}},V=[{title:"Route Status",key:"route_status",render:(G,ie)=>ie.fk_route_id?t.jsx("span",{children:ie.route_title}):t.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(G,ie)=>Oo(ie.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:(G,ie)=>`${ie.firstname} ${ie.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(G,ie)=>t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:ie.fk_route_id?t.jsxs(t.Fragment,{children:[t.jsx(ct,{id:ie?.id,funcName:Me}),t.jsx(l.Button,{type:"text",size:"small",icon:t.jsx(he.EditOutlined,{}),onClick:()=>O(ie),style:{padding:2}})]}):t.jsx(l.Button,{type:"text",size:"small",icon:t.jsx(he.PlusOutlined,{}),onClick:()=>xe(ie.student_id),style:{padding:2}})})}],Y=async(G,ie)=>{try{await Le(We(G,ie,e),Et(ie)),N.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),E(!1),rt()}catch{N.error("Failed to add the new item.",{duration:1e3})}},de=G=>{G.preventDefault();const ie=G?.target?.class_id?.value,Pe=G?.target?.section_id?.value;m(`${x}?cID=${ie}&sID=${Pe}`),ce(B=>({...B,page:1}))},Te=(G,ie)=>{ce({page:G,rowsPerPage:parseInt(ie,10)})},xe=G=>{q(G),E(!0)},nt=G=>{G.preventDefault();const ie=new FormData(G.target);Y(S,ie)},rt=()=>{E(!1),T(null),R(null),I(null),X(null)},yt=Eo();return t.jsxs("div",{children:[o&&t.jsx(l.Drawer,{open:C,title:K,placement:"right",width:420,destroyOnClose:!0,onClose:$,children:j?.id&&t.jsx(Ro,{token:e,assignmentId:j.id,studentName:`${j.firstname??""} ${j.lastname??""}`.trim(),onClose:$,onSuccess:()=>Le()})}),t.jsx(l.Modal,{open:y,title:"Assign Student to Transport",onCancel:rt,footer:null,width:640,destroyOnClose:!0,children:t.jsx("form",{onSubmit:nt,children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[t.jsx(fe,{options:tt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"fk_route_id",required:!0,allowSelectAll:!1,onChange:G=>ne(G,"route_id")}),t.jsx(fe,{options:Ee,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,onChange:G=>ne(G,"vehicle_id")},`vehicle001${H}`),t.jsx(fe,{options:Ke,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",name:"stop_id",required:!0,allowSelectAll:!1},`stop001${pe}`),t.jsx(Gr,{defaultValue:ge(),Desplay:"Start Date",name:"start_date",placement:"bottomRight",format:"YYYY-MM-DD"}),t.jsx("input",{type:"hidden",value:A??"",name:"student_id"}),t.jsx(ae,{className:"noDisplay",type:"text",name:"rootCost",value:Je??""}),t.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:Je!=null?`${yt}${Je} — Assign`:"Assign",color:"primary"}),t.jsx(l.Button,{type:"text",onClick:rt,style:dr,children:"Cancel"})]})]})})}),t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(oe,{pt:5,pb:1,children:t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Search Students"})}),t.jsx(oe,{px:3,pb:2,children:t.jsx("form",{onSubmit:de,children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[t.jsx(fe,{options:Ae,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:G=>ne(G,"class_id"),name:"class_id",required:!0,allowSelectAll:!1}),t.jsx(fe,{options:_e,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,name:"section_id",required:!0},`section1${_}`),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Search",color:"primary"}),t.jsx(l.Button,{type:"text",htmlType:"button",onClick:()=>{m(null),f(null),P(G=>!G)},style:dr,children:"Cancel"})]})]})})})]}),u&&t.jsx("div",{style:{marginTop:24},children:t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Student List"})}),t.jsx(oe,{children:t.jsx(Xe,{parentCallback:Te,data:{newData:Be,columns:V,columnstype:"antd",action:!1,Loading:Ye,error:$e,deleteTodoMutation:Me,pageController:z}})})]})})]})})]})}const ur={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},kt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function ko({token:e}){const[n,r]=h.useState({page:1,rowsPerPage:50}),[a,s]=h.useState(!1),[o,i]=h.useState(null),[c,x]=h.useState(""),[p,d]=h.useState(""),[b,v]=h.useState(""),[S,g]=h.useState(!1),u=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,m="api/branchapi/Transport/add_driver",_="api/branchapi/Transport/edit_driver",P="api/branchapi/Transport/deletedriver",C="api/branchapi/staff/uploadDocuments",k=h.useMemo(()=>String(C).startsWith("http")?C:`${vt()??""}${String(C).replace(/^\/+/,"")}`,[C]),j=vt()??"",{isLoading:Q,data:Z,error:T,mutate:D}=se(e?[u,e]:null,([W,f])=>le(W,f)),R=async(W,f)=>{try{await We(W,f,e),await D(),N.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),x("")}catch(y){N.error(y?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},U=W=>{W.preventDefault();const f=new FormData(W.target);R(m,f),W.target.reset()},I=async W=>{try{await D(He(P,W,e),mt(W)),N.success("Success! Deleted item.",{duration:1e3})}catch{N.error("Failed to delete the item.",{duration:1e3})}},H=W=>{i(W),x(W?.image??""),s(!0)},J=async W=>{try{await lt(_,W,e),await D(),N.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),s(!1),i(null),x("")}catch(f){N.error(f?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},pe=W=>{W.preventDefault();const f=new FormData(W.target);f.append("id",o?.id??""),J(f)},M=(W,f)=>{r({page:W,rowsPerPage:parseInt(f,10)})},z=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(W,f)=>String(W?.name??"").localeCompare(String(f?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(W,f)=>String(W?.Driver_licence??"").localeCompare(String(f?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(W,f)=>Number(W?.contact_number??0)-Number(f?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(W,f)=>String(W?.address??"").localeCompare(String(f?.address??""))}},{title:"Image",key:"image",width:100,render:(W,f)=>{const y=f?.image?`${j}staff/document/${f.image}`:"";return y?t.jsx("div",{style:{display:"flex",justifyContent:"center"},children:t.jsx(l.Image,{width:80,src:y,preview:{visible:!1,onVisibleChange:()=>{g(!0),d(y),v(f?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(W,f)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(l.Button,{type:"text",size:"small",icon:t.jsx(he.EditOutlined,{}),onClick:()=>H(f),style:{padding:2}}),t.jsx(ct,{id:f?.id,funcName:I})]})}],ce=o?.name?`Edit ${o.name}`:"Edit Driver";return t.jsxs("div",{children:[t.jsx(l.Drawer,{open:a,title:ce,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{s(!1),i(null),x("")},children:t.jsx("form",{onSubmit:pe,children:t.jsxs("div",{style:{display:"grid",gap:20},children:[t.jsx(ae,{type:"text",name:"name",label:"Driver Name",defaultValue:o?.name??"",required:"required"}),t.jsx(ae,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:o?.Driver_licence??"",required:"required"}),t.jsx(ae,{type:"number",name:"contact_number",label:"Driver Contact",defaultValue:o?.contact_number??"",required:"required"}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:kt,children:"Address"}),t.jsx(l.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}})]}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:kt,children:"Image"}),t.jsx(l.Upload,{maxCount:1,action:k,headers:e?{Authorization:e}:void 0,onChange:W=>{if(W?.file?.status!=="done")return;const f=W?.file?.response,y=f?.data??f?.filename??f?.file??f?.path??"";y&&x(String(y))},children:t.jsx(l.Button,{icon:t.jsx(he.UploadOutlined,{}),disabled:!k,children:"Upload"})}),t.jsx("input",{type:"hidden",name:"file",value:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Update",color:"primary"}),t.jsx(l.Button,{type:"text",onClick:()=>{s(!1),i(null),x("")},style:ur,children:"Cancel"})]})]})})}),t.jsx(l.Modal,{zIndex:9999,open:S,title:b,footer:null,onCancel:()=>g(!1),children:t.jsx("img",{alt:"preview",style:{width:"100%"},src:p})}),t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(oe,{pt:5,pb:1,children:t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Add Driver"})}),t.jsx(oe,{px:3,pb:2,children:t.jsx("form",{onSubmit:U,children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[t.jsx(ae,{type:"text",name:"name",label:"Driver Name",required:"required"}),t.jsx(ae,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),t.jsx(ae,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:kt,children:"Address"}),t.jsx(l.Input.TextArea,{name:"address",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:kt,children:"Image"}),t.jsx(l.Upload,{maxCount:1,action:k,headers:e?{Authorization:e}:void 0,onChange:W=>{if(W?.file?.status!=="done")return;const f=W?.file?.response,y=f?.data??f?.filename??f?.file??f?.path??"";y&&x(String(y))},children:t.jsx(l.Button,{icon:t.jsx(he.UploadOutlined,{}),disabled:!k,children:"Upload"})}),t.jsx("input",{type:"hidden",name:"file",value:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Save",color:"primary"}),t.jsx(l.Button,{type:"text",htmlType:"reset",onClick:()=>x(""),style:ur,children:"Cancel"})]})]})})})]}),t.jsx("div",{style:{marginTop:24},children:t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Driver List"})}),t.jsx(oe,{children:t.jsx(Xe,{parentCallback:M,data:{newData:Z,columns:z,columnstype:"antd",action:!1,Loading:Q,error:T,deleteTodoMutation:I}})})]})})]})})]})}const pr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},pt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},It={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},fr=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],Mt=e=>{const n=e?.data??e??[];return Array.isArray(n)?n:[]};function Io({token:e}){const[n,r]=h.useState({page:1,rowsPerPage:50}),[a,s]=h.useState(!1),[o,i]=h.useState(!1),[c,x]=h.useState(null),[p,d]=h.useState(null),[b,v]=h.useState(null),[S,g]=h.useState(null),[u,m]=h.useState(ge()),[_,P]=h.useState(ge()),[C,k]=h.useState("pick"),[j,Q]=h.useState(!1),[Z,T]=h.useState(null),[D,R]=h.useState(null),[U,I]=h.useState(!1),[H,J]=h.useState(null),[pe,M]=h.useState(null),[z,ce]=h.useState(null),[W,f]=h.useState(null),[y,E]=h.useState(ge()),[A,q]=h.useState(ge()),[ee,X]=h.useState("pick"),ne=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,O="api/branchapi/Transport/assignRouteTime",$="api/branchapi/Transport/editAssignRouteTime",K="api/branchapi/Transport/deleteAssignRouteTime",be="api/branchapi/Transport/driverDropdown",F="api/branchapi/transport/routeTimetableShowdata",je="api/branchapi/Transport/getrouteDropdown",Re="api/branchapi/Transport/getvehicleDropdown",{isLoading:ze,data:Ge,error:Qe,mutate:Ye}=se(e?[ne,e]:null,([B,te])=>le(B,te)),{data:$e}=se(e&&je?[je,e]:null,([B,te])=>le(B,te)),{data:Be}=se(e&&be?[be,e]:null,([B,te])=>le(B,te)),Le=h.useMemo(()=>c?`${Re}?route_id=${c}`:null,[c,Re]),{data:Ae}=se(e&&Le?[Le,e]:null,([B,te])=>le(B,te)),_e=h.useMemo(()=>Mt($e),[$e]),Ee=h.useMemo(()=>Mt(Be),[Be]),Ke=h.useMemo(()=>Mt(Ae),[Ae]),tt=(B,te)=>{r({page:B,rowsPerPage:parseInt(te,10)})},Je=async B=>{B.preventDefault();const te=new FormData(B.target);te.set("route_id",p?.value??c??""),te.set("driver_id",b?.value??""),te.set("vehicle_id",S?.value??""),te.set("start_time",u?u.format("h:mm a"):""),te.set("drop_time",_?_.format("h:mm a"):""),te.set("type",C);try{await We(O,te,e),await Ye(),N.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),B.target.reset(),x(null),d(null),v(null),g(null),i(Ne=>!Ne),m(ge()),P(ge()),k("pick"),s(Ne=>!Ne)}catch(Ne){N.error(Ne?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},Me=async B=>{try{await He(K,B,e),await Ye(),N.success("Success! Deleted item.",{duration:1e3})}catch(te){N.error(te?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},V=B=>{T(B),Q(!0);const te=B?.id??B?.route_time_id??B?.routeId??null;R(te);const Ne=B?.route_id??B?.routeId??B?.fk_route_id;J(Ne??null),M(_e.find(at=>at?.value===(Ne??B?.route_id))??null),ce(Ee.find(at=>at?.value===(B?.driver_id??B?.driverId))??null),f(null),I(at=>!at),E(B?.start_time?ge(B.start_time,["h:mm a","HH:mm"]):ge()),q(B?.drop_time?ge(B.drop_time,["h:mm a","HH:mm"]):ge()),X(B?.type??"pick")},Y=h.useMemo(()=>{if(!D)return null;const B=String(F).includes("?")?"&":"?";return`${F}${B}id=${encodeURIComponent(String(D))}`},[D,F]),{data:de,isLoading:Te}=se(e&&Y?[Y,e]:null,([B,te])=>le(B,te)),xe=h.useMemo(()=>{const B=de?.data??de;return Array.isArray(B)?B[0]??null:Array.isArray(B?.data)?B.data[0]??null:B??null},[de]);h.useEffect(()=>{if(!xe)return;const B=xe?.route_id??xe?.fk_route_id??xe?.routeId;J(B??null),M(_e.find(te=>te?.value===B)??null),ce(Ee.find(te=>te?.value===xe?.driver_id)??null),f(null),E(xe?.start_time?ge(xe.start_time,["h:mm a","HH:mm"]):ge()),q(xe?.drop_time?ge(xe.drop_time,["h:mm a","HH:mm"]):ge()),X(xe?.type??"pick"),I(te=>!te)},[Ee,xe,_e]),h.useEffect(()=>{if(!xe)return;const B=xe?.vehicle_id??xe?.vehicleId;B&&f(Pe.find(te=>te?.value===B)??null)},[xe,Pe]);const nt=async B=>{if(B.preventDefault(),!D)return;const te=new FormData(B.target);te.set("id",String(D)),te.set("route_id",pe?.value??H??""),te.set("driver_id",z?.value??""),te.set("vehicle_id",W?.value??""),te.set("start_time",y?y.format("h:mm a"):""),te.set("drop_time",A?A.format("h:mm a"):""),te.set("type",ee);try{await lt($,te,e),await Ye(),N.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),Q(!1),T(null)}catch(Ne){N.error(Ne?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},rt=[{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:(B,te)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(l.Button,{type:"text",size:"small",icon:t.jsx(he.EditOutlined,{}),onClick:()=>V(te),style:{padding:2}}),t.jsx(ct,{id:te?.id??te?.routeId??te?.route_time_id,funcName:Me})]})}],yt=Z?.route_title?`Edit ${Z.route_title}`:"Edit Route Time",G=h.useMemo(()=>H?`${Re}?route_id=${H}`:null,[H,Re]),{data:ie}=se(e&&G?[G,e]:null,([B,te])=>le(B,te)),Pe=h.useMemo(()=>Mt(ie),[ie]);return t.jsxs("div",{children:[t.jsx(l.Drawer,{open:j,title:yt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{Q(!1),T(null),R(null),J(null),M(null),ce(null),f(null)},children:t.jsx("form",{onSubmit:nt,children:t.jsxs("div",{style:{display:"grid",gap:20,opacity:Te?.6:1},children:[t.jsx(fe,{options:_e,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:pe,onChange:B=>{J(B?.value??null),M(B??null),f(null),I(te=>!te)}}),t.jsx(fe,{options:Ee,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:z,onChange:B=>ce(B??null)}),t.jsx(fe,{options:Pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:W,onChange:B=>f(B??null)},`edit-vehicle-${U}`),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:pt,children:"Start Time"}),t.jsx(l.TimePicker,{value:y,onChange:B=>E(B),use12Hours:!0,format:"h:mm a",allowClear:!1,style:It})]}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:pt,children:"Drop Time"}),t.jsx(l.TimePicker,{value:A,onChange:B=>q(B),use12Hours:!0,format:"h:mm a",allowClear:!1,style:It})]}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:pt,children:"Type"}),t.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:t.jsx(l.Radio.Group,{options:fr,optionType:"button",buttonStyle:"solid",value:ee,onChange:B=>X(B.target.value)})})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Update",color:"primary"}),t.jsx(l.Button,{type:"text",onClick:()=>{Q(!1),T(null)},style:pr,children:"Cancel"})]})]})})}),t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(oe,{pt:5,pb:1,children:t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Route Time Table"})}),t.jsx(oe,{px:3,pb:2,children:t.jsx("form",{onSubmit:Je,children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[t.jsx(fe,{options:_e,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:p,onChange:B=>{x(B?.value??null),d(B??null),g(null),i(te=>!te)},allowSelectAll:!1,required:!0}),t.jsx(fe,{options:Ee,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:b,onChange:B=>v(B??null),allowSelectAll:!1,required:!0}),t.jsx(fe,{options:Ke,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:S,onChange:B=>g(B??null),allowSelectAll:!1,required:!0},`vehicle-${o}`),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:pt,children:"Start Time"}),t.jsx(l.TimePicker,{value:u,onChange:B=>m(B),use12Hours:!0,format:"h:mm a",allowClear:!1,style:It})]}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:pt,children:"Drop Time"}),t.jsx(l.TimePicker,{value:_,onChange:B=>P(B),use12Hours:!0,format:"h:mm a",allowClear:!1,style:It})]}),t.jsxs("div",{style:{width:"100%"},children:[t.jsx("label",{className:"labelfont",style:pt,children:"Type"}),t.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:t.jsx(l.Radio.Group,{options:fr,optionType:"button",buttonStyle:"solid",value:C,onChange:B=>k(B.target.value)})})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx(we,{type:"submit",value:"Add",color:"primary"}),t.jsx(l.Button,{type:"text",htmlType:"reset",onClick:()=>{x(null),d(null),v(null),g(null),i(B=>!B),m(ge()),P(ge()),k("pick"),s(B=>!B)},style:pr,children:"Cancel"})]})]})},`form-${a}`)})]}),t.jsx("div",{style:{marginTop:24},children:t.jsxs("div",{children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Route Time List"})}),t.jsx(oe,{children:t.jsx(Xe,{parentCallback:tt,data:{newData:Ge,columns:rt,columnstype:"antd",action:!1,Loading:ze,error:Qe,deleteTodoMutation:Me}})})]})})]})})]})}const Mo={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},hr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},mr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},yr=({dataIndex:e,title:n,record:r,children:a,isEditable:s,...o})=>t.jsx("td",{...o,children:s?t.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:a}):a});let gr=2;function Uo({token:e}){const[n,r]=h.useState([]),[a,s]=h.useState(null),[o,i]=h.useState({pagination:{current:1,pageSize:50}}),{isLoading:c,data:x,mutate:p}=se(e?[`api/branchapi/transport/getrouteStoppageData?page=${o.pagination.current}&per_page=${o.pagination.pageSize}`,e]:null,([R,U])=>le(R,U)),{Status:d="Failed",pagination:{total_rows:b=0}={}}=x||{},{data:v=[]}=d==="Success"?x:{},{data:S}=se(e?["api/branchapi/Transport/getrouteDropdown",e]:null,([R,U])=>le(R,U)),g=h.useMemo(()=>{const R=S?.data??S??[];return Array.isArray(R)?R:[]},[S]),{data:u}=se(e&&a?["api/branchapi/transport/getrouteStoppageData?route_id="+a,e]:null,([R,U])=>le(R,U)),{Status:m="Failed"}=u||{},_=async(R,U)=>{try{await p(We(R,U,e),Et(U)),N.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{N.error("Failed to add the new item.",{duration:1e3})}},P=R=>{R.preventDefault();const U=new FormData(R.target);_("/branchapi/transport/addstoppageToRoute",U)},C=()=>{r(R=>[...R,{idKey:gr++}])},k=R=>{if(n.length===1)return;const U=[...n];U.splice(R,1),r(U)},j=R=>{i(U=>({...U,pagination:{current:R,pageSize:U.pagination.pageSize}}))},Q=async R=>{const U="/branchapi/Transport/deletevehicle";try{await p(He(U,R,e),mt(R)),N.success("Success! Deleted item.",{duration:1e3})}catch{N.error("Failed to delete the item.",{duration:1e3})}};h.useEffect(()=>{if(m==="Success"){const R=Array.isArray(u?.data)?u.data:[];R.length>0?r(R):a&&r([{idKey:gr++}])}},[m,u,a]);const Z=R=>{const{children:U=[]}=R||{},I=[{title:"Stop Name",dataIndex:"stop_name",onCell:H=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:H=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:H=>({isEditable:!0})}];return t.jsx("div",{style:{display:"flex",justifyContent:"center"},children:t.jsx("div",{style:{width:"95%",margin:8},children:t.jsx(l.Table,{components:{body:{cell:yr}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:I,rowKey:H=>T(H)+"cell01",dataSource:U,pagination:!1})})})},T=R=>{const U=["id","index"];for(let I=0;I<U.length;I++)if(R[U[I]])return R[U[I]]},D=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(R,U,I)=>t.jsx(t.Fragment,{children:U.children?.map((H,J,pe)=>t.jsx("span",{children:`${H.stop_name} ${J+1===pe.length?"":","}`},`${J}vehicle001`))})},{title:"Action",render:(R,U,I)=>t.jsx(t.Fragment,{children:t.jsx(ct,{id:U?.route_id,funcName:Q})})}];return t.jsxs("div",{children:[t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsxs(oe,{pt:5,pb:1,children:[t.jsx(oe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Route Time Table"})}),t.jsx(oe,{px:3,pb:2,children:t.jsxs("form",{onSubmit:P,children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[t.jsx("div",{children:t.jsx(fe,{options:g,value:g.find(R=>R.value===a)??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:R=>{s(R?.value??null),r([])},allowSelectAll:!1,required:!0})}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:a&&t.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:C,children:t.jsx(he.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[t.jsx(we,{type:"submit",value:"Add",color:"primary"}),t.jsx(l.Button,{type:"text",htmlType:"button",onClick:()=>{s(null),r([])},style:Mo,children:"Cancel"})]})]}),t.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((R,U)=>{const I=R.pickup_time?ge(R.pickup_time,"h:mm a"):ge(),H=R.drop_time?ge(R.drop_time,"h:mm a"):ge();return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[t.jsx("div",{children:t.jsx(ae,{defaultValue:R.stop_name??"",type:"text",name:`stoppage[${U}][name]`,label:"Place Name*",required:"required"})}),t.jsxs("div",{children:[t.jsx("label",{className:"labelfont",style:hr,children:"Pick Time"}),t.jsx(l.TimePicker,{defaultValue:I,use12Hours:!0,format:"h:mm a",name:`stoppage[${U}][pickTime]`,allowClear:!1,style:mr})]}),t.jsxs("div",{children:[t.jsx("label",{className:"labelfont",style:hr,children:"Drop Time"}),t.jsx(l.TimePicker,{defaultValue:H,use12Hours:!0,format:"h:mm a",name:`stoppage[${U}][drop_time]`,allowClear:!1,style:mr})]}),t.jsx("div",{style:{marginBottom:8},children:n.length>1&&t.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>k(U),children:t.jsx(he.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},R.idKey?R.idKey+"exp":R.id+"exp")})})]})}),t.jsx(oe,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:t.jsx(De,{variant:"h6",color:"white",children:"Stoppage List"})}),t.jsx(oe,{style:{padding:"10px 16px"},children:t.jsx(l.Table,{components:{body:{cell:yr}},columns:D,bordered:!0,size:"small",rowKey:R=>T(R),dataSource:v,loading:c,expandable:{expandedRowRender:Z,childrenColumnName:"changed"},pagination:{current:o.pagination.current,pageSize:o.pagination.pageSize,total:b,showSizeChanger:!0,onChange:j,onShowSizeChange:(R,U)=>{i(I=>({...I,pagination:{current:1,pageSize:U}}))},showTotal:(R,U)=>`${U[0]}-${U[1]} of ${R} items`}})})]})]})}const Bo=(e,n)=>{const r=String(e??"").replace(/\/+$/,""),a=String(n).replace(/^\/+/,"");return`${r}/${a}`};function No({token:e}){const n=e??localStorage.getItem("authToken")??"",[r,a]=h.useState(null),[s,o]=h.useState(null),[i,c]=h.useState(null),[x,p]=h.useState(null),[d,b]=h.useState(null),[v,S]=h.useState(null),[g,u]=h.useState(null),m="api/branchapi/library/bookCategorydropdown",_="api/branchapi/academy/classdropdownlist",P="api/branchapi/Academy/getClassSubjectdropdown",C="api/branchapi/library/addBook",k="api/branchapi/library/uploadcsv",{data:j}=se(n?[m,n]:null,([I,H])=>le(I,H)),{data:Q}=se(n&&_?[_,n]:null,([I,H])=>le(I,H)),{data:Z}=se(n&&P?[P,n]:null,([I,H])=>le(I,H)),T=h.useMemo(()=>Bo(vt(),k),[k]),D=async I=>{I.preventDefault();const H=new FormData(I.target);H.set("cat_id",d?.value??""),H.set("class_id",v?.value??""),H.set("subject_id",g?.value??"");try{await We(C,H,n),N.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),I.target.reset(),b(null),S(null),u(null)}catch(J){N.error(J?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},R=async I=>{if(I.preventDefault(),!r){N.error("Please select a CSV file.",{duration:1e3});return}const H=new FormData;H.append("file",r),H.append("cat_id",s?.value??""),H.append("class_id",i?.value??""),H.append("subject_id",x?.value??"");try{const J=await Se.post(T,H,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});J?.data?.Status==="Failed"?N.error(String(J?.data?.msg??"Upload failed."),{duration:1e3}):(N.success(String(J?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),a(null),I.target.reset(),o(null),c(null),p(null))}catch(J){N.error(J?.response?.data?.msg??"Upload failed.",{duration:1e3})}},U=()=>{fetch("/books.csv").then(I=>{I.blob().then(H=>{const J=window.URL.createObjectURL(H);let pe=document.createElement("a");pe.href=J,pe.download="/books.csv",pe.click()})})};return t.jsxs("div",{style:{display:"grid",gap:20},children:[t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsxs(l.Card,{title:t.jsx(l.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:t.jsx(l.Button,{type:"link",icon:t.jsx(he.DownloadOutlined,{}),onClick:U,children:"Download Sample"}),children:[t.jsx(l.Divider,{children:"Information"}),t.jsx(l.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."}),t.jsx("form",{onSubmit:R,children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[t.jsx(fe,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:s,onChange:I=>o(I??null)}),t.jsx(fe,{options:Q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:i,onChange:I=>c(I??null)}),t.jsx(fe,{options:Z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:x,onChange:I=>p(I??null)}),t.jsx(ae,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:I=>a(I.target.files?.[0]??null),required:!0}),t.jsx(we,{type:"submit",value:"Save",color:"primary"})]})})]}),t.jsx(l.Card,{title:t.jsx(l.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:t.jsx("form",{onSubmit:D,children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[t.jsx(ae,{type:"text",label:"Book Name",name:"title",required:!0}),t.jsx(ae,{type:"text",label:"Author",name:"author",required:!0}),t.jsx(ae,{type:"text",label:"Publication",name:"publisher"}),t.jsx(ae,{type:"number",label:"Qty",name:"quantity",required:!0}),t.jsx(ae,{type:"number",label:"Book Price",name:"price",required:!0}),t.jsx(ae,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),t.jsx(ae,{type:"text",label:"Barcode",name:"barcode"}),t.jsx(fe,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:d,onChange:I=>b(I??null)}),t.jsx(fe,{options:Q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:v,onChange:I=>S(I??null)}),t.jsx(fe,{options:Z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:g,onChange:I=>u(I??null)}),t.jsx(we,{type:"submit",value:"Save",color:"primary"})]})})})]})}const un={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},pn=e=>{const n=e?.data??e??[];return Array.isArray(n)?n:[]};function Fo({token:e}){const n=e??localStorage.getItem("authToken")??"",[r,a]=h.useState([]),[s,o]=h.useState([]),i=h.useRef(),c={selectedRowKeys:r,onChange:(O,$)=>{a(O),o($)}},x=xr.useReactToPrint({contentRef:i,documentTitle:"Book Barcodes"}),p=()=>{if(!(typeof window>"u")){if(!s.length){N.error("Select at least one book to print.",{duration:1e3});return}if(!i.current){N.error("Nothing to print.",{duration:1e3});return}x?.()}},[d,b]=h.useState(!1),[v,S]=h.useState(null),[g,u]=h.useState(null),[m,_]=h.useState(null),[P,C]=h.useState(null),[k,j]=h.useState({page:1,rowsPerPage:10}),Q=(O,$)=>{j({page:O,rowsPerPage:parseInt($,10)})},Z="api/branchapi/library/booktable",T="api/branchapi/library/deletebooks",D="api/branchapi/library/editbook",R=`${Z}?page=${k.page}&per_page=${k.rowsPerPage}`,{isLoading:U,error:I,data:H,mutate:J}=se(n?[R,n]:null,([O,$])=>le(O,$)),pe="api/branchapi/library/bookCategorydropdown",M="api/branchapi/academy/classdropdownlist",z="api/branchapi/Academy/getClassSubjectdropdown",{data:ce}=se(n?[pe,n]:null,([O,$])=>le(O,$)),{data:W}=se(n&&M?[M,n]:null,([O,$])=>le(O,$)),{data:f}=se(n&&z?[z,n]:null,([O,$])=>le(O,$)),y=h.useMemo(()=>pn(ce),[ce]),E=h.useMemo(()=>pn(W),[W]),A=h.useMemo(()=>pn(f),[f]),q=async O=>{try{await He(T,O,n),await J(),N.success("Success! Deleted item.",{duration:1e3})}catch($){N.error($?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ee=O=>{S(O??null);const $=O?.cat_id??O?.fk_cat_id??O?.category_id,K=O?.class_id??O?.fk_class_id,be=O?.subject_id??O?.fk_subject_id;u(y.find(F=>F?.value===$)??null),_(E.find(F=>F?.value===K)??null),C(A.find(F=>F?.value===be)??null),b(!0)},X=async O=>{O.preventDefault();const $=v?.id??v?.book_id??v?._id;if(!$)return;const K=new FormData(O.target);K.set("id",String($)),K.set("cat_id",g?.value??""),K.set("class_id",m?.value??""),K.set("subject_id",P?.value??"");try{await lt(D,K,n),await J(),N.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),b(!1),S(null)}catch(be){N.error(be?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},ne=h.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:(O,$)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(l.Button,{type:"text",size:"small",icon:t.jsx(he.EditOutlined,{}),onClick:()=>ee($),style:{padding:2}}),t.jsx(l.Button,{type:"text",size:"small",danger:!0,onClick:()=>q($?.id??$?.book_id??$?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[y,E,q,A]);return t.jsxs("div",{style:{},children:[t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(l.Drawer,{open:d,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{b(!1),S(null)},children:t.jsx("form",{onSubmit:X,children:t.jsxs("div",{style:{display:"grid",gap:16},children:[t.jsx(ae,{label:"Book Name",name:"title",defaultValue:v?.book_title??"",required:!0}),t.jsx(ae,{label:"Author",name:"author",defaultValue:v?.author??"",required:!0}),t.jsx(ae,{label:"Publication",name:"publish",defaultValue:v?.publish??""}),t.jsx(ae,{label:"Qty",name:"quantity",type:"number",defaultValue:v?.quantity??""}),t.jsx(ae,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:v?.perunitcost??""}),t.jsx(ae,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:v?.fine_amount??""}),t.jsx(ae,{label:"Barcode",name:"barcode",defaultValue:v?.barcode??""}),t.jsxs("div",{children:[t.jsx("label",{className:"labelfont",style:un,children:"Category"}),t.jsx(fe,{options:y,value:g,onChange:O=>u(O??null),name:"cat_id"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"labelfont",style:un,children:"Class"}),t.jsx(fe,{options:E,value:m,onChange:O=>_(O??null),name:"class_id"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"labelfont",style:un,children:"Subject"}),t.jsx(fe,{options:A,value:P,onChange:O=>C(O??null),name:"subject_id"})]}),t.jsxs("div",{style:{display:"flex",gap:12},children:[t.jsx(we,{type:"submit",value:"Update",color:"primary"}),t.jsx(l.Button,{type:"text",onClick:()=>{b(!1),S(null)},children:"Cancel"})]})]})})}),t.jsx(l.Card,{title:t.jsx(l.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:s.length>0?t.jsxs(l.Button,{type:"primary",onClick:p,children:["Print Barcode (",s.length,")"]}):null,children:t.jsx(Xe,{parentCallback:Q,data:{newData:H,columns:ne,columnstype:"antd",action:!1,Loading:U,error:I,rowSelection:c}})}),t.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:t.jsx("div",{ref:i,style:{padding:"20px"},children:t.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:s.map((O,$)=>t.jsxs("div",{style:{margin:"10px",textAlign:"center",border:"1px dashed black",padding:"10px",borderRadius:"5px",width:"fit-content"},children:[t.jsx("div",{style:{fontSize:"12px",fontWeight:"bold",maxWidth:"200px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:O.book_title}),t.jsx(Zr,{value:O.barcode?String(O.barcode):String(O.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},$))})})})]})}const $o=(e,n)=>{const r=String(e??"").replace(/\/+$/,""),a=String(n).replace(/^\/+/,"");return`${r}/${a}`},Ze=e=>{const n=e?.data??e??[];return Array.isArray(n)?n:[]};function Lo({token:e}){const n=e??localStorage.getItem("authToken")??"",r=JSON.parse(localStorage.getItem("genrall_settings")??"null")?.currency_symbol??"",[a,s]=h.useState("issue"),o=a==="return",[i,c]=h.useState(!1),[x,p]=h.useState(!1),[d,b]=h.useState(null),[v,S]=h.useState([]),[g,u]=h.useState([]),[m,_]=h.useState([]),[P,C]=h.useState(0),[k,j]=h.useState(!1),[Q,Z]=h.useState(null),[T,D]=h.useState(null),[R,U]=h.useState(null),[I,H]=h.useState(!1),[J,pe]=h.useState("Cash"),[M,z]=h.useState(""),[ce,W]=h.useState(""),[f,y]=h.useState(0),E=h.useRef(null),[A]=l.Form.useForm(),[q]=l.Form.useForm(),ee="api/branchapi/library/bookCategorydropdown",X="api/branchapi/academy/classdropdownlist",ne="api/branchapi/Academy/getClassSubjectdropdown",{data:O}=se(n?[ee,n]:null,([L,ue])=>le(L,ue)),{data:$}=se(n&&X?[X,n]:null,([L,ue])=>le(L,ue)),{data:K}=se(n&&ne?[ne,n]:null,([L,ue])=>le(L,ue)),be=h.useMemo(()=>Ze(O),[O]),F=h.useMemo(()=>Ze($),[$]),je=h.useMemo(()=>Ze(K),[K]),Re="api/branchapi/library/studentsearchByNameID",ze="api/branchapi/library/booksearchBybookname",Ge="api/branchapi/library/issuedBookList",Qe="api/branchapi/library/issueLibrarybook",Ye="api/branchapi/library/returnedLibrarybook",{trigger:$e,data:Be}=et(Re,(L,ue)=>Zt(L,ue,n)),{trigger:Le,data:Ae}=et(ze,(L,ue)=>Zt(L,ue,n)),{trigger:_e,data:Ee}=et(Ge,(L,ue)=>Zt(L,ue,n)),{trigger:Ke}=et(o?Ye:Qe,(L,ue)=>Fs(L,ue,n)),tt=h.useMemo(()=>Ze(Be),[Be]),Je=h.useMemo(()=>Ze(Ae),[Ae]),Me=h.useMemo(()=>Ze(Ee),[Ee]),V=L=>{const ue=ge().format("YYYY-MM-DD");S(ve=>ve.some(gt=>String(gt?.id)===String(L?.id))?ve:[...ve,{...L,return_date:L?.return_date?L.return_date:ue}])},Y=L=>{S(ue=>ue.filter(ve=>String(ve?.id)!==String(L)))},de=async L=>{if(n){if(!L){b(null);return}i||await $e({id:L})}},Te=async({search:L})=>{if(!n||!i)return;const ue=await $e({id:L}),ve=Ze(ue);ve.length===1&&(b(ve[0]),await _e({id:ve[0]?.student_id}),A.resetFields())},xe=async(L,ue)=>{b(ue??null),S([]),u([]),_([]),C(0),ue?.student_id&&await _e({id:ue.student_id}),A.resetFields()},nt=async L=>{n&&L&&(x||await Le({book:L}))},rt=async({search_book:L})=>{if(!n||!x)return;const ue=await Le({book:L,catID:Q?.value??"",sID:R?.value??"",cID:T?.value??""}),ve=Ze(ue);ve.length&&(V(ve[0]),q.resetFields())},yt=(L,ue)=>{V(ue),q.resetFields()},G=async()=>{if(!d?.member_id){N.error("Select a student first.",{duration:1e3});return}if(!v.length){N.error("Select at least one book.",{duration:1e3});return}const L=await Ke({member_id:d.member_id,fine:!1,books:v});L?.Status==="Success"?(N.success(String(L?.msg??"Success"),{duration:1e3}),S([]),b(null),u([]),_([]),C(0)):N.error(String(L?.msg??"Failed"),{duration:1e3})},ie=async()=>{if(!d?.member_id){N.error("Select a student first.",{duration:1e3});return}if(!m.length){N.error("Select at least one book to return.",{duration:1e3});return}if(Number(P)>0){H(!0);return}const L=await Ke({member_id:d.member_id,fine:!1,books:JSON.stringify(m)});L?.Status==="Success"?(N.success(String(L?.msg??"Success"),{duration:1e3}),u([]),_([]),C(0),await _e({id:d?.student_id})):N.error(String(L?.msg??"Failed"),{duration:1e3})},Pe=async()=>{if(!d?.member_id)return;const L=Math.max(0,Number(P)-Number(f||0)),ue={member_id:d.member_id,amount:L,fine:!0,books:JSON.stringify(m),payment_type:J,notes:M,attchement:ce,discount:f||0},ve=await Ke(ue);H(!1),ve?.Status==="Success"?(N.success(String(ve?.msg??"Success"),{duration:1e3}),u([]),_([]),C(0),y(0),z(""),W(""),await _e({id:d?.student_id})):N.error(String(ve?.msg??"Failed"),{duration:1e3})},B=h.useMemo(()=>$o(vt(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),te=[{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:(L,ue)=>t.jsx(l.Input,{value:ue?.return_date??"",onChange:ve=>{const gt=ve.target.value;S(Ht=>Ht.map(Yt=>String(Yt?.id)===String(ue?.id)?{...Yt,return_date:gt}:Yt))},placeholder:"YYYY-MM-DD"})},{title:"Action",key:"action",width:120,fixed:"right",render:(L,ue)=>t.jsx(l.Button,{type:"text",danger:!0,onClick:()=>Y(ue?.id),children:"Remove"})}],Ne={selectedRowKeys:g,onChange:(L,ue)=>{u(L),_(ue);const ve=(ue??[]).reduce((gt,Ht)=>gt+Number(Ht?.totalfine??0),0);C(ve)}},at=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:L=>t.jsxs("span",{children:[r," ",L]})}];return t.jsxs("div",{style:{display:"grid",gap:16},children:[t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(l.Modal,{open:I,onCancel:()=>H(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:t.jsxs("div",{style:{display:"grid",gap:12},children:[t.jsx(l.Radio.Group,{value:J,onChange:L=>pe(L.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"}]}),t.jsxs("div",{children:[t.jsx("label",{className:"labelfont",children:"Note"}),t.jsx(l.Input.TextArea,{rows:3,value:M,onChange:L=>z(L.target.value)})]}),t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("label",{className:"labelfont",children:"Image Attachment"}),t.jsx(l.Upload,{action:B,headers:{Authorization:n},maxCount:1,onChange:L=>{if(L.file.status==="done"){const ue=L.file.response?.data??L.file.response?.file??"";W(String(ue??""))}},children:t.jsx(l.Button,{icon:t.jsx(he.UploadOutlined,{}),children:"Upload"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"labelfont",children:"Discount"}),t.jsx(l.Input,{type:"number",value:f,onChange:L=>y(L.target.value),placeholder:"0"})]}),t.jsxs(l.Button,{type:"primary",onClick:Pe,children:["Collect ",r,Math.max(0,Number(P)-Number(f||0))]})]})}),t.jsxs(l.Card,{title:t.jsx(l.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[t.jsxs(l.Row,{gutter:[16,16],align:"middle",children:[t.jsx(l.Col,{xs:24,md:10,children:t.jsx(l.Radio.Group,{value:a,onChange:L=>{const ue=L.target.value;s(ue),S([]),u([]),_([]),C(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"}],optionType:"button",buttonStyle:"solid"})}),t.jsx(l.Col,{xs:24,md:14,children:t.jsx(l.Form,{form:A,onFinish:Te,layout:"vertical",children:t.jsx(l.Form.Item,{name:"search",label:"Search Student",children:t.jsx(l.Space.Compact,{style:{width:"100%"},children:i?t.jsx(l.Input,{autoFocus:!0,addonBefore:t.jsxs(l.Space,{children:[t.jsx(he.BarcodeOutlined,{}),t.jsx(l.Checkbox,{checked:i,onChange:L=>c(L.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):t.jsx(l.AutoComplete,{options:tt,onSelect:xe,onSearch:de,style:{width:"100%"},allowClear:!0,children:t.jsx(l.Input,{addonBefore:t.jsxs(l.Space,{children:[t.jsx(he.BarcodeOutlined,{}),t.jsx(l.Checkbox,{checked:i,onChange:L=>c(L.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),d?t.jsxs(t.Fragment,{children:[t.jsx(l.Divider,{}),t.jsxs(l.Row,{gutter:[12,12],children:[t.jsxs(l.Col,{xs:24,md:8,children:[t.jsx(l.Typography.Text,{strong:!0,children:"Name:"})," ",d?.value??""]}),t.jsxs(l.Col,{xs:24,md:8,children:[t.jsx(l.Typography.Text,{strong:!0,children:"Card No:"})," ",d?.library_card_no??""]}),t.jsxs(l.Col,{xs:24,md:8,children:[t.jsx(l.Typography.Text,{strong:!0,children:"Member ID:"})," ",d?.member_id??""]})]})]}):null,t.jsx(l.Divider,{}),o?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{width:"100%",overflowX:"auto"},children:t.jsx("div",{style:{minWidth:760},children:t.jsx(l.Table,{dataSource:Me,columns:at,rowSelection:Ne,pagination:!1,rowKey:L=>L?.id??L?.issue_id??L?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),t.jsx(l.Divider,{}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[t.jsxs(l.Typography.Text,{strong:!0,children:["Total Fine: ",r,P]}),t.jsx(l.Button,{type:"primary",onClick:ie,disabled:!m.length,children:P>0?`Pay Now ${r}${Math.max(0,Number(P)-Number(f||0))}`:"Return Selected"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(l.Row,{gutter:[16,16],align:"middle",children:[t.jsx(l.Col,{xs:24,md:18,children:t.jsx(l.Form,{form:q,onFinish:rt,layout:"vertical",children:t.jsx(l.Form.Item,{name:"search_book",label:"Search Book",children:t.jsx(l.Space.Compact,{style:{width:"100%"},children:x?t.jsx(l.Input,{autoFocus:!0,disabled:!d,addonBefore:t.jsxs(l.Space,{children:[t.jsx(he.BarcodeOutlined,{}),t.jsx(l.Checkbox,{checked:x,onChange:L=>p(L.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):t.jsx(l.AutoComplete,{disabled:!d,options:Je,onSelect:yt,onSearch:nt,style:{width:"100%"},allowClear:!0,children:t.jsx(l.Input,{addonBefore:t.jsxs(l.Space,{children:[t.jsx(he.BarcodeOutlined,{}),t.jsx(l.Checkbox,{checked:x,onChange:L=>p(L.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),t.jsx(l.Col,{xs:24,md:6,children:t.jsx(l.Button,{style:{width:"100%"},icon:t.jsx(he.FilterOutlined,{}),onClick:()=>j(!0),children:"Filter"})})]}),t.jsx(l.Drawer,{open:k,onClose:()=>j(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:t.jsxs("div",{style:{display:"grid",gap:16},children:[t.jsx(fe,{label:"Category",options:be,value:Q,onChange:L=>Z(L??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),t.jsx(fe,{label:"Class",options:F,value:T,onChange:L=>D(L??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),t.jsx(fe,{label:"Subjects",options:je,value:R,onChange:L=>U(L??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),t.jsx(l.Button,{type:"primary",onClick:()=>j(!1),children:"Apply"})]})}),t.jsx(l.Divider,{}),t.jsx("div",{style:{width:"100%",overflowX:"auto"},children:t.jsx("div",{style:{minWidth:720},children:t.jsx(l.Table,{dataSource:v,columns:te,pagination:!1,rowKey:L=>L?.id??L?.book_id??L?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),t.jsx(l.Divider,{}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx(we,{type:"button",value:"Issue",onClick:G})})]})]}),t.jsx("div",{ref:E,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}const br=e=>{const n=e?.data??e??[];return Array.isArray(n)?n:[]};function qo({token:e}){const n=e??localStorage.getItem("authToken")??"",[r,a]=h.useState({page:1,rowsPerPage:10}),[s,o]=h.useState(null),[i,c]=h.useState(null),[x,p]=h.useState(!1),[d,b]=h.useState(!1),[v,S]=h.useState(null),[g,u]=h.useState(!1),m="api/branchapi/academy/classdropdownlist",_="api/branchapi/academy/sectionoftheClass",P="api/branchapi/library/studenttableForLibrary",C="api/branchapi/library/addmembershipforStudent",k="api/branchapi/library/removemembershipforStudent",j=h.useMemo(()=>{if(!s?.value)return null;const f=_.includes("?")?"&":"?";return`${_}${f}class_id=${encodeURIComponent(String(s.value))}`},[_,s?.value]),Q=h.useMemo(()=>{if(!s?.value||!i?.value)return null;const f=P.includes("?")?"&":"?";return`${P}${f}cID=${encodeURIComponent(String(s.value))}&sID=${encodeURIComponent(String(i.value))}&page=${r.page}&per_page=${r.rowsPerPage}`},[r.page,r.rowsPerPage,s?.value,i?.value,P]),{data:Z}=se(n&&m?[m,n]:null,([f,y])=>le(f,y)),{data:T}=se(n&&j?[j,n]:null,([f,y])=>le(f,y)),{isLoading:D,error:R,data:U,mutate:I}=se(n&&Q?[Q,n]:null,([f,y])=>le(f,y)),H=h.useMemo(()=>br(Z),[Z]),J=h.useMemo(()=>br(T),[T]),pe=(f,y)=>{a({page:f,rowsPerPage:parseInt(y,10)})},M=f=>{const y=f?.id??f?.student_id??f?.member_id;S(y??null),b(!0),u(E=>!E)},z=async f=>{if(f.preventDefault(),!v)return;const y=new FormData(f.target);y.set("id",String(v));try{await We(C,y,n),N.success("Success! Added member.",{duration:1e3,icon:"🎉"}),b(!1),S(null),await I()}catch(E){N.error(E?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},ce=async f=>{try{await He(k,f,n),N.success("Success! Removed member.",{duration:1e3}),await I()}catch(y){N.error(y?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},W=h.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:(f,y)=>(console.log("data______________",y),t.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:y?.library_card_no==null?t.jsx(l.Button,{type:"primary",size:"small",icon:t.jsx(he.UserAddOutlined,{}),onClick:()=>M(y)}):t.jsx(l.Button,{danger:!0,type:"text",size:"small",icon:t.jsx(he.DeleteOutlined,{}),onClick:()=>ce(y?.id??y?.student_id??y?.member_id)})}))}],[ce]);return t.jsxs("div",{style:{},children:[t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(l.Modal,{open:d,title:"Add Member",onCancel:()=>{b(!1),S(null)},footer:null,destroyOnClose:!0,children:t.jsx("form",{onSubmit:z,children:t.jsxs("div",{style:{display:"grid",gap:16},children:[t.jsx(ae,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx(we,{type:"submit",value:"Add",color:"primary"})})]})},`add-${g}`)}),t.jsx(l.Card,{title:t.jsx(l.Typography.Title,{level:5,style:{margin:0},children:"Add Student"}),children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[t.jsx(fe,{options:H,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:s,onChange:f=>{o(f??null),c(null),p(y=>!y)},name:"class_id",required:!0,allowSelectAll:!1}),t.jsx(fe,{options:J,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:i,onChange:f=>c(f??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${x}`),t.jsx(we,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!s?.value||!i?.value){N.error("Select class and section.",{duration:1e3});return}a(f=>({...f,page:1}))}})]})}),t.jsx(l.Card,{title:t.jsx(l.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:t.jsx(Xe,{parentCallback:pe,data:{newData:U,columns:W,columnstype:"antd",action:!1,Loading:D,error:R}})})]})}function zo({token:e}){const n=e??localStorage.getItem("authToken")??"",[r,a]=h.useState({page:1,rowsPerPage:10}),[s]=l.Form.useForm(),[o]=l.Form.useForm(),[i,c]=h.useState(!1),[x,p]=h.useState(null),d="api/branchapi/library/BookCategorytable",b="api/branchapi/library/addBookCategory",v="api/branchapi/library/editBookCategory",S="api/branchapi/library/deleteBookCategory",g=h.useMemo(()=>{const R=d.includes("?")?"&":"?";return`${d}${R}page=${r.page}&per_page=${r.rowsPerPage}`},[d,r.page,r.rowsPerPage]),{isLoading:u,error:m,data:_,mutate:P}=se(n&&g?[g,n]:null,([R,U])=>le(R,U)),C=(R,U)=>{a({page:R,rowsPerPage:parseInt(U,10)})},k=async R=>{const U=new FormData;U.set("title",R?.title??"");try{await We(b,U,n),N.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),s.resetFields(),await P()}catch(I){N.error(I?.response?.data?.msg??I?.message??"Failed to add category.",{duration:1e3})}},j=R=>{p(R??null),o.setFieldsValue({title:R?.name??""}),c(!0)},Q=()=>{c(!1),p(null),o.resetFields()},Z=async R=>{const U=x?.id??x?.category_id??x?.cat_id;if(!U){N.error("Missing category id.",{duration:1e3});return}const I=new FormData;I.set("id",String(U)),I.set("title",R?.title??"");try{await lt(v,I,n),N.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),Q(),await P()}catch(H){N.error(H?.response?.data?.msg??H?.message??"Failed to update category.",{duration:1e3})}},T=async R=>{const U=R?.id??R?.category_id??R?.cat_id;if(!U){N.error("Missing category id.",{duration:1e3});return}try{await He(S,U,n),N.success("Success! Deleted category.",{duration:1e3}),await P()}catch(I){N.error(I?.response?.data?.msg??I?.message??"Failed to delete category.",{duration:1e3})}},D=h.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(R,U)=>t.jsxs(l.Space,{size:6,children:[t.jsx(l.Button,{type:"text",size:"small",icon:t.jsx(he.EditOutlined,{}),onClick:()=>j(U)}),t.jsx(l.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>T(U),children:t.jsx(l.Button,{danger:!0,type:"text",size:"small",icon:t.jsx(he.DeleteOutlined,{})})})]})}],[T]);return t.jsxs("div",{children:[t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsx(l.Modal,{open:i,title:"Edit Category",onCancel:Q,footer:null,destroyOnClose:!0,children:t.jsxs(l.Form,{form:o,layout:"vertical",onFinish:Z,children:[t.jsx(l.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:t.jsx(l.Input,{placeholder:"Enter category name"})}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[t.jsx(l.Button,{onClick:Q,children:"Cancel"}),t.jsx(we,{type:"submit",value:"Update",color:"primary"})]})]})}),t.jsxs(l.Row,{gutter:[16,16],children:[t.jsx(l.Col,{xs:24,lg:8,children:t.jsx(l.Card,{title:t.jsx(l.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:t.jsxs(l.Form,{form:s,layout:"vertical",onFinish:k,children:[t.jsx(l.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:t.jsx(l.Input,{placeholder:"Enter category name"})}),t.jsx(we,{type:"submit",value:"Add",color:"primary"})]})})}),t.jsx(l.Col,{xs:24,lg:16,children:t.jsx(l.Card,{title:t.jsx(l.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:t.jsx(Xe,{parentCallback:C,data:{newData:_,columns:D,columnstype:"antd",action:!1,Loading:u,error:m}})})})]})]})}const fn=e=>{const n=e?.data??e??[];return Array.isArray(n)?n:[]};function Vo({token:e}){const[n,r]=h.useState([ge().format("YYYY-MM-DD"),ge().format("YYYY-MM-DD")]),[a,s]=h.useState(null),[o,i]=h.useState(null),[c,x]=h.useState(null),[p,d]=h.useState(!1),[b,v]=h.useState(!1),S="api/branchapi/academy/classdropdownlist",g="api/branchapi/academy/sectionoftheClass",u="api/branchapi/library/memberDropdown",m="api/report/libraryReport/libraryReport",_=h.useMemo(()=>{if(!a?.value)return null;const M=g.includes("?")?"&":"?";return`${g}${M}class_id=${encodeURIComponent(String(a.value))}`},[g,a?.value]),P=h.useMemo(()=>{if(!a?.value)return null;const M=u.includes("?")?"&":"?",z=`${u}${M}class=${encodeURIComponent(String(a.value))}`;return o?.value?`${z}§ion=${encodeURIComponent(String(o.value))}`:z},[u,a?.value,o?.value]),{isLoading:C,error:k,data:j,mutate:Q}=se(e&&S?[S,e]:null,([M,z])=>le(M,z)),{data:Z}=se(e&&_?[_,e]:null,([M,z])=>le(M,z)),{data:T}=se(e&&P?[P,e]:null,([M,z])=>le(M,z)),D=h.useMemo(()=>fn(j),[j]),R=h.useMemo(()=>fn(Z),[Z]),U=h.useMemo(()=>fn(T),[T]),{trigger:I,data:H}=et(m,(M,z)=>$s(M,z,e));h.useEffect(()=>{(async()=>{v(!0);try{await I({duration:n})}finally{v(!1)}})()},[]);const J=async()=>{v(!0);try{await I({duration:n,class:a?.value??"",section:o?.value??"",student_id:c?.value??""})}finally{v(!1)}},pe=[{title:"Name",dataIndex:"full_name",render:(M,z)=>t.jsx(l.Typography.Text,{style:{fontSize:12},children:z?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(M,z)=>t.jsx(l.Typography.Text,{style:{fontSize:12},children:z?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(M,z)=>t.jsxs(l.Typography.Text,{style:{fontSize:12},children:[z?.class??"","(",z?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(M,z)=>t.jsx(l.Typography.Text,{style:{fontSize:12},children:z?.book_title??""})},{title:"Issue Date",key:"date",render:(M,z,ce)=>t.jsx(l.Typography.Text,{style:{fontSize:12},children:z?.issue_date??""})},{title:"Due Return Date",key:"date",render:(M,z,ce)=>t.jsx(l.Tag,{color:"orange",children:z?.return_date??""})},{title:"Return Date",key:"date",render:(M,z,ce)=>z?.retured_by_user?t.jsx(l.Tag,{color:"green",children:z?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(M,z,ce)=>String(z?.is_returned??"")==="1"?t.jsx(l.Tag,{color:"green",children:"Return"}):t.jsx(l.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(M,z,ce)=>{const W=z?.late_fine?Number(z.late_fine):0;return W?t.jsx(l.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:W}):null}}];return t.jsxs("div",{children:[t.jsx(N.Toaster,{toastOptions:{position:"top-center"}}),t.jsxs(l.Card,{title:t.jsx(l.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[t.jsxs(l.Row,{gutter:[16,16],align:"bottom",children:[t.jsx(l.Col,{xs:24,md:8,children:t.jsxs("div",{children:[t.jsx("label",{className:"labelfont",children:"Duration"}),t.jsx(l.DatePicker.RangePicker,{style:{width:"100%"},value:[ge(n[0],"YYYY-MM-DD"),ge(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(M,z)=>{Array.isArray(z)&&z.length===2&&r([z[0],z[1]])}})]})}),t.jsx(l.Col,{xs:24,md:5,children:t.jsx(fe,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:a,onChange:M=>{s(M??null),i(null),x(null),d(z=>!z)},allowSelectAll:!1})}),t.jsx(l.Col,{xs:24,md:5,children:t.jsx(fe,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:o,onChange:M=>{i(M??null),x(null)},allowSelectAll:!1},`section1${p}`)}),t.jsx(l.Col,{xs:24,md:5,children:t.jsx(fe,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:M=>x(M??null),allowSelectAll:!1})}),t.jsx(l.Col,{xs:24,md:1,children:t.jsx(l.Button,{type:"primary",icon:t.jsx(he.SearchOutlined,{}),onClick:J,style:{width:"100%"},children:"Search"})})]}),t.jsx("div",{style:{marginTop:16},children:t.jsx(l.Table,{columns:pe,pagination:!1,dataSource:Array.isArray(H?.data)?H.data:[],size:"small",rowKey:(M,z)=>M?.id??M?.issue_id??M?.fees_receipt_id??z,loading:b,scroll:{x:"max-content"},summary:M=>{const z=M.reduce((W,f)=>W+Number(f?.late_fine??0),0),ce=M.reduce((W,f)=>W+Number(f?.is_returned??0),0);return t.jsxs(l.Table.Summary.Row,{children:[t.jsx(l.Table.Summary.Cell,{colSpan:4,children:t.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",M.length]})}),t.jsx(l.Table.Summary.Cell,{colSpan:2,children:t.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(M.length-ce)]})}),t.jsx(l.Table.Summary.Cell,{colSpan:2,children:t.jsxs("span",{style:{fontWeight:700},children:["Return: ",ce]})}),t.jsx(l.Table.Summary.Cell,{colSpan:1,children:t.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",z.toLocaleString("en-IN")]})})]})}})})]})]})}const Wo=({routes:e=[],onNavigate:n})=>t.jsx(l.Row,{gutter:[16,16],children:e.map((r,a)=>t.jsx(l.Col,{xs:24,md:8,lg:8,children:t.jsx(oe,{children:t.jsx(wr,{icon:r?.icon??"",title:r?.title??"",path:r?.path??"",onClick:n})})},`${a}route001`))});exports.AddBook=No;exports.AddDriver=ko;exports.AdmissionEnquiry=po;exports.AssignStudentToTransport=Po;exports.AssignVehicles=wo;exports.BookList=Fo;exports.ErpDashboard=ea;exports.IssueReturn=Lo;exports.LibraryAssignStudent=qo;exports.LibraryCategory=zo;exports.LibraryReport=Vo;exports.MenuSubmenu=Ls;exports.RoutePage=Wo;exports.RouteTimeTable=Io;exports.Stoppage=Uo;exports.TransportRoutes=ho;exports.TransportVehicles=mo;exports.setBaseUrl=Bs;
|
|
59
|
+
`}),e.jsx(de,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(ia,{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(r.Select,{size:"small",value:R.rowsPerPage,onChange:Q=>F(1,Q),options:[10,25,50,100].map(Q=>({label:Q,value:Q})),style:{width:72}}),e.jsx("span",{children:"entries"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:12,color:"#222"},children:"Search:"}),e.jsx(r.Input,{size:"small",allowClear:!0,value:B,onChange:Q=>{q(Q.target.value),w(oe=>({...oe,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(re.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(hn,{})}),fe]}),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 ${ue} to ${he} of ${ze} entries`}),e.jsx(r.Pagination,{current:R.page,pageSize:R.rowsPerPage,total:ze||0,showSizeChanger:!1,onChange:F})]})]})]})},jl=({token:t,type:n})=>{const[a,s]=i.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${a.page}&per_page=${a.rowsPerPage}`,{isLoading:u,data:S,error:g}=K(t?[d,t]:null,([D,_])=>G(D,_)),[p,j]=i.useState(!1),I=(D,_)=>{s({page:D,rowsPerPage:parseInt(_)})},T=async D=>{},m=D=>{console.log("dsdsdsdsd",D),j(D)},c=()=>{},y=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],O=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(D,_)=>D.name.localeCompare(_.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(D,_)=>(D.contact||"").localeCompare(_.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(D,_)=>(D.description||"").localeCompare(_.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(D,_)=>(D.source_name||"").localeCompare(_.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(D,_)=>new Date(D.date)-new Date(_.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(D,_)=>new Date(D.follow_up_date)-new Date(_.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Me,{parentCallback:I,data:{newData:S,columns:O,action:!0,Loading:u,error:g,open:p,viewDetails:c,deleteTodoMutation:T,DrawerUpdate:m,ActionView:y}})})},wl={minWidth:160,height:36,padding:"0 28px",border:"none",borderRadius:999,background:"linear-gradient(90deg, #f59b1c 0%, #ef3e7b 100%)",color:"#fff",fontSize:14,fontWeight:700,textTransform:"uppercase",cursor:"pointer",boxShadow:"none"},pe=i.forwardRef(({error:t,success:n,disabled:a,style:s,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:a,style:{...wl,opacity:a?.7:1,cursor:a?"not-allowed":"pointer",...s||{}}})})),ot=({id:t,funcName:n,disabled:a=!1})=>{const s="Data",[o,l]=i.useState(!1),d=()=>{l(!0),n(t),r.message.success(`${s} deleted successfully!`)},u=()=>{r.message.info(`Deletion of ${s} cancelled`)};return e.jsx(r.Popconfirm,{title:`Delete ${s}?`,description:`Are you sure you want to delete ${s}?`,onConfirm:d,onCancel:u,okText:"Yes",cancelText:"No",disabled:a||o,children:e.jsx(r.Button,{danger:!0,disabled:a,loading:o,icon:e.jsx(re.DeleteOutlined,{}),size:"small"})})},Ze=t=>({optimisticData:n=>[...n.data,t],populateCache:(n,a)=>[...a.data,n]}),Ke=t=>({optimisticData:n=>n.data.filter(a=>a.id!==t),populateCache:(n,a)=>a.data.filter(s=>s.id!==t)}),Pr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function vl({token:t}){const[n,a]=i.useState({pagination:{current:1,pageSize:10}}),[s,o]=i.useState(!1),[l,d]=i.useState(null),u=`api/branchapi/Transport/routeTableList?page=${n.pagination.current}&per_page=${n.pagination.pageSize}`,S="api/branchapi/Transport/addroute",g="api/branchapi/Transport/editroute",p="api/branchapi/Transport/deleteroute",{isLoading:j,data:I,error:T,mutate:m}=K(t?[u,t]:null,([C,P])=>G(C,P)),c=async(C,P)=>{try{await m(Ye(C,P,t),Ze(P)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},y=C=>{C.preventDefault();const P=new FormData(C.target);c(S,P),C.target.reset()},O=(C,P)=>{a(k=>({...k,pagination:{current:C,pageSize:parseInt(P,10)}}))},D=async C=>{try{await m(tt(p,C,t),Ke(C)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},_=C=>{d(C),o(!0)},A=async C=>{try{await ut(g,C,t),await m(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},h=async C=>{C.preventDefault();const P=new FormData(C.target);P.append("id",l?.id),A(P)},f=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(C,P)=>C.name.localeCompare(P.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(C,P)=>C.fare-P.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(C,P)=>C.note.localeCompare(P.note)}},{title:"Action",key:"action",render:(C,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>_(P),style:{padding:2}}),e.jsx(ot,{id:P?.id,funcName:D})]})}],x=l?.route_title?`Edit ${l.route_title}`:"Edit Route";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:s,title:x,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:h,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(X,{type:"text",name:"title",label:"Title",defaultValue:l?.route_title||"",required:"required"}),e.jsx(X,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:l?.fare||"",required:"required"}),e.jsx(X,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(X,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Pr,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Route"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"}),e.jsx(X,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"}),e.jsx(X,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"reset",style:Pr,children:"Cancel"})]})]})})})]})}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Route List"})}),e.jsx(de,{children:e.jsx(Me,{parentCallback:O,data:{newData:I,columns:f,columnstype:"antd",action:!1,Loading:j,error:T,deleteTodoMutation:D}})})]})})]})})]})}const Er={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function _l({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),u=`api/branchapi/Transport/vehiclesTableList?page=${n.page}&per_page=${n.rowsPerPage}`,S="api/branchapi/Transport/addvehicles",g="api/branchapi/Transport/editvehicle",p="api/branchapi/Transport/deletevehicle",{isLoading:j,data:I,error:T,mutate:m}=K(t?[u,t]:null,([C,P])=>G(C,P)),c=async(C,P)=>{try{await m(Ye(C,P,t),Ze(P)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},y=C=>{C.preventDefault();const P=new FormData(C.target);c(S,P),C.target.reset()},O=async C=>{try{await m(tt(p,C,t),Ke(C)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},D=C=>{d(C),o(!0)},_=async C=>{try{await ut(g,C,t),await m(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},A=async C=>{C.preventDefault();const P=new FormData(C.target);P.append("id",l?.id),_(P)},h=(C,P)=>{a({page:C,rowsPerPage:parseInt(P,10)})},f=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(C,P)=>C.vehicle_no.localeCompare(P.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(C,P)=>C.vehicle_model.localeCompare(P.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(C,P)=>C.seating_capacity-P.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(C,P)=>C.manufacture_year-P.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(C,P)=>C.gps_url.localeCompare(P.gps_url)},render:(C,P)=>e.jsx("span",{title:P?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:P?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(C,P)=>C.note.localeCompare(P.note)}},{title:"Action",key:"action",render:(C,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>D(P),style:{padding:2}}),e.jsx(ot,{id:P?.id,funcName:O})]})}],x=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:s,title:x,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(X,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(X,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(X,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(X,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(X,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(X,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Er,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(X,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(X,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(X,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(X,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(X,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"reset",style:Er,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(de,{children:e.jsx(Me,{parentCallback:h,data:{newData:I,columns:f,columnstype:"antd",action:!1,Loading:j,error:T,deleteTodoMutation:O}})})]})})]})})]})}var Cl=Qs();const Ca=Ks(Cl),ai=()=>{};class Ga extends i.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=n=>{this.selectRef=n};componentDidUpdate(n){n.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(n,a)=>{this.props.onChange(n,a),this.setState({value:n})};getValue=()=>{const{value:n}=this.state;return n?Array.isArray(n)?n.length?"valid":"":typeof n=="object"?n.value||"":n:""};render(){const{SelectComponent:n,required:a,...s}=this.props;console.log("sdsdsfsdddddddd",{...s});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(n,{...s,ref:this.setSelectRef,onChange:this.onChange}),l&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:ai,onFocus:()=>this.selectRef.focus(),required:a})]})}}Ga.defaultProps={onChange:ai};Ga.protoTypes={selectComponent:Ca.func.isRequired,onChange:Ca.func,required:Ca.bool};const Tl={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Al={menuPortal:t=>({...t,zIndex:9999}),control:(t,n)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${n.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${n.isFocused?"#222":"#a8a8a8"}`}}),valueContainer:t=>({...t,height:40,padding:"0 0",display:"flex",alignItems:"center"}),input:t=>({...t,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),indicatorsContainer:t=>({...t,height:40}),dropdownIndicator:(t,n)=>({...t,padding:"0 0 0 8px",color:n.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,n)=>({...t,fontSize:"14px",backgroundColor:n.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},ri=t=>e.jsx(vs.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),Il=t=>e.jsx(Ga,{...t,SelectComponent:vs,components:{Input:ri},options:t.options}),te=i.forwardRef(({...t},n)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:Tl,children:t?.label}),e.jsx(Il,{components:{Input:ri},menuPortalTarget:document.body,styles:Al,className:"input-cont",...t,ref:n})]})),Rl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Fr=({dataIndex:t,title:n,record:a,children:s,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:s}):s});function Dl({token:t}){const[n,a]=i.useState(!1),[s,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[u,S]=i.useState([]),g="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleDropdown",j="api/branchapi/Transport/getchechkedVehicleData",I="api/branchapi/Transport/assignedVehicleTable",T="api/branchapi/transport/assignvehicle",m="api/branchapi/Transport/deleteassignvehicle",c=l?`${j}?route_id=${l}`:null,{isLoading:y,data:O,mutate:D}=K(t?[`${I}?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,t]:null,([w,M])=>G(w,M)),{data:_}=K(t&&g?[g,t]:null,([w,M])=>G(w,M)),{data:A}=K(t&&p?[p,t]:null,([w,M])=>G(w,M)),h=t&&c?[c,t]:null,{isLoading:f,data:x}=K(h,([w,M])=>G(w,M)),{Status:C="Failed",pagination:{total_rows:P=0}={}}=O||{},{data:k=[]}=C==="Success"?O:{},U=i.useMemo(()=>{const w=_?.data??_??[];return Array.isArray(w)?w:[]},[_]),b=i.useMemo(()=>{const w=A?.data??A??[];return(Array.isArray(w)?w:[]).map(F=>{if(F==null)return null;if(typeof F=="string"||typeof F=="number")return{label:String(F),value:F};const L=F.value??F.vehicle_id??F.id??F.vehicleID,ee=F.label??F.vehicle_name??F.vehicle_no??F.vehicle_number??F.name??String(L??"");return L==null||ee===""?null:{label:String(ee),value:L}}).filter(Boolean)},[A]),E=i.useMemo(()=>{const w=x?.data??x??[];return(Array.isArray(w)?w:[]).map(F=>F?.value??F?.vehicle_id??F?.id??F).filter(F=>F!=null)},[x]);i.useEffect(()=>{S(E)},[E,n]);const B=async(w,M,F)=>{try{await D(Ye(w,M,t),Ze(M)),c&&K.mutate(h),a(L=>!L),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(L){v.error(L?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},q=w=>{w.preventDefault();const M=new FormData;M.append("route_id",l??""),u.length?u.forEach(F=>M.append("vehicle_ids[]",F)):M.append("vehicle_ids[]",""),B(T,M)},$=w=>{o(M=>({...M,pagination:{current:w,pageSize:M.pagination.pageSize}}))},N=async w=>{try{await D(tt(m,w,t),Ke(w)),c&&K.mutate(h),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},H=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(w,M,F)=>e.jsx(e.Fragment,{children:M.children.map((L,ee,Y)=>e.jsx("span",{children:`${L.vehicle_name} ${ee+1===Y.length?"":","}`},`${ee}vehicle001`))})},{title:"Action",render:(w,M,F)=>e.jsx(e.Fragment,{children:e.jsx(ot,{id:M?.route_id,funcName:N})})}],V=w=>{const M=["route_id","index"];for(let F=0;F<M.length;F++)if(w[M[F]])return w[M[F]]},R=w=>{const{children:M=[]}=w||{},F=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:L=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:L=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:L=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:L=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:L=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:L=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:L=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(r.Table,{components:{body:{cell:Fr}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:F,rowKey:L=>V(L)+"cell01",dataSource:M,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(te,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:w=>{d(w?.value??null),a(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(r.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:b,value:u,onChange:w=>S(w),disabled:!l||f})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),S([]),a(w=>!w)},style:Rl,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(de,{style:{padding:"10px 16px"},children:e.jsx(r.Table,{components:{body:{cell:Fr}},columns:H,bordered:!0,rowKey:w=>V(w),dataSource:Array.isArray(k)?k:[],loading:y,expandable:{expandedRowRender:R,childrenColumnName:"changed"},pagination:{current:s.pagination.current,pageSize:s.pagination.pageSize,total:P,showSizeChanger:!0,onChange:$,onShowSizeChange:(w,M)=>{o(F=>({...F,pagination:{current:1,pageSize:M}}))},showTotal:(w,M)=>`${M[0]}-${M[1]} of ${w} items`}})})]})})]})})]})}const Ol={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Pl={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},El=(t,n,a)=>n?t>ye(a).endOf("day")||t<ye(n).endOf("day"):!1,si=i.forwardRef(function(n,a){const{...s}=n;return e.jsxs("div",{className:"form-group",children:[s.Desplay&&e.jsx("label",{className:`labelfont ${s.classnme?s.classnme:""}`,style:Ol,children:s.Desplay}),e.jsx(r.DatePicker,{...s,style:{...Pl,...s.style||{}},className:"form-group",disabledDate:o=>El(o,s.sessionStart||s.minDate?.subtract(1,"day").format("YYYY-MM-DD"),s.sessionEnd||s.maxDate?.format("YYYY-MM-DD")),required:!0,ref:a})]})}),kr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ta=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Aa=(t,n,a)=>{if(n==null||n==="")return null;const s=t.find(o=>String(o.value)===String(n));return s||(a?{label:String(a),value:n}:{label:String(n),value:n})},Fl=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},kl=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(a=>a!=null&&a!==""&&String(a).toLowerCase()!=="null"&&String(a).toLowerCase()!=="undefined").join(", ");const n=String(t).trim();return!n||n.toLowerCase()==="null"||n.toLowerCase()==="undefined"?"":n};function Ml({token:t,assignmentId:n,studentName:a,onClose:s,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",u="api/branchapi/Transport/getrouteDropdown",S="api/branchapi/Transport/getvehicleListByRouteIdwithCount",g="api/branchapi/Transport/getStoppageDropdown",p="api/branchapi/Transport/routeShowdata",[j,I]=i.useState(null),[T,m]=i.useState(0),[c,y]=i.useState(0),{data:O,isLoading:D}=K(t&&n?[`${l}?id=${n}`,t]:null,([W,Z])=>G(W,Z)),_=i.useMemo(()=>{if(!O||O?.Status&&O.Status!=="Success")return null;const W=O?.data??O;return Array.isArray(W)?W[0]??null:W},[O]);i.useEffect(()=>{const W=_?.fk_route_id??_?.route_id;W!=null&&I(W)},[_]);const A=t&&j?`${S}?route_id=${j}`:null,h=t&&j?`${p}?id=${j}`:null,f=t&&j?`${g}?route_id=${j}`:null,{data:x}=K(t&&u?[u,t]:null,([W,Z])=>G(W,Z)),{data:C,isLoading:P}=K(A?[A,t]:null,([W,Z])=>G(W,Z)),{data:k,isLoading:U}=K(f?[f,t]:null,([W,Z])=>G(W,Z)),{data:b}=K(h?[h,t]:null,([W,Z])=>G(W,Z)),E=i.useMemo(()=>Ta(x),[x]),B=i.useMemo(()=>Ta(C),[C]),q=i.useMemo(()=>Ta(k),[k]),$=b?.data?.[0]?.fare??_?.fare??_?.rootCost??_?.rootcost,N=Fl(),H=a||[_?.firstname,_?.lastname].filter(Boolean).join(" ")||"",V=(W,Z)=>{switch(Z){case"route_id":I(W?.value??null),m(se=>se+1),y(se=>se+1);break;case"vehicle_id":y(se=>se+1);break}},R=async W=>{W.preventDefault();const Z=new FormData(W.target);Z.append("id",n);try{await ut(d,Z,t),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),s?.()}catch(se){v.error(se?.message??"Failed to update the item.",{duration:1e3})}};if(D||!(_&&!D&&(!j||!P&&!U)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(r.Spin,{})});if(!_)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(r.Button,{type:"text",onClick:s,style:kr,children:"Close"})]});const M=_.fk_route_id??_.route_id,F=Aa(E,M,_.route_title),L=Aa(B,_.vehicle_id,_.vehicle_name??_.vehicle_no),ee=Aa(q,_.stop_id,_.stop_name??_.stoppage_name),Y=_.start_date?ye(_.start_date):ye(),J=kl(_?.service_push);return e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(X,{type:"text",name:"title",label:"Student",defaultValue:H,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:_.fk_student_id??_.student_id??""}),e.jsx(te,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"fk_route_id",required:!0,allowSelectAll:!1,defaultValue:F,onChange:W=>V(W,"route_id")}),e.jsx(te,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,defaultValue:L,onChange:W=>V(W,"vehicle_id")},`edit-vehicle-${T}`),e.jsx(te,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",name:"stop_id",required:!0,allowSelectAll:!1,defaultValue:ee},`edit-stop-${c}`),e.jsx(X,{type:"text",label:"Route Cost",value:$!=null?`${N}${$}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:$??""}),e.jsx(si,{defaultValue:Y,Desplay:"Start Date",name:"start_date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1}),e.jsx(X,{type:"text",name:"puse_service",label:"Pause Service",defaultValue:J,placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:s,style:kr,children:"Cancel"})]})]})},`edit-${n}-${T}`)}const Mr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Gt=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},$l=t=>t||"",Ul=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Bl=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},Nl=(t,n)=>{const a=n||"/TransportDashboard/EditAssignStudentTransport?id={id}",s=t?.id??"",o=encodeURIComponent(String(s));if(a.includes("{id}"))return a.replaceAll("{id}",o);if(a.includes(":id"))return a.replace(":id",o);try{const d=new URL(a,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(s)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=a.includes("?")?"&":"?";return`${a}${l}id=${o}`};function Ll({token:t,editType:n,onNavigate:a,editPagePath:s}){const l=Bl(n)==="drawer",d="api/branchapi/academy/classdropdownlist",u="api/branchapi/academy/sectionoftheClass",S="api/branchapi/Transport/routeStudentList",g="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleListByRouteIdwithCount",j="api/branchapi/Transport/getStoppageDropdown",I="api/branchapi/Transport/routeShowdata",T="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",[c,y]=i.useState(null),[O,D]=i.useState(!1),[_,A]=i.useState(!1),[h,f]=i.useState(null),[x,C]=i.useState(null),[P,k]=i.useState(null),[U,b]=i.useState(null),[E,B]=i.useState(!1),[q,$]=i.useState(!1),[N,H]=i.useState({page:1,rowsPerPage:50}),[V,R]=i.useState(null),[w,M]=i.useState(!1),[F,L]=i.useState(null),[ee,Y]=i.useState(null),J=(ge,Se)=>{switch(Se){case"class_id":R(`${u}?class_id=${ge.value}`),D(nt=>!nt);break;case"route_id":C(`${p}?route_id=${ge.value}`),k(`${I}?id=${ge.value}`),Y(ge.value),B(nt=>!nt);break;case"vehicle_id":b(`${j}?route_id=${ee}`),$(nt=>!nt);break}},W=ge=>{if(l){f(ge),A(!0);return}const Se=Nl(ge,s);if(typeof a=="function"){a(Se,ge);return}typeof window<"u"&&Se&&window.location.assign(Se)},Z=()=>{A(!1),f(null)},se=h?`Edit — ${h.firstname??""} ${h.lastname??""}`.trim():"Edit Student Transport",{data:je}=K(t&&d?[d,t]:null,([ge,Se])=>G(ge,Se)),{data:ne}=K(t&&V?[V,t]:null,([ge,Se])=>G(ge,Se)),{data:ae}=K(t&&x?[x,t]:null,([ge,Se])=>G(ge,Se)),{data:ce}=K(t&&U?[U,t]:null,([ge,Se])=>G(ge,Se)),{data:_e}=K(t&&P?[P,t]:null,([ge,Se])=>G(ge,Se)),{data:$e}=K(t&&g?[g,t]:null,([ge,Se])=>G(ge,Se)),qe=t&&c?`${c}&page=${N.page}&per_page=${N.rowsPerPage}`:null,{isLoading:Ne,error:Ue,data:Oe,mutate:We}=K(qe?[qe,t]:null,([ge,Se])=>G(ge,Se)),ze=i.useMemo(()=>Gt(je),[je]),Fe=i.useMemo(()=>Gt(ne),[ne]),Le=i.useMemo(()=>Gt(ae),[ae]),lt=i.useMemo(()=>Gt(ce),[ce]),ue=i.useMemo(()=>Gt($e),[$e]),he=_e?.data?.[0]?.fare,fe=async ge=>{try{await We(tt(m,ge,t),Ke(ge)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},Q=[{title:"Route Status",key:"route_status",render:(ge,Se)=>Se.fk_route_id?e.jsx("span",{children:Se.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(ge,Se)=>$l(Se.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,Se)=>`${Se.firstname} ${Se.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,Se)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:Se.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(ot,{id:Se?.id,funcName:fe}),e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>W(Se),style:{padding:2}})]}):e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.PlusOutlined,{}),onClick:()=>Ae(Se.student_id),style:{padding:2}})})}],oe=async(ge,Se)=>{try{await We(Ye(ge,Se,t),Ze(Se)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),M(!1),ht()}catch{v.error("Failed to add the new item.",{duration:1e3})}},me=ge=>{ge.preventDefault();const Se=ge?.target?.class_id?.value,nt=ge?.target?.section_id?.value;y(`${S}?cID=${Se}&sID=${nt}`),H(ie=>({...ie,page:1}))},Te=(ge,Se)=>{H({page:ge,rowsPerPage:parseInt(Se,10)})},Ae=ge=>{L(ge),M(!0)},pt=ge=>{ge.preventDefault();const Se=new FormData(ge.target);oe(T,Se)},ht=()=>{M(!1),C(null),k(null),b(null),Y(null)},vt=Ul();return e.jsxs("div",{children:[l&&e.jsx(r.Drawer,{open:_,title:se,placement:"right",width:420,destroyOnClose:!0,onClose:Z,children:h?.id&&e.jsx(Ml,{token:t,assignmentId:h.id,studentName:`${h.firstname??""} ${h.lastname??""}`.trim(),onClose:Z,onSuccess:()=>We()})}),e.jsx(r.Modal,{open:w,title:"Assign Student to Transport",onCancel:ht,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:pt,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[e.jsx(te,{options:ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"fk_route_id",required:!0,allowSelectAll:!1,onChange:ge=>J(ge,"route_id")}),e.jsx(te,{options:Le,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,onChange:ge=>J(ge,"vehicle_id")},`vehicle001${E}`),e.jsx(te,{options:lt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",name:"stop_id",required:!0,allowSelectAll:!1},`stop001${q}`),e.jsx(si,{defaultValue:ye(),Desplay:"Start Date",name:"start_date",placement:"bottomRight",format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:F??"",name:"student_id"}),e.jsx(X,{className:"noDisplay",type:"text",name:"rootCost",value:he??""}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:he!=null?`${vt}${he} — Assign`:"Assign",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:ht,style:Mr,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Search Students"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:me,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:ze,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:ge=>J(ge,"class_id"),name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(te,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,name:"section_id",required:!0},`section1${O}`),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Search",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"button",onClick:()=>{y(null),R(null),D(ge=>!ge)},style:Mr,children:"Cancel"})]})]})})})]}),c&&e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Student List"})}),e.jsx(de,{children:e.jsx(Me,{parentCallback:Te,data:{newData:Oe,columns:Q,columnstype:"antd",action:!1,Loading:Ne,error:Ue,deleteTodoMutation:fe,pageController:N}})})]})})]})})]})}const $r={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Cn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function ql({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,S]=i.useState(""),[g,p]=i.useState(""),[j,I]=i.useState(""),[T,m]=i.useState(!1),c=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,y="api/branchapi/Transport/add_driver",O="api/branchapi/Transport/edit_driver",D="api/branchapi/Transport/deletedriver",_="api/branchapi/staff/uploadDocuments",A=i.useMemo(()=>String(_).startsWith("http")?_:`${it()??""}${String(_).replace(/^\/+/,"")}`,[_]),h=it()??"",{isLoading:f,data:x,error:C,mutate:P}=K(t?[c,t]:null,([V,R])=>G(V,R)),k=async(V,R)=>{try{await Ye(V,R,t),await P(),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),S("")}catch(w){v.error(w?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},U=V=>{V.preventDefault();const R=new FormData(V.target);k(y,R),V.target.reset()},b=async V=>{try{await P(tt(D,V,t),Ke(V)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},E=V=>{d(V),S(V?.image??""),o(!0)},B=async V=>{try{await ut(O,V,t),await P(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),S("")}catch(R){v.error(R?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},q=V=>{V.preventDefault();const R=new FormData(V.target);R.append("id",l?.id??""),B(R)},$=(V,R)=>{a({page:V,rowsPerPage:parseInt(R,10)})},N=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(V,R)=>String(V?.name??"").localeCompare(String(R?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(V,R)=>String(V?.Driver_licence??"").localeCompare(String(R?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(V,R)=>Number(V?.contact_number??0)-Number(R?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(V,R)=>String(V?.address??"").localeCompare(String(R?.address??""))}},{title:"Image",key:"image",width:100,render:(V,R)=>{const w=R?.image?`${h}staff/document/${R.image}`:"";return w?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(r.Image,{width:80,src:w,preview:{visible:!1,onVisibleChange:()=>{m(!0),p(w),I(R?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(V,R)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>E(R),style:{padding:2}}),e.jsx(ot,{id:R?.id,funcName:b})]})}],H=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:s,title:H,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),S("")},children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(X,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(X,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(X,{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:Cn,children:"Address"}),e.jsx(r.Input.TextArea,{name:"address",defaultValue:l?.address??"",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Cn,children:"Image"}),e.jsx(r.Upload,{maxCount:1,action:A,headers:t?{Authorization:t}:void 0,onChange:V=>{if(V?.file?.status!=="done")return;const R=V?.file?.response,w=R?.data??R?.filename??R?.file??R?.path??"";w&&S(String(w))},children:e.jsx(r.Button,{icon:e.jsx(re.UploadOutlined,{}),disabled:!A,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:u})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null),S("")},style:$r,children:"Cancel"})]})]})})}),e.jsx(r.Modal,{zIndex:9999,open:T,title:j,footer:null,onCancel:()=>m(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:g})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(X,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(X,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Cn,children:"Address"}),e.jsx(r.Input.TextArea,{name:"address",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Cn,children:"Image"}),e.jsx(r.Upload,{maxCount:1,action:A,headers:t?{Authorization:t}:void 0,onChange:V=>{if(V?.file?.status!=="done")return;const R=V?.file?.response,w=R?.data??R?.filename??R?.file??R?.path??"";w&&S(String(w))},children:e.jsx(r.Button,{icon:e.jsx(re.UploadOutlined,{}),disabled:!A,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:u})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"reset",onClick:()=>S(""),style:$r,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(de,{children:e.jsx(Me,{parentCallback:$,data:{newData:x,columns:N,columnstype:"antd",action:!1,Loading:f,error:C,deleteTodoMutation:b}})})]})})]})})]})}const Ur={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ft={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Tn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Br=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],An=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function zl({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[s,o]=i.useState(!1),[l,d]=i.useState(!1),[u,S]=i.useState(null),[g,p]=i.useState(null),[j,I]=i.useState(null),[T,m]=i.useState(null),[c,y]=i.useState(ye()),[O,D]=i.useState(ye()),[_,A]=i.useState("pick"),[h,f]=i.useState(!1),[x,C]=i.useState(null),[P,k]=i.useState(null),[U,b]=i.useState(!1),[E,B]=i.useState(null),[q,$]=i.useState(null),[N,H]=i.useState(null),[V,R]=i.useState(null),[w,M]=i.useState(ye()),[F,L]=i.useState(ye()),[ee,Y]=i.useState("pick"),J=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,W="api/branchapi/Transport/assignRouteTime",Z="api/branchapi/Transport/editAssignRouteTime",se="api/branchapi/Transport/deleteAssignRouteTime",je="api/branchapi/Transport/driverDropdown",ne="api/branchapi/transport/routeTimetableShowdata",ae="api/branchapi/Transport/getrouteDropdown",ce="api/branchapi/Transport/getvehicleDropdown",{isLoading:_e,data:$e,error:qe,mutate:Ne}=K(t?[J,t]:null,([ie,xe])=>G(ie,xe)),{data:Ue}=K(t&&ae?[ae,t]:null,([ie,xe])=>G(ie,xe)),{data:Oe}=K(t&&je?[je,t]:null,([ie,xe])=>G(ie,xe)),We=i.useMemo(()=>u?`${ce}?route_id=${u}`:null,[u,ce]),{data:ze}=K(t&&We?[We,t]:null,([ie,xe])=>G(ie,xe)),Fe=i.useMemo(()=>An(Ue),[Ue]),Le=i.useMemo(()=>An(Oe),[Oe]),lt=i.useMemo(()=>An(ze),[ze]),ue=(ie,xe)=>{a({page:ie,rowsPerPage:parseInt(xe,10)})},he=async ie=>{ie.preventDefault();const xe=new FormData(ie.target);xe.set("route_id",g?.value??u??""),xe.set("driver_id",j?.value??""),xe.set("vehicle_id",T?.value??""),xe.set("start_time",c?c.format("h:mm a"):""),xe.set("drop_time",O?O.format("h:mm a"):""),xe.set("type",_);try{await Ye(W,xe,t),await Ne(),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),ie.target.reset(),S(null),p(null),I(null),m(null),d(at=>!at),y(ye()),D(ye()),A("pick"),o(at=>!at)}catch(at){v.error(at?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},fe=async ie=>{try{await tt(se,ie,t),await Ne(),v.success("Success! Deleted item.",{duration:1e3})}catch(xe){v.error(xe?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},Q=ie=>{C(ie),f(!0);const xe=ie?.id??ie?.route_time_id??ie?.routeId??null;k(xe);const at=ie?.route_id??ie?.routeId??ie?.fk_route_id;B(at??null),$(Fe.find(_t=>_t?.value===(at??ie?.route_id))??null),H(Le.find(_t=>_t?.value===(ie?.driver_id??ie?.driverId))??null),R(null),b(_t=>!_t),M(ie?.start_time?ye(ie.start_time,["h:mm a","HH:mm"]):ye()),L(ie?.drop_time?ye(ie.drop_time,["h:mm a","HH:mm"]):ye()),Y(ie?.type??"pick")},oe=i.useMemo(()=>{if(!P)return null;const ie=String(ne).includes("?")?"&":"?";return`${ne}${ie}id=${encodeURIComponent(String(P))}`},[P,ne]),{data:me,isLoading:Te}=K(t&&oe?[oe,t]:null,([ie,xe])=>G(ie,xe)),Ae=i.useMemo(()=>{const ie=me?.data??me;return Array.isArray(ie)?ie[0]??null:Array.isArray(ie?.data)?ie.data[0]??null:ie??null},[me]),pt=i.useMemo(()=>E?`${ce}?route_id=${E}`:null,[E,ce]),{data:ht}=K(t&&pt?[pt,t]:null,([ie,xe])=>G(ie,xe)),vt=i.useMemo(()=>An(ht),[ht]);i.useEffect(()=>{if(!Ae)return;const ie=Ae?.route_id??Ae?.fk_route_id??Ae?.routeId;B(ie??null),$(Fe.find(xe=>xe?.value===ie)??null),H(Le.find(xe=>xe?.value===Ae?.driver_id)??null),R(null),M(Ae?.start_time?ye(Ae.start_time,["h:mm a","HH:mm"]):ye()),L(Ae?.drop_time?ye(Ae.drop_time,["h:mm a","HH:mm"]):ye()),Y(Ae?.type??"pick"),b(xe=>!xe)},[Le,Ae,Fe]),i.useEffect(()=>{if(!Ae)return;const ie=Ae?.vehicle_id??Ae?.vehicleId;ie&&R(vt.find(xe=>xe?.value===ie)??null)},[Ae,vt]);const ge=async ie=>{if(ie.preventDefault(),!P)return;const xe=new FormData(ie.target);xe.set("id",String(P)),xe.set("route_id",q?.value??E??""),xe.set("driver_id",N?.value??""),xe.set("vehicle_id",V?.value??""),xe.set("start_time",w?w.format("h:mm a"):""),xe.set("drop_time",F?F.format("h:mm a"):""),xe.set("type",ee);try{await ut(Z,xe,t),await Ne(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),f(!1),C(null)}catch(at){v.error(at?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Se=[{title:"Route Name",dataIndex:"route_title",key:"route_title"},{title:"Driver Name",dataIndex:"driver_name",key:"driver_name"},{title:"Vehicle Name",dataIndex:"vehicle_name",key:"vehicle_name"},{title:"Start Time",dataIndex:"start_time",key:"start_time"},{title:"End Time",dataIndex:"drop_time",key:"drop_time"},{title:"Type",dataIndex:"type",key:"type"},{title:"Action",key:"action",render:(ie,xe)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>Q(xe),style:{padding:2}}),e.jsx(ot,{id:xe?.id??xe?.routeId??xe?.route_time_id,funcName:fe})]})}],nt=x?.route_title?`Edit ${x.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(r.Drawer,{open:h,title:nt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{f(!1),C(null),k(null),B(null),$(null),H(null),R(null)},children:e.jsx("form",{onSubmit:ge,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Te?.6:1},children:[e.jsx(te,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:q,onChange:ie=>{B(ie?.value??null),$(ie??null),R(null),b(xe=>!xe)}}),e.jsx(te,{options:Le,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:N,onChange:ie=>H(ie??null)}),e.jsx(te,{options:vt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:V,onChange:ie=>R(ie??null)},`edit-vehicle-${U}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Ft,children:"Start Time"}),e.jsx(r.TimePicker,{value:w,onChange:ie=>M(ie),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Tn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Ft,children:"Drop Time"}),e.jsx(r.TimePicker,{value:F,onChange:ie=>L(ie),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Tn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Ft,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(r.Radio.Group,{options:Br,optionType:"button",buttonStyle:"solid",value:ee,onChange:ie=>Y(ie.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{f(!1),C(null)},style:Ur,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(de,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:he,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:g,onChange:ie=>{S(ie?.value??null),p(ie??null),m(null),d(xe=>!xe)},allowSelectAll:!1,required:!0}),e.jsx(te,{options:Le,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:j,onChange:ie=>I(ie??null),allowSelectAll:!1,required:!0}),e.jsx(te,{options:lt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:T,onChange:ie=>m(ie??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Ft,children:"Start Time"}),e.jsx(r.TimePicker,{value:c,onChange:ie=>y(ie),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Tn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Ft,children:"Drop Time"}),e.jsx(r.TimePicker,{value:O,onChange:ie=>D(ie),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Tn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Ft,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(r.Radio.Group,{options:Br,optionType:"button",buttonStyle:"solid",value:_,onChange:ie=>A(ie.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Add",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"reset",onClick:()=>{S(null),p(null),I(null),m(null),d(ie=>!ie),y(ye()),D(ye()),A("pick"),o(ie=>!ie)},style:Ur,children:"Cancel"})]})]})},`form-${s}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(de,{children:e.jsx(Me,{parentCallback:ue,data:{newData:$e,columns:Se,columnstype:"antd",action:!1,Loading:_e,error:qe,deleteTodoMutation:fe}})})]})})]})})]})}const Vl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Nr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Lr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},qr=({dataIndex:t,title:n,record:a,children:s,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:s}):s});let zr=2;function Yl({token:t}){const[n,a]=i.useState([]),[s,o]=i.useState(null),[l,d]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:u,data:S,mutate:g}=K(t?[`api/branchapi/transport/getrouteStoppageData?page=${l.pagination.current}&per_page=${l.pagination.pageSize}`,t]:null,([k,U])=>G(k,U)),{Status:p="Failed",pagination:{total_rows:j=0}={}}=S||{},{data:I=[]}=p==="Success"?S:{},{data:T}=K(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([k,U])=>G(k,U)),m=i.useMemo(()=>{const k=T?.data??T??[];return Array.isArray(k)?k:[]},[T]),{data:c}=K(t&&s?["api/branchapi/transport/getrouteStoppageData?route_id="+s,t]:null,([k,U])=>G(k,U)),{Status:y="Failed"}=c||{},O=async(k,U)=>{try{await g(Ye(k,U,t),Ze(U)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},D=k=>{k.preventDefault();const U=new FormData(k.target);O("/branchapi/transport/addstoppageToRoute",U)},_=()=>{a(k=>[...k,{idKey:zr++}])},A=k=>{if(n.length===1)return;const U=[...n];U.splice(k,1),a(U)},h=k=>{d(U=>({...U,pagination:{current:k,pageSize:U.pagination.pageSize}}))},f=async k=>{const U="/branchapi/Transport/deletevehicle";try{await g(tt(U,k,t),Ke(k)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(y==="Success"){const k=Array.isArray(c?.data)?c.data:[];k.length>0?a(k):s&&a([{idKey:zr++}])}},[y,c,s]);const x=k=>{const{children:U=[]}=k||{},b=[{title:"Stop Name",dataIndex:"stop_name",onCell:E=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:E=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:E=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(r.Table,{components:{body:{cell:qr}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:b,rowKey:E=>C(E)+"cell01",dataSource:U,pagination:!1})})})},C=k=>{const U=["id","index"];for(let b=0;b<U.length;b++)if(k[U[b]])return k[U[b]]},P=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(k,U,b)=>e.jsx(e.Fragment,{children:U.children?.map((E,B,q)=>e.jsx("span",{children:`${E.stop_name} ${B+1===q.length?"":","}`},`${B}vehicle001`))})},{title:"Action",render:(k,U,b)=>e.jsx(e.Fragment,{children:e.jsx(ot,{id:U?.route_id,funcName:f})})}];return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(de,{pt:5,pb:1,children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(de,{px:3,pb:2,children:e.jsxs("form",{onSubmit:D,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(te,{options:m,value:m.find(k=>k.value===s)??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:k=>{o(k?.value??null),a([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:s&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:_,children:e.jsx(re.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(pe,{type:"submit",value:"Add",color:"primary"}),e.jsx(r.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),a([])},style:Vl,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((k,U)=>{const b=k.pickup_time?ye(k.pickup_time,"h:mm a"):ye(),E=k.drop_time?ye(k.drop_time,"h:mm a"):ye();return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[e.jsx("div",{children:e.jsx(X,{defaultValue:k.stop_name??"",type:"text",name:`stoppage[${U}][name]`,label:"Place Name*",required:"required"})}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Nr,children:"Pick Time"}),e.jsx(r.TimePicker,{defaultValue:b,use12Hours:!0,format:"h:mm a",name:`stoppage[${U}][pickTime]`,allowClear:!1,style:Lr})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Nr,children:"Drop Time"}),e.jsx(r.TimePicker,{defaultValue:E,use12Hours:!0,format:"h:mm a",name:`stoppage[${U}][drop_time]`,allowClear:!1,style:Lr})]}),e.jsx("div",{style:{marginBottom:8},children:n.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>A(U),children:e.jsx(re.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},k.idKey?k.idKey+"exp":k.id+"exp")})})]})}),e.jsx(de,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(de,{style:{padding:"10px 16px"},children:e.jsx(r.Table,{components:{body:{cell:qr}},columns:P,bordered:!0,size:"small",rowKey:k=>C(k),dataSource:I,loading:u,expandable:{expandedRowRender:x,childrenColumnName:"changed"},pagination:{current:l.pagination.current,pageSize:l.pagination.pageSize,total:j,showSizeChanger:!0,onChange:h,onShowSizeChange:(k,U)=>{d(b=>({...b,pagination:{current:1,pageSize:U}}))},showTotal:(k,U)=>`${U[0]}-${U[1]} of ${k} items`}})})]})]})}const Wl=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),s=String(n).replace(/^\/+/,"");return`${a}/${s}`};function Hl({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState(null),[o,l]=i.useState(null),[d,u]=i.useState(null),[S,g]=i.useState(null),[p,j]=i.useState(null),[I,T]=i.useState(null),[m,c]=i.useState(null),y="api/branchapi/library/bookCategorydropdown",O="api/branchapi/academy/classdropdownlist",D="api/branchapi/Academy/getClassSubjectdropdown",_="api/branchapi/library/addBook",A="api/branchapi/library/uploadcsv",{data:h}=K(n?[y,n]:null,([b,E])=>G(b,E)),{data:f}=K(n&&O?[O,n]:null,([b,E])=>G(b,E)),{data:x}=K(n&&D?[D,n]:null,([b,E])=>G(b,E)),C=i.useMemo(()=>Wl(it(),A),[A]),P=async b=>{b.preventDefault();const E=new FormData(b.target);E.set("cat_id",p?.value??""),E.set("class_id",I?.value??""),E.set("subject_id",m?.value??"");try{await Ye(_,E,n),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),b.target.reset(),j(null),T(null),c(null)}catch(B){v.error(B?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},k=async b=>{if(b.preventDefault(),!a){v.error("Please select a CSV file.",{duration:1e3});return}const E=new FormData;E.append("file",a),E.append("cat_id",o?.value??""),E.append("class_id",d?.value??""),E.append("subject_id",S?.value??"");try{const B=await Pe.post(C,E,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});B?.data?.Status==="Failed"?v.error(String(B?.data?.msg??"Upload failed."),{duration:1e3}):(v.success(String(B?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),s(null),b.target.reset(),l(null),u(null),g(null))}catch(B){v.error(B?.response?.data?.msg??"Upload failed.",{duration:1e3})}},U=()=>{fetch("/books.csv").then(b=>{b.blob().then(E=>{const B=window.URL.createObjectURL(E);let q=document.createElement("a");q.href=B,q.download="/books.csv",q.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(r.Button,{type:"link",icon:e.jsx(re.DownloadOutlined,{}),onClick:U,children:"Download Sample"}),children:[e.jsx(r.Divider,{children:"Information"}),e.jsx(r.Typography.Paragraph,{style:{marginBottom:16},children:"1. Your CSV data should be in the format below. The first line of your CSV file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("form",{onSubmit:k,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:b=>l(b??null)}),e.jsx(te,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:b=>u(b??null)}),e.jsx(te,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:S,onChange:b=>g(b??null)}),e.jsx(X,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:b=>s(b.target.files?.[0]??null),required:!0}),e.jsx(pe,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(X,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(X,{type:"text",label:"Publication",name:"publisher"}),e.jsx(X,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(X,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(X,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(X,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(te,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:p,onChange:b=>j(b??null)}),e.jsx(te,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:I,onChange:b=>T(b??null)}),e.jsx(te,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:m,onChange:b=>c(b??null)}),e.jsx(pe,{type:"submit",value:"Save",color:"primary"})]})})})]})}const Ia={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ra=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Kl({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),u={selectedRowKeys:a,onChange:(W,Z)=>{s(W),l(Z)}},S=cn.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),g=()=>{if(!(typeof window>"u")){if(!o.length){v.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){v.error("Nothing to print.",{duration:1e3});return}S?.()}},[p,j]=i.useState(!1),[I,T]=i.useState(null),[m,c]=i.useState(null),[y,O]=i.useState(null),[D,_]=i.useState(null),[A,h]=i.useState({page:1,rowsPerPage:10}),f=(W,Z)=>{h({page:W,rowsPerPage:parseInt(Z,10)})},x="api/branchapi/library/booktable",C="api/branchapi/library/deletebooks",P="api/branchapi/library/editbook",k=`${x}?page=${A.page}&per_page=${A.rowsPerPage}`,{isLoading:U,error:b,data:E,mutate:B}=K(n?[k,n]:null,([W,Z])=>G(W,Z)),q="api/branchapi/library/bookCategorydropdown",$="api/branchapi/academy/classdropdownlist",N="api/branchapi/Academy/getClassSubjectdropdown",{data:H}=K(n?[q,n]:null,([W,Z])=>G(W,Z)),{data:V}=K(n&&$?[$,n]:null,([W,Z])=>G(W,Z)),{data:R}=K(n&&N?[N,n]:null,([W,Z])=>G(W,Z)),w=i.useMemo(()=>Ra(H),[H]),M=i.useMemo(()=>Ra(V),[V]),F=i.useMemo(()=>Ra(R),[R]),L=async W=>{try{await tt(C,W,n),await B(),v.success("Success! Deleted item.",{duration:1e3})}catch(Z){v.error(Z?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ee=W=>{T(W??null);const Z=W?.cat_id??W?.fk_cat_id??W?.category_id,se=W?.class_id??W?.fk_class_id,je=W?.subject_id??W?.fk_subject_id;c(w.find(ne=>ne?.value===Z)??null),O(M.find(ne=>ne?.value===se)??null),_(F.find(ne=>ne?.value===je)??null),j(!0)},Y=async W=>{W.preventDefault();const Z=I?.id??I?.book_id??I?._id;if(!Z)return;const se=new FormData(W.target);se.set("id",String(Z)),se.set("cat_id",m?.value??""),se.set("class_id",y?.value??""),se.set("subject_id",D?.value??"");try{await ut(P,se,n),await B(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),j(!1),T(null)}catch(je){v.error(je?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},J=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:(W,Z)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>ee(Z),style:{padding:2}}),e.jsx(r.Button,{type:"text",size:"small",danger:!0,onClick:()=>L(Z?.id??Z?.book_id??Z?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[w,M,L,F]);return e.jsxs("div",{style:{},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:p,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{j(!1),T(null)},children:e.jsx("form",{onSubmit:Y,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(X,{label:"Book Name",name:"title",defaultValue:I?.book_title??"",required:!0}),e.jsx(X,{label:"Author",name:"author",defaultValue:I?.author??"",required:!0}),e.jsx(X,{label:"Publication",name:"publish",defaultValue:I?.publish??""}),e.jsx(X,{label:"Qty",name:"quantity",type:"number",defaultValue:I?.quantity??""}),e.jsx(X,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:I?.perunitcost??""}),e.jsx(X,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:I?.fine_amount??""}),e.jsx(X,{label:"Barcode",name:"barcode",defaultValue:I?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Ia,children:"Category"}),e.jsx(te,{options:w,value:m,onChange:W=>c(W??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Ia,children:"Class"}),e.jsx(te,{options:M,value:y,onChange:W=>O(W??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Ia,children:"Subject"}),e.jsx(te,{options:F,value:D,onChange:W=>_(W??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{j(!1),T(null)},children:"Cancel"})]})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(r.Button,{type:"primary",onClick:g,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Me,{parentCallback:f,data:{newData:E,columns:J,columnstype:"antd",action:!1,Loading:U,error:b,rowSelection:u}})}),e.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:e.jsx("div",{ref:d,style:{padding:"20px"},children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:o.map((W,Z)=>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:W.book_title}),e.jsx(_s,{value:W.barcode?String(W.barcode):String(W.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},Z))})})})]})}const Gl=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),s=String(n).replace(/^\/+/,"");return`${a}/${s}`},gt=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Jl({token:t}){const n=t??localStorage.getItem("authToken")??"",a=JSON.parse(localStorage.getItem("genrall_settings")??"null")?.currency_symbol??"",[s,o]=i.useState("issue"),l=s==="return",[d,u]=i.useState(!1),[S,g]=i.useState(!1),[p,j]=i.useState(null),[I,T]=i.useState([]),[m,c]=i.useState([]),[y,O]=i.useState([]),[D,_]=i.useState(0),[A,h]=i.useState(!1),[f,x]=i.useState(null),[C,P]=i.useState(null),[k,U]=i.useState(null),[b,E]=i.useState(!1),[B,q]=i.useState("Cash"),[$,N]=i.useState(""),[H,V]=i.useState(""),[R,w]=i.useState(0),M=i.useRef(null),[F]=r.Form.useForm(),[L]=r.Form.useForm(),ee="api/branchapi/library/bookCategorydropdown",Y="api/branchapi/academy/classdropdownlist",J="api/branchapi/Academy/getClassSubjectdropdown",{data:W}=K(n?[ee,n]:null,([le,ve])=>G(le,ve)),{data:Z}=K(n&&Y?[Y,n]:null,([le,ve])=>G(le,ve)),{data:se}=K(n&&J?[J,n]:null,([le,ve])=>G(le,ve)),je=i.useMemo(()=>gt(W),[W]),ne=i.useMemo(()=>gt(Z),[Z]),ae=i.useMemo(()=>gt(se),[se]),ce="api/branchapi/library/studentsearchByNameID",_e="api/branchapi/library/booksearchBybookname",$e="api/branchapi/library/issuedBookList",qe="api/branchapi/library/issueLibrarybook",Ne="api/branchapi/library/returnedLibrarybook",{trigger:Ue,data:Oe}=He(ce,(le,ve)=>At(le,ve,n)),{trigger:We,data:ze}=He(_e,(le,ve)=>At(le,ve,n)),{trigger:Fe,data:Le}=He($e,(le,ve)=>At(le,ve,n)),{trigger:lt}=He(l?Ne:qe,(le,ve)=>Wa(le,ve,n)),ue=i.useMemo(()=>gt(Oe),[Oe]),he=i.useMemo(()=>gt(ze),[ze]),fe=i.useMemo(()=>gt(Le),[Le]),Q=le=>{const ve=ye().format("YYYY-MM-DD");T(ke=>ke.some(Vt=>String(Vt?.id)===String(le?.id))?ke:[...ke,{...le,return_date:le?.return_date?le.return_date:ve}])},oe=le=>{T(ve=>ve.filter(ke=>String(ke?.id)!==String(le)))},me=async le=>{if(n){if(!le){j(null);return}d||await Ue({id:le})}},Te=async({search:le})=>{if(!n||!d)return;const ve=await Ue({id:le}),ke=gt(ve);ke.length===1&&(j(ke[0]),await Fe({id:ke[0]?.student_id}),F.resetFields())},Ae=async(le,ve)=>{j(ve??null),T([]),c([]),O([]),_(0),ve?.student_id&&await Fe({id:ve.student_id}),F.resetFields()},pt=async le=>{n&&le&&(S||await We({book:le}))},ht=async({search_book:le})=>{if(!n||!S)return;const ve=await We({book:le,catID:f?.value??"",sID:k?.value??"",cID:C?.value??""}),ke=gt(ve);ke.length&&(Q(ke[0]),L.resetFields())},vt=(le,ve)=>{Q(ve),L.resetFields()},ge=async()=>{if(!p?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!I.length){v.error("Select at least one book.",{duration:1e3});return}const le=await lt({member_id:p.member_id,fine:!1,books:I});le?.Status==="Success"?(v.success(String(le?.msg??"Success"),{duration:1e3}),T([]),j(null),c([]),O([]),_(0)):v.error(String(le?.msg??"Failed"),{duration:1e3})},Se=async()=>{if(!p?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!y.length){v.error("Select at least one book to return.",{duration:1e3});return}if(Number(D)>0){E(!0);return}const le=await lt({member_id:p.member_id,fine:!1,books:JSON.stringify(y)});le?.Status==="Success"?(v.success(String(le?.msg??"Success"),{duration:1e3}),c([]),O([]),_(0),await Fe({id:p?.student_id})):v.error(String(le?.msg??"Failed"),{duration:1e3})},nt=async()=>{if(!p?.member_id)return;const le=Math.max(0,Number(D)-Number(R||0)),ve={member_id:p.member_id,amount:le,fine:!0,books:JSON.stringify(y),payment_type:B,notes:$,attchement:H,discount:R||0},ke=await lt(ve);E(!1),ke?.Status==="Success"?(v.success(String(ke?.msg??"Success"),{duration:1e3}),c([]),O([]),_(0),w(0),N(""),V(""),await Fe({id:p?.student_id})):v.error(String(ke?.msg??"Failed"),{duration:1e3})},ie=i.useMemo(()=>Gl(it(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),xe=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Author",dataIndex:"author",key:"author",width:180,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(le,ve)=>e.jsx(r.Input,{value:ve?.return_date??"",onChange:ke=>{const Vt=ke.target.value;T(ua=>ua.map(pa=>String(pa?.id)===String(ve?.id)?{...pa,return_date:Vt}:pa))},placeholder:"YYYY-MM-DD"})},{title:"Action",key:"action",width:120,fixed:"right",render:(le,ve)=>e.jsx(r.Button,{type:"text",danger:!0,onClick:()=>oe(ve?.id),children:"Remove"})}],at={selectedRowKeys:m,onChange:(le,ve)=>{c(le),O(ve);const ke=(ve??[]).reduce((Vt,ua)=>Vt+Number(ua?.totalfine??0),0);_(ke)}},_t=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:le=>e.jsxs("span",{children:[a," ",le]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:b,onCancel:()=>E(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(r.Radio.Group,{value:B,onChange:le=>q(le.target.value),options:[{label:"Cash",value:"Cash"},{label:"UPI",value:"UPI"},{label:"DD",value:"DD"},{label:"Bank",value:"Bank"},{label:"Internet Banking",value:"Internet Banking"},{label:"Cheque",value:"Cheque"}]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Note"}),e.jsx(r.Input.TextArea,{rows:3,value:$,onChange:le=>N(le.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(r.Upload,{action:ie,headers:{Authorization:n},maxCount:1,onChange:le=>{if(le.file.status==="done"){const ve=le.file.response?.data??le.file.response?.file??"";V(String(ve??""))}},children:e.jsx(r.Button,{icon:e.jsx(re.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(r.Input,{type:"number",value:R,onChange:le=>w(le.target.value),placeholder:"0"})]}),e.jsxs(r.Button,{type:"primary",onClick:nt,children:["Collect ",a,Math.max(0,Number(D)-Number(R||0))]})]})}),e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(r.Row,{gutter:[16,16],align:"middle",children:[e.jsx(r.Col,{xs:24,md:10,children:e.jsx(r.Radio.Group,{value:s,onChange:le=>{const ve=le.target.value;o(ve),T([]),c([]),O([]),_(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(r.Col,{xs:24,md:14,children:e.jsx(r.Form,{form:F,onFinish:Te,layout:"vertical",children:e.jsx(r.Form.Item,{name:"search",label:"Search Student",children:e.jsx(r.Space.Compact,{style:{width:"100%"},children:d?e.jsx(r.Input,{autoFocus:!0,addonBefore:e.jsxs(r.Space,{children:[e.jsx(re.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:d,onChange:le=>u(le.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(r.AutoComplete,{options:ue,onSelect:Ae,onSearch:me,style:{width:"100%"},allowClear:!0,children:e.jsx(r.Input,{addonBefore:e.jsxs(r.Space,{children:[e.jsx(re.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:d,onChange:le=>u(le.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),p?e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{}),e.jsxs(r.Row,{gutter:[12,12],children:[e.jsxs(r.Col,{xs:24,md:8,children:[e.jsx(r.Typography.Text,{strong:!0,children:"Name:"})," ",p?.value??""]}),e.jsxs(r.Col,{xs:24,md:8,children:[e.jsx(r.Typography.Text,{strong:!0,children:"Card No:"})," ",p?.library_card_no??""]}),e.jsxs(r.Col,{xs:24,md:8,children:[e.jsx(r.Typography.Text,{strong:!0,children:"Member ID:"})," ",p?.member_id??""]})]})]}):null,e.jsx(r.Divider,{}),l?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(r.Table,{dataSource:fe,columns:_t,rowSelection:at,pagination:!1,rowKey:le=>le?.id??le?.issue_id??le?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(r.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(r.Typography.Text,{strong:!0,children:["Total Fine: ",a,D]}),e.jsx(r.Button,{type:"primary",onClick:Se,disabled:!y.length,children:D>0?`Pay Now ${a}${Math.max(0,Number(D)-Number(R||0))}`:"Return Selected"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(r.Row,{gutter:[16,16],align:"middle",children:[e.jsx(r.Col,{xs:24,md:18,children:e.jsx(r.Form,{form:L,onFinish:ht,layout:"vertical",children:e.jsx(r.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(r.Space.Compact,{style:{width:"100%"},children:S?e.jsx(r.Input,{autoFocus:!0,disabled:!p,addonBefore:e.jsxs(r.Space,{children:[e.jsx(re.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:S,onChange:le=>g(le.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(r.AutoComplete,{disabled:!p,options:he,onSelect:vt,onSearch:pt,style:{width:"100%"},allowClear:!0,children:e.jsx(r.Input,{addonBefore:e.jsxs(r.Space,{children:[e.jsx(re.BarcodeOutlined,{}),e.jsx(r.Checkbox,{checked:S,onChange:le=>g(le.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(r.Col,{xs:24,md:6,children:e.jsx(r.Button,{style:{width:"100%"},icon:e.jsx(re.FilterOutlined,{}),onClick:()=>h(!0),children:"Filter"})})]}),e.jsx(r.Drawer,{open:A,onClose:()=>h(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{label:"Category",options:je,value:f,onChange:le=>x(le??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(te,{label:"Class",options:ne,value:C,onChange:le=>P(le??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(te,{label:"Subjects",options:ae,value:k,onChange:le=>U(le??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(r.Button,{type:"primary",onClick:()=>h(!1),children:"Apply"})]})}),e.jsx(r.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(r.Table,{dataSource:I,columns:xe,pagination:!1,rowKey:le=>le?.id??le?.book_id??le?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(r.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"button",value:"Issue",onClick:ge})})]})]}),e.jsx("div",{ref:M,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}const Vr=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Ql({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,u]=i.useState(null),[S,g]=i.useState(!1),[p,j]=i.useState(!1),[I,T]=i.useState(null),[m,c]=i.useState(!1),y="api/branchapi/academy/classdropdownlist",O="api/branchapi/academy/sectionoftheClass",D="api/branchapi/library/studenttableForLibrary",_="api/branchapi/library/addmembershipforStudent",A="api/branchapi/library/removemembershipforStudent",h=i.useMemo(()=>{if(!o?.value)return null;const R=O.includes("?")?"&":"?";return`${O}${R}class_id=${encodeURIComponent(String(o.value))}`},[O,o?.value]),f=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const R=D.includes("?")?"&":"?";return`${D}${R}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${a.page}&per_page=${a.rowsPerPage}`},[a.page,a.rowsPerPage,o?.value,d?.value,D]),{data:x}=K(n&&y?[y,n]:null,([R,w])=>G(R,w)),{data:C}=K(n&&h?[h,n]:null,([R,w])=>G(R,w)),{isLoading:P,error:k,data:U,mutate:b}=K(n&&f?[f,n]:null,([R,w])=>G(R,w)),E=i.useMemo(()=>Vr(x),[x]),B=i.useMemo(()=>Vr(C),[C]),q=(R,w)=>{s({page:R,rowsPerPage:parseInt(w,10)})},$=R=>{const w=R?.id??R?.student_id??R?.member_id;T(w??null),j(!0),c(M=>!M)},N=async R=>{if(R.preventDefault(),!I)return;const w=new FormData(R.target);w.set("id",String(I));try{await Ye(_,w,n),v.success("Success! Added member.",{duration:1e3,icon:"🎉"}),j(!1),T(null),await b()}catch(M){v.error(M?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},H=async R=>{try{await tt(A,R,n),v.success("Success! Removed member.",{duration:1e3}),await b()}catch(w){v.error(w?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},V=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:(R,w)=>(console.log("data______________",w),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:w?.library_card_no==null?e.jsx(r.Button,{type:"primary",size:"small",icon:e.jsx(re.UserAddOutlined,{}),onClick:()=>$(w)}):e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{}),onClick:()=>H(w?.id??w?.student_id??w?.member_id)})}))}],[H]);return e.jsxs("div",{style:{},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:p,title:"Add Member",onCancel:()=>{j(!1),T(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(X,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Add",color:"primary"})})]})},`add-${m}`)}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Student"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(te,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:R=>{l(R??null),u(null),g(w=>!w)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(te,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:R=>u(R??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${S}`),e.jsx(pe,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){v.error("Select class and section.",{duration:1e3});return}s(R=>({...R,page:1}))}})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Me,{parentCallback:q,data:{newData:U,columns:V,columnstype:"antd",action:!1,Loading:P,error:k}})})]})}function Xl({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,s]=i.useState({page:1,rowsPerPage:10}),[o]=r.Form.useForm(),[l]=r.Form.useForm(),[d,u]=i.useState(!1),[S,g]=i.useState(null),p="api/branchapi/library/BookCategorytable",j="api/branchapi/library/addBookCategory",I="api/branchapi/library/editBookCategory",T="api/branchapi/library/deleteBookCategory",m=i.useMemo(()=>{const k=p.includes("?")?"&":"?";return`${p}${k}page=${a.page}&per_page=${a.rowsPerPage}`},[p,a.page,a.rowsPerPage]),{isLoading:c,error:y,data:O,mutate:D}=K(n&&m?[m,n]:null,([k,U])=>G(k,U)),_=(k,U)=>{s({page:k,rowsPerPage:parseInt(U,10)})},A=async k=>{const U=new FormData;U.set("title",k?.title??"");try{await Ye(j,U,n),v.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await D()}catch(b){v.error(b?.response?.data?.msg??b?.message??"Failed to add category.",{duration:1e3})}},h=k=>{g(k??null),l.setFieldsValue({title:k?.name??""}),u(!0)},f=()=>{u(!1),g(null),l.resetFields()},x=async k=>{const U=S?.id??S?.category_id??S?.cat_id;if(!U){v.error("Missing category id.",{duration:1e3});return}const b=new FormData;b.set("id",String(U)),b.set("title",k?.title??"");try{await ut(I,b,n),v.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),f(),await D()}catch(E){v.error(E?.response?.data?.msg??E?.message??"Failed to update category.",{duration:1e3})}},C=async k=>{const U=k?.id??k?.category_id??k?.cat_id;if(!U){v.error("Missing category id.",{duration:1e3});return}try{await tt(T,U,n),v.success("Success! Deleted category.",{duration:1e3}),await D()}catch(b){v.error(b?.response?.data?.msg??b?.message??"Failed to delete category.",{duration:1e3})}},P=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(k,U)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>h(U)}),e.jsx(r.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>C(U),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[C]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:d,title:"Edit Category",onCancel:f,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:l,layout:"vertical",onFinish:x,children:[e.jsx(r.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(r.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:f,children:"Cancel"}),e.jsx(pe,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(r.Row,{gutter:[16,16],children:[e.jsx(r.Col,{xs:24,lg:8,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:A,children:[e.jsx(r.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(r.Input,{placeholder:"Enter category name"})}),e.jsx(pe,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(r.Col,{xs:24,lg:16,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Me,{parentCallback:_,data:{newData:O,columns:P,columnstype:"antd",action:!1,Loading:c,error:y}})})})]})]})}const Da=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Zl({token:t}){const[n,a]=i.useState([ye().format("YYYY-MM-DD"),ye().format("YYYY-MM-DD")]),[s,o]=i.useState(null),[l,d]=i.useState(null),[u,S]=i.useState(null),[g,p]=i.useState(!1),[j,I]=i.useState(!1),T="api/branchapi/academy/classdropdownlist",m="api/branchapi/academy/sectionoftheClass",c="api/branchapi/library/memberDropdown",y="api/report/libraryReport/libraryReport",O=i.useMemo(()=>{if(!s?.value)return null;const $=m.includes("?")?"&":"?";return`${m}${$}class_id=${encodeURIComponent(String(s.value))}`},[m,s?.value]),D=i.useMemo(()=>{if(!s?.value)return null;const $=c.includes("?")?"&":"?",N=`${c}${$}class=${encodeURIComponent(String(s.value))}`;return l?.value?`${N}§ion=${encodeURIComponent(String(l.value))}`:N},[c,s?.value,l?.value]),{isLoading:_,error:A,data:h,mutate:f}=K(t&&T?[T,t]:null,([$,N])=>G($,N)),{data:x}=K(t&&O?[O,t]:null,([$,N])=>G($,N)),{data:C}=K(t&&D?[D,t]:null,([$,N])=>G($,N)),P=i.useMemo(()=>Da(h),[h]),k=i.useMemo(()=>Da(x),[x]),U=i.useMemo(()=>Da(C),[C]),{trigger:b,data:E}=He(y,($,N)=>Ha($,N,t));i.useEffect(()=>{(async()=>{I(!0);try{await b({duration:n})}finally{I(!1)}})()},[]);const B=async()=>{I(!0);try{await b({duration:n,class:s?.value??"",section:l?.value??"",student_id:u?.value??""})}finally{I(!1)}},q=[{title:"Name",dataIndex:"full_name",render:($,N)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:N?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:($,N)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:N?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:($,N)=>e.jsxs(r.Typography.Text,{style:{fontSize:12},children:[N?.class??"","(",N?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:($,N)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:N?.book_title??""})},{title:"Issue Date",key:"date",render:($,N,H)=>e.jsx(r.Typography.Text,{style:{fontSize:12},children:N?.issue_date??""})},{title:"Due Return Date",key:"date",render:($,N,H)=>e.jsx(r.Tag,{color:"orange",children:N?.return_date??""})},{title:"Return Date",key:"date",render:($,N,H)=>N?.retured_by_user?e.jsx(r.Tag,{color:"green",children:N?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:($,N,H)=>String(N?.is_returned??"")==="1"?e.jsx(r.Tag,{color:"green",children:"Return"}):e.jsx(r.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:($,N,H)=>{const V=N?.late_fine?Number(N.late_fine):0;return V?e.jsx(r.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:V}):null}}];return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(r.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(r.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(r.DatePicker.RangePicker,{style:{width:"100%"},value:[ye(n[0],"YYYY-MM-DD"),ye(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:($,N)=>{Array.isArray(N)&&N.length===2&&a([N[0],N[1]])}})]})}),e.jsx(r.Col,{xs:24,md:5,children:e.jsx(te,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:s,onChange:$=>{o($??null),d(null),S(null),p(N=>!N)},allowSelectAll:!1})}),e.jsx(r.Col,{xs:24,md:5,children:e.jsx(te,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:$=>{d($??null),S(null)},allowSelectAll:!1},`section1${g}`)}),e.jsx(r.Col,{xs:24,md:5,children:e.jsx(te,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:u,onChange:$=>S($??null),allowSelectAll:!1})}),e.jsx(r.Col,{xs:24,md:1,children:e.jsx(r.Button,{type:"primary",icon:e.jsx(re.SearchOutlined,{}),onClick:B,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(r.Table,{columns:q,pagination:!1,dataSource:Array.isArray(E?.data)?E.data:[],size:"small",rowKey:($,N)=>$?.id??$?.issue_id??$?.fees_receipt_id??N,loading:j,scroll:{x:"max-content"},summary:$=>{const N=$.reduce((V,R)=>V+Number(R?.late_fine??0),0),H=$.reduce((V,R)=>V+Number(R?.is_returned??0),0);return e.jsxs(r.Table.Summary.Row,{children:[e.jsx(r.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",$.length]})}),e.jsx(r.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number($.length-H)]})}),e.jsx(r.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",H]})}),e.jsx(r.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",N.toLocaleString("en-IN")]})})]})}})})]})]})}const oa=t=>t??localStorage.getItem("authToken")??"",ed=(t,n)=>{const a=String(t??""),s=String(n);return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s},Ee={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"}},td=()=>ed(it(),Ee.upload),nd=async({baseUrl:t,page:n=1,perPage:a=10},s)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return G(l,oa(s))},gn=async(t,n,a)=>Ye(t,n,oa(a)),qt=async(t,n,a)=>ut(t,n,oa(a)),xn=async(t,n,a)=>tt(t,n,oa(a)),ad=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Nt=({token:t,value:n,onChange:a})=>{const s=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(r.Upload,{maxCount:1,action:td(),headers:s,onChange:o=>{if(o?.file?.status==="done"){const l=ad(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},Ln=Ee.vendor,bn=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>K(s&&t?[t,n,a,s]:null,([l,d,u,S])=>nd({baseUrl:l,page:d,perPage:u},S)),rd=({token:t,page:n=1,perPage:a=10})=>bn({baseUrl:Ln.list,page:n,perPage:a,token:t}),sd={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Yr=[{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 id({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,S]=i.useState(""),{isLoading:g,error:p,data:j,mutate:I}=rd({token:t,page:n.page,perPage:n.rowsPerPage}),T=async A=>{try{await I(gn(Ln.add,A,t),Ze(A)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(h){v.error(h?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},m=A=>{A.preventDefault();const h=new FormData(A.target);u&&h.set("image",u),T(h),A.target.reset(),S("")},c=(A,h)=>{a({page:A,rowsPerPage:parseInt(h,10)})},y=async A=>{try{await I(xn(Ln.remove,A,t),Ke(A)),v.success("Success! Deleted item.",{duration:1e3})}catch(h){v.error(h?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},O=A=>{d(A),o(!0),S("")},D=async A=>{A.preventDefault();const h=new FormData(A.target);h.set("id",String(l?.id??"")),u&&h.set("image",u);try{await qt(Ln.edit,h,t),await I(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),S("")}catch(f){v.error(f?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},_=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:(A,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>O(h),style:{padding:2}}),e.jsx(ot,{id:h?.id,funcName:y})]})}],[y]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:s,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),S("")},children:e.jsx("form",{onSubmit:D,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[Yr.map(A=>e.jsx(X,{type:A.type,name:A.name,label:A.label,defaultValue:l?.[A.name]??"",required:A.required?"required":void 0},A.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(Nt,{token:t,value:u,onChange:S})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null),S("")},style:sd,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:m,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[Yr.map(A=>e.jsx(X,{type:A.type,name:A.name,label:A.label,required:A.required?"required":void 0},A.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(Nt,{token:t,value:u,onChange:S})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(de,{pt:3,children:e.jsx(Me,{parentCallback:c,data:{newData:j,columns:_,columnstype:"antd",action:!1,Loading:g,error:p}})})]})]})]})}const od=({token:t})=>e.jsx(id,{token:t}),ld={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},dd={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"},dn=({style:t,onFocus:n,onBlur:a,...s})=>{const[o,l]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[s.label&&e.jsx("label",{className:"labelfont",style:ld,children:s.label}),e.jsx("textarea",{placeholder:s.placeholder||s.label,...s,onFocus:d=>{l(!0),n?.(d)},onBlur:d=>{l(!1),a?.(d)},style:{...dd,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},qn=Ee.product,Wr=Ee.vendor.dropdown,Hr=Ee.category.dropdown,cd=Ee.subCategory.dropdown,Kr=Ee.unit.dropdown,ii=({token:t,page:n=1,perPage:a=10})=>bn({baseUrl:qn.list,page:n,perPage:a,token:t}),ud=({token:t})=>K(t&&Wr?[Wr,t]:null,([a,s])=>G(a,s)),pd=({token:t})=>K(t&&Hr?[Hr,t]:null,([a,s])=>G(a,s)),md=({token:t})=>K(t&&Kr?[Kr,t]:null,([a,s])=>G(a,s)),fd=({token:t,categoryId:n})=>{const a=t&&n?`${cd}?category_id=${encodeURIComponent(String(n))}`:null;return K(a?[a,t]:null,([o,l])=>G(o,l))},In=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},yd={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function hd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,S]=i.useState(""),[g,p]=i.useState(""),[j,I]=i.useState(""),[T,m]=i.useState(""),[c,y]=i.useState(""),{isLoading:O,error:D,data:_,mutate:A}=ii({token:t,page:n.page,perPage:n.rowsPerPage}),{data:h}=ud({token:t}),{data:f}=pd({token:t}),{data:x}=md({token:t}),{data:C}=fd({token:t,categoryId:g}),P=i.useMemo(()=>In(h),[h]),k=i.useMemo(()=>In(f),[f]),U=i.useMemo(()=>In(x),[x]),b=i.useMemo(()=>In(C),[C]),E=async R=>{try{await A(gn(qn.add,R,t),Ze(R)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(w){v.error(w?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},B=R=>{R.preventDefault();const w=new FormData(R.target);g&&w.set("fk_categoryID",String(g)),j&&w.set("fk_sub_categoryID",String(j)),T&&w.set("vendor_id",String(T)),c&&w.set("unit",String(c)),u&&w.set("image",u),E(w),R.target.reset(),S(""),p(""),I(""),m(""),y("")},q=(R,w)=>{a({page:R,rowsPerPage:parseInt(w,10)})},$=async R=>{try{await A(xn(qn.remove,R,t),Ke(R)),v.success("Success! Deleted item.",{duration:1e3})}catch(w){v.error(w?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},N=R=>{d(R),o(!0),S(""),p(R?.fk_categoryID??R?.category_id??""),I(R?.fk_sub_categoryID??R?.sub_category_id??""),m(R?.vendor_id??""),y(R?.unit??R?.unit_id??"")},H=async R=>{R.preventDefault();const w=new FormData(R.target);w.set("id",String(l?.id??"")),g&&w.set("fk_categoryID",String(g)),j&&w.set("fk_sub_categoryID",String(j)),T&&w.set("vendor_id",String(T)),c&&w.set("unit",String(c)),u&&w.set("image",u);try{await qt(qn.edit,w,t),await A(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),S("")}catch(M){v.error(M?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},V=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:(R,w)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>N(w),style:{padding:2}}),e.jsx(ot,{id:w?.id,funcName:$})]})}],[$]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:s,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),S("")},children:e.jsx("form",{onSubmit:H,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(X,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(te,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:R=>{const w=R?.value??"";p(w),I("")},defaultValue:g?k.find(R=>String(R?.value)===String(g)):null}),e.jsx(te,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:R=>I(R?.value??""),defaultValue:j?b.find(R=>String(R?.value)===String(j)):null}),e.jsx(X,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(te,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:R=>y(R?.value??""),defaultValue:c?U.find(R=>String(R?.value)===String(c)):null}),e.jsx(X,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(X,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(te,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:R=>m(R?.value??""),defaultValue:T?P.find(R=>String(R?.value)===String(T)):null}),e.jsx(X,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(dn,{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(Nt,{token:t,value:u,onChange:S})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null),S("")},style:yd,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(de,{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:[e.jsx(X,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(te,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:R=>{const w=R?.value??"";p(w),I("")}}),e.jsx(te,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:R=>I(R?.value??"")},`subcat_${g}`),e.jsx(X,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(te,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:R=>y(R?.value??"")}),e.jsx(X,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(X,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(te,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:R=>m(R?.value??"")}),e.jsx(X,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(dn,{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(Nt,{token:t,value:u,onChange:S})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(de,{pt:3,children:e.jsx(Me,{parentCallback:q,data:{newData:_,columns:V,columnstype:"antd",action:!1,Loading:O,error:D}})})]})]})]})}const gd=({token:t})=>e.jsx(hd,{token:t}),zn=Ee.category,xd=({token:t,page:n=1,perPage:a=10})=>bn({baseUrl:zn.list,page:n,perPage:a,token:t}),bd={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Sd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:u,error:S,data:g,mutate:p}=xd({token:t,page:n.page,perPage:n.rowsPerPage}),j=async D=>{try{await p(gn(zn.add,D,t),Ze(D)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(_){v.error(_?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},I=D=>{D.preventDefault();const _=new FormData(D.target);j(_),D.target.reset()},T=(D,_)=>{a({page:D,rowsPerPage:parseInt(_,10)})},m=async D=>{try{await p(xn(zn.remove,D,t),Ke(D)),v.success("Success! Deleted item.",{duration:1e3})}catch(_){v.error(_?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},c=D=>{d(D),o(!0)},y=async D=>{D.preventDefault();const _=new FormData(D.target);_.set("id",String(l?.id??""));try{await qt(zn.edit,_,t),await p(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(A){v.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(D,_)=>String(D?.name??"").localeCompare(String(_?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(D,_)=>String(D?.description??"").localeCompare(String(_?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(D,_)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>c(_),style:{padding:2}}),e.jsx(ot,{id:_?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:s,title:l?.name?`Edit ${l.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(X,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(X,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:bd,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(X,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(de,{pt:3,children:e.jsx(Me,{parentCallback:T,data:{newData:g,columns:O,columnstype:"antd",action:!1,Loading:u,error:S}})})]})]})]})}const jd=({token:t})=>e.jsx(Sd,{token:t}),Vn=Ee.subCategory,Gr=Ee.category.dropdown,wd=({token:t,page:n=1,perPage:a=10})=>bn({baseUrl:Vn.list,page:n,perPage:a,token:t}),vd=({token:t})=>K(t&&Gr?[Gr,t]:null,([a,s])=>G(a,s)),_d=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Cd={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Td({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,S]=i.useState(""),{isLoading:g,error:p,data:j,mutate:I}=wd({token:t,page:n.page,perPage:n.rowsPerPage}),{data:T}=vd({token:t}),m=i.useMemo(()=>_d(T),[T]),c=async f=>{try{await I(gn(Vn.add,f,t),Ze(f)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(x){v.error(x?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},y=f=>{f.preventDefault();const x=new FormData(f.target);x.set("status","active"),x.set("img",u||""),c(x),f.target.reset(),S("")},O=(f,x)=>{a({page:f,rowsPerPage:parseInt(x,10)})},D=async f=>{try{await I(xn(Vn.remove,f,t),Ke(f)),v.success("Success! Deleted item.",{duration:1e3})}catch(x){v.error(x?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},_=f=>{d(f),o(!0)},A=async f=>{f.preventDefault();const x=new FormData(f.target);x.set("id",String(l?.id??"")),u&&x.set("img",u);try{await qt(Vn.edit,x,t),await I(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),S("")}catch(C){v.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},h=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(f,x)=>String(f?.name??"").localeCompare(String(x?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(f,x)=>String(f?.description??"").localeCompare(String(x?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(f,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>_(x),style:{padding:2}}),e.jsx(ot,{id:x?.id,funcName:D})]})}],[D]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:s,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),S("")},children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?m.find(f=>String(f?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(X,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(X,{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(Nt,{token:t,value:u,onChange:S})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null),S("")},style:Cd,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(X,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(X,{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(Nt,{token:t,value:u,onChange:S})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(de,{pt:3,children:e.jsx(Me,{parentCallback:O,data:{newData:j,columns:h,columnstype:"antd",action:!1,Loading:g,error:p}})})]})]})]})}const Ad=({token:t})=>e.jsx(Td,{token:t}),Oa=Ee.product,Id=Ee.academy.classes,Rd=Ee.academy.sections,Dd=Ee.student.dropdown;function Jt(t){const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]}function Rn(t,n){const a=Math.trunc(Number(t)||1),s=Math.max(1,a);return!Number.isFinite(Number(n))||Number(n)<=0?s:Math.min(s,Math.trunc(Number(n)))}function Ge(t){return String(t??"")}function Od({token:t}){const[n,a]=i.useState(""),[s,o]=i.useState(""),[l,d]=i.useState(""),[u,S]=i.useState(!1),[g,p]=i.useState(""),[j,I]=i.useState([]),[T,m]=i.useState({}),[c,y]=i.useState({}),[O,D]=i.useState(!1),[_,A]=i.useState(""),[h,f]=i.useState(0),[x,C]=i.useState(""),[P,k]=i.useState(ye()),[U,b]=i.useState([]),E={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},B=!!(n&&s&&l),{data:q}=K(t?[Id,t]:null,([ue,he])=>G(ue,he)),$=i.useMemo(()=>Jt(q),[q]),N=t&&n?`${Rd}?class_id=${encodeURIComponent(String(n))}`:null,{data:H}=K(N?[N,t]:null,([ue,he])=>G(ue,he)),V=i.useMemo(()=>Jt(H),[H]),R=t&&n&&s?`${Dd}?class=${encodeURIComponent(String(n))}§ion=${encodeURIComponent(String(s))}`:null,{data:w}=K(R?[R,t]:null,([ue,he])=>G(ue,he)),M=i.useMemo(()=>Jt(w),[w]),F=B?`${Oa.list}?page=1&per_page=10000`:null,{data:L,isLoading:ee}=K(t&&F?[F,t]:null,([ue,he])=>G(ue,he),{revalidateOnFocus:!1}),Y=i.useMemo(()=>Jt(L),[L]),J=i.useMemo(()=>{const ue=new Map;return(Array.isArray(Y)?Y:[]).forEach(he=>{ue.set(Ge(he?.id),he)}),ue},[Y]),W=i.useMemo(()=>{const ue=Object.entries(c||{});return ue.length===0?[]:ue.map(([he,fe])=>{const Q=J.get(Ge(he));return Q?{id:Q?.id,name:Q?.name,barcode:Q?.barcode,stock:Number(Q?.quantity||0),price:Number(Q?.price||0),quantity:Rn(fe,Number(Q?.quantity||0))}:null}).filter(Boolean)},[c,J]),Z=i.useMemo(()=>new Set(W.map(ue=>Ge(ue?.id))),[W]),se=i.useMemo(()=>(Array.isArray(W)?W:[]).reduce((he,fe)=>he+Number(fe?.price||0)*Number(fe?.quantity||1),0),[W]),je=i.useMemo(()=>{const ue=Number(h||0);return!Number.isFinite(ue)||ue<=0?0:Math.min(ue,se)},[h,se]),ne=i.useMemo(()=>Math.max(0,se-je),[je,se]),ae=i.useMemo(()=>(Array.isArray(Y)?Y:[]).slice(0,30).map(ue=>({value:Ge(ue?.id),label:`${ue?.name??""}${ue?.barcode?` • ${ue.barcode}`:""}${ue?.quantity!==void 0&&ue?.quantity!==null?` • Stock: ${ue.quantity}`:""}`,product:ue})),[Y]),{trigger:ce}=He(t&&B?Oa.search:null,(ue,{arg:he})=>At(ue,{arg:he},t));i.useEffect(()=>{if(!B){I([]);return}const ue=String(g||"").trim();if(ue.length<2){I(ae);return}let he=!0;const fe=setTimeout(async()=>{let Q=[];try{if(ce){const me=await ce({search:ue});Q=Jt(me)}}catch{Q=[]}if(!Array.isArray(Q)||Q.length===0){const me=ue.toLowerCase();Q=(Array.isArray(Y)?Y:[]).filter(Te=>{const Ae=String(Te?.name??"").toLowerCase(),pt=String(Te?.barcode??"").toLowerCase();return Ae.includes(me)||pt.includes(me)}).slice(0,30)}const oe=Q.slice(0,30).map(me=>({value:Ge(me?.id),label:`${me?.name??""}${me?.barcode?` • ${me.barcode}`:""}${me?.quantity!==void 0&&me?.quantity!==null?` • Stock: ${me.quantity}`:""}`,product:me}));he&&I(oe)},250);return()=>{he=!1,clearTimeout(fe)}},[ae,B,ce,Y,g]),i.useEffect(()=>{y({}),m({}),p(""),I([]),D(!1),A(""),f(0),C(""),k(ye()),b([])},[n,s,l]);const _e=i.useCallback((ue,he=1)=>{const fe=ue?.id;if(!fe)return;const Q=Number(ue?.quantity||0);if(Q<=0){v.error("Out of stock.",{duration:1e3});return}const oe=Rn(he,Q);y(me=>{const Te=me||{};return Object.prototype.hasOwnProperty.call(Te,Ge(fe))?(v.error("Product already added.",{duration:1e3}),Te):{...Te,[Ge(fe)]:oe}})},[y]),$e=i.useCallback((ue,he,fe)=>{y(Q=>{const oe=Q||{},me=Ge(ue);return Object.prototype.hasOwnProperty.call(oe,me)?{...oe,[me]:Rn(he,fe)}:oe})},[]),qe=i.useCallback(ue=>{y(he=>{const fe=he||{},Q=Ge(ue);if(!Object.prototype.hasOwnProperty.call(fe,Q))return fe;const oe={...fe};return delete oe[Q],oe})},[]),Ne=i.useCallback((ue,he,fe)=>{m(Q=>({...Q||{},[Ge(ue)]:Rn(he,fe)}))},[]),Ue=i.useCallback((ue,he)=>{he?.product&&_e(he.product,1),p(""),I(ae)},[_e,ae]),Oe=i.useCallback(ue=>{if(ue.key!=="Enter")return;ue.preventDefault();const he=Array.isArray(j)&&j.length>0?j[0]:null;if(he?.product){_e(he.product,1),p(""),I(ae);return}const fe=String(g||"").trim().toLowerCase();if(fe.length===0)return;const Q=(Array.isArray(Y)?Y:[]).find(oe=>{const me=String(oe?.name??"").toLowerCase(),Te=String(oe?.barcode??"").toLowerCase();return me.includes(fe)||Te.includes(fe)});Q&&(_e(Q,1),p(""),I(ae))},[_e,ae,Y,j,g]),We=()=>{if(!t){v.error("Missing token.",{duration:1e3});return}if(!n){v.error("Select class.",{duration:1e3});return}if(!s){v.error("Select section.",{duration:1e3});return}if(!l){v.error("Select student.",{duration:1e3});return}if(!W||W.length===0){v.error("Add at least one product.",{duration:1e3});return}D(!0)},{trigger:ze,isMutating:Fe}=He(t?Oa.sellProduct:null,(ue,{arg:he})=>Wa(ue,{arg:he},t)),Le=async()=>{if(!_){v.error("Select payment type.",{duration:1e3});return}const ue=(Array.isArray(W)?W:[]).map(fe=>({id:fe?.id,quantity:Number(fe?.quantity||1),price:Number(fe?.price||0),total_price:Number(fe?.total_price||0),fk_vendor_id:fe?.fk_vendor_id||"",fk_categoryID:fe?.fk_categoryID||"",name:fe?.name||"",class_id:fe?.class_id||"",fk_sub_categoryID:fe?.fk_sub_categoryID||"",description:fe?.description||"",min_quantity:Number(fe?.min_quantity||0),storecategory:Number(fe?.storecategory||0),barcode:fe?.barcode||""})),he={amount:se,class:n,section:s,student_id:l,payment_type:_,discount:je,notes:x||"",receipt_date:P?ye(P).format("YYYY-MM-DD"):"",product:JSON.stringify(ue),total_payable_amount:se,attchement:U[0]?.originFileObj||""};try{const Q=Array.isArray(U)&&U.length>0&&U[0]?.originFileObj?(()=>{const me=new FormData;return Object.entries(he).forEach(([Te,Ae])=>{if(Te==="products"){me.append("product",JSON.stringify(Ae));return}me.append(Te,String(Ae??""))}),me.append("attachment",U[0].originFileObj),me})():he,oe=await ze(Q);oe?.Status==="Success"?(v.success("Success! Product sold.",{duration:1e3}),D(!1),y({}),m({}),p(""),I(ae),A(""),f(0),C(""),k(ye()),b([])):v.error(oe?.msg??"Failed to submit.",{duration:1e3})}catch{v.error("Failed to submit.",{duration:1e3})}},lt=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:(ue,he)=>{const fe=Ge(he?.id),Q=Number(he?.quantity||0),oe=Z.has(fe),me=(oe?c?.[fe]:T?.[fe])??1;return e.jsx(r.InputNumber,{min:1,max:Number.isFinite(Q)&&Q>0?Q:void 0,value:me,onChange:Te=>{oe?$e(fe,Te,Q):Ne(fe,Te,Q)},disabled:Q<=0})}},{title:"Amount",key:"amount",width:140,render:(ue,he)=>{const fe=Ge(he?.id),Q=(Z.has(fe)?c?.[fe]:T?.[fe])??1;return Number(he?.price||0)*Number(Q||1)}},{title:"Action",key:"action",width:120,render:(ue,he)=>{const fe=Ge(he?.id),Q=Number(he?.quantity||0),oe=Z.has(fe),me=(oe?c?.[fe]:T?.[fe])??1;return oe?e.jsx(r.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(re.DeleteOutlined,{}),onClick:()=>qe(fe),style:{padding:2}}):e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.PlusOutlined,{}),disabled:Q<=0,onClick:()=>_e(he,me),style:{padding:2}})}}],[_e,Z,c,T,qe,Ne,$e]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(de,{pt:5,pb:2,children:[e.jsxs(de,{style:{padding:"12px 16px"},children:[e.jsx(de,{children:"Sell Product"}),e.jsx(r.Card,{style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(te,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:ue=>{const he=ue?.value??"";a(he),o(""),d(""),S(fe=>!fe)}}),e.jsx(te,{options:V,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:ue=>{const he=ue?.value??"";o(he),d("")}},`section_${u}`),e.jsx(te,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:ue=>d(ue?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(r.Card,{style:{borderRadius:16,marginTop:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(260px, 520px) 1fr",gap:12,alignItems:"center",marginBottom:12},children:[e.jsx(de,{style:{marginTop:12},children:"Product Section"}),e.jsx(r.AutoComplete,{value:g,options:j,onSearch:p,onFocus:()=>{B&&String(g||"").trim().length<2&&I(ae)},onSelect:Ue,disabled:!B,children:e.jsx(r.Input,{placeholder:"Search by product name or barcode",onKeyDown:Oe,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",mt(se)]})]}),e.jsx(r.Table,{rowKey:ue=>Ge(ue?.id),columns:lt,dataSource:Y,loading:ee,size:"small",bordered:!0,pagination:{pageSize:50,showSizeChanger:!0,pageSizeOptions:[25,50,100,200]},scroll:{x:"max-content"}}),e.jsxs("div",{style:{position:"sticky",bottom:0,background:"#fff",paddingTop:12,marginTop:12,borderTop:"1px solid #f0f0f0"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Selected Items"}),e.jsx("span",{children:W.length})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700,marginTop:6},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:mt(se)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(pe,{type:"button",value:"Submit",disabled:!B||W.length===0,onClick:We,style:{flex:1,minWidth:140}}),e.jsx(r.Button,{type:"text",style:E,onClick:()=>{y({}),m({}),p(""),I(ae)},disabled:W.length===0,children:"Clear"})]})]})]})})]}),e.jsx(r.Modal,{open:O,title:"Payment",onCancel:()=>D(!1),onOk:Le,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(r.Select,{value:_||void 0,onChange:A,placeholder:"Select payment type",style:{width:"100%"},options:[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"Bank",label:"Bank"},{value:"Cheque",label:"Cheque"},{value:"DD",label:"DD"},{value:"Internet Banking",label:"Internet Banking"}]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Receipt Date"}),e.jsx(r.DatePicker,{value:P,onChange:ue=>k(ue),style:{width:"100%"},format:"YYYY-MM-DD"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Discount"}),e.jsx(r.InputNumber,{min:0,max:se,value:h,onChange:ue=>f(Number(ue||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(r.Upload,{fileList:U,beforeUpload:()=>!1,onChange:({fileList:ue})=>b((ue||[]).slice(-1)),maxCount:1,children:e.jsx(r.Button,{icon:e.jsx(re.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(r.Input.TextArea,{value:x,onChange:ue=>C(ue.target.value),rows:3})]}),e.jsx(r.Card,{style:{borderRadius:12,background:"#fafcff"},children:e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:mt(se)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:mt(je)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:mt(ne)})]})]})})]})})]})}const Pd=({token:t})=>e.jsx(Od,{token:t}),Yn=Ee.unit,Ed=({token:t,page:n=1,perPage:a=10})=>bn({baseUrl:Yn.list,page:n,perPage:a,token:t}),Fd={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function kd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:u,error:S,data:g,mutate:p}=Ed({token:t,page:n.page,perPage:n.rowsPerPage}),j=async D=>{try{await p(gn(Yn.add,D,t),Ze(D)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(_){v.error(_?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},I=D=>{D.preventDefault();const _=new FormData(D.target);j(_),D.target.reset()},T=(D,_)=>{a({page:D,rowsPerPage:parseInt(_,10)})},m=async D=>{try{await p(xn(Yn.remove,D,t),Ke(D)),v.success("Success! Deleted item.",{duration:1e3})}catch(_){v.error(_?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},c=D=>{d(D),o(!0)},y=async D=>{D.preventDefault();const _=new FormData(D.target);_.set("id",String(l?.id??""));try{await qt(Yn.edit,_,t),await p(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(A){v.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(D,_)=>String(D?.name??"").localeCompare(String(_?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(D,_)=>String(D?.description??"").localeCompare(String(_?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(D,_)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>c(_),style:{padding:2}}),e.jsx(ot,{id:_?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{open:s,title:l?.name?`Edit ${l.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(X,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(X,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Fd,children:"Cancel"})]})]})})}),e.jsxs(de,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(de,{px:3,pb:2,children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(X,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(de,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(de,{pt:3,children:e.jsx(Me,{parentCallback:T,data:{newData:g,columns:O,columnstype:"antd",action:!1,Loading:u,error:S}})})]})]})]})}const Md=({token:t})=>e.jsx(kd,{token:t}),$d=Ee.product.sellReports,Ud=Ee.academy.classes,Bd=Ee.academy.sections,Nd=Ee.student.dropdown,Jr=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Ld({token:t}){const n=i.useRef(null),[a,s]=i.useState(null),[o,l]=i.useState(""),[d,u]=i.useState(""),[S,g]=i.useState(""),[p,j]=i.useState(!1),I=b=>{const E=b?.data?.data??b?.data??b??[];return Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[]},{data:T}=K(t?[Ud,t]:null,([b,E])=>G(b,E)),m=i.useMemo(()=>I(T),[T]),c=t&&o?`${Bd}?class_id=${encodeURIComponent(String(o))}`:null,{data:y}=K(c?[c,t]:null,([b,E])=>G(b,E)),O=i.useMemo(()=>I(y),[y]),D=t&&o&&d?`${Nd}?class=${encodeURIComponent(String(o))}§ion=${encodeURIComponent(String(d))}`:null,{data:_}=K(D?[D,t]:null,([b,E])=>G(b,E)),A=i.useMemo(()=>I(_),[_]),{trigger:h,isMutating:f,data:x}=He($d,(b,{arg:E})=>Ha(b,{arg:E},t));i.useEffect(()=>{const E=new Date().toISOString().slice(0,10);h({duration:[E,E]})},[h]);const C=i.useMemo(()=>{const b=x?.data??x??[];return Array.isArray(b)?b:[]},[x]),P=b=>{const E=Array.isArray(b?.product_details)?b.product_details:[];return E.length===0?null:e.jsx(r.Table,{size:"small",bordered:!0,pagination:!1,rowKey:B=>`${b?.receipt_id??"r"}_${B?.product_name??B?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:B=>Jr(B)}],dataSource:E})},k=[{title:"Receipt No",dataIndex:"receipt_no",key:"receipt_no"},{title:"Date",dataIndex:"receipt_date",key:"receipt_date"},{title:"Amount",dataIndex:"receipt_amount",key:"receipt_amount",render:b=>Jr(b)}],U=async()=>{if(!a||a.length!==2)return;const[b,E]=a;await h({duration:[b.format("YYYY-MM-DD"),E.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:S||""})};return e.jsx("div",{children:e.jsxs(r.Row,{gutter:[16,16],children:[e.jsx(r.Col,{xs:24,lg:8,children:e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Filters"}),style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Duration"}),e.jsx(r.DatePicker.RangePicker,{value:a,onChange:s,style:{width:"100%"}})]}),e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:b=>{const E=b?.value??"";l(E),u(""),g(""),j(B=>!B)}}),e.jsx(te,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:b=>{const E=b?.value??"";u(E),g("")}},`section_${p}`),e.jsx(te,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:b=>g(b?.value??"")}),e.jsx(pe,{type:"button",value:f?"Searching...":"Search",disabled:f,onClick:U,style:{width:"100%"}})]})})}),e.jsx(r.Col,{xs:24,lg:16,children:e.jsx(r.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(ia,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(hn,{})}),e.jsx(r.Table,{bordered:!0,size:"small",loading:f,rowKey:b=>String(b?.receipt_id??b?.receipt_no??Math.random()),columns:k,expandable:{expandedRowRender:P},dataSource:C,pagination:{pageSize:20}})]})})})]})})}const qd=({token:t})=>e.jsx(Ld,{token:t}),zd=Ee.product;function Vd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState([]),[l,d]=i.useState([]),[u,S]=i.useState(!1),[g,p]=i.useState(!1),[j,I]=i.useState(null),[T,m]=i.useState(0),[c,y]=i.useState(null),[O,D]=i.useState(""),_=i.useRef(null),A=cn.useReactToPrint({contentRef:_,documentTitle:"Stock Barcodes"}),{isLoading:h,error:f,data:x,mutate:C}=ii({token:t,page:n.page,perPage:n.rowsPerPage}),P=(q,$)=>{a({page:q,rowsPerPage:parseInt($,10)})},k={selectedRowKeys:s,onChange:(q,$)=>{o(q),d($)}},U=q=>{I(q),m(Number(q?.quantity??0)),y(null),D(""),S(!0)},b=()=>{S(!1),I(null),m(0),y(null),D("")},E=async()=>{if(!j?.id)return;p(!0);const q=new FormData;q.append("product_id",String(j.id)),q.append("qty",String(T??0)),c&&q.append("tran_date",c.format("YYYY-MM-DD")),O&&q.append("remarks",O);try{const $=await qt(zd.addStock,q,t);$?.Status==="Success"?(v.success("Success! Updated quantity.",{duration:1e3}),b(),await C()):v.error($?.msg??"Failed to update quantity.",{duration:1e3})}catch{v.error("Failed to update quantity.",{duration:1e3})}finally{p(!1)}},B=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:(q,$)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(r.Button,{size:"small",onClick:()=>U($),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:j?.name?`Update Stock: ${j.name}`:"Update Stock",open:u,onCancel:b,onOk:E,okButtonProps:{loading:g},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(r.InputNumber,{min:0,style:{width:"100%"},value:T,onChange:q=>m(q??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(r.DatePicker,{style:{width:"100%"},value:c,onChange:y})]}),e.jsx(dn,{label:"Remarks",name:"remarks",rows:3,value:O,onChange:q=>D(q.target.value)})]})}),e.jsxs(de,{pt:5,pb:2,children:[e.jsxs(de,{children:["Manage Stock",e.jsx(pe,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>A?.(),style:{minWidth:170}})]}),e.jsx(de,{style:{padding:"12px 16px"},children:e.jsx(r.Card,{style:{borderRadius:16},children:e.jsx(Me,{parentCallback:P,data:{newData:x,columns:B,columnstype:"antd",action:!1,Loading:h,error:f,rowSelection:k}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:_,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map(q=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:q?.name??""}),e.jsx(_s,{value:String(q?.barcode??q?.id??""),height:50,width:1.6,displayValue:!0})]},q?.id??q?.barcode??q?.name))})})})]})}const Yd=({token:t})=>e.jsx(Vd,{token:t}),Wd=Ee.report.stock,Hd=Ee.product.dropdown,Kd=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Gd({token:t}){const n=i.useRef(null),[a,s]=i.useState(null),[o,l]=i.useState(""),{data:d}=K(t?[Hd,t]:null,([m,c])=>G(m,c)),u=i.useMemo(()=>Kd(d),[d]),{trigger:S,isMutating:g,data:p}=He(Wd,(m,{arg:c})=>Ha(m,{arg:c},t));i.useEffect(()=>{const c=new Date().toISOString().slice(0,10);S({duration:[c,c]})},[S]);const j=i.useMemo(()=>{const m=p?.data??p??[];return(Array.isArray(m)?m:[]).flatMap(y=>(Array.isArray(y?.ledger)?y.ledger:[]).map((O,D)=>({key:`${y.product_id??y.product_name??"p"}-${D}`,date:O?.date,product:y?.product_name,opening:O?.opening,inward:O?.inward,outward:O?.outward,closing:O?.closing})))},[p]),I=[{title:"Date",dataIndex:"date",key:"date"},{title:"Product",dataIndex:"product",key:"product"},{title:"Opening",dataIndex:"opening",key:"opening"},{title:"Inward",dataIndex:"inward",key:"inward"},{title:"Outward",dataIndex:"outward",key:"outward"},{title:"Closing",dataIndex:"closing",key:"closing",render:m=>e.jsx("span",{style:{color:Number(m)<0?"red":"green"},children:m})}],T=async()=>{if(!a||a.length!==2)return;const[m,c]=a;await S({duration:[m.format("YYYY-MM-DD"),c.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Stock Report"}),style:{borderRadius:16},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[e.jsx(r.DatePicker.RangePicker,{value:a,onChange:s}),e.jsxs("select",{value:o,onChange:m=>l(m.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),u.map(m=>e.jsx("option",{value:String(m?.value??""),children:String(m?.label??"")},String(m?.value??m?.id??m?.label)))]}),e.jsx(r.Button,{type:"primary",onClick:T,loading:g,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(ia,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(hn,{})}),e.jsx(r.Table,{bordered:!0,size:"small",loading:g,rowKey:"key",columns:I,dataSource:j,pagination:{pageSize:50}})]})]})}const Jd=({token:t})=>e.jsx(Gd,{token:t}),la=t=>t??localStorage.getItem("authToken")??"",Ja=(t,n)=>{const a=String(t??""),s=String(n??"");return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s},Ce={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",roleDropdown:"api/Branch/getRoledropdownforBranch",staff:{list:"api/branchapi/staff/stafflist",searchByRole:"api/branchapi/staff/staffsearchbyRole",searchByKeywords:"api/branchapi/staff/staffsearchbyKeywords",deactivate:"api/branchapi/staff/staff_deactive",basicById:"api/branchapi/staff/getbasicdetailsbyID",experienceById:"api/branchapi/staff/getworkexperencebyID",payrollById:"api/branchapi/staff/getpayrollbyID",lastEmpNo:"api/branchapi/staff/getLastStaffEMPnumber",addBasic:"api/branchapi/staff/addstaffbasicdetails",editBasic:"api/branchapi/staff/editstaffbasicdetails",addExperience:"api/branchapi/staff/addstaffExperience",editExperience:"api/branchapi/staff/editstaffExperience",addPayroll:"api/branchapi/staff/addstaffpayroll",editPayroll:"api/branchapi/staff/editstaffpayroll",uploadProfile:"api/branchapi/staff/uploadstaffProfilepicture",uploadDocuments:"api/branchapi/staff/uploadDocuments"},master:{shift:{dropdown:"api/branchapi/generalSettings/shiftDropdown",table:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/editshift",remove:"api/branchapi/generalSettings/deleteshift",show:"api/branchapi/generalSettings/shiftShowdata"},department:{dropdown:"api/branchapi/humanResource/departmentDropdown",table:"api/branchapi/humanResource/departmenttypeTable",add:"api/branchapi/humanResource/adddepartment",edit:"api/branchapi/humanResource/editdepartment",remove:"api/branchapi/humanResource/deletedepartment",show:"api/branchapi/humanResource/departmentShowdata"},designation:{dropdown:"api/branchapi/humanResource/designationDropdown",table:"api/branchapi/humanResource/designationTable",add:"api/branchapi/humanResource/adddesignation",edit:"api/branchapi/humanResource/editdesignation",remove:"api/branchapi/humanResource/deletedesignation",show:"api/branchapi/humanResource/designationShowdata"},leaveType:{dropdown:"api/branchapi/humanResource/leavetypeDropdown",table:"api/branchapi/humanResource/LeavetypeTable",add:"api/branchapi/humanResource/addleavetype",edit:"api/branchapi/humanResource/editleavetype",remove:"api/branchapi/humanResource/deleteleavetype",show:"api/branchapi/humanResource/leavetypeShowdata"}},leave:{table:"api/branchapi/humanResource/LeaveTable",apply:"api/branchapi/humanResource/applyLeave",requestTable:"api/branchapi/humanResource/leaverequestTable",approveRequest:"api/branchapi/humanResource/approveleaveRequest"},attendance:{staffListForAttendance:"api/staff/attendence/stafflistforAttendence",staffDropdownByRole:"api/staff/attendence/getStaffDropDownByRoleId",addAttendanceToStaffByBranch:"api/staff/attendence/addattendencetoStaffbyBranch",manualAttendance:"api/staff/attendence/staffMenualAttendance",staffShiftByStaffId:"api/branchapi/staff/getStaffShiftByStaffId",dailyAttendance:"api/staff/attendence/dailyAttendance",dailyAttendanceMultipleShift:"api/staff/attendence/dailyAttendanceMultipleShift"},attendanceReport:{monthlyStaffReport:"api/AttendenceReport/staffmonthlyAttendenceReport_new",staffAttendanceList:"api/AttendenceReport/staffAttendanceList",overallStaffReport:"api/staff/attendence/getAlloverAttendenceReportofStaff"},payroll:{monthlyGraph:"api/branchapi/reportGraph/monthlyPayroleReportgraph",staffPayrollByStaffId:"api/branchapi/humanResource/getStaffPayroleByStaffID",generatePayslip:"api/branchapi/humanResource/generatePayslip",payrollByRole:"api/branchapi/humanResource/getpayrolebyRole",monthlyReport:"api/branchapi/humanResource/monthlyPayRolereport"}},oi=()=>Ja(it(),Ce.upload),Qd=()=>Ja(it(),Ce.staff.uploadProfile),Xd=()=>Ja(it(),Ce.staff.uploadDocuments),Zd=async({baseUrl:t,page:n=1,perPage:a=10},s)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return G(l,la(s))},yt=async(t,n,a)=>Ye(t,n,la(a)),wt=async(t,n,a)=>ut(t,n,la(a)),Sn=async(t,n,a)=>tt(t,n,la(a)),It=Ce.staff,ec=Ce.master.shift.dropdown,tc=Ce.master.department.dropdown,nc=Ce.master.designation.dropdown,ac=Ce.roleDropdown,Dn=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},rc=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Qt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Qr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function sc({token:t,mode:n,staffId:a,initialValues:s,onSubmitted:o}){const l=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),d=String(l?.multiple_shift??"").toLowerCase()==="yes",[u,S]=i.useState(s?.roleValue??null),[g,p]=i.useState(s?.departmentValue??null),[j,I]=i.useState(s?.designationValue??null),[T,m]=i.useState(s?.genderValue??null),[c,y]=i.useState(s?.shiftValue??(d?[]:null)),[O,D]=i.useState(s?.dob?ye(s.dob):null),[_,A]=i.useState(s?.doj?ye(s.doj):null),[h,f]=i.useState(s?.file??""),{data:x}=K(t?[ec,t]:null,([H,V])=>G(H,V)),{data:C}=K(t?[tc,t]:null,([H,V])=>G(H,V)),{data:P}=K(t?[nc,t]:null,([H,V])=>G(H,V)),{data:k}=K(t?[ac,t]:null,([H,V])=>G(H,V)),{data:U}=K(t?[It.lastEmpNo,t]:null,([H,V])=>G(H,V)),b=i.useMemo(()=>Dn(x),[x]),E=i.useMemo(()=>Dn(C),[C]),B=i.useMemo(()=>Dn(P),[P]),q=i.useMemo(()=>Dn(k),[k]),$=i.useMemo(()=>{const H=U?.data?.emp_number??U?.emp_number??U?.data??"";return String(H??"")},[U]),N=async H=>{H.preventDefault();const V=new FormData(H.target);V.set("role",u?.value??u??""),V.set("department",g?.value??g??""),V.set("designation",j?.value??j??""),V.set("gender",T?.value??T??""),V.set("dob",O?O.format("YYYY-MM-DD"):""),V.set("doj",_?_.format("YYYY-MM-DD"):""),d?(V.delete("shift_id"),(Array.isArray(c)?c:[]).forEach(w=>{V.append("shift_id[]",w?.value??w??"")})):V.set("shift_id",c?.value??c??""),h&&V.set("file",h);try{const R=n==="edit"&&a,w=R?It.editBasic:It.addBasic;R&&V.set("staff_id",String(a));const M=R?await wt(w,V,t):await yt(w,V,t),F=M?.ID??M?.id??a??null;v.success("Success!",{duration:1e3}),o?.({staffId:F,basic:{roleValue:u,departmentValue:g,designationValue:j,genderValue:T,shiftValue:c,dob:O,doj:_,file:h}})}catch(R){v.error(R?.response?.data?.msg??R?.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(X,{type:"number",name:"emp_number",label:"EMP No",defaultValue:s?.emp_number??$,required:!0}),e.jsx(X,{type:"text",name:"f_name",label:"First Name",defaultValue:s?.f_name??"",required:!0}),e.jsx(X,{type:"text",name:"l_name",label:"Last Name",defaultValue:s?.l_name??"",required:!0}),e.jsx(X,{type:"text",name:"pan_no",label:"PAN",defaultValue:s?.pan_no??""}),e.jsx(X,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:s?.adhar_no??""}),e.jsx(te,{label:"Role",options:q,value:u,onChange:H=>S(H??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(te,{label:"Department",options:E,value:g,onChange:H=>p(H??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(te,{label:"Designation",options:B,value:j,onChange:H=>I(H??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(te,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:T,onChange:H=>m(H??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(X,{type:"text",name:"email",label:"Email",defaultValue:s?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:Qt,children:"DOB"}),e.jsx(r.DatePicker,{value:O,onChange:H=>D(H),style:Qr,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:Qt,children:"DOJ"}),e.jsx(r.DatePicker,{value:_,onChange:H=>A(H),style:Qr,placeholder:"Select DOJ"})]}),e.jsx(X,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:s?.bloodGroup??""}),e.jsx(X,{type:"text",name:"contact_no",label:"Contact No",defaultValue:s?.contact_no??"",required:!0}),e.jsx(X,{type:"text",name:"education",label:"Education",defaultValue:s?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:Qt,children:"Shift"}),e.jsx(te,{options:b,value:c,onChange:H=>y(H??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:Qt,children:"Profile Picture"}),e.jsx(r.Upload,{maxCount:1,action:Qd(),headers:t?{Authorization:t}:void 0,onChange:H=>{if(H?.file?.status==="done"){const V=rc(H?.file?.response);V&&f(V)}H?.file?.status==="removed"&&f("")},children:e.jsx(r.Button,{type:"link",style:{paddingLeft:0},children:h?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:Qt,children:"Address"}),e.jsx("textarea",{name:"address",rows:3,defaultValue:s?.address??"",placeholder:"Address",style:{width:"100%",resize:"vertical",padding:10,border:"1px solid #d9d9d9",borderRadius:8,outline:"none"}})]}),e.jsx("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const On={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Xr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ic=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Zr=t=>{if(!t)return null;const n=ye(t);return n.isValid()?n:null};function oc({token:t,mode:n,staffId:a,initialRows:s,onSubmitted:o,onBack:l}){const[d,u]=i.useState(()=>(Array.isArray(s)&&s.length?s:[{name:"",from:null,to:null,image:""}]).map(m=>({name:m?.name??"",from:Zr(m?.from),to:Zr(m?.to),image:m?.image??""}))),S=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),g=(T,m)=>{u(c=>c.map((y,O)=>O===T?{...y,...m}:y))},p=()=>u(T=>[...T,{name:"",from:null,to:null,image:""}]),j=T=>u(m=>m.length<=1?m:m.filter((c,y)=>y!==T)),I=async T=>{if(T.preventDefault(),!a){v.error("Missing staff id.",{duration:1e3});return}const m=new FormData;m.append("staff_id",String(a)),d.forEach((c,y)=>{m.append(`experience[${y}][name]`,String(c?.name??"")),m.append(`experience[${y}][from]`,c?.from?c.from.format("YYYY-MM-DD"):""),m.append(`experience[${y}][to]`,c?.to?c.to.format("YYYY-MM-DD"):""),m.append(`experience[${y}][image]`,String(c?.image??""))});try{const c=n==="edit",y=c?It.editExperience:It.addExperience,O=c?await wt(y,m,t):await yt(y,m,t);v.success("Success!",{duration:1e3}),o?.({experience:d,result:O})}catch(c){v.error(c?.response?.data?.msg??c?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((T,m)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end",border:"1px solid #eee",borderRadius:12,padding:14},children:[e.jsxs("div",{children:[e.jsx("div",{style:On,children:"Name"}),e.jsx("input",{value:T.name,onChange:c=>g(m,{name:c.target.value}),placeholder:"Company / School",style:{width:"100%",height:40,border:"none",borderBottom:"1px solid #d9d9d9",outline:"none",background:"transparent"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:On,children:"From"}),e.jsx(r.DatePicker,{value:T.from,onChange:c=>g(m,{from:c}),style:Xr})]}),e.jsxs("div",{children:[e.jsx("div",{style:On,children:"To"}),e.jsx(r.DatePicker,{value:T.to,onChange:c=>g(m,{to:c}),style:Xr})]}),e.jsxs("div",{children:[e.jsx("div",{style:On,children:"Document"}),e.jsx(r.Upload,{maxCount:1,action:Xd(),headers:S,onChange:c=>{if(c?.file?.status==="done"){const y=ic(c?.file?.response);y&&g(m,{image:y})}c?.file?.status==="removed"&&g(m,{image:""})},children:e.jsx(r.Button,{icon:e.jsx(re.UploadOutlined,{}),children:"Upload"})}),!!T.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:T.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(r.Button,{type:"text",icon:e.jsx(re.DeleteOutlined,{}),danger:!0,onClick:()=>j(m),disabled:d.length<=1})})]},`exp-${m}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(r.Button,{icon:e.jsx(re.PlusOutlined,{}),onClick:p,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(r.Button,{onClick:l,children:"Back"}),e.jsx(pe,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const es=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:n??[]},Xt=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function lc({token:t,mode:n,staffId:a,initialValues:s,onSubmitted:o,onBack:l}){const[d,u]=i.useState(s?.type??"Permanent"),[S,g]=i.useState(s?.salary_type??Xt[0]?.value),[p,j]=i.useState(Number(s?.amount??0)),[I,T]=i.useState(Number(s?.basic_pay??0)),[m,c]=i.useState(s?.declarationPERyear??""),{data:y}=K(t?[el,t]:null,([f,x])=>G(f,x),{revalidateOnFocus:!1}),O=i.useMemo(()=>es(y?.Allowances),[y]),D=i.useMemo(()=>es(y?.Dedection),[y]),_=i.useMemo(()=>{const f=Number(I||0),x=(Array.isArray(O)?O:[]).map(b=>{const E=b?.amount_type??b?.amountType??b?.type,B=Number(b?.Amount??b?.amount??0),q=String(E).toLowerCase()==="flat"?B:Number(f)/100*Number(B||0);return{...b,value:Number.isFinite(q)?q:0}}),C=(Array.isArray(D)?D:[]).map(b=>{const E=b?.amount_type??b?.amountType??b?.type,B=Number(b?.Amount??b?.amount??0),q=String(E).toLowerCase()==="flat"?B:Number(f)/100*Number(B||0);return{...b,value:Number.isFinite(q)?q:0}}),P=x.reduce((b,E)=>b+Number(E?.value||0),0),k=C.reduce((b,E)=>b+Number(E?.value||0),0),U=Math.max(0,Number(f)+P-k);return{allowances:x,deductions:C,netAmount:U}},[O,D,I]),A=async f=>{if(f.preventDefault(),!a){v.error("Missing staff id.",{duration:1e3});return}const x=new FormData;x.append("staff_id",String(a)),x.append("type",d),d==="Nonpermanent"?(x.append("salary_type",S??""),x.append("amount",String(p||"")),x.append("Allowances",JSON.stringify([])),x.append("Dedection",JSON.stringify([]))):(x.append("basic_pay",String(I||"")),x.append("declarationPERyear",String(m??"")),x.append("Allowances",JSON.stringify(_.allowances||[])),x.append("Dedection",JSON.stringify(_.deductions||[])),x.append("amount",String(_.netAmount||0)));try{const C=n==="edit",P=C?It.editPayroll:It.addPayroll,k=C?await wt(P,x,t):await yt(P,x,t);v.success("Success!",{duration:1e3}),o?.({payroll:{staffType:d,salaryType:S,amount:p,basicPay:I,declaration:m},result:k})}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed.",{duration:1e3})}},h=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(f,x)=>`${x?.Amount??""} / ${x?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:f=>u(f?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(te,{label:"Type",options:Xt,value:Xt.find(f=>f.value===S)??Xt[0],onChange:f=>g(f?.value??Xt[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(X,{type:"number",label:"Amount",value:p,onChange:f=>j(Number(f.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{type:"number",label:"Basic Pay",value:I,onChange:f=>T(Number(f.target.value||0)),required:!0}),e.jsx(X,{type:"text",label:"IT Declarations/Year",value:m,onChange:f=>c(f.target.value)}),e.jsx(X,{type:"number",label:"Net Amount",value:_.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(r.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(r.Table,{bordered:!0,size:"small",rowKey:(f,x)=>`${f?.title??"a"}-${x}`,columns:h,dataSource:_.allowances,pagination:!1})}),e.jsx(r.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(r.Table,{bordered:!0,size:"small",rowKey:(f,x)=>`${f?.title??"d"}-${x}`,columns:h,dataSource:_.deductions,pagination:!1})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(Button,{onClick:l,children:"Back"}),e.jsx(pe,{type:"submit",value:"Finish",color:"primary"})]})]})})}const dc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function cc({token:t,mode:n="add",staffId:a,onFinished:s}){const[o,l]=i.useState(0),[d,u]=i.useState(a??null),[S,g]=i.useState(null),[p,j]=i.useState(null),[I,T]=i.useState(null),m=n==="edit"?a??d:null,c=i.useMemo(()=>m?`${Ce.staff.basicById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),y=i.useMemo(()=>m?`${Ce.staff.experienceById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),O=i.useMemo(()=>m?`${Ce.staff.payrollById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),{data:D}=K(t&&c?[c,t]:null,([P,k])=>G(P,k)),{data:_}=K(t&&y?[y,t]:null,([P,k])=>G(P,k)),{data:A}=K(t&&O?[O,t]:null,([P,k])=>G(P,k)),h=i.useMemo(()=>{const P=dc(D)[0]??D?.data??D??null;return P?{emp_number:P?.emp_number??P?.empNo??"",f_name:P?.f_name??P?.firstname??P?.first_name??"",l_name:P?.l_name??P?.lastname??P?.last_name??"",pan_no:P?.pan_no??"",adhar_no:P?.adhar_no??"",email:P?.email??"",dob:P?.dob??"",doj:P?.doj??"",bloodGroup:P?.bloodGroup??P?.blood_group??"",contact_no:P?.contact_no??P?.phone??"",education:P?.education??"",address:P?.address??"",file:P?.file??P?.profile_picture??""}:null},[D]),f=i.useMemo(()=>{const P=_?.data??_??null;return(Array.isArray(P?.experience)?P.experience:Array.isArray(P)?P:[]).map(U=>({name:U?.name??"",from:U?.from??"",to:U?.to??"",image:U?.image??""}))},[_]),x=i.useMemo(()=>{const P=A?.data??A??null;return P?{type:P?.type??"Permanent",salary_type:P?.salary_type??"",amount:P?.amount??"",basic_pay:P?.basic_pay??"",declarationPERyear:P?.declarationPERyear??""}:null},[A]),C=i.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:n==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(r.Steps,{current:o,items:C}),o===0&&e.jsx(sc,{token:t,mode:n,staffId:m,initialValues:h,onSubmitted:({staffId:P})=>{P&&u(P),l(1)}}),o===1&&e.jsx(oc,{token:t,mode:n,staffId:m??d,initialRows:f,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(lc,{token:t,mode:n,staffId:m??d,initialValues:x,onBack:()=>l(1),onSubmitted:()=>{v.success("Completed.",{duration:1e3}),s?.({staffId:m??d})}})]})})]})}function uc({token:t}){return e.jsx(cc,{token:t,mode:"add"})}const pc=({token:t})=>e.jsx(uc,{token:t}),Pn=Ce.staff,mc=Ce.roleDropdown,fc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},yc=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function hc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(""),[l,d]=i.useState(""),{data:u}=K(t?[mc,t]:null,([O,D])=>G(O,D)),S=i.useMemo(()=>fc(u),[u]),g=i.useMemo(()=>{const O=n.page,D=n.rowsPerPage,_=s&&!l?`${Pn.searchByRole}?role_id=${encodeURIComponent(String(s))}`:l?`${Pn.searchByKeywords}?key=${encodeURIComponent(String(l))}`:Pn.list,A=_.includes("?")?"&":"?";return`${_}${A}page=${encodeURIComponent(String(O))}&per_page=${encodeURIComponent(String(D))}`},[n.page,n.rowsPerPage,l,s]),{isLoading:p,error:j,data:I,mutate:T}=K(t?[g,t]:null,([O,D])=>G(O,D)),m=i.useMemo(()=>yc(I),[I]),c=async O=>{const D=O?.id??O?.fk_staffID??O?.staff_id;if(D)try{await Sn(Pn.deactivate,D,t),v.success("Success! Staff deactivated.",{duration:1e3}),await T()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to deactivate staff.",{duration:1e3})}},y=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(O,D)=>`${D?.firstname??D?.first_name??""} ${D?.lastname??D?.last_name??""}`.trim()||D?.name||""},{title:"Role",dataIndex:"role_name",key:"role_name",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["lg"]},{title:"Status",dataIndex:"status",key:"status",width:120,responsive:["lg"]},{title:"Action",key:"action",width:90,fixed:"right",render:(O,D)=>e.jsx(r.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(re.DeleteOutlined,{}),onClick:()=>c(D),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:3,style:{margin:0},children:"Filters"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:[{value:"",label:"All Roles"},...S],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:O=>{o(O?.value??""),a(D=>({...D,page:1}))}}),e.jsx(X,{type:"text",label:"Keyword",value:l,onChange:O=>d(O.target.value),placeholder:"Search by keywords"}),e.jsx(pe,{type:"button",value:"Refresh",onClick:()=>T()})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(r.Table,{bordered:!0,size:"small",loading:p,rowKey:O=>String(O?.id??O?.fk_staffID??O?.staff_id??Math.random()),columns:y,dataSource:m,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(O,D)=>a({page:O,rowsPerPage:D}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const gc=({token:t})=>e.jsx(hc,{token:t}),xc=Ce.attendance,bc=Ce.roleDropdown,ts=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},En={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ns={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Sc({token:t,open:n,onClose:a,roleId:s,onSaved:o}){const[l,d]=i.useState(null),[u,S]=i.useState(""),[g,p]=i.useState(ye()),[j,I]=i.useState(ye()),[T,m]=i.useState(ye()),c=i.useMemo(()=>s?`${Ce.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(s))}`:null,[s]),{data:y}=K(t&&c?[c,t]:null,([f,x])=>G(f,x)),O=i.useMemo(()=>ts(y),[y]),{trigger:D,data:_}=He(t?Ce.attendance.staffShiftByStaffId:null,(f,{arg:x})=>At(f,{arg:x},t)),A=i.useMemo(()=>ts(_),[_]),h=async()=>{if(!l?.value){v.error("Select staff.",{duration:1e3});return}if(!u){v.error("Select shift.",{duration:1e3});return}const f=new FormData;f.set("staffID",String(l.value)),f.set("shift_id",String(u)),f.set("attendance_date",g?g.format("YYYY-MM-DD"):""),f.set("intime",j?j.format("h:mm a"):""),f.set("outime",T?T.format("h:mm a"):"");try{await yt(Ce.attendance.manualAttendance,f,t),v.success("Success!",{duration:1e3}),o?.(),a?.(),d(null),S(""),p(ye()),I(ye()),m(ye())}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed.",{duration:1e3})}};return e.jsx(r.Modal,{open:n,onCancel:a,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(r.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{label:"Staff",options:O,value:l,onChange:async f=>{if(d(f??null),S(""),f?.value&&D)try{await D({staff_id:f.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:En,children:"Shift"}),e.jsx(r.Radio.Group,{value:u,onChange:f=>S(f.target.value),style:{display:"grid",gap:8},children:A.map(f=>e.jsx(r.Radio,{value:f?.value,children:f?.label??f?.name??f?.title??String(f?.value??"")},String(f?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:En,children:"Date"}),e.jsx(r.DatePicker,{value:g,onChange:f=>f&&p(f),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:En,children:"Start Time"}),e.jsx(r.TimePicker,{value:j,onChange:f=>f&&I(f),use12Hours:!0,format:"h:mm a",style:ns})]}),e.jsxs("div",{children:[e.jsx("div",{style:En,children:"End Time"}),e.jsx(r.TimePicker,{value:T,onChange:f=>f&&m(f),use12Hours:!0,format:"h:mm a",style:ns})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(r.Button,{onClick:a,children:"Cancel"}),e.jsx(pe,{type:"button",value:"Save",color:"primary",onClick:h})]})]})})})}const jc=({tableRef:t,excelDisabled:n})=>{const a=new Date().getTime(),s=cn.useReactToPrint({content:()=>t?.current});return e.jsx(r.Row,{justify:"end",children:e.jsx(r.Col,{children:e.jsxs(r.Row,{gutter:8,children:[e.jsx(r.Col,{children:e.jsx(r.Button,{type:"text",icon:e.jsx(re.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:s})}),e.jsx(r.Col,{children:n?e.jsx(r.Button,{type:"text",icon:e.jsx(re.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>v.error("You must save attendance before download",{duration:2e3})}):e.jsx(ni.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:t?.current,children:e.jsx(r.Button,{type:"text",icon:e.jsx(re.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},wc=(t,n)=>{const a=t?.data?.data??t?.data??t??null;return a?n==="student"?Array.isArray(a?.student)?a.student:[]:Array.isArray(a?.staff)?a.staff:[]:[]},vc=t=>{const n=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,a=Number(n);return Number.isFinite(a)&&a>=0?a:0},_c=(t,n)=>{const a=t?.data?.data??t?.data??t??null;return a?n==="student"?{sunday:String(a?.sunday??"").toLowerCase()==="yes",holiday:String(a?.holiday??"").toLowerCase()==="yes"}:{sunday:!!a?.sunday,holiday:!!a?.holiday}:{sunday:!1,holiday:!1}};function Cc({token:t,url:n,columns:a,reload:s,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:u,type:S="staff"}){const g=i.useRef(null),[p,j]=i.useState({page:0,rowsPerPage:10}),[I,T]=i.useState(!1),[m,c]=i.useState(!1),[y,O]=i.useState(null),[D,_]=i.useState([]),[A,h]=i.useState({sunday:!1,holiday:!1}),[f,x]=i.useState(!0);i.useEffect(()=>{j(U=>({...U,page:0}))},[n]),i.useEffect(()=>{let U=!0;return(async()=>{if(!(!t||!n)){T(!0);try{const E=String(n).includes("?")?"&":"?",B=`${n}${E}page=${p.page+1}&per_page=${p.rowsPerPage}`,q=await G(B,t);if(!U)return;O(q),q?.Status==="Success"?(d?.(!1),_(wc(q,S)),h(_c(q,S))):(d?.(!0),_([]),h({sunday:!1,holiday:!1}))}catch{if(!U)return;d?.(!0),_([])}finally{U&&T(!1)}}})(),()=>{U=!1}},[p.page,p.rowsPerPage,s,d,t,S,n]);const C=i.useMemo(()=>vc(y),[y]);i.useEffect(()=>{const U=(Array.isArray(D)?D:[]).find(b=>b?.attendence_type_id===null);x(!!U)},[D]);const P=async()=>{if(t){c(!0);try{if(S==="staff"){const U=(Array.isArray(D)?D:[]).map(b=>({staff_id:b?.staff_id,attendence_type_id:b?.attendence_type_id?b.attendence_type_id:"1",in_time:b?.intime,out_time:b?.outtime,date:u}));await yt(Ce.attendance.addAttendanceToStaffByBranch,U,t),v.success("Attendance saved successfully",{duration:2e3}),o?.(b=>!b)}else v.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(U){v.error(U?.response?.data?.msg??U?.message??"Failed required dates",{duration:2e3})}finally{c(!1)}}},k=i.useMemo(()=>(Array.isArray(a)?a:[]).map(b=>b?.selector==="attendence_type_id"?{title:b?.name??"Attendance",dataIndex:b.selector,key:b.selector,render:E=>E==null||E===""?e.jsx(r.Tag,{color:"orange",children:"Not Set"}):String(E)==="1"?e.jsx(r.Tag,{color:"green",children:"Present"}):String(E)==="4"?e.jsx(r.Tag,{color:"red",children:"Absent"}):String(E)==="3"?e.jsx(r.Tag,{color:"orange",children:"Late"}):e.jsx(r.Tag,{children:String(E)})}:b?.selector==="snum"?{title:b?.name??"Sl",key:b.selector,render:(E,B,q)=>q+1}:{title:b?.name??b?.selector,dataIndex:b?.selector,key:b?.selector}),[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(r.Card,{children:[e.jsx(jc,{tableRef:g,excelDisabled:f}),e.jsx(r.Modal,{open:m,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(r.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),A.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):A.holiday?e.jsx("div",{style:{textAlign:"center",padding:"16px 0"},children:e.jsx("div",{style:{fontWeight:700,marginBottom:6},children:"Holiday"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:g,children:e.jsx(r.Table,{bordered:!0,size:"small",rowKey:(U,b)=>String(U?.id??U?.staff_id??b),columns:k,dataSource:D,loading:I,pagination:{current:p.page+1,pageSize:p.rowsPerPage,total:C,showSizeChanger:!0,onChange:(U,b)=>j({page:U-1,rowsPerPage:b})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:P,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const Tc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Ac={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ic({token:t}){const[n,a]=i.useState(""),[s,o]=i.useState(ye().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[u,S]=i.useState(null),[g,p]=i.useState(!1),[j,I]=i.useState(!0),[T,m]=i.useState(!1),c=i.useRef(null),{data:y}=K(t?[bc,t]:null,([_,A])=>G(_,A)),O=i.useMemo(()=>Tc(y),[y]),D=i.useMemo(()=>[{id:"1",name:"Staff Id",selector:"employee_id",sortable:!0},{id:"2",name:"Name",selector:"full_name",sortable:!0},{id:"4",name:"Contact",selector:"contact_no",sortable:!0},{id:"3",name:"Attendance",selector:"attendence_type_id",sortable:!0},{id:"5",name:"In Time",selector:"intime",sortable:!0},{id:"6",name:"Out Time",selector:"outtime",sortable:!0}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:_=>a(_?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(r.DatePicker,{defaultValue:ye(),onChange:_=>_&&o(_.format("YYYY-MM-DD")),style:Ac,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!s||(S(`${xc.staffListForAttendance}?role=${encodeURIComponent(String(n))}&date=${encodeURIComponent(String(s))}`),d(_=>!_))}})})]})}),e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:12},children:[e.jsx(r.Button,{size:"small",type:g?"primary":"default",onClick:()=>p(_=>!_),children:g?"Marked":"Mark As Holiday"}),e.jsx(r.Button,{size:"small",type:"default",disabled:j,onClick:()=>m(!0),children:"Give Attendance"})]}),u?e.jsx(Cc,{token:t,url:u,columns:D,reload:l,setReload:d,saveBtnRef:c,setSaveBtnDisabled:I,date:s,type:"staff",holidayChecked:g}):null]}),e.jsx(Sc,{token:t,open:T,onClose:()=>m(!1),roleId:n,onSaved:()=>d(_=>!_)})]})}const Rc=({token:t})=>e.jsx(Ic,{token:t}),as=Ce.attendanceReport.monthlyStaffReport,Dc=Ce.roleDropdown,Oc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Pc({token:t}){const n=i.useRef(null),[a,s]=i.useState(!1),[o,l]=i.useState([]),[d,u]=i.useState({role:"",rolllabel:"",year:"",month:""}),S=i.useMemo(()=>Xs(5),[]),{data:g}=K(t?[Dc,t]:null,([U,b])=>G(U,b)),p=i.useMemo(()=>Oc(g),[g]),[j,I]=i.useState([]),[T,m]=i.useState(1),[c,y]=i.useState(!1),[O,D]=i.useState(!1),[_,A]=i.useState(null),h=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:f}=He(t&&as?`${as}?page=${T}&per_page=3`:null,(U,{arg:b})=>At(U,{arg:b},t),{onSuccess:U=>{y(!1);const b=Array.isArray(U)?U:[];b.length>0&&I(E=>[...E||[],...b]),b.length>1?m(E=>E+1):D(!1)},onError:()=>{y(!1),D(!1)}});i.useEffect(()=>{O&&f&&_&&f(_)},[O,T,_,f]);const x=i.useMemo(()=>{const U=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(b,E)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:E?.full_name??""})}];return Array.isArray(j)&&j.length>0&&((j[0]?.monthly_data??[]).forEach((E,B)=>{U.push({title:B+1,align:"center",key:String(B+1),render:(q,$)=>{const N=$?.monthly_data?.[B]?.[0]?.data?.[0]??{},H=N?.intime??"",V=N?.outtime??"",R=N?.attendance_type??"";return e.jsx(r.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",H]}),e.jsxs("div",{children:["Out Time ",V]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:Pt(R)})})}})}),U.push({title:"Total",key:"Total",render:(E,B)=>{const q=B?.monthly_data??[],$=q.filter(H=>H?.[0]?.data?.[0]?.attendance_type==="A").length,N=q.filter(H=>H?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",$," P : ",N]})})}})),U},[j]),C=i.useMemo(()=>[{label:"Present",el:Pt("P")},{label:"Absent",el:Pt("A")},{label:"Leave",el:Pt("L")},{label:"Weekly Off",el:Pt("W")},{label:"Holiday",el:Pt("H")}],[]),P=i.useMemo(()=>d.month?o.find(U=>U?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),k=async U=>{if(U.preventDefault(),!d.role||!d.year||!d.month)return;m(1),y(!0),I([]);const b={session:h,year:d.year,month:d.month,day:"01",role:d.role};A(b),D(!0),await f?.(b)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{className:"d-print-none",title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:k,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:U=>u(b=>({...b,role:U?.value??"",rolllabel:U?.label??""}))}),e.jsx(te,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:U=>{const b=Zs(U?.value);l(b),s(E=>!E),u(E=>({...E,year:U?.label??""}))}}),e.jsx(te,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:U=>u(b=>({...b,month:U?.value??""}))},`month-${a}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(hn,{})}),e.jsxs("div",{style:{border:"1px solid #ddd",borderRadius:8,padding:16,marginBottom:24,backgroundColor:"#f8f9fa"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:6},children:"Staff Attendance Summary"}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:10,fontSize:13},children:[e.jsxs("div",{children:["Role: ",e.jsx("span",{style:{fontWeight:700},children:d.rolllabel||"--"})]}),e.jsxs("div",{children:["Year: ",e.jsx("span",{style:{fontWeight:700},children:d.year||"--"})]}),e.jsxs("div",{children:["Month: ",e.jsx("span",{style:{fontWeight:700},children:P})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ia,{data:{tableRef:n}})})]}),e.jsx("div",{style:{marginTop:14,paddingTop:14,borderTop:"1px solid #e0e0e0"},children:e.jsx("div",{style:{display:"flex",justifyContent:"center",flexWrap:"wrap",gap:12,fontSize:12},children:C.map(U=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[U.label," :"]}),e.jsx("div",{children:U.el})]},U.label))})})]}),e.jsx(r.Skeleton,{active:!0,loading:c,paragraph:{rows:10},children:e.jsx(r.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:x,dataSource:j,pagination:!1,scroll:{x:"max-content"},rowKey:(U,b)=>String(U?.staff_id??U?.id??b)})})]})})]})}const Ec=({token:t})=>e.jsx(Pc,{token:t}),rs=Ce.payroll,Fc=Ce.roleDropdown,kc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Mc=t=>t?.data?.data??t?.data??t??[];function $c({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:a}){const[s,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[u,S]=i.useState([]),[g,p]=i.useState({role:"",roleLabel:"",year:"",month:""}),[j,I]=i.useState(null),T=x=>{if(!x)return;if(typeof a=="function"){a(x);return}const C=`${n}?id=${encodeURIComponent(String(x))}`;typeof window<"u"&&window?.location&&(window.location.href=C)},{data:m}=K(t?[Fc,t]:null,([x,C])=>G(x,C)),c=i.useMemo(()=>kc(m),[m]),y=i.useMemo(()=>Xs(5),[]),{isLoading:O,error:D,data:_}=K(t&&j?[j,t]:null,([x,C])=>G(x,C)),A=i.useMemo(()=>{const x=Mc(_);return Array.isArray(x)?x:[]},[_]),h=i.useMemo(()=>{const x=_?.pagination?.total_rows??_?.data?.pagination?.total_rows??_?.total??_?.total_rows,C=Number(x);return Number.isFinite(C)&&C>=0?C:A.length},[_,A.length]),f=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(x,C,P)=>P+1},{title:"Name",dataIndex:"full_name",key:"full_name",ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Mobile No",dataIndex:"contact_no",key:"contact_no",width:140,responsive:["md"]},{title:"Status",dataIndex:"status",key:"status",width:120,align:"center",render:(x,C)=>{const P=C?.id??C?.staff_id??C?.staffId;return e.jsx(r.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{T(P)},children:ei(C?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:x=>{if(x.preventDefault(),!g.role||!g.year||!g.month)return;const C=`${rs.payrollByRole}?page=${encodeURIComponent(String(s.page))}&per_page=${encodeURIComponent(String(s.rowsPerPage))}&role=${encodeURIComponent(String(g.role))}&year=${encodeURIComponent(String(g.year))}&month=${encodeURIComponent(String(g.month))}`;I(C)},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",marginBottom:14,padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsx(te,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:x=>p(C=>({...C,role:x?.value??"",roleLabel:x?.label??""}))}),e.jsx(te,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:x=>{const C=Zs(x?.value);S(C),d(P=>!P),p(P=>({...P,year:x?.label??"",month:""}))}}),e.jsx(te,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:x=>p(C=>({...C,month:x?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Search",color:"primary",onClick:()=>o(x=>({...x,page:1}))})})]})}),e.jsx(r.Table,{bordered:!0,size:"small",loading:O,rowKey:(x,C)=>String(x?.id??x?.staff_id??C),columns:f,dataSource:A,pagination:{current:s.page,pageSize:s.rowsPerPage,total:h,showSizeChanger:!0,onChange:(x,C)=>{o({page:x,rowsPerPage:C}),!(!g.role||!g.year||!g.month)&&I(`${rs.payrollByRole}?page=${encodeURIComponent(String(x))}&per_page=${encodeURIComponent(String(C))}&role=${encodeURIComponent(String(g.role))}&year=${encodeURIComponent(String(g.year))}&month=${encodeURIComponent(String(g.month))}`)}},scroll:{x:"max-content"}})]})})}const Uc=({token:t})=>e.jsx($c,{token:t}),li=Ce.leave,zt=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>K(s&&t?[t,n,a,s]:null,([l,d,u,S])=>Zd({baseUrl:l,page:d,perPage:u},S)),Bc=({token:t,page:n=1,perPage:a=10})=>zt({token:t,baseUrl:li.requestTable,page:n,perPage:a}),Nc=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Lc=(t,n)=>{const a=new FormData;return Object.entries(t??{}).forEach(([s,o])=>{o!=null&&a.append(s,String(o))}),a.set("status",n),a};function qc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),{isLoading:s,error:o,data:l,mutate:d}=Bc({token:t,page:n.page,perPage:n.rowsPerPage}),u=i.useMemo(()=>Nc(l),[l]),S=async(p,j)=>{try{const I=Lc(p,j),T=await wt(li.approveRequest,I,t);T?.Status==="Success"?v.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):v.error(T?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(I){v.error(I?.response?.data?.msg??I?.message??"Failed to update request.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(p,j)=>j?.full_name??j?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(p,j)=>j?.leave_from??j?.from_date??""},{title:"To",key:"leave_to",width:120,render:(p,j)=>j?.leave_to??j?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(p,j)=>j?.leavetype??j?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(p,j)=>j?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(p,j)=>j?.employee_remark??j?.reason??""},{title:"View",key:"document_file",width:140,render:(p,j)=>{const I=j?.document_file;return I?e.jsx(r.Button,{size:"small",onClick:()=>window.open(I,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(p,j)=>{const I=String(j?.status??"").toLowerCase();return I==="approved"?e.jsx(r.Tag,{color:"green",children:"Approved"}):I==="declined"?e.jsx(r.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(r.Button,{type:"text",size:"small",onClick:()=>S(j,"approved"),icon:e.jsx(re.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(r.Button,{type:"text",size:"small",onClick:()=>S(j,"declined"),icon:e.jsx(re.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(r.Table,{bordered:!0,size:"small",loading:s,rowKey:(p,j)=>String(p?.id??p?.leave_id??j),columns:g,dataSource:u,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(p,j)=>a({page:p,rowsPerPage:j}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const zc=({token:t})=>e.jsx(qc,{token:t}),Vc=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Yc=({token:t,value:n,onChange:a})=>{const s=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(r.Upload,{maxCount:1,action:oi(),headers:s,onChange:o=>{if(o?.file?.status==="done"){const l=Vc(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},di=Ce.leave,Wc=Ce.master.leaveType.dropdown,Hc=({token:t,page:n=1,perPage:a=10})=>zt({token:t,baseUrl:di.table,page:n,perPage:a}),Kc=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Pa={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Gc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(""),[u]=r.Form.useForm(),{isLoading:S,error:g,data:p,mutate:j}=Hc({token:t,page:n.page,perPage:n.rowsPerPage}),{data:I}=K(t?[Wc,t]:null,([A,h])=>G(A,h)),T=i.useMemo(()=>Kc(I),[I]),m=(A,h)=>a({page:A,rowsPerPage:parseInt(h,10)}),c=()=>{d(""),u.resetFields(),u.setFieldsValue({apply_date:ye()}),o(!0)},y=()=>{o(!1),d(""),u.resetFields()},O=async A=>{const h=new FormData;h.set("apply_date",A?.apply_date?A.apply_date.format("YYYY-MM-DD"):""),h.set("leave_type",A?.leave_type?.value??A?.leave_type??""),h.set("from_date",A?.from_date?A.from_date.format("YYYY-MM-DD"):""),h.set("to_date",A?.to_date?A.to_date.format("YYYY-MM-DD"):""),h.set("reason",A?.reason??""),l&&h.set("file",l);try{await yt(di.apply,h,t),v.success("Success! Leave request submitted.",{duration:1e3}),y(),await j()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to submit leave request.",{duration:1e3})}},D=i.useMemo(()=>{const A=p?.data??p??[];return Array.isArray(A)?A:Array.isArray(A?.data)?A.data:[]},[p]),_=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(A,h)=>h?.leavetype??h?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(A,h)=>h?.date??h?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(A,h)=>h?.leave_from??h?.from_date??""},{title:"To",key:"leave_to",width:130,render:(A,h)=>h?.leave_to??h?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(A,h)=>h?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:s,title:"Add Leave Request",onCancel:y,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:u,layout:"vertical",onFinish:O,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"apply_date",rules:[{required:!0,message:"Select date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(r.DatePicker,{style:Pa})]})}),e.jsx(r.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(te,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsx(r.Form.Item,{name:"from_date",rules:[{required:!0,message:"Select from date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From"}),e.jsx(r.DatePicker,{style:Pa})]})}),e.jsx(r.Form.Item,{name:"to_date",rules:[{required:!0,message:"Select to date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To"}),e.jsx(r.DatePicker,{style:Pa})]})}),e.jsx(r.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(X,{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(Yc,{token:t,value:l,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(r.Button,{onClick:y,children:"Cancel"}),e.jsx(pe,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(pe,{type:"button",value:"Add Leave Request",onClick:c})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(r.Table,{bordered:!0,size:"small",loading:S,rowKey:(A,h)=>String(A?.id??A?.leave_id??h),columns:_,dataSource:D,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(A,h)=>m(A,h),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Jc=({token:t})=>e.jsx(Gc,{token:t}),Wn=Ce.master.leaveType,Qc=({token:t,page:n=1,perPage:a=10})=>zt({token:t,baseUrl:Wn.table,page:n,perPage:a});function Xc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[u,S]=i.useState(null),{isLoading:g,error:p,data:j,mutate:I}=Qc({token:t,page:n.page,perPage:n.rowsPerPage}),T=(A,h)=>{a({page:A,rowsPerPage:parseInt(h,10)})},m=async A=>{const h=new FormData;h.set("title",A?.title??"");try{await I(yt(Wn.add,h,t),Ze(h)),v.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add leave type.",{duration:1e3})}},c=A=>{S(A??null),o.setFieldsValue({title:A?.leave_type_name??A?.name??""}),d(!0)},y=()=>{d(!1),S(null),o.resetFields()},O=async A=>{const h=u?.id??u?.leave_type_id;if(!h){v.error("Missing leave type id.",{duration:1e3});return}const f=new FormData;f.set("id",String(h)),f.set("title",A?.title??"");try{await wt(Wn.edit,f,t),await I(),v.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),y()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to update leave type.",{duration:1e3})}},D=async A=>{const h=A?.id??A?.leave_type_id;if(h)try{await I(Sn(Wn.remove,h,t),Ke(h)),v.success("Success! Deleted leave type.",{duration:1e3})}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete leave type.",{duration:1e3})}},_=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(A,h)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>c(h)}),e.jsx(r.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>D(h),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Leave Type",onCancel:y,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:O,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(X,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:y,children:"Cancel"}),e.jsx(pe,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(r.Form,{form:s,layout:"vertical",onFinish:m,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(X,{type:"text",label:"Name"})}),e.jsx(pe,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Me,{parentCallback:T,data:{newData:j,columns:_,columnstype:"antd",action:!1,Loading:g,error:p}})})]})}const Zc=({token:t})=>e.jsx(Xc,{token:t}),Hn=Ce.master.department,eu=({token:t,page:n=1,perPage:a=10})=>zt({token:t,baseUrl:Hn.table,page:n,perPage:a});function tu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[u,S]=i.useState(null),{isLoading:g,error:p,data:j,mutate:I}=eu({token:t,page:n.page,perPage:n.rowsPerPage}),T=(A,h)=>{a({page:A,rowsPerPage:parseInt(h,10)})},m=async A=>{const h=new FormData;h.set("title",A?.title??"");try{await I(yt(Hn.add,h,t),Ze(h)),v.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add department.",{duration:1e3})}},c=A=>{S(A??null),o.setFieldsValue({title:A?.department_name??A?.name??""}),d(!0)},y=()=>{d(!1),S(null),o.resetFields()},O=async A=>{const h=u?.id??u?.department_id;if(!h){v.error("Missing department id.",{duration:1e3});return}const f=new FormData;f.set("id",String(h)),f.set("title",A?.title??"");try{await wt(Hn.edit,f,t),await I(),v.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),y()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to update department.",{duration:1e3})}},D=async A=>{const h=A?.id??A?.department_id;if(h)try{await I(Sn(Hn.remove,h,t),Ke(h)),v.success("Success! Deleted department.",{duration:1e3})}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete department.",{duration:1e3})}},_=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(A,h)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>c(h)}),e.jsx(r.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>D(h),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Department",onCancel:y,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:O,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(X,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:y,children:"Cancel"}),e.jsx(pe,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(r.Form,{form:s,layout:"vertical",onFinish:m,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(X,{type:"text",label:"Name"})}),e.jsx(pe,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Me,{parentCallback:T,data:{newData:j,columns:_,columnstype:"antd",action:!1,Loading:g,error:p}})})]})}const nu=({token:t})=>e.jsx(tu,{token:t}),Kn=Ce.master.designation,au=({token:t,page:n=1,perPage:a=10})=>zt({token:t,baseUrl:Kn.table,page:n,perPage:a});function ru({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[u,S]=i.useState(null),{isLoading:g,error:p,data:j,mutate:I}=au({token:t,page:n.page,perPage:n.rowsPerPage}),T=(A,h)=>{a({page:A,rowsPerPage:parseInt(h,10)})},m=async A=>{const h=new FormData;h.set("title",A?.title??"");try{await I(yt(Kn.add,h,t),Ze(h)),v.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add designation.",{duration:1e3})}},c=A=>{S(A??null),o.setFieldsValue({title:A?.designation??""}),d(!0)},y=()=>{d(!1),S(null),o.resetFields()},O=async A=>{const h=u?.id??u?.designation_id;if(!h){v.error("Missing designation id.",{duration:1e3});return}const f=new FormData;f.set("id",String(h)),f.set("title",A?.title??"");try{await wt(Kn.edit,f,t),await I(),v.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),y()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to update designation.",{duration:1e3})}},D=async A=>{const h=A?.id??A?.designation_id;if(h)try{await I(Sn(Kn.remove,h,t),Ke(h)),v.success("Success! Deleted designation.",{duration:1e3})}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete designation.",{duration:1e3})}},_=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(A,h)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>c(h)}),e.jsx(r.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>D(h),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Designation",onCancel:y,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:O,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(X,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:y,children:"Cancel"}),e.jsx(pe,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(r.Form,{form:s,layout:"vertical",onFinish:m,children:[e.jsx(r.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(X,{type:"text",label:"Name"})}),e.jsx(pe,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Me,{parentCallback:T,data:{newData:j,columns:_,columnstype:"antd",action:!1,Loading:g,error:p}})})]})}const su=({token:t})=>e.jsx(ru,{token:t}),Gn=Ce.master.shift,iu=({token:t,page:n=1,perPage:a=10})=>zt({token:t,baseUrl:Gn.table,page:n,perPage:a}),Je="hh:mm A",kt=t=>{const n=String(t??"");if(!n)return null;const a=ye(n,[Je,"HH:mm","HH:mm:ss"],!0);return a.isValid()?a:null},Mt=t=>t?t.format(Je):"",st={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function ou({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState(!1),[u,S]=i.useState(null),{isLoading:g,error:p,data:j,mutate:I}=iu({token:t,page:n.page,perPage:n.rowsPerPage}),T=(f,x)=>{a({page:f,rowsPerPage:parseInt(x,10)})},m=(f,x)=>{const C=new FormData;return x&&C.set("id",String(x)),C.set("name",f?.name??""),C.set("start_time",Mt(f?.start_time)),C.set("end_time",Mt(f?.end_time)),C.set("shift_start_from",Mt(f?.shift_start_from)),C.set("shift_start_to",Mt(f?.shift_start_to)),C.set("shift_end_from",Mt(f?.shift_end_from)),C.set("shift_end_to",Mt(f?.shift_end_to)),C},c=async f=>{try{const x=m(f);await I(yt(Gn.add,x,t),Ze(x)),v.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),s.resetFields()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to add shift.",{duration:1e3})}},y=f=>{S(f??null),o.setFieldsValue({name:f?.shift_name??f?.name??"",start_time:kt(f?.start_time),end_time:kt(f?.end_time),shift_start_from:kt(f?.shift_start_from),shift_start_to:kt(f?.shift_start_to),shift_end_from:kt(f?.shift_end_from),shift_end_to:kt(f?.shift_end_to)}),d(!0)},O=()=>{d(!1),S(null),o.resetFields()},D=async f=>{const x=u?.id??u?.shift_id;if(!x){v.error("Missing shift id.",{duration:1e3});return}try{const C=m(f,x);await wt(Gn.edit,C,t),await I(),v.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),O()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to update shift.",{duration:1e3})}},_=async f=>{const x=f?.id??f?.shift_id;if(x)try{await I(Sn(Gn.remove,x,t),Ke(x)),v.success("Success! Deleted shift.",{duration:1e3})}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to delete shift.",{duration:1e3})}},A=i.useMemo(()=>[{title:"Name",dataIndex:"shift_name",key:"shift_name",ellipsis:!0,fixed:"left",width:160},{title:"Start Time",dataIndex:"start_time",key:"start_time",width:120},{title:"End Time",dataIndex:"end_time",key:"end_time",width:120},{title:"Start From",dataIndex:"shift_start_from",key:"shift_start_from",width:120,responsive:["md"]},{title:"Start To",dataIndex:"shift_start_to",key:"shift_start_to",width:120,responsive:["md"]},{title:"End From",dataIndex:"shift_end_from",key:"shift_end_from",width:120,responsive:["md"]},{title:"End To",dataIndex:"shift_end_to",key:"shift_end_to",width:120,responsive:["md"]},{title:"Action",key:"action",width:110,fixed:"right",render:(f,x)=>e.jsxs(r.Space,{size:6,children:[e.jsx(r.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>y(x)}),e.jsx(r.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>_(x),children:e.jsx(r.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]),h=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{open:l,title:"Edit Shift",onCancel:O,footer:null,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(X,{type:"text",label:"Name"})}),e.jsx(r.Form.Item,{name:"start_time",label:"Start Time",rules:h,children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"end_time",label:"End Time",rules:h,children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(r.Button,{onClick:O,children:"Cancel"}),e.jsx(pe,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(r.Form,{form:s,layout:"vertical",onFinish:c,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(X,{type:"text",label:"Name"})}),e.jsx(r.Form.Item,{name:"start_time",label:"Start Time",rules:h,children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"end_time",label:"End Time",rules:h,children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(r.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(r.TimePicker,{format:Je,use12Hours:!0,style:st})}),e.jsx(pe,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Me,{parentCallback:T,data:{newData:j,columns:A,columnstype:"antd",action:!1,Loading:g,error:p}})})]})}const lu=({token:t})=>e.jsx(ou,{token:t}),ss=Ce.attendance;function du({data:t}){return t?e.jsx("div",{style:{margin:15,fontSize:13,padding:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{}),(t?.shifts??[]).map((n,a)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:n?.shift_name??""},`${a}heading1`))]}),e.jsxs("tr",{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Sl.No"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Teacher's Name"}),(t?.shifts??[]).map((n,a)=>e.jsxs(i.Fragment,{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"In Time"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Out Time"})]},`${a}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((n,a)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${n?.name??""} ${n?.surname??""}`.trim()})}),(t?.shifts??[]).map((s,o)=>e.jsxs(i.Fragment,{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:n?.attendance_data?(n.attendance_data?.[s?.office_shift_id]?.checkintime??"").toUpperCase():""})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:n?.attendance_data?(n.attendance_data?.[s?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${a}`))]},`${a}row`))})]})}):null}const cu=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},uu=t=>{const n=String(t??"").toLowerCase();return n==="present"?e.jsx(r.Tag,{color:"green",children:"Present"}):n==="absent"?e.jsx(r.Tag,{color:"red",children:"Absent"}):n==="leave"?e.jsx(r.Tag,{color:"orange",children:"Leave"}):e.jsx(r.Tag,{children:t??""})};function pu({token:t}){const[n,a]=i.useState(ye()),[s,o]=i.useState(!1),[l,d]=i.useState(0),u=i.useMemo(()=>`${s?ss.dailyAttendanceMultipleShift:ss.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,s,l]),{isLoading:S,error:g,data:p}=K(t?[u,t]:null,([c,y])=>G(c,y)),j=i.useMemo(()=>cu(p),[p]),I=i.useMemo(()=>s?p?.data?.data??p?.data??p??null:null,[p,s]),T=cn.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),m=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(c,y,O)=>O+1},{title:"Name",key:"name",render:(c,y)=>`${y?.name??""} ${y?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(c,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[uu(y?.attendance),y?.late_time?e.jsx(r.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(c,y)=>y?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(c,y)=>y?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(c,y)=>y?.late_time?e.jsx(r.Tag,{color:"red",children:y.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Staff Daily Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(r.DatePicker,{value:n,onChange:c=>c&&a(c),style:{width:"100%"},allowClear:!1})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Multiple Shift"}),e.jsx(r.Switch,{checked:s,onChange:o})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"button",value:"Search",onClick:()=>d(c=>c+1)})})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(re.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:T}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(hn,{})}),s?e.jsx(du,{data:I}):e.jsx(r.Table,{bordered:!0,size:"small",loading:S,rowKey:(c,y)=>String(c?.id??c?.staff_id??y),columns:m,dataSource:j,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const mu=({token:t})=>e.jsx(pu,{token:t}),is=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},fu=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 yu({token:t,staffId:n}){const[a,s]=i.useState(!1),[o,l]=i.useState(null),[d,u]=i.useState({value:"Cash",label:"Cash"}),[S,g]=i.useState(""),[p,j]=i.useState(""),I=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),T=P=>{const k=Number(P??0),U=Number.isFinite(k)?k.toLocaleString("en-IN"):"0";return`${I?`${I} `:""}${U}`},m=i.useMemo(()=>n?`${Ce.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),c=i.useMemo(()=>n?`${Ce.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:y}=K(t&&m?[m,t]:null,([P,k])=>G(P,k)),{data:O,isLoading:D,mutate:_}=K(t&&c?[c,t]:null,([P,k])=>G(P,k)),A=i.useMemo(()=>is(y)[0]??y?.data??y??null,[y]),h=i.useMemo(()=>is(O),[O]),f=i.useMemo(()=>[{title:"Month",dataIndex:"month",key:"month",width:120,align:"center"},{title:"Basic Salary",dataIndex:"basic_salary",key:"basic_salary",width:140,align:"center",render:(P,k)=>e.jsx("div",{style:{fontSize:11},children:mt(k?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(P,k)=>e.jsx("div",{style:{fontSize:11},children:mt(k?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(P,k)=>e.jsx("div",{style:{fontSize:11},children:mt(k?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(P,k)=>e.jsx("div",{style:{fontSize:11},children:mt(k?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(P,k)=>e.jsx("div",{style:{cursor:k?.status==="due"?"pointer":"default"},onClick:()=>{k?.status==="due"&&(l(k),s(!0))},children:ei(k?.status)})}],[]),x=i.useMemo(()=>[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"DD",label:"DD"},{value:"Bank",label:"Bank"},{value:"Internet Banking",label:"Internet Banking"},{value:"Cheque",label:"Cheque"}],[]),C=async()=>{if(!o)return;const P={...o,staff_id:n,payment_type:d?.value??"",notes:S,attchement:p};try{await Ye(Ce.payroll.generatePayslip,{arg:P},t),v.success("Success!",{duration:1e3}),s(!1),l(null),g(""),j(""),await _()}catch(k){v.error(k?.response?.data?.msg??k?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("div",{style:{fontSize:13,color:"#444"},children:A?`${A?.f_name??A?.firstname??""} ${A?.l_name??A?.lastname??""}`.trim():""}),e.jsx(r.Table,{bordered:!0,size:"small",loading:D,rowKey:(P,k)=>String(P?.id??`${P?.month}-${k}`),columns:f,dataSource:h,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(r.Modal,{open:a,onCancel:()=>{s(!1),l(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{label:"Pay",options:x,value:d,onChange:P=>u(P??x[0]),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Note"}),e.jsx(r.Input.TextArea,{rows:4,placeholder:"Note",value:S,onChange:P=>g(P.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(r.Upload,{maxCount:1,action:oi(),headers:t?{Authorization:t}:void 0,onChange:P=>{if(P?.file?.status==="done"){const k=fu(P?.file?.response);k&&j(k)}P?.file?.status==="removed"&&j("")},children:e.jsx(r.Button,{icon:e.jsx(re.UploadOutlined,{}),children:"Upload"})}),!!p&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:p})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(r.Button,{onClick:()=>s(!1),children:"Cancel"}),e.jsx(pe,{type:"button",value:o?.Total_Payable_Amount?`Pay ${T(o.Total_Payable_Amount)}`:"Pay",onClick:C})]})]})})]})}function hu({token:t,staffId:n}){const a=i.useMemo(()=>{if(n!=null&&String(n).trim()!=="")return n;if(typeof window>"u")return null;const s=new URLSearchParams(window.location.search).get("id");return s||null},[n]);return a?e.jsx(yu,{token:t,staffId:a}):e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsx("div",{style:{fontSize:13,color:"#666"},children:"Missing staff id."})})}function gu(){return null}const da=t=>t??localStorage.getItem("authToken")??"",xu=(t,n)=>{const a=String(t??""),s=String(n);return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s},ci=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",we={uploadNotes:"api/branchapi/Academy/uploadNotes",master:{classes:{dropdown:"api/branchapi/academy/classdropdownlist",table:"api/branchapi/academy/classestableList",add:"api/branchapi/academy/addclasses",edit:"api/branchapi/academy/editclass",remove:"api/branchapi/academy/deleteclass",show:"api/branchapi/academy/classShowdata"},sections:{list:"api/branchapi/academy/sectionlist",table:"api/branchapi/academy/sectiontableList",add:"api/branchapi/academy/addsections",edit:"api/branchapi/academy/editsection",remove:"api/branchapi/academy/deletesection",show:"api/branchapi/academy/sectionShowdata",byClass:"api/branchapi/academy/sectionoftheClass"},subjects:{dropdown:"api/branchapi/Academy/getClassSubjectdropdown",byClassLabelValue:"api/branchapi/Academy/getSubjectsbyClassaslablevalue",table:"api/branchapi/academy/subjecttableList",add:"api/branchapi/academy/addsubjects",edit:"api/branchapi/academy/editsubject",remove:"api/branchapi/academy/deletesubject",show:"api/branchapi/academy/subjectShowdata"},holidays:{table:"api/branchapi/academy/holidayList",add:"api/branchapi/academy/addholidays",edit:"api/branchapi/academy/editholidays",remove:"api/branchapi/academy/deleteholiday",show:"api/branchapi/academy/getByIdholidays"}},assignSubjects:{assign:"api/branchapi/Academy/assign_class_subjects",list:"api/branchapi/academy/getSubjectsbyClass",update:"api/branchapi/academy/updateAssignSubject",editByClass:"api/branchapi/academy/editSubjectsbyClass"},assignByClass:{teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classWithSection:"api/branchapi/academy/getClasswithSection",assignedSubjectsOfTeacher:"api/branchapi/academy/getassignedSubjectsofTeacher",subjectsOfTeacherByTeacherId:"api/branchapi/academy/getSubjectsofTeacherbyTeacherID",assignClassToTeacher:"api/branchapi/academy/assignClasstoTeacher",deleteTeacherSub:"api/branchapi/academy/deleteTeacherSub"},promoteStudents:{searchByClassSection:"api/branchapi/student/currentSessionStudentlist",sessionDropdown:"api/branchapi/generalSettings/sessiondropdown",promote:"api/branchapi/student/promotestudent"},timeGroup:{table:"api/branchapi/academy/getTimeGroupTable",add:"api/branchapi/academy/addTimeGroup",edit:"api/branchapi/academy/editTimeGroup",remove:"api/branchapi/academy/deleteTimeGroup",show:"api/branchapi/academy/getTimeGroupDataById",dropdown:"api/branchapi/academy/getTimeGroupDropDown"},assignTimeGroup:{classIdByTimeGroup:"api/branchapi/academy/getClassIdByTimeGroup",table:"api/branchapi/academy/getAssignedTimeGroupTable",show:"api/branchapi/academy/getAssignedTimeGroupDataById",assign:"api/branchapi/academy/assignTimeGroup"},timetable:{save:"api/timetable/save",byClassSection:"api/timetable/class",teacherTimetable:"api/timetable/teacher/",teachersBySubject:"api/branchapi/Academy/gettechersSubject"},notes:{table:"api/branchapi/Academy/getNotesTable",add:"api/branchapi/Academy/addNotes"},syllabus:{table:"api/branchapi/Academy/getsyllabusTable",add:"api/branchapi/Academy/addsyllabus",edit:"api/branchapi/Academy/editsyllabus"},transferCertificate:{studentList:"api/branchapi/student/getstudenttransferCertificateList",addData:"api/branchapi/academy/addtransferCertificatedata",view:"api/branchapi/academy/gettransferCertificateUrl"},coscholastic:{table:"api/branchapi/academy/getcoscholastic",addSkill:"api/branchapi/academy/add_coscholastic_skill",deleteSkill:"api/branchapi/academy/deleteCoscholastic",categoryDropdown:"api/branchapi/academy/coscholastic_categorydropdown",addCategory:"api/branchapi/academy/addcoscholastic_category",deleteCategory:"api/branchapi/academy/coscholasticCategoryDelete"}},bu=()=>xu(it(),we.uploadNotes),Su=async({baseUrl:t,page:n=1,perPage:a=10},s)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return G(l,da(s))},dt=async(t,n,a,{includeSession:s=!1}={})=>{const o=n instanceof FormData?n:new FormData;return s&&!o.has("session_id")&&o.append("session_id",ci()),Ye(t,o,da(a))},St=async(t,n,a,{includeSession:s=!1}={})=>{const o=n instanceof FormData?n:new FormData;return s&&!o.has("session_id")&&o.append("session_id",ci()),ut(t,o,da(a))},jt=async(t,n,a)=>tt(t,n,da(a)),Jn=we.master.sections,jn=({baseUrl:t,page:n=1,perPage:a=10,token:s})=>K(s&&t?[t,n,a,s]:null,([l,d,u,S])=>Su({baseUrl:l,page:d,perPage:u},S)),ju=({token:t,page:n=1,perPage:a=10})=>jn({token:t,baseUrl:Jn.table,page:n,perPage:a}),wu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function vu({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),{data:S,isLoading:g,mutate:p}=ju({token:t,page:n.page,perPage:n.perPage}),j=i.useMemo(()=>wu(S),[S]),I=i.useMemo(()=>S?.pagination?.total_rows??S?.pagination?.total??j.length??0,[S,j]),T=async D=>{D.preventDefault();const _=new FormData(D.target);try{await dt(Jn.add,_,t),v.success("Success! Added new item.",{duration:1e3}),D.target.reset(),p()}catch(A){v.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},m=async D=>{try{await jt(Jn.remove,D,t),v.success("Success! Deleted item.",{duration:1e3}),p()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to delete the item.",{duration:1500})}},c=D=>{d(D),o(!0),u.setFieldsValue({section:D?.section??""})},y=async D=>{const _=new FormData;_.append("id",String(l?.id??"")),_.append("section",D.section??"");try{await St(Jn.edit,_,t),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(A){v.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},O=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(D,_)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>c(_)}),e.jsx(r.Popconfirm,{title:"Delete this section?",onConfirm:()=>m(_?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[u]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Section",open:s,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(r.Form,{form:u,layout:"vertical",onFinish:y,children:[e.jsx(r.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(r.Input,{placeholder:"Section Name"})}),e.jsxs(r.Space,{children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),children:e.jsx("form",{onSubmit:T,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(pe,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(r.Space,{}),children:e.jsx(r.Table,{rowKey:D=>D.id,columns:O,dataSource:j,loading:g,pagination:{current:n.page,pageSize:n.perPage,total:I,showSizeChanger:!0,onChange:(D,_)=>a({page:D,perPage:_})}})})]})}function _u({token:t}){return e.jsx(vu,{token:t})}const rn=we.master.classes,Cu=({token:t,page:n=1,perPage:a=10})=>jn({token:t,baseUrl:rn.table,page:n,perPage:a}),Tu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Au=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function Iu({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),[S]=r.Form.useForm(),{data:g}=K(t?[we.master.sections.list,t]:null,([C,P])=>G(C,P)),p=i.useMemo(()=>Au(g),[g]),j=i.useMemo(()=>p.map(C=>({label:C.label??C.section??String(C.value??""),value:String(C.value??C.id??"")})),[p]),{data:I,isLoading:T,mutate:m}=Cu({token:t,page:n.page,perPage:n.perPage}),c=i.useMemo(()=>Tu(I),[I]),y=i.useMemo(()=>I?.pagination?.total_rows??I?.pagination?.total??c.length??0,[I,c]),{data:O}=K(t&&l?[`${rn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([C,P])=>G(C,P)),D=i.useMemo(()=>{const C=O?.data??O;return Array.isArray(C)?C:Array.isArray(C?.data)?C.data:C?[C]:[]},[O]),_=C=>{const P=C?.id??C?.class_id;P&&(d(P),o(!0))};i.useEffect(()=>{if(!s||!D.length)return;const C=D[0],P=D.map(b=>b?.section_id??b?.fk_sectionId??b?.sectionId??b?.section).filter(b=>b!=null&&String(b).trim()!=="").map(b=>String(b)),k=Array.isArray(C?.section_ids)?C.section_ids.map(b=>String(b)):typeof C?.section_ids=="string"?C.section_ids.split(",").map(b=>b.trim()).filter(Boolean):Array.isArray(C?.section)?C.section.map(b=>String(b)):[],U=P.length?P:k;S.setFieldsValue({name:C?.class??C?.name??"",section:U})},[s,D,S]);const A=async C=>{const P=new FormData;P.append("name",C.name??""),(C.section??[]).forEach(k=>P.append("section[]",String(k)));try{await dt(rn.add,P,t),v.success("Success! Added new item.",{duration:1e3}),u.resetFields(),m()}catch(k){v.error(k?.response?.data?.msg??k?.message??"Failed to add the new item.",{duration:1500})}},h=async C=>{const P=new FormData;P.append("id",String(l??"")),P.append("name",C.name??""),(C.section??[]).forEach(k=>P.append("section[]",String(k)));try{await St(rn.edit,P,t),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),m()}catch(k){v.error(k?.response?.data?.msg??k?.message??"Failed to update the item.",{duration:1500})}},f=async C=>{try{await jt(rn.remove,C,t),v.success("Success! Deleted item.",{duration:1e3}),m()}catch(P){v.error(P?.response?.data?.msg??P?.message??"Failed to delete the item.",{duration:1500})}},x=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(C,P)=>C??P?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:C=>C??""},{title:"Actions",key:"actions",width:120,render:(C,P)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>_(P)}),e.jsx(r.Popconfirm,{title:"Delete this class?",onConfirm:()=>f(P?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Class",open:s,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(r.Form,{form:S,layout:"vertical",onFinish:h,children:[e.jsx(r.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(r.Input,{placeholder:"Class"})}),e.jsx(r.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(r.Checkbox.Group,{options:j})}),e.jsxs(r.Space,{children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(r.Form,{form:u,layout:"vertical",onFinish:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(r.Input,{placeholder:"Class"})}),e.jsx(r.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(r.Checkbox.Group,{options:j})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(r.Table,{rowKey:C=>C.id,columns:x,dataSource:c,loading:T,pagination:{current:n.page,pageSize:n.perPage,total:y,showSizeChanger:!0,onChange:(C,P)=>a({page:C,perPage:P})}})})]})}function Ru({token:t}){return e.jsx(Iu,{token:t})}function Dt({onAdd:t,onExport:n,onPrint:a,onDownload:s,onFilter:o,actions:l}){const d=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(re.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(re.FileExcelOutlined,{}),onClick:n},{key:"print",title:"Print",icon:e.jsx(re.PrinterOutlined,{}),onClick:a},{key:"download",title:"Download",icon:e.jsx(re.DownloadOutlined,{}),onClick:s},{key:"filter",title:"Filter",icon:e.jsx(re.FilterOutlined,{}),onClick:o}],[t,n,a,s,o]),u=i.useMemo(()=>{const S=Array.isArray(l)&&l.length?new Set(l):null;return S?d.filter(g=>S.has(g.key)):d},[d,l]);return e.jsx(r.Space,{size:8,children:u.map(S=>e.jsx(r.Tooltip,{title:S.title,children:e.jsx(r.Button,{type:"text",icon:S.icon,onClick:S.onClick,disabled:!S.onClick})},S.key))})}const sn=we.master.subjects,Du=({token:t,page:n=1,perPage:a=10})=>jn({token:t,baseUrl:sn.table,page:n,perPage:a}),Ou=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},os=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],ls=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function Pu({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),[S]=r.Form.useForm(),{data:g,isLoading:p,mutate:j}=Du({token:t,page:n.page,perPage:n.perPage}),I=i.useMemo(()=>Ou(g),[g]),T=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??I.length??0,[g,I]),{data:m}=K(t&&l?[`${sn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([h,f])=>G(h,f)),c=i.useMemo(()=>{const h=m?.data??m;return Array.isArray(h)?h[0]:h??null},[m]);i.useEffect(()=>{s&&c&&S.setFieldsValue({name:c?.name??"",subject_type:c?.subject_type??c?.type??"",type:"",subject_types:Array.isArray(c?.subject_types)?c.subject_types:typeof c?.subject_types=="string"?c.subject_types.split(",").map(h=>h.trim()).filter(Boolean):[],code:c?.code??""})},[s,c,S]);const y=async h=>{const f=h?.type??h?.subject_type??"",x={name:h?.name??"",subject_type:f,type:f,subject_types:Array.isArray(h?.subject_types)?h.subject_types:[],code:h?.code??""};try{await Ye(sn.add,x,t),v.success("Success! Added new item.",{duration:1e3}),u.resetFields(),j()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},O=async h=>{const f=new FormData,x=h?.type??h?.subject_type??"";f.append("id",String(l??"")),f.append("name",h.name??""),f.append("subject_type",h.subject_type??""),f.append("subject_type",x),f.append("type",x),f.append("code",h.code??"");try{await St(sn.edit,f,t),v.success("Success! Updated item.",{duration:1e3}),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),j()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to update the item.",{duration:1500})}},D=async h=>{try{await jt(sn.remove,h,t),v.success("Success! Deleted item.",{duration:1e3}),j()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},_=h=>{const f=h?.id;f&&(d(f),o(!0))},A=i.useMemo(()=>[{title:"Subject Name",dataIndex:"name",key:"name"},{title:"Subject",dataIndex:"subject_type",key:"subject_type"},{title:"Subject Code",dataIndex:"code",key:"code"},{title:"Subject Type",key:"subject_types",render:(h,f)=>{const x=[],C=f?.subject_types;Array.isArray(C)?C.forEach(E=>{const B=String(E??"").trim();B&&x.push(B)}):typeof C=="string"&&C.split(",").map(E=>E.trim()).filter(Boolean).forEach(E=>x.push(E));const P=["yes","1","true"].includes(String(f?.is_practical??"").toLowerCase()),k=["yes","1","true"].includes(String(f?.is_theory??"").toLowerCase());P&&x.push("Practical"),k&&x.push("Theory");const U=x.map(E=>String(E??"").trim()).filter(Boolean).map(E=>E.toLowerCase()==="practical"?"Practical":E.toLowerCase()==="theory"?"Theory":E),b=Array.from(new Set(U));return b.length?b.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(h,f)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>_(f)}),e.jsx(r.Popconfirm,{title:"Delete this subject?",onConfirm:()=>D(f?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Subject",open:s,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(r.Form,{form:S,layout:"vertical",onFinish:O,children:[e.jsx(r.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(X,{placeholder:"Subject Name"})}),e.jsx(r.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(r.Radio.Group,{options:ls})}),e.jsx(r.Form.Item,{label:"Subject Type",name:"subject_types",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(r.Checkbox.Group,{options:os})}),e.jsx(r.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(X,{placeholder:"Subject Code"})}),e.jsxs(r.Space,{children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(r.Form,{form:u,layout:"vertical",onFinish:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(X,{placeholder:"Subject Name"})}),e.jsx(r.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(r.Radio.Group,{options:ls})}),e.jsx(r.Form.Item,{name:"subject_types",label:"Subject Type",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(r.Checkbox.Group,{options:os})}),e.jsx(r.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(X,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(r.Table,{rowKey:h=>h.id,columns:A,dataSource:I,loading:p,pagination:{current:n.page,pageSize:n.perPage,total:T,showSizeChanger:!0,onChange:(h,f)=>a({page:h,perPage:f})}})})]})}function Eu({token:t}){return e.jsx(Pu,{token:t})}const on=we.master.holidays,Fu=({token:t,page:n=1,perPage:a=10})=>jn({token:t,baseUrl:on.table,page:n,perPage:a}),ku=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Fn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Mu({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),[S]=r.Form.useForm(),{data:g,isLoading:p,mutate:j}=Fu({token:t,page:n.page,perPage:n.perPage}),I=i.useMemo(()=>ku(g),[g]),T=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??I.length??0,[g,I]),{data:m}=K(t&&l?[`${on.show}?id=${encodeURIComponent(String(l))}`,t]:null,([h,f])=>G(h,f)),c=i.useMemo(()=>{const h=m?.data??m;return Array.isArray(h)?h[0]:h??null},[m]);i.useEffect(()=>{s&&c&&S.setFieldsValue({title:c?.holiday_title??"",description:c?.holiday_description??"",from:c?.start_date?ye(c.start_date):null,to:c?.end_date?ye(c.end_date):null})},[s,c,S]);const y=async h=>{const f=new FormData;f.append("title",h.title??""),f.append("description",h.description??""),f.append("from",h.from?ye(h.from).format("YYYY-MM-DD"):""),f.append("to",h.to?ye(h.to).format("YYYY-MM-DD"):"");try{await dt(on.add,f,t,{includeSession:!0}),v.success("Success! Added new item.",{duration:1e3}),u.resetFields(),j()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to add the new item.",{duration:1500})}},O=async h=>{const f=new FormData;f.append("id",String(l??"")),f.append("title",h.title??""),f.append("description",h.description??""),f.append("from",h.from?ye(h.from).format("YYYY-MM-DD"):""),f.append("to",h.to?ye(h.to).format("YYYY-MM-DD"):"");try{await St(on.edit,f,t,{includeSession:!0}),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),j()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to update the item.",{duration:1500})}},D=async h=>{try{await jt(on.remove,h,t),v.success("Success! Deleted item.",{duration:1e3}),j()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},_=h=>{const f=h?.id;f&&(d(f),o(!0))},A=i.useMemo(()=>[{title:"Holiday Title",dataIndex:"holiday_title",key:"holiday_title"},{title:"Holiday Description",dataIndex:"holiday_description",key:"holiday_description"},{title:"Start From",dataIndex:"start_date",key:"start_date"},{title:"End At",dataIndex:"end_date",key:"end_date"},{title:"Actions",key:"actions",width:120,render:(h,f)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>_(f)}),e.jsx(r.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>D(f?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Holiday",open:s,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(r.Form,{form:S,layout:"vertical",onFinish:O,children:[e.jsx(r.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(X,{placeholder:"Holiday Title"})}),e.jsx(r.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(X,{placeholder:"Holiday Description"})}),e.jsx(r.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:Fn})}),e.jsx(r.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:Fn})}),e.jsxs(r.Space,{children:[e.jsx(pe,{type:"submit",value:"Update",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(r.Form,{form:u,layout:"vertical",onFinish:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(X,{placeholder:"Holiday Title"})}),e.jsx(r.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(dn,{placeholder:"Holiday Description"})}),e.jsx(r.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:Fn})}),e.jsx(r.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:Fn})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(r.Table,{rowKey:h=>h.id,columns:A,dataSource:I,loading:p,pagination:{current:n.page,pageSize:n.perPage,total:T,showSizeChanger:!0,onChange:(h,f)=>a({page:h,perPage:f})}})})]})}function $u({token:t}){return e.jsx(Mu,{token:t})}const Qn=we.assignSubjects,Uu=({token:t,page:n=1,perPage:a=50})=>jn({token:t,baseUrl:Qn.list,page:n,perPage:a}),ds=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Bu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Nu({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[s,o]=i.useState(null),[l,d]=i.useState([]),[u,S]=i.useState(!1),[g,p]=i.useState(!1),[j,I]=i.useState(null),[T,m]=i.useState([]),{data:c}=K(t?[we.master.classes.dropdown,t]:null,([B,q])=>G(B,q)),{data:y}=K(t?[we.master.subjects.dropdown,t]:null,([B,q])=>G(B,q)),O=i.useMemo(()=>ds(c),[c]),D=i.useMemo(()=>ds(y),[y]),_=i.useMemo(()=>D.map(B=>({label:B.label??B.subject??String(B.value??""),value:B.value??B.id})),[D]),{data:A,isLoading:h,mutate:f}=Uu({token:t,page:n.page,perPage:n.perPage}),x=i.useMemo(()=>Bu(A),[A]),C=i.useMemo(()=>A?.pagination?.total_rows??A?.pagination?.total??x.length??0,[A,x]),{data:P}=K(t&&j?[`${Qn.editByClass}?class_id=${encodeURIComponent(String(j))}`,t]:null,([B,q])=>G(B,q));i.useEffect(()=>{if(!g)return;const B=P?.data??P,q=Array.isArray(B)?B:Array.isArray(B?.data)?B.data:[];m(q.map($=>$.subject_id).filter(Boolean))},[g,P]);const k=async B=>{if(B.preventDefault(),!s?.value){v.error("Please select class",{duration:1200});return}if(!l.length){v.error("Please select subjects",{duration:1200});return}const q=new FormData;q.append("class_id",String(s.value)),l.forEach($=>q.append("subject[]",String($)));try{S(!0),await St(Qn.assign,q,t),v.success("Success! Updated item.",{duration:1e3}),o(null),d([]),f()}catch($){v.error($?.response?.data?.msg??$?.message??"Failed to update the item.",{duration:1500})}finally{S(!1)}},U=B=>{B&&(I(B),p(!0))},b=async()=>{if(!j)return;if(!T.length){v.error("Please select subjects",{duration:1200});return}const B=new FormData;B.append("class_id",String(j)),T.forEach(q=>B.append("subject[]",String(q)));try{await St(Qn.update,B,t),v.success("Success! Updated item.",{duration:1e3}),p(!1),I(null),f()}catch(q){v.error(q?.response?.data?.msg??q?.message??"Failed to update the item.",{duration:1500})}},E=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(B,q)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(q?.subject_name??B??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(B,q)=>e.jsx(r.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>U(q?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Assigned Subjects",open:g,onClose:()=>{p(!1),I(null)},width:520,extra:e.jsxs(r.Space,{children:[e.jsx(r.Button,{onClick:()=>p(!1),children:"Cancel"}),e.jsx(r.Button,{type:"primary",onClick:b,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:O.find(B=>String(B.value)===String(j))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(r.Checkbox.Group,{options:_,value:T,onChange:m})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:k,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:s,onChange:B=>o(B??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(r.Checkbox.Group,{options:_,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:u?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(r.Table,{rowKey:B=>B.id,columns:E,dataSource:x,loading:h,pagination:{current:n.page,pageSize:n.perPage,total:C,showSizeChanger:!0,onChange:(B,q)=>a({page:B,perPage:q})}})})]})}function Lu({token:t}){return e.jsx(Nu,{token:t})}const $t=we.assignByClass,ui=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(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[]},Zt=t=>ui(t),qu=t=>ui(t),en=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function zu({token:t}){const[n,a]=i.useState(null),[s,o]=i.useState(null),[l,d]=i.useState(null),[u,S]=i.useState("No"),[g,p]=i.useState([]),[j,I]=i.useState([]),[T,m]=i.useState(null),[c,y]=i.useState(null),[O,D]=i.useState(!1),[_,A]=i.useState(""),{data:h}=K(t?[$t.teacherDropdown,t]:null,([ae,ce])=>G(ae,ce)),{data:f}=K(t?[we.master.classes.dropdown,t]:null,([ae,ce])=>G(ae,ce)),{data:x}=K(t&&c?[c,t]:null,([ae,ce])=>G(ae,ce)),{data:C}=K(t&&T?[T,t]:null,([ae,ce])=>G(ae,ce)),P=i.useMemo(()=>Zt(h),[h]),k=i.useMemo(()=>Zt(f),[f]),U=i.useMemo(()=>Zt(x),[x]),b=i.useMemo(()=>Zt(C),[C]),{data:E}=K(t&&n&&s&&l?[`${$t.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(n))}&class_id=${encodeURIComponent(String(s))}§ion_id=${encodeURIComponent(String(l))}`,t]:null,([ae,ce])=>G(ae,ce)),B=E?.data??E??null;i.useEffect(()=>{B&&(p(Array.isArray(B?.subject_ids)?B.subject_ids:[]),S(B?.isClassTeacher||"No"),I([]))},[B]);const{data:q}=K(t?[$t.classWithSection,t]:null,([ae,ce])=>G(ae,ce)),$=i.useMemo(()=>Zt(q),[q]),[N,H]=i.useState(null),[V,R]=i.useState({page:1,perPage:25});i.useEffect(()=>{N||$?.[0]&&H(`${$[0].class_id}val${$[0].section_id}`)},[$,N]);const w=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),M=i.useMemo(()=>{if(!N)return null;const[ae,ce]=String(N).split("val");if(!ae||!ce)return null;const _e=V.page??1,$e=V.perPage??25;return`${$t.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(_e))}&per_page=${encodeURIComponent(String($e))}&session_id=${encodeURIComponent(String(w))}&class_id=${encodeURIComponent(String(ae))}§ion_id=${encodeURIComponent(String(ce))}`},[N,V.page,V.perPage,w]),{data:F,isLoading:L,mutate:ee}=K(t&&M?[M,t]:null,([ae,ce])=>G(ae,ce),{revalidateOnFocus:!1}),Y=i.useMemo(()=>qu(F),[F]),J=i.useMemo(()=>{const ae=F?.pagination??F?.data?.pagination??F?.data?.data?.pagination;return ae?.total_rows??ae?.total??Y.length??0},[F,Y]),W=async ae=>{if(ae.preventDefault(),A(""),!n||!s||!l){v.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(g)||g.length===0){A("error"),v.error("Please Select Subject",{duration:1200});return}const ce=new FormData;ce.append("teacher_id",String(n)),ce.append("class_id",String(s)),ce.append("section_id",String(l)),ce.append("isClassTeacher",String(u??"No")),en(g).forEach(_e=>ce.append("subject_ids[]",String(_e))),en(j).forEach(_e=>ce.append("delete_subject[]",String(_e)));try{await dt($t.assignClassToTeacher,ce,t,{includeSession:!0}),v.success("Success! Added new item.",{duration:1e3}),A(""),ee()}catch(_e){v.error(_e?.response?.data?.msg??_e?.message??"Failed to add the new item.",{duration:1500})}},Z=async ae=>{try{await jt($t.deleteTeacherSub,ae,t),v.success("Success! Deleted item.",{duration:1e3}),ee()}catch(ce){v.error(ce?.response?.data?.msg??ce?.message??"Failed to delete the item.",{duration:1500})}},se=ae=>{const ce=Array.isArray(ae?.child)?ae.child:[],_e=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:($e,qe)=>e.jsx(r.Popconfirm,{title:"Delete this subject?",onConfirm:()=>Z(qe?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(r.Table,{columns:_e,bordered:!0,size:"small",dataSource:ce,pagination:!1,rowKey:$e=>$e.id})})},je=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(ae,ce)=>e.jsxs("div",{children:[ce.teacher_name,ce.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],ne=i.useMemo(()=>($??[]).map(ae=>({label:ae.label??`${ae.class_name??""} ${ae.section_name??""}`.trim(),key:`${ae.class_id}val${ae.section_id}`,children:e.jsx(r.Table,{size:"small",columns:je,bordered:!0,dataSource:Array.isArray(Y)?Y:[],loading:L,rowKey:ce=>ce.id,expandable:{expandedRowRender:se},pagination:{current:V.page,pageSize:V.perPage,total:J,showSizeChanger:!0,onChange:(ce,_e)=>R({page:ce,perPage:_e})}})})),[$,V.page,V.perPage,Y,L,J]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(320px, 380px) 1fr",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:W,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:P.find(ae=>String(ae.value)===String(n))??null,onChange:ae=>a(ae?.value??null)}),e.jsx(te,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:k.find(ae=>String(ae.value)===String(s))??null,onChange:ae=>{const ce=ae?.value??null;o(ce),d(null),m(ce?`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(ce))}`:null),y(ce?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(ce))}`:null),D(_e=>!_e)}}),e.jsx(te,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:U.find(ae=>String(ae.value)===String(l))??null,onChange:ae=>d(ae?.value??null)},`section_${O}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const ae=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(te,{style:{width:"100%"},options:ae,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:ae.find(ce=>String(ce.value)===String(u??"No"))??ae[1],onChange:ce=>S(ce?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(te,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:b,value:(b??[]).filter(ae=>en(g).some(ce=>String(ce)===String(ae.value))),onChange:(ae,ce)=>{const $e=(Array.isArray(ae)?ae:[]).map(Oe=>Oe?.value).filter(Oe=>Oe!=null&&Oe!=="");p($e);const qe=Array.isArray(B?.subject_ids)?B.subject_ids.map(String):[],Ne=ce?.removedValue?.value,Ue=ce?.option?.value;(ce?.action==="remove-value"||ce?.action==="pop-value")&&Ne!=null&&qe.includes(String(Ne))&&I(Oe=>Array.from(new Set([...en(Oe).map(String),String(Ne)]))),ce?.action==="select-option"&&Ue!=null&&qe.includes(String(Ue))&&I(Oe=>en(Oe).filter(We=>String(We)!==String(Ue)))}},`subjects_${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(pe,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(r.Tabs,{activeKey:N??void 0,onChange:ae=>{H(ae),R(ce=>({...ce,page:1}))},items:ne,type:"card",size:"small"})})]})]})}function Vu({token:t}){return e.jsx(zu,{token:t})}const tn=we.timeGroup,Yu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},xt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function kn(t){if(!t)return null;const n=ye(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return n.isValid()?n:null}function bt(t){return t?ye(t).format("h:mm a"):""}function Wu({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u]=r.Form.useForm(),[S]=r.Form.useForm(),g=`${tn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:p,isLoading:j,mutate:I}=K(t?[g,t]:null,([f,x])=>G(f,x)),T=i.useMemo(()=>Yu(p),[p]),m=i.useMemo(()=>p?.pagination?.total_rows??p?.pagination?.total??T.length??0,[p,T]),{data:c}=K(t&&l?[`${tn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,x])=>G(f,x)),y=i.useMemo(()=>{const f=c?.data??c;return Array.isArray(f)?f[0]:f??null},[c]);i.useEffect(()=>{s&&y&&S.setFieldsValue({title:y?.title??"",start_time_from:kn(y?.start_time_from),start_time_to:kn(y?.start_time_to),end_time_from:kn(y?.end_time_from),end_time_to:kn(y?.end_time_to)})},[s,y,S]);const O=async f=>{const x=new FormData;x.append("title",f.title??""),x.append("start_time_from",bt(f.start_time_from)),x.append("start_time_to",bt(f.start_time_to)),x.append("end_time_from",bt(f.end_time_from)),x.append("end_time_to",bt(f.end_time_to));try{await dt(tn.add,x,t),v.success("Success! Added new item.",{duration:1e3}),u.resetFields(),I()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},D=async f=>{const x=new FormData;x.append("id",String(l??"")),x.append("title",f.title??""),x.append("start_time_from",bt(f.start_time_from)),x.append("start_time_to",bt(f.start_time_to)),x.append("end_time_from",bt(f.end_time_from)),x.append("end_time_to",bt(f.end_time_to));try{await St(tn.edit,x,t),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),I()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to update the item.",{duration:1500})}},_=async f=>{try{await jt(tn.remove,f,t),v.success("Success! Deleted item.",{duration:1e3}),I()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to delete the item.",{duration:1500})}},A=f=>{f?.id&&(d(f.id),o(!0))},h=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:120,render:(f,x)=>e.jsxs(r.Space,{children:[e.jsx(r.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>A(x)}),e.jsx(r.Popconfirm,{title:"Delete this time group?",onConfirm:()=>_(x?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Time Group",open:s,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(r.Form,{form:S,layout:"vertical",onFinish:D,children:[e.jsx(r.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(X,{placeholder:"Title"})}),e.jsx(r.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:xt})}),e.jsx(r.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:xt})}),e.jsx(r.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:xt})}),e.jsx(r.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:xt})}),e.jsxs(r.Space,{children:[e.jsx(pe,{type:"submit",value:"Submit",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(r.Form,{form:u,layout:"vertical",onFinish:O,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(X,{placeholder:"Title"})}),e.jsx(r.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:xt})}),e.jsx(r.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:xt})}),e.jsx(r.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:xt})}),e.jsx(r.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(r.TimePicker,{use12Hours:!0,format:"h:mm a",style:xt})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(r.Table,{rowKey:f=>f.id,columns:h,dataSource:T,loading:j,pagination:{current:n.page,pageSize:n.perPage,total:m,showSizeChanger:!0,onChange:(f,x)=>a({page:f,perPage:x})}})})]})}function Hu({token:t}){return e.jsx(Wu,{token:t})}const nn=we.assignTimeGroup,Ku=we.timeGroup.dropdown,Gu=we.master.classes.dropdown,cs=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Ju=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Qu({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[s,o]=i.useState(null),[l,d]=i.useState([]),[u,S]=i.useState(""),[g,p]=i.useState(""),[j,I]=i.useState(null),[T,m]=i.useState(!1),[c,y]=i.useState(!1),[O,D]=i.useState(null),[_,A]=i.useState([]),[h,f]=i.useState(""),[x,C]=i.useState(""),{data:P}=K(t?[Ku,t]:null,([Y,J])=>G(Y,J)),{data:k}=K(t?[Gu,t]:null,([Y,J])=>G(Y,J)),U=i.useMemo(()=>cs(P?.data??P),[P]),b=i.useMemo(()=>cs(k),[k]),{data:E}=K(t&&j?[j,t]:null,([Y,J])=>G(Y,J));i.useEffect(()=>{const Y=Array.isArray(E?.data)?E.data.map(J=>J.fk_classId):[];Y.length&&d(Y)},[E]);const B=`${nn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:q,isLoading:$,mutate:N}=K(t?[B,t]:null,([Y,J])=>G(Y,J)),H=i.useMemo(()=>Ju(q),[q]),V=i.useMemo(()=>q?.pagination?.total_rows??q?.pagination?.total??H.length??0,[q,H]),{data:R}=K(t&&O?[`${nn.show}?id=${encodeURIComponent(String(O))}`,t]:null,([Y,J])=>G(Y,J)),w=R?.data??R??null;i.useEffect(()=>{if(!c||!w)return;const Y=Array.isArray(w?.class_ids)?w.class_ids:[];A(Y);const J=Array.isArray(U)?U.find(W=>String(W.value)===String(w?.timegroup_id)):null;J&&C(`${J.start_time_from} -> ${J.end_time_from}`)},[c,w,U]);const M=async Y=>{if(Y.preventDefault(),S(""),!s?.value){v.error("Select Time Group",{duration:1200});return}if(!l.length){S("error"),v.error("Please Select Classes",{duration:1200});return}const J=new FormData;J.append("timegroup_id",String(s.value)),l.forEach(W=>J.append("class_ids[]",String(W)));try{await dt(nn.assign,J,t),v.success("Success! Added new item.",{duration:1e3}),d([]),o(null),p(""),N()}catch(W){v.error(W?.response?.data?.msg??W?.message??"Failed to add the new item.",{duration:1500})}},F=async()=>{if(f(""),!O)return;if(!_.length){f("error"),v.error("Please Select Classes",{duration:1200});return}const Y=new FormData;Y.append("id",String(O)),Y.append("timegroup_id",String(w?.timegroup_id??"")),_.forEach(J=>Y.append("class_ids[]",String(J)));try{await St(nn.assign,Y,t),v.success("Success! Updated item.",{duration:1e3}),y(!1),D(null),N()}catch(J){v.error(J?.response?.data?.msg??J?.message??"Failed to update the item.",{duration:1500})}},L=Y=>{Y&&(D(Y),y(!0))},ee=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Class Names",dataIndex:"class_names",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:90,render:(Y,J)=>J?.class_names?e.jsx(r.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>L(J?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Drawer,{title:"Edit Assigned Time Group",open:c,onClose:()=>{y(!1),D(null)},width:520,extra:e.jsxs(r.Space,{children:[e.jsx(r.Button,{onClick:()=>y(!1),children:"Cancel"}),e.jsx(r.Button,{type:"primary",onClick:F,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(te,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:U.find(Y=>String(Y.value)===String(w?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:x}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(r.Select,{mode:"multiple",style:{width:"100%"},status:h,value:_,placeholder:"Select Classes",onChange:Y=>A(Y),options:Array.isArray(b)?b:[]})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:M,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(te,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:s,onChange:Y=>{o(Y??null),d([]),S(""),Y?.value?(I(`${nn.classIdByTimeGroup}?id=${encodeURIComponent(String(Y.value))}`),p(`${Y.start_time_from} -> ${Y.end_time_from}`)):(I(null),p("")),m(J=>!J)}}),e.jsx("div",{style:{marginTop:6},children:g})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(te,{mode:"multiple",style:{width:"100%"},status:u,value:l,placeholder:"Select Classes",onChange:Y=>d(Y),options:Array.isArray(b)?b:[]},`class_${T}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(r.Table,{rowKey:Y=>Y.id,columns:ee,dataSource:H,loading:$,pagination:{current:n.page,pageSize:n.perPage,total:V,showSizeChanger:!0,onChange:(Y,J)=>a({page:Y,perPage:J})}})})]})}function Xu({token:t}){return e.jsx(Qu,{token:t})}const Na=we.promoteStudents,Zu=({token:t})=>K(t?[Na.sessionDropdown,t]:null,([n,a])=>G(n,a)),Mn=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[]},ep=(t,n)=>{const a=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,s=a?.total_rows??a?.total??a?.totalItems;return Number.isFinite(Number(s))?Number(s):n};function tp({token:t}){const[n]=r.Form.useForm(),[a,s]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,u]=i.useState({sessionId:null,classId:null}),[S,g]=i.useState(!1),[p,j]=i.useState([]),I=i.useMemo(()=>new Set(p),[p]),[T,m]=i.useState({}),[c,y]=i.useState({}),{data:O}=K(t?[we.master.classes.dropdown,t]:null,([F,L])=>G(F,L)),D=i.useMemo(()=>Mn(O),[O]),_=i.useMemo(()=>o.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:A}=K(t&&_?[_,t]:null,([F,L])=>G(F,L)),h=i.useMemo(()=>Mn(A),[A]),f=i.useMemo(()=>d.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:x}=K(t&&f?[f,t]:null,([F,L])=>G(F,L),{revalidateOnFocus:!1}),C=i.useMemo(()=>Mn(x),[x]),{data:P}=Zu({token:t}),k=i.useMemo(()=>Mn(P),[P]),{trigger:U,data:b,isMutating:E}=He(t?Na.searchByClassSection:null,(F,{arg:L})=>At(F,{arg:L},t)),B=i.useMemo(()=>{const F=b?.data?.data??b?.data??b??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},[b]),q=i.useMemo(()=>ep(b,B.length??0),[b,B.length]),$=i.useMemo(()=>{const F=new Map;return(Array.isArray(B)?B:[]).forEach(L=>{L?.id!==void 0&&L?.id!==null&&F.set(String(L.id),L)}),F},[B]),N=i.useCallback((F,L)=>{const ee=String(F);y(Y=>({...Y,[ee]:{...Y?.[ee]??{},...L}}))},[]),H=i.useCallback((F,L)=>{const ee=String(F),Y=L==="Leave";m(J=>({...J,[ee]:Y}))},[]),V=F=>{const L=F?.class_id?.value??F?.class_id??null,ee=F?.section_id?.value??F?.section_id??null;if(!L||!ee){v.error("Please select Class and Section",{duration:1200});return}s(Y=>({...Y,page:1})),l({classId:L,sectionId:ee}),j([]),m({}),y({})},R=async()=>{if(!d.sessionId||!d.classId){v.error("Please select Session and Class for promotion",{duration:1300});return}if(!Array.isArray(p)||p.length===0){v.error("Please select students to promote",{duration:1200});return}const F=p.map(J=>String(J)).map(J=>{const W=$.get(J)??{},Z=!!T?.[J],se=c?.[J]??{},je=String(se.current_result??"Pass");if(Z){const ce=String(se.leave_date??"");return{student_id:J,current_result:je,next_session_status:"Leave",leave_date:ce}}const ne=String(se.roll_no??W?.roll_no??""),ae=String(se.section_id??"");return{student_id:J,roll_no:ne,section_id:ae,current_result:je,next_session_status:"Continue"}});if(F.some(J=>J?.next_session_status==="Leave"&&!String(J?.leave_date??"").trim())){v.error("Leave date is required for Leave students.",{duration:1500});return}if(F.some(J=>J?.next_session_status==="Continue"&&!String(J?.section_id??"").trim())){v.error("Section is required for Continue students.",{duration:1500});return}const Y={class_id:String(d.classId),session_id:String(d.sessionId),students:F};try{const J=await ut(Na.promote,Y,t);if(J?.Status&&String(J.Status)!=="success")throw new Error(J?.msg||"Failed to update");v.success("Success! Updated.",{duration:1e3});const W=Number(J?.success_count??0)+Number(J?.leave_count??0),Z=a.page===Math.ceil((Number(q)||0)/a.perPage||1),se=W>0&&W===B.length&&B.length===p.length,je=Z&&se&&a.page>1?a.page-1:a.page;s(ne=>({...ne,page:je})),U?.({cID:o.classId,sID:o.sectionId,page:je,per_page:a.perPage}),j([]),m({}),y({})}catch(J){v.error(J?.response?.data?.msg??J?.message??"Failed to update",{duration:1500})}},w=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:(F,L)=>{const ee=String(L?.id??""),Y=I.has(ee),J=!!T?.[ee],Z=(c?.[ee]??{}).roll_no??(J?"":L?.roll_no??"");return e.jsx(r.Input,{value:Y?Z:L?.roll_no,style:Y?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!Y||J,onChange:se=>N(ee,{roll_no:se.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(F,L)=>`${L?.firstname??""} ${L?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(F,L)=>{const ee=String(L?.id??""),Y=I.has(ee),J=!!T?.[ee],Z=(c?.[ee]??{}).section_id??"",se=Array.isArray(C)?C:[];return e.jsx(r.Select,{options:se,placeholder:Y&&!J?"Select Section":"Section",disabled:!Y||J,value:Y&&!J&&Z||void 0,style:{width:"100%"},onChange:je=>N(ee,{section_id:je})},`section_${ee}_${S}_${J?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(F,L)=>{const ee=String(L?.id??""),Y=I.has(ee),J=c?.[ee]??{},W=String(J.current_result??"Pass");return e.jsxs(r.Radio.Group,{value:W,disabled:!Y,buttonStyle:"solid",onChange:Z=>N(ee,{current_result:Z.target.value}),children:[e.jsx(r.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(r.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(F,L)=>{const ee=String(L?.id??""),Y=I.has(ee),J=!!T?.[ee],W=c?.[ee]??{},Z=String(W.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(r.Radio.Group,{value:J?"Leave":"Continue",disabled:!Y,buttonStyle:"solid",onChange:se=>H(ee,se.target.value),children:[e.jsx(r.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(r.Radio.Button,{value:"Leave",children:"Leave"})]}),Y&&J&&e.jsx(r.DatePicker,{style:{width:"100%"},value:Z?ye(Z):null,onChange:se=>N(ee,{leave_date:se?se.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[H,T,c,I,S,C,N]),M=i.useMemo(()=>({selectedRowKeys:p,onChange:F=>j((Array.isArray(F)?F:[]).map(L=>String(L)))}),[p]);return i.useEffect(()=>{!o.classId||!o.sectionId||U&&U({cID:o.classId,sID:o.sectionId,page:a.page,per_page:a.perPage})},[a.page,a.perPage,U,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(r.Form,{form:n,layout:"vertical",onFinish:V,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:F=>F,children:e.jsx(te,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{const L=F?.value??null;n.setFieldValue("section_id",null),l({classId:L,sectionId:null})}})}),e.jsx(r.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:F=>F,children:e.jsx(te,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Dt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(r.Typography.Text,{children:["Selected: ",p.length]}),e.jsx(r.Typography.Text,{type:"secondary",children:"Select students → set Continue/Leave → Save"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{label:"Session",options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:k.find(F=>String(F.value)===String(d.sessionId))??null,onChange:F=>u(L=>({...L,sessionId:F?.value??null}))}),e.jsx(te,{label:"Class",options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:D.find(F=>String(F.value)===String(d.classId))??null,onChange:F=>{const L=F?.value??null;u(ee=>({...ee,classId:L})),g(ee=>!ee)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"button",value:"Save",color:"primary",onClick:R})})]}),e.jsx(r.Table,{rowKey:F=>String(F.id),rowSelection:M,columns:w,dataSource:B,loading:E,pagination:{current:a.page,pageSize:a.perPage,total:q,showSizeChanger:!0,onChange:(F,L)=>{s({page:F,perPage:L}),j([]),m({}),y({})}}})]})})]})}function np({token:t}){return e.jsx(tp,{token:t})}const Ut=we.coscholastic,ap=({token:t})=>K(t?[Ut.table,t]:null,([n,a])=>G(n,a),{revalidateOnFocus:!1}),rp=({token:t})=>K(t?[Ut.categoryDropdown,t]:null,([n,a])=>G(n,a),{revalidateOnFocus:!1}),us=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]};function sp({token:t}){const[n,a]=i.useState(""),[s,o]=i.useState(null),[l,d]=i.useState(null),u=i.useRef(null),{data:S}=K(t?[we.master.classes.dropdown,t]:null,([x,C])=>G(x,C)),g=i.useMemo(()=>us(S),[S]),{data:p,isLoading:j,mutate:I}=ap({token:t}),T=i.useMemo(()=>{const x=p?.data?.data??p?.data??p??[];return Array.isArray(x)?x:Array.isArray(x?.data)?x.data:[]},[p]),{data:m,mutate:c}=rp({token:t}),y=i.useMemo(()=>us(m),[m]),O=i.useMemo(()=>(Array.isArray(y)?y:[]).map(x=>({value:x?.value??x?.id,label:x?.label??x?.title??""})),[y]),D=async()=>{const x=String(n??"").trim();if(!x){v.error("Please enter category title",{duration:1200});return}try{await Ye(Ut.addCategory,{title:x},t),v.success("Success! Added category.",{duration:1e3}),a(""),c()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to add category",{duration:1500})}},_=async x=>{try{await jt(Ut.deleteCategory,x,t),v.success("Success! Deleted category.",{duration:1e3}),c()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to delete category",{duration:1500})}},A=async x=>{if(x.preventDefault(),!s){v.error("Please select Category",{duration:1200});return}if(!l){v.error("Please select Class",{duration:1200});return}if(!x?.target?.skill?.value){v.error("Please enter Skill Name",{duration:1200});return}const P=new FormData(x.target);P.append("scholastic_catid",String(s)),P.append("class_id",String(l));try{await dt(Ut.addSkill,P,t),v.success("Success! Added new item.",{duration:1e3}),x.target.reset(),d(null),I()}catch(k){v.error(k?.response?.data?.msg??k?.message??"Failed to add the new item.",{duration:1500})}},h=async x=>{try{await jt(Ut.deleteSkill,x,t),v.success("Success! Deleted item.",{duration:1e3}),I()}catch(C){v.error(C?.response?.data?.msg??C?.message??"Failed to delete the item.",{duration:1500})}},f=i.useMemo(()=>[{title:"Skill Category",dataIndex:"title",key:"title"},{title:"Class",dataIndex:"class",key:"class"},{title:"Skill Name",dataIndex:"skill",key:"skill"},{title:"Action",key:"action",width:90,render:(x,C)=>e.jsx(r.Popconfirm,{title:"Delete this skill?",onConfirm:()=>h(C?.id),children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Category"}),e.jsx(te,{style:{width:"100%"},value:O.find(x=>String(x.value)===String(s))??null,placeholder:"Select Category",onChange:x=>o(x?.value??null),options:O}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(X,{placeholder:"New category",ref:u,value:n,onChange:x=>a(x.target.value)}),e.jsx(r.Button,{type:"text",icon:e.jsx(re.PlusOutlined,{}),onClick:D}),e.jsx(r.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{s&&(_(s),o(null))},children:e.jsx(r.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{}),disabled:!s})})]})]}),e.jsx(te,{label:"Class",options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:g.find(x=>String(x.value)===String(l))??null,onChange:x=>d(x?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(X,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Dt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(r.Table,{rowKey:x=>x.id,columns:f,dataSource:T,loading:j,pagination:!1})})]})}function ip({token:t}){return e.jsx(sp,{token:t})}const op=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",pi=({token:t,value:n,onChange:a})=>{const s=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(r.Upload,{maxCount:1,action:bu(),headers:s,onChange:o=>{if(o?.file?.status==="done"){const l=op(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},ps=we.notes,lp=({token:t,url:n})=>K(t&&n?[n,t]:null,([a,s])=>G(a,s),{revalidateOnFocus:!1}),$n=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[]},dp=(t,n)=>{const a=String(t??""),s=String(n??"");return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s};function cp({token:t}){const[n]=r.Form.useForm(),[a]=r.Form.useForm(),[s,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null,sectionId:null}),[u,S]=i.useState(!1),[g,p]=i.useState(""),{data:j}=K(t?[we.master.classes.dropdown,t]:null,([M,F])=>G(M,F)),I=i.useMemo(()=>$n(j),[j]),T=i.useMemo(()=>l.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:m}=K(t&&T?[T,t]:null,([M,F])=>G(M,F)),c=i.useMemo(()=>$n(m),[m]),y=i.useMemo(()=>!l.classId||!l.sectionId?null:`${ps.table}?class_id=${encodeURIComponent(String(l.classId))}§ion_id=${encodeURIComponent(String(l.sectionId))}&page=${encodeURIComponent(String(s.page))}&per_page=${encodeURIComponent(String(s.perPage))}`,[l.classId,l.sectionId,s.page,s.perPage]),{data:O,isLoading:D,mutate:_}=lp({token:t,url:y}),A=i.useMemo(()=>{const M=O?.data?.data??O?.data??O??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},[O]),h=i.useMemo(()=>O?.pagination?.total_rows??O?.pagination?.total??A.length??0,[O,A.length]),[f,x]=i.useState(null),[C,P]=i.useState(null),[k,U]=i.useState(null),[b,E]=i.useState(!1),{data:B}=K(t&&k?[k,t]:null,([M,F])=>G(M,F),{revalidateOnFocus:!1}),q=i.useMemo(()=>$n(B),[B]),{data:$}=K(t&&C?[C,t]:null,([M,F])=>G(M,F)),N=i.useMemo(()=>$n($),[$]),H=M=>{const F=M?.class_id?.value??null,L=M?.section_id?.value??null;!F||!L||(o(ee=>({...ee,page:1})),d({classId:F,sectionId:L}))},V=()=>{p(""),S(!0),x(null),P(null),U(null),E(M=>!M),a.resetFields()},R=async M=>{const F=M?.class_id?.value??null,L=M?.section_id?.value??null,ee=M?.sub_id?.value??null,Y=M?.status?.value??"publish",J=M?.title??"",W=M?.remark??"";if(!F||!L||!ee||!J||!W||!g){v.error("Please fill all fields",{duration:1200});return}const Z=new FormData;Z.append("class_id",String(F)),Z.append("section_id",String(L)),Z.append("sub_id",String(ee)),Z.append("title",String(J)),Z.append("remark",String(W)),Z.append("status",String(Y)),Z.append("file",String(g));try{await dt(ps.add,Z,t),v.success("Success! Added new item.",{duration:1e3}),S(!1),_()}catch(se){v.error(se?.response?.data?.msg??se?.message??"Failed to add the new item.",{duration:1500})}},w=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,F)=>{const L=String(F?.status??"").toLowerCase();return e.jsx(r.Tag,{color:L==="publish"?"green":"red",children:F?.status??"-"})}},{title:"File",key:"file",align:"center",render:(M,F)=>{const L=F?.file;if(!L)return"-";const ee=dp(it(),`/student/note/${L}`);return e.jsx("a",{href:ee,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"publish_date",key:"publish_date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:"Add Note",open:u,onCancel:()=>S(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(r.Form,{form:a,layout:"vertical",onFinish:R,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(te,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const F=M?.value??null;x(F),a.setFieldValue("section_id",null),a.setFieldValue("sub_id",null),U(F?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(F))}`:null),P(F?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(F))}`:null),E(L=>!L)}},`class_${b}`)}),e.jsx(r.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:M=>M,children:e.jsx(te,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${b}_${f??"none"}`)}),e.jsx(r.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:M=>M,children:e.jsx(te,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${b}_${C??"none"}`)}),e.jsx(r.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(X,{placeholder:"Title"})}),e.jsx(r.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(X,{placeholder:"Remark"})}),e.jsx(r.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:M=>M,children:e.jsx(te,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(r.Form.Item,{label:"File",required:!0,children:e.jsx(pi,{token:t,value:g,onChange:p})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>S(!1),children:"Cancel"})]})]})})}),e.jsx(r.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Dt,{actions:["add","export","print","download","filter"],onAdd:V,onPrint:()=>window.print()})]}),children:e.jsx(r.Form,{form:n,layout:"vertical",onFinish:H,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(te,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const F=M?.value??null;n.setFieldValue("section_id",null),d({classId:F,sectionId:null})}})}),e.jsx(r.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:M=>M,children:e.jsx(te,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(r.Table,{rowKey:M=>M.id,columns:w,dataSource:A,loading:D,pagination:{current:s.page,pageSize:s.perPage,total:h,showSizeChanger:!0,onChange:(M,F)=>o({page:M,perPage:F})}})})]})}function up({token:t}){return e.jsx(cp,{token:t})}const pp=({token:t})=>K(t?[we.promoteStudents.sessionDropdown,t]:null,([n,a])=>G(n,a),{revalidateOnFocus:!1}),ms=we.transferCertificate,Ea=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[]},mp={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},fp=(t,n)=>t.inputtype==="Select"?null:t.inputtype==="date"?ye():"",fs=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}],ys=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 yp({token:t,transferCertificateViewPath:n="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:a}){const[s]=r.Form.useForm(),[o]=r.Form.useForm(),[l,d]=i.useState({page:1,perPage:10}),[u,S]=i.useState({classId:null,sectionId:null,sessionId:null}),[g,p]=i.useState(null),[j,I]=i.useState(!1),{data:T}=K(t?[we.master.classes.dropdown,t]:null,([w,M])=>G(w,M)),m=i.useMemo(()=>Ea(T),[T]),{data:c}=K(t&&g?[g,t]:null,([w,M])=>G(w,M)),y=i.useMemo(()=>Ea(c),[c]),{data:O}=pp({token:t}),D=i.useMemo(()=>Ea(O),[O]),_=i.useMemo(()=>!u.classId||!u.sectionId||!u.sessionId?null:`${ms.studentList}?class_id=${encodeURIComponent(String(u.classId))}§ion_id=${encodeURIComponent(String(u.sectionId))}&session_id=${encodeURIComponent(String(u.sessionId))}&page=${encodeURIComponent(String(l.page))}&per_page=${encodeURIComponent(String(l.perPage))}`,[u.classId,u.sectionId,u.sessionId,l.page,l.perPage]),{data:A,isLoading:h,mutate:f}=K(t&&_?[_,t]:null,([w,M])=>G(w,M),{revalidateOnFocus:!1,onSuccess:w=>{const M=w?.data?.data??w?.data??[];Array.isArray(M)&&M[0]?.transefer_certificate_id&&B(String(M[0].transefer_certificate_id))}}),x=i.useMemo(()=>{const w=A?.data?.data??A?.data??A??[];return Array.isArray(w)?w:Array.isArray(w?.data)?w.data:[]},[A]),C=i.useMemo(()=>A?.pagination?.total_rows??A?.pagination?.total??x.length??0,[A,x.length]),[P,k]=i.useState(!1),[U,b]=i.useState(null),[E,B]=i.useState("1"),q=w=>{b(w);const M=E==="1"?fs(w):ys(w),F={};M.forEach(L=>{F[L.name]=L.value??fp(L)}),o.setFieldsValue(F),k(!0)},$=async w=>{if(!w)return;if(typeof a=="function")return a(w);const M=`${n}?id=${encodeURIComponent(String(w))}`;window.location.href=M},N=w=>{const M=w?.class_id?.value??null,F=w?.section_id?.value??null,L=w?.session_id?.value??null;if(!M||!F||!L){v.error("Please select Class, Section and Session",{duration:1200});return}d(ee=>({...ee,page:1})),S({classId:M,sectionId:F,sessionId:L})},H=async w=>{const M=new FormData;Object.entries(w??{}).forEach(([F,L])=>{if(L!=null){if(ye.isDayjs(L)){M.append(F,L.format("YYYY-MM-DD"));return}M.append(F,String(L))}});try{await dt(ms.addData,M,t),v.success("Success! Added new item.",{duration:1e3}),k(!1),b(null),f()}catch(F){v.error(F?.response?.data?.msg??F?.message??"Failed to add the new item.",{duration:1500})}},V=i.useMemo(()=>E==="1"?fs(U):ys(U),[E,U]),R=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:(w,M)=>e.jsx(r.Button,{type:"text",icon:M?.transfer_certificate_data==="not_present"?e.jsx(re.EyeOutlined,{}):e.jsx(re.CheckOutlined,{}),onClick:()=>{M?.transfer_certificate_data==="not_present"?q(M?.id):$(M?.id)}})}],[E]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:"Transfer Certificate",open:P,onCancel:()=>k(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(r.Form,{form:o,layout:"vertical",onFinish:H,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:V.map(w=>w.inputtype==="hidden"?e.jsx(r.Form.Item,{name:w.name,initialValue:w.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},w.name):w.inputtype==="date"?e.jsx(r.Form.Item,{label:w.label,name:w.name,children:e.jsx(r.DatePicker,{format:"YYYY-MM-DD",style:mp})},w.name):w.inputtype==="radio"?e.jsx(r.Form.Item,{label:w.label,name:w.name,children:e.jsx(r.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},w.name):w.inputtype==="Select"?e.jsx(r.Form.Item,{label:w.label,name:w.name,getValueFromEvent:M=>M,children:e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},w.name):e.jsx(r.Form.Item,{label:w.label,name:w.name,children:e.jsx(X,{placeholder:w.label})},w.name))}),e.jsxs(r.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(pe,{type:"submit",value:"Submit",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>k(!1),children:"Cancel"})]})]})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(r.Form,{form:s,layout:"vertical",onFinish:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:w=>w,children:e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:w=>{const M=w?.value??null;p(M?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(M))}`:null),I(F=>!F),s.setFieldValue("section_id",null)}})}),e.jsx(r.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:w=>w,children:e.jsx(te,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${j}`)}),e.jsx(r.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:w=>w,children:e.jsx(te,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Dt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(r.Table,{rowKey:w=>w.id,columns:R,dataSource:x,loading:h,pagination:{current:l.page,pageSize:l.perPage,total:C,showSizeChanger:!0,onChange:(w,M)=>d({page:w,perPage:M})}})})]})}function hp({token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a}){return e.jsx(yp,{token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a})}const gp=({token:t,url:n})=>K(t&&n?[n,t]:null,([a,s])=>G(a,s),{revalidateOnFocus:!1}),Fa=we.syllabus,hs=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[]},xp=(t,n)=>{const a=String(t??""),s=String(n??"");return a?s?a.endsWith("/")&&s.startsWith("/")?`${a}${s.slice(1)}`:!a.endsWith("/")&&!s.startsWith("/")?`${a}/${s}`:`${a}${s}`:a:s};function bp({token:t}){const[n]=r.Form.useForm(),[a]=r.Form.useForm(),[s,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null}),[u,S]=i.useState(!1),[g,p]=i.useState(null),[j,I]=i.useState(""),{data:T}=K(t?[we.master.classes.dropdown,t]:null,([$,N])=>G($,N)),m=i.useMemo(()=>hs(T),[T]),c=i.useMemo(()=>l.classId?`${Fa.table}?class_id=${encodeURIComponent(String(l.classId))}&page=${encodeURIComponent(String(s.page))}&per_page=${encodeURIComponent(String(s.perPage))}`:null,[l.classId,s.page,s.perPage]),{data:y,isLoading:O,mutate:D}=gp({token:t,url:c}),_=i.useMemo(()=>{const $=y?.data?.data??y?.data??y??[];return Array.isArray($)?$:Array.isArray($?.data)?$.data:[]},[y]),A=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??_.length??0,[y,_.length]),[h,f]=i.useState(null),[x,C]=i.useState(!1),{data:P}=K(t&&h?[h,t]:null,([$,N])=>G($,N),{revalidateOnFocus:!1}),k=i.useMemo(()=>hs(P),[P]),U=$=>{const N=$?.class_id?.value??null;N&&(o(H=>({...H,page:1})),d({classId:N}))},b=()=>{p(null),I(""),f(null),C($=>!$),a.resetFields(),S(!0)},E=$=>{p($),I($?.attchement??"");const N=$?.class_id;f(N?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),C(H=>!H),a.setFieldsValue({class_id:m.find(H=>String(H.value)===String(N))??null,sub_id:k.find(H=>String(H.value)===String($?.sub_id??$?.subject_id))??($?.sub_id||$?.subject_id?{label:$?.subject_title??"Subject",value:$?.sub_id??$?.subject_id}:null),title:$?.title??"",description:$?.description??""}),S(!0)},B=async $=>{const N=$?.class_id?.value??null,H=$?.sub_id?.value??null,V=$?.title??"",R=$?.description??"";if(!N||!H||!V||!R||!j){v.error("Please fill all fields",{duration:1200});return}const w=new FormData;w.append("class_id",String(N)),w.append("sub_id",String(H)),w.append("title",String(V)),w.append("description",String(R)),w.append("file",String(j));try{g?.id?(w.append("id",String(g.id)),await dt(Fa.edit,w,t),v.success("Success! Updated item.",{duration:1e3})):(await dt(Fa.add,w,t),v.success("Success! Added new item.",{duration:1e3})),S(!1),p(null),D()}catch(M){v.error(M?.response?.data?.msg??M?.message??"Failed to save",{duration:1500})}},q=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:($,N)=>{const H=N?.attchement;if(!H)return"-";const V=xp(it(),`uploads/student/note/${H}`);return e.jsx("a",{href:V,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:($,N)=>e.jsx(r.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>E(N)})}],[k,m]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Modal,{title:g?"Edit Syllabus":"Add Syllabus",open:u,onCancel:()=>{S(!1),p(null),I("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(r.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(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const N=$?.value??null;a.setFieldValue("sub_id",null),f(N?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),C(H=>!H)}},`class_${g?.id??"add"}_${x}`)}),e.jsx(r.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:$=>$,children:e.jsx(te,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${g?.id??"add"}_${x}_${h??"none"}`)}),e.jsx(r.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(X,{placeholder:"Title"})}),e.jsx(r.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(dn,{placeholder:"Description"})}),e.jsx(r.Form.Item,{label:"File",required:!0,children:e.jsx(pi,{token:t,value:j,onChange:I})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(pe,{type:"submit",value:"Save",color:"primary"}),e.jsx(r.Button,{type:"text",onClick:()=>S(!1),children:"Cancel"})]})]})})}),e.jsx(r.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Dt,{actions:["add","export","print","download","filter"],onAdd:b,onPrint:()=>window.print()})]}),children:e.jsx(r.Form,{form:n,layout:"vertical",onFinish:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(r.Table,{rowKey:$=>$.id,columns:q,dataSource:_,loading:O,pagination:{current:s.page,pageSize:s.perPage,total:A,showSizeChanger:!0,onChange:($,N)=>o({page:$,perPage:N})}})})]})}function Sp({token:t}){return e.jsx(bp,{token:t})}const ca=we.timetable,gs=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[]},xs=t=>{if(!t)return"";const n=ye(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},jp=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let a=0;for(let o=0;o<n.length;o+=1)a=(a*31+n.charCodeAt(o))%1e5;const s=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return s[a%s.length]},bs=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],wp=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"};function vp({token:t}){const[n,a]=i.useState(null),[s,o]=i.useState(!1),[l,d]=i.useState(null),[u,S]=i.useState(""),[g,p]=i.useState(""),{data:j}=K(t?[we.master.classes.dropdown,t]:null,([f,x])=>G(f,x)),I=i.useMemo(()=>gs(j),[j]),{data:T}=K(t&&n?[n,t]:null,([f,x])=>G(f,x)),m=i.useMemo(()=>gs(T),[T]),{data:c,isLoading:y}=K(t&&l?[l,t]:null,([f,x])=>G(f,x),{revalidateOnFocus:!1}),O=i.useMemo(()=>c?.days??c?.data?.days??c?.data?.data?.days??{},[c]),{dataSource:D,daySpanByFirstKey:_}=i.useMemo(()=>{const f=Object.entries(O||{}).slice().sort((P,k)=>bs.indexOf(String(P[0]).toLowerCase())-bs.indexOf(String(k[0]).toLowerCase())),x=new Map,C=[];for(const[P,k]of f){const U=(Array.isArray(k)?k:[]).slice().sort((E,B)=>Number(E?.order_no||0)-Number(B?.order_no||0)),b=U.length;for(let E=0;E<b;E+=1){const B=U[E],q=B?.id||`${P}-${B?.order_no}-${E}`;E===0&&x.set(q,b),C.push({key:q,_dayKey:P,...B})}}return{dataSource:C,daySpanByFirstKey:x}},[O]),A=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(f,x)=>{const C=_.get(x.key);return C===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(re.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(r.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:wp(f)})]}),props:{rowSpan:C}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:f=>e.jsx(r.Tag,{color:"#5080f8",style:{fontWeight:500},children:f})},{title:"Time",key:"time",width:180,render:(f,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(re.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(r.Typography.Text,{children:[xs(x?.time_from)," - ",xs(x?.time_to)]})]})},{title:"Subject",key:"subject",render:(f,x)=>{if(String(x?.is_break)==="1")return e.jsx(r.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const P=x?.subject_name||"-";return e.jsx(r.Tag,{color:jp(P),style:{fontWeight:500},children:P})}},{title:"Teacher",key:"teacher",render:(f,x)=>{const C=String(x?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(re.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(r.Typography.Text,{children:C?"-":x?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(f,x)=>{const C=String(x?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(re.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(r.Typography.Text,{children:C?"-":x?.room_no||"-"})]})}}],[_]),h=f=>{f.preventDefault();const x=f.target.class_id?.value,C=f.target.section_id?.value;if(!x||!C)return;const P=I.find(E=>String(E.value)===String(x)),k=m.find(E=>String(E.value)===String(C));S(P?.label||""),p(k?.label||"");const b=`${ca.byClassSection}/${x}/section/${C}`;d(b)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Dt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:h,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:f=>{a(`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(f?.value??""))}`),o(x=>!x)}}),e.jsx(te,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${s}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:u||g?`Timetable: ${u} ${g}`:"Timetable"}),children:e.jsx(r.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:D,columns:A,rowKey:"key",loading:y,scroll:{x:"max-content"}})})]})}const _p=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[]},Ss=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Cp=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"},js=t=>{if(!t)return"";const n=ye(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},Tp=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let a=0;for(let o=0;o<n.length;o+=1)a=(a*31+n.charCodeAt(o))%1e5;const s=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return s[a%s.length]};function Ap({token:t}){const[n,a]=i.useState(null),[s,o]=i.useState(null),{data:l}=K(t?[we.assignByClass.teacherDropdown,t]:null,([T,m])=>G(T,m)),d=i.useMemo(()=>_p(l),[l]),{data:u,isLoading:S}=K(t&&s?[s,t]:null,([T,m])=>G(T,m),{revalidateOnFocus:!1}),{dataSource:g,daySpanByFirstKey:p}=i.useMemo(()=>{const m=(Array.isArray(u?.data)&&u.data||Array.isArray(u?.data?.data)&&u.data.data||[]).slice().sort((D,_)=>{const A=Ss.indexOf(String(D?.day_name||"").toLowerCase()),h=Ss.indexOf(String(_?.day_name||"").toLowerCase());if(A!==h)return A-h;const f=Number(D?.order_no||0),x=Number(_?.order_no||0);return f!==x?f-x:String(D?.time_from||"").localeCompare(String(_?.time_from||""))}),c=new Map,y=[];let O=0;for(;O<m.length;){const D=String(m[O]?.day_name||"").toLowerCase();let _=O;for(;_<m.length&&String(m[_]?.day_name||"").toLowerCase()===D;)_+=1;const A=_-O;for(let h=O;h<_;h+=1){const f=m[h],x=f?.id||`${D}-${f?.order_no}-${h}`;h===O&&c.set(x,A),y.push({key:x,_dayKey:D,...f})}O=_}return{dataSource:y,daySpanByFirstKey:c}},[u]),j=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(T,m)=>{const c=p.get(m.key);return c===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(re.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(r.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Cp(T)})]}),props:{rowSpan:c}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:T=>e.jsx(r.Tag,{color:"#5080f8",style:{fontWeight:500},children:T})},{title:"Time",key:"time",width:180,render:(T,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(re.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(r.Typography.Text,{children:[js(m?.time_from)," - ",js(m?.time_to)]})]})},{title:"Subject",key:"subject",render:(T,m)=>{if(String(m?.is_break)==="1")return e.jsx(r.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const y=m?.subject_name||"-";return e.jsx(r.Tag,{color:Tp(y),style:{fontWeight:500},children:y})}},{title:"Class",key:"class",width:160,render:(T,m)=>e.jsxs(r.Tag,{color:"purple",style:{fontWeight:500},children:[m?.class_name||m?.class_id||"-"," ",m?.section_name?`(${m.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(T,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(re.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(r.Typography.Text,{children:m?.room_no||"-"})]})}],[p]),I=T=>{T.preventDefault();const m=T.target.teacher_id?.value;if(!m)return;a(m);const y=`${ca.teacherTimetable}${encodeURIComponent(String(m))}`;o(y)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Dt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(te,{options:d,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teacher",name:"teacher_id",allowSelectAll:!1,required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(pe,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(r.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:g,columns:j,rowKey:"key",loading:S,scroll:{x:"max-content"}})})]})}function ws(t){if(!t)return null;const n=String(t).trim().replaceAll(".",":");if(!n)return null;const a=n.toLowerCase(),s=a.includes("am")||a.includes("pm");let o=0,l=0,d=0;if(s){const S=a.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!S)return null;o=Number.parseInt(S[1],10),l=Number.parseInt(S[2],10),d=Number.parseInt(S[3]||"0",10);const g=S[4].toLowerCase();g==="pm"&&o<12&&(o+=12),g==="am"&&o===12&&(o=0)}else{const u=n.split(":").map(S=>S.trim());if(u.length<2)return null;o=Number.parseInt(u[0],10),l=Number.parseInt(u[1],10),d=Number.parseInt(u[2]||"0",10)}return![o,l,d].every(u=>Number.isFinite(u))||o<0||o>23||l<0||l>59||d<0||d>59?null:ye().hour(o).minute(l).second(d).millisecond(0)}function an(t,n){const a=Number.parseInt(n,10);return!Number.isFinite(a)||a<=0||!t||!t.isValid?.()?null:t.add(a,"minute")}const Xn=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[]},ln={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},Ip=t=>{const n=ln[String(t)];return n?n.charAt(0).toUpperCase()+n.slice(1):String(t)},Rp=({token:t,classId:n,sectionId:a,subjectId:s,value:o,onChange:l,disabled:d})=>{const u=t&&n&&a&&s?`${ca.teachersBySubject}?subject_id=${encodeURIComponent(String(s))}&class_id=${encodeURIComponent(String(n))}§ion_id=${encodeURIComponent(String(a))}`:null,{data:S,isLoading:g}=K(u?[u,t]:null,([j,I])=>G(j,I),{revalidateOnFocus:!1}),p=i.useMemo(()=>Xn(S?.data??S).map(I=>({value:I?.value??I?.id,label:I?.label??I?.name??I?.teacher_name??""})),[S]);return e.jsx(r.Select,{placeholder:d?"-":"Select Teacher",loading:g,disabled:d,style:{width:"100%"},options:p,value:o?String(o):void 0,onChange:j=>l?.(j),showSearch:!0,optionFilterProp:"label"})};function Dp({token:t}){const[n]=r.Form.useForm(),[a,s]=i.useState({classId:null,sectionId:null,dayKey:"1",daysEnabled:{0:!1,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}),[o,l]=i.useState({startTime:null,endTime:null,duration:40,interval:0,roomNo:"",tiffinEnabled:!1,tiffinAfterPeriod:3,tiffinDuration:20}),[d,u]=i.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[S,g]=i.useState(!1),p=i.useMemo(()=>t?we.master.classes.dropdown:null,[t]),{data:j}=K(p?[p,t]:null,([b,E])=>G(b,E)),I=i.useMemo(()=>Xn(j).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[j]),T=i.useMemo(()=>!t||!a.classId?null:`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:m}=K(T?[T,t]:null,([b,E])=>G(b,E)),c=i.useMemo(()=>Xn(m).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[m]),y=i.useMemo(()=>!t||!a.classId?null:`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:O}=K(y?[y,t]:null,([b,E])=>G(b,E)),D=i.useMemo(()=>Xn(O).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[O]),_=i.useMemo(()=>Array.isArray(d?.[a.dayKey])?d[a.dayKey]:[],[a.dayKey,d]),A=i.useCallback((b,E,B)=>{u(q=>{const $={...q},N=Array.isArray($[b])?$[b].slice():[];return N[E]={...N[E]??{},...B},$[b]=N,$})},[]),h=i.useCallback((b,E)=>{u(B=>{const q={...B},$=Array.isArray(q[b])?q[b].slice():[];return $.splice(E,1),q[b]=$.map((N,H)=>({...N,order_no:H+1})),q})},[]),f=i.useCallback(b=>{u(E=>{const B={...E},q=Array.isArray(B[b])?B[b].slice():[];let $=null,N=null;const H=q[q.length-1];if(H?.time_to){const V=ws(H.time_to),R=Number.parseInt(o.interval,10)||0,w=Number.parseInt(o.duration,10)||0,M=an(V,R),F=w>0?an(M,w):null;$=M?.isValid?.()?M.format("HH:mm:ss"):null,N=F?.isValid?.()?F.format("HH:mm:ss"):null}return q.push({order_no:q.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:$,time_to:N,is_break:!1}),B[b]=q,B})},[o.duration,o.interval,o.roomNo]),x=i.useCallback(()=>{const b=o.startTime,E=o.endTime,B=Number.parseInt(o.duration,10),q=Number.parseInt(o.interval,10);if(!b||!b.isValid?.()){v.error("Start time is required",{duration:1500});return}if(!E||!E.isValid?.()){v.error("End time is required",{duration:1500});return}if(!E.isAfter(b)){v.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(B)||B<=0){v.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(q)||q<0){v.error("Interval must be 0 or more",{duration:1500});return}const $=()=>{const N=[];let H=b;for(let V=0;V<50;V+=1){const R=an(H,B);if(!R||!R.isValid?.()||R.isAfter(E))break;N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:H.format("HH:mm:ss"),time_to:R.format("HH:mm:ss"),is_break:!1});const w=an(R,q);if(!w||!w.isValid?.()||w.isAfter(E)||w.isSame(E))break;H=w}if(o.tiffinEnabled){const V=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),R=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),w=Math.min(V,N.length);if(w>0&&R>0){const M=N[w-1],F=M?.time_to?ws(M.time_to):null,L=F?an(F,R):null;F?.isValid?.()&&L?.isValid?.()&&!L.isAfter(E)&&N.splice(w,0,{order_no:w+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:F.format("HH:mm:ss"),time_to:L.format("HH:mm:ss"),is_break:!0})}}return N.map((V,R)=>({...V,order_no:R+1}))};u(N=>{const H={...N};return Object.keys(ln).forEach(V=>{a.daysEnabled?.[V]&&(H[V]=$())}),H}),v.success("Generated schedule",{duration:1e3})},[o,a.daysEnabled]),C=i.useCallback(()=>{const b=localStorage.getItem("genrall_settings"),B=(b?JSON.parse(b):{})?.session_id??"1",q=a.classId,$=a.sectionId,N=Object.keys(ln).map(H=>{const V=(Array.isArray(d?.[H])?d[H]:[]).map((R,w)=>({order_no:w+1,subject_id:R?.is_break?0:R?.subject_id??null,teacher_id:R?.is_break?0:R?.teacher_id??null,room_no:R?.room_no??"",time_from:R?.time_from??null,time_to:R?.time_to??null,is_break:R?.is_break?1:0}));return{day:ln[H],class_id:q,section_id:$,session_id:B,args:V}});return{class_id:q,section_id:$,session_id:B,days:N}},[a.classId,a.sectionId,d]),P=i.useCallback(async()=>{if(!a.classId||!a.sectionId){v.error("Please select Class and Section",{duration:1500});return}const b=C(),E=Array.isArray(b?.days)?b.days:[];if(!E.some($=>Array.isArray($?.args)&&$.args.length>0)){v.error("No timetable rows to submit",{duration:1500});return}const q=$=>{const N=$?.is_break;return N===1||N==="1"||N===!0?!0:String(N??"").toLowerCase()==="true"};E.some($=>(Array.isArray($?.args)?$.args:[]).some(N=>String(N?.time_from??"").trim()&&String(N?.time_to??"").trim()?q(N)?!1:!String(N?.subject_id??"").trim()||!String(N?.teacher_id??"").trim():!0)),g(!0);try{const $=ca.save,N=$==="api/timetable/save"?"timetable/save":null,H=async w=>{const M=await Wa(w,b,t);if(M&&typeof M=="object")return M;throw new Error("No response from server")};let V;try{V=await H($)}catch{V=await H(N)}const R=String(V?.msg??"");if(String(V?.Status)==="Success"){if(Array.isArray(V?.data)&&V.data.length===0&&R){v.error(R,{duration:3e3});return}v.success(R||"Weekly Time Table added successfully!",{duration:1200});return}v.error(R||"Failed to add time table",{duration:3e3})}catch($){v.error($?.response?.data?.msg??$?.message??"Failed to add time table",{duration:3e3})}finally{g(!1)}},[C,a.classId,a.sectionId,t]),k=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:b=>b?ye(b,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:b=>b?ye(b,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(b,E,B)=>e.jsx(r.Switch,{checked:!!E?.is_break,onChange:q=>{A(a.dayKey,B,{is_break:q,subject_id:q?"":E?.subject_id??"",teacher_id:q?"":E?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(b,E,B)=>e.jsx(r.Select,{placeholder:E?.is_break?"-":"Select Subject",disabled:!!E?.is_break,style:{width:"100%"},options:D,value:E?.subject_id?String(E.subject_id):void 0,onChange:q=>A(a.dayKey,B,{subject_id:q,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(b,E,B)=>e.jsx(Rp,{token:t,classId:a.classId,sectionId:a.sectionId,subjectId:E?.subject_id,disabled:!!E?.is_break||!E?.subject_id,value:E?.teacher_id,onChange:q=>A(a.dayKey,B,{teacher_id:q})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(b,E,B)=>e.jsx(r.Input,{value:E?.room_no??"",onChange:q=>A(a.dayKey,B,{room_no:q.target.value})})},{title:"Action",key:"action",width:90,render:(b,E,B)=>e.jsx(r.Popconfirm,{title:"Delete this row?",onConfirm:()=>h(a.dayKey,B),children:e.jsx(r.Button,{danger:!0,type:"text",children:"Delete"})})}],[a.classId,a.dayKey,a.sectionId,h,D,t,A]),U=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(r.Form,{form:n,layout:"vertical",initialValues:{duration:o.duration,interval:o.interval,roomNo:o.roomNo,tiffinEnabled:o.tiffinEnabled,tiffinAfterPeriod:o.tiffinAfterPeriod,tiffinDuration:o.tiffinDuration},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(r.Form.Item,{label:"Class",required:!0,children:e.jsx(r.Select,{placeholder:"Select Class",options:I,value:a.classId?String(a.classId):void 0,onChange:b=>{s(E=>({...E,classId:b,sectionId:null})),u({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(r.Form.Item,{label:"Section",required:!0,children:e.jsx(r.Select,{placeholder:"Select Section",options:c,value:a.sectionId?String(a.sectionId):void 0,onChange:b=>s(E=>({...E,sectionId:b})),disabled:!a.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(r.Form.Item,{label:"Start Time",required:!0,children:e.jsx(r.TimePicker,{value:o.startTime,onChange:b=>l(E=>({...E,startTime:b})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"End Time",required:!0,children:e.jsx(r.TimePicker,{value:o.endTime,onChange:b=>l(E=>({...E,endTime:b})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(r.InputNumber,{min:1,value:o.duration,onChange:b=>l(E=>({...E,duration:b})),style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"Interval (min)",children:e.jsx(r.InputNumber,{min:0,value:o.interval,onChange:b=>l(E=>({...E,interval:b})),style:{width:"100%"}})}),e.jsx(r.Form.Item,{label:"Room No",children:e.jsx(r.Input,{value:o.roomNo,onChange:b=>l(E=>({...E,roomNo:b.target.value}))})}),e.jsx(r.Form.Item,{label:"Tiffin Break",children:e.jsxs(r.Space,{children:[e.jsx(r.Switch,{checked:o.tiffinEnabled,onChange:b=>l(E=>({...E,tiffinEnabled:b}))}),e.jsx(r.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(r.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(r.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:b=>l(E=>({...E,tiffinAfterPeriod:b})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(r.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(r.InputNumber,{min:1,value:o.tiffinDuration,onChange:b=>l(E=>({...E,tiffinDuration:b})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(r.Button,{onClick:x,children:"Generate"}),e.jsx(r.Button,{type:"primary",loading:S,onClick:P,children:"Save"})]})]})})}),e.jsx(r.Card,{title:e.jsx(r.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(r.Space,{children:[e.jsx(r.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(r.Select,{style:{width:160},value:a.dayKey,onChange:b=>s(E=>({...E,dayKey:b})),options:Object.keys(ln).map(b=>({value:String(b),label:Ip(b)}))}),e.jsx(r.Button,{onClick:()=>f(a.dayKey),children:"Add Row"})]}),children:e.jsx(r.Table,{rowKey:(b,E)=>`${a.dayKey}_${E}`,columns:k,dataSource:_,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(r.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(r.Tabs,{type:"card",items:[{key:"create",label:"Create",children:U},{key:"routine",label:"Routine",children:e.jsx(vp,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(Ap,{token:t})}]})]})}function Op({token:t}){return e.jsx(Dp,{token:t})}const Pp=({routes:t=[],onNavigate:n})=>e.jsx(r.Row,{gutter:[16,16],children:t.map((a,s)=>e.jsx(r.Col,{xs:24,md:8,lg:8,children:e.jsx(de,{children:e.jsx(Cs,{icon:a?.icon??"",title:a?.title??"",path:a?.path??"",onClick:n})})},`${s}route001`))});exports.Academics=gu;exports.AddBook=Hl;exports.AddDriver=ql;exports.AddStaff=pc;exports.AdmissionEnquiry=jl;exports.ApplyLeave=Jc;exports.AprroveLeaveRequest=zc;exports.AssignByClass=Vu;exports.AssignStudentToTransport=Ll;exports.AssignSubjects=Lu;exports.AssignTimeGroup=Xu;exports.AssignVehicles=Dl;exports.BookList=Kl;exports.BuySellProduct=Pd;exports.Category=jd;exports.Class=Ru;exports.CoScholasticArea=ip;exports.CreateTimeGroup=Hu;exports.Department=nu;exports.Designation=su;exports.ErpDashboard=fi;exports.Holidays=$u;exports.IssueReturn=Jl;exports.LeaveType=Zc;exports.LibraryAssignStudent=Ql;exports.LibraryCategory=Xl;exports.LibraryReport=Zl;exports.ManageStock=Yd;exports.MenuSubmenu=tl;exports.Notes=up;exports.Payroll=Uc;exports.PayrollReceiptDetails=hu;exports.Products=gd;exports.PromoteStudents=np;exports.RoutePage=Pp;exports.RouteTimeTable=zl;exports.Sections=_u;exports.SellReports=qd;exports.Shift=lu;exports.StaffAttendance=Rc;exports.StaffAttendanceReport=Ec;exports.StaffDailyAttendance=mu;exports.StaffDirectory=gc;exports.StockReport=Jd;exports.Stoppage=Yl;exports.SubCategory=Ad;exports.Subjects=Eu;exports.Syllabus=Sp;exports.TimeTable=Op;exports.TransferCertificate=hp;exports.TransportRoutes=vl;exports.TransportVehicles=_l;exports.Unit=Md;exports.Vendor=od;exports.setBaseUrl=Xo;
|