ubk.erp.webpack 1.3.5 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Layout/Exam/AdmitCardSetting.d.ts +5 -0
- package/dist/Layout/Exam/Assessment.d.ts +5 -0
- package/dist/Layout/Exam/AssignMarks.d.ts +5 -0
- package/dist/Layout/Exam/CoScholasticAreaMarks.d.ts +5 -0
- package/dist/Layout/Exam/Exam.d.ts +5 -0
- package/dist/Layout/Exam/ExamDashboard.d.ts +5 -0
- package/dist/Layout/Exam/ExamDetails.d.ts +5 -0
- package/dist/Layout/Exam/ExamEdit.d.ts +5 -0
- package/dist/Layout/Exam/ExamInstruction.d.ts +5 -0
- package/dist/Layout/Exam/ExamLink.d.ts +5 -0
- package/dist/Layout/Exam/ExamList.d.ts +5 -0
- package/dist/Layout/Exam/ExamSetting.d.ts +5 -0
- package/dist/Layout/Exam/ExamType.d.ts +5 -0
- package/dist/Layout/Exam/MarksReport.d.ts +5 -0
- package/dist/Layout/Exam/Pages/AdmitCardSettingPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/AssessmentPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/AssignMarksPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/CoScholasticAreaMarksPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/ExamDashboardPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/ExamDetailsPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/ExamEditPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/ExamInstructionPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/ExamLinkPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/ExamListPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/ExamPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/ExamSettingPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/ExamTypePage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/MarksReportPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/RoomManagementPage.d.ts +5 -0
- package/dist/Layout/Exam/Pages/StudentResultPage.d.ts +5 -0
- package/dist/Layout/Exam/RoomManagment.d.ts +5 -0
- package/dist/Layout/Exam/Services/examsService.d.ts +131 -0
- package/dist/Layout/Exam/StudentResult.d.ts +5 -0
- package/dist/Layout/Exam/hooks.d.ts +35 -0
- package/dist/Layout/Exam/index.d.ts +16 -0
- package/dist/Secondary/CommonFuntion.d.ts +2 -0
- package/dist/Secondary/TextChangeGlobal.d.ts +1 -0
- package/dist/index.cjs +79 -15
- package/dist/index.d.ts +3 -2
- package/dist/index.js +19244 -11964
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("antd"),K=require("swr"),v=require("react-hot-toast"),i=require("react"),pt=require("swr/mutation"),ee=require("@ant-design/icons"),se=require("dayjs"),Wo=require("react-dom/server"),ia=require("react-to-print"),Al=require("react-select"),Dl=require("react-barcode"),Vo=()=>e.jsxs(a.Card,{style:{borderRadius:16},children:[e.jsx(a.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(a.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),w=({width:t,height:n,display:s,justifyContent:r,alignItems:l,flexDirection:o,gap:d,style:c,children:g,...y})=>{const p={width:t,height:n,display:s,justifyContent:r,alignItems:l,flexDirection:o,gap:d,...c};return e.jsx("div",{style:p,...y,children:g})},be=({variant:t,fontWeight:n,style:s,children:r,...l})=>{const o=n==="bold"?700:n==="light"?300:n;return t==="h1"?e.jsx(a.Typography.Title,{level:1,style:{fontWeight:o,...s},...l,children:r}):t==="h2"?e.jsx(a.Typography.Title,{level:2,style:{fontWeight:o,...s},...l,children:r}):t==="h3"?e.jsx(a.Typography.Title,{level:3,style:{fontWeight:o,...s},...l,children:r}):t==="h4"?e.jsx(a.Typography.Title,{level:4,style:{fontWeight:o,...s},...l,children:r}):t==="h5"?e.jsx(a.Typography.Title,{level:5,style:{fontWeight:o,...s},...l,children:r}):e.jsx(a.Typography.Text,{style:{fontWeight:o,...s},...l,children:r})};function Tl({title:t="",icon:n="",path:s="",onClick:r}){const l=()=>{if(r){r(s);return}typeof window<"u"&&typeof s=="string"&&s.length>0&&window.location.assign(s)};return e.jsxs(a.Card,{hoverable:!0,onClick:l,style:{borderRadius:12,overflow:"hidden",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.10)"},bodyStyle:{padding:0,cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[e.jsx(w,{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(w,{style:{padding:"0 12px"},children:e.jsx(a.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(w,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(be,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function Rl(t,n){return function(){return t.apply(n,arguments)}}const{toString:Ho}=Object.prototype,{getPrototypeOf:as}=Object,{iterator:ns,toStringTag:Il}=Symbol,ss=(t=>n=>{const s=Ho.call(n);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Ot=t=>(t=t.toLowerCase(),n=>ss(n)===t),rs=t=>n=>typeof n===t,{isArray:Ta}=Array,_a=rs("undefined");function rn(t){return t!==null&&!_a(t)&&t.constructor!==null&&!_a(t.constructor)&&St(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const kl=Ot("ArrayBuffer");function Ko(t){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(t):n=t&&t.buffer&&kl(t.buffer),n}const Go=rs("string"),St=rs("function"),Pl=rs("number"),ln=t=>t!==null&&typeof t=="object",Jo=t=>t===!0||t===!1,$n=t=>{if(ss(t)!=="object")return!1;const n=as(t);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Il in t)&&!(ns in t)},Qo=t=>{if(!ln(t)||rn(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Xo=Ot("Date"),Zo=Ot("File"),ed=t=>!!(t&&typeof t.uri<"u"),td=t=>t&&typeof t.getParts<"u",ad=Ot("Blob"),nd=Ot("FileList"),sd=t=>ln(t)&&St(t.pipe);function rd(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const br=rd(),jr=typeof br.FormData<"u"?br.FormData:void 0,id=t=>{if(!t)return!1;if(jr&&t instanceof jr)return!0;const n=as(t);if(!n||n===Object.prototype||!St(t.append))return!1;const s=ss(t);return s==="formdata"||s==="object"&&St(t.toString)&&t.toString()==="[object FormData]"},ld=Ot("URLSearchParams"),[od,dd,cd,ud]=["ReadableStream","Request","Response","Headers"].map(Ot),pd=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function on(t,n,{allOwnKeys:s=!1}={}){if(t===null||typeof t>"u")return;let r,l;if(typeof t!="object"&&(t=[t]),Ta(t))for(r=0,l=t.length;r<l;r++)n.call(null,t[r],r,t);else{if(rn(t))return;const o=s?Object.getOwnPropertyNames(t):Object.keys(t),d=o.length;let c;for(r=0;r<d;r++)c=o[r],n.call(null,t[c],c,t)}}function Ol(t,n){if(rn(t))return null;n=n.toLowerCase();const s=Object.keys(t);let r=s.length,l;for(;r-- >0;)if(l=s[r],n===l.toLowerCase())return l;return null}const ta=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ml=t=>!_a(t)&&t!==ta;function Ks(){const{caseless:t,skipUndefined:n}=Ml(this)&&this||{},s={},r=(l,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const d=t&&Ol(s,o)||o;$n(s[d])&&$n(l)?s[d]=Ks(s[d],l):$n(l)?s[d]=Ks({},l):Ta(l)?s[d]=l.slice():(!n||!_a(l))&&(s[d]=l)};for(let l=0,o=arguments.length;l<o;l++)arguments[l]&&on(arguments[l],r);return s}const md=(t,n,s,{allOwnKeys:r}={})=>(on(n,(l,o)=>{s&&St(l)?Object.defineProperty(t,o,{value:Rl(l,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,o,{value:l,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),hd=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),fd=(t,n,s,r)=>{t.prototype=Object.create(n.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:n.prototype}),s&&Object.assign(t.prototype,s)},yd=(t,n,s,r)=>{let l,o,d;const c={};if(n=n||{},t==null)return n;do{for(l=Object.getOwnPropertyNames(t),o=l.length;o-- >0;)d=l[o],(!r||r(d,t,n))&&!c[d]&&(n[d]=t[d],c[d]=!0);t=s!==!1&&as(t)}while(t&&(!s||s(t,n))&&t!==Object.prototype);return n},gd=(t,n,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=n.length;const r=t.indexOf(n,s);return r!==-1&&r===s},xd=t=>{if(!t)return null;if(Ta(t))return t;let n=t.length;if(!Pl(n))return null;const s=new Array(n);for(;n-- >0;)s[n]=t[n];return s},bd=(t=>n=>t&&n instanceof t)(typeof Uint8Array<"u"&&as(Uint8Array)),jd=(t,n)=>{const r=(t&&t[ns]).call(t);let l;for(;(l=r.next())&&!l.done;){const o=l.value;n.call(t,o[0],o[1])}},Sd=(t,n)=>{let s;const r=[];for(;(s=t.exec(n))!==null;)r.push(s);return r},vd=Ot("HTMLFormElement"),wd=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,r,l){return r.toUpperCase()+l}),Sr=(({hasOwnProperty:t})=>(n,s)=>t.call(n,s))(Object.prototype),_d=Ot("RegExp"),El=(t,n)=>{const s=Object.getOwnPropertyDescriptors(t),r={};on(s,(l,o)=>{let d;(d=n(l,o,t))!==!1&&(r[o]=d||l)}),Object.defineProperties(t,r)},Cd=t=>{El(t,(n,s)=>{if(St(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const r=t[s];if(St(r)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},Ad=(t,n)=>{const s={},r=l=>{l.forEach(o=>{s[o]=!0})};return Ta(t)?r(t):r(String(t).split(n)),s},Dd=()=>{},Td=(t,n)=>t!=null&&Number.isFinite(t=+t)?t:n;function Rd(t){return!!(t&&St(t.append)&&t[Il]==="FormData"&&t[ns])}const Id=t=>{const n=new Array(10),s=(r,l)=>{if(ln(r)){if(n.indexOf(r)>=0)return;if(rn(r))return r;if(!("toJSON"in r)){n[l]=r;const o=Ta(r)?[]:{};return on(r,(d,c)=>{const g=s(d,l+1);!_a(g)&&(o[c]=g)}),n[l]=void 0,o}}return r};return s(t,0)},kd=Ot("AsyncFunction"),Pd=t=>t&&(ln(t)||St(t))&&St(t.then)&&St(t.catch),Fl=((t,n)=>t?setImmediate:n?((s,r)=>(ta.addEventListener("message",({source:l,data:o})=>{l===ta&&o===s&&r.length&&r.shift()()},!1),l=>{r.push(l),ta.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",St(ta.postMessage)),Od=typeof queueMicrotask<"u"?queueMicrotask.bind(ta):typeof process<"u"&&process.nextTick||Fl,Md=t=>t!=null&&St(t[ns]),te={isArray:Ta,isArrayBuffer:kl,isBuffer:rn,isFormData:id,isArrayBufferView:Ko,isString:Go,isNumber:Pl,isBoolean:Jo,isObject:ln,isPlainObject:$n,isEmptyObject:Qo,isReadableStream:od,isRequest:dd,isResponse:cd,isHeaders:ud,isUndefined:_a,isDate:Xo,isFile:Zo,isReactNativeBlob:ed,isReactNative:td,isBlob:ad,isRegExp:_d,isFunction:St,isStream:sd,isURLSearchParams:ld,isTypedArray:bd,isFileList:nd,forEach:on,merge:Ks,extend:md,trim:pd,stripBOM:hd,inherits:fd,toFlatObject:yd,kindOf:ss,kindOfTest:Ot,endsWith:gd,toArray:xd,forEachEntry:jd,matchAll:Sd,isHTMLForm:vd,hasOwnProperty:Sr,hasOwnProp:Sr,reduceDescriptors:El,freezeMethods:Cd,toObjectSet:Ad,toCamelCase:wd,noop:Dd,toFiniteNumber:Td,findKey:Ol,global:ta,isContextDefined:Ml,isSpecCompliantForm:Rd,toJSONObject:Id,isAsyncFn:kd,isThenable:Pd,setImmediate:Fl,asap:Od,isIterable:Md};let Me=class $l extends Error{static from(n,s,r,l,o,d){const c=new $l(n.message,s||n.code,r,l,o);return c.cause=n,c.name=n.name,n.status!=null&&c.status==null&&(c.status=n.status),d&&Object.assign(c,d),c}constructor(n,s,r,l,o){super(n),Object.defineProperty(this,"message",{value:n,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,s&&(this.code=s),r&&(this.config=r),l&&(this.request=l),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:te.toJSONObject(this.config),code:this.code,status:this.status}}};Me.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Me.ERR_BAD_OPTION="ERR_BAD_OPTION";Me.ECONNABORTED="ECONNABORTED";Me.ETIMEDOUT="ETIMEDOUT";Me.ERR_NETWORK="ERR_NETWORK";Me.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Me.ERR_DEPRECATED="ERR_DEPRECATED";Me.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Me.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Me.ERR_CANCELED="ERR_CANCELED";Me.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Me.ERR_INVALID_URL="ERR_INVALID_URL";Me.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const Ed=null;function Gs(t){return te.isPlainObject(t)||te.isArray(t)}function Ul(t){return te.endsWith(t,"[]")?t.slice(0,-2):t}function bs(t,n,s){return t?t.concat(n).map(function(l,o){return l=Ul(l),!s&&o?"["+l+"]":l}).join(s?".":""):n}function Fd(t){return te.isArray(t)&&!t.some(Gs)}const $d=te.toFlatObject(te,{},null,function(n){return/^is[A-Z]/.test(n)});function is(t,n,s){if(!te.isObject(t))throw new TypeError("target must be an object");n=n||new FormData,s=te.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,R){return!te.isUndefined(R[x])});const r=s.metaTokens,l=s.visitor||m,o=s.dots,d=s.indexes,c=s.Blob||typeof Blob<"u"&&Blob,g=s.maxDepth===void 0?100:s.maxDepth,y=c&&te.isSpecCompliantForm(n);if(!te.isFunction(l))throw new TypeError("visitor must be a function");function p(f){if(f===null)return"";if(te.isDate(f))return f.toISOString();if(te.isBoolean(f))return f.toString();if(!y&&te.isBlob(f))throw new Me("Blob is not supported. Use a Buffer instead.");return te.isArrayBuffer(f)||te.isTypedArray(f)?y&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function m(f,x,R){let k=f;if(te.isReactNative(n)&&te.isReactNativeBlob(f))return n.append(bs(R,x,o),p(f)),!1;if(f&&!R&&typeof f=="object"){if(te.endsWith(x,"{}"))x=r?x:x.slice(0,-2),f=JSON.stringify(f);else if(te.isArray(f)&&Fd(f)||(te.isFileList(f)||te.endsWith(x,"[]"))&&(k=te.toArray(f)))return x=Ul(x),k.forEach(function(_,D){!(te.isUndefined(_)||_===null)&&n.append(d===!0?bs([x],D,o):d===null?x:x+"[]",p(_))}),!1}return Gs(f)?!0:(n.append(bs(R,x,o),p(f)),!1)}const A=[],C=Object.assign($d,{defaultVisitor:m,convertValue:p,isVisitable:Gs});function b(f,x,R=0){if(!te.isUndefined(f)){if(R>g)throw new Me("Object is too deeply nested ("+R+" levels). Max depth: "+g,Me.ERR_FORM_DATA_DEPTH_EXCEEDED);if(A.indexOf(f)!==-1)throw Error("Circular reference detected in "+x.join("."));A.push(f),te.forEach(f,function(O,_){(!(te.isUndefined(O)||O===null)&&l.call(n,O,te.isString(_)?_.trim():_,x,C))===!0&&b(O,x?x.concat(_):[_],R+1)}),A.pop()}}if(!te.isObject(t))throw new TypeError("data must be an object");return b(t),n}function vr(t){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return n[r]})}function ar(t,n){this._pairs=[],t&&is(t,this,n)}const Bl=ar.prototype;Bl.append=function(n,s){this._pairs.push([n,s])};Bl.toString=function(n){const s=n?function(r){return n.call(this,r,vr)}:vr;return this._pairs.map(function(l){return s(l[0])+"="+s(l[1])},"").join("&")};function Ud(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Nl(t,n,s){if(!n)return t;const r=s&&s.encode||Ud,l=te.isFunction(s)?{serialize:s}:s,o=l&&l.serialize;let d;if(o?d=o(n,l):d=te.isURLSearchParams(n)?n.toString():new ar(n,l).toString(r),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class wr{constructor(){this.handlers=[]}use(n,s,r){return this.handlers.push({fulfilled:n,rejected:s,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){te.forEach(this.handlers,function(r){r!==null&&n(r)})}}const nr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Bd=typeof URLSearchParams<"u"?URLSearchParams:ar,Nd=typeof FormData<"u"?FormData:null,Ld=typeof Blob<"u"?Blob:null,qd={isBrowser:!0,classes:{URLSearchParams:Bd,FormData:Nd,Blob:Ld},protocols:["http","https","file","blob","url","data"]},sr=typeof window<"u"&&typeof document<"u",Js=typeof navigator=="object"&&navigator||void 0,zd=sr&&(!Js||["ReactNative","NativeScript","NS"].indexOf(Js.product)<0),Yd=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Wd=sr&&window.location.href||"http://localhost",Vd=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:sr,hasStandardBrowserEnv:zd,hasStandardBrowserWebWorkerEnv:Yd,navigator:Js,origin:Wd},Symbol.toStringTag,{value:"Module"})),yt={...Vd,...qd};function Hd(t,n){return is(t,new yt.classes.URLSearchParams,{visitor:function(s,r,l,o){return yt.isNode&&te.isBuffer(s)?(this.append(r,s.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...n})}function Kd(t){return te.matchAll(/\w+|\[(\w*)]/g,t).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Gd(t){const n={},s=Object.keys(t);let r;const l=s.length;let o;for(r=0;r<l;r++)o=s[r],n[o]=t[o];return n}function Ll(t){function n(s,r,l,o){let d=s[o++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),g=o>=s.length;return d=!d&&te.isArray(l)?l.length:d,g?(te.hasOwnProp(l,d)?l[d]=te.isArray(l[d])?l[d].concat(r):[l[d],r]:l[d]=r,!c):((!l[d]||!te.isObject(l[d]))&&(l[d]=[]),n(s,r,l[d],o)&&te.isArray(l[d])&&(l[d]=Gd(l[d])),!c)}if(te.isFormData(t)&&te.isFunction(t.entries)){const s={};return te.forEachEntry(t,(r,l)=>{n(Kd(r),l,s,0)}),s}return null}const da=(t,n)=>t!=null&&te.hasOwnProp(t,n)?t[n]:void 0;function Jd(t,n,s){if(te.isString(t))try{return(n||JSON.parse)(t),te.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(s||JSON.stringify)(t)}const dn={transitional:nr,adapter:["xhr","http","fetch"],transformRequest:[function(n,s){const r=s.getContentType()||"",l=r.indexOf("application/json")>-1,o=te.isObject(n);if(o&&te.isHTMLForm(n)&&(n=new FormData(n)),te.isFormData(n))return l?JSON.stringify(Ll(n)):n;if(te.isArrayBuffer(n)||te.isBuffer(n)||te.isStream(n)||te.isFile(n)||te.isBlob(n)||te.isReadableStream(n))return n;if(te.isArrayBufferView(n))return n.buffer;if(te.isURLSearchParams(n))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(o){const g=da(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Hd(n,g).toString();if((c=te.isFileList(n))||r.indexOf("multipart/form-data")>-1){const y=da(this,"env"),p=y&&y.FormData;return is(c?{"files[]":n}:n,p&&new p,g)}}return o||l?(s.setContentType("application/json",!1),Jd(n)):n}],transformResponse:[function(n){const s=da(this,"transitional")||dn.transitional,r=s&&s.forcedJSONParsing,l=da(this,"responseType"),o=l==="json";if(te.isResponse(n)||te.isReadableStream(n))return n;if(n&&te.isString(n)&&(r&&!l||o)){const c=!(s&&s.silentJSONParsing)&&o;try{return JSON.parse(n,da(this,"parseReviver"))}catch(g){if(c)throw g.name==="SyntaxError"?Me.from(g,Me.ERR_BAD_RESPONSE,this,null,da(this,"response")):g}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:yt.classes.FormData,Blob:yt.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};te.forEach(["delete","get","head","post","put","patch"],t=>{dn.headers[t]={}});const Qd=te.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"]),Xd=t=>{const n={};let s,r,l;return t&&t.split(`
|
|
2
|
-
`).forEach(function(d){
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...s){const r=new this(n);return s.forEach(l=>r.set(l)),r}static accessor(n){const r=(this[_r]=this[_r]={accessors:{}}).accessors,l=this.prototype;function o(d){const c=Oa(d);r[c]||(rc(l,d),r[c]=!0)}return te.isArray(n)?n.forEach(o):o(n),this}};vt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);te.reduceDescriptors(vt.prototype,({value:t},n)=>{let s=n[0].toUpperCase()+n.slice(1);return{get:()=>t,set(r){this[s]=r}}});te.freezeMethods(vt);function Ss(t,n){const s=this||dn,r=n||s,l=vt.from(r.headers);let o=r.data;return te.forEach(t,function(c){o=c.call(s,o,l.normalize(),n?n.status:void 0)}),l.normalize(),o}function ql(t){return!!(t&&t.__CANCEL__)}let cn=class extends Me{constructor(n,s,r){super(n??"canceled",Me.ERR_CANCELED,s,r),this.name="CanceledError",this.__CANCEL__=!0}};function zl(t,n,s){const r=s.config.validateStatus;!s.status||!r||r(s.status)?t(s):n(new Me("Request failed with status code "+s.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function ic(t){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return n&&n[1]||""}function lc(t,n){t=t||10;const s=new Array(t),r=new Array(t);let l=0,o=0,d;return n=n!==void 0?n:1e3,function(g){const y=Date.now(),p=r[o];d||(d=y),s[l]=g,r[l]=y;let m=o,A=0;for(;m!==l;)A+=s[m++],m=m%t;if(l=(l+1)%t,l===o&&(o=(o+1)%t),y-d<n)return;const C=p&&y-p;return C?Math.round(A*1e3/C):void 0}}function oc(t,n){let s=0,r=1e3/n,l,o;const d=(y,p=Date.now())=>{s=p,l=null,o&&(clearTimeout(o),o=null),t(...y)};return[(...y)=>{const p=Date.now(),m=p-s;m>=r?d(y,p):(l=y,o||(o=setTimeout(()=>{o=null,d(l)},r-m)))},()=>l&&d(l)]}const ts=(t,n,s=3)=>{let r=0;const l=lc(50,250);return oc(o=>{const d=o.loaded,c=o.lengthComputable?o.total:void 0,g=c!=null?Math.min(d,c):d,y=Math.max(0,g-r),p=l(y);r=Math.max(r,g);const m={loaded:g,total:c,progress:c?g/c:void 0,bytes:y,rate:p||void 0,estimated:p&&c?(c-g)/p:void 0,event:o,lengthComputable:c!=null,[n?"download":"upload"]:!0};t(m)},s)},Cr=(t,n)=>{const s=t!=null;return[r=>n[0]({lengthComputable:s,total:t,loaded:r}),n[1]]},Ar=t=>(...n)=>te.asap(()=>t(...n)),dc=yt.hasStandardBrowserEnv?((t,n)=>s=>(s=new URL(s,yt.origin),t.protocol===s.protocol&&t.host===s.host&&(n||t.port===s.port)))(new URL(yt.origin),yt.navigator&&/(msie|trident)/i.test(yt.navigator.userAgent)):()=>!0,cc=yt.hasStandardBrowserEnv?{write(t,n,s,r,l,o,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(n)}`];te.isNumber(s)&&c.push(`expires=${new Date(s).toUTCString()}`),te.isString(r)&&c.push(`path=${r}`),te.isString(l)&&c.push(`domain=${l}`),o===!0&&c.push("secure"),te.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const n=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return n?decodeURIComponent(n[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function uc(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function pc(t,n){return n?t.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):t}function Yl(t,n,s){let r=!uc(n);return t&&(r||s===!1)?pc(t,n):n}const Dr=t=>t instanceof vt?{...t}:t;function ra(t,n){n=n||{};const s=Object.create(null);Object.defineProperty(s,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(y,p,m,A){return te.isPlainObject(y)&&te.isPlainObject(p)?te.merge.call({caseless:A},y,p):te.isPlainObject(p)?te.merge({},p):te.isArray(p)?p.slice():p}function l(y,p,m,A){if(te.isUndefined(p)){if(!te.isUndefined(y))return r(void 0,y,m,A)}else return r(y,p,m,A)}function o(y,p){if(!te.isUndefined(p))return r(void 0,p)}function d(y,p){if(te.isUndefined(p)){if(!te.isUndefined(y))return r(void 0,y)}else return r(void 0,p)}function c(y,p,m){if(te.hasOwnProp(n,m))return r(y,p);if(te.hasOwnProp(t,m))return r(void 0,y)}const g={url:o,method:o,data:o,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:c,headers:(y,p,m)=>l(Dr(y),Dr(p),m,!0)};return te.forEach(Object.keys({...t,...n}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const m=te.hasOwnProp(g,p)?g[p]:l,A=te.hasOwnProp(t,p)?t[p]:void 0,C=te.hasOwnProp(n,p)?n[p]:void 0,b=m(A,C,p);te.isUndefined(b)&&m!==c||(s[p]=b)}),s}const Wl=t=>{const n=ra({},t),s=A=>te.hasOwnProp(n,A)?n[A]:void 0,r=s("data");let l=s("withXSRFToken");const o=s("xsrfHeaderName"),d=s("xsrfCookieName");let c=s("headers");const g=s("auth"),y=s("baseURL"),p=s("allowAbsoluteUrls"),m=s("url");if(n.headers=c=vt.from(c),n.url=Nl(Yl(y,m,p),t.params,t.paramsSerializer),g&&c.set("Authorization","Basic "+btoa((g.username||"")+":"+(g.password?unescape(encodeURIComponent(g.password)):""))),te.isFormData(r)){if(yt.hasStandardBrowserEnv||yt.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(te.isFunction(r.getHeaders)){const A=r.getHeaders(),C=["content-type","content-length"];Object.entries(A).forEach(([b,f])=>{C.includes(b.toLowerCase())&&c.set(b,f)})}}if(yt.hasStandardBrowserEnv&&(te.isFunction(l)&&(l=l(n)),l===!0||l==null&&dc(n.url))){const C=o&&d&&cc.read(d);C&&c.set(o,C)}return n},mc=typeof XMLHttpRequest<"u",hc=mc&&function(t){return new Promise(function(s,r){const l=Wl(t);let o=l.data;const d=vt.from(l.headers).normalize();let{responseType:c,onUploadProgress:g,onDownloadProgress:y}=l,p,m,A,C,b;function f(){C&&C(),b&&b(),l.cancelToken&&l.cancelToken.unsubscribe(p),l.signal&&l.signal.removeEventListener("abort",p)}let x=new XMLHttpRequest;x.open(l.method.toUpperCase(),l.url,!0),x.timeout=l.timeout;function R(){if(!x)return;const O=vt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),D={data:!c||c==="text"||c==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:O,config:t,request:x};zl(function(h){s(h),f()},function(h){r(h),f()},D),x=null}"onloadend"in x?x.onloadend=R:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(R)},x.onabort=function(){x&&(r(new Me("Request aborted",Me.ECONNABORTED,t,x)),x=null)},x.onerror=function(_){const D=_&&_.message?_.message:"Network Error",u=new Me(D,Me.ERR_NETWORK,t,x);u.event=_||null,r(u),x=null},x.ontimeout=function(){let _=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded";const D=l.transitional||nr;l.timeoutErrorMessage&&(_=l.timeoutErrorMessage),r(new Me(_,D.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,t,x)),x=null},o===void 0&&d.setContentType(null),"setRequestHeader"in x&&te.forEach(d.toJSON(),function(_,D){x.setRequestHeader(D,_)}),te.isUndefined(l.withCredentials)||(x.withCredentials=!!l.withCredentials),c&&c!=="json"&&(x.responseType=l.responseType),y&&([A,b]=ts(y,!0),x.addEventListener("progress",A)),g&&x.upload&&([m,C]=ts(g),x.upload.addEventListener("progress",m),x.upload.addEventListener("loadend",C)),(l.cancelToken||l.signal)&&(p=O=>{x&&(r(!O||O.type?new cn(null,t,x):O),x.abort(),x=null)},l.cancelToken&&l.cancelToken.subscribe(p),l.signal&&(l.signal.aborted?p():l.signal.addEventListener("abort",p)));const k=ic(l.url);if(k&&yt.protocols.indexOf(k)===-1){r(new Me("Unsupported protocol "+k+":",Me.ERR_BAD_REQUEST,t));return}x.send(o||null)})},fc=(t,n)=>{const{length:s}=t=t?t.filter(Boolean):[];if(n||s){let r=new AbortController,l;const o=function(y){if(!l){l=!0,c();const p=y instanceof Error?y:this.reason;r.abort(p instanceof Me?p:new cn(p instanceof Error?p.message:p))}};let d=n&&setTimeout(()=>{d=null,o(new Me(`timeout of ${n}ms exceeded`,Me.ETIMEDOUT))},n);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(y=>{y.unsubscribe?y.unsubscribe(o):y.removeEventListener("abort",o)}),t=null)};t.forEach(y=>y.addEventListener("abort",o));const{signal:g}=r;return g.unsubscribe=()=>te.asap(c),g}},yc=function*(t,n){let s=t.byteLength;if(s<n){yield t;return}let r=0,l;for(;r<s;)l=r+n,yield t.slice(r,l),r=l},gc=async function*(t,n){for await(const s of xc(t))yield*yc(s,n)},xc=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const n=t.getReader();try{for(;;){const{done:s,value:r}=await n.read();if(s)break;yield r}}finally{await n.cancel()}},Tr=(t,n,s,r)=>{const l=gc(t,n);let o=0,d,c=g=>{d||(d=!0,r&&r(g))};return new ReadableStream({async pull(g){try{const{done:y,value:p}=await l.next();if(y){c(),g.close();return}let m=p.byteLength;if(s){let A=o+=m;s(A)}g.enqueue(new Uint8Array(p))}catch(y){throw c(y),y}},cancel(g){return c(g),l.return()}},{highWaterMark:2})},Rr=64*1024,{isFunction:bn}=te,bc=(({Request:t,Response:n})=>({Request:t,Response:n}))(te.global),{ReadableStream:Ir,TextEncoder:kr}=te.global,Pr=(t,...n)=>{try{return!!t(...n)}catch{return!1}},jc=t=>{t=te.merge.call({skipUndefined:!0},bc,t);const{fetch:n,Request:s,Response:r}=t,l=n?bn(n):typeof fetch=="function",o=bn(s),d=bn(r);if(!l)return!1;const c=l&&bn(Ir),g=l&&(typeof kr=="function"?(b=>f=>b.encode(f))(new kr):async b=>new Uint8Array(await new s(b).arrayBuffer())),y=o&&c&&Pr(()=>{let b=!1;const f=new s(yt.origin,{body:new Ir,method:"POST",get duplex(){return b=!0,"half"}}),x=f.headers.has("Content-Type");return f.body!=null&&f.body.cancel(),b&&!x}),p=d&&c&&Pr(()=>te.isReadableStream(new r("").body)),m={stream:p&&(b=>b.body)};l&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!m[b]&&(m[b]=(f,x)=>{let R=f&&f[b];if(R)return R.call(f);throw new Me(`Response type '${b}' is not supported`,Me.ERR_NOT_SUPPORT,x)})});const A=async b=>{if(b==null)return 0;if(te.isBlob(b))return b.size;if(te.isSpecCompliantForm(b))return(await new s(yt.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(te.isArrayBufferView(b)||te.isArrayBuffer(b))return b.byteLength;if(te.isURLSearchParams(b)&&(b=b+""),te.isString(b))return(await g(b)).byteLength},C=async(b,f)=>{const x=te.toFiniteNumber(b.getContentLength());return x??A(f)};return async b=>{let{url:f,method:x,data:R,signal:k,cancelToken:O,timeout:_,onDownloadProgress:D,onUploadProgress:u,responseType:h,headers:S,withCredentials:E="same-origin",fetchOptions:$}=Wl(b),q=n||fetch;h=h?(h+"").toLowerCase():"text";let T=fc([k,O&&O.toAbortSignal()],_),F=null;const j=T&&T.unsubscribe&&(()=>{T.unsubscribe()});let P;try{if(u&&y&&x!=="get"&&x!=="head"&&(P=await C(S,R))!==0){let U=new s(f,{method:"POST",body:R,duplex:"half"}),M;if(te.isFormData(R)&&(M=U.headers.get("content-type"))&&S.setContentType(M),U.body){const[L,z]=Cr(P,ts(Ar(u)));R=Tr(U.body,Rr,L,z)}}te.isString(E)||(E=E?"include":"omit");const I=o&&"credentials"in s.prototype;if(te.isFormData(R)){const U=S.getContentType();U&&/^multipart\/form-data/i.test(U)&&!/boundary=/i.test(U)&&S.delete("content-type")}const N={...$,signal:T,method:x.toUpperCase(),headers:S.normalize().toJSON(),body:R,duplex:"half",credentials:I?E:void 0};F=o&&new s(f,N);let W=await(o?q(F,$):q(f,N));const Y=p&&(h==="stream"||h==="response");if(p&&(D||Y&&j)){const U={};["status","statusText","headers"].forEach(ne=>{U[ne]=W[ne]});const M=te.toFiniteNumber(W.headers.get("content-length")),[L,z]=D&&Cr(M,ts(Ar(D),!0))||[];W=new r(Tr(W.body,Rr,L,()=>{z&&z(),j&&j()}),U)}h=h||"text";let B=await m[te.findKey(m,h)||"text"](W,b);return!Y&&j&&j(),await new Promise((U,M)=>{zl(U,M,{data:B,headers:vt.from(W.headers),status:W.status,statusText:W.statusText,config:b,request:F})})}catch(I){throw j&&j(),I&&I.name==="TypeError"&&/Load failed|fetch/i.test(I.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,b,F,I&&I.response),{cause:I.cause||I}):Me.from(I,I&&I.code,b,F,I&&I.response)}}},Sc=new Map,Vl=t=>{let n=t&&t.env||{};const{fetch:s,Request:r,Response:l}=n,o=[r,l,s];let d=o.length,c=d,g,y,p=Sc;for(;c--;)g=o[c],y=p.get(g),y===void 0&&p.set(g,y=c?new Map:jc(n)),p=y;return y};Vl();const rr={http:Ed,xhr:hc,fetch:{get:Vl}};te.forEach(rr,(t,n)=>{if(t){try{Object.defineProperty(t,"name",{value:n})}catch{}Object.defineProperty(t,"adapterName",{value:n})}});const Or=t=>`- ${t}`,vc=t=>te.isFunction(t)||t===null||t===!1;function wc(t,n){t=te.isArray(t)?t:[t];const{length:s}=t;let r,l;const o={};for(let d=0;d<s;d++){r=t[d];let c;if(l=r,!vc(r)&&(l=rr[(c=String(r)).toLowerCase()],l===void 0))throw new Me(`Unknown adapter '${c}'`);if(l&&(te.isFunction(l)||(l=l.get(n))))break;o[c||"#"+d]=l}if(!l){const d=Object.entries(o).map(([g,y])=>`adapter ${g} `+(y===!1?"is not supported by the environment":"is not available in the build"));let c=s?d.length>1?`since :
|
|
4
|
-
`+d.map(
|
|
5
|
-
`):" "+
|
|
6
|
-
`);return d===-1?"":
|
|
7
|
-
`),c=d===-1?-1:
|
|
8
|
-
`,d+1),
|
|
9
|
-
`+o)}}catch{}}throw r}}_request(n,s){typeof n=="string"?(s=s||{},s.url=n):s=n||{},s=ra(this.defaults,s);const{transitional:r,paramsSerializer:l,headers:o}=s;r!==void 0&&Bn.assertOptions(r,{silentJSONParsing:Rt.transitional(Rt.boolean),forcedJSONParsing:Rt.transitional(Rt.boolean),clarifyTimeoutError:Rt.transitional(Rt.boolean),legacyInterceptorReqResOrdering:Rt.transitional(Rt.boolean)},!1),l!=null&&(te.isFunction(l)?s.paramsSerializer={serialize:l}:Bn.assertOptions(l,{encode:Rt.function,serialize:Rt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),Bn.assertOptions(s,{baseUrl:Rt.spelling("baseURL"),withXsrfToken:Rt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let d=o&&te.merge(o.common,o[s.method]);o&&te.forEach(["delete","get","head","post","put","patch","common"],b=>{delete o[b]}),s.headers=vt.concat(d,o);const c=[];let g=!0;this.interceptors.request.forEach(function(f){if(typeof f.runWhen=="function"&&f.runWhen(s)===!1)return;g=g&&f.synchronous;const x=s.transitional||nr;x&&x.legacyInterceptorReqResOrdering?c.unshift(f.fulfilled,f.rejected):c.push(f.fulfilled,f.rejected)});const y=[];this.interceptors.response.forEach(function(f){y.push(f.fulfilled,f.rejected)});let p,m=0,A;if(!g){const b=[Mr.bind(this),void 0];for(b.unshift(...c),b.push(...y),A=b.length,p=Promise.resolve(s);m<A;)p=p.then(b[m++],b[m++]);return p}A=c.length;let C=s;for(;m<A;){const b=c[m++],f=c[m++];try{C=b(C)}catch(x){f.call(this,x);break}}try{p=Mr.call(this,C)}catch(b){return Promise.reject(b)}for(m=0,A=y.length;m<A;)p=p.then(y[m++],y[m++]);return p}getUri(n){n=ra(this.defaults,n);const s=Yl(n.baseURL,n.url,n.allowAbsoluteUrls);return Nl(s,n.params,n.paramsSerializer)}};te.forEach(["delete","get","head","options"],function(n){aa.prototype[n]=function(s,r){return this.request(ra(r||{},{method:n,url:s,data:(r||{}).data}))}});te.forEach(["post","put","patch"],function(n){function s(r){return function(o,d,c){return this.request(ra(c||{},{method:n,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:d}))}}aa.prototype[n]=s(),aa.prototype[n+"Form"]=s(!0)});let Cc=class Gl{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(o){s=o});const r=this;this.promise.then(l=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](l);r._listeners=null}),this.promise.then=l=>{let o;const d=new Promise(c=>{r.subscribe(c),o=c}).then(l);return d.cancel=function(){r.unsubscribe(o)},d},n(function(o,d,c){r.reason||(r.reason=new cn(o,d,c),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const s=this._listeners.indexOf(n);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const n=new AbortController,s=r=>{n.abort(r)};return this.subscribe(s),n.signal.unsubscribe=()=>this.unsubscribe(s),n.signal}static source(){let n;return{token:new Gl(function(l){n=l}),cancel:n}}};function Ac(t){return function(s){return t.apply(null,s)}}function Dc(t){return te.isObject(t)&&t.isAxiosError===!0}const Qs={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(Qs).forEach(([t,n])=>{Qs[n]=t});function Jl(t){const n=new aa(t),s=Rl(aa.prototype.request,n);return te.extend(s,aa.prototype,n,{allOwnKeys:!0}),te.extend(s,n,null,{allOwnKeys:!0}),s.create=function(l){return Jl(ra(t,l))},s}const Xe=Jl(dn);Xe.Axios=aa;Xe.CanceledError=cn;Xe.CancelToken=Cc;Xe.isCancel=ql;Xe.VERSION=Kl;Xe.toFormData=is;Xe.AxiosError=Me;Xe.Cancel=Xe.CanceledError;Xe.all=function(n){return Promise.all(n)};Xe.spread=Ac;Xe.isAxiosError=Dc;Xe.mergeConfig=ra;Xe.AxiosHeaders=vt;Xe.formToJSON=t=>Ll(te.isHTMLForm(t)?new FormData(t):t);Xe.getAdapter=Hl.getAdapter;Xe.HttpStatusCode=Qs;Xe.default=Xe;const{Axios:tj,AxiosError:aj,CanceledError:nj,isCancel:sj,CancelToken:rj,VERSION:ij,all:lj,Cancel:oj,isAxiosError:dj,spread:cj,toFormData:uj,AxiosHeaders:pj,HttpStatusCode:mj,formToJSON:hj,getAdapter:fj,mergeConfig:yj}=Xe,Tc=()=>new Promise(t=>setTimeout(()=>t(),800));let Xs=null;const Rc=t=>{Xs=t,ht.defaults.baseURL=ir()},ir=()=>Xs||"https://npmapi.ubkerp.com/",ht=Xe.create({baseURL:ir()}),At=()=>ir();let Zs=null;const Ic=t=>{Zs=t},at=()=>Zs||"https://image.ubkerp.com",kc=t=>{if(!t||typeof t!="string")return null;const n=t.split(".");if(n.length<2)return null;try{let s=n[1];s=s.replace(/-/g,"+").replace(/_/g,"/");const r=(4-s.length%4)%4;s+="=".repeat(r);const l=typeof atob=="function"?atob(s):Buffer.from(s,"base64").toString("binary");return JSON.parse(l)}catch{return null}},qt=t=>{const n=kc(t);return n?n?.branch_id??n?.branchID??n?.fk_branchID??n?.branch??null:null},Ge=async(t,n,s)=>{const r=await ht.post(t,n,{headers:{Authorization:s}});if(console.log("ddddfdfdfd",r.data?.Status),r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},Ca=async(t,n,s)=>{const r=n instanceof FormData;return(await ht.post(t,n,{headers:{Authorization:s,...r?{"Content-type":"multipart/form-data"}:{}}})).data},G=async(t,n)=>{try{const s=(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}})();let r=t;if(!t.includes("session_id")&&s){const o=t.includes("?")?"&":"?";r=`${t}${o}session_id=${s}`}return(await ht.get(r,{headers:{Authorization:n}})).data}catch(s){throw s.response?.status===401&&console.error("401 Unauthorized"),s}},Pc=async(t,n)=>{const s=await ht.post(t,"",{headers:{Authorization:n}});if(s.data?.Status=="Success")return s?.data?.data||s?.data;throw new Error(s.data?.msg)},Oc=async(t,n,s)=>{const r=await ht.post(t,n,{headers:{Authorization:s}});if(console.log("ddddfdfdfd",r.data),r.data?.Status=="Success")return!0;throw new Error(r.data?.msg)},os=async(t,n,s)=>{try{const r=await ht.post(t,n,{headers:{Authorization:s,"Content-Type":"application/json"}});return r.data?.Status==="Success"?r.data:(v.error(r.data?.msg||"Unable to issue library book",{duration:2e3}),!1)}catch(r){throw v.error(r.response?.data?.msg||r.response?.data?.message||"Request failed",{duration:2e3}),r}},an=async(t,n,s)=>{const r=n?.arg;return(await ht.post(t,r,{headers:{Authorization:s}}))?.data},na=async(t,n,s)=>{const r=n?.arg,l=t.includes("?")?"&":"?";return(await ht.get(t+l,{params:r,headers:{Authorization:s}}))?.data},Mc="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",lr=async(t,n,s)=>{const r=n?.arg,l=t.includes("?")?"&":"?",o=await ht.get(t+l,{params:r,headers:{Authorization:s}});if(console.log("ddddfdfdfd",o.data?.Status),o.data?.Status=="Success")return o?.data?.data||o?.data;throw new Error(o.data?.msg)},tt=async(t,n,s)=>(await Tc(),(await ht.post(t,n,{headers:{Authorization:s}}))?.data),Ra=async(t,n,s)=>(await ht.post(t,n,{headers:{Authorization:s}})).data,Ze=async(t,n,s)=>(await ht.delete(`${t}/${n}`,{headers:{Authorization:s}})).data,Ec="api/report/LibraryRenewalReport/renewalHistory",Fc="api/report/LibraryRenewalReport/renewalFineReport",$c="api/report/LibraryRenewalReport/currentlyRenewedBooks",Uc="api/report/LibraryRenewalReport/upcomingRenewalDue",Bc="api/report/LibraryRenewalReport/overdueRenewalReport",Nc="api/report/LibraryRenewalReport/renewalLimitReport",Lc="api/report/LibraryRenewalReport/renewalStatusReport",qc="api/report/LibraryRenewalReport/studentWiseReport",zc="api/report/LibraryRenewalReport/bookWiseReport",Yc="api/report/LibraryRenewalReport/classWiseReport",Wc="api/report/LibraryRenewalReport/staffWiseReport",Vc="api/report/LibraryRenewalReport/renewalStatisticsByDate",Hc="/sample_templates/route_upload.xlsx",un="api/branchapi/academy/classdropdownlist",pn="api/branchapi/academy/sectionoftheClass",Kc="/sample_templates/student_transport_upload.xlsx",Gc="api/branchapi/income/incomeTableList",Jc="api/branchapi/income/addincome",Qc="api/branchapi/income/editincome",Xc="api/branchapi/income/deleteincome",Ql="api/branchapi/income/incomeheadDropdown",Zc="api/branchapi/income/incomeheadTableList",eu="api/branchapi/income/addincomehead",tu="api/branchapi/income/editincomehead",au="api/branchapi/income/deleteincomehead",nu="api/branchapi/income/incomeShowdata",su="api/branchapi/income/incomeheadShowdata",ru="api/branchapi/income/searchincomebydates",iu="api/branchapi/expense/expenseTableList",lu="api/branchapi/expense/addexpense",ou="api/branchapi/expense/editexpense",du="api/branchapi/expense/deleteExpense",Xl="api/branchapi/expense/expenseheadDropdown",cu="api/branchapi/expense/expenseheadTableList",uu="api/branchapi/expense/addexpensehead",pu="api/branchapi/expense/editexpensehead",mu="api/branchapi/expense/deleteexpensehead",hu="api/branchapi/expense/expenseShowdata",fu="api/branchapi/expense/expenseVoucherbyID",yu="api/branchapi/expense/expenseheadShowdata",gu="api/branchapi/expense/searchexpensebydates",Zl="api/accounts/vendor/vendorlist",xu="api/student/studentDetails/studentLoginCredentialList",eo="/branchapi/student/studentlist",to="api/branchapi/student/studentsearchbyKeywords",ao="api/branchapi/student/studentsearchbyClassSection",bu="/branchapi/student/addStudentMedicineDetails",ju="/branchapi/student/StudentMedicineDetails",no="/branchapi/academy/getstudentClasssubjectByStudentId",Su="/branchapi/academy/removeAssignStudentSubject",er="/branchapi/feesCollection/extraCurricularActivitiesFess",vu="/branchapi/academy/unAssigneStudentSubject",wu="/branchapi/student/uploadstudentbyCSV",_u="api/branchapi/academy/categorytableList",Cu="api/branchapi/transport/downloadBulkTemplate",Au="api/branchapi/transport/validateBulkUpload",Du="api/branchapi/transport/confirmBulkImport",Tu="api/branchapi/transport/downloadBulkErrorReport",Ru=async({class_id:t,section_id:n}={},s)=>{const r=new URLSearchParams;t&&r.append("class_id",t),n&&r.append("section_id",n);const l=`${Cu}${r.toString()?`?${r.toString()}`:""}`;return(await ht.get(l,{headers:{Authorization:s},responseType:"blob"})).data},Iu=async(t,n)=>{const s=new FormData;return s.append("file",t),(await ht.post(Au,s,{headers:{Authorization:n,"Content-Type":"multipart/form-data"}})).data},ku=async(t,n,s="skip")=>(await ht.post(Du,{rows:t,duplicate_action:s},{headers:{Authorization:n,"Content-Type":"application/json"}})).data,Pu=async(t,n)=>(await ht.post(Tu,{rows:t},{headers:{Authorization:n,"Content-Type":"application/json"},responseType:"blob"})).data,Ou=({token:t,menu:n})=>{const{isLoading:s,data:r}=K(t?["api/sdk/Menus",t]:null,([o,d])=>Pc(o,d)),l=r?.find(o=>o.path===n)?.sub_menu??[];return console.log("menuData",r),e.jsx(a.Row,{gutter:[16,16],children:l?.map((o,d)=>o.dashboard_show==="YES"?e.jsx(a.Col,{xs:24,md:8,lg:8,children:e.jsx(w,{children:e.jsx(Tl,{icon:`${At()}icons/frontoffice/${o.icons}`,title:o.submenu_name,path:o.menu_key})})},`${d}office001`):null)})};function so(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ct={},ws,Fr;function Mu(){return Fr||(Fr=1,ws=function t(n,s){if(n===s)return!0;if(n&&s&&typeof n=="object"&&typeof s=="object"){if(n.constructor!==s.constructor)return!1;var r,l,o;if(Array.isArray(n)){if(r=n.length,r!=s.length)return!1;for(l=r;l--!==0;)if(!t(n[l],s[l]))return!1;return!0}if(n.constructor===RegExp)return n.source===s.source&&n.flags===s.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===s.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===s.toString();if(o=Object.keys(n),r=o.length,r!==Object.keys(s).length)return!1;for(l=r;l--!==0;)if(!Object.prototype.hasOwnProperty.call(s,o[l]))return!1;for(l=r;l--!==0;){var d=o[l];if(!t(n[d],s[d]))return!1}return!0}return n!==n&&s!==s}),ws}var jn={exports:{}},Sn={exports:{}},We={};var $r;function Eu(){if($r)return We;$r=1;var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,l=t?Symbol.for("react.strict_mode"):60108,o=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,m=t?Symbol.for("react.suspense"):60113,A=t?Symbol.for("react.suspense_list"):60120,C=t?Symbol.for("react.memo"):60115,b=t?Symbol.for("react.lazy"):60116,f=t?Symbol.for("react.block"):60121,x=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,k=t?Symbol.for("react.scope"):60119;function O(D){if(typeof D=="object"&&D!==null){var u=D.$$typeof;switch(u){case n:switch(D=D.type,D){case g:case y:case r:case o:case l:case m:return D;default:switch(D=D&&D.$$typeof,D){case c:case p:case b:case C:case d:return D;default:return u}}case s:return u}}}function _(D){return O(D)===y}return We.AsyncMode=g,We.ConcurrentMode=y,We.ContextConsumer=c,We.ContextProvider=d,We.Element=n,We.ForwardRef=p,We.Fragment=r,We.Lazy=b,We.Memo=C,We.Portal=s,We.Profiler=o,We.StrictMode=l,We.Suspense=m,We.isAsyncMode=function(D){return _(D)||O(D)===g},We.isConcurrentMode=_,We.isContextConsumer=function(D){return O(D)===c},We.isContextProvider=function(D){return O(D)===d},We.isElement=function(D){return typeof D=="object"&&D!==null&&D.$$typeof===n},We.isForwardRef=function(D){return O(D)===p},We.isFragment=function(D){return O(D)===r},We.isLazy=function(D){return O(D)===b},We.isMemo=function(D){return O(D)===C},We.isPortal=function(D){return O(D)===s},We.isProfiler=function(D){return O(D)===o},We.isStrictMode=function(D){return O(D)===l},We.isSuspense=function(D){return O(D)===m},We.isValidElementType=function(D){return typeof D=="string"||typeof D=="function"||D===r||D===y||D===o||D===l||D===m||D===A||typeof D=="object"&&D!==null&&(D.$$typeof===b||D.$$typeof===C||D.$$typeof===d||D.$$typeof===c||D.$$typeof===p||D.$$typeof===x||D.$$typeof===R||D.$$typeof===k||D.$$typeof===f)},We.typeOf=O,We}var Ve={};var Ur;function Fu(){return Ur||(Ur=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,l=t?Symbol.for("react.strict_mode"):60108,o=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,m=t?Symbol.for("react.suspense"):60113,A=t?Symbol.for("react.suspense_list"):60120,C=t?Symbol.for("react.memo"):60115,b=t?Symbol.for("react.lazy"):60116,f=t?Symbol.for("react.block"):60121,x=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,k=t?Symbol.for("react.scope"):60119;function O(le){return typeof le=="string"||typeof le=="function"||le===r||le===y||le===o||le===l||le===m||le===A||typeof le=="object"&&le!==null&&(le.$$typeof===b||le.$$typeof===C||le.$$typeof===d||le.$$typeof===c||le.$$typeof===p||le.$$typeof===x||le.$$typeof===R||le.$$typeof===k||le.$$typeof===f)}function _(le){if(typeof le=="object"&&le!==null){var ue=le.$$typeof;switch(ue){case n:var oe=le.type;switch(oe){case g:case y:case r:case o:case l:case m:return oe;default:var Ce=oe&&oe.$$typeof;switch(Ce){case c:case p:case b:case C:case d:return Ce;default:return ue}}case s:return ue}}}var D=g,u=y,h=c,S=d,E=n,$=p,q=r,T=b,F=C,j=s,P=o,I=l,N=m,W=!1;function Y(le){return W||(W=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),B(le)||_(le)===g}function B(le){return _(le)===y}function U(le){return _(le)===c}function M(le){return _(le)===d}function L(le){return typeof le=="object"&&le!==null&&le.$$typeof===n}function z(le){return _(le)===p}function ne(le){return _(le)===r}function X(le){return _(le)===b}function J(le){return _(le)===C}function H(le){return _(le)===s}function Q(le){return _(le)===o}function ce(le){return _(le)===l}function De(le){return _(le)===m}Ve.AsyncMode=D,Ve.ConcurrentMode=u,Ve.ContextConsumer=h,Ve.ContextProvider=S,Ve.Element=E,Ve.ForwardRef=$,Ve.Fragment=q,Ve.Lazy=T,Ve.Memo=F,Ve.Portal=j,Ve.Profiler=P,Ve.StrictMode=I,Ve.Suspense=N,Ve.isAsyncMode=Y,Ve.isConcurrentMode=B,Ve.isContextConsumer=U,Ve.isContextProvider=M,Ve.isElement=L,Ve.isForwardRef=z,Ve.isFragment=ne,Ve.isLazy=X,Ve.isMemo=J,Ve.isPortal=H,Ve.isProfiler=Q,Ve.isStrictMode=ce,Ve.isSuspense=De,Ve.isValidElementType=O,Ve.typeOf=_})()),Ve}var Br;function ro(){return Br||(Br=1,process.env.NODE_ENV==="production"?Sn.exports=Eu():Sn.exports=Fu()),Sn.exports}var _s,Nr;function $u(){if(Nr)return _s;Nr=1;var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function r(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function l(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var g=Object.getOwnPropertyNames(d).map(function(p){return d[p]});if(g.join("")!=="0123456789")return!1;var y={};return"abcdefghijklmnopqrst".split("").forEach(function(p){y[p]=p}),Object.keys(Object.assign({},y)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return _s=l()?Object.assign:function(o,d){for(var c,g=r(o),y,p=1;p<arguments.length;p++){c=Object(arguments[p]);for(var m in c)n.call(c,m)&&(g[m]=c[m]);if(t){y=t(c);for(var A=0;A<y.length;A++)s.call(c,y[A])&&(g[y[A]]=c[y[A]])}}return g},_s}var Cs,Lr;function or(){if(Lr)return Cs;Lr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Cs=t,Cs}var As,qr;function io(){return qr||(qr=1,As=Function.call.bind(Object.prototype.hasOwnProperty)),As}var Ds,zr;function Uu(){if(zr)return Ds;zr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=or(),s={},r=io();t=function(o){var d="Warning: "+o;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function l(o,d,c,g,y){if(process.env.NODE_ENV!=="production"){for(var p in o)if(r(o,p)){var m;try{if(typeof o[p]!="function"){var A=Error((g||"React class")+": "+c+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw A.name="Invariant Violation",A}m=o[p](d,p,g,c,null,n)}catch(b){m=b}if(m&&!(m instanceof Error)&&t((g||"React class")+": type specification of "+c+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in s)){s[m.message]=!0;var C=y?y():"";t("Failed "+c+" type: "+m.message+(C??""))}}}}return l.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(s={})},Ds=l,Ds}var Ts,Yr;function Bu(){if(Yr)return Ts;Yr=1;var t=ro(),n=$u(),s=or(),r=io(),l=Uu(),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(c){var g="Warning: "+c;typeof console<"u"&&console.error(g);try{throw new Error(g)}catch{}});function d(){return null}return Ts=function(c,g){var y=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function m(B){var U=B&&(y&&B[y]||B[p]);if(typeof U=="function")return U}var A="<<anonymous>>",C={array:R("array"),bigint:R("bigint"),bool:R("boolean"),func:R("function"),number:R("number"),object:R("object"),string:R("string"),symbol:R("symbol"),any:k(),arrayOf:O,element:_(),elementType:D(),instanceOf:u,node:$(),objectOf:S,oneOf:h,oneOfType:E,shape:T,exact:F};function b(B,U){return B===U?B!==0||1/B===1/U:B!==B&&U!==U}function f(B,U){this.message=B,this.data=U&&typeof U=="object"?U:{},this.stack=""}f.prototype=Error.prototype;function x(B){if(process.env.NODE_ENV!=="production")var U={},M=0;function L(ne,X,J,H,Q,ce,De){if(H=H||A,ce=ce||J,De!==s){if(g){var le=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw le.name="Invariant Violation",le}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ue=H+":"+J;!U[ue]&&M<3&&(o("You are manually calling a React.PropTypes validation function for the `"+ce+"` prop on `"+H+"`. 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."),U[ue]=!0,M++)}}return X[J]==null?ne?X[J]===null?new f("The "+Q+" `"+ce+"` is marked as required "+("in `"+H+"`, but its value is `null`.")):new f("The "+Q+" `"+ce+"` is marked as required in "+("`"+H+"`, but its value is `undefined`.")):null:B(X,J,H,Q,ce)}var z=L.bind(null,!1);return z.isRequired=L.bind(null,!0),z}function R(B){function U(M,L,z,ne,X,J){var H=M[L],Q=I(H);if(Q!==B){var ce=N(H);return new f("Invalid "+ne+" `"+X+"` of type "+("`"+ce+"` supplied to `"+z+"`, expected ")+("`"+B+"`."),{expectedType:B})}return null}return x(U)}function k(){return x(d)}function O(B){function U(M,L,z,ne,X){if(typeof B!="function")return new f("Property `"+X+"` of component `"+z+"` has invalid PropType notation inside arrayOf.");var J=M[L];if(!Array.isArray(J)){var H=I(J);return new f("Invalid "+ne+" `"+X+"` of type "+("`"+H+"` supplied to `"+z+"`, expected an array."))}for(var Q=0;Q<J.length;Q++){var ce=B(J,Q,z,ne,X+"["+Q+"]",s);if(ce instanceof Error)return ce}return null}return x(U)}function _(){function B(U,M,L,z,ne){var X=U[M];if(!c(X)){var J=I(X);return new f("Invalid "+z+" `"+ne+"` of type "+("`"+J+"` supplied to `"+L+"`, expected a single ReactElement."))}return null}return x(B)}function D(){function B(U,M,L,z,ne){var X=U[M];if(!t.isValidElementType(X)){var J=I(X);return new f("Invalid "+z+" `"+ne+"` of type "+("`"+J+"` supplied to `"+L+"`, expected a single ReactElement type."))}return null}return x(B)}function u(B){function U(M,L,z,ne,X){if(!(M[L]instanceof B)){var J=B.name||A,H=Y(M[L]);return new f("Invalid "+ne+" `"+X+"` of type "+("`"+H+"` supplied to `"+z+"`, expected ")+("instance of `"+J+"`."))}return null}return x(U)}function h(B){if(!Array.isArray(B))return process.env.NODE_ENV!=="production"&&(arguments.length>1?o("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):o("Invalid argument supplied to oneOf, expected an array.")),d;function U(M,L,z,ne,X){for(var J=M[L],H=0;H<B.length;H++)if(b(J,B[H]))return null;var Q=JSON.stringify(B,function(De,le){var ue=N(le);return ue==="symbol"?String(le):le});return new f("Invalid "+ne+" `"+X+"` of value `"+String(J)+"` "+("supplied to `"+z+"`, expected one of "+Q+"."))}return x(U)}function S(B){function U(M,L,z,ne,X){if(typeof B!="function")return new f("Property `"+X+"` of component `"+z+"` has invalid PropType notation inside objectOf.");var J=M[L],H=I(J);if(H!=="object")return new f("Invalid "+ne+" `"+X+"` of type "+("`"+H+"` supplied to `"+z+"`, expected an object."));for(var Q in J)if(r(J,Q)){var ce=B(J,Q,z,ne,X+"."+Q,s);if(ce instanceof Error)return ce}return null}return x(U)}function E(B){if(!Array.isArray(B))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var U=0;U<B.length;U++){var M=B[U];if(typeof M!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+W(M)+" at index "+U+"."),d}function L(z,ne,X,J,H){for(var Q=[],ce=0;ce<B.length;ce++){var De=B[ce],le=De(z,ne,X,J,H,s);if(le==null)return null;le.data&&r(le.data,"expectedType")&&Q.push(le.data.expectedType)}var ue=Q.length>0?", expected one of type ["+Q.join(", ")+"]":"";return new f("Invalid "+J+" `"+H+"` supplied to "+("`"+X+"`"+ue+"."))}return x(L)}function $(){function B(U,M,L,z,ne){return j(U[M])?null:new f("Invalid "+z+" `"+ne+"` supplied to "+("`"+L+"`, expected a ReactNode."))}return x(B)}function q(B,U,M,L,z){return new f((B||"React class")+": "+U+" type `"+M+"."+L+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+z+"`.")}function T(B){function U(M,L,z,ne,X){var J=M[L],H=I(J);if(H!=="object")return new f("Invalid "+ne+" `"+X+"` of type `"+H+"` "+("supplied to `"+z+"`, expected `object`."));for(var Q in B){var ce=B[Q];if(typeof ce!="function")return q(z,ne,X,Q,N(ce));var De=ce(J,Q,z,ne,X+"."+Q,s);if(De)return De}return null}return x(U)}function F(B){function U(M,L,z,ne,X){var J=M[L],H=I(J);if(H!=="object")return new f("Invalid "+ne+" `"+X+"` of type `"+H+"` "+("supplied to `"+z+"`, expected `object`."));var Q=n({},M[L],B);for(var ce in Q){var De=B[ce];if(r(B,ce)&&typeof De!="function")return q(z,ne,X,ce,N(De));if(!De)return new f("Invalid "+ne+" `"+X+"` key `"+ce+"` supplied to `"+z+"`.\nBad object: "+JSON.stringify(M[L],null," ")+`
|
|
10
|
-
Valid keys: `+JSON.stringify(Object.keys(B),null," "));var le=De(J,ce,z,ne,X+"."+ce,s);if(le)return le}return null}return x(U)}function j(B){switch(typeof B){case"number":case"string":case"undefined":return!0;case"boolean":return!B;case"object":if(Array.isArray(B))return B.every(j);if(B===null||c(B))return!0;var U=m(B);if(U){var M=U.call(B),L;if(U!==B.entries){for(;!(L=M.next()).done;)if(!j(L.value))return!1}else for(;!(L=M.next()).done;){var z=L.value;if(z&&!j(z[1]))return!1}}else return!1;return!0;default:return!1}}function P(B,U){return B==="symbol"?!0:U?U["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&U instanceof Symbol:!1}function I(B){var U=typeof B;return Array.isArray(B)?"array":B instanceof RegExp?"object":P(U,B)?"symbol":U}function N(B){if(typeof B>"u"||B===null)return""+B;var U=I(B);if(U==="object"){if(B instanceof Date)return"date";if(B instanceof RegExp)return"regexp"}return U}function W(B){var U=N(B);switch(U){case"array":case"object":return"an "+U;case"boolean":case"date":case"regexp":return"a "+U;default:return U}}function Y(B){return!B.constructor||!B.constructor.name?A:B.constructor.name}return C.checkPropTypes=l,C.resetWarningCache=l.resetWarningCache,C.PropTypes=C,C},Ts}var Rs,Wr;function Nu(){if(Wr)return Rs;Wr=1;var t=or();function n(){}function s(){}return s.resetWarningCache=n,Rs=function(){function r(d,c,g,y,p,m){if(m!==t){var A=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw A.name="Invariant Violation",A}}r.isRequired=r;function l(){return r}var o={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:l,element:r,elementType:r,instanceOf:l,node:r,objectOf:l,oneOf:l,oneOfType:l,shape:l,exact:l,checkPropTypes:s,resetWarningCache:n};return o.PropTypes=o,o},Rs}var Vr;function lo(){if(Vr)return jn.exports;if(Vr=1,process.env.NODE_ENV!=="production"){var t=ro(),n=!0;jn.exports=Bu()(t.isElement,n)}else jn.exports=Nu()();return jn.exports}var Hr;function Lu(){if(Hr)return ct;Hr=1;var t=ct&&ct.__extends||(function(){var C=function(b,f){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,R){x.__proto__=R}||function(x,R){for(var k in R)Object.prototype.hasOwnProperty.call(R,k)&&(x[k]=R[k])},C(b,f)};return function(b,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");C(b,f);function x(){this.constructor=b}b.prototype=f===null?Object.create(f):(x.prototype=f.prototype,new x)}})(),n=ct&&ct.__assign||function(){return n=Object.assign||function(C){for(var b,f=1,x=arguments.length;f<x;f++){b=arguments[f];for(var R in b)Object.prototype.hasOwnProperty.call(b,R)&&(C[R]=b[R])}return C},n.apply(this,arguments)},s=ct&&ct.__createBinding||(Object.create?(function(C,b,f,x){x===void 0&&(x=f);var R=Object.getOwnPropertyDescriptor(b,f);(!R||("get"in R?!b.__esModule:R.writable||R.configurable))&&(R={enumerable:!0,get:function(){return b[f]}}),Object.defineProperty(C,x,R)}):(function(C,b,f,x){x===void 0&&(x=f),C[x]=b[f]})),r=ct&&ct.__setModuleDefault||(Object.create?(function(C,b){Object.defineProperty(C,"default",{enumerable:!0,value:b})}):function(C,b){C.default=b}),l=ct&&ct.__importStar||function(C){if(C&&C.__esModule)return C;var b={};if(C!=null)for(var f in C)f!=="default"&&Object.prototype.hasOwnProperty.call(C,f)&&s(b,C,f);return r(b,C),b},o=ct&&ct.__rest||function(C,b){var f={};for(var x in C)Object.prototype.hasOwnProperty.call(C,x)&&b.indexOf(x)<0&&(f[x]=C[x]);if(C!=null&&typeof Object.getOwnPropertySymbols=="function")for(var R=0,x=Object.getOwnPropertySymbols(C);R<x.length;R++)b.indexOf(x[R])<0&&Object.prototype.propertyIsEnumerable.call(C,x[R])&&(f[x[R]]=C[x[R]]);return f},d=ct&&ct.__importDefault||function(C){return C&&C.__esModule?C:{default:C}};Object.defineProperty(ct,"__esModule",{value:!0});var c=l(i),g=d(Mu()),y=l(lo());function p(C){return C&&C.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function m(C){var b=document.createTextNode("");C.appendChild(b);var f=document.activeElement===C;if(b!==null&&b.nodeValue!==null&&f){var x=window.getSelection();if(x!==null){var R=document.createRange();R.setStart(b,b.nodeValue.length),R.collapse(!0),x.removeAllRanges(),x.addRange(R)}C instanceof HTMLElement&&C.focus()}}var A=(function(C){t(b,C);function b(){var f=C!==null&&C.apply(this,arguments)||this;return f.lastHtml=f.props.html,f.el=typeof f.props.innerRef=="function"?{current:null}:c.createRef(),f.getEl=function(){return(f.props.innerRef&&typeof f.props.innerRef!="function"?f.props.innerRef:f.el).current},f.emitChange=function(x){var R=f.getEl();if(R){var k=R.innerHTML;if(f.props.onChange&&k!==f.lastHtml){var O=Object.assign({},x,{target:{value:k}});f.props.onChange(O)}f.lastHtml=k}},f}return b.prototype.render=function(){var f=this,x=this.props,R=x.tagName,k=x.html,O=x.innerRef,_=o(x,["tagName","html","innerRef"]);return c.createElement(R||"div",n(n({},_),{ref:typeof O=="function"?function(D){O(D),f.el.current=D}:O||this.el,onInput:this.emitChange,onBlur:this.props.onBlur||this.emitChange,onKeyUp:this.props.onKeyUp||this.emitChange,onKeyDown:this.props.onKeyDown||this.emitChange,contentEditable:!this.props.disabled,dangerouslySetInnerHTML:{__html:k}}),this.props.children)},b.prototype.shouldComponentUpdate=function(f){var x=this.props,R=this.getEl();return!R||p(f.html)!==p(R.innerHTML)?!0:x.disabled!==f.disabled||x.tagName!==f.tagName||x.className!==f.className||x.innerRef!==f.innerRef||x.placeholder!==f.placeholder||!(0,g.default)(x.style,f.style)},b.prototype.componentDidUpdate=function(){var f=this.getEl();f&&(this.props.html!==f.innerHTML&&(f.innerHTML=this.props.html),this.lastHtml=this.props.html,m(f))},b.propTypes={html:y.string.isRequired,onChange:y.func,disabled:y.bool,tagName:y.string,className:y.string,style:y.object,innerRef:y.oneOfType([y.object,y.func])},b})(c.Component);return ct.default=A,ct}var qu=Lu();const oo=so(qu),zu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Yu={width:"100%",minHeight:40,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",transition:"border-color 0.2s ease"},V=i.forwardRef(({style:t,onFocus:n,onBlur:s,...r},l)=>{const[o,d]=i.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:zu,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:l,onFocus:c=>{d(!0),n?.(c)},onBlur:c=>{d(!1),s?.(c)},style:{...Yu,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})}),Kr=[{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 dr(t){const n=se().year(),s=[];for(let r=n;r>=n-t;r--)s.push({label:String(r),value:r});return s}function ut(t){switch(t){case"late":return e.jsx("span",{className:"label label-late",children:"L"});case"present":return e.jsx("span",{className:"label label-success",children:"P"});case"absent":return e.jsx("span",{className:"label label-danger",children:"A"});case"P":return e.jsx("span",{className:"monthlyLabel label-success",children:"P"});case"A":return e.jsx("span",{className:"monthlyLabel label-danger",children:"A"});case"L":return e.jsx("span",{className:"monthlyLabel label-late",children:"L"});case"W":return e.jsx("span",{className:"monthlyLabel sunday",children:"W"});case"H":return e.jsx("span",{className:"monthlyLabel holiday",children:"H"});default:return e.jsx("span",{className:"label",children:t})}}function cr(t){const n=se().year(),s=se().month();return t<n?Kr:Kr.slice(0,s+1)}function Gr(t,n){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:n});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:n});default:return e.jsx("span",{className:"monthlyLabel",children:n})}}function Wu(){return[{label:"One Time (During Admission)",value:"one_time"},{label:"One Time",value:"one_time_without_admission"},{label:"Monthly",value:"monthly"},{label:"Quarterly",value:"quarterly"},{label:"Half Yearly",value:"half_yearly"},{label:"Yearly",value:"yearly"}]}const co=t=>{switch(t){case"paid":return e.jsx("div",{style:{background:"#3cb371",color:"white",textAlign:"center"},children:"PAID"});case"due":return e.jsx("div",{style:{background:"red",color:"white",textAlign:"center"},children:"DUE"});case"partially_paid":return e.jsx("div",{style:{background:"#ff8d00",color:"white",textAlign:"center"},children:"Partially Paid"});case"Present":return e.jsx(a.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(a.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(a.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""}},Ft=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 Ma={},Ea={},Ct={},Fa={},ca={},Jr;function Vu(){if(Jr)return ca;Jr=1;var t=ca&&ca.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(ca,"__esModule",{value:!0});const n=t(i),s=Wo,r=["string","number","boolean"];function l({header:o,body:d}){const c=n.default.createElement("tr",null,o.map(y=>n.default.createElement("th",{key:y},y))),g=d.map((y,p)=>Array.isArray(y)?n.default.createElement("tr",{key:p},y.map((m,A)=>n.default.createElement("th",{key:A}," ",m," "))):y!==null&&typeof y=="object"?n.default.createElement("tr",{key:p},Object.entries(y).map(([m,A],C)=>typeof A=="object"?(console.error(`typeof ${m} is incorrect, only accept ${r.join(", ")} `),n.default.createElement("th",{key:C})):n.default.createElement("th",{key:C},n.default.createElement(n.default.Fragment,null,A)))):(console.error(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("antd"),q=require("swr"),T=require("react-hot-toast"),i=require("react"),it=require("swr/mutation"),re=require("@ant-design/icons"),ne=require("dayjs"),am=require("react-dom/server"),Ka=require("react-to-print"),jc=require("react-select"),Sc=require("react-barcode");function nm(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const fe=nm(i),sm=()=>e.jsxs(s.Card,{style:{borderRadius:16},children:[e.jsx(s.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(s.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),w=({width:t,height:a,display:n,justifyContent:r,alignItems:o,flexDirection:l,gap:d,style:c,children:h,...f})=>{const p={width:t,height:a,display:n,justifyContent:r,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:p,...f,children:h})},he=({variant:t,fontWeight:a,style:n,children:r,...o})=>{const l=a==="bold"?700:a==="light"?300:a;return t==="h1"?e.jsx(s.Typography.Title,{level:1,style:{fontWeight:l,...n},...o,children:r}):t==="h2"?e.jsx(s.Typography.Title,{level:2,style:{fontWeight:l,...n},...o,children:r}):t==="h3"?e.jsx(s.Typography.Title,{level:3,style:{fontWeight:l,...n},...o,children:r}):t==="h4"?e.jsx(s.Typography.Title,{level:4,style:{fontWeight:l,...n},...o,children:r}):t==="h5"?e.jsx(s.Typography.Title,{level:5,style:{fontWeight:l,...n},...o,children:r}):e.jsx(s.Typography.Text,{style:{fontWeight:l,...n},...o,children:r})};function wc({title:t="",icon:a="",path:n="",onClick:r}){const o=()=>{if(r){r(n);return}typeof window<"u"&&typeof n=="string"&&n.length>0&&window.location.assign(n)};return e.jsxs(s.Card,{hoverable:!0,onClick:o,style:{borderRadius:12,overflow:"hidden",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.10)"},bodyStyle:{padding:0,cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[e.jsx(w,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:a,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(w,{style:{padding:"0 12px"},children:e.jsx(s.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(w,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(he,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function vc(t,a){return function(){return t.apply(a,arguments)}}const{toString:rm}=Object.prototype,{getPrototypeOf:Ir}=Object,{iterator:Pr,toStringTag:Cc}=Symbol,Mr=(t=>a=>{const n=rm.call(a);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ea=t=>(t=t.toLowerCase(),a=>Mr(a)===t),Er=t=>a=>typeof a===t,{isArray:_n}=Array,xn=Er("undefined");function ds(t){return t!==null&&!xn(t)&&t.constructor!==null&&!xn(t.constructor)&&$t(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const _c=ea("ArrayBuffer");function im(t){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(t):a=t&&t.buffer&&_c(t.buffer),a}const om=Er("string"),$t=Er("function"),Ac=Er("number"),cs=t=>t!==null&&typeof t=="object",lm=t=>t===!0||t===!1,Qs=t=>{if(Mr(t)!=="object")return!1;const a=Ir(t);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(Cc in t)&&!(Pr in t)},dm=t=>{if(!cs(t)||ds(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},cm=ea("Date"),um=ea("File"),pm=t=>!!(t&&typeof t.uri<"u"),mm=t=>t&&typeof t.getParts<"u",hm=ea("Blob"),fm=ea("FileList"),gm=t=>cs(t)&&$t(t.pipe);function ym(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Go=ym(),Jo=typeof Go.FormData<"u"?Go.FormData:void 0,xm=t=>{if(!t)return!1;if(Jo&&t instanceof Jo)return!0;const a=Ir(t);if(!a||a===Object.prototype||!$t(t.append))return!1;const n=Mr(t);return n==="formdata"||n==="object"&&$t(t.toString)&&t.toString()==="[object FormData]"},bm=ea("URLSearchParams"),[jm,Sm,wm,vm]=["ReadableStream","Request","Response","Headers"].map(ea),Cm=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function us(t,a,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),_n(t))for(r=0,o=t.length;r<o;r++)a.call(null,t[r],r,t);else{if(ds(t))return;const l=n?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(r=0;r<d;r++)c=l[r],a.call(null,t[c],c,t)}}function Tc(t,a){if(ds(t))return null;a=a.toLowerCase();const n=Object.keys(t);let r=n.length,o;for(;r-- >0;)if(o=n[r],a===o.toLowerCase())return o;return null}const za=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Dc=t=>!xn(t)&&t!==za;function Ni(){const{caseless:t,skipUndefined:a}=Dc(this)&&this||{},n={},r=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&Tc(n,l)||l;Qs(n[d])&&Qs(o)?n[d]=Ni(n[d],o):Qs(o)?n[d]=Ni({},o):_n(o)?n[d]=o.slice():(!a||!xn(o))&&(n[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&us(arguments[o],r);return n}const _m=(t,a,n,{allOwnKeys:r}={})=>(us(a,(o,l)=>{n&&$t(o)?Object.defineProperty(t,l,{value:vc(o,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),Am=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Tm=(t,a,n,r)=>{t.prototype=Object.create(a.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:a.prototype}),n&&Object.assign(t.prototype,n)},Dm=(t,a,n,r)=>{let o,l,d;const c={};if(a=a||{},t==null)return a;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!r||r(d,t,a))&&!c[d]&&(a[d]=t[d],c[d]=!0);t=n!==!1&&Ir(t)}while(t&&(!n||n(t,a))&&t!==Object.prototype);return a},km=(t,a,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=a.length;const r=t.indexOf(a,n);return r!==-1&&r===n},Rm=t=>{if(!t)return null;if(_n(t))return t;let a=t.length;if(!Ac(a))return null;const n=new Array(a);for(;a-- >0;)n[a]=t[a];return n},Im=(t=>a=>t&&a instanceof t)(typeof Uint8Array<"u"&&Ir(Uint8Array)),Pm=(t,a)=>{const r=(t&&t[Pr]).call(t);let o;for(;(o=r.next())&&!o.done;){const l=o.value;a.call(t,l[0],l[1])}},Mm=(t,a)=>{let n;const r=[];for(;(n=t.exec(a))!==null;)r.push(n);return r},Em=ea("HTMLFormElement"),Om=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Qo=(({hasOwnProperty:t})=>(a,n)=>t.call(a,n))(Object.prototype),$m=ea("RegExp"),kc=(t,a)=>{const n=Object.getOwnPropertyDescriptors(t),r={};us(n,(o,l)=>{let d;(d=a(o,l,t))!==!1&&(r[l]=d||o)}),Object.defineProperties(t,r)},Fm=t=>{kc(t,(a,n)=>{if($t(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if($t(r)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Bm=(t,a)=>{const n={},r=o=>{o.forEach(l=>{n[l]=!0})};return _n(t)?r(t):r(String(t).split(a)),n},Lm=()=>{},Um=(t,a)=>t!=null&&Number.isFinite(t=+t)?t:a;function Nm(t){return!!(t&&$t(t.append)&&t[Cc]==="FormData"&&t[Pr])}const zm=t=>{const a=new Array(10),n=(r,o)=>{if(cs(r)){if(a.indexOf(r)>=0)return;if(ds(r))return r;if(!("toJSON"in r)){a[o]=r;const l=_n(r)?[]:{};return us(r,(d,c)=>{const h=n(d,o+1);!xn(h)&&(l[c]=h)}),a[o]=void 0,l}}return r};return n(t,0)},qm=ea("AsyncFunction"),Ym=t=>t&&(cs(t)||$t(t))&&$t(t.then)&&$t(t.catch),Rc=((t,a)=>t?setImmediate:a?((n,r)=>(za.addEventListener("message",({source:o,data:l})=>{o===za&&l===n&&r.length&&r.shift()()},!1),o=>{r.push(o),za.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",$t(za.postMessage)),Wm=typeof queueMicrotask<"u"?queueMicrotask.bind(za):typeof process<"u"&&process.nextTick||Rc,Vm=t=>t!=null&&$t(t[Pr]),ie={isArray:_n,isArrayBuffer:_c,isBuffer:ds,isFormData:xm,isArrayBufferView:im,isString:om,isNumber:Ac,isBoolean:lm,isObject:cs,isPlainObject:Qs,isEmptyObject:dm,isReadableStream:jm,isRequest:Sm,isResponse:wm,isHeaders:vm,isUndefined:xn,isDate:cm,isFile:um,isReactNativeBlob:pm,isReactNative:mm,isBlob:hm,isRegExp:$m,isFunction:$t,isStream:gm,isURLSearchParams:bm,isTypedArray:Im,isFileList:fm,forEach:us,merge:Ni,extend:_m,trim:Cm,stripBOM:Am,inherits:Tm,toFlatObject:Dm,kindOf:Mr,kindOfTest:ea,endsWith:km,toArray:Rm,forEachEntry:Pm,matchAll:Mm,isHTMLForm:Em,hasOwnProperty:Qo,hasOwnProp:Qo,reduceDescriptors:kc,freezeMethods:Fm,toObjectSet:Bm,toCamelCase:Om,noop:Lm,toFiniteNumber:Um,findKey:Tc,global:za,isContextDefined:Dc,isSpecCompliantForm:Nm,toJSONObject:zm,isAsyncFn:qm,isThenable:Ym,setImmediate:Rc,asap:Wm,isIterable:Vm};let Be=class Ic extends Error{static from(a,n,r,o,l,d){const c=new Ic(a.message,n||a.code,r,o,l);return c.cause=a,c.name=a.name,a.status!=null&&c.status==null&&(c.status=a.status),d&&Object.assign(c,d),c}constructor(a,n,r,o,l){super(a),Object.defineProperty(this,"message",{value:a,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),o&&(this.request=o),l&&(this.response=l,this.status=l.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ie.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 Hm=null;function zi(t){return ie.isPlainObject(t)||ie.isArray(t)}function Pc(t){return ie.endsWith(t,"[]")?t.slice(0,-2):t}function ni(t,a,n){return t?t.concat(a).map(function(o,l){return o=Pc(o),!n&&l?"["+o+"]":o}).join(n?".":""):a}function Km(t){return ie.isArray(t)&&!t.some(zi)}const Gm=ie.toFlatObject(ie,{},null,function(a){return/^is[A-Z]/.test(a)});function Or(t,a,n){if(!ie.isObject(t))throw new TypeError("target must be an object");a=a||new FormData,n=ie.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(b,D){return!ie.isUndefined(D[b])});const r=n.metaTokens,o=n.visitor||m,l=n.dots,d=n.indexes,c=n.Blob||typeof Blob<"u"&&Blob,h=n.maxDepth===void 0?100:n.maxDepth,f=c&&ie.isSpecCompliantForm(a);if(!ie.isFunction(o))throw new TypeError("visitor must be a function");function p(g){if(g===null)return"";if(ie.isDate(g))return g.toISOString();if(ie.isBoolean(g))return g.toString();if(!f&&ie.isBlob(g))throw new Be("Blob is not supported. Use a Buffer instead.");return ie.isArrayBuffer(g)||ie.isTypedArray(g)?f&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function m(g,b,D){let R=g;if(ie.isReactNative(a)&&ie.isReactNativeBlob(g))return a.append(ni(D,b,l),p(g)),!1;if(g&&!D&&typeof g=="object"){if(ie.endsWith(b,"{}"))b=r?b:b.slice(0,-2),g=JSON.stringify(g);else if(ie.isArray(g)&&Km(g)||(ie.isFileList(g)||ie.endsWith(b,"[]"))&&(R=ie.toArray(g)))return b=Pc(b),R.forEach(function(A,_){!(ie.isUndefined(A)||A===null)&&a.append(d===!0?ni([b],_,l):d===null?b:b+"[]",p(A))}),!1}return zi(g)?!0:(a.append(ni(D,b,l),p(g)),!1)}const v=[],S=Object.assign(Gm,{defaultVisitor:m,convertValue:p,isVisitable:zi});function y(g,b,D=0){if(!ie.isUndefined(g)){if(D>h)throw new Be("Object is too deeply nested ("+D+" levels). Max depth: "+h,Be.ERR_FORM_DATA_DEPTH_EXCEEDED);if(v.indexOf(g)!==-1)throw Error("Circular reference detected in "+b.join("."));v.push(g),ie.forEach(g,function(I,A){(!(ie.isUndefined(I)||I===null)&&o.call(a,I,ie.isString(A)?A.trim():A,b,S))===!0&&y(I,b?b.concat(A):[A],D+1)}),v.pop()}}if(!ie.isObject(t))throw new TypeError("data must be an object");return y(t),a}function Xo(t){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return a[r]})}function so(t,a){this._pairs=[],t&&Or(t,this,a)}const Mc=so.prototype;Mc.append=function(a,n){this._pairs.push([a,n])};Mc.toString=function(a){const n=a?function(r){return a.call(this,r,Xo)}:Xo;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Jm(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ec(t,a,n){if(!a)return t;const r=n&&n.encode||Jm,o=ie.isFunction(n)?{serialize:n}:n,l=o&&o.serialize;let d;if(l?d=l(a,o):d=ie.isURLSearchParams(a)?a.toString():new so(a,o).toString(r),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class Zo{constructor(){this.handlers=[]}use(a,n,r){return this.handlers.push({fulfilled:a,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){ie.forEach(this.handlers,function(r){r!==null&&a(r)})}}const ro={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Qm=typeof URLSearchParams<"u"?URLSearchParams:so,Xm=typeof FormData<"u"?FormData:null,Zm=typeof Blob<"u"?Blob:null,eh={isBrowser:!0,classes:{URLSearchParams:Qm,FormData:Xm,Blob:Zm},protocols:["http","https","file","blob","url","data"]},io=typeof window<"u"&&typeof document<"u",qi=typeof navigator=="object"&&navigator||void 0,th=io&&(!qi||["ReactNative","NativeScript","NS"].indexOf(qi.product)<0),ah=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",nh=io&&window.location.href||"http://localhost",sh=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:io,hasStandardBrowserEnv:th,hasStandardBrowserWebWorkerEnv:ah,navigator:qi,origin:nh},Symbol.toStringTag,{value:"Module"})),Dt={...sh,...eh};function rh(t,a){return Or(t,new Dt.classes.URLSearchParams,{visitor:function(n,r,o,l){return Dt.isNode&&ie.isBuffer(n)?(this.append(r,n.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...a})}function ih(t){return ie.matchAll(/\w+|\[(\w*)]/g,t).map(a=>a[0]==="[]"?"":a[1]||a[0])}function oh(t){const a={},n=Object.keys(t);let r;const o=n.length;let l;for(r=0;r<o;r++)l=n[r],a[l]=t[l];return a}function Oc(t){function a(n,r,o,l){let d=n[l++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),h=l>=n.length;return d=!d&&ie.isArray(o)?o.length:d,h?(ie.hasOwnProp(o,d)?o[d]=ie.isArray(o[d])?o[d].concat(r):[o[d],r]:o[d]=r,!c):((!o[d]||!ie.isObject(o[d]))&&(o[d]=[]),a(n,r,o[d],l)&&ie.isArray(o[d])&&(o[d]=oh(o[d])),!c)}if(ie.isFormData(t)&&ie.isFunction(t.entries)){const n={};return ie.forEachEntry(t,(r,o)=>{a(ih(r),o,n,0)}),n}return null}const en=(t,a)=>t!=null&&ie.hasOwnProp(t,a)?t[a]:void 0;function lh(t,a,n){if(ie.isString(t))try{return(a||JSON.parse)(t),ie.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const ps={transitional:ro,adapter:["xhr","http","fetch"],transformRequest:[function(a,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,l=ie.isObject(a);if(l&&ie.isHTMLForm(a)&&(a=new FormData(a)),ie.isFormData(a))return o?JSON.stringify(Oc(a)):a;if(ie.isArrayBuffer(a)||ie.isBuffer(a)||ie.isStream(a)||ie.isFile(a)||ie.isBlob(a)||ie.isReadableStream(a))return a;if(ie.isArrayBufferView(a))return a.buffer;if(ie.isURLSearchParams(a))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let c;if(l){const h=en(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return rh(a,h).toString();if((c=ie.isFileList(a))||r.indexOf("multipart/form-data")>-1){const f=en(this,"env"),p=f&&f.FormData;return Or(c?{"files[]":a}:a,p&&new p,h)}}return l||o?(n.setContentType("application/json",!1),lh(a)):a}],transformResponse:[function(a){const n=en(this,"transitional")||ps.transitional,r=n&&n.forcedJSONParsing,o=en(this,"responseType"),l=o==="json";if(ie.isResponse(a)||ie.isReadableStream(a))return a;if(a&&ie.isString(a)&&(r&&!o||l)){const c=!(n&&n.silentJSONParsing)&&l;try{return JSON.parse(a,en(this,"parseReviver"))}catch(h){if(c)throw h.name==="SyntaxError"?Be.from(h,Be.ERR_BAD_RESPONSE,this,null,en(this,"response")):h}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Dt.classes.FormData,Blob:Dt.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ie.forEach(["delete","get","head","post","put","patch"],t=>{ps.headers[t]={}});const dh=ie.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"]),ch=t=>{const a={};let n,r,o;return t&&t.split(`
|
|
2
|
+
`).forEach(function(d){o=d.indexOf(":"),n=d.substring(0,o).trim().toLowerCase(),r=d.substring(o+1).trim(),!(!n||a[n]&&dh[n])&&(n==="set-cookie"?a[n]?a[n].push(r):a[n]=[r]:a[n]=a[n]?a[n]+", "+r:r)}),a},el=Symbol("internals"),uh=/[^\x09\x20-\x7E\x80-\xFF]/g;function ph(t){let a=0,n=t.length;for(;a<n;){const r=t.charCodeAt(a);if(r!==9&&r!==32)break;a+=1}for(;n>a;){const r=t.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return a===0&&n===t.length?t:t.slice(a,n)}function On(t){return t&&String(t).trim().toLowerCase()}function mh(t){return ph(t.replace(uh,""))}function Xs(t){return t===!1||t==null?t:ie.isArray(t)?t.map(Xs):mh(String(t))}function hh(t){const a=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)a[r[1]]=r[2];return a}const fh=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function si(t,a,n,r,o){if(ie.isFunction(r))return r.call(this,a,n);if(o&&(a=n),!!ie.isString(a)){if(ie.isString(r))return a.indexOf(r)!==-1;if(ie.isRegExp(r))return r.test(a)}}function gh(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,n,r)=>n.toUpperCase()+r)}function yh(t,a){const n=ie.toCamelCase(" "+a);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(o,l,d){return this[r].call(this,a,o,l,d)},configurable:!0})})}let Ft=class{constructor(a){a&&this.set(a)}set(a,n,r){const o=this;function l(c,h,f){const p=On(h);if(!p)throw new Error("header name must be a non-empty string");const m=ie.findKey(o,p);(!m||o[m]===void 0||f===!0||f===void 0&&o[m]!==!1)&&(o[m||h]=Xs(c))}const d=(c,h)=>ie.forEach(c,(f,p)=>l(f,p,h));if(ie.isPlainObject(a)||a instanceof this.constructor)d(a,n);else if(ie.isString(a)&&(a=a.trim())&&!fh(a))d(ch(a),n);else if(ie.isObject(a)&&ie.isIterable(a)){let c={},h,f;for(const p of a){if(!ie.isArray(p))throw TypeError("Object iterator must return a key-value pair");c[f=p[0]]=(h=c[f])?ie.isArray(h)?[...h,p[1]]:[h,p[1]]:p[1]}d(c,n)}else a!=null&&l(n,a,r);return this}get(a,n){if(a=On(a),a){const r=ie.findKey(this,a);if(r){const o=this[r];if(!n)return o;if(n===!0)return hh(o);if(ie.isFunction(n))return n.call(this,o,r);if(ie.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,n){if(a=On(a),a){const r=ie.findKey(this,a);return!!(r&&this[r]!==void 0&&(!n||si(this,this[r],r,n)))}return!1}delete(a,n){const r=this;let o=!1;function l(d){if(d=On(d),d){const c=ie.findKey(r,d);c&&(!n||si(r,r[c],c,n))&&(delete r[c],o=!0)}}return ie.isArray(a)?a.forEach(l):l(a),o}clear(a){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const l=n[r];(!a||si(this,this[l],l,a,!0))&&(delete this[l],o=!0)}return o}normalize(a){const n=this,r={};return ie.forEach(this,(o,l)=>{const d=ie.findKey(r,l);if(d){n[d]=Xs(o),delete n[l];return}const c=a?gh(l):String(l).trim();c!==l&&delete n[l],n[c]=Xs(o),r[c]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const n=Object.create(null);return ie.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=a&&ie.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,n])=>a+": "+n).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...n){const r=new this(a);return n.forEach(o=>r.set(o)),r}static accessor(a){const r=(this[el]=this[el]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=On(d);r[c]||(yh(o,d),r[c]=!0)}return ie.isArray(a)?a.forEach(l):l(a),this}};Ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ie.reduceDescriptors(Ft.prototype,({value:t},a)=>{let n=a[0].toUpperCase()+a.slice(1);return{get:()=>t,set(r){this[n]=r}}});ie.freezeMethods(Ft);function ri(t,a){const n=this||ps,r=a||n,o=Ft.from(r.headers);let l=r.data;return ie.forEach(t,function(c){l=c.call(n,l,o.normalize(),a?a.status:void 0)}),o.normalize(),l}function $c(t){return!!(t&&t.__CANCEL__)}let ms=class extends Be{constructor(a,n,r){super(a??"canceled",Be.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function Fc(t,a,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):a(new Be("Request failed with status code "+n.status,[Be.ERR_BAD_REQUEST,Be.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function xh(t){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return a&&a[1]||""}function bh(t,a){t=t||10;const n=new Array(t),r=new Array(t);let o=0,l=0,d;return a=a!==void 0?a:1e3,function(h){const f=Date.now(),p=r[l];d||(d=f),n[o]=h,r[o]=f;let m=l,v=0;for(;m!==o;)v+=n[m++],m=m%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),f-d<a)return;const S=p&&f-p;return S?Math.round(v*1e3/S):void 0}}function jh(t,a){let n=0,r=1e3/a,o,l;const d=(f,p=Date.now())=>{n=p,o=null,l&&(clearTimeout(l),l=null),t(...f)};return[(...f)=>{const p=Date.now(),m=p-n;m>=r?d(f,p):(o=f,l||(l=setTimeout(()=>{l=null,d(o)},r-m)))},()=>o&&d(o)]}const yr=(t,a,n=3)=>{let r=0;const o=bh(50,250);return jh(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,h=c!=null?Math.min(d,c):d,f=Math.max(0,h-r),p=o(f);r=Math.max(r,h);const m={loaded:h,total:c,progress:c?h/c:void 0,bytes:f,rate:p||void 0,estimated:p&&c?(c-h)/p:void 0,event:l,lengthComputable:c!=null,[a?"download":"upload"]:!0};t(m)},n)},tl=(t,a)=>{const n=t!=null;return[r=>a[0]({lengthComputable:n,total:t,loaded:r}),a[1]]},al=t=>(...a)=>ie.asap(()=>t(...a)),Sh=Dt.hasStandardBrowserEnv?((t,a)=>n=>(n=new URL(n,Dt.origin),t.protocol===n.protocol&&t.host===n.host&&(a||t.port===n.port)))(new URL(Dt.origin),Dt.navigator&&/(msie|trident)/i.test(Dt.navigator.userAgent)):()=>!0,wh=Dt.hasStandardBrowserEnv?{write(t,a,n,r,o,l,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(a)}`];ie.isNumber(n)&&c.push(`expires=${new Date(n).toUTCString()}`),ie.isString(r)&&c.push(`path=${r}`),ie.isString(o)&&c.push(`domain=${o}`),l===!0&&c.push("secure"),ie.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const a=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return a?decodeURIComponent(a[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function vh(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Ch(t,a){return a?t.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):t}function Bc(t,a,n){let r=!vh(a);return t&&(r||n===!1)?Ch(t,a):a}const nl=t=>t instanceof Ft?{...t}:t;function Va(t,a){a=a||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(f,p,m,v){return ie.isPlainObject(f)&&ie.isPlainObject(p)?ie.merge.call({caseless:v},f,p):ie.isPlainObject(p)?ie.merge({},p):ie.isArray(p)?p.slice():p}function o(f,p,m,v){if(ie.isUndefined(p)){if(!ie.isUndefined(f))return r(void 0,f,m,v)}else return r(f,p,m,v)}function l(f,p){if(!ie.isUndefined(p))return r(void 0,p)}function d(f,p){if(ie.isUndefined(p)){if(!ie.isUndefined(f))return r(void 0,f)}else return r(void 0,p)}function c(f,p,m){if(ie.hasOwnProp(a,m))return r(f,p);if(ie.hasOwnProp(t,m))return r(void 0,f)}const h={url:l,method:l,data:l,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:c,headers:(f,p,m)=>o(nl(f),nl(p),m,!0)};return ie.forEach(Object.keys({...t,...a}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const m=ie.hasOwnProp(h,p)?h[p]:o,v=ie.hasOwnProp(t,p)?t[p]:void 0,S=ie.hasOwnProp(a,p)?a[p]:void 0,y=m(v,S,p);ie.isUndefined(y)&&m!==c||(n[p]=y)}),n}const Lc=t=>{const a=Va({},t),n=v=>ie.hasOwnProp(a,v)?a[v]:void 0,r=n("data");let o=n("withXSRFToken");const l=n("xsrfHeaderName"),d=n("xsrfCookieName");let c=n("headers");const h=n("auth"),f=n("baseURL"),p=n("allowAbsoluteUrls"),m=n("url");if(a.headers=c=Ft.from(c),a.url=Ec(Bc(f,m,p),t.params,t.paramsSerializer),h&&c.set("Authorization","Basic "+btoa((h.username||"")+":"+(h.password?unescape(encodeURIComponent(h.password)):""))),ie.isFormData(r)){if(Dt.hasStandardBrowserEnv||Dt.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(ie.isFunction(r.getHeaders)){const v=r.getHeaders(),S=["content-type","content-length"];Object.entries(v).forEach(([y,g])=>{S.includes(y.toLowerCase())&&c.set(y,g)})}}if(Dt.hasStandardBrowserEnv&&(ie.isFunction(o)&&(o=o(a)),o===!0||o==null&&Sh(a.url))){const S=l&&d&&wh.read(d);S&&c.set(l,S)}return a},_h=typeof XMLHttpRequest<"u",Ah=_h&&function(t){return new Promise(function(n,r){const o=Lc(t);let l=o.data;const d=Ft.from(o.headers).normalize();let{responseType:c,onUploadProgress:h,onDownloadProgress:f}=o,p,m,v,S,y;function g(){S&&S(),y&&y(),o.cancelToken&&o.cancelToken.unsubscribe(p),o.signal&&o.signal.removeEventListener("abort",p)}let b=new XMLHttpRequest;b.open(o.method.toUpperCase(),o.url,!0),b.timeout=o.timeout;function D(){if(!b)return;const I=Ft.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),_={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:I,config:t,request:b};Fc(function(x){n(x),g()},function(x){r(x),g()},_),b=null}"onloadend"in b?b.onloadend=D:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(D)},b.onabort=function(){b&&(r(new Be("Request aborted",Be.ECONNABORTED,t,b)),b=null)},b.onerror=function(A){const _=A&&A.message?A.message:"Network Error",u=new Be(_,Be.ERR_NETWORK,t,b);u.event=A||null,r(u),b=null},b.ontimeout=function(){let A=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const _=o.transitional||ro;o.timeoutErrorMessage&&(A=o.timeoutErrorMessage),r(new Be(A,_.clarifyTimeoutError?Be.ETIMEDOUT:Be.ECONNABORTED,t,b)),b=null},l===void 0&&d.setContentType(null),"setRequestHeader"in b&&ie.forEach(d.toJSON(),function(A,_){b.setRequestHeader(_,A)}),ie.isUndefined(o.withCredentials)||(b.withCredentials=!!o.withCredentials),c&&c!=="json"&&(b.responseType=o.responseType),f&&([v,y]=yr(f,!0),b.addEventListener("progress",v)),h&&b.upload&&([m,S]=yr(h),b.upload.addEventListener("progress",m),b.upload.addEventListener("loadend",S)),(o.cancelToken||o.signal)&&(p=I=>{b&&(r(!I||I.type?new ms(null,t,b):I),b.abort(),b=null)},o.cancelToken&&o.cancelToken.subscribe(p),o.signal&&(o.signal.aborted?p():o.signal.addEventListener("abort",p)));const R=xh(o.url);if(R&&Dt.protocols.indexOf(R)===-1){r(new Be("Unsupported protocol "+R+":",Be.ERR_BAD_REQUEST,t));return}b.send(l||null)})},Th=(t,a)=>{const{length:n}=t=t?t.filter(Boolean):[];if(a||n){let r=new AbortController,o;const l=function(f){if(!o){o=!0,c();const p=f instanceof Error?f:this.reason;r.abort(p instanceof Be?p:new ms(p instanceof Error?p.message:p))}};let d=a&&setTimeout(()=>{d=null,l(new Be(`timeout of ${a}ms exceeded`,Be.ETIMEDOUT))},a);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(f=>{f.unsubscribe?f.unsubscribe(l):f.removeEventListener("abort",l)}),t=null)};t.forEach(f=>f.addEventListener("abort",l));const{signal:h}=r;return h.unsubscribe=()=>ie.asap(c),h}},Dh=function*(t,a){let n=t.byteLength;if(n<a){yield t;return}let r=0,o;for(;r<n;)o=r+a,yield t.slice(r,o),r=o},kh=async function*(t,a){for await(const n of Rh(t))yield*Dh(n,a)},Rh=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const a=t.getReader();try{for(;;){const{done:n,value:r}=await a.read();if(n)break;yield r}}finally{await a.cancel()}},sl=(t,a,n,r)=>{const o=kh(t,a);let l=0,d,c=h=>{d||(d=!0,r&&r(h))};return new ReadableStream({async pull(h){try{const{done:f,value:p}=await o.next();if(f){c(),h.close();return}let m=p.byteLength;if(n){let v=l+=m;n(v)}h.enqueue(new Uint8Array(p))}catch(f){throw c(f),f}},cancel(h){return c(h),o.return()}},{highWaterMark:2})},rl=64*1024,{isFunction:ks}=ie,Ih=(({Request:t,Response:a})=>({Request:t,Response:a}))(ie.global),{ReadableStream:il,TextEncoder:ol}=ie.global,ll=(t,...a)=>{try{return!!t(...a)}catch{return!1}},Ph=t=>{t=ie.merge.call({skipUndefined:!0},Ih,t);const{fetch:a,Request:n,Response:r}=t,o=a?ks(a):typeof fetch=="function",l=ks(n),d=ks(r);if(!o)return!1;const c=o&&ks(il),h=o&&(typeof ol=="function"?(y=>g=>y.encode(g))(new ol):async y=>new Uint8Array(await new n(y).arrayBuffer())),f=l&&c&&ll(()=>{let y=!1;const g=new n(Dt.origin,{body:new il,method:"POST",get duplex(){return y=!0,"half"}}),b=g.headers.has("Content-Type");return g.body!=null&&g.body.cancel(),y&&!b}),p=d&&c&&ll(()=>ie.isReadableStream(new r("").body)),m={stream:p&&(y=>y.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(y=>{!m[y]&&(m[y]=(g,b)=>{let D=g&&g[y];if(D)return D.call(g);throw new Be(`Response type '${y}' is not supported`,Be.ERR_NOT_SUPPORT,b)})});const v=async y=>{if(y==null)return 0;if(ie.isBlob(y))return y.size;if(ie.isSpecCompliantForm(y))return(await new n(Dt.origin,{method:"POST",body:y}).arrayBuffer()).byteLength;if(ie.isArrayBufferView(y)||ie.isArrayBuffer(y))return y.byteLength;if(ie.isURLSearchParams(y)&&(y=y+""),ie.isString(y))return(await h(y)).byteLength},S=async(y,g)=>{const b=ie.toFiniteNumber(y.getContentLength());return b??v(g)};return async y=>{let{url:g,method:b,data:D,signal:R,cancelToken:I,timeout:A,onDownloadProgress:_,onUploadProgress:u,responseType:x,headers:j,withCredentials:P="same-origin",fetchOptions:O}=Lc(y),z=a||fetch;x=x?(x+"").toLowerCase():"text";let k=Th([R,I&&I.toAbortSignal()],A),F=null;const C=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let E;try{if(u&&f&&b!=="get"&&b!=="head"&&(E=await S(j,D))!==0){let B=new n(g,{method:"POST",body:D,duplex:"half"}),$;if(ie.isFormData(D)&&($=B.headers.get("content-type"))&&j.setContentType($),B.body){const[N,H]=tl(E,yr(al(u)));D=sl(B.body,rl,N,H)}}ie.isString(P)||(P=P?"include":"omit");const M=l&&"credentials"in n.prototype;if(ie.isFormData(D)){const B=j.getContentType();B&&/^multipart\/form-data/i.test(B)&&!/boundary=/i.test(B)&&j.delete("content-type")}const U={...O,signal:k,method:b.toUpperCase(),headers:j.normalize().toJSON(),body:D,duplex:"half",credentials:M?P:void 0};F=l&&new n(g,U);let Y=await(l?z(F,O):z(g,U));const V=p&&(x==="stream"||x==="response");if(p&&(_||V&&C)){const B={};["status","statusText","headers"].forEach(Q=>{B[Q]=Y[Q]});const $=ie.toFiniteNumber(Y.headers.get("content-length")),[N,H]=_&&tl($,yr(al(_),!0))||[];Y=new r(sl(Y.body,rl,N,()=>{H&&H(),C&&C()}),B)}x=x||"text";let L=await m[ie.findKey(m,x)||"text"](Y,y);return!V&&C&&C(),await new Promise((B,$)=>{Fc(B,$,{data:L,headers:Ft.from(Y.headers),status:Y.status,statusText:Y.statusText,config:y,request:F})})}catch(M){throw C&&C(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new Be("Network Error",Be.ERR_NETWORK,y,F,M&&M.response),{cause:M.cause||M}):Be.from(M,M&&M.code,y,F,M&&M.response)}}},Mh=new Map,Uc=t=>{let a=t&&t.env||{};const{fetch:n,Request:r,Response:o}=a,l=[r,o,n];let d=l.length,c=d,h,f,p=Mh;for(;c--;)h=l[c],f=p.get(h),f===void 0&&p.set(h,f=c?new Map:Ph(a)),p=f;return f};Uc();const oo={http:Hm,xhr:Ah,fetch:{get:Uc}};ie.forEach(oo,(t,a)=>{if(t){try{Object.defineProperty(t,"name",{value:a})}catch{}Object.defineProperty(t,"adapterName",{value:a})}});const dl=t=>`- ${t}`,Eh=t=>ie.isFunction(t)||t===null||t===!1;function Oh(t,a){t=ie.isArray(t)?t:[t];const{length:n}=t;let r,o;const l={};for(let d=0;d<n;d++){r=t[d];let c;if(o=r,!Eh(r)&&(o=oo[(c=String(r)).toLowerCase()],o===void 0))throw new Be(`Unknown adapter '${c}'`);if(o&&(ie.isFunction(o)||(o=o.get(a))))break;l[c||"#"+d]=o}if(!o){const d=Object.entries(l).map(([h,f])=>`adapter ${h} `+(f===!1?"is not supported by the environment":"is not available in the build"));let c=n?d.length>1?`since :
|
|
4
|
+
`+d.map(dl).join(`
|
|
5
|
+
`):" "+dl(d[0]):"as no adapter specified";throw new Be("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o}const Nc={getAdapter:Oh,adapters:oo};function ii(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new ms(null,t)}function cl(t){return ii(t),t.headers=Ft.from(t.headers),t.data=ri.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Nc.getAdapter(t.adapter||ps.adapter,t)(t).then(function(r){return ii(t),r.data=ri.call(t,t.transformResponse,r),r.headers=Ft.from(r.headers),r},function(r){return $c(r)||(ii(t),r&&r.response&&(r.response.data=ri.call(t,t.transformResponse,r.response),r.response.headers=Ft.from(r.response.headers))),Promise.reject(r)})}const zc="1.15.2",$r={};["object","boolean","number","function","string","symbol"].forEach((t,a)=>{$r[t]=function(r){return typeof r===t||"a"+(a<1?"n ":" ")+t}});const ul={};$r.transitional=function(a,n,r){function o(l,d){return"[Axios v"+zc+"] Transitional option '"+l+"'"+d+(r?". "+r:"")}return(l,d,c)=>{if(a===!1)throw new Be(o(d," has been removed"+(n?" in "+n:"")),Be.ERR_DEPRECATED);return n&&!ul[d]&&(ul[d]=!0,console.warn(o(d," has been deprecated since v"+n+" and will be removed in the near future"))),a?a(l,d,c):!0}};$r.spelling=function(a){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${a}`),!0)};function $h(t,a,n){if(typeof t!="object")throw new Be("options must be an object",Be.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let o=r.length;for(;o-- >0;){const l=r[o],d=Object.prototype.hasOwnProperty.call(a,l)?a[l]:void 0;if(d){const c=t[l],h=c===void 0||d(c,l,t);if(h!==!0)throw new Be("option "+l+" must be "+h,Be.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Be("Unknown option "+l,Be.ERR_BAD_OPTION)}}const Zs={assertOptions:$h,validators:$r},Ht=Zs.validators;let qa=class{constructor(a){this.defaults=a||{},this.interceptors={request:new Zo,response:new Zo}}async request(a,n){try{return await this._request(a,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const l=(()=>{if(!o.stack)return"";const d=o.stack.indexOf(`
|
|
6
|
+
`);return d===-1?"":o.stack.slice(d+1)})();try{if(!r.stack)r.stack=l;else if(l){const d=l.indexOf(`
|
|
7
|
+
`),c=d===-1?-1:l.indexOf(`
|
|
8
|
+
`,d+1),h=c===-1?"":l.slice(c+1);String(r.stack).endsWith(h)||(r.stack+=`
|
|
9
|
+
`+l)}}catch{}}throw r}}_request(a,n){typeof a=="string"?(n=n||{},n.url=a):n=a||{},n=Va(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:l}=n;r!==void 0&&Zs.assertOptions(r,{silentJSONParsing:Ht.transitional(Ht.boolean),forcedJSONParsing:Ht.transitional(Ht.boolean),clarifyTimeoutError:Ht.transitional(Ht.boolean),legacyInterceptorReqResOrdering:Ht.transitional(Ht.boolean)},!1),o!=null&&(ie.isFunction(o)?n.paramsSerializer={serialize:o}:Zs.assertOptions(o,{encode:Ht.function,serialize:Ht.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Zs.assertOptions(n,{baseUrl:Ht.spelling("baseURL"),withXsrfToken:Ht.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let d=l&&ie.merge(l.common,l[n.method]);l&&ie.forEach(["delete","get","head","post","put","patch","common"],y=>{delete l[y]}),n.headers=Ft.concat(d,l);const c=[];let h=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(n)===!1)return;h=h&&g.synchronous;const b=n.transitional||ro;b&&b.legacyInterceptorReqResOrdering?c.unshift(g.fulfilled,g.rejected):c.push(g.fulfilled,g.rejected)});const f=[];this.interceptors.response.forEach(function(g){f.push(g.fulfilled,g.rejected)});let p,m=0,v;if(!h){const y=[cl.bind(this),void 0];for(y.unshift(...c),y.push(...f),v=y.length,p=Promise.resolve(n);m<v;)p=p.then(y[m++],y[m++]);return p}v=c.length;let S=n;for(;m<v;){const y=c[m++],g=c[m++];try{S=y(S)}catch(b){g.call(this,b);break}}try{p=cl.call(this,S)}catch(y){return Promise.reject(y)}for(m=0,v=f.length;m<v;)p=p.then(f[m++],f[m++]);return p}getUri(a){a=Va(this.defaults,a);const n=Bc(a.baseURL,a.url,a.allowAbsoluteUrls);return Ec(n,a.params,a.paramsSerializer)}};ie.forEach(["delete","get","head","options"],function(a){qa.prototype[a]=function(n,r){return this.request(Va(r||{},{method:a,url:n,data:(r||{}).data}))}});ie.forEach(["post","put","patch"],function(a){function n(r){return function(l,d,c){return this.request(Va(c||{},{method:a,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}qa.prototype[a]=n(),qa.prototype[a+"Form"]=n(!0)});let Fh=class qc{constructor(a){if(typeof a!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(l){n=l});const r=this;this.promise.then(o=>{if(!r._listeners)return;let l=r._listeners.length;for(;l-- >0;)r._listeners[l](o);r._listeners=null}),this.promise.then=o=>{let l;const d=new Promise(c=>{r.subscribe(c),l=c}).then(o);return d.cancel=function(){r.unsubscribe(l)},d},a(function(l,d,c){r.reason||(r.reason=new ms(l,d,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const n=this._listeners.indexOf(a);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const a=new AbortController,n=r=>{a.abort(r)};return this.subscribe(n),a.signal.unsubscribe=()=>this.unsubscribe(n),a.signal}static source(){let a;return{token:new qc(function(o){a=o}),cancel:a}}};function Bh(t){return function(n){return t.apply(null,n)}}function Lh(t){return ie.isObject(t)&&t.isAxiosError===!0}const Yi={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(Yi).forEach(([t,a])=>{Yi[a]=t});function Yc(t){const a=new qa(t),n=vc(qa.prototype.request,a);return ie.extend(n,qa.prototype,a,{allOwnKeys:!0}),ie.extend(n,a,null,{allOwnKeys:!0}),n.create=function(o){return Yc(Va(t,o))},n}const dt=Yc(ps);dt.Axios=qa;dt.CanceledError=ms;dt.CancelToken=Fh;dt.isCancel=$c;dt.VERSION=zc;dt.toFormData=Or;dt.AxiosError=Be;dt.Cancel=dt.CanceledError;dt.all=function(a){return Promise.all(a)};dt.spread=Bh;dt.isAxiosError=Lh;dt.mergeConfig=Va;dt.AxiosHeaders=Ft;dt.formToJSON=t=>Oc(ie.isHTMLForm(t)?new FormData(t):t);dt.getAdapter=Nc.getAdapter;dt.HttpStatusCode=Yi;dt.default=dt;const{Axios:jA,AxiosError:SA,CanceledError:wA,isCancel:vA,CancelToken:CA,VERSION:_A,all:AA,Cancel:TA,isAxiosError:DA,spread:kA,toFormData:RA,AxiosHeaders:IA,HttpStatusCode:PA,formToJSON:MA,getAdapter:EA,mergeConfig:OA}=dt,Uh=()=>new Promise(t=>setTimeout(()=>t(),800));let Wi=null;const Nh=t=>{Wi=t,_t.defaults.baseURL=lo()},lo=()=>Wi||"https://npmapi.ubkerp.com/",_t=dt.create({baseURL:lo()}),Nt=()=>lo();let Vi=null;const zh=t=>{Vi=t},ut=()=>Vi||"https://image.ubkerp.com",qh=t=>{if(!t||typeof t!="string")return null;const a=t.split(".");if(a.length<2)return null;try{let n=a[1];n=n.replace(/-/g,"+").replace(/_/g,"/");const r=(4-n.length%4)%4;n+="=".repeat(r);const o=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary");return JSON.parse(o)}catch{return null}},ya=t=>{const a=qh(t);return a?a?.branch_id??a?.branchID??a?.fk_branchID??a?.branch??null:null},Ze=async(t,a,n)=>{const r=await _t.post(t,a,{headers:{Authorization:n}});if(r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},bn=async(t,a,n)=>{const r=a instanceof FormData;return(await _t.post(t,a,{headers:{Authorization:n,...r?{"Content-type":"multipart/form-data"}:{}}})).data},W=async(t,a)=>{try{const n=(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}})();let r=t;if(!t.includes("session_id")&&n){const l=t.includes("?")?"&":"?";r=`${t}${l}session_id=${n}`}return(await _t.get(r,{headers:{Authorization:a}})).data}catch(n){throw n.response?.status===401&&console.error("401 Unauthorized"),n}},Yh=async(t,a)=>{const n=await _t.post(t,"",{headers:{Authorization:a}});if(n.data?.Status=="Success")return n?.data?.data||n?.data;throw new Error(n.data?.msg)},Wc=async(t,a,n)=>{const r=await _t.post(t,a,{headers:{Authorization:n}});if(r.data?.Status=="Success")return!0;throw new Error(r?.data?.msg||"Request failed")},hs=async(t,a,n)=>{try{const r=await _t.post(t,a,{headers:{Authorization:n,"Content-Type":"application/json"}});return r.data?.Status==="Success"?r.data:(T.error(r.data?.msg||"Unable to issue library book",{duration:2e3}),!1)}catch(r){throw T.error(r.response?.data?.msg||r.response?.data?.message||"Request failed",{duration:2e3}),r}},gn=async(t,a,n)=>{const r=a?.arg;return(await _t.post(t,r,{headers:{Authorization:n}}))?.data},Ta=async(t,a,n)=>{const r=a?.arg,o=t.includes("?")?"&":"?";return(await _t.get(t+o,{params:r,headers:{Authorization:n}}))?.data},Wh="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",co=async(t,a,n)=>{const r=a?.arg,o=t.includes("?")?"&":"?",l=await _t.get(t+o,{params:r,headers:{Authorization:n}});if(l?.data?.Status=="Success")return l?.data?.data||l?.data;throw new Error(l?.data?.msg||"Request failed")},ct=async(t,a,n)=>(await Uh(),(await _t.post(t,a,{headers:{Authorization:n}}))?.data),An=async(t,a,n)=>(await _t.post(t,a,{headers:{Authorization:n}})).data,st=async(t,a,n)=>(await _t.delete(`${t}/${a}`,{headers:{Authorization:n}})).data,Vh="api/report/LibraryRenewalReport/renewalHistory",Hh="api/report/LibraryRenewalReport/renewalFineReport",Kh="api/report/LibraryRenewalReport/currentlyRenewedBooks",Gh="api/report/LibraryRenewalReport/upcomingRenewalDue",Jh="api/report/LibraryRenewalReport/overdueRenewalReport",Qh="api/report/LibraryRenewalReport/renewalLimitReport",Xh="api/report/LibraryRenewalReport/renewalStatusReport",Zh="api/report/LibraryRenewalReport/studentWiseReport",ef="api/report/LibraryRenewalReport/bookWiseReport",tf="api/report/LibraryRenewalReport/classWiseReport",af="api/report/LibraryRenewalReport/staffWiseReport",nf="api/report/LibraryRenewalReport/renewalStatisticsByDate",sf="/sample_templates/route_upload.xlsx",oa="api/branchapi/academy/classdropdownlist",la="api/branchapi/academy/sectionoftheClass",Fr="api/branchapi/academy/classSubjectdropdown",rf="/sample_templates/student_transport_upload.xlsx",of="api/branchapi/income/incomeTableList",lf="api/branchapi/income/addincome",df="api/branchapi/income/editincome",cf="api/branchapi/income/deleteincome",Vc="api/branchapi/income/incomeheadDropdown",uf="api/branchapi/income/incomeheadTableList",pf="api/branchapi/income/addincomehead",mf="api/branchapi/income/editincomehead",hf="api/branchapi/income/deleteincomehead",ff="api/branchapi/income/incomeShowdata",gf="api/branchapi/income/incomeheadShowdata",yf="api/branchapi/income/searchincomebydates",xf="api/branchapi/expense/expenseTableList",bf="api/branchapi/expense/addexpense",jf="api/branchapi/expense/editexpense",Sf="api/branchapi/expense/deleteExpense",Hc="api/branchapi/expense/expenseheadDropdown",wf="api/branchapi/expense/expenseheadTableList",vf="api/branchapi/expense/addexpensehead",Cf="api/branchapi/expense/editexpensehead",_f="api/branchapi/expense/deleteexpensehead",Af="api/branchapi/expense/expenseShowdata",Tf="api/branchapi/expense/expenseVoucherbyID",Df="api/branchapi/expense/expenseheadShowdata",kf="api/branchapi/expense/searchexpensebydates",Kc="api/accounts/vendor/vendorlist",Rf="api/student/studentDetails/studentLoginCredentialList",Gc="/branchapi/student/studentlist",Jc="api/branchapi/student/studentsearchbyKeywords",Qc="api/branchapi/student/studentsearchbyClassSection",If="/branchapi/student/addStudentMedicineDetails",Pf="/branchapi/student/StudentMedicineDetails",Xc="/branchapi/academy/getstudentClasssubjectByStudentId",Mf="/branchapi/academy/removeAssignStudentSubject",Hi="/branchapi/feesCollection/extraCurricularActivitiesFess",Ef="/branchapi/academy/unAssigneStudentSubject",Of="/branchapi/student/uploadstudentbyCSV",$f="api/branchapi/academy/categorytableList",Ff="api/branchapi/transport/downloadBulkTemplate",Bf="api/branchapi/transport/validateBulkUpload",Lf="api/branchapi/transport/confirmBulkImport",Uf="api/branchapi/transport/downloadBulkErrorReport",Nf=async({class_id:t,section_id:a}={},n)=>{const r=new URLSearchParams;t&&r.append("class_id",t),a&&r.append("section_id",a);const o=`${Ff}${r.toString()?`?${r.toString()}`:""}`;return(await _t.get(o,{headers:{Authorization:n},responseType:"blob"})).data},zf=async(t,a)=>{const n=new FormData;return n.append("file",t),(await _t.post(Bf,n,{headers:{Authorization:a,"Content-Type":"multipart/form-data"}})).data},qf=async(t,a,n="skip")=>(await _t.post(Lf,{rows:t,duplicate_action:n},{headers:{Authorization:a,"Content-Type":"application/json"}})).data,Yf=async(t,a)=>(await _t.post(Uf,{rows:t},{headers:{Authorization:a,"Content-Type":"application/json"},responseType:"blob"})).data,Wf=({token:t,menu:a})=>{const{isLoading:n,data:r}=q(t?["api/sdk/Menus",t]:null,([l,d])=>Yh(l,d)),o=r?.find(l=>l.path===a)?.sub_menu??[];return console.log("menuData",r),e.jsx(s.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(s.Col,{xs:24,md:8,lg:8,children:e.jsx(w,{children:e.jsx(wc,{icon:`${Nt()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function Zc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jt={},oi,pl;function Vf(){return pl||(pl=1,oi=function t(a,n){if(a===n)return!0;if(a&&n&&typeof a=="object"&&typeof n=="object"){if(a.constructor!==n.constructor)return!1;var r,o,l;if(Array.isArray(a)){if(r=a.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!t(a[o],n[o]))return!1;return!0}if(a.constructor===RegExp)return a.source===n.source&&a.flags===n.flags;if(a.valueOf!==Object.prototype.valueOf)return a.valueOf()===n.valueOf();if(a.toString!==Object.prototype.toString)return a.toString()===n.toString();if(l=Object.keys(a),r=l.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,l[o]))return!1;for(o=r;o--!==0;){var d=l[o];if(!t(a[d],n[d]))return!1}return!0}return a!==a&&n!==n}),oi}var Rs={exports:{}},Is={exports:{}},et={};var ml;function Hf(){if(ml)return et;ml=1;var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,h=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,m=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,S=t?Symbol.for("react.memo"):60115,y=t?Symbol.for("react.lazy"):60116,g=t?Symbol.for("react.block"):60121,b=t?Symbol.for("react.fundamental"):60117,D=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function I(_){if(typeof _=="object"&&_!==null){var u=_.$$typeof;switch(u){case a:switch(_=_.type,_){case h:case f:case r:case l:case o:case m:return _;default:switch(_=_&&_.$$typeof,_){case c:case p:case y:case S:case d:return _;default:return u}}case n:return u}}}function A(_){return I(_)===f}return et.AsyncMode=h,et.ConcurrentMode=f,et.ContextConsumer=c,et.ContextProvider=d,et.Element=a,et.ForwardRef=p,et.Fragment=r,et.Lazy=y,et.Memo=S,et.Portal=n,et.Profiler=l,et.StrictMode=o,et.Suspense=m,et.isAsyncMode=function(_){return A(_)||I(_)===h},et.isConcurrentMode=A,et.isContextConsumer=function(_){return I(_)===c},et.isContextProvider=function(_){return I(_)===d},et.isElement=function(_){return typeof _=="object"&&_!==null&&_.$$typeof===a},et.isForwardRef=function(_){return I(_)===p},et.isFragment=function(_){return I(_)===r},et.isLazy=function(_){return I(_)===y},et.isMemo=function(_){return I(_)===S},et.isPortal=function(_){return I(_)===n},et.isProfiler=function(_){return I(_)===l},et.isStrictMode=function(_){return I(_)===o},et.isSuspense=function(_){return I(_)===m},et.isValidElementType=function(_){return typeof _=="string"||typeof _=="function"||_===r||_===f||_===l||_===o||_===m||_===v||typeof _=="object"&&_!==null&&(_.$$typeof===y||_.$$typeof===S||_.$$typeof===d||_.$$typeof===c||_.$$typeof===p||_.$$typeof===b||_.$$typeof===D||_.$$typeof===R||_.$$typeof===g)},et.typeOf=I,et}var tt={};var hl;function Kf(){return hl||(hl=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,h=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,p=t?Symbol.for("react.forward_ref"):60112,m=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,S=t?Symbol.for("react.memo"):60115,y=t?Symbol.for("react.lazy"):60116,g=t?Symbol.for("react.block"):60121,b=t?Symbol.for("react.fundamental"):60117,D=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function I(te){return typeof te=="string"||typeof te=="function"||te===r||te===f||te===l||te===o||te===m||te===v||typeof te=="object"&&te!==null&&(te.$$typeof===y||te.$$typeof===S||te.$$typeof===d||te.$$typeof===c||te.$$typeof===p||te.$$typeof===b||te.$$typeof===D||te.$$typeof===R||te.$$typeof===g)}function A(te){if(typeof te=="object"&&te!==null){var se=te.$$typeof;switch(se){case a:var le=te.type;switch(le){case h:case f:case r:case l:case o:case m:return le;default:var Ce=le&&le.$$typeof;switch(Ce){case c:case p:case y:case S:case d:return Ce;default:return se}}case n:return se}}}var _=h,u=f,x=c,j=d,P=a,O=p,z=r,k=y,F=S,C=n,E=l,M=o,U=m,Y=!1;function V(te){return Y||(Y=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),L(te)||A(te)===h}function L(te){return A(te)===f}function B(te){return A(te)===c}function $(te){return A(te)===d}function N(te){return typeof te=="object"&&te!==null&&te.$$typeof===a}function H(te){return A(te)===p}function Q(te){return A(te)===r}function X(te){return A(te)===y}function J(te){return A(te)===S}function K(te){return A(te)===n}function Z(te){return A(te)===l}function ee(te){return A(te)===o}function pe(te){return A(te)===m}tt.AsyncMode=_,tt.ConcurrentMode=u,tt.ContextConsumer=x,tt.ContextProvider=j,tt.Element=P,tt.ForwardRef=O,tt.Fragment=z,tt.Lazy=k,tt.Memo=F,tt.Portal=C,tt.Profiler=E,tt.StrictMode=M,tt.Suspense=U,tt.isAsyncMode=V,tt.isConcurrentMode=L,tt.isContextConsumer=B,tt.isContextProvider=$,tt.isElement=N,tt.isForwardRef=H,tt.isFragment=Q,tt.isLazy=X,tt.isMemo=J,tt.isPortal=K,tt.isProfiler=Z,tt.isStrictMode=ee,tt.isSuspense=pe,tt.isValidElementType=I,tt.typeOf=A})()),tt}var fl;function eu(){return fl||(fl=1,process.env.NODE_ENV==="production"?Is.exports=Hf():Is.exports=Kf()),Is.exports}var li,gl;function Gf(){if(gl)return li;gl=1;var t=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function r(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function o(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var h=Object.getOwnPropertyNames(d).map(function(p){return d[p]});if(h.join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(p){f[p]=p}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return li=o()?Object.assign:function(l,d){for(var c,h=r(l),f,p=1;p<arguments.length;p++){c=Object(arguments[p]);for(var m in c)a.call(c,m)&&(h[m]=c[m]);if(t){f=t(c);for(var v=0;v<f.length;v++)n.call(c,f[v])&&(h[f[v]]=c[f[v]])}}return h},li}var di,yl;function uo(){if(yl)return di;yl=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return di=t,di}var ci,xl;function tu(){return xl||(xl=1,ci=Function.call.bind(Object.prototype.hasOwnProperty)),ci}var ui,bl;function Jf(){if(bl)return ui;bl=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var a=uo(),n={},r=tu();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,h,f){if(process.env.NODE_ENV!=="production"){for(var p in l)if(r(l,p)){var m;try{if(typeof l[p]!="function"){var v=Error((h||"React class")+": "+c+" 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 v.name="Invariant Violation",v}m=l[p](d,p,h,c,null,a)}catch(y){m=y}if(m&&!(m instanceof Error)&&t((h||"React class")+": type specification of "+c+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in n)){n[m.message]=!0;var S=f?f():"";t("Failed "+c+" type: "+m.message+(S??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},ui=o,ui}var pi,jl;function Qf(){if(jl)return pi;jl=1;var t=eu(),a=Gf(),n=uo(),r=tu(),o=Jf(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var h="Warning: "+c;typeof console<"u"&&console.error(h);try{throw new Error(h)}catch{}});function d(){return null}return pi=function(c,h){var f=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function m(L){var B=L&&(f&&L[f]||L[p]);if(typeof B=="function")return B}var v="<<anonymous>>",S={array:D("array"),bigint:D("bigint"),bool:D("boolean"),func:D("function"),number:D("number"),object:D("object"),string:D("string"),symbol:D("symbol"),any:R(),arrayOf:I,element:A(),elementType:_(),instanceOf:u,node:O(),objectOf:j,oneOf:x,oneOfType:P,shape:k,exact:F};function y(L,B){return L===B?L!==0||1/L===1/B:L!==L&&B!==B}function g(L,B){this.message=L,this.data=B&&typeof B=="object"?B:{},this.stack=""}g.prototype=Error.prototype;function b(L){if(process.env.NODE_ENV!=="production")var B={},$=0;function N(Q,X,J,K,Z,ee,pe){if(K=K||v,ee=ee||J,pe!==n){if(h){var te=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 te.name="Invariant Violation",te}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var se=K+":"+J;!B[se]&&$<3&&(l("You are manually calling a React.PropTypes validation function for the `"+ee+"` prop on `"+K+"`. 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."),B[se]=!0,$++)}}return X[J]==null?Q?X[J]===null?new g("The "+Z+" `"+ee+"` is marked as required "+("in `"+K+"`, but its value is `null`.")):new g("The "+Z+" `"+ee+"` is marked as required in "+("`"+K+"`, but its value is `undefined`.")):null:L(X,J,K,Z,ee)}var H=N.bind(null,!1);return H.isRequired=N.bind(null,!0),H}function D(L){function B($,N,H,Q,X,J){var K=$[N],Z=M(K);if(Z!==L){var ee=U(K);return new g("Invalid "+Q+" `"+X+"` of type "+("`"+ee+"` supplied to `"+H+"`, expected ")+("`"+L+"`."),{expectedType:L})}return null}return b(B)}function R(){return b(d)}function I(L){function B($,N,H,Q,X){if(typeof L!="function")return new g("Property `"+X+"` of component `"+H+"` has invalid PropType notation inside arrayOf.");var J=$[N];if(!Array.isArray(J)){var K=M(J);return new g("Invalid "+Q+" `"+X+"` of type "+("`"+K+"` supplied to `"+H+"`, expected an array."))}for(var Z=0;Z<J.length;Z++){var ee=L(J,Z,H,Q,X+"["+Z+"]",n);if(ee instanceof Error)return ee}return null}return b(B)}function A(){function L(B,$,N,H,Q){var X=B[$];if(!c(X)){var J=M(X);return new g("Invalid "+H+" `"+Q+"` of type "+("`"+J+"` supplied to `"+N+"`, expected a single ReactElement."))}return null}return b(L)}function _(){function L(B,$,N,H,Q){var X=B[$];if(!t.isValidElementType(X)){var J=M(X);return new g("Invalid "+H+" `"+Q+"` of type "+("`"+J+"` supplied to `"+N+"`, expected a single ReactElement type."))}return null}return b(L)}function u(L){function B($,N,H,Q,X){if(!($[N]instanceof L)){var J=L.name||v,K=V($[N]);return new g("Invalid "+Q+" `"+X+"` of type "+("`"+K+"` supplied to `"+H+"`, expected ")+("instance of `"+J+"`."))}return null}return b(B)}function x(L){if(!Array.isArray(L))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 B($,N,H,Q,X){for(var J=$[N],K=0;K<L.length;K++)if(y(J,L[K]))return null;var Z=JSON.stringify(L,function(pe,te){var se=U(te);return se==="symbol"?String(te):te});return new g("Invalid "+Q+" `"+X+"` of value `"+String(J)+"` "+("supplied to `"+H+"`, expected one of "+Z+"."))}return b(B)}function j(L){function B($,N,H,Q,X){if(typeof L!="function")return new g("Property `"+X+"` of component `"+H+"` has invalid PropType notation inside objectOf.");var J=$[N],K=M(J);if(K!=="object")return new g("Invalid "+Q+" `"+X+"` of type "+("`"+K+"` supplied to `"+H+"`, expected an object."));for(var Z in J)if(r(J,Z)){var ee=L(J,Z,H,Q,X+"."+Z,n);if(ee instanceof Error)return ee}return null}return b(B)}function P(L){if(!Array.isArray(L))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var B=0;B<L.length;B++){var $=L[B];if(typeof $!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Y($)+" at index "+B+"."),d}function N(H,Q,X,J,K){for(var Z=[],ee=0;ee<L.length;ee++){var pe=L[ee],te=pe(H,Q,X,J,K,n);if(te==null)return null;te.data&&r(te.data,"expectedType")&&Z.push(te.data.expectedType)}var se=Z.length>0?", expected one of type ["+Z.join(", ")+"]":"";return new g("Invalid "+J+" `"+K+"` supplied to "+("`"+X+"`"+se+"."))}return b(N)}function O(){function L(B,$,N,H,Q){return C(B[$])?null:new g("Invalid "+H+" `"+Q+"` supplied to "+("`"+N+"`, expected a ReactNode."))}return b(L)}function z(L,B,$,N,H){return new g((L||"React class")+": "+B+" type `"+$+"."+N+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+H+"`.")}function k(L){function B($,N,H,Q,X){var J=$[N],K=M(J);if(K!=="object")return new g("Invalid "+Q+" `"+X+"` of type `"+K+"` "+("supplied to `"+H+"`, expected `object`."));for(var Z in L){var ee=L[Z];if(typeof ee!="function")return z(H,Q,X,Z,U(ee));var pe=ee(J,Z,H,Q,X+"."+Z,n);if(pe)return pe}return null}return b(B)}function F(L){function B($,N,H,Q,X){var J=$[N],K=M(J);if(K!=="object")return new g("Invalid "+Q+" `"+X+"` of type `"+K+"` "+("supplied to `"+H+"`, expected `object`."));var Z=a({},$[N],L);for(var ee in Z){var pe=L[ee];if(r(L,ee)&&typeof pe!="function")return z(H,Q,X,ee,U(pe));if(!pe)return new g("Invalid "+Q+" `"+X+"` key `"+ee+"` supplied to `"+H+"`.\nBad object: "+JSON.stringify($[N],null," ")+`
|
|
10
|
+
Valid keys: `+JSON.stringify(Object.keys(L),null," "));var te=pe(J,ee,H,Q,X+"."+ee,n);if(te)return te}return null}return b(B)}function C(L){switch(typeof L){case"number":case"string":case"undefined":return!0;case"boolean":return!L;case"object":if(Array.isArray(L))return L.every(C);if(L===null||c(L))return!0;var B=m(L);if(B){var $=B.call(L),N;if(B!==L.entries){for(;!(N=$.next()).done;)if(!C(N.value))return!1}else for(;!(N=$.next()).done;){var H=N.value;if(H&&!C(H[1]))return!1}}else return!1;return!0;default:return!1}}function E(L,B){return L==="symbol"?!0:B?B["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&B instanceof Symbol:!1}function M(L){var B=typeof L;return Array.isArray(L)?"array":L instanceof RegExp?"object":E(B,L)?"symbol":B}function U(L){if(typeof L>"u"||L===null)return""+L;var B=M(L);if(B==="object"){if(L instanceof Date)return"date";if(L instanceof RegExp)return"regexp"}return B}function Y(L){var B=U(L);switch(B){case"array":case"object":return"an "+B;case"boolean":case"date":case"regexp":return"a "+B;default:return B}}function V(L){return!L.constructor||!L.constructor.name?v:L.constructor.name}return S.checkPropTypes=o,S.resetWarningCache=o.resetWarningCache,S.PropTypes=S,S},pi}var mi,Sl;function Xf(){if(Sl)return mi;Sl=1;var t=uo();function a(){}function n(){}return n.resetWarningCache=a,mi=function(){function r(d,c,h,f,p,m){if(m!==t){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}r.isRequired=r;function o(){return r}var l={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:a};return l.PropTypes=l,l},mi}var wl;function au(){if(wl)return Rs.exports;if(wl=1,process.env.NODE_ENV!=="production"){var t=eu(),a=!0;Rs.exports=Qf()(t.isElement,a)}else Rs.exports=Xf()();return Rs.exports}var vl;function Zf(){if(vl)return jt;vl=1;var t=jt&&jt.__extends||(function(){var S=function(y,g){return S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,D){b.__proto__=D}||function(b,D){for(var R in D)Object.prototype.hasOwnProperty.call(D,R)&&(b[R]=D[R])},S(y,g)};return function(y,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");S(y,g);function b(){this.constructor=y}y.prototype=g===null?Object.create(g):(b.prototype=g.prototype,new b)}})(),a=jt&&jt.__assign||function(){return a=Object.assign||function(S){for(var y,g=1,b=arguments.length;g<b;g++){y=arguments[g];for(var D in y)Object.prototype.hasOwnProperty.call(y,D)&&(S[D]=y[D])}return S},a.apply(this,arguments)},n=jt&&jt.__createBinding||(Object.create?(function(S,y,g,b){b===void 0&&(b=g);var D=Object.getOwnPropertyDescriptor(y,g);(!D||("get"in D?!y.__esModule:D.writable||D.configurable))&&(D={enumerable:!0,get:function(){return y[g]}}),Object.defineProperty(S,b,D)}):(function(S,y,g,b){b===void 0&&(b=g),S[b]=y[g]})),r=jt&&jt.__setModuleDefault||(Object.create?(function(S,y){Object.defineProperty(S,"default",{enumerable:!0,value:y})}):function(S,y){S.default=y}),o=jt&&jt.__importStar||function(S){if(S&&S.__esModule)return S;var y={};if(S!=null)for(var g in S)g!=="default"&&Object.prototype.hasOwnProperty.call(S,g)&&n(y,S,g);return r(y,S),y},l=jt&&jt.__rest||function(S,y){var g={};for(var b in S)Object.prototype.hasOwnProperty.call(S,b)&&y.indexOf(b)<0&&(g[b]=S[b]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function")for(var D=0,b=Object.getOwnPropertySymbols(S);D<b.length;D++)y.indexOf(b[D])<0&&Object.prototype.propertyIsEnumerable.call(S,b[D])&&(g[b[D]]=S[b[D]]);return g},d=jt&&jt.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(jt,"__esModule",{value:!0});var c=o(i),h=d(Vf()),f=o(au());function p(S){return S&&S.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function m(S){var y=document.createTextNode("");S.appendChild(y);var g=document.activeElement===S;if(y!==null&&y.nodeValue!==null&&g){var b=window.getSelection();if(b!==null){var D=document.createRange();D.setStart(y,y.nodeValue.length),D.collapse(!0),b.removeAllRanges(),b.addRange(D)}S instanceof HTMLElement&&S.focus()}}var v=(function(S){t(y,S);function y(){var g=S!==null&&S.apply(this,arguments)||this;return g.lastHtml=g.props.html,g.el=typeof g.props.innerRef=="function"?{current:null}:c.createRef(),g.getEl=function(){return(g.props.innerRef&&typeof g.props.innerRef!="function"?g.props.innerRef:g.el).current},g.emitChange=function(b){var D=g.getEl();if(D){var R=D.innerHTML;if(g.props.onChange&&R!==g.lastHtml){var I=Object.assign({},b,{target:{value:R}});g.props.onChange(I)}g.lastHtml=R}},g}return y.prototype.render=function(){var g=this,b=this.props,D=b.tagName,R=b.html,I=b.innerRef,A=l(b,["tagName","html","innerRef"]);return c.createElement(D||"div",a(a({},A),{ref:typeof I=="function"?function(_){I(_),g.el.current=_}:I||this.el,onInput:this.emitChange,onBlur:this.props.onBlur||this.emitChange,onKeyUp:this.props.onKeyUp||this.emitChange,onKeyDown:this.props.onKeyDown||this.emitChange,contentEditable:!this.props.disabled,dangerouslySetInnerHTML:{__html:R}}),this.props.children)},y.prototype.shouldComponentUpdate=function(g){var b=this.props,D=this.getEl();return!D||p(g.html)!==p(D.innerHTML)?!0:b.disabled!==g.disabled||b.tagName!==g.tagName||b.className!==g.className||b.innerRef!==g.innerRef||b.placeholder!==g.placeholder||!(0,h.default)(b.style,g.style)},y.prototype.componentDidUpdate=function(){var g=this.getEl();g&&(this.props.html!==g.innerHTML&&(g.innerHTML=this.props.html),this.lastHtml=this.props.html,m(g))},y.propTypes={html:f.string.isRequired,onChange:f.func,disabled:f.bool,tagName:f.string,className:f.string,style:f.object,innerRef:f.oneOfType([f.object,f.func])},y})(c.Component);return jt.default=v,jt}var eg=Zf();const nu=Zc(eg),tg={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ag={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"},G=i.forwardRef(({style:t,onFocus:a,onBlur:n,...r},o)=>{const[l,d]=i.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:tg,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:o,onFocus:c=>{d(!0),a?.(c)},onBlur:c=>{d(!1),n?.(c)},style:{...ag,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})});var jn=function(){return jn=Object.assign||function(a){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(a[l]=n[l])}return a},jn.apply(this,arguments)},ng={2e3:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2001:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2002:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2003:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2004:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2005:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2006:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2007:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2008:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:29,Mangsir:30,Poush:30,Magh:29,Falgun:29,Chaitra:31},2009:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2010:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2011:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2012:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:29,Mangsir:30,Poush:30,Magh:29,Falgun:30,Chaitra:30},2013:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2014:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2015:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2016:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:29,Mangsir:30,Poush:30,Magh:29,Falgun:30,Chaitra:30},2017:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2018:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2019:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2020:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2021:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2022:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:30},2023:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2024:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2025:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2026:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2027:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2028:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2029:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:32,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2030:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2031:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2032:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2033:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2034:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2035:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:29,Mangsir:30,Poush:30,Magh:29,Falgun:29,Chaitra:31},2036:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2037:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2038:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2039:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:29,Mangsir:30,Poush:30,Magh:29,Falgun:30,Chaitra:30},2040:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2041:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2042:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2043:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:29,Mangsir:30,Poush:30,Magh:29,Falgun:30,Chaitra:30},2044:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2045:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2046:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2047:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2048:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2049:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:30},2050:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2051:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2052:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2053:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:30},2054:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2055:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2056:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:32,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2057:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2058:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2059:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2060:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2061:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2062:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:29,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2063:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2064:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2065:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2066:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:29,Mangsir:30,Poush:30,Magh:29,Falgun:29,Chaitra:31},2067:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2068:{Baisakh:31,Jestha:31,Asar:32,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2069:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2070:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:29,Mangsir:30,Poush:30,Magh:29,Falgun:30,Chaitra:30},2071:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2072:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2073:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2074:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2075:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2076:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:30},2077:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2078:{Baisakh:31,Jestha:31,Asar:31,Shrawan:32,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2079:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2080:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:30},2081:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2082:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2083:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2084:{Baisakh:31,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:29,Falgun:30,Chaitra:31},2085:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:29,Chaitra:31},2086:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:29,Poush:30,Magh:29,Falgun:30,Chaitra:30},2087:{Baisakh:31,Jestha:31,Asar:32,Shrawan:31,Bhadra:31,Aswin:31,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:30,Chaitra:30},2088:{Baisakh:30,Jestha:31,Asar:32,Shrawan:32,Bhadra:30,Aswin:31,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:30,Chaitra:30},2089:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:30,Chaitra:30},2090:{Baisakh:30,Jestha:32,Asar:31,Shrawan:32,Bhadra:31,Aswin:30,Kartik:30,Mangsir:30,Poush:29,Magh:30,Falgun:30,Chaitra:30}},Ki;(function(t){t.np="np",t.en="en"})(Ki||(Ki={}));var su=Object.values(ng).map(function(t){return Object.values(t)}),Gi=su.map(function(t){var a=0;return t.map(function(n){var r=[n,a];return a+=n,r})},[]),Ji=0,xr=su.map(function(t){var a=t.reduce(function(r,o){return r+o},0),n=[a,Ji];return Ji+=a,n}),br=33238;if(Ji!==br)throw new Error("Invalid constant initialization for Nepali Date.");var Qi=1;function sg(t){return t-ru}function rg(t){return t+ru}var ru=2e3,ma=1,Cl=0;function ig(t,a){for(;a<0;)a+=t;return a%t}var Zn={en:{day:{short:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],long:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},month:{short:["Bai","Jes","Asa","Shr","Bhd","Asw","Kar","Man","Pou","Mag","Fal","Cha"],long:["Baisakh","Jestha","Asar","Shrawan","Bhadra","Aswin","Kartik","Mangsir","Poush","Magh","Falgun","Chaitra"]},date:["0","1","2","3","4","5","6","7","8","9"]},np:{day:{short:["आइत","सोम","मंगल","बुध","बिहि","शुक्र","शनि"],long:["आइतबार","सोमबार","मंगलबार","बुधबार","बिहिबार","शुक्रबार","शनिबार"]},month:{short:["बै","जे","अ","श्रा","भा","आ","का","मं","पौ","मा","फा","चै"],long:["बैशाख","जेठ","असार","श्रावण","भाद्र","आश्विन","कार्तिक","मंसिर","पौष","माघ","फाल्गुण","चैत्र"]},date:["०","१","२","३","४","५","६","७","८","९"]}},hi={year:1943,month:3,date:13};function og(t,a,n){try{var r=sg(t),o=xr[r][ma],l=ig(12,a),d=Math.floor(a/12),c=xr[r+d][ma]-o+Gi[r+d][l][ma],h=o+c+n;if(h<Qi||h>br)throw new Error;return h}catch{throw new Error("The date doesn't fall within 2000/01/01 - 2090/12/30")}}function iu(t){if(t<Qi||t>br)throw new Error("The epoch difference is not within the boundaries ".concat(Qi," - ").concat(br));var a=xr.findIndex(function(l){return t>l[ma]&&t<=l[ma]+l[Cl]}),n=t-xr[a][ma],r=Gi[a].findIndex(function(l){return n>l[ma]&&n<=l[ma]+l[Cl]}),o=n-Gi[a][r][ma];return{year:rg(a),month:r,date:o}}function lg(t,a,n){var r=Math.abs(Date.UTC(t,a,n)-Date.UTC(hi.year,hi.month,hi.date)),o=Math.ceil(r/(1e3*3600*24));return o}function ou(t){var a=new Date(Date.UTC(1943,3,13+t));return{year:a.getUTCFullYear(),month:a.getUTCMonth(),date:a.getUTCDate(),day:a.getUTCDay()}}function dg(t){try{var a=og(t.year,t.month,t.date),n=iu(a),r=ou(a);return{AD:r,BS:jn(jn({},n),{day:r.day})}}catch{throw new Error("The date doesn't fall within 2000/01/01 - 2090/12/30")}}function cg(t){try{var a=lg(t.getFullYear(),t.getMonth(),t.getDate()),n=iu(a),r=ou(a);return{AD:r,BS:jn(jn({},n),{day:r.day})}}catch{throw new Error("The date doesn't fall within 2000/01/01 - 2090/12/30")}}function ja(t,a){return t.split("").map(function(n){return Zn[a].date[parseInt(n,10)]}).join("")}function ug(t,a,n){return a.replace(/((\\[MDYd])|D{1,2}|M{1,4}|Y{2,4}|d{1,3})/g,function(r,o,l){var d;switch(r){case"D":return ja(t.date.toString(),n);case"DD":return ja(t.date.toString().padStart(2,"0"),n);case"M":return ja((t.month+1).toString(),n);case"MM":return ja((t.month+1).toString().padStart(2,"0"),n);case"MMM":return Zn[n].month.short[t.month];case"MMMM":return Zn[n].month.long[t.month];case"YY":return ja(t.year.toString().slice(-2),n);case"YYY":return ja(t.year.toString().slice(-3),n);case"YYYY":return ja(t.year.toString(),n);case"d":return ja(((d=t.day)===null||d===void 0?void 0:d.toString())||"0",n);case"dd":return Zn[n].day.short[t.day||0];case"ddd":return Zn[n].day.long[t.day||0];default:return l.replace("/","")}}).replace(/\\/g,"")}function _l(t){var a=/(\d{4})\s*([/-]|\s+)\s*(\d{1,2})\s*([/-]|\s+)\s*(\d{1,2})/,n=/(\d{1,2})\s*([/-]|\s+)\s*(\d{1,2})\s*([/-]|\s+)\s*(\d{4})/,r;if(r=t.match(a),r!==null)return{year:parseInt(r[1],10),month:parseInt(r[3],10)-1,date:parseInt(r[5],10)};if(r=t.match(n),r!==null)return{year:parseInt(r[5],10),month:parseInt(r[3],10)-1,date:parseInt(r[1],10)};throw new Error("Invalid date format")}var Oa=Symbol("Date"),fi=Symbol("Day"),$a=Symbol("Year"),Fa=Symbol("MonthIndex"),Ba=Symbol("JsDate"),Ps=Symbol("convertToBS()"),tn=Symbol("convertToAD()"),gi=Symbol("setADBS()"),Ms=Symbol("setDayYearMonth()");(function(){function t(){var a=new Error("Invalid constructor arguments");if(arguments.length===0)this[Ps](new Date);else if(arguments.length===1){var n=arguments[0];switch(typeof n){case"number":this[Ps](new Date(n));break;case"string":var r=_l(n),o=r.date,l=r.year,d=r.month;this[Ms](l,d,o),this[tn]();break;case"object":if(n instanceof Date)this[Ps](n);else throw a;break;default:throw a}}else if(arguments.length<=3)this[Ms](arguments[0],arguments[1],arguments[2]),this[tn]();else throw a}return t.prototype[Ms]=function(a,n,r,o){n===void 0&&(n=0),r===void 0&&(r=1),o===void 0&&(o=0),this[$a]=a,this[Fa]=n,this[Oa]=r,this[fi]=o},t.prototype.toJsDate=function(){return this[Ba]},t.prototype.getDate=function(){return this[Oa]},t.prototype.getYear=function(){return this[$a]},t.prototype.getDay=function(){return this[fi]},t.prototype.getMonth=function(){return this[Fa]},t.prototype.getDateObject=function(){return{BS:this.getBS(),AD:this.getAD()}},t.prototype.getBS=function(){return{year:this[$a],month:this[Fa],date:this[Oa],day:this[fi]}},t.prototype.getAD=function(){return{year:this[Ba].getFullYear(),month:this[Ba].getMonth(),date:this[Ba].getDate(),day:this[Ba].getDay()}},t.prototype.setDate=function(a){var n=this[Oa];try{this[Oa]=a,this[tn]()}catch(r){throw this[Oa]=n,r}},t.prototype.setMonth=function(a){var n=this[Fa];try{this[Fa]=a,this[tn]()}catch(r){throw this[Fa]=n,r}},t.prototype.setYear=function(a){var n=this[$a];try{this[$a]=a,this[tn]()}catch(r){throw this[$a]=n,r}},t.prototype.format=function(a,n){return n===void 0&&(n=t.language),ug(this.getBS(),a,n)},t.parse=function(a){var n=_l(a),r=n.date,o=n.year,l=n.month;return new t(o,l,r)},t.now=function(){return new t},t.fromAD=function(a){return new t(a)},t.prototype[Ps]=function(a){var n=cg(a),r=n.AD,o=n.BS;this[gi](r,o)},t.prototype[gi]=function(a,n){this[Ms](n.year,n.month,n.date,n.day),this[Ba]=new Date(a.year,a.month,a.date)},t.prototype[tn]=function(){var a=dg({year:this[$a],month:this[Fa],date:this[Oa]}),n=a.AD,r=a.BS;this[gi](n,r)},t.prototype.valueOf=function(){return this[Ba].getTime()},t.prototype.toString=function(){return this.format("ddd DD, MMMM YYYY")},t.language=Ki.en,t})();const lu=t=>{switch(t){case"paid":return e.jsx("div",{style:{background:"#3cb371",color:"white",textAlign:"center"},children:"PAID"});case"due":return e.jsx("div",{style:{background:"red",color:"white",textAlign:"center"},children:"DUE"});case"partially_paid":return e.jsx("div",{style:{background:"#ff8d00",color:"white",textAlign:"center"},children:"Partially Paid"});case"Present":return e.jsx(s.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(s.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(s.Tag,{color:"error",children:"No Attendance"});case"one_time":return"ONETIME";case"monthly":return"MONTHLY";case"half_yearly":return"HALF YEARLY";case"quarterly":return"QUARTERLY";default:return""}},ra=t=>{const a=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[a?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})},Al=[{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 po(t){const a=ne().year(),n=[];for(let r=a;r>=a-t;r--)n.push({label:String(r),value:r});return n}function St(t){switch(t){case"late":return e.jsx("span",{className:"label label-late",children:"L"});case"present":return e.jsx("span",{className:"label label-success",children:"P"});case"absent":return e.jsx("span",{className:"label label-danger",children:"A"});case"P":return e.jsx("span",{className:"monthlyLabel label-success",children:"P"});case"A":return e.jsx("span",{className:"monthlyLabel label-danger",children:"A"});case"L":return e.jsx("span",{className:"monthlyLabel label-late",children:"L"});case"W":return e.jsx("span",{className:"monthlyLabel sunday",children:"W"});case"H":return e.jsx("span",{className:"monthlyLabel holiday",children:"H"});default:return e.jsx("span",{className:"label",children:t})}}function mo(t){const a=ne().year(),n=ne().month();return t<a?Al:Al.slice(0,n+1)}function Tl(t,a){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:a});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:a});default:return e.jsx("span",{className:"monthlyLabel",children:a})}}function pg(){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"}]}var $n={},Fn={},Ut={},Bn={},an={},Dl;function mg(){if(Dl)return an;Dl=1;var t=an&&an.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(an,"__esModule",{value:!0});const a=t(i),n=am,r=["string","number","boolean"];function o({header:l,body:d}){const c=a.default.createElement("tr",null,l.map(f=>a.default.createElement("th",{key:f},f))),h=d.map((f,p)=>Array.isArray(f)?a.default.createElement("tr",{key:p},f.map((m,v)=>a.default.createElement("th",{key:v}," ",m," "))):f!==null&&typeof f=="object"?a.default.createElement("tr",{key:p},Object.entries(f).map(([m,v],S)=>typeof v=="object"?(console.error(`typeof ${m} is incorrect, only accept ${r.join(", ")} `),a.default.createElement("th",{key:S})):a.default.createElement("th",{key:S},a.default.createElement(a.default.Fragment,null,v)))):(console.error(`
|
|
11
11
|
data structure is incorrect,
|
|
12
12
|
data structure type ->
|
|
13
13
|
" type data = Array<{ [key: string]: string | number | boolean }>
|
|
14
14
|
or
|
|
15
15
|
type data = Array<(string | number | boolean)[]>"
|
|
16
|
-
`),null));return(0,s.renderToString)(n.default.createElement("table",null,n.default.createElement("tbody",null,c,g)))}return ca.default=l,ca}var Qr;function Hu(){return Qr||(Qr=1,(function(t){var n=Fa&&Fa.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(t,"__esModule",{value:!0}),t.createTable=t.template=t.uri=t.format=t.base64=void 0;function s(o){return window.btoa(unescape(encodeURIComponent(o)))}t.base64=s;function r(o,d){return o.replace(/{(\w+)}/g,(c,g)=>d[g])}t.format=r,t.uri="data:application/vnd.ms-excel;base64,",t.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var l=Vu();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return n(l).default}})})(Fa)),Fa}var Xr;function uo(){if(Xr)return Ct;Xr=1;var t=Ct&&Ct.__createBinding||(Object.create?(function(y,p,m,A){A===void 0&&(A=m);var C=Object.getOwnPropertyDescriptor(p,m);(!C||("get"in C?!p.__esModule:C.writable||C.configurable))&&(C={enumerable:!0,get:function(){return p[m]}}),Object.defineProperty(y,A,C)}):(function(y,p,m,A){A===void 0&&(A=m),y[A]=p[m]})),n=Ct&&Ct.__setModuleDefault||(Object.create?(function(y,p){Object.defineProperty(y,"default",{enumerable:!0,value:p})}):function(y,p){y.default=p}),s=Ct&&Ct.__importStar||function(y){if(y&&y.__esModule)return y;var p={};if(y!=null)for(var m in y)m!=="default"&&Object.prototype.hasOwnProperty.call(y,m)&&t(p,y,m);return n(p,y),p};Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.downloadExcel=Ct.excel=void 0;const r=s(Hu());function l(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function o(y,p){const m=window.document.createElement("a");return m.href=r.uri+r.base64(r.format(r.template,p)),m.download=y,document.body.appendChild(m),m.click(),document.body.removeChild(m),!0}function d(y,p){if(y)return y.cloneNode(!0).outerHTML;if(p)return r.createTable(p);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:y,sheet:p,tablePayload:m},A){if(!l())return!1;const C=d(A,m);return o(y,{worksheet:p||"Worksheet",table:C})}Ct.downloadExcel=c;function g({currentTableRef:y,filename:p,sheet:m}){function A(){if(!l())return!1;const C=d(y),b=`${p}.xls`;return o(b,{worksheet:m||"Worksheet",table:C})}return{onDownload:A}}return Ct.excel=g,Ct}var Zr;function Ku(){if(Zr)return Ea;Zr=1,Object.defineProperty(Ea,"__esModule",{value:!0}),Ea.useDownloadExcel=void 0;const t=i,n=uo();function s({currentTableRef:r,filename:l,sheet:o}){const[d,c]=(0,t.useState)({});return(0,t.useEffect)(()=>{c({currentTableRef:r,filename:l,sheet:o})},[r,l,o]),(0,t.useMemo)(()=>(0,n.excel)(d),[d])}return Ea.useDownloadExcel=s,Ea}var ei;function Gu(){return ei||(ei=1,(function(t){var n=Ma&&Ma.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadExcel=t.useDownloadExcel=t.DownloadTableExcel=void 0;const s=n(i),r=Ku();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const l=uo();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return l.downloadExcel}});const o=({currentTableRef:d,filename:c,sheet:g,children:y})=>{const{onDownload:p}=(0,r.useDownloadExcel)({currentTableRef:d,filename:c,sheet:g});return s.default.createElement("span",{onClick:p},y)};t.DownloadTableExcel=o})(Ma)),Ma}var po=Gu();const kt=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:n}=t.data;t?.tableRef;const s=new Date().getTime(),r=ia.useReactToPrint({content:()=>n.current});return e.jsx(e.Fragment,{children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsxs(a.Row,{gutter:8,children:[e.jsx(a.Col,{children:e.jsx(a.Button,{type:"text",icon:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(a.Col,{children:e.jsx(po.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:n.current,children:e.jsx(a.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},$t=t=>{const{tableRef:n}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(a.Row,{justify:"center",children:e.jsx(a.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},Mt=i.createContext(),Ju=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),ze=t=>{const{columns:n,action:s,DrawerUpdate:r,editDesign:l,newData:o,Loading:d,error:c,deleteTodoMutation:g,open:y,ActionView:p,viewDetails:m,myType:A,type:C,urlkey:b,columnstype:f,rowSelection:x}=t.data,R=Ju(),[k,O]=i.useState(!1),[_,D]=i.useState(null),[u,h]=i.useState("false"),[S,E]=i.useState(!1),[$,q]=i.useState(!1),[T,F]=i.useState(),[j,P]=i.useState(""),I=()=>O(!1),N=re=>{h(re),O(!0)},[W,Y]=i.useState(),[B,U]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),M=i.useRef(null),L=(re,xe)=>{t.parentCallback?.(re,xe),U({rowsPerPage:xe,page:re})},z=(re,xe)=>{D(xe),E(!0),F(re)},ne=(re,xe)=>{D(xe),q(!0),F(re)},X=t?.data?.onNavigate??t?.onNavigate,J=(re,xe)=>{if(typeof X=="function"){X(re,xe);return}typeof window<"u"&&typeof re=="string"&&re.length>0&&window.location.assign(re)},H=re=>{if(C==="staff"){J(`/HumanResourceDashboard/StaffFullInformation?id=${re.fk_staffID}`,re);return}J(`/StudentInformation/StudentFullInformation?id=${re.id}`,re)},Q=(re,xe)=>{Y(re),r?.(xe)},ce=async(re,xe,je,Le)=>{r?.(!0),je!==""&&((await Le({id:re,admission_no:xe,ec_no:je}))?.Status==="Success"?a.message.success("Ec No updated successfully"):a.message.error("Failed to Update Ec No."))},De=()=>e.jsx(Mt.Provider,{value:W,children:l}),{trigger:le}=pt("branchapi/staff/updateStaffPassword",an),{trigger:ue}=pt("branchapi/Student/updateEcNo",an),{trigger:oe}=pt(b,(re,xe)=>an("student/studentDetails/editStudentLogInCredential",xe)),Ce=async re=>{re.preventDefault(),E(!1);try{(await le({staff_id:T,new_passwod:re.target.password.value}))?.Status==="Success"?a.message.success("Password updated successfully"):a.message.error("Failed to update password")}catch{a.message.error("Failed to update password")}},Ne=async re=>{re.preventDefault(),q(!1);try{(await oe({edit_id:_?.edit_id,new_passwod:re.target.password.value,username:re.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?a.message.success("Password updated successfully"):a.message.error("Failed to update password")}catch(xe){a.message.error(xe?.response?.data?.msg??"Failed to update password")}},et=(Array.isArray(n)?n:[]).some(re=>re?.fixed==="left"),we=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:f==="antd"&&et?"left":void 0,sorter:(re,xe)=>(re.__serialNumber??0)-(xe.__serialNumber??0),render:re=>re},...f==="antd"?n:(Array.isArray(n)?n:[]).map(re=>({title:re.name,dataIndex:re.selector,key:re.selector,sorter:re.sorter||(re.sortable?(xe,je)=>{const Le=xe[re.selector]??"",qe=je[re.selector]??"";return typeof Le=="number"&&typeof qe=="number"?Le-qe:String(Le).localeCompare(String(qe))}:!1),render:(xe,je)=>{switch(re.selector){case"my_staff":return je.staff_id!=="0"?je.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(a.Image,{width:50,src:`undefined/branch/gallery/${je.gallery_cat_logo}`});case"file01":return je.documents?e.jsx("div",{onClick:()=>N(`undefined/branch/frontoffice/${je.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 Ft(xe);case"full_name":return e.jsx("span",{onClick:()=>H(je),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:xe||`${je.firstname} ${je.lastname}`});case"extra_curricular_activity":return xe==="Yes"?"Extra Subject":"Fees Master";case"is_active":return xe==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return je?.current_status==="Active"?e.jsx(a.Progress,{percent:je.steps==="1"?30:je.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:je?.current_status});case"Password":return e.jsx("span",{onClick:()=>z(je.id,je),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>ne(je.id,je),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(a.Tag,{onClick:()=>m?.(je.id),color:xe==="paid"?"#66aa18":xe==="partially_paid"?"#ff5722":"#DC143C",children:xe==="paid"?"Paid":xe==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return Wu().find(Le=>Le.value===xe)?.label;case"status":return e.jsx("span",{onClick:()=>m?.(je?.fk_staffID,je?.total_leave),className:`label ${xe==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:xe==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[je.is_theory==="yes"&&"Theory, ",je.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(oo,{html:je.ec_no,onBlur:Le=>ce(je.id,je.admission_no,Le.target.innerHTML,ue)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(a.Button,{type:"primary",icon:e.jsx(ee.SendOutlined,{}),size:"small",onClick:()=>Q(je.id,!0,re.name),children:re.name});case"Button":return e.jsx(a.Tag,{color:"cyan",onClick:()=>m?.(je),children:re.name});default:return typeof re.render=="function"?re.render(xe,je):xe}}})),...s?[{title:"Action",key:"action",render:(re,xe)=>{const je=xe?.current_status==="Promoted",Le=()=>{if(A=="sameAddUpdate"){Q(xe,!0);return}if(A?.type==="examEdit"){A.editFunc(xe.id);return}Q(xe.id||xe,!0)},qe=()=>{if(A==="student_result"){m?.(xe);return}if(A==="student"){m?.(xe.id,xe.class_id);return}m?.(xe.id)},fe=()=>{g?.(xe?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[p?.[0]?.status&&e.jsx(a.Button,{icon:e.jsx(ee.EditOutlined,{}),size:"small",disabled:je,onClick:Le}),p?.[1]?.status&&e.jsx(a.Button,{icon:e.jsx(ee.DeleteOutlined,{}),size:"small",danger:!0,disabled:je,onClick:fe}),p?.[2]?.status&&e.jsx(a.Button,{icon:e.jsx(ee.EyeOutlined,{}),size:"small",onClick:qe})]})}}]:[]],Ae=i.useMemo(()=>{if(!o)return[];const re=o?.data?.data??o?.data??o??{};return Array.isArray(re)?re:Array.isArray(re?.data)?re.data:Array.isArray(re?.resultlist)?re.resultlist:Array.isArray(re?.students)?re.students:Array.isArray(re?.report)?re.report:[]},[o]),Fe=i.useMemo(()=>{const re=j.trim().toLowerCase();return re?Ae.filter(xe=>Object.values(xe??{}).some(je=>String(je??"").toLowerCase().includes(re))):Ae},[Ae,j]),me=!!t.parentCallback,de=j?Fe.length:o?.pagination?.total_rows??Fe.length,Re=(B.page-1)*B.rowsPerPage,Be=me?Fe:Fe.slice(Re,Re+B.rowsPerPage),$e=i.useMemo(()=>(Be??[]).map((re,xe)=>({...re??{},__serialNumber:Re+xe+1})),[Re,Be]),ge=de===0?0:Math.min(Re+1,de),_e=de===0?0:Math.min(Re+Be.length,de);let ve;return d?ve=e.jsx("p",{children:"Loading..."}):c?ve=e.jsx("p",{children:c.message}):Be.length?ve=e.jsx(a.Table,{dataSource:$e,columns:we,size:"small",bordered:!0,pagination:!1,rowSelection:x,rowKey:(re,xe)=>re?.id??re?._id??xe,scroll:{x:"max-content"}}):ve=e.jsx(a.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(a.Drawer,{open:y,placement:"right",onClose:()=>r?.(!1),width:720,children:De()}),e.jsx(a.Modal,{title:"Update Password",open:S,onCancel:()=>E(!1),footer:null,children:e.jsx("form",{onSubmit:Ce,children:e.jsxs(w,{children:[e.jsx(w,{style:{marginBottom:12},children:e.jsx(V,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(w,{style:{marginTop:16},children:e.jsx(a.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(a.Modal,{title:" Update Credential",open:$,onCancel:()=>q(!1),footer:null,children:e.jsx("form",{onSubmit:Ne,children:e.jsxs(w,{children:[e.jsx(w,{style:{marginBottom:12},children:e.jsx(V,{type:"text",label:"User Name",name:"username",required:"required",value:_?.username?_?.username:"",onChange:re=>D({..._,username:re.target.value})})}),e.jsx(w,{style:{marginBottom:12},children:e.jsx(V,{label:"Password",name:"password",required:"required",value:_?.password?_?.password:"",onChange:re=>D({..._,password:re.target.value})})}),e.jsx(w,{style:{marginTop:16},children:e.jsx(a.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(a.Modal,{open:k,onCancel:I,footer:null,centered:!0,width:"80%",className:R.modal,children:e.jsxs("div",{style:{position:"relative"},className:R.img,children:[e.jsx(a.Image,{src:u,alt:"",style:{width:"100%"},preview:!1}),e.jsx(a.Button,{type:"text",icon:e.jsx(ee.CloseOutlined,{}),onClick:I,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(a.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
|
|
16
|
+
`),null));return(0,n.renderToString)(a.default.createElement("table",null,a.default.createElement("tbody",null,c,h)))}return an.default=o,an}var kl;function hg(){return kl||(kl=1,(function(t){var a=Bn&&Bn.__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 n(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=n;function r(l,d){return l.replace(/{(\w+)}/g,(c,h)=>d[h])}t.format=r,t.uri="data:application/vnd.ms-excel;base64,",t.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var o=mg();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return a(o).default}})})(Bn)),Bn}var Rl;function du(){if(Rl)return Ut;Rl=1;var t=Ut&&Ut.__createBinding||(Object.create?(function(f,p,m,v){v===void 0&&(v=m);var S=Object.getOwnPropertyDescriptor(p,m);(!S||("get"in S?!p.__esModule:S.writable||S.configurable))&&(S={enumerable:!0,get:function(){return p[m]}}),Object.defineProperty(f,v,S)}):(function(f,p,m,v){v===void 0&&(v=m),f[v]=p[m]})),a=Ut&&Ut.__setModuleDefault||(Object.create?(function(f,p){Object.defineProperty(f,"default",{enumerable:!0,value:p})}):function(f,p){f.default=p}),n=Ut&&Ut.__importStar||function(f){if(f&&f.__esModule)return f;var p={};if(f!=null)for(var m in f)m!=="default"&&Object.prototype.hasOwnProperty.call(f,m)&&t(p,f,m);return a(p,f),p};Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.downloadExcel=Ut.excel=void 0;const r=n(hg());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(f,p){const m=window.document.createElement("a");return m.href=r.uri+r.base64(r.format(r.template,p)),m.download=f,document.body.appendChild(m),m.click(),document.body.removeChild(m),!0}function d(f,p){if(f)return f.cloneNode(!0).outerHTML;if(p)return r.createTable(p);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:f,sheet:p,tablePayload:m},v){if(!o())return!1;const S=d(v,m);return l(f,{worksheet:p||"Worksheet",table:S})}Ut.downloadExcel=c;function h({currentTableRef:f,filename:p,sheet:m}){function v(){if(!o())return!1;const S=d(f),y=`${p}.xls`;return l(y,{worksheet:m||"Worksheet",table:S})}return{onDownload:v}}return Ut.excel=h,Ut}var Il;function fg(){if(Il)return Fn;Il=1,Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.useDownloadExcel=void 0;const t=i,a=du();function n({currentTableRef:r,filename:o,sheet:l}){const[d,c]=(0,t.useState)({});return(0,t.useEffect)(()=>{c({currentTableRef:r,filename:o,sheet:l})},[r,o,l]),(0,t.useMemo)(()=>(0,a.excel)(d),[d])}return Fn.useDownloadExcel=n,Fn}var Pl;function gg(){return Pl||(Pl=1,(function(t){var a=$n&&$n.__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 n=a(i),r=fg();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const o=du();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:h,children:f})=>{const{onDownload:p}=(0,r.useDownloadExcel)({currentTableRef:d,filename:c,sheet:h});return n.default.createElement("span",{onClick:p},f)};t.DownloadTableExcel=l})($n)),$n}var cu=gg();const Jt=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:a}=t.data;t?.tableRef;const n=new Date().getTime(),r=Ka.useReactToPrint({content:()=>a.current});return e.jsx(e.Fragment,{children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(s.Row,{gutter:8,children:[e.jsx(s.Col,{children:e.jsx(s.Button,{type:"text",icon:e.jsx(re.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:e.jsx(cu.DownloadTableExcel,{filename:n,sheet:"users",currentTableRef:a.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(re.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},da=t=>{const{tableRef:a}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},ta=i.createContext(),yg=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Ke=t=>{const{columns:a,action:n,DrawerUpdate:r,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:h,open:f,ActionView:p,viewDetails:m,myType:v,type:S,urlkey:y,columnstype:g,rowSelection:b}=t.data,D=yg(),[R,I]=i.useState(!1),[A,_]=i.useState(null),[u,x]=i.useState("false"),[j,P]=i.useState(!1),[O,z]=i.useState(!1),[k,F]=i.useState(),[C,E]=i.useState(""),M=()=>I(!1),U=ce=>{x(ce),I(!0)},[Y,V]=i.useState(),[L,B]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),$=i.useRef(null),N=(ce,ve)=>{t.parentCallback?.(ce,ve),B({rowsPerPage:ve,page:ce})},H=(ce,ve)=>{_(ve),P(!0),F(ce)},Q=(ce,ve)=>{_(ve),z(!0),F(ce)},X=t?.data?.onNavigate??t?.onNavigate,J=(ce,ve)=>{if(typeof X=="function"){X(ce,ve);return}typeof window<"u"&&typeof ce=="string"&&ce.length>0&&window.location.assign(ce)},K=ce=>{if(S==="staff"){J(`/HumanResourceDashboard/StaffFullInformation?id=${ce.fk_staffID}`,ce);return}J(`/StudentInformation/StudentFullInformation?id=${ce.id}`,ce)},Z=(ce,ve)=>{V(ce),r?.(ve)},ee=async(ce,ve,_e,Ve)=>{r?.(!0),_e!==""&&((await Ve({id:ce,admission_no:ve,ec_no:_e}))?.Status==="Success"?s.message.success("Ec No updated successfully"):s.message.error("Failed to Update Ec No."))},pe=()=>e.jsx(ta.Provider,{value:Y,children:o}),{trigger:te}=it("branchapi/staff/updateStaffPassword",gn),{trigger:se}=it("branchapi/Student/updateEcNo",gn),{trigger:le}=it(y,(ce,ve)=>gn("student/studentDetails/editStudentLogInCredential",ve)),Ce=async ce=>{ce.preventDefault(),P(!1);try{(await te({staff_id:k,new_passwod:ce.target.password.value}))?.Status==="Success"?s.message.success("Password updated successfully"):s.message.error("Failed to update password")}catch{s.message.error("Failed to update password")}},Le=async ce=>{ce.preventDefault(),z(!1);try{(await le({edit_id:A?.edit_id,new_passwod:ce.target.password.value,username:ce.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?s.message.success("Password updated successfully"):s.message.error("Failed to update password")}catch(ve){s.message.error(ve?.response?.data?.msg??"Failed to update password")}},Re=(Array.isArray(a)?a:[]).some(ce=>ce?.fixed==="left"),xe=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:g==="antd"&&Re?"left":void 0,sorter:(ce,ve)=>(ce.__serialNumber??0)-(ve.__serialNumber??0),render:ce=>ce},...g==="antd"?a:(Array.isArray(a)?a:[]).map(ce=>({title:ce.name,dataIndex:ce.selector,key:ce.selector,sorter:ce.sorter||(ce.sortable?(ve,_e)=>{const Ve=ve[ce.selector]??"",He=_e[ce.selector]??"";return typeof Ve=="number"&&typeof He=="number"?Ve-He:String(Ve).localeCompare(String(He))}:!1),render:(ve,_e)=>{switch(ce.selector){case"my_staff":return _e.staff_id!=="0"?_e.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(s.Image,{width:50,src:`undefined/branch/gallery/${_e.gallery_cat_logo}`});case"file01":return _e.documents?e.jsx("div",{onClick:()=>U(`undefined/branch/frontoffice/${_e.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 ra(ve);case"full_name":return e.jsx("span",{onClick:()=>K(_e),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:ve||`${_e.firstname} ${_e.lastname}`});case"extra_curricular_activity":return ve==="Yes"?"Extra Subject":"Fees Master";case"is_active":return ve==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return _e?.current_status==="Active"?e.jsx(s.Progress,{percent:_e.steps==="1"?30:_e.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:_e?.current_status});case"Password":return e.jsx("span",{onClick:()=>H(_e.id,_e),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>Q(_e.id,_e),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(s.Tag,{onClick:()=>m?.(_e.id),color:ve==="paid"?"#66aa18":ve==="partially_paid"?"#ff5722":"#DC143C",children:ve==="paid"?"Paid":ve==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return pg().find(Ve=>Ve.value===ve)?.label;case"status":return e.jsx("span",{onClick:()=>m?.(_e?.fk_staffID,_e?.total_leave),className:`label ${ve==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:ve==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[_e.is_theory==="yes"&&"Theory, ",_e.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(nu,{html:_e.ec_no,onBlur:Ve=>ee(_e.id,_e.admission_no,Ve.target.innerHTML,se)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(s.Button,{type:"primary",icon:e.jsx(re.SendOutlined,{}),size:"small",onClick:()=>Z(_e.id,!0,ce.name),children:ce.name});case"Button":return e.jsx(s.Tag,{color:"cyan",onClick:()=>m?.(_e),children:ce.name});default:return typeof ce.render=="function"?ce.render(ve,_e):ve}}})),...n?[{title:"Action",key:"action",render:(ce,ve)=>{const _e=ve?.current_status==="Promoted",Ve=()=>{if(v=="sameAddUpdate"){Z(ve,!0);return}if(v?.type==="examEdit"){v.editFunc(ve.id);return}Z(ve.id||ve,!0)},He=()=>{if(v==="student_result"){m?.(ve);return}if(v==="student"){m?.(ve.id,ve.class_id);return}m?.(ve.id)},je=()=>{h?.(ve?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[p?.[0]?.status&&e.jsx(s.Button,{icon:e.jsx(re.EditOutlined,{}),size:"small",disabled:_e,onClick:Ve}),p?.[1]?.status&&e.jsx(s.Button,{icon:e.jsx(re.DeleteOutlined,{}),size:"small",danger:!0,disabled:_e,onClick:je}),p?.[2]?.status&&e.jsx(s.Button,{icon:e.jsx(re.EyeOutlined,{}),size:"small",onClick:He})]})}}]:[]],De=i.useMemo(()=>{if(!l)return[];const ce=l?.data?.data??l?.data??l??{};return Array.isArray(ce)?ce:Array.isArray(ce?.data)?ce.data:Array.isArray(ce?.resultlist)?ce.resultlist:Array.isArray(ce?.students)?ce.students:Array.isArray(ce?.report)?ce.report:[]},[l]),Ue=i.useMemo(()=>{const ce=C.trim().toLowerCase();return ce?De.filter(ve=>Object.values(ve??{}).some(_e=>String(_e??"").toLowerCase().includes(ce))):De},[De,C]),ye=!!t.parentCallback,me=C?Ue.length:l?.pagination?.total_rows??Ue.length,Pe=(L.page-1)*L.rowsPerPage,Ye=ye?Ue:Ue.slice(Pe,Pe+L.rowsPerPage),ze=i.useMemo(()=>(Ye??[]).map((ce,ve)=>({...ce??{},__serialNumber:Pe+ve+1})),[Pe,Ye]),we=me===0?0:Math.min(Pe+1,me),ke=me===0?0:Math.min(Pe+Ye.length,me);let Te;return d?Te=e.jsx("p",{children:"Loading..."}):c?Te=e.jsx("p",{children:c.message}):Ye.length?Te=e.jsx(s.Table,{dataSource:ze,columns:xe,size:"small",bordered:!0,pagination:!1,rowSelection:b,rowKey:(ce,ve)=>ce?.id??ce?._id??ve,scroll:{x:"max-content"}}):Te=e.jsx(s.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(s.Drawer,{open:f,placement:"right",onClose:()=>r?.(!1),width:720,children:pe()}),e.jsx(s.Modal,{title:"Update Password",open:j,onCancel:()=>P(!1),footer:null,children:e.jsx("form",{onSubmit:Ce,children:e.jsxs(w,{children:[e.jsx(w,{style:{marginBottom:12},children:e.jsx(G,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(w,{style:{marginTop:16},children:e.jsx(s.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(s.Modal,{title:" Update Credential",open:O,onCancel:()=>z(!1),footer:null,children:e.jsx("form",{onSubmit:Le,children:e.jsxs(w,{children:[e.jsx(w,{style:{marginBottom:12},children:e.jsx(G,{type:"text",label:"User Name",name:"username",required:"required",value:A?.username?A?.username:"",onChange:ce=>_({...A,username:ce.target.value})})}),e.jsx(w,{style:{marginBottom:12},children:e.jsx(G,{label:"Password",name:"password",required:"required",value:A?.password?A?.password:"",onChange:ce=>_({...A,password:ce.target.value})})}),e.jsx(w,{style:{marginTop:16},children:e.jsx(s.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(s.Modal,{open:R,onCancel:M,footer:null,centered:!0,width:"80%",className:D.modal,children:e.jsxs("div",{style:{position:"relative"},className:D.img,children:[e.jsx(s.Image,{src:u,alt:"",style:{width:"100%"},preview:!1}),e.jsx(s.Button,{type:"text",icon:e.jsx(re.CloseOutlined,{}),onClick:M,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(s.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
|
|
17
17
|
.ubk-table-shell .ant-table-wrapper {
|
|
18
18
|
background: #fff;
|
|
19
19
|
border: 1px solid #e7e8f2;
|
|
@@ -56,7 +56,71 @@ Valid keys: `+JSON.stringify(Object.keys(B),null," "));var le=De(J,ce,z,ne,X+".
|
|
|
56
56
|
.ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
|
|
57
57
|
color: #8f99ff;
|
|
58
58
|
}
|
|
59
|
-
`}),e.jsx(w,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(kt,{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(a.Select,{size:"small",value:B.rowsPerPage,onChange:re=>L(1,re),options:[10,25,50,100].map(re=>({label:re,value:re})),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(a.Input,{size:"small",allowClear:!0,value:j,onChange:re=>{P(re.target.value),U(xe=>({...xe,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(ee.SearchOutlined,{style:{color:"#a3a8cf"}}),style:{width:220,borderWidth:"0 0 1px 0",borderRadius:0,background:"transparent"}})]})]}),e.jsx("div",{className:"print-only",children:e.jsx($t,{})}),ve]}),o&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,marginTop:16,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:`Showing ${ge} to ${_e} of ${de} entries`}),e.jsx(a.Pagination,{current:B.page,pageSize:B.rowsPerPage,total:de||0,showSizeChanger:!1,onChange:L})]})]})]})},Qu=({token:t,type:n})=>{const[s,r]=i.useState({page:1,rowsPerPage:10}),l="api/branchapi/frontoffice/enquirytablelist",o=l.includes("?")?l.endsWith("?")||l.endsWith("&")?"":"&":"?",d=`${l}${o}page=${s.page}&per_page=${s.rowsPerPage}`,{isLoading:c,data:g,error:y}=K(t?[d,t]:null,([k,O])=>G(k,O)),[p,m]=i.useState(!1),A=(k,O)=>{r({page:k,rowsPerPage:parseInt(O)})},C=async k=>{},b=k=>{console.log("dsdsdsdsd",k),m(k)},f=()=>{},x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],R=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(k,O)=>k.name.localeCompare(O.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(k,O)=>(k.contact||"").localeCompare(O.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(k,O)=>(k.description||"").localeCompare(O.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(k,O)=>(k.source_name||"").localeCompare(O.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(k,O)=>new Date(k.date)-new Date(O.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(k,O)=>new Date(k.follow_up_date)-new Date(O.follow_up_date)}]);return e.jsx("div",{children:e.jsx(ze,{parentCallback:A,data:{newData:g,columns:R,action:!0,Loading:c,error:y,open:p,viewDetails:f,deleteTodoMutation:C,DrawerUpdate:b,ActionView:x}})})};var Xu=lo();const Is=so(Xu),mo=()=>{};class ur 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,s)=>{this.props.onChange(n,s),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:s,...r}=this.props,{isDisabled:l}=this.props,o=!l;return e.jsxs("div",{children:[e.jsx(n,{...r,ref:this.setSelectRef,onChange:this.onChange}),o&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:mo,onFocus:()=>this.selectRef.focus(),required:s})]})}}ur.defaultProps={onChange:mo};ur.protoTypes={selectComponent:Is.func.isRequired,onChange:Is.func,required:Is.bool};const Zu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ep={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"})},ho=t=>e.jsx(Al.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),tp=t=>e.jsx(ur,{...t,SelectComponent:Al,components:{Input:ho},options:t.options}),Z=i.forwardRef(({...t},n)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:Zu,children:t?.label}),e.jsx(tp,{components:{Input:ho},menuPortalTarget:document.body,styles:ep,className:"input-cont",...t,ref:n})]})),ap={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},np={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},sp=(t,n,s)=>n?t>se(s).endOf("day")||t<se(n).endOf("day"):!1,He=i.forwardRef(function(n,s){const{...r}=n;return e.jsxs("div",{className:"form-group",children:[r.Desplay&&e.jsx("label",{className:`labelfont ${r.classnme?r.classnme:""}`,style:ap,children:r.Desplay}),e.jsx(a.DatePicker,{...r,style:{...np,...r.style||{}},className:"form-group",disabledDate:l=>sp(l,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:s})]})}),rp={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"},ie=i.forwardRef(({error:t,success:n,disabled:s,loading:r,style:l,...o},d)=>e.jsxs("div",{className:"form-group",style:{marginBottom:0,position:"relative"},children:[e.jsx("input",{...o,ref:d,disabled:s||r,style:{...rp,opacity:s||r?.7:1,cursor:s||r?"not-allowed":"pointer",...l||{}}}),r?e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",opacity:.8,children:e.jsx("animateTransform",{attributeName:"transform",type:"rotate",dur:"0.8s",values:"0 0 0 0;360 0 0 0",repeatCount:"indefinite",children:e.jsx("circle",{cx:"8",cy:"8",r:"6",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeDasharray:"60",strokeLinecap:"round",children:e.jsx("animate",{attributeName:"stroke-dashoffset",type:"subtract",from:"60",to:"0",dur:"0.8s",repeatCount:"indefinite"})})})})}):null]})),ip={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},lp={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"},gt=({style:t,onFocus:n,onBlur:s,...r})=>{const[l,o]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:ip,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{o(!0),n?.(d)},onBlur:d=>{o(!1),s?.(d)},style:{...lp,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})},st=t=>({optimisticData:n=>[...n.data,t],populateCache:(n,s)=>[...s.data,n]}),nt=t=>({optimisticData:n=>n.data.filter(s=>s.id!==t),populateCache:(n,s)=>s.data.filter(r=>r.id!==t)}),op=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},dp="api/branchapi/Frontoffice/visitorbookShowdata",cp="api/branchapi/Frontoffice/purposedropdown";function up({data:t}){const{handleUpdate:n,token:s}=t||{},r=i.useContext(Mt),l=dp.replace(/\?.*$/,""),{isLoading:o,data:d}=K(s&&r?[l,r,s]:null,([f,x,R])=>Ra(f,{id:x},R)),{isLoading:c,data:g}=K(s?[cp,s]:null,([f,x])=>G(f,x)),y=i.useMemo(()=>op(g),[g]),p=d?.data?.[0],[m,A]=i.useState({purpose:void 0,name:"",phone:"",id_card:"",number_of_person:1,date:null,in_time:null,out_time:null,note:"",address:"",image:""});i.useEffect(()=>{p&&A({purpose:p?.purpose,name:p?.name||"",phone:p?.contact||"",id_card:p?.id_proof||"",number_of_person:p?.no_of_pepple||1,date:p?.date?se(p.date):null,in_time:p?.in_time?se(p.in_time,"h:mm a"):null,out_time:p?.out_time?se(p.out_time,"h:mm a"):null,note:p?.note||"",address:p?.address||"",image:p?.image||""})},[p]);const C=(f,x)=>{A(R=>({...R,[f]:x}))},b=`${At()}/branchapi/frontoffice/uploadfrontofficeDocument`;return o||c?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:f=>n(f,r),children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Visitor"})}),e.jsx(w,{p:2,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",allowSelectAll:!1,value:m.purpose,onChange:f=>C("purpose",f)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0,value:m.name,onChange:f=>C("name",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"phone",type:"text",label:"Phone No.",required:!0,value:m.phone,onChange:f=>C("phone",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"id_card",type:"text",label:"ID Card",value:m.id_card,onChange:f=>C("id_card",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"number_of_person",type:"number",label:"Number of Person",value:m.number_of_person,onChange:f=>C("number_of_person",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",value:m.date,Desplay:"Date",id:"date",name:"date",required:!0,onChange:f=>C("date",f)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",value:m.in_time,onChange:f=>C("in_time",f),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:m.in_time?m.in_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",value:m.out_time,onChange:f=>C("out_time",f),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time",value:m.out_time?m.out_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:m.note,onChange:f=>C("note",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(gt,{type:"text",label:"Address",name:"address",rows:3,required:!0,value:m.address,onChange:f=>C("address",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.Upload,{action:b,headers:{Authorization:s},maxCount:1,onChange:f=>{if(f.file.status==="removed"&&C("image",""),f.file.status==="done"){const x=f.file.response?.data??f.file.response?.file??"";C("image",String(x??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:m.image?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:m.image||"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"center",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; }"})]})}const pp=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ua="api/branchapi/Frontoffice/visitortablelist",mp="api/branchapi/Frontoffice/purposedropdown",hp="api/branchapi/frontoffice/addvisitors",fp="api/branchapi/frontoffice/editvisitorsdata",yp="api/branchapi/frontoffice/deletevisitors",gp=`${At()}/branchapi/frontoffice/uploadfrontofficeDocument`;function xp({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState("03:30 PM"),m=(T,F)=>{s({page:T,rowsPerPage:Number.parseInt(F,10)})},A=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],C=i.useMemo(()=>{const T=ua.includes("?")?ua.endsWith("?")||ua.endsWith("&")?"":"&":"?";return`${ua}${T}page=${n.page}&per_page=${n.rowsPerPage}`},[ua,n.page,n.rowsPerPage]),{isLoading:b,error:f,data:x,mutate:R}=K(t?[C,t]:null,([T,F])=>G(T,F)),{isLoading:k,data:O}=K(t?[mp,t]:null,([T,F])=>G(T,F)),_=i.useMemo(()=>pp(O),[O]),D=async(T,F)=>{try{await R(Ge(T,F,t),st(F)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},u=async T=>{try{await R(Ze(yp,T,t),nt(T)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},h=async(T,F,j)=>{try{const P=await tt(T,F,t);R(P),Array.isArray(P?.data)&&R(`${ua.replace(/\?.*$/,"")}?id=${j}`,P),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},S=async(T,F)=>{T.preventDefault();const j=new FormData(T.target);await h(fp,j,F),T.target.reset(),d(""),l(!1)},E=async T=>{if(T.preventDefault(),!T.target?.date?.value)v.error("Select required dates"),T.target?.date?.focus(),g("textDanger");else{const F=new FormData(T.target);await D(hp,F),T.target.reset(),g(""),d(""),p("03:30 PM")}},$=T=>{l(T)},q=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Address",selector:"address",sortable:!0},{id:"5",name:"In Time",selector:"in_time",sortable:!0},{id:"6",name:"Out Time",selector:"out_time",sortable:!0}],[]);return e.jsxs("div",{children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Visitor"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:E,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",required:!0,allowSelectAll:!1})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone No.",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"id_card",type:"text",label:"ID Card"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{defaultValue:1,name:"number_of_person",type:"number",label:"Number of Person"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",defaultValue:se(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.TimePicker,{defaultValue:se("2022-04-17T15:30","h:mm a"),id:"in_time",use12Hours:!0,format:"h:mm a",onChange:(T,F)=>p(F),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:y,readOnly:!0})]})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(gt,{type:"text",label:"Address*",name:"address",rows:3,required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.Upload,{action:gp,headers:{Authorization:t},maxCount:1,onChange:T=>{if(T.file.status==="removed"&&d(""),T.file.status==="done"){const F=T.file.response?.data??T.file.response?.file??"";d(String(F??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:o?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:o||"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Visitor List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:m,data:{newData:x,columns:q,action:!0,ActionView:A,Loading:b,error:f,editDesign:e.jsx(up,{data:{handleUpdate:S,token:t}}),deleteTodoMutation:u,open:r,DrawerUpdate:$,viewDetails:""}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const bp="api/branchapi/frontoffice/generalcallsShowdata",jp=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}];function Sp({data:t}){const{handleUpdate:n,token:s}=t||{},r=i.useContext(Mt),l=bp.replace(/\?.*$/,""),{isLoading:o,data:d}=K(s&&r?[l,r,s]:null,([m,A,C])=>Ra(m,{id:A},C)),c=d?.data?.[0],[g,y]=i.useState({name:"",phone:"",description:"",date:null,next_follow_up_date:null,call_duration:"",note:"",call_type:""});i.useEffect(()=>{c&&y({name:c?.name||"",phone:c?.contact||"",description:c?.description||"",date:c?.date?se(c.date):null,next_follow_up_date:c?.follow_up_date?se(c.follow_up_date):null,call_duration:c?.call_dureation||"",note:c?.note||"",call_type:c?.call_type||""})},[c]);const p=(m,A)=>{y(C=>({...C,[m]:A}))};return o?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>n(m,r),children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Call Log"})}),e.jsx(w,{p:2,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0,value:g.name,onChange:m=>p("name",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",value:g.phone,onChange:m=>p("phone",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description",value:g.description,onChange:m=>p("description",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:m=>p("date",m)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",value:g.next_follow_up_date,Desplay:"Next Follow Up Date",id:"fdate",name:"next_follow_up_date",onChange:m=>p("next_follow_up_date",m)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"call_duration",type:"text",label:"Call Duration",value:g.call_duration,onChange:m=>p("call_duration",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:g.note,onChange:m=>p("note",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:jp,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:g.call_type?{value:g.call_type,label:g.call_type}:null,onChange:m=>p("call_type",m?.value||"")})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"center",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const pa="api/branchapi/frontoffice/generalcalltablelist",vp="api/branchapi/frontoffice/addgenaralcalls",wp="api/branchapi/frontoffice/editgeneralcall",_p="api/branchapi/frontoffice/deletegeneralcall",Cp=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}],Ap=[{key:"all",label:"All Calls"},{key:"Incoming",label:"Incoming"},{key:"Outgoing",label:"Outgoing"}];function Dp({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState("all"),[m,A]=i.useState(""),C=i.useRef(null),b=(T,F)=>{s({page:T,rowsPerPage:Number.parseInt(F,10)})},f=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],x=i.useMemo(()=>{const T=pa.includes("?")?pa.endsWith("?")||pa.endsWith("&")?"":"&":"?",F=new URLSearchParams;return F.set("page",String(n.page)),F.set("per_page",String(n.rowsPerPage)),y!=="all"&&F.set("call_type",y),`${pa}${T}${F.toString()}`},[pa,n.page,n.rowsPerPage,y]),{isLoading:R,error:k,data:O,mutate:_}=K(t?[x,t]:null,([T,F])=>G(T,F)),D=async(T,F)=>{try{await _(Ge(T,F,t),st(F)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},u=async T=>{try{await _(Ze(_p,T,t),nt(T)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},h=async(T,F,j)=>{try{const P=await tt(T,F,t);_(P),Array.isArray(P?.data)&&_(`${pa.replace(/\?.*$/,"")}?id=${j}`,P),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},S=async(T,F)=>{T.preventDefault();const j=new FormData(T.target);await h(wp,j,F),T.target.reset(),d(""),l(!1)},E=async T=>{if(T.preventDefault(),!T.target?.date?.value)v.error("Select required dates"),T.target?.date?.focus(),g("textDanger");else{const F=new FormData(T.target);await D(vp,F),T.target.reset(),g(""),d(""),A("")}},$=T=>{l(T)},q=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Phone",selector:"contact",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Follow Up Date",selector:"follow_up_date",sortable:!0},{id:"6",name:"Call Duration",selector:"call_dureation",sortable:!0}],[]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Phone Call Log"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:E,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",defaultValue:se(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",Desplay:"Next Follow Up Date",id:"fdate",name:"follow_up_date"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"call_dureation",type:"text",label:"Call Duration"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:Cp,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:m?{value:m,label:m}:null,onChange:T=>A(T?.value||"")})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Phone Call Log List"})}),e.jsxs(w,{pt:3,children:[e.jsx(a.Tabs,{activeKey:y,onChange:p,items:Ap}),e.jsx(kt,{data:{tableRef:C}}),e.jsx(ze,{parentCallback:b,data:{newData:O,columns:q,action:!0,ActionView:f,Loading:R,error:k,editDesign:e.jsx(Sp,{data:{handleUpdate:S,token:t}}),deleteTodoMutation:u,open:r,DrawerUpdate:$,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Tp="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function Rp({data:t}){const{handleUpdate:n,token:s}=t||{},r=i.useContext(Mt),l=Tp.replace(/\?.*$/,""),{isLoading:o,data:d}=K(s&&r?[l,r,s]:null,([m,A,C])=>Ra(m,{id:A},C)),c=d?.data?.[0],[g,y]=i.useState({to_title:"",refernce:"",address:"",note:"",from_title:"",date:null,image:""});i.useEffect(()=>{c&&y({to_title:c?.to_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",from_title:c?.from_title||"",date:c?.date?se(c.date):null,image:c?.image||""})},[c]);const p=(m,A)=>{y(C=>({...C,[m]:A}))};return o?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>n(m,r),children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Dispatch"})}),e.jsx(w,{p:2,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"title",type:"text",label:"To Title *",required:!0,value:g.to_title,onChange:m=>p("to_title",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"refernce",type:"text",label:"Reference No",value:g.refernce,onChange:m=>p("refernce",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:m=>p("address",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:g.note,onChange:m=>p("note",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"from_title",type:"text",label:"From Title",required:!0,value:g.from_title,onChange:m=>p("from_title",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:m=>p("date",m)})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"center",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ma="api/branchapi/frontoffice/postaldispatchtablelist",Ip="api/branchapi/frontoffice/addpostaldispatch",kp="api/branchapi/frontoffice/editpostaldispatch",Pp="api/branchapi/frontoffice/deletepostalreceivedispatch";function Op({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),y=i.useRef(null),p=(S,E)=>{s({page:S,rowsPerPage:Number.parseInt(E,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],A=i.useMemo(()=>{const S=ma.includes("?")?ma.endsWith("?")||ma.endsWith("&")?"":"&":"?";return`${ma}${S}page=${n.page}&per_page=${n.rowsPerPage}`},[ma,n.page,n.rowsPerPage]),{isLoading:C,error:b,data:f,mutate:x}=K(t?[A,t]:null,([S,E])=>G(S,E)),R=async(S,E)=>{try{await x(Ge(S,E,t),st(E)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},k=async S=>{try{await x(Ze(Pp,S,t),nt(S)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},O=async(S,E,$)=>{try{const q=await tt(S,E,t);x(q),Array.isArray(q?.data)&&x(`${ma.replace(/\?.*$/,"")}?id=${$}`,q),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},_=async(S,E)=>{S.preventDefault();const $=new FormData(S.target);await O(kp,$,E),S.target.reset(),d(""),l(!1)},D=async S=>{if(S.preventDefault(),!S.target?.date?.value)v.error("Select required dates"),S.target?.date?.focus(),g("textDanger");else{const E=new FormData(S.target);await R(Ip,E),S.target.reset(),g(""),d("")}},u=S=>{l(S)},h=i.useMemo(()=>[{id:"1",name:"To Title",selector:"to_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"From Title",selector:"from_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Dispatch"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:D,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:"title",type:"text",label:"To Title *"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:"from_title",type:"text",label:"From Title"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",defaultValue:se(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx("input",{type:"hidden",name:"image",value:o||"",readOnly:!0})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Dispatch List"})}),e.jsxs(w,{pt:3,children:[e.jsx(kt,{data:{tableRef:y}}),e.jsx(ze,{parentCallback:p,data:{newData:f,columns:h,action:!0,ActionView:m,Loading:C,error:b,editDesign:e.jsx(Rp,{data:{handleUpdate:_,token:t}}),deleteTodoMutation:k,open:r,DrawerUpdate:u,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Mp="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function Ep({data:t}){const{handleUpdate:n,token:s}=t||{},r=i.useContext(Mt),l=Mp.replace(/\?.*$/,""),{isLoading:o,data:d}=K(s&&r?[l,r,s]:null,([m,A,C])=>Ra(m,{id:A},C)),c=d?.data?.[0],[g,y]=i.useState({from_title:"",refernce:"",address:"",note:"",title:"",date:null,image:""});i.useEffect(()=>{c&&y({from_title:c?.from_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",title:c?.to_title||"",date:c?.date?se(c.date):null,image:c?.image||""})},[c]);const p=(m,A)=>{y(C=>({...C,[m]:A}))};return o?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>n(m,r),children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Receive"})}),e.jsx(w,{p:2,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"from_title",type:"text",label:"From Title *",required:!0,value:g.from_title,onChange:m=>p("from_title",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"refernce",type:"text",label:"Reference No",required:!0,value:g.refernce,onChange:m=>p("refernce",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:m=>p("address",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:g.note,onChange:m=>p("note",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"title",type:"text",label:"To Title",required:!0,value:g.title,onChange:m=>p("title",m.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:m=>p("date",m)})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"center",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ha="api/branchapi/frontoffice/postalrecivetablelist",Fp="api/branchapi/frontoffice/addpostalrecive",$p="api/branchapi/frontoffice/editpostalrecive",Up="api/branchapi/frontoffice/deletepostalreceivedispatch";function Bp({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),y=i.useRef(null),p=(S,E)=>{s({page:S,rowsPerPage:Number.parseInt(E,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],A=i.useMemo(()=>{const S=ha.includes("?")?ha.endsWith("?")||ha.endsWith("&")?"":"&":"?";return`${ha}${S}page=${n.page}&per_page=${n.rowsPerPage}`},[ha,n.page,n.rowsPerPage]),{isLoading:C,error:b,data:f,mutate:x}=K(t?[A,t]:null,([S,E])=>G(S,E)),R=async(S,E)=>{try{await x(Ge(S,E,t),st(E)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},k=async S=>{try{await x(Ze(Up,S,t),nt(S)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},O=async(S,E,$)=>{try{const q=await tt(S,E,t);x(q),Array.isArray(q?.data)&&x(`${ha.replace(/\?.*$/,"")}?id=${$}`,q),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},_=async(S,E)=>{S.preventDefault();const $=new FormData(S.target);await O($p,$,E),S.target.reset(),d(""),l(!1)},D=async S=>{if(S.preventDefault(),!S.target?.date?.value)v.error("Select required dates"),S.target?.date?.focus(),g("textDanger");else{const E=new FormData(S.target);await R(Fp,E),S.target.reset(),g(""),d("")}},u=S=>{l(S)},h=i.useMemo(()=>[{id:"1",name:"From Title",selector:"from_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"To Title",selector:"to_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Receive"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:D,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:"from_title",type:"text",label:"From Title *"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:"title",type:"text",label:"To Title"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",defaultValue:se(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx("input",{type:"hidden",name:"image",value:o||"",readOnly:!0})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Receive List"})}),e.jsxs(w,{pt:3,children:[e.jsx(kt,{data:{tableRef:y}}),e.jsx(ze,{parentCallback:p,data:{newData:f,columns:h,action:!0,ActionView:m,Loading:C,error:b,editDesign:e.jsx(Ep,{data:{handleUpdate:_,token:t}}),deleteTodoMutation:k,open:r,DrawerUpdate:u,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Np="api/branchapi/frontoffice/complaintShowdata",Lp="api/branchapi/frontoffice/complainttypedropdown",qp=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function zp({data:t}){const{handleUpdate:n,token:s}=t||{},r=i.useContext(Mt),l=Np.replace(/\?.*$/,""),{isLoading:o,data:d}=K(s&&r?[l,r,s]:null,([f,x,R])=>Ra(f,{id:x},R)),{isLoading:c,data:g}=K(s?[Lp,s]:null,([f,x])=>G(f,x)),y=i.useMemo(()=>qp(g).map(x=>({value:x?.value??x?.id??x?.complaint_type??"",label:x?.complaint_type??x?.label??""})),[g]),p=d?.data?.[0],[m,A]=i.useState({complain_type:"",complain_by_name:"",phone:"",date:null,description:"",action_token:"",assigned:"",note:"",file:""});i.useEffect(()=>{p&&A({complain_type:p?.complaint_type??"",complain_by_name:p?.name??"",phone:p?.contact??"",date:p?.date?se(p.date):null,description:p?.description??"",action_token:p?.action_taken??"",assigned:p?.assigned??"",note:p?.note??"",file:p?.image??""})},[p]);const C=(f,x)=>{A(R=>({...R,[f]:x}))},b=i.useMemo(()=>y.find(f=>f.value===m.complain_type)||null,[y,m.complain_type]);return o||c?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsxs("form",{onSubmit:f=>n(f,r),children:[e.jsx("input",{type:"hidden",name:"id",value:r??""}),e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Complaint"})}),e.jsx(w,{p:2,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",allowSelectAll:!1,value:b,onChange:f=>C("complain_type",f?.value??"")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0,value:m.complain_by_name,onChange:f=>C("complain_by_name",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{10}",value:m.phone,onChange:f=>C("phone",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",value:m.date,Desplay:"Enquiry Date",id:"date",name:"date",onChange:f=>C("date",f)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description",value:m.description,onChange:f=>C("description",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"action_token",type:"text",label:"Action Taken",value:m.action_token,onChange:f=>C("action_token",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"assigned",type:"text",label:"Assigned",value:m.assigned,onChange:f=>C("assigned",f.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note",value:m.note,onChange:f=>C("note",f.target.value)})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"center",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})]})})}const fa="api/branchapi/frontoffice/complainttablelist",Yp="api/branchapi/frontoffice/complainttypedropdown",Wp="api/branchapi/frontoffice/addcomplaint",Vp="api/branchapi/frontoffice/editcomplaint",Hp="api/branchapi/frontoffice/deletecomplaint",Kp=[{key:"all",label:"All Complaints"},{key:"pending",label:"Pending"},{key:"resolved",label:"Resolved"}];function Gp({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState("all"),m=i.useRef(null),A=(F,j)=>{s({page:F,rowsPerPage:Number.parseInt(j,10)})},C=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],b=i.useMemo(()=>{const F=fa.includes("?")?fa.endsWith("?")||fa.endsWith("&")?"":"&":"?",j=new URLSearchParams;return j.set("page",String(n.page)),j.set("per_page",String(n.rowsPerPage)),y!=="all"&&j.set("status",y),`${fa}${F}${j.toString()}`},[fa,n.page,n.rowsPerPage,y]),{isLoading:f,error:x,data:R,mutate:k}=K(t?[b,t]:null,([F,j])=>G(F,j)),{isLoading:O,data:_}=K(t?[Yp,t]:null,([F,j])=>G(F,j)),D=i.useMemo(()=>{const F=_?.data??_??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},[_]),u=async(F,j)=>{try{await k(Ge(F,j,t),st(j)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},h=async F=>{try{await k(Ze(Hp,F,t),nt(F)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},S=async(F,j,P)=>{try{const I=await tt(F,j,t);k(I),Array.isArray(I?.data)&&k(`${fa.replace(/\?.*$/,"")}?id=${P}`,I),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},E=async(F,j)=>{F.preventDefault();const P=new FormData(F.target);await S(Vp,P,j),F.target.reset(),d(""),l(!1)},$=async F=>{if(F.preventDefault(),!F.target?.date?.value)v.error("Select required dates"),F.target?.date?.focus(),g("textDanger");else{const j=new FormData(F.target);await u(Wp,j),F.target.reset(),g(""),d("")}},q=F=>{l(F)},T=i.useMemo(()=>[{id:"1",name:"Complain Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Action Taken",selector:"action_taken",sortable:!0},{id:"6",name:"Assigned",selector:"assigned",sortable:!0}],[]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Complaint"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:$,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",required:!0,allowSelectAll:!1})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",defaultValue:se(),Desplay:"Complain Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"action_token",type:"text",label:"Action Taken"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"assigned",type:"text",label:"Assigned"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"note",type:"text",label:"Note"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx("input",{type:"hidden",name:"file",value:o||"",readOnly:!0})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Complaint List"})}),e.jsxs(w,{pt:3,children:[e.jsx(a.Tabs,{activeKey:y,onChange:p,items:Kp}),e.jsx(kt,{data:{tableRef:m}}),e.jsx(ze,{parentCallback:A,data:{newData:R,columns:T,action:!0,ActionView:C,Loading:f,error:x,editDesign:e.jsx(zp,{data:{handleUpdate:E,token:t}}),deleteTodoMutation:h,open:r,DrawerUpdate:q,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const ti="api/branchapi/Frontoffice/purposetablelist",Jp="api/branchapi/Frontoffice/complaint_typetablelist",Qp="api/branchapi/Frontoffice/sourcetablelist",Xp="api/branchapi/Frontoffice/referencetablelist",ai="api/branchapi/frontoffice/visitorpurposeShowdata",Zp="api/branchapi/frontoffice/complaintTypeShowdata",em="api/branchapi/frontoffice/sourceShowdata",tm="api/branchapi/frontoffice/referenceShowdata",va=[{key:"purpose",label:"Purpose"},{key:"complainType",label:"Complain Type"},{key:"source",label:"Source"},{key:"reference",label:"Reference"}],ni={purpose:[{id:"1",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],complainType:[{id:"1",name:"Complaint Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],source:[{id:"1",name:"Source",selector:"source",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],reference:[{id:"1",name:"Reference",selector:"reference",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}]};function am({token:t}){const[n,s]=i.useState("purpose"),[r,l]=i.useState({page:1,rowsPerPage:10}),[o,d]=i.useState(!1),c=i.useRef(null),g=($,q)=>{l({page:$,rowsPerPage:Number.parseInt(q,10)})},y=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],p=()=>{switch(n){case"purpose":return ti;case"complainType":return Jp;case"source":return Qp;case"reference":return Xp;default:return ti}},m=()=>{switch(n){case"purpose":return"api/branchapi/frontoffice/addvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/addcomplaint_type";case"source":return"api/branchapi/frontoffice/addsource";case"reference":return"api/branchapi/frontoffice/addreference";default:return"api/branchapi/frontoffice/addvisitors_purpose"}},A=()=>{switch(n){case"purpose":return"api/branchapi/frontoffice/editvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/editcomplaint_type";case"source":return"api/branchapi/frontoffice/editsource";case"reference":return"api/branchapi/frontoffice/editreference";default:return"api/branchapi/frontoffice/editvisitors_purpose"}},C=$=>{switch(n){case"purpose":return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:$};case"complainType":return{url:"api/branchapi/frontoffice/deletecomplaint_type",id:$};case"source":return{url:"api/branchapi/frontoffice/deletesource",id:$};case"reference":return{url:"api/branchapi/frontoffice/deletereference",id:$};default:return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:$}}},b=i.useMemo(()=>{const $=p(),q=$.includes("?")?$.endsWith("?")||$.endsWith("&")?"":"&":"?";return`${$}${q}page=${r.page}&per_page=${r.rowsPerPage}`},[n,r.page,r.rowsPerPage]),{isLoading:f,error:x,data:R,mutate:k}=K(t?[b,t]:null,([$,q])=>G($,q)),O=async($,q)=>{try{await Ge($,q,t),await k(),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},_=async $=>{const{url:q,id:T}=C($);try{await Ze(q,T,t),await k(),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},D=async($,q,T)=>{try{const F=await tt($,q,t);k(F),Array.isArray(F?.data)&&k(`${p().replace(/\?.*$/,"")}?id=${T}`,F),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},u=async($,q)=>{$.preventDefault();const T=new FormData($.target),F=A();await D(F,T,q),$.target.reset(),d(!1)},h=async $=>{$.preventDefault();const q=new FormData($.target),T=m();await O(T,q),$.target.reset()},S=$=>{d($)},E=i.useMemo(()=>ni[n]||ni.purpose,[n]);return e.jsx(w,{pt:5,pb:1,children:e.jsx(a.Row,{gutter:[16,16],children:e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Setup Front Office"})}),e.jsxs(w,{p:3,children:[e.jsx(a.Tabs,{activeKey:n,onChange:$=>{s($),l({page:1,rowsPerPage:10})},items:va}),e.jsxs(a.Row,{gutter:[16,16],mt:3,children:[e.jsx(a.Col,{xs:24,md:8,children:e.jsx("form",{onSubmit:h,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Add ",va.find($=>$.key===n)?.label]})}),e.jsx(w,{p:3,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{required:!0,name:n==="reference"?"title":"name",type:"text",label:va.find($=>$.key===n)?.label+" *"})})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description"})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Add",color:"primary"})})})})]})})]})})}),e.jsx(a.Col,{xs:24,md:16,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:[va.find($=>$.key===n)?.label," List"]})}),e.jsxs(w,{pt:3,children:[e.jsx(kt,{data:{tableRef:c}}),e.jsx(ze,{parentCallback:g,data:{newData:R,columns:E,action:!0,ActionView:y,Loading:f,error:x,editDesign:e.jsx(nm,{data:{handleUpdate:u,token:t,activeTab:n}}),deleteTodoMutation:_,open:o,DrawerUpdate:S,viewDetails:""}})]})]})})]})]})]})})})})}function nm({data:t}){const{handleUpdate:n,token:s,activeTab:r}=t||{},l=i.useContext(Mt),d=(f=>{switch(f){case"purpose":return ai;case"complainType":return Zp;case"source":return em;case"reference":return tm;default:return ai}})(r).replace(/\?.*$/,""),{isLoading:c,data:g}=K(s&&l?[d,l,s]:null,([f,x,R])=>Ra(f,{id:x},R)),y=g?.data?.[0],[p,m]=i.useState({name:"",description:""});i.useEffect(()=>{y&&m({name:y?.visitors_purpose||y?.complaint_type||y?.source||y?.reference||"",description:y?.description||""})},[y]);const A=(f,x)=>{m(R=>({...R,[f]:x}))};if(c)return e.jsx(w,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(a.Spin,{size:"large"})});const b={purpose:"title",complainType:"title",source:"title",reference:"title"}[r]||"name";return e.jsxs(w,{pt:4,pb:1,style:{width:350},children:[e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Edit ",va.find(f=>f.key===r)?.label]})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:f=>n(f,l),children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{type:"text",value:l,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{name:b,type:"text",label:va.find(f=>f.key===r)?.label+" *",required:!0,value:p.name,onChange:f=>A("name",f.target.value)})})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description",value:p.description,onChange:f=>A("description",f.target.value)})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"center",children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})]})})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const sm="api/branchapi/Student/studentGatePass",$a="api/branchapi/Student/studentGatePassList";function rm({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:25}),[r,l]=i.useState(!1),o=i.useRef(null),d=(O,_)=>{s({page:O,rowsPerPage:Number.parseInt(_,10)})},c=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],{data:g,mutate:y}=K(t?[sm,t]:null,([O,_])=>G(O,_)),p=i.useMemo(()=>{const O=$a.includes("?")?$a.endsWith("?")||$a.endsWith("&")?"":"&":"?";return`${$a}${O}page=${n.page}&per_page=${n.rowsPerPage}`},[$a,n.page,n.rowsPerPage]),{isLoading:m,error:A,data:C,mutate:b}=K(t?[p,t]:null,([O,_])=>G(O,_)),f=async O=>{const _="api/branchapi/frontoffice/deletevisitors";try{await b(deleteData(_,O,t),nt(O)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},x=O=>{l(O)},R=()=>{},k=[{title:"Name",dataIndex:"lastname",key:"lastname",render:(O,_)=>`${_?.lastname||""} ${_?.firstname||""}`.trim()},{title:"Class",dataIndex:"class_name",key:"class_name",render:(O,_)=>`${_?.class_name||""}-${_?.section_name||""}`},{title:"Father Name",dataIndex:"father_name",key:"father_name"},{title:"Authorized Persons",dataIndex:"authorized_persons_fullname",key:"authorized_persons_fullname"},{title:"Relation",dataIndex:"authorized_persons_relation",key:"authorized_persons_relation"},{title:"Generated Date",dataIndex:"genrated_date_time",key:"genrated_date_time"},{title:"Return Date",dataIndex:"expected_return_date_time",key:"expected_return_date_time"},{title:"Reason",dataIndex:"reason",key:"reason"},{title:"Action",key:"action",render:(O,_)=>e.jsx(a.Tag,{color:_?.status==="Generated"?"green":"blue",children:_?.status||"Pending"})},{title:"Print",key:"print",render:(O,_)=>e.jsx(ee.PrinterOutlined,{style:{color:"#3892ee",cursor:"pointer"},onClick:()=>window.print()})}];return e.jsx(w,{pt:5,pb:1,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Today Gate Pass"})}),e.jsx(w,{pt:3,children:e.jsx(a.List,{grid:{column:4,gutter:16},dataSource:g?.data||[],style:{padding:0},renderItem:O=>e.jsx(a.List.Item,{style:{padding:0},children:e.jsx(a.Card,{size:"small",style:{marginBottom:8,width:"100%"},children:e.jsxs(w,{children:[e.jsxs(a.Typography.Text,{strong:!0,children:[O?.lastname," ",O?.firstname]}),e.jsx("br",{}),e.jsxs(a.Typography.Text,{type:"secondary",children:[O?.class_name,"-",O?.section_name]}),e.jsx("br",{}),e.jsxs(a.Typography.Text,{type:"secondary",children:["Return: ",O?.expected_return_date_time]}),e.jsx("br",{}),e.jsx(ie,{type:"button",value:"Print",color:"primary",size:"small",onClick:()=>window.print(),style:{marginTop:4}})]})})})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Gate Pass List"})}),e.jsxs(w,{pt:3,children:[e.jsx(kt,{data:{tableRef:o}}),e.jsx(ze,{parentCallback:d,data:{newData:C,columns:k,action:!1,ActionView:c,Loading:m,error:A,editDesign:"",deleteTodoMutation:f,open:r,DrawerUpdate:x,viewDetails:R}})]})]})})]})})}const wt=({id:t,funcName:n,disabled:s=!1})=>{const r="Data",[l,o]=i.useState(!1),d=()=>{o(!0),n(t),a.message.success(`${r} deleted successfully!`)},c=()=>{a.message.info(`Deletion of ${r} cancelled`)};return e.jsx(a.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:s||l,children:e.jsx(a.Button,{danger:!0,disabled:s,loading:l,icon:e.jsx(ee.DeleteOutlined,{}),size:"small"})})},si={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function im({token:t,sampleTemplateUrl:n=Hc}){const[s,r]=i.useState({pagination:{current:1,pageSize:10}}),[l,o]=i.useState(!1),[d,c]=i.useState(null),[g,y]=i.useState(null),[p,m]=i.useState(!1),[A,C]=i.useState([]),b=`api/branchapi/Transport/routeTableList?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,f="api/branchapi/Transport/addroute",x="api/branchapi/Transport/editroute",R="api/branchapi/Transport/deleteroute",k=void 0,{isLoading:O,data:_,error:D,mutate:u}=K(t?[b,t]:null,([Y,B])=>G(Y,B)),h=i.useMemo(()=>!_?.data||Array.isArray(_.data)?[]:_.data?.rows||[],[_]),S=_?.data?.pagination?.total_rows||_?.pagination?.total_rows||0,E=async(Y,B)=>{try{await u(Ge(Y,B,t),st(B)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},$=Y=>{Y.preventDefault();const B=new FormData(Y.target);E(f,B),Y.target.reset()},q=(Y,B)=>{r(U=>({...U,pagination:{current:Y,pageSize:parseInt(B,10)}}))},T=async Y=>{try{await u(Ze(R,Y,t),nt(Y)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},F=Y=>{c(Y),o(!0)},j=async Y=>{try{const B=await tt(x,Y,t);u(B),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),c(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},P=async Y=>{Y.preventDefault();const B=new FormData(Y.target);B.append("id",d?.id),j(B)},I=async()=>{if(!g){v.error("Please select an Excel file to upload.",{duration:1e3});return}m(!0),C([]);try{const Y=new FormData;Y.append("file",g);const U=await(await fetch(`${k}`,{method:"POST",headers:{Authorization:t},body:Y})).json();if(U.Status==="Success"){const M=U.data?.rows||[];C(M);const L=U.data?.success_count||0,z=U.data?.failed_count||0;v.success(U.message||`Route bulk upload completed. ${L} succeeded, ${z} failed.`,{duration:1e3}),L>0&&u()}else v.error(U.message||"Failed to upload routes.",{duration:1e3})}catch(Y){v.error(Y?.message||"Something went wrong.",{duration:1e3})}finally{m(!1),y(null)}},N=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(Y,B)=>(Y.route_title||"").localeCompare(B.route_title||"")}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(Y,B)=>Number(Y.fare||0)-Number(B.fare||0)}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(Y,B)=>(Y.note||"").localeCompare(B.note||"")}},{title:"Action",key:"action",render:(Y,B)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>F(B),style:{padding:2}}),e.jsx(wt,{id:B?.id,funcName:T})]})}],W=d?.route_title?`Edit ${d.route_title}`:"Edit Route";return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Routes"})}),e.jsxs(w,{p:3,children:[e.jsxs(a.Row,{gutter:[16,16],align:"middle",children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(a.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:Y=>(y(Y),!1),children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:p,children:g?g.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(a.Button,{type:"primary",onClick:I,disabled:p||!g,loading:p,children:p?"Uploading...":"Upload Routes"})})})]}),A.length>0&&e.jsxs(w,{mt:3,children:[e.jsx(be,{level:5,children:"Upload Results"}),e.jsx(a.Table,{dataSource:A.map((Y,B)=>({...Y,key:B})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Title",dataIndex:"title"},{title:"Status",dataIndex:"status",render:Y=>e.jsx("span",{style:{color:Y==="Success"?"green":"red",fontWeight:500},children:Y})},{title:"Message",dataIndex:"message"}]})]}),n&&e.jsx(w,{mt:2,children:e.jsx("a",{href:n,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})})]})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Add Route"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:$,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(V,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"})})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(V,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"})})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(V,{type:"text",name:"note",label:"Note"})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsxs(w,{children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(a.Button,{type:"text",htmlType:"reset",style:si,children:"Cancel"})]})})})})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Route List"})}),e.jsx(w,{p:3,children:e.jsx(ze,{parentCallback:q,data:{newData:{data:h,pagination:{total_rows:S}},columns:N,columnstype:"antd",action:!1,Loading:O,error:D,deleteTodoMutation:T}})})]})})]}),e.jsx(a.Drawer,{open:l,title:W,placement:"right",width:420,onClose:()=>{o(!1),c(null)},children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"title",label:"Title",defaultValue:d?.route_title||"",required:"required"}),e.jsx(V,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:d?.fare||"",required:"required"}),e.jsx(V,{type:"text",name:"note",label:"Note",defaultValue:d?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(V,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{o(!1),c(null)},style:si,children:"Cancel"})]})]})})})]})}const ri={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function lm({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${n.page}&per_page=${n.rowsPerPage}`,g="api/branchapi/Transport/addvehicles",y="api/branchapi/Transport/editvehicle",p="api/branchapi/Transport/deletevehicle",{isLoading:m,data:A,error:C,mutate:b}=K(t?[c,t]:null,([S,E])=>G(S,E)),f=async(S,E)=>{try{await b(Ge(S,E,t),st(E)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},x=S=>{S.preventDefault();const E=new FormData(S.target);f(g,E),S.target.reset()},R=async S=>{try{await b(Ze(p,S,t),nt(S)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},k=S=>{d(S),l(!0)},O=async S=>{try{await tt(y,S,t),await b(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},_=async S=>{S.preventDefault();const E=new FormData(S.target);E.append("id",o?.id),O(E)},D=(S,E)=>{s({page:S,rowsPerPage:parseInt(E,10)})},u=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(S,E)=>S.vehicle_no.localeCompare(E.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(S,E)=>S.vehicle_model.localeCompare(E.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(S,E)=>S.seating_capacity-E.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(S,E)=>S.manufacture_year-E.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(S,E)=>S.gps_url.localeCompare(E.gps_url)},render:(S,E)=>e.jsx("span",{title:E?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(S,E)=>S.note.localeCompare(E.note)}},{title:"Action",key:"action",render:(S,E)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(E),style:{padding:2}}),e.jsx(wt,{id:E?.id,funcName:R})]})}],h=o?.vehicle_no?`Edit ${o.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(a.Drawer,{open:r,title:h,placement:"right",width:420,onClose:()=>{l(!1),d(null)},children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"number",label:"Vehicle Number",defaultValue:o?.vehicle_no||"",required:"required"}),e.jsx(V,{type:"text",name:"model",label:"Vehicle Model",defaultValue:o?.vehicle_model||""}),e.jsx(V,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:o?.manufacture_year||""}),e.jsx(V,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:o?.seating_capacity||""}),e.jsx(V,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:o?.gps_url||""}),e.jsx(V,{type:"text",name:"note",label:"Note",defaultValue:o?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null)},style:ri,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(w,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(V,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(V,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(V,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(V,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(V,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(a.Button,{type:"text",htmlType:"reset",style:ri,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(w,{children:e.jsx(ze,{parentCallback:D,data:{newData:A,columns:u,columnstype:"antd",action:!1,Loading:m,error:C,deleteTodoMutation:R}})})]})})]})})]})}const om={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ii=({dataIndex:t,title:n,record:s,children:r,isEditable:l,...o})=>e.jsx("td",{...o,children:l?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function dm({token:t}){const[n,s]=i.useState(!1),[r,l]=i.useState({pagination:{current:1,pageSize:50}}),[o,d]=i.useState(null),[c,g]=i.useState([]),y="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleDropdown",m="api/branchapi/Transport/getchechkedVehicleData",A="api/branchapi/Transport/assignedVehicleTable",C="api/branchapi/transport/assignvehicle",b="api/branchapi/Transport/deleteassignvehicle",f=o?`${m}?route_id=${o}`:null,{isLoading:x,data:R,mutate:k}=K(t?[`${A}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([U,M])=>G(U,M)),{data:O}=K(t&&y?[y,t]:null,([U,M])=>G(U,M)),{data:_}=K(t&&p?[p,t]:null,([U,M])=>G(U,M)),D=t&&f?[f,t]:null,{isLoading:u,data:h}=K(D,([U,M])=>G(U,M)),{Status:S="Failed",pagination:{total_rows:E=0}={}}=R||{},{data:$=[]}=S==="Success"?R:{},q=i.useMemo(()=>{const U=O?.data??O??[];return Array.isArray(U)?U:[]},[O]),T=i.useMemo(()=>{const U=_?.data??_??[];return(Array.isArray(U)?U:[]).map(L=>{if(L==null)return null;if(typeof L=="string"||typeof L=="number")return{label:String(L),value:L};const z=L.value??L.vehicle_id??L.id??L.vehicleID,ne=L.label??L.vehicle_name??L.vehicle_no??L.vehicle_number??L.name??String(z??"");return z==null||ne===""?null:{label:String(ne),value:z}}).filter(Boolean)},[_]),F=i.useMemo(()=>{const U=h?.data??h??[];return(Array.isArray(U)?U:[]).map(L=>L?.value??L?.vehicle_id??L?.id??L).filter(L=>L!=null)},[h]);i.useEffect(()=>{g(F)},[F,n]);const j=async(U,M,L)=>{try{await k(Ge(U,M,t),st(M)),f&&K.mutate(D),s(z=>!z),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(z){v.error(z?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},P=U=>{U.preventDefault();const M=new FormData;M.append("route_id",o??""),c.length?c.forEach(L=>M.append("vehicle_ids[]",L)):M.append("vehicle_ids[]",""),j(C,M)},I=U=>{l(M=>({...M,pagination:{current:U,pageSize:M.pagination.pageSize}}))},N=async U=>{try{await k(Ze(b,U,t),nt(U)),f&&K.mutate(D),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},W=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(U,M,L)=>e.jsx(e.Fragment,{children:M.children.map((z,ne,X)=>e.jsx("span",{children:`${z.vehicle_name} ${ne+1===X.length?"":","}`},`${ne}vehicle001`))})},{title:"Action",render:(U,M,L)=>e.jsx(e.Fragment,{children:e.jsx(wt,{id:M?.route_id,funcName:N})})}],Y=U=>{const M=["route_id","index"];for(let L=0;L<M.length;L++)if(U[M[L]])return U[M[L]]},B=U=>{const{children:M=[]}=U||{},L=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:z=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:z=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:z=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:z=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:z=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:z=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:z=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(a.Table,{components:{body:{cell:ii}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:L,rowKey:z=>Y(z)+"cell01",dataSource:M,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(w,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:U=>{d(U?.value??null),s(M=>!M)}})}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:e.jsx(a.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:T,value:c,onChange:U=>g(U),disabled:!o||u})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(a.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),g([]),s(U=>!U)},style:om,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(w,{style:{padding:"10px 16px"},children:e.jsx(a.Table,{components:{body:{cell:ii}},columns:W,bordered:!0,rowKey:U=>Y(U),dataSource:Array.isArray($)?$:[],loading:x,expandable:{expandedRowRender:B,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:E,showSizeChanger:!0,onChange:I,onShowSizeChange:(U,M)=>{l(L=>({...L,pagination:{current:1,pageSize:M}}))},showTotal:(U,M)=>`${M[0]}-${M[1]} of ${U} items`}})})]})})]})})]})}const li={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ks=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},ya=(t,n,s)=>{if(n==null||n==="")return null;const r=t.find(l=>String(l.value)===String(n));return r||(s?{label:String(s),value:n}:{label:String(n),value:n})},cm=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},um=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(s=>s!=null&&s!==""&&String(s).toLowerCase()!=="null"&&String(s).toLowerCase()!=="undefined").join(", ");const n=String(t).trim();return!n||n.toLowerCase()==="null"||n.toLowerCase()==="undefined"?"":n};function pm({token:t,assignmentId:n,studentName:s,onClose:r,onSuccess:l}){const o="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",g="api/branchapi/Transport/getvehicleListByRouteIdwithCount",y="api/branchapi/Transport/getStoppageDropdown",p="api/branchapi/Transport/routeShowdata",[m,A]=i.useState(null),[C,b]=i.useState(null),[f,x]=i.useState(null),[R,k]=i.useState(se()),[O,_]=i.useState(""),[D,u]=i.useState(0),[h,S]=i.useState(0),{data:E,isLoading:$}=K(t&&n?[`${o}?id=${n}`,t]:null,([oe,Ce])=>G(oe,Ce)),q=i.useMemo(()=>{if(!E||E?.Status&&E.Status!=="Success")return null;const oe=E?.data??E;return Array.isArray(oe)?oe[0]??null:oe},[E]);i.useEffect(()=>{const oe=q?.fk_route_id??q?.route_id;oe!=null&&A(oe),q?.vehicle_id!=null&&b(q.vehicle_id),q?.stop_id!=null&&x(q.stop_id),k(q?.start_date?se(q.start_date):se()),_(um(q?.service_push))},[q]);const T=t&&m?`${g}?route_id=${m}`:null,F=t&&m?`${p}?id=${m}`:null,j=t&&m?`${y}?route_id=${m}`:null,{data:P}=K(t&&c?[c,t]:null,([oe,Ce])=>G(oe,Ce)),{data:I,isLoading:N}=K(T?[T,t]:null,([oe,Ce])=>G(oe,Ce)),{data:W,isLoading:Y}=K(j?[j,t]:null,([oe,Ce])=>G(oe,Ce)),{data:B}=K(F?[F,t]:null,([oe,Ce])=>G(oe,Ce)),U=i.useMemo(()=>ks(P),[P]),M=i.useMemo(()=>ks(I),[I]),L=i.useMemo(()=>ks(W),[W]),z=E?.data[0]?.rootCost,ne=cm(),X=s||[q?.firstname,q?.lastname].filter(Boolean).join(" ")||"",J=(oe,Ce)=>{switch(Ce){case"route_id":A(oe?.value??null),b(null),x(null),u(Ne=>Ne+1),S(Ne=>Ne+1);break;case"vehicle_id":b(oe?.value??null),x(null),S(Ne=>Ne+1);break;case"stop_id":x(oe?.value??null);break}},H=async oe=>{if(oe.preventDefault(),!m||!C||!f){v.error("Please select Route, Vehicle and Stop",{duration:1200});return}const Ce=new FormData;Ce.append("id",String(n)),Ce.append("student_id",String(q?.fk_student_id??q?.student_id??"")),Ce.append("fk_route_id",String(m)),Ce.append("vehicle_id",String(C)),Ce.append("stop_id",String(f)),Ce.append("rootCost",String(z??"")),Ce.append("start_date",R?.isValid?.()?R.format("YYYY-MM-DD"):se().format("YYYY-MM-DD")),Ce.append("puse_service",String(O??""));try{await tt(d,Ce,t),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l?.(),r?.()}catch(Ne){v.error(Ne?.message??"Failed to update the item.",{duration:1e3})}};if($||!(q&&!$&&(!m||!N&&!Y)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(a.Spin,{})});if(!q)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(a.Button,{type:"text",onClick:r,style:li,children:"Close"})]});const ce=q.fk_route_id??q.route_id,De=ya(U,ce,q.route_title),le=ya(M,q.vehicle_id,q.vehicle_name??q.vehicle_no),ue=ya(L,q.stop_id,q.stop_name??q.stoppage_name);return e.jsx("form",{onSubmit:H,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"title",label:"Student",defaultValue:X,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:q.fk_student_id??q.student_id??""}),e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:ya(U,m,De?.label)??null,onChange:oe=>J(oe,"route_id")}),e.jsx(Z,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:ya(M,C,le?.label)??null,onChange:oe=>J(oe,"vehicle_id")},`edit-vehicle-${D}`),e.jsx(Z,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:ya(L,f,ue?.label)??null,onChange:oe=>J(oe,"stop_id")},`edit-stop-${h}`),e.jsx(V,{type:"text",label:"Route Cost",value:z!=null?`${ne}${z}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:z??""}),e.jsx(He,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:R,onChange:oe=>k(oe)}),e.jsx(V,{type:"text",label:"Pause Service",value:O,onChange:oe=>_(oe?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:r,style:li,children:"Cancel"})]})]})},`edit-${n}-${D}`)}const oi={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},mm=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[]},Ua=t=>mm(t),hm=t=>t||"",fm=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},ym=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},gm=(t,n)=>{const s=n||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",l=encodeURIComponent(String(r));if(s.includes("{id}"))return s.replaceAll("{id}",l);if(s.includes(":id"))return s.replace(":id",l);try{const d=new URL(s,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(r)),`${d.pathname}${d.search}${d.hash}`}catch{}const o=s.includes("?")?"&":"?";return`${s}${o}id=${l}`};function xm({token:t,editType:n,onNavigate:s,editPagePath:r,sampleTemplateUrl:l=Kc}){const d=ym(n)==="drawer",c="api/branchapi/academy/classdropdownlist",g="api/branchapi/academy/sectionoftheClass",y="api/branchapi/Transport/routeStudentList",p="api/branchapi/Transport/getrouteDropdown",m="api/branchapi/Transport/getvehicleListByRouteIdwithCount",A="api/branchapi/Transport/getStoppageDropdown",C="api/branchapi/Transport/routeShowdata",b="api/branchapi/Transport/assignTransportRoutesStudent",f="api/branchapi/transport/removeStudentTransport",x="api/branchapi/transport/assignTransportRoutesStudentBulk",[R,k]=i.useState(null),[O,_]=i.useState(!1),[D,u]=i.useState(!1),[h,S]=i.useState(null),[E,$]=i.useState(null),[q,T]=i.useState(null),[F,j]=i.useState(null),[P,I]=i.useState(!1),[N,W]=i.useState(!1),[Y,B]=i.useState({page:1,rowsPerPage:50}),[U,M]=i.useState(null),[L,z]=i.useState(!1),[ne,X]=i.useState(null),[J,H]=i.useState(null),[Q,ce]=i.useState(null),[De,le]=i.useState(null),[ue,oe]=i.useState(null),[Ce,Ne]=i.useState(null),[et,we]=i.useState(null),[Ae,Fe]=i.useState(se()),[me,de]=i.useState(""),[Re,Be]=i.useState(null),[$e,ge]=i.useState(!1),[_e,ve]=i.useState([]),re=(Se,Oe)=>{const dt=Se?.value??null;switch(Oe){case"class_id":ce(dt),le(null),M(dt?`${g}?class_id=${encodeURIComponent(String(dt))}`:null),_(Bt=>!Bt);break;case"route_id":oe(dt),Ne(null),we(null),H(dt),$(dt?`${m}?route_id=${encodeURIComponent(String(dt))}`:null),T(dt?`${C}?id=${encodeURIComponent(String(dt))}`:null),j(null),I(Bt=>!Bt),W(Bt=>!Bt);break;case"vehicle_id":Ne(dt),we(null),j(ue?`${A}?route_id=${encodeURIComponent(String(ue))}`:null),W(Bt=>!Bt);break;case"stop_id":we(dt);break}},xe=Se=>{if(d){S(Se),u(!0);return}const Oe=gm(Se,r);if(typeof s=="function"){s(Oe,Se);return}typeof window<"u"&&Oe&&window.location.assign(Oe)},je=()=>{u(!1),S(null)},Le=h?`Edit — ${h.firstname??""} ${h.lastname??""}`.trim():"Edit Student Transport",{data:qe}=K(t&&c?[c,t]:null,([Se,Oe])=>G(Se,Oe)),{data:fe}=K(t&&U?[U,t]:null,([Se,Oe])=>G(Se,Oe)),{data:Ie}=K(t&&E?[E,t]:null,([Se,Oe])=>G(Se,Oe)),{data:Je}=K(t&&F?[F,t]:null,([Se,Oe])=>G(Se,Oe)),{data:mt}=K(t&&q?[q,t]:null,([Se,Oe])=>G(Se,Oe)),{data:Et}=K(t&&p?[p,t]:null,([Se,Oe])=>G(Se,Oe)),Tt=t&&R?`${R}&page=${Y.page}&per_page=${Y.rowsPerPage}`:null,{isLoading:ye,error:ke,data:ae,mutate:pe}=K(Tt?[Tt,t]:null,([Se,Oe])=>G(Se,Oe)),Pe=i.useMemo(()=>Ua(qe),[qe]),Ee=i.useMemo(()=>Ua(fe),[fe]),it=i.useMemo(()=>Ua(Ie),[Ie]),lt=i.useMemo(()=>Ua(Je),[Je]),ft=i.useMemo(()=>Ua(Et),[Et]),he=mt?.data?.[0]?.fare??mt?.data?.fare??mt?.fare??mt?.data?.data?.[0]?.fare??mt?.data?.data?.fare;i.useEffect(()=>{he==null||he===""||de(String(he))},[he]);const Te=async Se=>{try{await pe(Ze(f,Se,t),nt(Se)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},Ke=async()=>{if(!Re){v.error("Please select an Excel file to upload.",{duration:1e3});return}ge(!0),ve([]);try{const Se=new FormData;Se.append("file",Re);const dt=await(await fetch(`${x}`,{method:"POST",headers:{Authorization:t},body:Se})).json();if(dt.Status==="Success"){const Bt=dt.data?.rows||[];ve(Bt);const xr=dt.data?.success_count||0,Yo=dt.data?.failed_count||0;v.success(dt.message||`Transport bulk upload completed. ${xr} succeeded, ${Yo} failed.`,{duration:1e3}),xr>0&&pe()}else v.error(dt.message||"Failed to upload student transport assignments.",{duration:1e3})}catch(Se){v.error(Se?.message||"Something went wrong.",{duration:1e3})}finally{ge(!1),Be(null)}},ot=[{title:"Route Status",key:"route_status",render:(Se,Oe)=>Oe.fk_route_id?e.jsx("span",{children:Oe.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(Se,Oe)=>hm(Oe.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:(Se,Oe)=>`${Oe.firstname} ${Oe.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(Se,Oe)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:Oe.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(wt,{id:Oe?.id,funcName:Te}),e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>xe(Oe),style:{padding:2}})]}):e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>gs(Oe.student_id),style:{padding:2}})})}],xt=async(Se,Oe)=>{try{await pe(Ge(Se,Oe,t),st(Oe)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),z(!1),xs()}catch{v.error("Failed to add the new item.",{duration:1e3})}},_t=Se=>{if(Se.preventDefault(),!Q||!De){v.error("Please select Class and Section",{duration:1200});return}k(`${y}?cID=${encodeURIComponent(String(Q))}&sID=${encodeURIComponent(String(De))}`),B(Oe=>({...Oe,page:1}))},ys=(Se,Oe)=>{B({page:Se,rowsPerPage:parseInt(Oe,10)})},gs=Se=>{X(Se),z(!0)},Pa=Se=>{if(Se.preventDefault(),!ne){v.error("Student is required",{duration:1200});return}if(!ue||!Ce||!et){v.error("Please select Route, Vehicle and Stop",{duration:1300});return}const Oe=new FormData;Oe.append("student_id",String(ne)),Oe.append("fk_route_id",String(ue)),Oe.append("vehicle_id",String(Ce)),Oe.append("stop_id",String(et)),Oe.append("start_date",Ae?.isValid?.()?Ae.format("YYYY-MM-DD"):se().format("YYYY-MM-DD")),Oe.append("rootCost",String(me??"")),xt(b,Oe)},xs=()=>{z(!1),$(null),T(null),j(null),H(null),oe(null),Ne(null),we(null),Fe(se()),de(""),I(Se=>!Se),W(Se=>!Se)},zo=fm();return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Assign Students to Transport"})}),e.jsxs(w,{p:3,children:[e.jsxs(a.Row,{gutter:[16,16],align:"middle",children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(a.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:Se=>(Be(Se),!1),children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:$e,children:Re?Re.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(a.Button,{type:"primary",onClick:Ke,disabled:$e||!Re,loading:$e,children:$e?"Uploading...":"Upload Students"})})})]}),l&&e.jsx(w,{mt:2,children:e.jsx("a",{href:l,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})}),_e.length>0&&e.jsxs(w,{mt:3,children:[e.jsx(be,{level:5,children:"Upload Results"}),e.jsx(a.Table,{dataSource:_e.map((Se,Oe)=>({...Se,key:Oe})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Student ID",dataIndex:"student_id"},{title:"Status",dataIndex:"status",render:Se=>e.jsx("span",{style:{color:Se==="Success"?"green":"red",fontWeight:500},children:Se})},{title:"Message",dataIndex:"message"}]})]})]})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Search Students"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:_t,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(Z,{options:Pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:Se=>re(Se,"class_id"),required:!0,allowSelectAll:!1,value:Pe.find(Se=>String(Se.value)===String(Q))??null})})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(Z,{options:Ee,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:Ee.find(Se=>String(Se.value)===String(De))??null,onChange:Se=>le(Se?.value??null)},`section1${O}`)})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsxs(w,{display:"flex",alignItems:"center",height:"100%",mt:2,children:[e.jsx(ie,{type:"submit",value:"Search",color:"primary"}),e.jsx(a.Button,{type:"text",htmlType:"button",onClick:()=>{k(null),M(null),ce(null),le(null),_(Se=>!Se)},style:oi,children:"Cancel"})]})})]})})})]})}),R&&e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(w,{p:3,children:e.jsx(ze,{parentCallback:ys,data:{newData:ae,columns:ot,columnstype:"antd",action:!1,Loading:ye,error:ke,deleteTodoMutation:Te,pageController:Y}})})]})})]}),e.jsx(a.Drawer,{open:D,title:Le,placement:"right",width:420,destroyOnClose:!0,onClose:je,children:h?.id&&e.jsx(pm,{token:t,assignmentId:h.id,studentName:`${h.firstname??""} ${h.lastname??""}`.trim(),onClose:je,onSuccess:()=>pe()})}),e.jsx(a.Modal,{open:L,title:"Assign Student to Transport",onCancel:xs,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:Pa,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:ft,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:ft.find(Se=>String(Se.value)===String(ue))??null,onChange:Se=>re(Se,"route_id")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:it,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:it.find(Se=>String(Se.value)===String(Ce))??null,onChange:Se=>re(Se,"vehicle_id")},`vehicle001${P}`)})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:lt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:lt.find(Se=>String(Se.value)===String(et))??null,onChange:Se=>re(Se,"stop_id")},`stop001${N}`)})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Ae,onChange:Se=>Fe(Se)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{type:"text",name:"rootCost",label:"Route Cost",value:me,onChange:Se=>de(Se?.target?.value??"")})})}),e.jsx(a.Col,{xs:24,children:e.jsxs(w,{display:"flex",alignItems:"center",gap:12,children:[e.jsx(ie,{type:"submit",value:String(me??"").trim()?`${zo}${me} — Assign`:"Assign",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:xs,style:oi,children:"Cancel"})]})})]})})})]})}const di={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},vn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function bm({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:50}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState(""),[C,b]=i.useState(!1),f=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,x="api/branchapi/Transport/add_driver",R="api/branchapi/Transport/edit_driver",k="api/branchapi/Transport/deletedriver",O="api/branchapi/staff/uploadDocuments",_=i.useMemo(()=>String(O).startsWith("http")?O:`${At()??""}${String(O).replace(/^\/+/,"")}`,[O]),D=At()??"",{isLoading:u,data:h,error:S,mutate:E}=K(t?[f,t]:null,([Y,B])=>G(Y,B)),$=async(Y,B)=>{try{await Ge(Y,B,t),await E(),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),g("")}catch(U){v.error(U?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},q=Y=>{Y.preventDefault();const B=new FormData(Y.target);$(x,B),Y.target.reset()},T=async Y=>{try{await E(Ze(k,Y,t),nt(Y)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},F=Y=>{d(Y),g(Y?.image??""),l(!0)},j=async Y=>{try{await tt(R,Y,t),await E(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null),g("")}catch(B){v.error(B?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},P=Y=>{Y.preventDefault();const B=new FormData(Y.target);B.append("id",o?.id??""),j(B)},I=(Y,B)=>{s({page:Y,rowsPerPage:parseInt(B,10)})},N=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(Y,B)=>String(Y?.name??"").localeCompare(String(B?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(Y,B)=>String(Y?.Driver_licence??"").localeCompare(String(B?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(Y,B)=>Number(Y?.contact_number??0)-Number(B?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(Y,B)=>String(Y?.address??"").localeCompare(String(B?.address??""))}},{title:"Image",key:"image",width:100,render:(Y,B)=>{const U=B?.image?`${D}staff/document/${B.image}`:"";return U?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(a.Image,{width:80,src:U,preview:{visible:!1,onVisibleChange:()=>{b(!0),p(U),A(B?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(Y,B)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>F(B),style:{padding:2}}),e.jsx(wt,{id:B?.id,funcName:T})]})}],W=o?.name?`Edit ${o.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(a.Drawer,{open:r,title:W,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{l(!1),d(null),g("")},children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"name",label:"Driver Name",defaultValue:o?.name??"",required:"required"}),e.jsx(V,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:o?.Driver_licence??"",required:"required"}),e.jsx(V,{type:"number",name:"contact_number",label:"Driver Contact",defaultValue:o?.contact_number??"",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:vn,children:"Address"}),e.jsx(a.Input.TextArea,{name:"address",defaultValue:o?.address??"",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:vn,children:"Image"}),e.jsx(a.Upload,{maxCount:1,action:_,headers:t?{Authorization:t}:void 0,onChange:Y=>{if(Y?.file?.status!=="done")return;const B=Y?.file?.response,U=B?.data??B?.filename??B?.file??B?.path??"";U&&g(String(U))},children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:!_,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null),g("")},style:di,children:"Cancel"})]})]})})}),e.jsx(a.Modal,{zIndex:9999,open:C,title:m,footer:null,onCancel:()=>b(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:y})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(w,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(V,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(V,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:vn,children:"Address"}),e.jsx(a.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:vn,children:"Image"}),e.jsx(a.Upload,{maxCount:1,action:_,headers:t?{Authorization:t}:void 0,onChange:Y=>{if(Y?.file?.status!=="done")return;const B=Y?.file?.response,U=B?.data??B?.filename??B?.file??B?.path??"";U&&g(String(U))},children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:!_,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(a.Button,{type:"text",htmlType:"reset",onClick:()=>g(""),style:di,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(w,{children:e.jsx(ze,{parentCallback:I,data:{newData:h,columns:N,columnstype:"antd",action:!1,Loading:u,error:S,deleteTodoMutation:T}})})]})})]})})]})}const ci={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ga={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},wn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ui=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],_n=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function jm({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:50}),[r,l]=i.useState(!1),[o,d]=i.useState(!1),[c,g]=i.useState(null),[y,p]=i.useState(null),[m,A]=i.useState(null),[C,b]=i.useState(null),[f,x]=i.useState(se()),[R,k]=i.useState(se()),[O,_]=i.useState("pick"),[D,u]=i.useState(!1),[h,S]=i.useState(null),[E,$]=i.useState(null),[q,T]=i.useState(!1),[F,j]=i.useState(null),[P,I]=i.useState(null),[N,W]=i.useState(null),[Y,B]=i.useState(null),[U,M]=i.useState(se()),[L,z]=i.useState(se()),[ne,X]=i.useState("pick"),J=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,H="api/branchapi/Transport/assignRouteTime",Q="api/branchapi/Transport/editAssignRouteTime",ce="api/branchapi/Transport/deleteAssignRouteTime",De="api/branchapi/Transport/driverDropdown",le="api/branchapi/transport/routeTimetableShowdata",ue="api/branchapi/Transport/getrouteDropdown",oe="api/branchapi/Transport/getvehicleDropdown",{isLoading:Ce,data:Ne,error:et,mutate:we}=K(t?[J,t]:null,([ye,ke])=>G(ye,ke)),{data:Ae}=K(t&&ue?[ue,t]:null,([ye,ke])=>G(ye,ke)),{data:Fe}=K(t&&De?[De,t]:null,([ye,ke])=>G(ye,ke)),me=i.useMemo(()=>c?`${oe}?route_id=${c}`:null,[c,oe]),{data:de}=K(t&&me?[me,t]:null,([ye,ke])=>G(ye,ke)),Re=i.useMemo(()=>_n(Ae),[Ae]),Be=i.useMemo(()=>_n(Fe),[Fe]),$e=i.useMemo(()=>_n(de),[de]),ge=(ye,ke)=>{s({page:ye,rowsPerPage:parseInt(ke,10)})},_e=async ye=>{ye.preventDefault();const ke=new FormData(ye.target);ke.set("route_id",y?.value??c??""),ke.set("driver_id",m?.value??""),ke.set("vehicle_id",C?.value??""),ke.set("start_time",f?f.format("h:mm a"):""),ke.set("drop_time",R?R.format("h:mm a"):""),ke.set("type",O);try{await Ge(H,ke,t),await we(),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),ye.target.reset(),g(null),p(null),A(null),b(null),d(ae=>!ae),x(se()),k(se()),_("pick"),l(ae=>!ae)}catch(ae){v.error(ae?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},ve=async ye=>{try{await Ze(ce,ye,t),await we(),v.success("Success! Deleted item.",{duration:1e3})}catch(ke){v.error(ke?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},re=ye=>{S(ye),u(!0);const ke=ye?.id??ye?.route_time_id??ye?.routeId??null;$(ke);const ae=ye?.route_id??ye?.routeId??ye?.fk_route_id;j(ae??null),I(Re.find(pe=>pe?.value===(ae??ye?.route_id))??null),W(Be.find(pe=>pe?.value===(ye?.driver_id??ye?.driverId))??null),B(null),T(pe=>!pe),M(ye?.start_time?se(ye.start_time,["h:mm a","HH:mm"]):se()),z(ye?.drop_time?se(ye.drop_time,["h:mm a","HH:mm"]):se()),X(ye?.type??"pick")},xe=i.useMemo(()=>{if(!E)return null;const ye=String(le).includes("?")?"&":"?";return`${le}${ye}id=${encodeURIComponent(String(E))}`},[E,le]),{data:je,isLoading:Le}=K(t&&xe?[xe,t]:null,([ye,ke])=>G(ye,ke)),qe=i.useMemo(()=>{const ye=je?.data??je;return Array.isArray(ye)?ye[0]??null:Array.isArray(ye?.data)?ye.data[0]??null:ye??null},[je]),fe=i.useMemo(()=>F?`${oe}?route_id=${F}`:null,[F,oe]),{data:Ie}=K(t&&fe?[fe,t]:null,([ye,ke])=>G(ye,ke)),Je=i.useMemo(()=>_n(Ie),[Ie]);i.useEffect(()=>{if(!qe)return;const ye=qe?.route_id??qe?.fk_route_id??qe?.routeId;j(ye??null),I(Re.find(ke=>ke?.value===ye)??null),W(Be.find(ke=>ke?.value===qe?.driver_id)??null),B(null),M(qe?.start_time?se(qe.start_time,["h:mm a","HH:mm"]):se()),z(qe?.drop_time?se(qe.drop_time,["h:mm a","HH:mm"]):se()),X(qe?.type??"pick"),T(ke=>!ke)},[Be,qe,Re]),i.useEffect(()=>{if(!qe)return;const ye=qe?.vehicle_id??qe?.vehicleId;ye&&B(Je.find(ke=>ke?.value===ye)??null)},[qe,Je]);const mt=async ye=>{if(ye.preventDefault(),!E)return;const ke=new FormData(ye.target);ke.set("id",String(E)),ke.set("route_id",P?.value??F??""),ke.set("driver_id",N?.value??""),ke.set("vehicle_id",Y?.value??""),ke.set("start_time",U?U.format("h:mm a"):""),ke.set("drop_time",L?L.format("h:mm a"):""),ke.set("type",ne);try{await tt(Q,ke,t),await we(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),u(!1),S(null)}catch(ae){v.error(ae?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Et=[{title:"Route Name",dataIndex:"route_title",key:"route_title"},{title:"Driver Name",dataIndex:"driver_name",key:"driver_name"},{title:"Vehicle Name",dataIndex:"vehicle_name",key:"vehicle_name"},{title:"Start Time",dataIndex:"start_time",key:"start_time"},{title:"End Time",dataIndex:"drop_time",key:"drop_time"},{title:"Type",dataIndex:"type",key:"type"},{title:"Action",key:"action",render:(ye,ke)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>re(ke),style:{padding:2}}),e.jsx(wt,{id:ke?.id??ke?.routeId??ke?.route_time_id,funcName:ve})]})}],Tt=h?.route_title?`Edit ${h.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(a.Drawer,{open:D,title:Tt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{u(!1),S(null),$(null),j(null),I(null),W(null),B(null)},children:e.jsx("form",{onSubmit:mt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Le?.6:1},children:[e.jsx(Z,{options:Re,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:P,onChange:ye=>{j(ye?.value??null),I(ye??null),B(null),T(ke=>!ke)}}),e.jsx(Z,{options:Be,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:N,onChange:ye=>W(ye??null)}),e.jsx(Z,{options:Je,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:Y,onChange:ye=>B(ye??null)},`edit-vehicle-${q}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ga,children:"Start Time"}),e.jsx(a.TimePicker,{value:U,onChange:ye=>M(ye),use12Hours:!0,format:"h:mm a",allowClear:!1,style:wn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ga,children:"Drop Time"}),e.jsx(a.TimePicker,{value:L,onChange:ye=>z(ye),use12Hours:!0,format:"h:mm a",allowClear:!1,style:wn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ga,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(a.Radio.Group,{options:ui,optionType:"button",buttonStyle:"solid",value:ne,onChange:ye=>X(ye.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{u(!1),S(null)},style:ci,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(w,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:_e,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:Re,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:y,onChange:ye=>{g(ye?.value??null),p(ye??null),b(null),d(ke=>!ke)},allowSelectAll:!1,required:!0}),e.jsx(Z,{options:Be,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:m,onChange:ye=>A(ye??null),allowSelectAll:!1,required:!0}),e.jsx(Z,{options:$e,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:C,onChange:ye=>b(ye??null),allowSelectAll:!1,required:!0},`vehicle-${o}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ga,children:"Start Time"}),e.jsx(a.TimePicker,{value:f,onChange:ye=>x(ye),use12Hours:!0,format:"h:mm a",allowClear:!1,style:wn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ga,children:"Drop Time"}),e.jsx(a.TimePicker,{value:R,onChange:ye=>k(ye),use12Hours:!0,format:"h:mm a",allowClear:!1,style:wn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:ga,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(a.Radio.Group,{options:ui,optionType:"button",buttonStyle:"solid",value:O,onChange:ye=>_(ye.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Add",color:"primary"}),e.jsx(a.Button,{type:"text",htmlType:"reset",onClick:()=>{g(null),p(null),A(null),b(null),d(ye=>!ye),x(se()),k(se()),_("pick"),l(ye=>!ye)},style:ci,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(w,{children:e.jsx(ze,{parentCallback:ge,data:{newData:Ne,columns:Et,columnstype:"antd",action:!1,Loading:Ce,error:et,deleteTodoMutation:ve}})})]})})]})})]})}const Sm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},pi={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},mi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},hi=({dataIndex:t,title:n,record:s,children:r,isEditable:l,...o})=>e.jsx("td",{...o,children:l?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let fi=2;function vm({token:t}){const[n,s]=i.useState([]),[r,l]=i.useState(null),[o,d]=i.useState([]),[c,g]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:y,data:p,mutate:m}=K(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([j,P])=>G(j,P)),{Status:A="Failed",pagination:{total_rows:C=0}={}}=p||{},{data:b=[]}=A==="Success"?p:{},{data:f}=K(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([j,P])=>G(j,P)),x=i.useMemo(()=>{const j=f?.data??f??[];if(Array.isArray(j))return j;if(j&&typeof j=="object"){if(Array.isArray(j?.data))return j.data;if(Array.isArray(j?.data?.data))return j.data.data}return[]},[f]),{data:R}=K(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([j,P])=>G(j,P)),{Status:k="Failed"}=R||{},O=async(j,P)=>{try{await m(Ge(j,P,t),st(P)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},_=j=>j?typeof j=="string"?j:j?.isValid?.()?j.format("h:mm a"):"":"",D=(j,P=[])=>{const I=(Array.isArray(j)?j:[]).map(Y=>({id:Y?.id??"",name:String(Y?.stop_name??Y?.name??"").trim(),pickTime:_(Y?.pickup_time??Y?.pickTime??Y?.pickupTime),drop_time:_(Y?.drop_time??Y?.dropTime)})),N=I.filter(Y=>Y?.id!=null&&String(Y.id).trim()!==""),W=I.filter(Y=>!(Y?.id!=null&&String(Y.id).trim()!==""));return{route_id:r??"",edit_stoppage:N,add_stoppage:W,delete_stoppage:Array.isArray(P)?P:[]}},u=j=>{j.preventDefault();const P="/api/branchapi/transport/addstoppageToRoute",I=D(n,o);O(P,I)},h=()=>{s(j=>[...Array.isArray(j)?j:[],{idKey:fi++,stop_name:"",pickup_time:se().format("h:mm a"),drop_time:se().format("h:mm a")}])},S=j=>{if(n.length===1)return;const P=n[j];P?.id!=null&&String(P.id).trim()!==""&&!P?.idKey&&d(I=>{const N=Array.isArray(I)?I:[];return N.some(Y=>String(Y)===String(P.id))?N:[...N,P.id]}),s(I=>{const N=[...I];return N.splice(j,1),N})},E=j=>{g(P=>({...P,pagination:{current:j,pageSize:P.pagination.pageSize}}))},$=async j=>{const P="/api/branchapi/Transport/deletevehicle";try{await m(Ze(P,j,t),nt(j)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(k==="Success"){const j=Array.isArray(R?.data)?R.data:[];j.length>0?(s(j),d([])):r&&(s([{idKey:fi++,stop_name:"",pickup_time:se().format("h:mm a"),drop_time:se().format("h:mm a")}]),d([]))}},[k,R,r]);const q=j=>{const{children:P=[]}=j||{},I=[{title:"Stop Name",dataIndex:"stop_name",onCell:N=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:N=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:N=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(a.Table,{components:{body:{cell:hi}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:I,rowKey:N=>T(N)+"cell01",dataSource:P,pagination:!1})})})},T=j=>{const P=["id","index"];for(let I=0;I<P.length;I++)if(j[P[I]])return j[P[I]]},F=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(j,P,I)=>e.jsx(e.Fragment,{children:(Array.isArray(P.children)?P.children:[]).map((N,W,Y)=>e.jsx("span",{children:`${N.stop_name} ${W+1===Y.length?"":","}`},`${W}vehicle001`))})},{title:"Action",render:(j,P,I)=>e.jsx(e.Fragment,{children:e.jsx(wt,{id:P?.route_id,funcName:$})})}];return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(w,{pt:5,pb:1,children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(w,{px:3,pb:2,children:e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Z,{options:x,value:x.find(j=>String(j.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:j=>{l(j?.value??null),s([]),d([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:r&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:h,children:e.jsx(ee.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(ie,{type:"submit",value:"Add",color:"primary"}),e.jsx(a.Button,{type:"text",htmlType:"button",onClick:()=>{l(null),s([]),d([])},style:Sm,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((j,P)=>{const I=j.pickup_time?se(j.pickup_time,"h:mm a"):null,N=j.drop_time?se(j.drop_time,"h:mm a"):null;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx(V,{value:j.stop_name??"",type:"text",name:`stoppage[${P}][name]`,label:"Place Name*",required:"required",onChange:W=>{const Y=W?.target?.value??"";s(B=>{const U=[...B];return U[P]={...U[P]??{},stop_name:Y},U})}}),j?.id!=null&&String(j.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${P}][id]`,value:String(j.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:pi,children:"Pick Time"}),e.jsx(a.TimePicker,{value:I,use12Hours:!0,format:"h:mm a",name:`stoppage[${P}][pickTime]`,allowClear:!1,style:mi,onChange:W=>{const Y=W?W.format("h:mm a"):"";s(B=>{const U=[...B];return U[P]={...U[P]??{},pickup_time:Y},U})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:pi,children:"Drop Time"}),e.jsx(a.TimePicker,{value:N,use12Hours:!0,format:"h:mm a",name:`stoppage[${P}][drop_time]`,allowClear:!1,style:mi,onChange:W=>{const Y=W?W.format("h:mm a"):"";s(B=>{const U=[...B];return U[P]={...U[P]??{},drop_time:Y},U})}})]}),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:()=>S(P),children:e.jsx(ee.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},j.idKey?j.idKey+"exp":j.id+"exp")})})]})}),e.jsx(w,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(w,{style:{padding:"10px 16px"},children:e.jsx(a.Table,{components:{body:{cell:hi}},columns:F,bordered:!0,size:"small",rowKey:j=>T(j),dataSource:b,loading:y,expandable:{expandedRowRender:q,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:C,showSizeChanger:!0,onChange:E,onShowSizeChange:(j,P)=>{g(I=>({...I,pagination:{current:1,pageSize:P}}))},showTotal:(j,P)=>`${P[0]}-${P[1]} of ${j} items`}})})]})]})}const{Step:Cn}=a.Steps;function wm({token:t}){const[n,s]=i.useState(0),[r,l]=i.useState(void 0),[o,d]=i.useState(void 0),[c,g]=i.useState(!1),[y,p]=i.useState(null),[m,A]=i.useState(!1),[C,b]=i.useState(!1),[f,x]=i.useState(!1),[R,k]=i.useState([]),[O,_]=i.useState(null),[D,u]=i.useState(null),[h,S]=i.useState(!1),{isLoading:E,data:$}=K(t?[un,t]:null,([M,L])=>G(M,L)),{isLoading:q,data:T}=K(h?[h,t]:null,([M,L])=>G(M,L)),{data:F}=K(c?[c,t]:null,([M,L])=>G(M,L)),j=i.useMemo(()=>[{title:"Excel Row",dataIndex:"row",width:90,render:M=>M??"-"},{title:"Student Name",dataIndex:"student_name_system",render:M=>M?e.jsx("span",{style:{color:"#d97706"},children:M}):"-"},{title:"Route",dataIndex:"route",render:M=>M||"-"},{title:"Vehicle",dataIndex:"vehicle",render:M=>M||"-"},{title:"Stop",dataIndex:"stop",render:M=>M||"-"},{title:"Start Date",dataIndex:"start_date",render:M=>M||"-"},{title:"Transport Fee",dataIndex:"transport_fee",render:M=>M??"-"},{title:"Status",dataIndex:"status",width:110,render:M=>{const z={Valid:"success",Invalid:"error",Duplicate:"warning",Imported:"success",Skipped:"warning",Failed:"error"}[M]||"default";return e.jsx("span",{style:{color:z,fontWeight:500},children:M})}},{title:"Message",dataIndex:"message",render:M=>M?e.jsx("span",{style:{color:"#dc2626"},children:M}):"-"}],[]),P=()=>{p(null),A(!1),b(!1),x(!1),k([]),_(null),u(null),l(void 0),d(void 0),g(!1),s(0)},I=async()=>{try{const M=await Ru({class_id:r?.value,section_id:o?.value},t),L=window.URL.createObjectURL(M),z=document.createElement("a");z.href=L,z.download="transport-bulk-template.xlsx",document.body.appendChild(z),z.click(),document.body.removeChild(z),window.URL.revokeObjectURL(L),v.success("Template downloaded.",{duration:1e3})}catch(M){v.error(M?.message||"Failed to download template.",{duration:1e3})}},N=async()=>{if(!y){v.error("Please select an Excel file to upload.",{duration:1e3});return}b(!0),k([]),_(null),u(null);try{const M=await Iu(y,t);if(M.Status!=="Success"){v.error(M.msg||"Validation failed.",{duration:1e3}),b(!1);return}_(M.data?.summary||null),k(M.data?.rows||[]),s(2),v.success(M.msg||"Validation complete.",{duration:1e3})}catch(M){v.error(M?.message||"Validation failed.",{duration:1e3})}finally{b(!1)}},W=async()=>{if(!R.length){v.error("No rows provided to import.",{duration:1e3});return}x(!0),u(null);try{const M=await ku(R,t,"skip");if(M.Status!=="Success"){v.error(M.msg||"Import failed.",{duration:1e3}),x(!1);return}u(M.data||null),s(3),v.success(M.msg||"Import completed.",{duration:1e3})}catch(M){v.error(M?.message||"Import failed.",{duration:1e3})}finally{x(!1)}},Y=async M=>{if(!M||!M.length){v.error("No rows provided.",{duration:1e3});return}try{const L=await Pu(M,t),z=window.URL.createObjectURL(L),ne=document.createElement("a");ne.href=z,ne.download="transport-bulk-error-report.xlsx",document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),window.URL.revokeObjectURL(z),v.success("Error report downloaded.",{duration:1e3})}catch(L){v.error(L?.message||"Failed to download error report.",{duration:1e3})}},B=i.useMemo(()=>R.length?(D?D.rows:R).filter(L=>!["Valid","Imported"].includes(L.status)):[],[R,D]),U={background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"};return e.jsx(w,{pt:5,pb:1,children:e.jsx(a.Row,{gutter:[16,16],children:e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:U,children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Transport / Bulk Upload"})}),e.jsxs(w,{p:3,children:[e.jsxs(a.Steps,{current:n,style:{marginBottom:16},children:[e.jsx(Cn,{title:"Download Template"}),e.jsx(Cn,{title:"Upload & Validate"}),e.jsx(Cn,{title:"Review"}),e.jsx(Cn,{title:"Import Result"})]}),n===0&&e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:4,children:e.jsx(w,{children:e.jsx(Z,{label:"Class",options:Array.isArray($)?$:[],value:r,onChange:M=>{l(M),M?g(`${pn}?class_id=${M.value}`):(d(void 0),g(!1))},showSearch:!0,allowClear:!0})})}),e.jsx(a.Col,{xs:24,md:4,children:e.jsx(w,{children:e.jsx(Z,{label:"Section",options:Array.isArray(F)?F:[],value:o,onChange:d,showSearch:!0,allowClear:!0})})}),e.jsx(a.Col,{xs:24,md:4,style:{marginTop:20},children:e.jsx(w,{children:e.jsx(a.Button,{type:"primary",onClick:I,block:!0,children:"Download Excel Template"})})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{mt:1,children:e.jsx(a.Button,{type:"primary",onClick:()=>s(1),children:"Next: Upload Excel"})})})]}),n===1&&e.jsxs(a.Row,{gutter:[16,16],align:"middle",children:[e.jsx(a.Col,{xs:24,md:6,children:e.jsxs(w,{children:[e.jsx(a.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:M=>(p(M),!1),children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),block:!0,disabled:m||C,children:y?y.name:"Choose Excel File (.xlsx)"})}),y&&e.jsxs(w,{mt:.5,display:"flex",alignItems:"center",gap:1,children:[e.jsxs(be,{level:6,color:"textSecondary",children:[(y.size/1024).toFixed(1)," KB"]}),e.jsx(a.Button,{size:"small",danger:!0,onClick:()=>p(null),children:"Remove"})]})]})}),e.jsx(a.Col,{xs:24,md:3,children:e.jsx(w,{children:e.jsx(ie,{type:"button",value:C?"Validating...":"Validate & Preview",color:"primary",onClick:N,disabled:C||!y})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Button,{type:"text",size:"small",onClick:()=>{P(),s(0)},children:"Back"})})]}),n===2&&e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:6,md:3,children:e.jsx(a.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsx(be,{level:6,color:"textSecondary",children:"Total"}),e.jsx(be,{level:4,children:O?.total??R.length})]})})}),e.jsx(a.Col,{xs:6,md:3,children:e.jsx(a.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsx(be,{level:6,color:"textSecondary",children:"Valid"}),e.jsx(be,{level:4,style:{color:"#52c41a"},children:O?.valid??0})]})})}),e.jsx(a.Col,{xs:6,md:3,children:e.jsx(a.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsx(be,{level:6,color:"textSecondary",children:"Invalid"}),e.jsx(be,{level:4,style:{color:"#ff4d4f"},children:O?.invalid??0})]})})}),e.jsx(a.Col,{xs:6,md:3,children:e.jsx(a.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsx(be,{level:6,color:"textSecondary",children:"Duplicate"}),e.jsx(be,{level:4,style:{color:"#faad14"},children:O?.duplicate??0})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(a.Table,{dataSource:R.map((M,L)=>({...M,key:`${M.row}-${L}`})),columns:j,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:(M,L)=>`${L[0]}-${L[1]} of ${M} items`}})})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Row,{gutter:[8,8],align:"middle",children:[e.jsx(a.Col,{children:e.jsx(ie,{type:"button",value:f?"Importing...":"Import Valid Rows",color:"primary",onClick:W,disabled:f})}),e.jsx(a.Col,{children:e.jsx(a.Button,{size:"small",onClick:()=>Y(B),disabled:!B.length,children:"Download Error Report"})}),e.jsx(a.Col,{children:e.jsx(a.Button,{type:"text",size:"small",onClick:()=>{P(),s(1)},children:"Upload Another File"})})]})})]}),n===3&&e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:6,md:3,children:e.jsx(a.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsxs(be,{level:6,color:"textSecondary",children:["Total "," "]}),e.jsx(be,{level:4,children:D?.total??0})]})})}),e.jsx(a.Col,{xs:6,md:3,children:e.jsx(a.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsxs(be,{level:6,color:"textSecondary",children:["Imported "," "]}),e.jsx(be,{level:4,style:{color:"#52c41a"},children:D?.imported??0})]})})}),e.jsx(a.Col,{xs:6,md:3,children:e.jsx(a.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsxs(be,{level:6,color:"textSecondary",children:["Skipped "," "]}),e.jsx(be,{level:4,style:{color:"#faad14"},children:D?.skipped??0})]})})}),e.jsx(a.Col,{xs:6,md:3,children:e.jsx(a.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsxs(be,{level:6,color:"textSecondary",children:["Failed "," "]}),e.jsx(be,{level:4,style:{color:"#ff4d4f"},children:D?.failed??0})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(a.Table,{dataSource:(D?.rows||[]).map((M,L)=>({...M,key:`${M.row}-${L}`})),columns:j,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:(M,L)=>`${L[0]}-${L[1]} of ${M} items`}})})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Row,{gutter:[8,8],align:"middle",children:[e.jsx(a.Col,{children:e.jsx(a.Button,{size:"small",onClick:()=>Y(B),disabled:!B.length,children:"Download Error Report"})}),e.jsx(a.Col,{children:e.jsx(a.Button,{type:"primary",size:"small",onClick:P,children:"Upload Another File"})})]})})]})]})]})})})})}const _m=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},fo=t=>{const n=qt(t);if(n)return n;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},yi=(t,n,s)=>{const r=`${t||""}`.trim();if(!r)return"";if(/^https?:\/\//i.test(r))return r;const l=n?.fk_branchID??fo(s),o=r.startsWith("/")?r.slice(1):r;return _m(at(),`uploads/school_${l}/student/homework/${o}`)},gi={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ba=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Cm({token:t}){const[n,s]=i.useState("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),[r,l]=i.useState({page:1,rowsPerPage:10}),[o,d]=i.useState(null),[c,g]=i.useState(null),[y,p]=i.useState(null),[m,A]=i.useState(null),[C,b]=i.useState(!1),[f,x]=i.useState(null),[R,k]=i.useState(null),[O,_]=i.useState(null),[D,u]=i.useState(null),[h,S]=i.useState(null),[E,$]=i.useState(null),[q,T]=i.useState(!1),[F,j]=i.useState(""),[P,I]=i.useState(""),[N,W]=i.useState(""),[Y,B]=i.useState(!1),U=(fe,Ie)=>{const Je=fe?.value??null;switch(Ie){case"class_id":d(Je),g(null),p(null);break;case"section_id":g(Je);break;case"subject_id":p(Je);break}},{data:M}=K(t?["api/branchapi/academy/classdropdownlist",t]:null,([fe,Ie])=>G(fe,Ie)),{data:L}=K(t&&h?[h,t]:null,([fe,Ie])=>G(fe,Ie)),{data:z}=K(t&&E?[E,t]:null,([fe,Ie])=>G(fe,Ie)),ne=o?`api/branchapi/academy/sectionoftheClass?class_id=${o}`:null,{data:X}=K(t&&ne?[ne,t]:null,([fe,Ie])=>G(fe,Ie)),J=o?`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${o}`:null,{data:H}=K(t&&J?[J,t]:null,([fe,Ie])=>G(fe,Ie)),Q=i.useMemo(()=>Ba(M),[M]),ce=i.useMemo(()=>Ba(L),[L]),De=i.useMemo(()=>Ba(z),[z]),le=i.useMemo(()=>Ba(X),[X]),ue=i.useMemo(()=>Ba(H),[H]),oe=t&&n?`${n}class_id=${o||""}&subject_id=${y||""}§ion_id=${c||""}&date=${m?.format("YYYY-MM-DD")||""}&page=${r.page}&per_page=${r.rowsPerPage}`:null,{isLoading:Ce,error:Ne,data:et,mutate:we}=K(oe?[oe,t]:null,([fe,Ie])=>G(fe,Ie)),Ae=async(fe,Ie)=>{try{await we(Ge(fe,Ie,t),st(Ie)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),$e()}catch(Je){console.error(Je),v.error("Failed to add the new item.",{duration:1e3})}},Fe=async fe=>{try{await we(Ze("api/student/Homework/deleteHomework",fe,t),nt(fe)),v.success("Success! Deleted item.",{duration:1e3})}catch(Ie){console.error(Ie),v.error("Failed to delete the item.",{duration:1e3})}},me=async fe=>{try{const Ie=await tt("api/student/Homework/updateHomework",fe,t);we(Ie),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),$e()}catch(Ie){console.error(Ie),v.error("Failed to update the item.",{duration:1e3})}},de=fe=>{fe.preventDefault();const Ie=new FormData(fe.target),Je=Ie.get("class_id")||o,mt=Ie.get("section_id")||c,Et=Ie.get("subject_id")||y,Tt=m?.format("YYYY-MM-DD");s(`api/branchapi/homeworks/gethomeworklistByClassSectionBranch?class_id=${Je||""}&subject_id=${Et||""}§ion_id=${mt||""}${Tt?`&date=${Tt}`:""}&`),l(ye=>({...ye,page:1}))},Re=fe=>{fe.preventDefault();const Ie=new FormData(fe.target);Ae("api/branchapi/homeworks/addHomework",Ie),W("")},Be=async(fe,Ie)=>{fe.preventDefault();const Je=new FormData(fe.target);Je.append("id",Ie),B(!0);try{await me(Je)}finally{B(!1)}},$e=()=>{b(!1),x(null),k(null),_(null),u(null),S(null),$(null),W("")},ge=fe=>{x(fe);const Ie=fe?.class_id??fe?.classId??null,Je=fe?.section_id??fe?.sectionId??null,mt=fe?.subject_id??fe?.subjectId??null;k(Ie),_(Je),u(mt),Ie?(S(`api/branchapi/academy/sectionoftheClass?class_id=${Ie}`),$(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${Ie}`)):(S(null),$(null)),W(fe?.file||fe?.document||""),b(!0)},_e=fe=>{const Ie=fe?.value??null;k(Ie),_(null),u(null),Ie?(S(`api/branchapi/academy/sectionoftheClass?class_id=${Ie}`),$(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${Ie}`)):(S(null),$(null))},ve=fe=>{_(fe?.value??null)},re=fe=>{u(fe?.value??null)},xe=(fe,Ie)=>{l({page:fe,rowsPerPage:parseInt(Ie,10)})},je=()=>{T(!1),j(""),I("")},Le=(fe,Ie)=>{if(!fe){v.error("No document found.",{duration:1e3});return}j(fe),I(Ie||"Document"),T(!0)},qe=[{title:"Date",dataIndex:"homework_date",key:"homework_date"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission Date",dataIndex:"submit_date",key:"submit_date"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Document",key:"document",render:(fe,Ie)=>{const Je=Ie?.document||Ie?.file||"";if(!Je)return e.jsx("span",{style:{color:"#999",fontSize:12},children:"Not Uploaded"});const mt=yi(Je,Ie,t);return e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>Le(mt,Je),children:"View"})}},{title:"Action",key:"action",render:(fe,Ie)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>ge(Ie),style:{padding:2}}),e.jsx(wt,{id:Ie?.id,funcName:Fe})]})}];return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Search Homework"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:de,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{options:Q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:Q.find(fe=>String(fe.value)===String(o))??null,onChange:fe=>U(fe,"class_id")})})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{options:le,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:le.find(fe=>String(fe.value)===String(c))??null,onChange:fe=>U(fe,"section_id")})})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{options:ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:ue.find(fe=>String(fe.value)===String(y))??null,onChange:fe=>U(fe,"subject_id")})})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(He,{Desplay:"Date",format:"YYYY-MM-DD",allowClear:!1,value:m,onChange:fe=>A(fe)})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsxs(w,{children:[e.jsx(ie,{type:"submit",value:"Search",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{s("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),d(null),g(null),p(null),A(null)},style:gi,children:"Cancel"})]})})})})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Homework List"})}),e.jsx(w,{p:3,children:e.jsx(ze,{parentCallback:xe,data:{newData:et,columns:qe,columnstype:"antd",action:!1,Loading:Ce,error:Ne,deleteTodoMutation:Fe,pageController:r}})})]})})]}),e.jsx(a.Drawer,{open:C,title:f?"Edit Homework":"Add Homework",placement:"right",width:600,destroyOnClose:!0,onClose:$e,children:e.jsx("form",{onSubmit:f?fe=>Be(fe,f.id):Re,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:Q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,placeholder:"Select Class",value:Q.find(fe=>String(fe.value)===String(R))??null,onChange:_e})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:ce,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,placeholder:R?"Select Section":"Select Class First",value:ce.find(fe=>String(fe.value)===String(O))??null,onChange:ve,isDisabled:!R})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{options:De,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"sub_id",required:!0,allowSelectAll:!1,placeholder:R?"Select Subject":"Select Class First",value:De.find(fe=>String(fe.value)===String(D))??null,onChange:re,isDisabled:!R})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",defaultValue:f?.homew_date?se(f?.homew_date):se(),Desplay:"From",name:"homew_date"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",defaultValue:f?.submission_date?se(f?.submission_date):se(),Desplay:"Deadline",name:"submission_date"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{type:"text",label:"Title",name:"title",defaultValue:f?.title||"",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(gt,{type:"text",label:"Description",name:"description",defaultValue:f?.description||"",rows:3,required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.Upload,{action:`${at()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${fo(t)}/student/homework`},headers:{Authorization:t},maxCount:1,onChange:fe=>{if(fe.file.status==="removed"&&W(""),fe.file.status==="done"){const Ie=fe.file.response?.data??fe.file.response?.file??"";W(String(Ie??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:N?"Change":"Upload"})}),N&&f&&e.jsx("a",{href:yi(N,f,t),target:"_blank",rel:"noreferrer",style:{display:"block",marginTop:8,fontSize:12,color:"#1677ff",textDecoration:"underline"},children:"View existing document"}),e.jsx("input",{type:"hidden",name:"file",value:N||"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsxs(w,{children:[e.jsx(ie,{type:"submit",value:Y?"Saving...":"Save",color:"primary",disabled:Y}),e.jsx(a.Button,{type:"text",onClick:$e,style:gi,children:"Cancel"})]})})})})]})})}),e.jsx(a.Modal,{open:q,onCancel:je,footer:null,width:900,closable:!0,children:e.jsxs(w,{p:3,children:[e.jsx(w,{mb:2,children:e.jsx(be,{level:5,children:P||"View Document"})}),F?F.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:F,title:P||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:F,alt:P||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(be,{children:"No document found"})]})}),e.jsx(w,{style:{position:"fixed",bottom:24,right:24,zIndex:1e3},children:e.jsx(a.Button,{type:"primary",size:"large",onClick:()=>{x(null),k(null),_(null),u(null),S(null),$(null),W(""),b(!0)},style:{borderRadius:"50%",width:56,height:56,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24},children:"+"})})]})}const Ps=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Am({token:t}){const[n,s]=i.useState(!1),[r,l]=i.useState(null),[o,d]=i.useState(null),[c,g]=i.useState({page:1,rowsPerPage:10}),[y,p]=i.useState(!1),[m,A]=i.useState(""),[C,b]=i.useState(""),[f,x]=i.useState({label:"",value:""}),[R,k]=i.useState({label:"",value:""}),[O,_]=i.useState({label:"",value:""}),[D,u]=i.useState(!1),[h,S]=i.useState(!1),{data:E}=K(t?["api/branchapi/academy/classdropdownlist",t]:null,([X,J])=>G(X,J)),{data:$}=K(t&&n?[n,t]:null,([X,J])=>G(X,J)),{data:q}=K(t&&(r||!0)?[r||"api/branchapi/academy/subjecttableList",t]:null,([X,J])=>G(X,J)),T=i.useMemo(()=>Ps(E),[E]),F=i.useMemo(()=>Ps($),[$]),j=i.useMemo(()=>Ps(q),[q]),P=t&&o?`${o}page=${c.page}&per_page=${c.rowsPerPage}`:null,{isLoading:I,error:N,data:W,mutate:Y}=K(P?[P,t]:null,([X,J])=>G(X,J)),B=(X,J)=>{switch(J){case"class_id":x(X||{label:"",value:""}),k({label:"",value:""}),_({label:"",value:""}),l(`/api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${X?.value??""}`),s(`/api/branchapi/academy/sectionoftheClass?class_id=${X?.value??""}`),u(H=>!H),S(H=>!H);break;case"section_id":k(X||{label:"",value:""});break;case"subject_id":_(X||{label:"",value:""});break}},U=async X=>{X.preventDefault();const J="/api/branchapi/homeworks/gethomeworklistByClassSectionBranch",H=new URLSearchParams;f.value&&H.append("class_id",String(f.value)),R.value&&H.append("section_id",String(R.value)),O.value&&H.append("subject_id",String(O.value));const Q=H.toString(),ce=Q?`${J}?${Q}&`:`${J}?`;g(De=>({...De,page:1})),d(ce),await Y()},M=(X,J)=>{g({page:X,rowsPerPage:parseInt(J,10)})},L=()=>{p(!1),A(""),b("")},z=(X,J)=>{A(X),b(J||"Document"),p(!0)},ne=[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Assign By",dataIndex:"staff_name",key:"staff_name"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission",dataIndex:"total_submission",key:"total_submission"},{title:"View Document",key:"document",render:(X,J)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>z(J.document_url,J.document),children:"View"})}];return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Submission Details"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:U,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:T.find(X=>String(X.value)===String(f.value))??null,onChange:X=>B(X,"class_id")})})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:F.find(X=>String(X.value)===String(R.value))??null,onChange:X=>k(X||{label:"",value:""})},`sections1${D}`)})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:j.find(X=>String(X.value)===String(O.value))??null,onChange:X=>_(X||{label:"",value:""})},`subjects1${h}`)})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})})]})})})]})}),o&&e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Students List"})}),e.jsx(w,{p:3,children:e.jsx(ze,{parentCallback:M,data:{newData:W,columns:ne,columnstype:"antd",action:!1,Loading:I,error:N,pageController:c}})})]})})]}),e.jsx(a.Modal,{open:y,onClose:L,footer:null,width:900,children:e.jsxs(w,{p:3,children:[e.jsxs(w,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(be,{level:5,children:C||"View Document"}),e.jsx(ie,{type:"button",value:"Close",color:"primary",onClick:L})]}),m?m.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:m,title:C||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:m,alt:C||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(be,{children:"No document found"})]})})]})}const Dm=(t,n)=>{const s=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${s}/${r}`};function Tm({token:t,sampleFileUrl:n}){const s=t??localStorage.getItem("authToken")??"",[r,l]=i.useState(null),[o,d]=i.useState(null),[c,g]=i.useState(null),[y,p]=i.useState(null),[m,A]=i.useState(null),[C,b]=i.useState(null),[f,x]=i.useState(null),R="api/branchapi/library/bookCategorydropdown",k="api/branchapi/academy/classdropdownlist",O="api/branchapi/Academy/getClassSubjectdropdown",_="api/branchapi/library/addBook",D="api/branchapi/library/uploadcsv",{data:u}=K(s?[R,s]:null,([P,I])=>G(P,I)),{data:h}=K(s&&k?[k,s]:null,([P,I])=>G(P,I)),{data:S}=K(s&&O?[O,s]:null,([P,I])=>G(P,I)),E=i.useMemo(()=>Dm(At(),D),[D]),$=async P=>{P.preventDefault();const I=new FormData(P.target);I.set("cat_id",m?.value??""),I.set("class_id",C?.value??""),I.set("subject_id",f?.value??"");try{await Ge(_,I,s),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),P.target.reset(),A(null),b(null),x(null)}catch(N){v.error(N?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},q=async P=>{if(P.preventDefault(),!r){v.error("Please select a CSV file.",{duration:1e3});return}const I=new FormData;I.append("file",r),I.append("cat_id",o?.value??""),I.append("class_id",c?.value??""),I.append("subject_id",y?.value??"");try{const N=await Xe.post(E,I,{headers:{Authorization:s,"Content-type":"multipart/form-data"}});N?.data?.Status==="Failed"?v.error(String(N?.data?.msg??"Upload failed."),{duration:1e3}):(v.success(String(N?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),l(null),P.target.reset(),d(null),g(null),p(null))}catch(N){v.error(N?.response?.data?.msg??"Upload failed.",{duration:1e3})}},T=()=>["title,author,publisher,quantity,price,fine,subject_id,barcode,class_id",...["Advanced Chemistry,Rahul Mondal,RM PUBLISHER,10,210,20,1,,1","Advanced Chemistry,Rahul Mondal,RM PUBLISHER,10,210,20,1,123321,1"]].join(`
|
|
60
|
-
`),F=()=>{if(n)return n;const P=At();return P?`${P.replace(/\/+$/,"")}/books.csv`:"/books.csv"},j=()=>{const P=F();fetch(P).then(I=>{if(!I.ok)throw new Error("Sample file not found");const N=I.headers.get("content-type")||"";return!N.includes("csv")&&!N.includes("text/plain")&&!N.includes("application/octet-stream")?I.text().then(W=>{if(W.trim().startsWith("<")||W.includes("<!doctype")||W.includes("<html"))throw new Error("Sample file URL returned HTML. Host the CSV at a public URL and pass it via sampleFileUrl prop.");return new Blob([W],{type:"text/csv"})}):I.blob()}).then(I=>{const N=window.URL.createObjectURL(I),W=document.createElement("a");W.href=N,W.download="books.csv",W.click(),window.URL.revokeObjectURL(N)}).catch(()=>{const I=T(),N=new Blob([I],{type:"text/csv"}),W=window.URL.createObjectURL(N),Y=document.createElement("a");Y.href=W,Y.download="books.csv",Y.click(),window.URL.revokeObjectURL(W)})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(a.Button,{type:"link",icon:e.jsx(ee.DownloadOutlined,{}),onClick:j,children:"Download Sample"}),children:[e.jsx(a.Divider,{children:"Information"}),e.jsx(a.Typography.Paragraph,{style:{marginBottom:16},children:"1. Your CSV data should be in the format below. The first line of your CSV file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:P=>d(P??null)}),e.jsx(Z,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:c,onChange:P=>g(P??null)}),e.jsx(Z,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:y,onChange:P=>p(P??null)}),e.jsx(V,{type:"file",label:"Upload CSV/Excel",name:"csv",accept:".csv,.xlsx,.xls",onChange:P=>l(P.target.files?.[0]??null),required:!0}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(V,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(V,{type:"text",label:"Publication",name:"publisher"}),e.jsx(V,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(V,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(V,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(V,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(Z,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:m,onChange:P=>A(P??null)}),e.jsx(Z,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:C,onChange:P=>b(P??null)}),e.jsx(Z,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:f,onChange:P=>x(P??null)}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})})})]})}const Os={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ms=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Rm({token:t}){const n=t??localStorage.getItem("authToken")??"",[s,r]=i.useState([]),[l,o]=i.useState([]),d=i.useRef(),c={selectedRowKeys:s,onChange:(H,Q)=>{r(H),o(Q)}},g=ia.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),y=()=>{if(!(typeof window>"u")){if(!l.length){v.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){v.error("Nothing to print.",{duration:1e3});return}g?.()}},[p,m]=i.useState(!1),[A,C]=i.useState(null),[b,f]=i.useState(null),[x,R]=i.useState(null),[k,O]=i.useState(null),[_,D]=i.useState({page:1,rowsPerPage:10}),u=(H,Q)=>{D({page:H,rowsPerPage:parseInt(Q,10)})},h="api/branchapi/library/booktable",S="api/branchapi/library/deletebooks",E="api/branchapi/library/editbook",$=`${h}?page=${_.page}&per_page=${_.rowsPerPage}`,{isLoading:q,error:T,data:F,mutate:j}=K(n?[$,n]:null,([H,Q])=>G(H,Q)),P="api/branchapi/library/bookCategorydropdown",I="api/branchapi/academy/classdropdownlist",N="api/branchapi/Academy/getClassSubjectdropdown",{data:W}=K(n?[P,n]:null,([H,Q])=>G(H,Q)),{data:Y}=K(n&&I?[I,n]:null,([H,Q])=>G(H,Q)),{data:B}=K(n&&N?[N,n]:null,([H,Q])=>G(H,Q)),U=i.useMemo(()=>Ms(W),[W]),M=i.useMemo(()=>Ms(Y),[Y]),L=i.useMemo(()=>Ms(B),[B]),z=async H=>{try{await Ze(S,H,n),await j(),v.success("Success! Deleted item.",{duration:1e3})}catch(Q){v.error(Q?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ne=H=>{C(H??null);const Q=H?.cat_id??H?.fk_cat_id??H?.category_id,ce=H?.class_id??H?.fk_class_id,De=H?.subject_id??H?.fk_subject_id;f(U.find(le=>le?.value===Q)??null),R(M.find(le=>le?.value===ce)??null),O(L.find(le=>le?.value===De)??null),m(!0)},X=async H=>{H.preventDefault();const Q=A?.id??A?.book_id??A?._id;if(!Q)return;const ce=new FormData(H.target);ce.set("id",String(Q)),ce.set("cat_id",b?.value??""),ce.set("class_id",x?.value??""),ce.set("subject_id",k?.value??"");try{await tt(E,ce,n),await j(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),m(!1),C(null)}catch(De){v.error(De?.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:(H,Q)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>ne(Q),style:{padding:2}}),e.jsx(a.Button,{type:"text",size:"small",danger:!0,onClick:()=>z(Q?.id??Q?.book_id??Q?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[U,M,z,L]);return e.jsxs("div",{style:{},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{open:p,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{m(!1),C(null)},children:e.jsx("form",{onSubmit:X,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(V,{label:"Book Name",name:"title",defaultValue:A?.book_title??"",required:!0}),e.jsx(V,{label:"Author",name:"author",defaultValue:A?.author??"",required:!0}),e.jsx(V,{label:"Publication",name:"publish",defaultValue:A?.publish??""}),e.jsx(V,{label:"Qty",name:"quantity",type:"number",defaultValue:A?.quantity??""}),e.jsx(V,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:A?.perunitcost??""}),e.jsx(V,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:A?.fine_amount??""}),e.jsx(V,{label:"Barcode",name:"barcode",defaultValue:A?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Os,children:"Category"}),e.jsx(Z,{options:U,value:b,onChange:H=>f(H??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Os,children:"Class"}),e.jsx(Z,{options:M,value:x,onChange:H=>R(H??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Os,children:"Subject"}),e.jsx(Z,{options:L,value:k,onChange:H=>O(H??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{m(!1),C(null)},children:"Cancel"})]})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:l.length>0?e.jsxs(a.Button,{type:"primary",onClick:y,children:["Print Barcode (",l.length,")"]}):null,children:e.jsx(ze,{parentCallback:u,data:{newData:F,columns:J,columnstype:"antd",action:!1,Loading:q,error:T,rowSelection:c}})}),e.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:e.jsx("div",{ref:d,style:{padding:"20px"},children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:l.map((H,Q)=>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:H.book_title}),e.jsx(Dl,{value:H.barcode?String(H.barcode):String(H.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},Q))})})})]})}const Im=(t,n)=>{const s=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${s}/${r}`},zt=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},An=t=>se(t).add(1,"month").format("YYYY-MM-DD"),km=i.forwardRef(({token:t,onReturn:n},s)=>{const r=t??localStorage.getItem("authToken")??"",[l,o]=i.useState("issue"),d=l==="return",[c,g]=i.useState(!1),[y,p]=i.useState(!1),[m,A]=i.useState(null),[C,b]=i.useState([]),[f,x]=i.useState([]),[R,k]=i.useState([]),[O,_]=i.useState(0),[D,u]=i.useState(!1),[h,S]=i.useState(null),[E,$]=i.useState(null),[q,T]=i.useState(null),[F,j]=i.useState(!1),[P,I]=i.useState("Cash"),[N,W]=i.useState(""),[Y,B]=i.useState(""),[U,M]=i.useState(0),[L,z]=i.useState("NO_FINE"),ne=i.useRef(null),[X]=a.Form.useForm(),[J]=a.Form.useForm(),H="api/branchapi/library/bookCategorydropdown",Q="api/branchapi/academy/classdropdownlist",ce="api/branchapi/Academy/getClassSubjectdropdown",{data:De}=K(r?[H,r]:null,([he,Te])=>G(he,Te)),{data:le}=K(r&&Q?[Q,r]:null,([he,Te])=>G(he,Te)),{data:ue}=K(r&&ce?[ce,r]:null,([he,Te])=>G(he,Te)),oe=i.useMemo(()=>zt(De),[De]),Ce=i.useMemo(()=>zt(le),[le]),Ne=i.useMemo(()=>zt(ue),[ue]),et="api/branchapi/library/studentsearchByNameID",we="api/branchapi/library/booksearchBybookname",Ae="api/branchapi/library/issuedBookList",Fe="api/branchapi/library/issueLibrarybook",me="api/branchapi/library/returnedLibrarybook",{trigger:de,data:Re}=pt(et,(he,Te)=>na(he,Te,r)),{trigger:Be,data:$e}=pt(we,(he,Te)=>na(he,Te,r)),{trigger:ge,data:_e}=pt(Ae,(he,Te)=>na(he,Te,r)),{trigger:ve}=pt(d?me:Fe,(he,Te)=>os(he,Te,r)),re=i.useMemo(()=>zt(Re),[Re]),xe=i.useMemo(()=>zt($e),[$e]),je=i.useMemo(()=>zt(_e),[_e]),Le=he=>{const Te=An(se());b(Ke=>Ke.some(ot=>String(ot?.id)===String(he?.id))?Ke:[...Ke,{...he,return_date:he?.return_date?he.return_date:Te}])},qe=async()=>{console.log("Reloading IssueReturn..."),v.success("Success",{duration:1e3}),x([]),k([]),_(0),z("FINE_PAY_LATER"),await ge({id:m?.student_id})};i.useImperativeHandle(s,()=>({reloadPayLater:qe}));const fe=he=>{b(Te=>Te.filter(Ke=>String(Ke?.id)!==String(he)))},Ie=async he=>{if(r){if(!he){A(null);return}c||await de({id:he})}},Je=async({search:he})=>{if(!r||!c)return;const Te=await de({id:he}),Ke=zt(Te);Ke.length===1&&(A(Ke[0]),await ge({id:Ke[0]?.student_id}),X.resetFields())},mt=async(he,Te)=>{A(Te??null),b([]),x([]),k([]),_(0),z("NO_FINE"),M(0),Te?.student_id&&await ge({id:Te.student_id}),X.resetFields()},Et=async he=>{r&&he&&(y||await Be({book:he}))},Tt=async({search_book:he})=>{if(!r||!y)return;const Te=await Be({book:he,catID:h?.value??"",sID:q?.value??"",cID:E?.value??""}),Ke=zt(Te);Ke.length&&(Le(Ke[0]),J.resetFields())},ye=(he,Te)=>{Le(Te),J.resetFields()},ke=async()=>{if(!m?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!C.length){v.error("Select at least one book.",{duration:1e3});return}const he=await ve({member_id:m.member_id,fine:!1,books:C});he?.Status==="Success"&&(v.success(String(he?.msg??"Success"),{duration:1e3}),b([]),A(null),x([]),k([]),_(0))},ae=async()=>{if(!m?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!R.length){v.error("Select at least one book to return.",{duration:1e3});return}if(Number(O)>0){z("FINE_PAID"),j(!0);return}const he=await ve({member_id:m.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(R)});he?.Status==="Success"?(v.success(String(he?.msg??"Success"),{duration:1e3}),x([]),k([]),_(0),await ge({id:m?.student_id})):v.error(String(he?.msg??"Failed"),{duration:1e3})},pe=async()=>{if(!m?.member_id)return;const he=Math.max(0,Number(O)-Number(U||0)),Te={member_id:m.member_id,collection_type:L,amount:L==="FINE_PAID"?he:0,payment_type:P,notes:N,attchement:Y,discount:U||0,books:JSON.stringify(R)},Ke=await ve(Te);j(!1),Ke?.Status==="Success"?(v.success(String(Ke?.msg??"Success"),{duration:1e3}),x([]),k([]),_(0),M(0),W(""),B(""),z("NO_FINE"),await ge({id:m?.student_id})):v.error(String(Ke?.msg??"Failed"),{duration:1e3})},Pe=async()=>{if(!m?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!R.length){v.error("Select at least one book to return.",{duration:1e3});return}const he={member_id:m.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(R)};n(he)},Ee=i.useMemo(()=>Im(At(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),it=[{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:(he,Te)=>e.jsx(He,{defaultValue:se(Te?.return_date||se().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(Ke,ot)=>{b(xt=>xt.map(_t=>String(_t?.id)===String(Te?.id)?{..._t,return_date:ot}:_t))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(he,Te)=>e.jsx(a.Button,{type:"text",danger:!0,onClick:()=>fe(Te?.id),children:"Remove"})}],lt={selectedRowKeys:f,onChange:(he,Te)=>{x(he),k(Te);const Ke=(Te??[]).reduce((ot,xt)=>ot+Number(xt?.totalfine??0),0);_(Ke)},onSelect:(he,Te,Ke)=>{if(Te){const ot=Ke.map(xt=>({...xt,return_date:xt?.return_date?xt.return_date:An(xt?.issue_date||se())}));k(ot)}},onSelectAll:(he,Te)=>{if(he){const Ke=Te.map(ot=>({...ot,return_date:ot?.return_date?ot.return_date:An(ot?.issue_date||se())}));k(Ke)}}},ft=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(he,Te)=>{const ot=R.find(_t=>String(_t?.id)===String(Te?.id))?.return_date||Te?.return_date,xt=An(Te?.issue_date||se());return e.jsx(He,{defaultValue:se(ot||xt),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(_t,ys)=>{k(gs=>gs.map(Pa=>String(Pa?.id)===String(Te?.id)?{...Pa,return_date:ys}:Pa))}})}},{title:"Days",key:"days",width:100,render:(he,Te)=>{const ot=R.find(_t=>String(_t?.id)===String(Te?.id))?.return_date||Te?.return_date,xt=Te?.issue_date;if(xt&&ot){const _t=se(ot).diff(se(xt),"day");return _t>=0?_t:0}return"-"}},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:he=>e.jsxs("span",{children:["₹ ",he]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{open:F,onCancel:()=>j(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(a.Radio.Group,{value:P,onChange:he=>I(he.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(a.Input.TextArea,{rows:3,value:N,onChange:he=>W(he.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(a.Upload,{action:Ee,headers:{Authorization:r},maxCount:1,onChange:he=>{if(he.file.status==="done"){const Te=he.file.response?.data??he.file.response?.file??"";B(String(Te??""))}},children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(a.Input,{type:"number",value:U,onChange:he=>M(he.target.value),placeholder:"0"})]}),e.jsxs(a.Button,{type:"primary",onClick:pe,children:["Collect ₹",Math.max(0,Number(O)-Number(U||0))]}),e.jsx(a.Button,{onClick:()=>j(!1),children:"Cancel"})]})}),e.jsxs(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(a.Row,{gutter:[16,16],align:"middle",children:[e.jsx(a.Col,{xs:24,md:10,children:e.jsx(a.Radio.Group,{value:l,onChange:he=>{const Te=he.target.value;o(Te),b([]),x([]),k([]),_(0),z("NO_FINE"),M(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(a.Col,{xs:24,md:14,children:e.jsx(a.Form,{form:X,onFinish:Je,layout:"vertical",children:e.jsx(a.Form.Item,{name:"search",label:"Search Student",children:e.jsx(a.Space.Compact,{style:{width:"100%"},children:c?e.jsx(a.Input,{autoFocus:!0,addonBefore:e.jsxs(a.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(a.Checkbox,{checked:c,onChange:he=>g(he.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(a.AutoComplete,{options:re,onSelect:mt,onSearch:Ie,style:{width:"100%"},allowClear:!0,children:e.jsx(a.Input,{addonBefore:e.jsxs(a.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(a.Checkbox,{checked:c,onChange:he=>g(he.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),m?e.jsxs(e.Fragment,{children:[e.jsx(a.Divider,{}),e.jsxs(a.Row,{gutter:[12,12],children:[e.jsxs(a.Col,{xs:24,md:8,children:[e.jsx(a.Typography.Text,{strong:!0,children:"Name:"})," ",m?.value??""]}),e.jsxs(a.Col,{xs:24,md:8,children:[e.jsx(a.Typography.Text,{strong:!0,children:"Card No:"})," ",m?.library_card_no??""]}),e.jsxs(a.Col,{xs:24,md:8,children:[e.jsx(a.Typography.Text,{strong:!0,children:"Member ID:"})," ",m?.member_id??""]})]})]}):null,e.jsx(a.Divider,{}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(a.Table,{dataSource:je,columns:ft,rowSelection:lt,pagination:!1,rowKey:he=>he?.id??he?.issue_id??he?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(a.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(a.Typography.Text,{strong:!0,children:["Total Fine: ₹",O]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(a.Button,{type:"primary",onClick:ae,disabled:!R.length,children:O>0?`Pay Now ₹ ${Math.max(0,Number(O)-Number(U||0))}`:"Return Selected"}),O>0?e.jsx(a.Button,{onClick:Pe,disabled:!R.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(a.Row,{gutter:[16,16],align:"middle",children:[e.jsx(a.Col,{xs:24,md:18,children:e.jsx(a.Form,{form:J,onFinish:Tt,layout:"vertical",children:e.jsx(a.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(a.Space.Compact,{style:{width:"100%"},children:y?e.jsx(a.Input,{autoFocus:!0,disabled:!m,addonBefore:e.jsxs(a.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(a.Checkbox,{checked:y,onChange:he=>p(he.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(a.AutoComplete,{disabled:!m,options:xe,onSelect:ye,onSearch:Et,style:{width:"100%"},allowClear:!0,children:e.jsx(a.Input,{addonBefore:e.jsxs(a.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(a.Checkbox,{checked:y,onChange:he=>p(he.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(a.Button,{style:{width:"100%"},icon:e.jsx(ee.FilterOutlined,{}),onClick:()=>u(!0),children:"Filter"})})]}),e.jsx(a.Drawer,{open:D,onClose:()=>u(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{label:"Category",options:oe,value:h,onChange:he=>S(he??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(Z,{label:"Class",options:Ce,value:E,onChange:he=>$(he??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(Z,{label:"Subjects",options:Ne,value:q,onChange:he=>T(he??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(a.Button,{type:"primary",onClick:()=>u(!1),children:"Apply"})]})}),e.jsx(a.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(a.Table,{dataSource:C,columns:it,pagination:!1,rowKey:he=>he?.id??he?.book_id??he?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(a.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Issue",onClick:ke})})]})]}),e.jsx("div",{ref:ne,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}),xi=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Pm({token:t}){const n=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[l,o]=i.useState(null),[d,c]=i.useState(null),[g,y]=i.useState(!1),[p,m]=i.useState(!1),[A,C]=i.useState(null),[b,f]=i.useState(!1),x="api/branchapi/academy/classdropdownlist",R="api/branchapi/academy/sectionoftheClass",k="api/branchapi/library/studenttableForLibrary",O="api/branchapi/library/addmembershipforStudent",_="api/branchapi/library/removemembershipforStudent",D=i.useMemo(()=>{if(!l?.value)return null;const B=R.includes("?")?"&":"?";return`${R}${B}class_id=${encodeURIComponent(String(l.value))}`},[R,l?.value]),u=i.useMemo(()=>{if(!l?.value||!d?.value)return null;const B=k.includes("?")?"&":"?";return`${k}${B}cID=${encodeURIComponent(String(l.value))}&sID=${encodeURIComponent(String(d.value))}&page=${s.page}&per_page=${s.rowsPerPage}`},[s.page,s.rowsPerPage,l?.value,d?.value,k]),{data:h}=K(n&&x?[x,n]:null,([B,U])=>G(B,U)),{data:S}=K(n&&D?[D,n]:null,([B,U])=>G(B,U)),{isLoading:E,error:$,data:q,mutate:T}=K(n&&u?[u,n]:null,([B,U])=>G(B,U)),F=i.useMemo(()=>xi(h),[h]),j=i.useMemo(()=>xi(S),[S]),P=(B,U)=>{r({page:B,rowsPerPage:parseInt(U,10)})},I=B=>{const U=B?.id??B?.student_id??B?.member_id;C(U??null),m(!0),f(M=>!M)},N=async B=>{if(B.preventDefault(),!A)return;const U=new FormData(B.target);U.set("id",String(A));try{await Ge(O,U,n),v.success("Success! Added member.",{duration:1e3,icon:"🎉"}),m(!1),C(null),await T()}catch(M){v.error(M?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},W=async B=>{try{await Ze(_,B,n),v.success("Success! Removed member.",{duration:1e3}),await T()}catch(U){v.error(U?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},Y=i.useMemo(()=>[{title:"Library Card No",dataIndex:"library_card_no",key:"library_card_no",width:180,ellipsis:!0,fixed:"left"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140,responsive:["sm"]},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,responsive:["lg"]},{title:"First Name",dataIndex:"firstname",key:"firstname",width:140,responsive:["sm"]},{title:"Last Name",dataIndex:"lastname",key:"lastname",width:140,responsive:["lg"]},{title:"Class",dataIndex:"class",key:"class",width:120,responsive:["xl"]},{title:"Section",dataIndex:"section",key:"section",width:120,responsive:["xl"]},{title:"Mobile",dataIndex:"mobileno",key:"mobileno",width:140,responsive:["lg"]},{title:"Action",key:"action",width:80,fixed:"right",render:(B,U)=>(console.log("data______________",U),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:U?.library_card_no==null?e.jsx(a.Button,{type:"primary",size:"small",icon:e.jsx(ee.UserAddOutlined,{}),onClick:()=>I(U)}):e.jsx(a.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>W(U?.id??U?.student_id??U?.member_id)})}))}],[W]);return e.jsxs("div",{style:{},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{open:p,title:"Add Member",onCancel:()=>{m(!1),C(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(V,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Add",color:"primary"})})]})},`add-${b}`)}),e.jsx(a.Card,{title:e.jsx(a.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(Z,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:l,onChange:B=>{o(B??null),c(null),y(U=>!U)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(Z,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:B=>c(B??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${g}`),e.jsx(ie,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!l?.value||!d?.value){v.error("Select class and section.",{duration:1e3});return}r(B=>({...B,page:1}))}})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(ze,{parentCallback:P,data:{newData:q,columns:Y,columnstype:"antd",action:!1,Loading:E,error:$}})})]})}function Om({token:t}){const n=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[l]=a.Form.useForm(),[o]=a.Form.useForm(),[d,c]=i.useState(!1),[g,y]=i.useState(null),p="api/branchapi/library/BookCategorytable",m="api/branchapi/library/addBookCategory",A="api/branchapi/library/editBookCategory",C="api/branchapi/library/deleteBookCategory",b=i.useMemo(()=>{const $=p.includes("?")?"&":"?";return`${p}${$}page=${s.page}&per_page=${s.rowsPerPage}`},[p,s.page,s.rowsPerPage]),{isLoading:f,error:x,data:R,mutate:k}=K(n&&b?[b,n]:null,([$,q])=>G($,q)),O=($,q)=>{r({page:$,rowsPerPage:parseInt(q,10)})},_=async $=>{const q=new FormData;q.set("title",$?.title??"");try{await Ge(m,q,n),v.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),l.resetFields(),await k()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to add category.",{duration:1e3})}},D=$=>{y($??null),o.setFieldsValue({title:$?.name??""}),c(!0)},u=()=>{c(!1),y(null),o.resetFields()},h=async $=>{const q=g?.id??g?.category_id??g?.cat_id;if(!q){v.error("Missing category id.",{duration:1e3});return}const T=new FormData;T.set("id",String(q)),T.set("title",$?.title??"");try{await tt(A,T,n),v.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),u(),await k()}catch(F){v.error(F?.response?.data?.msg??F?.message??"Failed to update category.",{duration:1e3})}},S=async $=>{const q=$?.id??$?.category_id??$?.cat_id;if(!q){v.error("Missing category id.",{duration:1e3});return}try{await Ze(C,q,n),v.success("Success! Deleted category.",{duration:1e3}),await k()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to delete category.",{duration:1e3})}},E=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:($,q)=>e.jsxs(a.Space,{size:6,children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>D(q)}),e.jsx(a.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>S(q),children:e.jsx(a.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[S]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{open:d,title:"Edit Category",onCancel:u,footer:null,destroyOnClose:!0,children:e.jsxs(a.Form,{form:o,layout:"vertical",onFinish:h,children:[e.jsx(a.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(a.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(a.Button,{onClick:u,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,lg:8,children:e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(a.Form,{form:l,layout:"vertical",onFinish:_,children:[e.jsx(a.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(a.Input,{placeholder:"Enter category name"})}),e.jsx(ie,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(a.Col,{xs:24,lg:16,children:e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(ze,{parentCallback:O,data:{newData:R,columns:E,columnstype:"antd",action:!1,Loading:f,error:x}})})})]})]})}const Es=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Mm({token:t}){const[n,s]=i.useState([se().format("YYYY-MM-DD"),se().format("YYYY-MM-DD")]),[r,l]=i.useState(null),[o,d]=i.useState(null),[c,g]=i.useState(null),[y,p]=i.useState(!1),[m,A]=i.useState(!1),C="api/branchapi/academy/classdropdownlist",b="api/branchapi/academy/sectionoftheClass",f="api/branchapi/library/memberDropdown",x="api/report/libraryReport/libraryReport",R=i.useMemo(()=>{if(!r?.value)return null;const I=b.includes("?")?"&":"?";return`${b}${I}class_id=${encodeURIComponent(String(r.value))}`},[b,r?.value]),k=i.useMemo(()=>{if(!r?.value)return null;const I=f.includes("?")?"&":"?",N=`${f}${I}class=${encodeURIComponent(String(r.value))}`;return o?.value?`${N}§ion=${encodeURIComponent(String(o.value))}`:N},[f,r?.value,o?.value]),{isLoading:O,error:_,data:D,mutate:u}=K(t&&C?[C,t]:null,([I,N])=>G(I,N)),{data:h}=K(t&&R?[R,t]:null,([I,N])=>G(I,N)),{data:S}=K(t&&k?[k,t]:null,([I,N])=>G(I,N)),E=i.useMemo(()=>Es(D),[D]),$=i.useMemo(()=>Es(h),[h]),q=i.useMemo(()=>Es(S),[S]),{trigger:T,data:F}=pt(x,(I,N)=>lr(I,N,t));i.useEffect(()=>{(async()=>{A(!0);try{await T({duration:n})}finally{A(!1)}})()},[]);const j=async()=>{A(!0);try{await T({duration:n,class:r?.value??"",section:o?.value??"",student_id:c?.value??""})}finally{A(!1)}},P=[{title:"Name",dataIndex:"full_name",render:(I,N)=>e.jsx(a.Typography.Text,{style:{fontSize:12},children:N?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(I,N)=>e.jsx(a.Typography.Text,{style:{fontSize:12},children:N?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(I,N)=>e.jsxs(a.Typography.Text,{style:{fontSize:12},children:[N?.class??"","(",N?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(I,N)=>e.jsx(a.Typography.Text,{style:{fontSize:12},children:N?.book_title??""})},{title:"Issue Date",key:"date",render:(I,N,W)=>e.jsx(a.Typography.Text,{style:{fontSize:12},children:N?.issue_date??""})},{title:"Due Return Date",key:"date",render:(I,N,W)=>e.jsx(a.Tag,{color:"orange",children:N?.return_date??""})},{title:"Return Date",key:"date",render:(I,N,W)=>N?.retured_by_user?e.jsx(a.Tag,{color:"green",children:N?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(I,N,W)=>String(N?.is_returned??"")==="1"?e.jsx(a.Tag,{color:"green",children:"Return"}):e.jsx(a.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(I,N,W)=>{const Y=N?.late_fine?Number(N.late_fine):0;return Y?e.jsx(a.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:Y}):null}}];return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(a.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(a.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(a.DatePicker.RangePicker,{style:{width:"100%"},value:[se(n[0],"YYYY-MM-DD"),se(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(I,N)=>{Array.isArray(N)&&N.length===2&&s([N[0],N[1]])}})]})}),e.jsx(a.Col,{xs:24,md:5,children:e.jsx(Z,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:I=>{l(I??null),d(null),g(null),p(N=>!N)},allowSelectAll:!1})}),e.jsx(a.Col,{xs:24,md:5,children:e.jsx(Z,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:o,onChange:I=>{d(I??null),g(null)},allowSelectAll:!1},`section1${y}`)}),e.jsx(a.Col,{xs:24,md:5,children:e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:I=>g(I??null),allowSelectAll:!1})}),e.jsx(a.Col,{xs:24,md:1,children:e.jsx(a.Button,{type:"primary",icon:e.jsx(ee.SearchOutlined,{}),onClick:j,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(a.Table,{columns:P,pagination:!1,dataSource:Array.isArray(F?.data)?F.data:[],size:"small",rowKey:(I,N)=>I?.id??I?.issue_id??I?.fees_receipt_id??N,loading:m,scroll:{x:"max-content"},summary:I=>{const N=I.reduce((Y,B)=>Y+Number(B?.late_fine??0),0),W=I.reduce((Y,B)=>Y+Number(B?.is_returned??0),0);return e.jsxs(a.Table.Summary.Row,{children:[e.jsx(a.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",I.length]})}),e.jsx(a.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(I.length-W)]})}),e.jsx(a.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",W]})}),e.jsx(a.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",N.toLocaleString("en-IN")]})})]})}})})]})]})}const bi=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],ji=[{key:"renewalHistory",label:"Renewal History"},{key:"renewalFineReport",label:"Renewal + Fine"},{key:"currentlyRenewedBooks",label:"Currently Renewed"},{key:"upcomingRenewalDue",label:"Upcoming Due"},{key:"overdueRenewalReport",label:"Overdue"},{key:"renewalLimitReport",label:"Renewal Limit"},{key:"renewalStatusReport",label:"Renewal Status"},{key:"studentWiseReport",label:"Student-wise"},{key:"bookWiseReport",label:"Book-wise"},{key:"classWiseReport",label:"Class-wise"},{key:"staffWiseReport",label:"Staff-wise"},{key:"renewalStatisticsByDate",label:"Statistics by Date"}];function Em({token:t}){const n=t??localStorage.getItem("authToken")??"",[s,r]=i.useState("renewalHistory"),[l,o]=i.useState("This Month"),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(7),[A,C]=i.useState(1),[b,f]=i.useState(20),[x,R]=i.useState(""),[k,O]=i.useState("DESC"),_=i.useRef(null),D=N=>{const W=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s)&&(W.set("date_range",l),l==="Custom"&&d&&g&&(W.set("from_date",d),W.set("to_date",g))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(s)&&(W.set("page",String(A)),W.set("per_page",String(b))),s==="upcomingRenewalDue"&&W.set("days_ahead",String(p)),x&&W.set("sort_by",x),k&&W.set("sort_dir",k),`${N}?${W.toString()}`},u=i.useMemo(()=>{switch(s){case"renewalHistory":return D(Ec);case"renewalFineReport":return D(Fc);case"currentlyRenewedBooks":return D($c);case"upcomingRenewalDue":return D(Uc);case"overdueRenewalReport":return D(Bc);case"renewalLimitReport":return D(Nc);case"renewalStatusReport":return D(Lc);case"studentWiseReport":return D(qc);case"bookWiseReport":return D(zc);case"classWiseReport":return D(Yc);case"staffWiseReport":return D(Wc);case"renewalStatisticsByDate":return D(Vc);default:return null}},[s,l,d,g,p,A,b]),{data:h,isLoading:S}=K(n?[u,n]:null,([N,W])=>G(N,W)),E=h?.data||{},$=E?.rows||[],q=E?.pagination||{},T=N=>{r(N),C(1),f(20)},F=()=>{C(1)},j=()=>{switch(s){case"renewalHistory":case"renewalFineReport":return[{title:"Renewal ID",dataIndex:"renewal_id",key:"renewal_id"},{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Renewal No",dataIndex:"renewal_no",key:"renewal_no"},{title:"Old Due Date",dataIndex:"old_due_date",key:"old_due_date"},{title:"New Due Date",dataIndex:"new_due_date",key:"new_due_date"},{title:"Renewal Date",dataIndex:"renewal_date",key:"renewal_date"},{title:"Status",dataIndex:"status",key:"status",render:N=>e.jsx(a.Tag,{color:N==="renewed"?"green":"red",children:N})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:N=>N??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:N=>N?e.jsx(a.Tag,{color:N==="paid"?"green":N==="partial"?"orange":"red",children:N}):"-"}];case"currentlyRenewedBooks":case"upcomingRenewalDue":case"overdueRenewalReport":case"renewalLimitReport":case"renewalStatusReport":return[{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Due Date",dataIndex:"return_date",key:"return_date"},{title:"Renewal Count",dataIndex:"renewal_count",key:"renewal_count"},{title:"Max Renewal",dataIndex:"maximum_renewal",key:"maximum_renewal"},{title:"Days Remaining",dataIndex:"days_remaining",key:"days_remaining",render:N=>N??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:N=>N??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:N=>e.jsx(a.Tag,{color:N?"green":"red",children:N?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:N=>Array.isArray(N)?N.join("; "):"-"}];case"studentWiseReport":return[{title:"Student ID",dataIndex:"student_id",key:"student_id"},{title:"Student Name",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Books",dataIndex:"unique_books_renewed",key:"unique_books_renewed"},{title:"First Renewal",dataIndex:"first_renewal_date",key:"first_renewal_date"},{title:"Last Renewal",dataIndex:"last_renewal_date",key:"last_renewal_date"}];case"bookWiseReport":return[{title:"Book ID",dataIndex:"book_id",key:"book_id"},{title:"Title",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Category",dataIndex:"category",key:"category"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"classWiseReport":return[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"staffWiseReport":return[{title:"Staff",dataIndex:"renewed_by",key:"renewed_by"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];case"renewalStatisticsByDate":return[{title:"Period",dataIndex:"period",key:"period"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];default:return[]}},P=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s),I=i.useMemo(()=>j(),[s]);return e.jsx(w,{pt:5,pb:1,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,padding:"4px 8px",color:"#fff",display:"inline-block"}}),e.jsxs(w,{p:3,children:[e.jsxs(a.Row,{gutter:[16,16],mb:3,children:[P&&e.jsxs(e.Fragment,{children:[e.jsx(a.Col,{xs:24,md:6,children:e.jsx(Z,{options:bi,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:bi.find(N=>N.value===l)||null,onChange:N=>o(N?.value||"This Month")})}),l==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(a.Col,{xs:24,md:6,children:e.jsx(He,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:N=>c(N?N.format("YYYY-MM-DD"):"")})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(He,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:N=>y(N?N.format("YYYY-MM-DD"):"")})})]})]}),s==="upcomingRenewalDue"&&e.jsx(a.Col,{xs:24,md:6,children:e.jsx(Z,{options:[{label:"7 Days",value:7},{label:"14 Days",value:14},{label:"30 Days",value:30}],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Days Ahead",allowSelectAll:!1,value:{label:p+" Days",value:p},onChange:N=>m(N?.value||7)})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:F})})})]}),e.jsx(a.Tabs,{activeKey:s,onChange:T,items:ji})]})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:ji.find(N=>N.key===s)?.label||"Report"})}),e.jsxs(w,{p:3,children:[e.jsx(kt,{data:{tableRef:_}}),S?e.jsx(w,{py:8,textAlign:"center",children:e.jsx(a.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(a.Table,{size:"small",dataSource:$,columns:I,loading:S,pagination:!1,bordered:!0,rowKey:N=>N.renewal_id||N.id||JSON.stringify(N),ref:_}),$.length>0&&e.jsx(a.Pagination,{current:A,pageSize:b,total:q.total_rows||$.length,onChange:(N,W)=>{C(N),f(W)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const ds=t=>t??localStorage.getItem("authToken")??"",Fm=(t,n)=>{const s=String(t??""),r=String(n);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},rt={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"}},$m=()=>Fm(At(),rt.upload),Um=async({baseUrl:t,page:n=1,perPage:s=10},r)=>{const l=t.includes("?")?"&":"?",o=`${t}${l}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(s))}`;return G(o,ds(r))},mn=async(t,n,s)=>Ge(t,n,ds(s)),Ia=async(t,n,s)=>tt(t,n,ds(s)),hn=async(t,n,s)=>Ze(t,n,ds(s)),Bm=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Aa=({token:t,value:n,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(a.Upload,{maxCount:1,action:$m(),headers:r,onChange:l=>{if(l?.file?.status==="done"){const o=Bm(l?.file?.response);o&&s?.(o)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},Nn=rt.vendor,fn=({baseUrl:t,page:n=1,perPage:s=10,token:r})=>K(r&&t?[t,n,s,r]:null,([o,d,c,g])=>Um({baseUrl:o,page:d,perPage:c},g)),Nm=({token:t,page:n=1,perPage:s=10})=>fn({baseUrl:Nn.list,page:n,perPage:s,token:t}),Lm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Si=[{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 qm({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),{isLoading:y,error:p,data:m,mutate:A}=Nm({token:t,page:n.page,perPage:n.rowsPerPage}),C=async _=>{try{await A(mn(Nn.add,_,t),st(_)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){v.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},b=_=>{_.preventDefault();const D=new FormData(_.target);c&&D.set("image",c),C(D),_.target.reset(),g("")},f=(_,D)=>{s({page:_,rowsPerPage:parseInt(D,10)})},x=async _=>{try{await A(hn(Nn.remove,_,t),nt(_)),v.success("Success! Deleted item.",{duration:1e3})}catch(D){v.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},R=_=>{d(_),l(!0),g("")},k=async _=>{_.preventDefault();const D=new FormData(_.target);D.set("id",String(o?.id??"")),c&&D.set("image",c);try{await Ia(Nn.edit,D,t),await A(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null),g("")}catch(u){v.error(u?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["md"]},{title:"Address",dataIndex:"address",key:"address",ellipsis:!0,responsive:["lg"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Branch Name",dataIndex:"business_name",key:"business_name",ellipsis:!0,responsive:["lg"]},{title:"Account Holder",dataIndex:"acc_holder_name",key:"acc_holder_name",ellipsis:!0,responsive:["xl"]},{title:"Account Number",dataIndex:"acc_number",key:"acc_number",ellipsis:!0,responsive:["xl"]},{title:"UPI ID",dataIndex:"upi_id",key:"upi_id",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(_,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>R(D),style:{padding:2}}),e.jsx(wt,{id:D?.id,funcName:x})]})}],[x]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{l(!1),d(null),g("")},children:e.jsx("form",{onSubmit:k,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[Si.map(_=>e.jsx(V,{type:_.type,name:_.name,label:_.label,defaultValue:o?.[_.name]??"",required:_.required?"required":void 0},_.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(Aa,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null),g("")},style:Lm,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(w,{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:[Si.map(_=>e.jsx(V,{type:_.type,name:_.name,label:_.label,required:_.required?"required":void 0},_.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(Aa,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:f,data:{newData:m,columns:O,columnstype:"antd",action:!1,Loading:y,error:p}})})]})]})]})}const zm=({token:t})=>e.jsx(qm,{token:t}),Ln=rt.product,vi=rt.vendor.dropdown,wi=rt.category.dropdown,Ym=rt.subCategory.dropdown,_i=rt.unit.dropdown,yo=({token:t,page:n=1,perPage:s=10})=>fn({baseUrl:Ln.list,page:n,perPage:s,token:t}),Wm=({token:t})=>K(t&&vi?[vi,t]:null,([s,r])=>G(s,r)),Vm=({token:t})=>K(t&&wi?[wi,t]:null,([s,r])=>G(s,r)),Hm=({token:t})=>K(t&&_i?[_i,t]:null,([s,r])=>G(s,r)),Km=({token:t,categoryId:n})=>{const s=t&&n?`${Ym}?category_id=${encodeURIComponent(String(n))}`:null;return K(s?[s,t]:null,([l,o])=>G(l,o))},Dn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Gm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Jm({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState(""),[C,b]=i.useState(""),[f,x]=i.useState(""),{isLoading:R,error:k,data:O,mutate:_}=yo({token:t,page:n.page,perPage:n.rowsPerPage}),{data:D}=Wm({token:t}),{data:u}=Vm({token:t}),{data:h}=Hm({token:t}),{data:S}=Km({token:t,categoryId:y}),E=i.useMemo(()=>Dn(D),[D]),$=i.useMemo(()=>Dn(u),[u]),q=i.useMemo(()=>Dn(h),[h]),T=i.useMemo(()=>Dn(S),[S]),F=async B=>{try{await _(mn(Ln.add,B,t),st(B)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(U){v.error(U?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=B=>{B.preventDefault();const U=new FormData(B.target);y&&U.set("fk_categoryID",String(y)),m&&U.set("fk_sub_categoryID",String(m)),C&&U.set("vendor_id",String(C)),f&&U.set("unit",String(f)),c&&U.set("image",c),F(U),B.target.reset(),g(""),p(""),A(""),b(""),x("")},P=(B,U)=>{s({page:B,rowsPerPage:parseInt(U,10)})},I=async B=>{try{await _(hn(Ln.remove,B,t),nt(B)),v.success("Success! Deleted item.",{duration:1e3})}catch(U){v.error(U?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},N=B=>{d(B),l(!0),g(""),p(B?.fk_categoryID??B?.category_id??""),A(B?.fk_sub_categoryID??B?.sub_category_id??""),b(B?.vendor_id??""),x(B?.unit??B?.unit_id??"")},W=async B=>{B.preventDefault();const U=new FormData(B.target);U.set("id",String(o?.id??"")),y&&U.set("fk_categoryID",String(y)),m&&U.set("fk_sub_categoryID",String(m)),C&&U.set("vendor_id",String(C)),f&&U.set("unit",String(f)),c&&U.set("image",c);try{await Ia(Ln.edit,U,t),await _(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null),g("")}catch(M){v.error(M?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Y=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["lg"]},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",ellipsis:!0,width:100,responsive:["md"]},{title:"Unit",dataIndex:"unit_name",key:"unit_name",ellipsis:!0,width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",ellipsis:!0,width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["xl"]},{title:"Hsn Code",dataIndex:"hsn_code",key:"hsn_code",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(B,U)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>N(U),style:{padding:2}}),e.jsx(wt,{id:U?.id,funcName:I})]})}],[I]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{l(!1),d(null),g("")},children:e.jsx("form",{onSubmit:W,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(V,{type:"text",name:"name",label:"Product Name*",defaultValue:o?.name??"",required:"required"}),e.jsx(Z,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:B=>{const U=B?.value??"";p(U),A("")},defaultValue:y?$.find(B=>String(B?.value)===String(y)):null}),e.jsx(Z,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:B=>A(B?.value??""),defaultValue:m?T.find(B=>String(B?.value)===String(m)):null}),e.jsx(V,{type:"text",name:"barcode",label:"Barcode",defaultValue:o?.barcode??""}),e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:B=>x(B?.value??""),defaultValue:f?q.find(B=>String(B?.value)===String(f)):null}),e.jsx(V,{type:"number",name:"quantity",label:"Quantity*",defaultValue:o?.quantity??"",required:"required"}),e.jsx(V,{type:"number",name:"price",label:"Price*",defaultValue:o?.price??"",required:"required"}),e.jsx(Z,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:B=>b(B?.value??""),defaultValue:C?E.find(B=>String(B?.value)===String(C)):null}),e.jsx(V,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:o?.hsn_code??""}),e.jsx(gt,{type:"text",label:"Description",name:"description",rows:3,defaultValue:o?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(Aa,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null),g("")},style:Gm,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(V,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(Z,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:B=>{const U=B?.value??"";p(U),A("")}}),e.jsx(Z,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:B=>A(B?.value??"")},`subcat_${y}`),e.jsx(V,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:B=>x(B?.value??"")}),e.jsx(V,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(V,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(Z,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:B=>b(B?.value??"")}),e.jsx(V,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(gt,{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(Aa,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:P,data:{newData:O,columns:Y,columnstype:"antd",action:!1,Loading:R,error:k}})})]})]})]})}const Qm=({token:t})=>e.jsx(Jm,{token:t}),qn=rt.category,Xm=({token:t,page:n=1,perPage:s=10})=>fn({baseUrl:qn.list,page:n,perPage:s,token:t}),Zm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function eh({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),{isLoading:c,error:g,data:y,mutate:p}=Xm({token:t,page:n.page,perPage:n.rowsPerPage}),m=async k=>{try{await p(mn(qn.add,k,t),st(k)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(O){v.error(O?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},A=k=>{k.preventDefault();const O=new FormData(k.target);m(O),k.target.reset()},C=(k,O)=>{s({page:k,rowsPerPage:parseInt(O,10)})},b=async k=>{try{await p(hn(qn.remove,k,t),nt(k)),v.success("Success! Deleted item.",{duration:1e3})}catch(O){v.error(O?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},f=k=>{d(k),l(!0)},x=async k=>{k.preventDefault();const O=new FormData(k.target);O.set("id",String(o?.id??""));try{await Ia(qn.edit,O,t),await p(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null)}catch(_){v.error(_?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(k,O)=>String(k?.name??"").localeCompare(String(O?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(k,O)=>String(k?.description??"").localeCompare(String(O?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(k,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(O),style:{padding:2}}),e.jsx(wt,{id:O?.id,funcName:b})]})}],[b]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{l(!1),d(null)},children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"name",label:"Name",defaultValue:o?.name??"",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description",defaultValue:o?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null)},style:Zm,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:C,data:{newData:y,columns:R,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const th=({token:t})=>e.jsx(eh,{token:t}),zn=rt.subCategory,Ci=rt.category.dropdown,ah=({token:t,page:n=1,perPage:s=10})=>fn({baseUrl:zn.list,page:n,perPage:s,token:t}),nh=({token:t})=>K(t&&Ci?[Ci,t]:null,([s,r])=>G(s,r)),sh=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},rh={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function ih({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),{isLoading:y,error:p,data:m,mutate:A}=ah({token:t,page:n.page,perPage:n.rowsPerPage}),{data:C}=nh({token:t}),b=i.useMemo(()=>sh(C),[C]),f=async u=>{try{await A(mn(zn.add,u,t),st(u)),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})}},x=u=>{u.preventDefault();const h=new FormData(u.target);h.set("status","active"),h.set("img",c||""),f(h),u.target.reset(),g("")},R=(u,h)=>{s({page:u,rowsPerPage:parseInt(h,10)})},k=async u=>{try{await A(hn(zn.remove,u,t),nt(u)),v.success("Success! Deleted item.",{duration:1e3})}catch(h){v.error(h?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},O=u=>{d(u),l(!0)},_=async u=>{u.preventDefault();const h=new FormData(u.target);h.set("id",String(o?.id??"")),c&&h.set("img",c);try{await Ia(zn.edit,h,t),await A(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null),g("")}catch(S){v.error(S?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(u,h)=>String(u?.name??"").localeCompare(String(h?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(u,h)=>String(u?.description??"").localeCompare(String(h?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(u,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>O(h),style:{padding:2}}),e.jsx(wt,{id:h?.id,funcName:k})]})}],[k]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{l(!1),d(null),g("")},children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:o?.category_id?b.find(u=>String(u?.value)===String(o.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(V,{type:"text",name:"name",label:"Name*",defaultValue:o?.name??"",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description",defaultValue:o?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(Aa,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null),g("")},style:rh,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(V,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(Aa,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:R,data:{newData:m,columns:D,columnstype:"antd",action:!1,Loading:y,error:p}})})]})]})]})}const lh=({token:t})=>e.jsx(ih,{token:t}),Fs=rt.product,oh=rt.academy.classes,dh=rt.academy.sections,ch=rt.student.dropdown;function Na(t){const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]}function Tn(t,n){const s=Math.trunc(Number(t)||1),r=Math.max(1,s);return!Number.isFinite(Number(n))||Number(n)<=0?r:Math.min(r,Math.trunc(Number(n)))}function bt(t){return String(t??"")}function uh({token:t}){const[n,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState(!1),[y,p]=i.useState(""),[m,A]=i.useState([]),[C,b]=i.useState({}),[f,x]=i.useState({}),[R,k]=i.useState(!1),[O,_]=i.useState(""),[D,u]=i.useState(0),[h,S]=i.useState(""),[E,$]=i.useState(se()),[q,T]=i.useState([]),F={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},j=!!(n&&r&&o),{data:P}=K(t?[oh,t]:null,([ge,_e])=>G(ge,_e)),I=i.useMemo(()=>Na(P),[P]),N=t&&n?`${dh}?class_id=${encodeURIComponent(String(n))}`:null,{data:W}=K(N?[N,t]:null,([ge,_e])=>G(ge,_e)),Y=i.useMemo(()=>Na(W),[W]),B=t&&n&&r?`${ch}?class=${encodeURIComponent(String(n))}§ion=${encodeURIComponent(String(r))}`:null,{data:U}=K(B?[B,t]:null,([ge,_e])=>G(ge,_e)),M=i.useMemo(()=>Na(U),[U]),L=j?`${Fs.list}?page=1&per_page=10000`:null,{data:z,isLoading:ne}=K(t&&L?[L,t]:null,([ge,_e])=>G(ge,_e),{revalidateOnFocus:!1}),X=i.useMemo(()=>Na(z),[z]),J=i.useMemo(()=>{const ge=new Map;return(Array.isArray(X)?X:[]).forEach(_e=>{ge.set(bt(_e?.id),_e)}),ge},[X]),H=i.useMemo(()=>{const ge=Object.entries(f||{});return ge.length===0?[]:ge.map(([_e,ve])=>{const re=J.get(bt(_e));return re?{id:re?.id,name:re?.name,barcode:re?.barcode,stock:Number(re?.quantity||0),price:Number(re?.price||0),quantity:Tn(ve,Number(re?.quantity||0))}:null}).filter(Boolean)},[f,J]),Q=i.useMemo(()=>new Set(H.map(ge=>bt(ge?.id))),[H]),ce=i.useMemo(()=>(Array.isArray(H)?H:[]).reduce((_e,ve)=>_e+Number(ve?.price||0)*Number(ve?.quantity||1),0),[H]),De=i.useMemo(()=>{const ge=Number(D||0);return!Number.isFinite(ge)||ge<=0?0:Math.min(ge,ce)},[D,ce]),le=i.useMemo(()=>Math.max(0,ce-De),[De,ce]),ue=i.useMemo(()=>(Array.isArray(X)?X:[]).slice(0,30).map(ge=>({value:bt(ge?.id),label:`${ge?.name??""}${ge?.barcode?` • ${ge.barcode}`:""}${ge?.quantity!==void 0&&ge?.quantity!==null?` • Stock: ${ge.quantity}`:""}`,product:ge})),[X]),{trigger:oe}=pt(t&&j?Fs.search:null,(ge,{arg:_e})=>na(ge,{arg:_e},t));i.useEffect(()=>{if(!j){A([]);return}const ge=String(y||"").trim();if(ge.length<2){A(ue);return}let _e=!0;const ve=setTimeout(async()=>{let re=[];try{if(oe){const je=await oe({search:ge});re=Na(je)}}catch{re=[]}if(!Array.isArray(re)||re.length===0){const je=ge.toLowerCase();re=(Array.isArray(X)?X:[]).filter(Le=>{const qe=String(Le?.name??"").toLowerCase(),fe=String(Le?.barcode??"").toLowerCase();return qe.includes(je)||fe.includes(je)}).slice(0,30)}const xe=re.slice(0,30).map(je=>({value:bt(je?.id),label:`${je?.name??""}${je?.barcode?` • ${je.barcode}`:""}${je?.quantity!==void 0&&je?.quantity!==null?` • Stock: ${je.quantity}`:""}`,product:je}));_e&&A(xe)},250);return()=>{_e=!1,clearTimeout(ve)}},[ue,j,oe,X,y]),i.useEffect(()=>{x({}),b({}),p(""),A([]),k(!1),_(""),u(0),S(""),$(se()),T([])},[n,r,o]);const Ce=i.useCallback((ge,_e=1)=>{const ve=ge?.id;if(!ve)return;const re=Number(ge?.quantity||0);if(re<=0){v.error("Out of stock.",{duration:1e3});return}const xe=Tn(_e,re);x(je=>{const Le=je||{};return Object.prototype.hasOwnProperty.call(Le,bt(ve))?(v.error("Product already added.",{duration:1e3}),Le):{...Le,[bt(ve)]:xe}})},[x]),Ne=i.useCallback((ge,_e,ve)=>{x(re=>{const xe=re||{},je=bt(ge);return Object.prototype.hasOwnProperty.call(xe,je)?{...xe,[je]:Tn(_e,ve)}:xe})},[]),et=i.useCallback(ge=>{x(_e=>{const ve=_e||{},re=bt(ge);if(!Object.prototype.hasOwnProperty.call(ve,re))return ve;const xe={...ve};return delete xe[re],xe})},[]),we=i.useCallback((ge,_e,ve)=>{b(re=>({...re||{},[bt(ge)]:Tn(_e,ve)}))},[]),Ae=i.useCallback((ge,_e)=>{_e?.product&&Ce(_e.product,1),p(""),A(ue)},[Ce,ue]),Fe=i.useCallback(ge=>{if(ge.key!=="Enter")return;ge.preventDefault();const _e=Array.isArray(m)&&m.length>0?m[0]:null;if(_e?.product){Ce(_e.product,1),p(""),A(ue);return}const ve=String(y||"").trim().toLowerCase();if(ve.length===0)return;const re=(Array.isArray(X)?X:[]).find(xe=>{const je=String(xe?.name??"").toLowerCase(),Le=String(xe?.barcode??"").toLowerCase();return je.includes(ve)||Le.includes(ve)});re&&(Ce(re,1),p(""),A(ue))},[Ce,ue,X,m,y]),me=()=>{if(!t){v.error("Missing token.",{duration:1e3});return}if(!n){v.error("Select class.",{duration:1e3});return}if(!r){v.error("Select section.",{duration:1e3});return}if(!o){v.error("Select student.",{duration:1e3});return}if(!H||H.length===0){v.error("Add at least one product.",{duration:1e3});return}k(!0)},{trigger:de,isMutating:Re}=pt(t?Fs.sellProduct:null,(ge,{arg:_e})=>os(ge,{arg:_e},t)),Be=async()=>{if(!O){v.error("Select payment type.",{duration:1e3});return}const ge=(Array.isArray(H)?H:[]).map(ve=>({id:ve?.id,quantity:Number(ve?.quantity||1),price:Number(ve?.price||0),total_price:Number(ve?.total_price||0),fk_vendor_id:ve?.fk_vendor_id||"",fk_categoryID:ve?.fk_categoryID||"",name:ve?.name||"",class_id:ve?.class_id||"",fk_sub_categoryID:ve?.fk_sub_categoryID||"",description:ve?.description||"",min_quantity:Number(ve?.min_quantity||0),storecategory:Number(ve?.storecategory||0),barcode:ve?.barcode||""})),_e={amount:ce,class:n,section:r,student_id:o,payment_type:O,discount:De,notes:h||"",receipt_date:E?se(E).format("YYYY-MM-DD"):"",product:JSON.stringify(ge),total_payable_amount:ce,attchement:q[0]?.originFileObj||""};try{const re=Array.isArray(q)&&q.length>0&&q[0]?.originFileObj?(()=>{const je=new FormData;return Object.entries(_e).forEach(([Le,qe])=>{if(Le==="products"){je.append("product",JSON.stringify(qe));return}je.append(Le,String(qe??""))}),je.append("attachment",q[0].originFileObj),je})():_e,xe=await de(re);xe?.Status==="Success"?(v.success("Success! Product sold.",{duration:1e3}),k(!1),x({}),b({}),p(""),A(ue),_(""),u(0),S(""),$(se()),T([])):v.error(xe?.msg??"Failed to submit.",{duration:1e3})}catch{v.error("Failed to submit.",{duration:1e3})}},$e=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:(ge,_e)=>{const ve=bt(_e?.id),re=Number(_e?.quantity||0),xe=Q.has(ve),je=(xe?f?.[ve]:C?.[ve])??1;return e.jsx(a.InputNumber,{min:1,max:Number.isFinite(re)&&re>0?re:void 0,value:je,onChange:Le=>{xe?Ne(ve,Le,re):we(ve,Le,re)},disabled:re<=0})}},{title:"Amount",key:"amount",width:140,render:(ge,_e)=>{const ve=bt(_e?.id),re=(Q.has(ve)?f?.[ve]:C?.[ve])??1;return Number(_e?.price||0)*Number(re||1)}},{title:"Action",key:"action",width:120,render:(ge,_e)=>{const ve=bt(_e?.id),re=Number(_e?.quantity||0),xe=Q.has(ve),je=(xe?f?.[ve]:C?.[ve])??1;return xe?e.jsx(a.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>et(ve),style:{padding:2}}):e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.PlusOutlined,{}),disabled:re<=0,onClick:()=>Ce(_e,je),style:{padding:2}})}}],[Ce,Q,f,C,et,we,Ne]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(w,{pt:5,pb:2,children:[e.jsxs(w,{style:{padding:"12px 16px"},children:[e.jsx(w,{children:"Sell Product"}),e.jsx(a.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(Z,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:ge=>{const _e=ge?.value??"";s(_e),l(""),d(""),g(ve=>!ve)}}),e.jsx(Z,{options:Y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:ge=>{const _e=ge?.value??"";l(_e),d("")}},`section_${c}`),e.jsx(Z,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:ge=>d(ge?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(a.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(w,{style:{marginTop:12},children:"Product Section"}),e.jsx(a.AutoComplete,{value:y,options:m,onSearch:p,onFocus:()=>{j&&String(y||"").trim().length<2&&A(ue)},onSelect:Ae,disabled:!j,children:e.jsx(a.Input,{placeholder:"Search by product name or barcode",onKeyDown:Fe,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",Ft(ce)]})]}),e.jsx(a.Table,{rowKey:ge=>bt(ge?.id),columns:$e,dataSource:X,loading:ne,size:"small",bordered:!0,pagination:{pageSize:50,showSizeChanger:!0,pageSizeOptions:[25,50,100,200]},scroll:{x:"max-content"}}),e.jsxs("div",{style:{position:"sticky",bottom:0,background:"#fff",paddingTop:12,marginTop:12,borderTop:"1px solid #f0f0f0"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Selected Items"}),e.jsx("span",{children:H.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:Ft(ce)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(ie,{type:"button",value:"Submit",disabled:!j||H.length===0,onClick:me,style:{flex:1,minWidth:140}}),e.jsx(a.Button,{type:"text",style:F,onClick:()=>{x({}),b({}),p(""),A(ue)},disabled:H.length===0,children:"Clear"})]})]})]})})]}),e.jsx(a.Modal,{open:R,title:"Payment",onCancel:()=>k(!1),onOk:Be,confirmLoading:Re,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(a.Select,{value:O||void 0,onChange:_,placeholder:"Select payment type",style:{width:"100%"},options:[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"Bank",label:"Bank"},{value:"Cheque",label:"Cheque"},{value:"DD",label:"DD"},{value:"Internet Banking",label:"Internet Banking"}]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Receipt Date"}),e.jsx(a.DatePicker,{value:E,onChange:ge=>$(ge),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(a.InputNumber,{min:0,max:ce,value:D,onChange:ge=>u(Number(ge||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(a.Upload,{fileList:q,beforeUpload:()=>!1,onChange:({fileList:ge})=>T((ge||[]).slice(-1)),maxCount:1,children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(a.Input.TextArea,{value:h,onChange:ge=>S(ge.target.value),rows:3})]}),e.jsx(a.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:Ft(ce)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:Ft(De)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:Ft(le)})]})]})})]})})]})}const ph=({token:t})=>e.jsx(uh,{token:t}),Yn=rt.unit,mh=({token:t,page:n=1,perPage:s=10})=>fn({baseUrl:Yn.list,page:n,perPage:s,token:t}),hh={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function fh({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),{isLoading:c,error:g,data:y,mutate:p}=mh({token:t,page:n.page,perPage:n.rowsPerPage}),m=async k=>{try{await p(mn(Yn.add,k,t),st(k)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(O){v.error(O?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},A=k=>{k.preventDefault();const O=new FormData(k.target);m(O),k.target.reset()},C=(k,O)=>{s({page:k,rowsPerPage:parseInt(O,10)})},b=async k=>{try{await p(hn(Yn.remove,k,t),nt(k)),v.success("Success! Deleted item.",{duration:1e3})}catch(O){v.error(O?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},f=k=>{d(k),l(!0)},x=async k=>{k.preventDefault();const O=new FormData(k.target);O.set("id",String(o?.id??""));try{await Ia(Yn.edit,O,t),await p(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),d(null)}catch(_){v.error(_?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(k,O)=>String(k?.name??"").localeCompare(String(O?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(k,O)=>String(k?.description??"").localeCompare(String(O?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(k,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(O),style:{padding:2}}),e.jsx(wt,{id:O?.id,funcName:b})]})}],[b]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{open:r,title:o?.name?`Edit ${o.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{l(!1),d(null)},children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{type:"text",name:"name",label:"Unit Name",defaultValue:o?.name??"",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description",defaultValue:o?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null)},style:hh,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(V,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(be,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:C,data:{newData:y,columns:R,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const yh=({token:t})=>e.jsx(fh,{token:t}),gh=rt.product.sellReports,xh=rt.academy.classes,bh=rt.academy.sections,jh=rt.student.dropdown,Ai=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Sh({token:t}){const n=i.useRef(null),[s,r]=i.useState(null),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(!1),A=T=>{const F=T?.data?.data??T?.data??T??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},{data:C}=K(t?[xh,t]:null,([T,F])=>G(T,F)),b=i.useMemo(()=>A(C),[C]),f=t&&l?`${bh}?class_id=${encodeURIComponent(String(l))}`:null,{data:x}=K(f?[f,t]:null,([T,F])=>G(T,F)),R=i.useMemo(()=>A(x),[x]),k=t&&l&&d?`${jh}?class=${encodeURIComponent(String(l))}§ion=${encodeURIComponent(String(d))}`:null,{data:O}=K(k?[k,t]:null,([T,F])=>G(T,F)),_=i.useMemo(()=>A(O),[O]),{trigger:D,isMutating:u,data:h}=pt(gh,(T,{arg:F})=>lr(T,{arg:F},t));i.useEffect(()=>{const F=new Date().toISOString().slice(0,10);D({duration:[F,F]})},[D]);const S=i.useMemo(()=>{const T=h?.data??h??[];return Array.isArray(T)?T:[]},[h]),E=T=>{const F=Array.isArray(T?.product_details)?T.product_details:[];return F.length===0?null:e.jsx(a.Table,{size:"small",bordered:!0,pagination:!1,rowKey:j=>`${T?.receipt_id??"r"}_${j?.product_name??j?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:j=>Ai(j)}],dataSource:F})},$=[{title:"Receipt No",dataIndex:"receipt_no",key:"receipt_no"},{title:"Date",dataIndex:"receipt_date",key:"receipt_date"},{title:"Amount",dataIndex:"receipt_amount",key:"receipt_amount",render:T=>Ai(T)}],q=async()=>{if(!s||s.length!==2)return;const[T,F]=s;await D({duration:[T.format("YYYY-MM-DD"),F.format("YYYY-MM-DD")],class:l||"",section:d||"",student_id:g||""})};return e.jsx("div",{children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,lg:8,children:e.jsx(a.Card,{title:e.jsx(a.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(a.DatePicker.RangePicker,{value:s,onChange:r,style:{width:"100%"}})]}),e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:T=>{const F=T?.value??"";o(F),c(""),y(""),m(j=>!j)}}),e.jsx(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:T=>{const F=T?.value??"";c(F),y("")}},`section_${p}`),e.jsx(Z,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:T=>y(T?.value??"")}),e.jsx(ie,{type:"button",value:u?"Searching...":"Search",disabled:u,onClick:q,style:{width:"100%"}})]})})}),e.jsx(a.Col,{xs:24,lg:16,children:e.jsx(a.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(kt,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx($t,{})}),e.jsx(a.Table,{bordered:!0,size:"small",loading:u,rowKey:T=>String(T?.receipt_id??T?.receipt_no??Math.random()),columns:$,expandable:{expandedRowRender:E},dataSource:S,pagination:{pageSize:20}})]})})})]})})}const vh=({token:t})=>e.jsx(Sh,{token:t}),wh=rt.product;function _h({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState([]),[o,d]=i.useState([]),[c,g]=i.useState(!1),[y,p]=i.useState(!1),[m,A]=i.useState(null),[C,b]=i.useState(0),[f,x]=i.useState(null),[R,k]=i.useState(""),O=i.useRef(null),_=ia.useReactToPrint({contentRef:O,documentTitle:"Stock Barcodes"}),{isLoading:D,error:u,data:h,mutate:S}=yo({token:t,page:n.page,perPage:n.rowsPerPage}),E=(P,I)=>{s({page:P,rowsPerPage:parseInt(I,10)})},$={selectedRowKeys:r,onChange:(P,I)=>{l(P),d(I)}},q=P=>{A(P),b(Number(P?.quantity??0)),x(null),k(""),g(!0)},T=()=>{g(!1),A(null),b(0),x(null),k("")},F=async()=>{if(!m?.id)return;p(!0);const P=new FormData;P.append("product_id",String(m.id)),P.append("qty",String(C??0)),f&&P.append("tran_date",f.format("YYYY-MM-DD")),R&&P.append("remarks",R);try{const I=await Ia(wh.addStock,P,t);I?.Status==="Success"?(v.success("Success! Updated quantity.",{duration:1e3}),T(),await S()):v.error(I?.msg??"Failed to update quantity.",{duration:1e3})}catch{v.error("Failed to update quantity.",{duration:1e3})}finally{p(!1)}},j=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",width:100},{title:"Unit",dataIndex:"unit_name",key:"unit_name",width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["lg"]},{title:"Action",key:"action",width:160,fixed:"right",render:(P,I)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(a.Button,{size:"small",onClick:()=>q(I),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{title:m?.name?`Update Stock: ${m.name}`:"Update Stock",open:c,onCancel:T,onOk:F,okButtonProps:{loading:y},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(a.InputNumber,{min:0,style:{width:"100%"},value:C,onChange:P=>b(P??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(a.DatePicker,{style:{width:"100%"},value:f,onChange:x})]}),e.jsx(gt,{label:"Remarks",name:"remarks",rows:3,value:R,onChange:P=>k(P.target.value)})]})}),e.jsxs(w,{pt:5,pb:2,children:[e.jsxs(w,{children:["Manage Stock",e.jsx(ie,{type:"button",value:"Print Barcodes",disabled:!o||o.length===0,onClick:()=>_?.(),style:{minWidth:170}})]}),e.jsx(w,{style:{padding:"12px 16px"},children:e.jsx(a.Card,{style:{borderRadius:16},children:e.jsx(ze,{parentCallback:E,data:{newData:h,columns:j,columnstype:"antd",action:!1,Loading:D,error:u,rowSelection:$}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:O,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(o)?o:[]).map(P=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:P?.name??""}),e.jsx(Dl,{value:String(P?.barcode??P?.id??""),height:50,width:1.6,displayValue:!0})]},P?.id??P?.barcode??P?.name))})})})]})}const Ch=({token:t})=>e.jsx(_h,{token:t}),Ah=rt.report.stock,Dh=rt.product.dropdown,Th=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Rh({token:t}){const n=i.useRef(null),[s,r]=i.useState(null),[l,o]=i.useState(""),{data:d}=K(t?[Dh,t]:null,([b,f])=>G(b,f)),c=i.useMemo(()=>Th(d),[d]),{trigger:g,isMutating:y,data:p}=pt(Ah,(b,{arg:f})=>lr(b,{arg:f},t));i.useEffect(()=>{const f=new Date().toISOString().slice(0,10);g({duration:[f,f]})},[g]);const m=i.useMemo(()=>{const b=p?.data??p??[];return(Array.isArray(b)?b:[]).flatMap(x=>(Array.isArray(x?.ledger)?x.ledger:[]).map((R,k)=>({key:`${x.product_id??x.product_name??"p"}-${k}`,date:R?.date,product:x?.product_name,opening:R?.opening,inward:R?.inward,outward:R?.outward,closing:R?.closing})))},[p]),A=[{title:"Date",dataIndex:"date",key:"date"},{title:"Product",dataIndex:"product",key:"product"},{title:"Opening",dataIndex:"opening",key:"opening"},{title:"Inward",dataIndex:"inward",key:"inward"},{title:"Outward",dataIndex:"outward",key:"outward"},{title:"Closing",dataIndex:"closing",key:"closing",render:b=>e.jsx("span",{style:{color:Number(b)<0?"red":"green"},children:b})}],C=async()=>{if(!s||s.length!==2)return;const[b,f]=s;await g({duration:[b.format("YYYY-MM-DD"),f.format("YYYY-MM-DD")],product_id:l||""})};return e.jsxs(a.Card,{title:e.jsx(a.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(a.DatePicker.RangePicker,{value:s,onChange:r}),e.jsxs("select",{value:l,onChange:b=>o(b.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(b=>e.jsx("option",{value:String(b?.value??""),children:String(b?.label??"")},String(b?.value??b?.id??b?.label)))]}),e.jsx(a.Button,{type:"primary",onClick:C,loading:y,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(kt,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx($t,{})}),e.jsx(a.Table,{bordered:!0,size:"small",loading:y,rowKey:"key",columns:A,dataSource:m,pagination:{pageSize:50}})]})]})}const Ih=({token:t})=>e.jsx(Rh,{token:t}),Di=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],Nt={total_packages:124,total_downloads:45892,active_packages:118,deprecated_packages:6,pending_approval:3,published_this_month:12,published_this_week:4,packages_needing_update:8,packages_with_issues:2},Ti=[{npm_id:"NPM-001",package_name:"@ubk/erp-core",version:"1.2.1",description:"Core ERP utilities and shared types",author:"UBK Infotech",repository:"https://github.com/ubk/erp-core",license:"MIT",status:"published",created_at:"2024-01-15",updated_at:"2025-06-20"},{npm_id:"NPM-002",package_name:"@ubk/erp-components",version:"2.0.0",description:"Reusable Ant Design ERP component library",author:"UBK Infotech",repository:"https://github.com/ubk/erp-components",license:"ISC",status:"published",created_at:"2024-03-10",updated_at:"2025-08-01"},{npm_id:"NPM-003",package_name:"@ubk/erp-api-client",version:"0.9.5",description:"Axios-based API client for UBK ERP backends",author:"UBK Infotech",repository:"https://github.com/ubk/erp-api-client",license:"MIT",status:"draft",created_at:"2025-05-22",updated_at:"2025-07-14"},{npm_id:"NPM-004",package_name:"@ubk/erp-hooks",version:"1.1.0",description:"Custom React hooks for ERP workflows",author:"UBK Infotech",repository:"https://github.com/ubk/erp-hooks",license:"MIT",status:"published",created_at:"2024-08-05",updated_at:"2025-04-30"},{npm_id:"NPM-005",package_name:"@ubk/erp-utils",version:"3.2.1",description:"Utility functions for date, currency, and validation",author:"UBK Infotech",repository:"https://github.com/ubk/erp-utils",license:"ISC",status:"deprecated",created_at:"2023-11-20",updated_at:"2025-02-10"}],Ri=[{key:"dashboard",label:"Dashboard"},{key:"allPackages",label:"All Packages"},{key:"published",label:"Published"},{key:"draft",label:"Draft"},{key:"deprecated",label:"Deprecated"},{key:"pendingApproval",label:"Pending Approval"}];function kh(){const[t,n]=i.useState("dashboard"),[s,r]=i.useState("This Month"),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(1),[p,m]=i.useState(10),[A,C]=i.useState(""),b=i.useRef(null),f=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),x=i.useMemo(()=>{if(!A.trim())return Ti;const D=A.toLowerCase();return Ti.filter(u=>Object.values(u).some(h=>String(h??"").toLowerCase().includes(D)))},[A]),R=i.useMemo(()=>{const D=(g-1)*p;return x.slice(D,D+p)},[x,g,p]),k=()=>{y(1)},O=()=>{const D=[{title:"Total Packages",value:Nt.total_packages,icon:e.jsx(ee.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:Nt.total_downloads.toLocaleString(),icon:e.jsx(ee.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:Nt.active_packages,icon:e.jsx(ee.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:Nt.deprecated_packages,icon:e.jsx(ee.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:Nt.pending_approval,icon:e.jsx(ee.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:Nt.published_this_month,icon:e.jsx(ee.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:Nt.published_this_week,icon:e.jsx(ee.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:Nt.packages_needing_update,icon:e.jsx(ee.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:Nt.packages_with_issues,icon:e.jsx(ee.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(a.Row,{gutter:[16,16],children:D.map((u,h)=>e.jsx(a.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(a.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${u.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(w,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${u.color}15`,color:u.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:u.icon}),e.jsxs(w,{children:[e.jsx(a.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:u.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:u.value})]})]})},h))})},_=()=>{const D=[{title:"NPM ID",dataIndex:"npm_id",key:"npm_id",width:100},{title:"Package Name",dataIndex:"package_name",key:"package_name",ellipsis:!0},{title:"Version",dataIndex:"version",key:"version",width:100},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["md"]},{title:"Author",dataIndex:"author",key:"author",width:140,responsive:["lg"]},{title:"License",dataIndex:"license",key:"license",width:100},{title:"Status",dataIndex:"status",key:"status",width:120,render:u=>{let h="default";return u==="published"?h="green":u==="draft"?h="orange":u==="deprecated"?h="red":u==="pending"&&(h="blue"),e.jsx(a.Tag,{color:h,children:u.toUpperCase()})}},{title:"Created Date",dataIndex:"created_at",key:"created_at",width:120,responsive:["lg"]},{title:"Updated Date",dataIndex:"updated_at",key:"updated_at",width:120,responsive:["lg"]},{title:"Actions",key:"action",width:120,fixed:"right",render:(u,h)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:D};return e.jsx(w,{pt:5,pb:1,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(w,{p:3,children:[e.jsxs(a.Row,{gutter:[16,16],mb:3,children:[f&&e.jsxs(e.Fragment,{children:[e.jsx(a.Col,{xs:24,md:6,children:e.jsx(Z,{options:Di,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:Di.find(D=>D.value===s)||null,onChange:D=>r(D?.value||"This Month")})}),s==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(a.Col,{xs:24,md:6,children:e.jsx(He,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:D=>o(D?D.format("YYYY-MM-DD"):"")})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(He,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:D=>c(D?D.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:k})})})]}),e.jsx(a.Tabs,{activeKey:t,onChange:n,items:Ri})]})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(a.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:Ri.find(D=>D.key===t)?.label||"Report"})}),e.jsxs(w,{p:3,children:[t!=="dashboard"&&e.jsx(kt,{data:{tableRef:b}}),t==="dashboard"?O():e.jsx(a.Table,{size:"small",dataSource:R,columns:_(),loading:!1,pagination:!1,bordered:!0,rowKey:D=>D.npm_id||D.package_name||Math.random(),ref:b}),t!=="dashboard"&&x.length>0&&e.jsx(a.Pagination,{current:g,pageSize:p,total:x.length,onChange:(D,u)=>{y(D),m(u)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const cs=t=>t??localStorage.getItem("authToken")??"",Ph=(t,n)=>{const s=String(t??""),r=String(n);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Ye={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",roleDropdown:"api/Branch/getRoledropdownforBranch",staff:{list:"api/branchapi/staff/stafflist",searchByRole:"api/branchapi/staff/staffsearchbyRole",searchByKeywords:"api/branchapi/staff/staffsearchbyKeywords",deactivate:"api/branchapi/staff/staff_deactive",basicById:"api/branchapi/staff/getbasicdetailsbyID",experienceById:"api/branchapi/staff/getworkexperencebyID",payrollById:"api/branchapi/staff/getpayrollbyID",lastEmpNo:"api/branchapi/staff/getLastStaffEMPnumber",addBasic:"api/branchapi/staff/addstaffbasicdetails",editBasic:"api/branchapi/staff/editstaffbasicdetails",addExperience:"api/branchapi/staff/addstaffExperience",editExperience:"api/branchapi/staff/editstaffExperience",addPayroll:"api/branchapi/staff/addstaffpayroll",editPayroll:"api/branchapi/staff/editstaffpayroll",uploadProfile:"api/branchapi/staff/uploadstaffProfilepicture",uploadDocuments:"api/branchapi/staff/uploadDocuments"},master:{shift:{dropdown:"api/branchapi/generalSettings/shiftDropdown",table:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/editshift",remove:"api/branchapi/generalSettings/deleteshift",show:"api/branchapi/generalSettings/shiftShowdata"},department:{dropdown:"api/branchapi/humanResource/departmentDropdown",table:"api/branchapi/humanResource/departmenttypeTable",add:"api/branchapi/humanResource/adddepartment",edit:"api/branchapi/humanResource/editdepartment",remove:"api/branchapi/humanResource/deletedepartment",show:"api/branchapi/humanResource/departmentShowdata"},designation:{dropdown:"api/branchapi/humanResource/designationDropdown",table:"api/branchapi/humanResource/designationTable",add:"api/branchapi/humanResource/adddesignation",edit:"api/branchapi/humanResource/editdesignation",remove:"api/branchapi/humanResource/deletedesignation",show:"api/branchapi/humanResource/designationShowdata"},leaveType:{dropdown:"api/branchapi/humanResource/leavetypeDropdown",table:"api/branchapi/humanResource/LeavetypeTable",add:"api/branchapi/humanResource/addleavetype",edit:"api/branchapi/humanResource/editleavetype",remove:"api/branchapi/humanResource/deleteleavetype",show:"api/branchapi/humanResource/leavetypeShowdata"}},leave:{table:"api/branchapi/humanResource/LeaveTable",apply:"api/branchapi/humanResource/applyLeave",requestTable:"api/branchapi/humanResource/leaverequestTable",approveRequest:"api/branchapi/humanResource/approveleaveRequest"},attendance:{staffListForAttendance:"api/staff/attendence/stafflistforAttendence",staffDropdownByRole:"api/staff/attendence/getStaffDropDownByRoleId",addAttendanceToStaffByBranch:"api/staff/attendence/addattendencetoStaffbyBranch",manualAttendance:"api/staff/attendence/staffMenualAttendance",staffShiftByStaffId:"api/branchapi/staff/getStaffShiftByStaffId",dailyAttendance:"api/staff_attendance/attendance/report/daily",dailyAttendanceMultipleShift:"api/staff/attendence/dailyAttendanceMultipleShift"},attendanceReport:{monthlyStaffReport:"api/AttendenceReport/staffmonthlyAttendenceReport_new",staffAttendanceList:"api/AttendenceReport/staffAttendanceList",overallStaffReport:"api/staff/attendence/getAlloverAttendenceReportofStaff"},payroll:{monthlyGraph:"api/branchapi/reportGraph/monthlyPayroleReportgraph",staffPayrollByStaffId:"api/branchapi/humanResource/getStaffPayroleByStaffID",generatePayslip:"api/branchapi/humanResource/generatePayslip",payrollByRole:"api/branchapi/humanResource/getpayrolebyRole",monthlyReport:"api/branchapi/humanResource/monthlyPayRolereport"}},go=()=>Ph(At(),Ye.upload),Oh=async({baseUrl:t,page:n=1,perPage:s=10},r)=>{const l=t.includes("?")?"&":"?",o=`${t}${l}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(s))}`;return G(o,cs(r))},Ut=async(t,n,s)=>Ge(t,n,cs(s)),Jt=async(t,n,s)=>tt(t,n,cs(s)),yn=async(t,n,s)=>Ze(t,n,cs(s)),sa=Ye.staff,Mh=Ye.master.shift.dropdown,Eh=Ye.master.department.dropdown,Fh=Ye.master.designation.dropdown,$h=Ye.roleDropdown,Uh=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},xo=t=>{const n=qt(t);if(n)return n;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Bh=(t,n)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=xo(n),l=s.startsWith("/")?s.slice(1):s;return Uh(at(),`uploads/school_${r}/staff/Profile_picture/${l}`)},Nh=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:"),Wn=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Lh=t=>Wn(t).map(s=>{if(s?.value!==void 0&&s?.label!==void 0)return{...s,value:String(s.value),label:String(s.label)};const r=String(s?.shift_id??s?.id??s?.value??""),l=String(s?.shift_name??s?.label??s?.name??s?.title??r);return{...s,value:r,label:l}}),qh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",La={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ii=[{value:"A+",label:"A+"},{value:"A-",label:"A-"},{value:"B+",label:"B+"},{value:"B-",label:"B-"},{value:"O+",label:"O+"},{value:"O-",label:"O-"},{value:"AB+",label:"AB+"},{value:"AB-",label:"AB-"}],ki={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function zh({token:t,mode:n,staffId:s,initialValues:r,onSubmitted:l}){const[o,d]=i.useState(!1),c=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),g=String(c?.multiple_shift??"").toLowerCase()==="yes",[y,p]=i.useState(r?.roleValue??null),[m,A]=i.useState(r?.departmentValue??null),[C,b]=i.useState(r?.designationValue??null),[f,x]=i.useState(r?.genderValue??null),[R,k]=i.useState(r?.shiftValue??(g?[]:null)),[O,_]=i.useState(r?.dob?se(r.dob):null),[D,u]=i.useState(r?.doj?se(r.doj):null),[h,S]=i.useState(r?.file??""),[E,$]=i.useState(r?.bloodGroup??"");i.useEffect(()=>{r&&(p(r?.roleValue??null),A(r?.departmentValue??null),b(r?.designationValue??null),x(r?.genderValue??null),k(r?.shiftValue??(g?[]:null)),_(r?.dob?se(r.dob):null),u(r?.doj?se(r.doj):null),S(r?.file??""),$(r?.bloodGroup??""))},[r,g]);const{data:q}=K(t?[Mh,t]:null,([M,L])=>G(M,L)),{data:T}=K(t?[Eh,t]:null,([M,L])=>G(M,L)),{data:F}=K(t?[Fh,t]:null,([M,L])=>G(M,L)),{data:j}=K(t?[$h,t]:null,([M,L])=>G(M,L)),{data:P}=K(t?[sa.lastEmpNo,t]:null,([M,L])=>G(M,L)),I=i.useMemo(()=>Lh(q),[q]),N=i.useMemo(()=>Wn(T),[T]),W=i.useMemo(()=>Wn(F),[F]),Y=i.useMemo(()=>Wn(j),[j]),B=i.useMemo(()=>{const M=P?.data?.emp_number??P?.emp_number??P?.data??"";return String(M??"")},[P]),U=async M=>{M.preventDefault(),d(!0);const L=new FormData(M.target);L.set("role",y?.value??y??""),L.set("department",m?.value??m??""),L.set("designation",C?.value??C??""),L.set("gender",f?.value??f??""),L.set("dob",O?O.format("YYYY-MM-DD"):""),L.set("doj",D?D.format("YYYY-MM-DD"):""),log.e("Shift_Value:",R,"Multiple Shift:",g),g?(L.delete("shift_id"),(Array.isArray(R)?R:[]).forEach(ne=>{L.append("shift_id[]",ne?.value??ne??"")})):L.set("shift_id",R?.value??R??""),h&&L.set("file",h);try{const z=n==="edit"&&s,ne=z?sa.editBasic:sa.addBasic;z&&L.set("staff_id",String(s));const X=z?await Jt(ne,L,t):await Ut(ne,L,t),J=X?.ID??X?.id??s??null;v.success("Success!",{duration:1e3}),l?.({staffId:J,basic:{roleValue:y,departmentValue:m,designationValue:C,genderValue:f,shiftValue:R,dob:O,doj:D,file:h}})}catch(z){v.error(z?.response?.data?.msg??z?.message??"Failed.",{duration:1e3})}finally{d(!1)}};return 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(V,{type:"number",name:"emp_number",label:"EMP No",defaultValue:r?.emp_number??B,required:!0}),e.jsx(V,{type:"text",name:"f_name",label:"First Name",defaultValue:r?.f_name??"",required:!0}),e.jsx(V,{type:"text",name:"l_name",label:"Last Name",defaultValue:r?.l_name??"",required:!0}),e.jsx(V,{type:"text",name:"pan_no",label:"PAN",defaultValue:r?.pan_no??"",pattern:"[A-Z]{5}[0-9]{4}[A-Z]",title:"Enter valid PAN (e.g., ABCDE1234D)"}),e.jsx(V,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??"",pattern:"[0-9]{12}",title:"Enter 12-digit Aadhaar number"}),e.jsx(Z,{label:"Role",options:Y,value:y,onChange:M=>p(M??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{label:"Department",options:N,value:m,onChange:M=>A(M??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{label:"Designation",options:W,value:C,onChange:M=>b(M??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:f,onChange:M=>x(M??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(V,{type:"email",name:"email",label:"Email",defaultValue:r?.email??"",title:"Enter a valid email address"}),e.jsxs("div",{children:[e.jsx("div",{style:La,children:"DOB"}),e.jsx(a.DatePicker,{value:O,onChange:M=>_(M),style:ki,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:La,children:"DOJ"}),e.jsx(a.DatePicker,{value:D,onChange:M=>u(M),style:ki,placeholder:"Select DOJ"})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Blood Group",options:Ii,value:Ii.find(M=>M.value===E)??null,onChange:M=>$(M?.value??""),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsx("input",{type:"hidden",name:"bloodGroup",value:E})]}),e.jsx(V,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0,pattern:"[0-9]{10}",title:"Enter 10-digit contact number"}),e.jsx(V,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:La,children:"Shift"}),e.jsx(Z,{options:I,value:Array.isArray(R)&&g?I.filter(M=>R.some(L=>String(L?.value??L)===String(M?.value??M))):I.find(M=>String(R?.value??R)===String(M?.value??M))??(R&&!g?R:null),onChange:M=>k(M??(g?[]:null)),isMulti:g,closeMenuOnSelect:!g,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:La,children:"Profile Picture"}),e.jsxs("div",{style:{display:"grid",gap:8},children:[h?e.jsx("img",{src:Nh(h)?h:Bh(h,t),alt:"profile-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(a.Upload,{action:`${at()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${xo(t)}/staff/Profile_picture`},headers:t?{Authorization:t}:void 0,maxCount:1,accept:"image/*",onChange:M=>{if(M?.file?.status==="done"){const L=qh(M?.file?.response);L&&S(L)}M?.file?.status==="removed"&&S("")},children:e.jsx(a.Button,{type:"link",style:{paddingLeft:0},children:h?"Change":"Upload"})})]}),e.jsx("input",{type:"hidden",name:"file",value:h??""})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:La,children:"Address"}),e.jsx("textarea",{name:"address",rows:3,defaultValue:r?.address??"",placeholder:"Address",style:{width:"100%",resize:"vertical",padding:10,border:"1px solid #d9d9d9",borderRadius:8,outline:"none"}})]}),e.jsx("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:o?"Saving...":"Save & Next",color:"primary",disabled:o,loading:o})})]})})}const Yh=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},bo=t=>{const n=qt(t);if(n)return n;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Wh=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:"),Vh=(t,n)=>{const s=`${t||""}`.trim();if(!s)return"";if(Wh(s))return s;const r=bo(n),l=s.startsWith("/")?s.slice(1):s;return Yh(at(),`uploads/school_${r}/staff/document/${l}`)},Rn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Pi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Hh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Oi=t=>{if(!t)return null;const n=se(t);return n.isValid()?n:null};function Kh({token:t,mode:n,staffId:s,initialRows:r,onSubmitted:l,onBack:o}){const[d,c]=i.useState(!1),[g,y]=i.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(x=>({name:x?.name??"",from:Oi(x?.from_date??x?.from),to:Oi(x?.to_date??x?.to),image:x?.image??""}))),p=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),m=(f,x)=>{y(R=>R.map((k,O)=>O===f?{...k,...x}:k))},A=()=>y(f=>[...f,{name:"",from:null,to:null,image:""}]),C=f=>y(x=>x.length<=1?x:x.filter((R,k)=>k!==f)),b=async f=>{if(f.preventDefault(),c(!0),!s){v.error("Missing staff id.",{duration:1e3}),c(!1);return}const x=new FormData;x.append("staff_id",String(s)),g.forEach((R,k)=>{x.append(`experience[${k}][name]`,String(R?.name??"")),x.append(`experience[${k}][from]`,R?.from?R.from.format("YYYY-MM-DD"):""),x.append(`experience[${k}][to]`,R?.to?R.to.format("YYYY-MM-DD"):""),x.append(`experience[${k}][image]`,String(R?.image??""))});try{const R=n==="edit",k=R?sa.editExperience:sa.addExperience,O=R?await Jt(k,x,t):await Ut(k,x,t);v.success("Success!",{duration:1e3}),l?.({experience:g,result:O})}catch(R){v.error(R?.response?.data?.msg??R?.message??"Failed.",{duration:1e3})}finally{c(!1)}};return e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[g.map((f,x)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end",border:"1px solid #eee",borderRadius:12,padding:14},children:[e.jsxs("div",{children:[e.jsx("div",{style:Rn,children:"Name"}),e.jsx("input",{value:f.name,onChange:R=>m(x,{name:R.target.value}),placeholder:"Company / School",style:{width:"100%",height:40,border:"none",borderBottom:"1px solid #d9d9d9",outline:"none",background:"transparent"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:Rn,children:"From"}),e.jsx(a.DatePicker,{value:f.from,onChange:R=>m(x,{from:R}),style:Pi})]}),e.jsxs("div",{children:[e.jsx("div",{style:Rn,children:"To"}),e.jsx(a.DatePicker,{value:f.to,onChange:R=>m(x,{to:R}),style:Pi})]}),e.jsxs("div",{children:[e.jsx("div",{style:Rn,children:"Document"}),e.jsx(a.Upload,{maxCount:1,action:`${at()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${bo(t)}/staff/document`},headers:p,onChange:R=>{if(R?.file?.status==="done"){const k=Hh(R?.file?.response);k&&m(x,{image:k})}R?.file?.status==="removed"&&m(x,{image:""})},children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})}),!!f.image&&e.jsx("a",{href:Vh(f.image,t),target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"#1677ff",textDecoration:"underline",cursor:"pointer"},children:"View document"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(a.Button,{type:"text",icon:e.jsx(ee.DeleteOutlined,{}),danger:!0,onClick:()=>C(x),disabled:g.length<=1})})]},`exp-${x}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(a.Button,{icon:e.jsx(ee.PlusOutlined,{}),onClick:A,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(a.Button,{onClick:o,children:"Back"}),e.jsx(ie,{type:"submit",value:d?"Saving...":"Save & Next",color:"primary",disabled:d,loading:d})]})]})]})})}const Mi=(t,n=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const s=n.length?n:["allowances","Allowances","dedection","Dedection","deductions","Deductions"],r=[t];t?.data&&typeof t.data=="object"&&r.push(t.data);for(const o of r)for(const d of s){const c=o?.[d]??o?.[d.toLowerCase()]??o?.[d.toUpperCase()];if(Array.isArray(c)&&c.length>0)return c}const l=t?.data;if(Array.isArray(l)&&l.length>0)return l}return[]},qa=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function Gh({token:t,mode:n,staffId:s,initialValues:r,onSubmitted:l,onBack:o}){const[d,c]=i.useState(!1),[g,y]=i.useState(r?.type??"Permanent"),[p,m]=i.useState(r?.salary_type??qa[0]?.value),[A,C]=i.useState(Number(r?.amount??0)),[b,f]=i.useState(Number(r?.basic_pay)),[x,R]=i.useState(r?.declarationPERyear??""),{data:k}=K(t?[Mc,t]:null,([S,E])=>G(S,E),{revalidateOnFocus:!1}),O=i.useMemo(()=>r?.allowances&&Array.isArray(r.allowances)&&r.allowances.length>0?r.allowances:Mi(k,["allowances","Allowances"]),[k,r]),_=i.useMemo(()=>r?.deductions&&Array.isArray(r.deductions)&&r.deductions.length>0?r.deductions:Mi(k,["dedection","Dedection","deductions","Deductions"]),[k,r]),D=i.useMemo(()=>{const S=Number(b||0),E=(Array.isArray(O)?O:[]).map(j=>{const P=j?.amount_type??j?.amountType??j?.type??"",I=Number(j?.Amount??j?.amount??0),W=String(P).trim().toLowerCase()==="flat"?I:Number(S)/100*Number(I||0);return{...j,value:Number.isFinite(W)?W:0}}),$=(Array.isArray(_)?_:[]).map(j=>{const P=j?.amount_type??j?.amountType??j?.type??"",I=Number(j?.Amount??j?.amount??0),W=String(P).trim().toLowerCase()==="flat"?I:Number(S)/100*Number(I||0);return{...j,value:Number.isFinite(W)?W:0}}),q=E.reduce((j,P)=>j+Number(P?.value||0),0),T=$.reduce((j,P)=>j+Number(P?.value||0),0),F=Math.max(0,Number(S)+q-T);return{allowances:E,deductions:$,netAmount:F}},[O,_,b]),u=async S=>{if(S.preventDefault(),c(!0),!s){v.error("Missing staff id.",{duration:1e3}),c(!1);return}const E=new FormData;E.append("staff_id",String(s)),E.append("type",g),g==="Nonpermanent"?(E.append("salary_type",p??""),E.append("amount",String(A||"")),E.append("Allowances",JSON.stringify([])),E.append("Dedection",JSON.stringify([]))):(E.append("basic_pay",String(b||"")),E.append("declarationPERyear",String(x??"")),E.append("Allowances",JSON.stringify(D.allowances||[])),E.append("Dedection",JSON.stringify(D.deductions||[])),E.append("amount",String(D.netAmount||0)));try{const $=n==="edit",q=$?sa.editPayroll:sa.addPayroll,T=$?await Jt(q,E,t):await Ut(q,E,t);v.success("Success!",{duration:1e3}),l?.({payroll:{staffType:g,salaryType:p,amount:A,basicPay:b,declaration:x},result:T})}catch($){v.error($?.response?.data?.msg??$?.message??"Failed.",{duration:1e3})}finally{c(!1)}},h=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(S,E)=>`${E?.Amount??""} / ${E?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:u,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:g==="Nonpermanent"?"Non Permanent":"Permanent",value:g},onChange:S=>y(S?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),g==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(Z,{label:"Type",options:qa,value:qa.find(S=>S.value===p)??qa[0],onChange:S=>m(S?.value??qa[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(V,{type:"number",label:"Amount",value:A,onChange:S=>C(Number(S.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{type:"number",label:"Basic Pay",value:b,onChange:S=>f(Number(S.target.value||0)),required:!0}),e.jsx(V,{type:"text",label:"IT Declarations/Year",value:x,onChange:S=>R(S.target.value)}),e.jsx(V,{type:"number",label:"Net Amount",value:D.netAmount,disabled:!0})]})]}),g==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(a.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(a.Table,{bordered:!0,size:"small",rowKey:(S,E)=>`${S?.title??"a"}-${E}`,columns:h,dataSource:D.allowances,pagination:!1})}),e.jsx(a.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(a.Table,{bordered:!0,size:"small",rowKey:(S,E)=>`${S?.title??"d"}-${E}`,columns:h,dataSource:D.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(ie,{type:"submit",value:d?"Finishing...":"Finish",color:"primary",disabled:d,loading:d})})]})})}const Jh=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function jo({token:t,mode:n="add",staffId:s,onFinished:r}){const[l,o]=i.useState(0),[d,c]=i.useState(s??null),[g,y]=i.useState(null),[p,m]=i.useState(null),[A,C]=i.useState(null),b=n==="edit"?s??d:null,f=i.useMemo(()=>b?`${Ye.staff.basicById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),x=i.useMemo(()=>b?`${Ye.staff.experienceById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),R=i.useMemo(()=>b?`${Ye.staff.payrollById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),k=K(t&&f?[f,t]:null,([j,P])=>G(j,P)),O=K(t&&x?[x,t]:null,([j,P])=>G(j,P)),_=K(t&&R?[R,t]:null,([j,P])=>G(j,P)),D=k?.data,u=O?.data,h=_?.data,S=!!k?.isLoading;O?.isLoading,_?.isLoading;const E=i.useMemo(()=>{try{const j=JSON.parse(localStorage.getItem("genrall_settings")??"null");return String(j?.multiple_shift??"").toLowerCase()==="yes"}catch{return!1}},[]),$=i.useMemo(()=>{const j=Jh(D)[0]??D?.data??D??null;if(!j)return null;let P=null;const I=j?.shift_id??j?.shift_ids??j?.shift;if(I)if(E){const N=String(I).split(",").map(W=>W.trim()).filter(Boolean);N.length>0&&(P=N.map(W=>({value:String(W),label:W})))}else j?.shift_id?P={value:String(j.shift_id),label:j?.shift??""}:j?.shift&&(P={value:String(j.shift),label:j.shift});return{emp_number:j?.emp_number??j?.empNo??j?.employee_id??"",f_name:j?.f_name??j?.firstname??j?.first_name??j?.name??"",l_name:j?.l_name??j?.lastname??j?.last_name??j?.surname??"",pan_no:j?.pan_no??j?.pan??"",adhar_no:j?.adhar_no??j?.aadhar_no??"",email:j?.email??j?.email_id??"",dob:j?.dob??j?.date_of_birth??"",doj:j?.doj??j?.date_of_joining??j?.joining_date??"",bloodGroup:j?.bloodGroup??j?.blood_group??"",contact_no:j?.contact_no??j?.phone??j?.contact??"",education:j?.education??j?.qualification??"",address:j?.address??j?.bussiness_address??j?.business_address??"",file:j?.file??j?.profile_picture??j?.profile_pic??j?.image??"",genderValue:j?.gender?{value:j.gender,label:j.gender}:null,roleValue:j?.role_id?{value:String(j.role_id),label:j?.role??""}:j?.fk_roleid?{value:String(j.fk_roleid),label:j?.role??""}:null,departmentValue:j?.department?{value:String(j.department),label:j?.departments??""}:null,designationValue:j?.designation?{value:String(j.designation),label:j?.designations??""}:null,shiftValue:P}},[D,E]),q=i.useMemo(()=>{const j=u?.data??u??null;return(Array.isArray(j?.experience)?j.experience:Array.isArray(j)?j:[]).map(I=>({name:I?.name??"",from:I?.from_date??I?.from??"",to:I?.to_date??I?.to??"",image:I?.image??""}))},[u]),T=i.useMemo(()=>{const j=h?.data??h??null,I=(Array.isArray(j)?j:j?.data&&Array.isArray(j.data)?j.data:[])[0]??null;if(!I)return null;const N=h?.allowances??j?.allowances??[],W=h?.dedection??j?.dedection??h?.deductions??j?.deductions??[];return{type:I?.type??"Permanent",salary_type:I?.salary_type??"Hourly",amount:Number(I?.amount??0),basic_pay:Number(I?.basic_pay??0),declarationPERyear:I?.declarationPERyear??I?.it_declarationPERyear??"",allowances:Array.isArray(N)?N:[],deductions:Array.isArray(W)?W:[]}},[h]),F=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(a.Card,{title:e.jsx(a.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(a.Steps,{current:l,items:F}),l===0&&(n==="edit"&&S?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:40},children:e.jsx(a.Spin,{tip:"Loading staff data...",size:"large"})}):e.jsx(zh,{token:t,mode:n,staffId:b,initialValues:$,onSubmitted:({staffId:j})=>{j&&c(j),o(1)}})),l===1&&e.jsx(Kh,{token:t,mode:n,staffId:b??d,initialRows:q,onBack:()=>o(0),onSubmitted:()=>o(2)}),l===2&&e.jsx(Gh,{token:t,mode:n,staffId:b??d,initialValues:T,onBack:()=>o(1),onSubmitted:()=>{v.success("Completed.",{duration:1e3}),r?.({staffId:b??d}),o(0),n!=="edit"&&(c(null),y(null),m(null),C(null))}})]})})]})}function Qh({token:t}){return e.jsx(jo,{token:t,mode:"add"})}const Xh=({token:t})=>e.jsx(Qh,{token:t}),In=Ye.staff,Zh=Ye.roleDropdown,ef=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},tf=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function af({token:t,onNavigate:n}){const[s,r]=i.useState({page:1,rowsPerPage:10}),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(!1),[p,m]=i.useState(null),{data:A}=K(t?[Zh,t]:null,([u,h])=>G(u,h)),C=i.useMemo(()=>ef(A),[A]),b=i.useMemo(()=>{const u=s.page,h=s.rowsPerPage,S=l&&!d?`${In.searchByRole}?role_id=${encodeURIComponent(String(l))}`:d?`${In.searchByKeywords}?key=${encodeURIComponent(String(d))}`:In.list,E=S.includes("?")?"&":"?";return`${S}${E}page=${encodeURIComponent(String(u))}&per_page=${encodeURIComponent(String(h))}`},[s.page,s.rowsPerPage,d,l]),{isLoading:f,error:x,data:R,mutate:k}=K(t?[b,t]:null,([u,h])=>G(u,h)),O=i.useMemo(()=>tf(R),[R]),_=async u=>{const h=u?.id??u?.fk_staffID??u?.staff_id;if(h)try{await yn(In.deactivate,h,t),v.success("Success! Staff deactivated.",{duration:1e3}),await k()}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to deactivate staff.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Emp ID",dataIndex:"employee_id",key:"employee_id",width:120,responsive:["lg"]},{title:"Name",key:"name",ellipsis:!0,render:(u,h)=>`${h?.name||""} ${h?.surname||""}`.trim()},{title:"Role",dataIndex:"role",key:"role",ellipsis:!0,responsive:["md"]},{title:"Department",dataIndex:"departments",key:"departments",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"contact_no",key:"contact_no",ellipsis:!0,responsive:["md"]},{title:"Status",key:"steps",width:140,responsive:["lg"],render:(u,h)=>{const S=Number(h?.steps??h?.status??1),E=S<=1?30:S===2?60:100;return e.jsx(a.Progress,{percent:E,size:"small",format:$=>`${$}%`,style:{margin:"-4px 0"}})}},{title:"Action",key:"action",width:110,fixed:"right",render:(u,h)=>e.jsxs(a.Space,{size:"middle",children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>{typeof n=="function"?n("staff-edit",h):(m(h?.id??h?.fk_staffID??h?.staff_id??""),y(!0))}}),e.jsx(a.Popconfirm,{title:"Delete staff?",description:"Are you sure you want to deactivate this staff member?",okText:"Yes",cancelText:"No",onConfirm:()=>_(h),children:e.jsx(a.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ee.DeleteOutlined,{}),style:{padding:2}})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:2,style:{margin:0},children:"Filters"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:[{value:"",label:"All Roles"},...C],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:u=>{o(u?.value??""),r(h=>({...h,page:1}))}}),e.jsx(V,{type:"text",label:"Keyword",value:d,onChange:u=>c(u.target.value),placeholder:"Search by keywords"}),e.jsx(ie,{type:"button",value:"Refresh",onClick:()=>k()})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:8,style:{margin:0},children:"Staff Directory"}),children:e.jsx(a.Table,{bordered:!0,size:"small",loading:f,rowKey:u=>String(u?.id??u?.fk_staffID??u?.staff_id??Math.random()),columns:D,dataSource:O,pagination:{current:s.page,pageSize:s.rowsPerPage,onChange:(u,h)=>r({page:u,rowsPerPage:h}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]}),e.jsx(a.Drawer,{open:g,onClose:()=>{y(!1),m(null)},title:"Edit Staff",width:"80%",destroyOnClose:!0,footer:null,children:p!=null&&e.jsx(jo,{token:t,mode:"edit",staffId:String(p),onFinished:()=>{y(!1),m(null),k()}})})]})}const nf=({token:t,onNavigate:n})=>e.jsx(af,{token:t,onNavigate:n}),sf=Ye.attendance,rf=Ye.roleDropdown,Ei=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},kn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Fi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function lf({token:t,open:n,onClose:s,roleId:r,onSaved:l}){const[o,d]=i.useState(null),[c,g]=i.useState(""),[y,p]=i.useState(se()),[m,A]=i.useState(se()),[C,b]=i.useState(se()),f=i.useMemo(()=>r?`${Ye.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:x}=K(t&&f?[f,t]:null,([u,h])=>G(u,h)),R=i.useMemo(()=>Ei(x),[x]),{trigger:k,data:O}=pt(t?Ye.attendance.staffShiftByStaffId:null,(u,{arg:h})=>na(u,{arg:h},t)),_=i.useMemo(()=>Ei(O),[O]),D=async()=>{if(!o?.value){v.error("Select staff.",{duration:1e3});return}if(!c){v.error("Select shift.",{duration:1e3});return}const u=new FormData;u.set("staffID",String(o.value)),u.set("shift_id",String(c)),u.set("attendance_date",y?y.format("YYYY-MM-DD"):""),u.set("intime",m?m.format("h:mm a"):""),u.set("outime",C?C.format("h:mm a"):"");try{await Ut(Ye.attendance.manualAttendance,u,t),v.success("Success!",{duration:1e3}),l?.(),s?.(),d(null),g(""),p(se()),A(se()),b(se())}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed.",{duration:1e3})}};return e.jsx(a.Modal,{open:n,onCancel:s,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(a.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{label:"Staff",options:R,value:o,onChange:async u=>{if(d(u??null),g(""),u?.value&&k)try{await k({staff_id:u.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:kn,children:"Shift"}),e.jsx(a.Radio.Group,{value:c,onChange:u=>g(u.target.value),style:{display:"grid",gap:8},children:_.map(u=>e.jsx(a.Radio,{value:u?.value,children:u?.label??u?.name??u?.title??String(u?.value??"")},String(u?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:kn,children:"Date"}),e.jsx(a.DatePicker,{value:y,onChange:u=>u&&p(u),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:kn,children:"Start Time"}),e.jsx(a.TimePicker,{value:m,onChange:u=>u&&A(u),use12Hours:!0,format:"h:mm a",style:Fi})]}),e.jsxs("div",{children:[e.jsx("div",{style:kn,children:"End Time"}),e.jsx(a.TimePicker,{value:C,onChange:u=>u&&b(u),use12Hours:!0,format:"h:mm a",style:Fi})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(a.Button,{onClick:s,children:"Cancel"}),e.jsx(ie,{type:"button",value:"Save",color:"primary",onClick:D})]})]})})})}const of=({tableRef:t,excelDisabled:n})=>{const s=new Date().getTime(),r=ia.useReactToPrint({content:()=>t?.current});return e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsxs(a.Row,{gutter:8,children:[e.jsx(a.Col,{children:e.jsx(a.Button,{type:"text",icon:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(a.Col,{children:n?e.jsx(a.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>v.error("You must save attendance before download",{duration:2e3})}):e.jsx(po.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:t?.current,children:e.jsx(a.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},df=(t,n)=>{const s=t?.data?.data??t?.data??t??null;return s?n==="student"?Array.isArray(s?.student)?s.student:[]:Array.isArray(s?.staff)?s.staff:[]:[]},cf=t=>{const n=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,s=Number(n);return Number.isFinite(s)&&s>=0?s:0},uf=(t,n)=>{const s=t?.data?.data??t?.data??t??null;return s?n==="student"?{sunday:String(s?.sunday??"").toLowerCase()==="yes",holiday:String(s?.holiday??"").toLowerCase()==="yes"}:{sunday:!!s?.sunday,holiday:!!s?.holiday}:{sunday:!1,holiday:!1}};function pf({token:t,url:n,columns:s,reload:r,setReload:l,saveBtnRef:o,setSaveBtnDisabled:d,date:c,type:g="staff"}){const y=i.useRef(null),[p,m]=i.useState({page:0,rowsPerPage:10}),[A,C]=i.useState(!1),[b,f]=i.useState(!1),[x,R]=i.useState(null),[k,O]=i.useState([]),[_,D]=i.useState({sunday:!1,holiday:!1}),[u,h]=i.useState(!0);i.useEffect(()=>{m(q=>({...q,page:0}))},[n]),i.useEffect(()=>{let q=!0;return(async()=>{if(!(!t||!n)){C(!0);try{const F=String(n).includes("?")?"&":"?",j=`${n}${F}page=${p.page+1}&per_page=${p.rowsPerPage}`,P=await G(j,t);if(!q)return;R(P),P?.Status==="Success"?(d?.(!1),O(df(P,g)),D(uf(P,g))):(d?.(!0),O([]),D({sunday:!1,holiday:!1}))}catch{if(!q)return;d?.(!0),O([])}finally{q&&C(!1)}}})(),()=>{q=!1}},[p.page,p.rowsPerPage,r,d,t,g,n]);const S=i.useMemo(()=>cf(x),[x]);i.useEffect(()=>{const q=(Array.isArray(k)?k:[]).find(T=>T?.attendence_type_id===null);h(!!q)},[k]);const E=async()=>{if(t){f(!0);try{if(g==="staff"){const q=(Array.isArray(k)?k:[]).map(T=>({staff_id:T?.staff_id,attendence_type_id:T?.attendence_type_id?T.attendence_type_id:"1",in_time:T?.intime,out_time:T?.outtime,date:c}));await Ut(Ye.attendance.addAttendanceToStaffByBranch,q,t),v.success("Attendance saved successfully",{duration:2e3}),l?.(T=>!T)}else v.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(q){v.error(q?.response?.data?.msg??q?.message??"Failed required dates",{duration:2e3})}finally{f(!1)}}},$=i.useMemo(()=>(Array.isArray(s)?s:[]).map(T=>T?.selector==="attendence_type_id"?{title:T?.name??"Attendance",dataIndex:T.selector,key:T.selector,render:F=>F==null||F===""?e.jsx(a.Tag,{color:"orange",children:"Not Set"}):String(F)==="1"?e.jsx(a.Tag,{color:"green",children:"Present"}):String(F)==="4"?e.jsx(a.Tag,{color:"red",children:"Absent"}):String(F)==="3"?e.jsx(a.Tag,{color:"orange",children:"Late"}):e.jsx(a.Tag,{children:String(F)})}:T?.selector==="snum"?{title:T?.name??"Sl",key:T.selector,render:(F,j,P)=>P+1}:{title:T?.name??T?.selector,dataIndex:T?.selector,key:T?.selector}),[s]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(a.Card,{children:[e.jsx(of,{tableRef:y,excelDisabled:u}),e.jsx(a.Modal,{open:b,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(a.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),_.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):_.holiday?e.jsx("div",{style:{textAlign:"center",padding:"16px 0"},children:e.jsx("div",{style:{fontWeight:700,marginBottom:6},children:"Holiday"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:y,children:e.jsx(a.Table,{bordered:!0,size:"small",rowKey:(q,T)=>String(q?.id??q?.staff_id??T),columns:$,dataSource:k,loading:A,pagination:{current:p.page+1,pageSize:p.rowsPerPage,total:S,showSizeChanger:!0,onChange:(q,T)=>m({page:q-1,rowsPerPage:T})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:E,ref:o,style:{display:"none"},children:"hidden"})]})]})]})}const mf=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},hf={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function ff({token:t}){const[n,s]=i.useState(""),[r,l]=i.useState(se().format("YYYY-MM-DD")),[o,d]=i.useState(!1),[c,g]=i.useState(null),[y,p]=i.useState(!1),[m,A]=i.useState(!0),[C,b]=i.useState(!1),f=i.useRef(null),{data:x}=K(t?[rf,t]:null,([O,_])=>G(O,_)),R=i.useMemo(()=>mf(x),[x]),k=i.useMemo(()=>[{id:"1",name:"Staff Id",selector:"employee_id",sortable:!0},{id:"2",name:"Name",selector:"full_name",sortable:!0},{id:"4",name:"Contact",selector:"contact_no",sortable:!0},{id:"3",name:"Attendance",selector:"attendence_type_id",sortable:!0},{id:"5",name:"In Time",selector:"intime",sortable:!0},{id:"6",name:"Out Time",selector:"outtime",sortable:!0}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(a.Card,{title:e.jsx(a.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(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:O=>s(O?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(a.DatePicker,{defaultValue:se(),onChange:O=>O&&l(O.format("YYYY-MM-DD")),style:hf,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!r||(g(`${sf.staffListForAttendance}?role=${encodeURIComponent(String(n))}&date=${encodeURIComponent(String(r))}`),d(O=>!O))}})})]})}),e.jsxs(a.Card,{title:e.jsx(a.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(a.Button,{size:"small",type:y?"primary":"default",onClick:()=>p(O=>!O),children:y?"Marked":"Mark As Holiday"}),e.jsx(a.Button,{size:"small",type:"default",disabled:m,onClick:()=>b(!0),children:"Give Attendance"})]}),c?e.jsx(pf,{token:t,url:c,columns:k,reload:o,setReload:d,saveBtnRef:f,setSaveBtnDisabled:A,date:r,type:"staff",holidayChecked:y}):null]}),e.jsx(lf,{token:t,open:C,onClose:()=>b(!1),roleId:n,onSaved:()=>d(O=>!O)})]})}const yf=({token:t})=>e.jsx(ff,{token:t}),$i=Ye.attendanceReport.monthlyStaffReport,gf=Ye.roleDropdown,xf=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function bf({token:t}){const n=i.useRef(null),[s,r]=i.useState(!1),[l,o]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),g=i.useMemo(()=>dr(5),[]),{data:y}=K(t?[gf,t]:null,([q,T])=>G(q,T)),p=i.useMemo(()=>xf(y),[y]),[m,A]=i.useState([]),[C,b]=i.useState(1),[f,x]=i.useState(!1),[R,k]=i.useState(!1),[O,_]=i.useState(null),D=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:u}=pt(t&&$i?`${$i}?page=${C}&per_page=3`:null,(q,{arg:T})=>na(q,{arg:T},t),{onSuccess:q=>{x(!1);const T=Array.isArray(q)?q:[];T.length>0&&A(F=>[...F||[],...T]),T.length>1?b(F=>F+1):k(!1)},onError:()=>{x(!1),k(!1)}});i.useEffect(()=>{R&&u&&O&&u(O)},[R,C,O,u]);const h=i.useMemo(()=>{const q=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(T,F)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:F?.full_name??""})}];return Array.isArray(m)&&m.length>0&&((m[0]?.monthly_data??[]).forEach((F,j)=>{q.push({title:j+1,align:"center",key:String(j+1),render:(P,I)=>{const N=I?.monthly_data?.[j]?.[0]?.data?.[0]??{},W=N?.intime??"",Y=N?.outtime??"",B=N?.attendance_type??"";return e.jsx(a.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",W]}),e.jsxs("div",{children:["Out Time ",Y]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:ut(B)})})}})}),q.push({title:"Total",key:"Total",render:(F,j)=>{const P=j?.monthly_data??[],I=P.filter(W=>W?.[0]?.data?.[0]?.attendance_type==="A").length,N=P.filter(W=>W?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",I," P : ",N]})})}})),q},[m]),S=i.useMemo(()=>[{label:"Present",el:ut("P")},{label:"Absent",el:ut("A")},{label:"Leave",el:ut("L")},{label:"Weekly Off",el:ut("W")},{label:"Holiday",el:ut("H")}],[]),E=i.useMemo(()=>d.month?l.find(q=>q?.value==d.month)?.label??d.month??"--":"--",[d.month,l]),$=async q=>{if(q.preventDefault(),!d.role||!d.year||!d.month)return;b(1),x(!0),A([]);const T={session:D,year:d.year,month:d.month,day:"01",role:d.role};_(T),k(!0),await u?.(T)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(a.Card,{className:"d-print-none",title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:q=>c(T=>({...T,role:q?.value??"",rolllabel:q?.label??""}))}),e.jsx(Z,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:q=>{const T=cr(q?.value);o(T),r(F=>!F),c(F=>({...F,year:q?.label??""}))}}),e.jsx(Z,{options:l,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:q=>c(T=>({...T,month:q?.value??""}))},`month-${s}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.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($t,{})}),e.jsxs("div",{style:{border:"1px solid #ddd",borderRadius:8,padding:16,marginBottom:24,backgroundColor:"#f8f9fa"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:6},children:"Staff Attendance Summary"}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:10,fontSize:13},children:[e.jsxs("div",{children:["Role: ",e.jsx("span",{style:{fontWeight:700},children:d.rolllabel||"--"})]}),e.jsxs("div",{children:["Year: ",e.jsx("span",{style:{fontWeight:700},children:d.year||"--"})]}),e.jsxs("div",{children:["Month: ",e.jsx("span",{style:{fontWeight:700},children:E})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(kt,{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:S.map(q=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[q.label," :"]}),e.jsx("div",{children:q.el})]},q.label))})})]}),e.jsx(a.Skeleton,{active:!0,loading:f,paragraph:{rows:10},children:e.jsx(a.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:h,dataSource:m,pagination:!1,scroll:{x:"max-content"},rowKey:(q,T)=>String(q?.staff_id??q?.id??T)})})]})})]})}const jf=({token:t})=>e.jsx(bf,{token:t}),Ui=Ye.payroll,Sf=Ye.roleDropdown,vf=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},wf=t=>t?.data?.data??t?.data??t??[];function _f({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:s}){const[r,l]=i.useState({page:1,rowsPerPage:10}),[o,d]=i.useState(!1),[c,g]=i.useState([]),[y,p]=i.useState({role:"",roleLabel:"",year:"",month:""}),[m,A]=i.useState(null),C=h=>{if(!h)return;if(typeof s=="function"){s(h);return}const S=`${n}?id=${encodeURIComponent(String(h))}`;typeof window<"u"&&window?.location&&(window.location.href=S)},{data:b}=K(t?[Sf,t]:null,([h,S])=>G(h,S)),f=i.useMemo(()=>vf(b),[b]),x=i.useMemo(()=>dr(5),[]),{isLoading:R,error:k,data:O}=K(t&&m?[m,t]:null,([h,S])=>G(h,S)),_=i.useMemo(()=>{const h=wf(O);return Array.isArray(h)?h:[]},[O]),D=i.useMemo(()=>{const h=O?.pagination?.total_rows??O?.data?.pagination?.total_rows??O?.total??O?.total_rows,S=Number(h);return Number.isFinite(S)&&S>=0?S:_.length},[O,_.length]),u=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(h,S,E)=>E+1},{title:"Name",dataIndex:"full_name",key:"full_name",ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Mobile No",dataIndex:"contact_no",key:"contact_no",width:140,responsive:["md"]},{title:"Status",dataIndex:"status",key:"status",width:120,align:"center",render:(h,S)=>{const E=S?.id??S?.staff_id??S?.staffId;return e.jsx(a.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{C(E)},children:co(S?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:h=>{if(h.preventDefault(),!y.role||!y.year||!y.month)return;const S=`${Ui.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`;A(S)},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",marginBottom:14,padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsx(Z,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:h=>p(S=>({...S,role:h?.value??"",roleLabel:h?.label??""}))}),e.jsx(Z,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:h=>{const S=cr(h?.value);g(S),d(E=>!E),p(E=>({...E,year:h?.label??"",month:""}))}}),e.jsx(Z,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:h=>p(S=>({...S,month:h?.value??""}))},`month-${o}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary",onClick:()=>l(h=>({...h,page:1}))})})]})}),e.jsx(a.Table,{bordered:!0,size:"small",loading:R,rowKey:(h,S)=>String(h?.id??h?.staff_id??S),columns:u,dataSource:_,pagination:{current:r.page,pageSize:r.rowsPerPage,total:D,showSizeChanger:!0,onChange:(h,S)=>{l({page:h,rowsPerPage:S}),!(!y.role||!y.year||!y.month)&&A(`${Ui.payrollByRole}?page=${encodeURIComponent(String(h))}&per_page=${encodeURIComponent(String(S))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`)}},scroll:{x:"max-content"}})]})})}const Cf=({token:t})=>e.jsx(_f,{token:t}),So=Ye.leave,ka=({baseUrl:t,page:n=1,perPage:s=10,token:r})=>K(r&&t?[t,n,s,r]:null,([o,d,c,g])=>Oh({baseUrl:o,page:d,perPage:c},g)),Af=({token:t,page:n=1,perPage:s=10})=>ka({token:t,baseUrl:So.requestTable,page:n,perPage:s}),Df=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Tf=(t,n)=>{const s=new FormData;return Object.entries(t??{}).forEach(([r,l])=>{l!=null&&s.append(r,String(l))}),s.set("status",n),s};function Rf({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:l,data:o,mutate:d}=Af({token:t,page:n.page,perPage:n.rowsPerPage}),c=i.useMemo(()=>Df(o),[o]),g=async(p,m)=>{try{const A=Tf(p,m),C=await Jt(So.approveRequest,A,t);C?.Status==="Success"?v.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):v.error(C?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(A){v.error(A?.response?.data?.msg??A?.message??"Failed to update request.",{duration:1e3})}},y=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(p,m)=>m?.full_name??m?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(p,m)=>m?.leave_from??m?.from_date??""},{title:"To",key:"leave_to",width:120,render:(p,m)=>m?.leave_to??m?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(p,m)=>m?.leavetype??m?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(p,m)=>m?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(p,m)=>m?.employee_remark??m?.reason??""},{title:"View",key:"document_file",width:140,render:(p,m)=>{const A=m?.document_file;return A?e.jsx(a.Button,{size:"small",onClick:()=>window.open(A,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(p,m)=>{const A=String(m?.status??"").toLowerCase();return A==="approved"?e.jsx(a.Tag,{color:"green",children:"Approved"}):A==="declined"?e.jsx(a.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(a.Button,{type:"text",size:"small",onClick:()=>g(m,"approved"),icon:e.jsx(ee.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(a.Button,{type:"text",size:"small",onClick:()=>g(m,"declined"),icon:e.jsx(ee.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(a.Table,{bordered:!0,size:"small",loading:r,rowKey:(p,m)=>String(p?.id??p?.leave_id??m),columns:y,dataSource:c,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(p,m)=>s({page:p,rowsPerPage:m}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const If=({token:t})=>e.jsx(Rf,{token:t}),kf=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Pf=({token:t,value:n,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(a.Upload,{maxCount:1,action:go(),headers:r,onChange:l=>{if(l?.file?.status==="done"){const o=kf(l?.file?.response);o&&s?.(o)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},vo=Ye.leave,Of=Ye.master.leaveType.dropdown,Mf=({token:t,page:n=1,perPage:s=10})=>ka({token:t,baseUrl:vo.table,page:n,perPage:s}),Ef=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},$s={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ff({token:t,userType:n}){const[s,r]=i.useState({page:1,rowsPerPage:10}),[l,o]=i.useState(!1),[d,c]=i.useState(""),[g]=a.Form.useForm();console.log("ApplyLeavePage render",n);const{isLoading:y,error:p,data:m,mutate:A}=Mf({token:t,page:s.page,perPage:s.rowsPerPage}),{data:C}=K(t?[Of,t]:null,([u,h])=>G(u,h)),b=i.useMemo(()=>Ef(C),[C]),f=(u,h)=>r({page:u,rowsPerPage:parseInt(h,10)}),x=()=>{c(""),g.resetFields(),g.setFieldsValue({apply_date:se()}),o(!0)},R=()=>{o(!1),c(""),g.resetFields()},k=async u=>{const h=new FormData;h.set("apply_date",u?.apply_date?u.apply_date.format("YYYY-MM-DD"):""),h.set("leave_type",u?.leave_type?.value??u?.leave_type??""),h.set("from_date",u?.from_date?u.from_date.format("YYYY-MM-DD"):""),h.set("to_date",u?.to_date?u.to_date.format("YYYY-MM-DD"):""),h.set("reason",u?.reason??""),d&&h.set("file",d);try{await Ut(vo.apply,h,t),v.success("Success! Leave request submitted.",{duration:1e3}),R(),await A()}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to submit leave request.",{duration:1e3})}},O=i.useMemo(()=>{const u=m?.data??m??[];return Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]},[m]),_=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(u,h)=>h?.leavetype??h?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(u,h)=>h?.date??h?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(u,h)=>h?.leave_from??h?.from_date??""},{title:"To",key:"leave_to",width:130,render:(u,h)=>h?.leave_to??h?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(u,h)=>h?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]),D=n==="staff";return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{open:l,title:"Add Leave Request",onCancel:R,footer:null,destroyOnClose:!0,children:e.jsxs(a.Form,{form:g,layout:"vertical",onFinish:k,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(a.Form.Item,{name:"apply_date",rules:[{required:!0,message:"Select date"}],style:{marginBottom:0},children:e.jsx(a.DatePicker,{style:$s})})]}),e.jsx(a.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From"}),e.jsx(a.Form.Item,{name:"from_date",rules:[{required:!0,message:"Select from date"}],style:{marginBottom:0},children:e.jsx(a.DatePicker,{style:$s})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To"}),e.jsx(a.Form.Item,{name:"to_date",rules:[{required:!0,message:"Select to date"}],style:{marginBottom:0},children:e.jsx(a.DatePicker,{style:$s})})]}),e.jsx(a.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(V,{type:"text",label:"Reason",placeholder:"Reason"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(Pf,{token:t,value:d,onChange:c})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(a.Button,{onClick:R,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})]})}),D&&e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(ie,{type:"button",value:"Add Leave Request",onClick:x})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(a.Table,{bordered:!0,size:"small",loading:y,rowKey:(u,h)=>String(u?.id??u?.leave_id??h),columns:_,dataSource:O,pagination:{current:s.page,pageSize:s.rowsPerPage,onChange:(u,h)=>f(u,h),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const $f=({token:t,userType:n})=>e.jsx(Ff,{token:t,userType:n}),Vn=Ye.master.leaveType,Uf=({token:t,page:n=1,perPage:s=10})=>ka({token:t,baseUrl:Vn.table,page:n,perPage:s});function Bf({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r]=a.Form.useForm(),[l]=a.Form.useForm(),[o,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:y,error:p,data:m,mutate:A}=Uf({token:t,page:n.page,perPage:n.rowsPerPage}),C=(_,D)=>{s({page:_,rowsPerPage:parseInt(D,10)})},b=async _=>{const D=new FormData;D.set("title",_?.title??"");try{await A(Ut(Vn.add,D,t),st(D)),v.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(u){v.error(u?.response?.data?.msg??u?.message??"Failed to add leave type.",{duration:1e3})}},f=_=>{g(_??null),l.setFieldsValue({title:_?.leave_type_name??_?.name??""}),d(!0)},x=()=>{d(!1),g(null),l.resetFields()},R=async _=>{const D=c?.id??c?.leave_type_id;if(!D){v.error("Missing leave type id.",{duration:1e3});return}const u=new FormData;u.set("id",String(D)),u.set("title",_?.title??"");try{await Jt(Vn.edit,u,t),await A(),v.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),x()}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to update leave type.",{duration:1e3})}},k=async _=>{const D=_?.id??_?.leave_type_id;if(D)try{await A(yn(Vn.remove,D,t),nt(D)),v.success("Success! Deleted leave type.",{duration:1e3})}catch(u){v.error(u?.response?.data?.msg??u?.message??"Failed to delete leave type.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(_,D)=>e.jsxs(a.Space,{size:6,children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(D)}),e.jsx(a.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>k(D),children:e.jsx(a.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{open:o,title:"Edit Leave Type",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(a.Form,{form:l,layout:"vertical",onFinish:R,children:[e.jsx(a.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(a.Button,{onClick:x,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(a.Form,{form:r,layout:"vertical",onFinish:b,children:[e.jsx(a.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(ze,{parentCallback:C,data:{newData:m,columns:O,columnstype:"antd",action:!1,Loading:y,error:p}})})]})}const Nf=({token:t})=>e.jsx(Bf,{token:t}),Hn=Ye.master.department,Lf=({token:t,page:n=1,perPage:s=10})=>ka({token:t,baseUrl:Hn.table,page:n,perPage:s});function qf({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r]=a.Form.useForm(),[l]=a.Form.useForm(),[o,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:y,error:p,data:m,mutate:A}=Lf({token:t,page:n.page,perPage:n.rowsPerPage}),C=(_,D)=>{s({page:_,rowsPerPage:parseInt(D,10)})},b=async _=>{const D=new FormData;D.set("title",_?.title??"");try{await A(Ut(Hn.add,D,t),st(D)),v.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(u){v.error(u?.response?.data?.msg??u?.message??"Failed to add department.",{duration:1e3})}},f=_=>{g(_??null),l.setFieldsValue({title:_?.department_name??_?.name??""}),d(!0)},x=()=>{d(!1),g(null),l.resetFields()},R=async _=>{const D=c?.id??c?.department_id;if(!D){v.error("Missing department id.",{duration:1e3});return}const u=new FormData;u.set("id",String(D)),u.set("title",_?.title??"");try{await Jt(Hn.edit,u,t),await A(),v.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),x()}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to update department.",{duration:1e3})}},k=async _=>{const D=_?.id??_?.department_id;if(D)try{await A(yn(Hn.remove,D,t),nt(D)),v.success("Success! Deleted department.",{duration:1e3})}catch(u){v.error(u?.response?.data?.msg??u?.message??"Failed to delete department.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(_,D)=>e.jsxs(a.Space,{size:6,children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(D)}),e.jsx(a.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>k(D),children:e.jsx(a.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{open:o,title:"Edit Department",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(a.Form,{form:l,layout:"vertical",onFinish:R,children:[e.jsx(a.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(a.Button,{onClick:x,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(a.Form,{form:r,layout:"vertical",onFinish:b,children:[e.jsx(a.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(ze,{parentCallback:C,data:{newData:m,columns:O,columnstype:"antd",action:!1,Loading:y,error:p}})})]})}const zf=({token:t})=>e.jsx(qf,{token:t}),Kn=Ye.master.designation,Yf=({token:t,page:n=1,perPage:s=10})=>ka({token:t,baseUrl:Kn.table,page:n,perPage:s});function Wf({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r]=a.Form.useForm(),[l]=a.Form.useForm(),[o,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:y,error:p,data:m,mutate:A}=Yf({token:t,page:n.page,perPage:n.rowsPerPage}),C=(_,D)=>{s({page:_,rowsPerPage:parseInt(D,10)})},b=async _=>{const D=new FormData;D.set("title",_?.title??"");try{await A(Ut(Kn.add,D,t),st(D)),v.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(u){v.error(u?.response?.data?.msg??u?.message??"Failed to add designation.",{duration:1e3})}},f=_=>{g(_??null),l.setFieldsValue({title:_?.designation??""}),d(!0)},x=()=>{d(!1),g(null),l.resetFields()},R=async _=>{const D=c?.id??c?.designation_id;if(!D){v.error("Missing designation id.",{duration:1e3});return}const u=new FormData;u.set("id",String(D)),u.set("title",_?.title??"");try{await Jt(Kn.edit,u,t),await A(),v.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),x()}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to update designation.",{duration:1e3})}},k=async _=>{const D=_?.id??_?.designation_id;if(D)try{await A(yn(Kn.remove,D,t),nt(D)),v.success("Success! Deleted designation.",{duration:1e3})}catch(u){v.error(u?.response?.data?.msg??u?.message??"Failed to delete designation.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(_,D)=>e.jsxs(a.Space,{size:6,children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(D)}),e.jsx(a.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>k(D),children:e.jsx(a.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{open:o,title:"Edit Designation",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(a.Form,{form:l,layout:"vertical",onFinish:R,children:[e.jsx(a.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(a.Button,{onClick:x,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(a.Form,{form:r,layout:"vertical",onFinish:b,children:[e.jsx(a.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(ze,{parentCallback:C,data:{newData:m,columns:O,columnstype:"antd",action:!1,Loading:y,error:p}})})]})}const Vf=({token:t})=>e.jsx(Wf,{token:t}),Gn=Ye.master.shift,Hf=({token:t,page:n=1,perPage:s=10})=>ka({token:t,baseUrl:Gn.table,page:n,perPage:s}),jt="hh:mm A",xa=t=>{const n=String(t??"");if(!n)return null;const s=se(n,[jt,"HH:mm","HH:mm:ss"],!0);return s.isValid()?s:null},ba=t=>t?t.format(jt):"",It={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Kf({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r]=a.Form.useForm(),[l]=a.Form.useForm(),[o,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:y,error:p,data:m,mutate:A}=Hf({token:t,page:n.page,perPage:n.rowsPerPage}),C=(u,h)=>{s({page:u,rowsPerPage:parseInt(h,10)})},b=(u,h)=>{const S=new FormData;return h&&S.set("id",String(h)),S.set("name",u?.name??""),S.set("start_time",ba(u?.start_time)),S.set("end_time",ba(u?.end_time)),S.set("shift_start_from",ba(u?.shift_start_from)),S.set("shift_start_to",ba(u?.shift_start_to)),S.set("shift_end_from",ba(u?.shift_end_from)),S.set("shift_end_to",ba(u?.shift_end_to)),S},f=async u=>{try{const h=b(u);await Ut(Gn.add,h,t),await A(),v.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to add shift.",{duration:1e3})}},x=u=>{g(u??null),l.setFieldsValue({name:u?.shift_name??u?.name??"",start_time:xa(u?.start_time),end_time:xa(u?.end_time),shift_start_from:xa(u?.shift_start_from),shift_start_to:xa(u?.shift_start_to),shift_end_from:xa(u?.shift_end_from),shift_end_to:xa(u?.shift_end_to)}),d(!0)},R=()=>{d(!1),g(null),l.resetFields()},k=async u=>{const h=c?.id??c?.shift_id;if(!h){v.error("Missing shift id.",{duration:1e3});return}try{const S=b(u,h);await Jt(Gn.edit,S,t),await A(),v.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),R()}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to update shift.",{duration:1e3})}},O=async u=>{const h=u?.id??u?.shift_id;if(h)try{await yn(Gn.remove,h,t),await A(),v.success("Success! Deleted shift.",{duration:1e3})}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to delete shift.",{duration:1e3})}},_=i.useMemo(()=>[{title:"Name",dataIndex:"shift_name",key:"shift_name",ellipsis:!0,fixed:"left",width:160},{title:"Start Time",dataIndex:"start_time",key:"start_time",width:120},{title:"End Time",dataIndex:"end_time",key:"end_time",width:120},{title:"Start From",dataIndex:"shift_start_from",key:"shift_start_from",width:120,responsive:["md"]},{title:"Start To",dataIndex:"shift_start_to",key:"shift_start_to",width:120,responsive:["md"]},{title:"End From",dataIndex:"shift_end_from",key:"shift_end_from",width:120,responsive:["md"]},{title:"End To",dataIndex:"shift_end_to",key:"shift_end_to",width:120,responsive:["md"]},{title:"Action",key:"action",width:110,fixed:"right",render:(u,h)=>e.jsxs(a.Space,{size:6,children:[e.jsx(a.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>x(h)}),e.jsx(a.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>O(h),children:e.jsx(a.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]),D=[{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(a.Modal,{open:o,title:"Edit Shift",onCancel:R,footer:null,destroyOnClose:!0,children:e.jsxs(a.Form,{form:l,layout:"vertical",onFinish:k,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(a.Form.Item,{name:"start_time",label:"Start Time",rules:D,children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"end_time",label:"End Time",rules:D,children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(a.Button,{onClick:R,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(a.Form,{form:r,layout:"vertical",onFinish:f,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(V,{type:"text",label:"Name"})}),e.jsx(a.Form.Item,{name:"start_time",label:"Start Time",rules:D,children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"end_time",label:"End Time",rules:D,children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(a.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(a.TimePicker,{format:jt,use12Hours:!0,style:It})}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(ze,{parentCallback:C,data:{newData:m,columns:_,columnstype:"antd",action:!1,Loading:y,error:p}})})]})}const Gf=({token:t})=>e.jsx(Kf,{token:t}),Jf=Ye.attendance;function Qf({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,s)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:n?.shift_name??""},`${s}heading1`))]}),e.jsxs("tr",{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Sl.No"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Teacher's Name"}),(t?.shifts??[]).map((n,s)=>e.jsxs(i.Fragment,{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"In Time"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Out Time"})]},`${s}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((n,s)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:s+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${n?.name??""} ${n?.surname??""}`.trim()})}),(t?.shifts??[]).map((r,l)=>e.jsxs(i.Fragment,{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:n?.attendance_data?(n.attendance_data?.[r?.office_shift_id]?.checkintime??"").toUpperCase():""})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:n?.attendance_data?(n.attendance_data?.[r?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${l}cells${s}`))]},`${s}row`))})]})}):null}const Xf=t=>{const n=t?.data??t??{};return Array.isArray(n)?n:Array.isArray(n?.items)?n.items:Array.isArray(n?.data)?n.data:[]},Zf=t=>{const n=String(t??"").toLowerCase();return n==="present"?e.jsx(a.Tag,{color:"green",children:"Present"}):n==="absent"?e.jsx(a.Tag,{color:"red",children:"Absent"}):n==="leave"?e.jsx(a.Tag,{color:"orange",children:"Leave"}):e.jsx(a.Tag,{children:t??""})};function ey({token:t}){const[n,s]=i.useState(se()),[r,l]=i.useState(!1),[o,d]=i.useState(0),c=i.useMemo(()=>`${Jf.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,r,o]),{isLoading:g,error:y,data:p}=K(t?[c,t]:null,([f,x])=>G(f,x)),m=i.useMemo(()=>Xf(p),[p]),A=i.useMemo(()=>r?p?.data?.data??p?.data??p??null:null,[p,r]),C=ia.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),b=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(f,x,R)=>R+1},{title:"Name",key:"name",render:(f,x)=>x?.staff_name??`${x?.name??""} ${x?.surname??""}`.trim(),ellipsis:!0},{title:"Department",dataIndex:"department",key:"department",ellipsis:!0,responsive:["md"]},{title:"Designation",dataIndex:"designation",key:"designation",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(f,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[Zf(x?.attendance_status??x?.attendance),x?.is_week_off?e.jsx(a.Tag,{color:"blue",children:"W/O"}):null]})},{title:"In Time",key:"intime",width:120,render:(f,x)=>{const R=x?.attendance_data?.[0];return x?.check_in??R?.intime??""}},{title:"Out Time",key:"outtime",width:120,render:(f,x)=>{const R=x?.attendance_data?.[0];return x?.check_out??R?.outtime??""}}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(a.Card,{title:e.jsx(a.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(a.DatePicker,{value:n,onChange:f=>f&&s(f),style:{width:"100%"},allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",onClick:()=>d(f=>f+1)})})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:C}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx($t,{})}),r?e.jsx(Qf,{data:A}):e.jsx(a.Table,{bordered:!0,size:"small",loading:g,rowKey:(f,x)=>String(f?.id??f?.staff_id??x),columns:b,dataSource:m,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const ty=({token:t})=>e.jsx(ey,{token:t}),Bi=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ay=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 ny({token:t,staffId:n}){const[s,r]=i.useState(!1),[l,o]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[g,y]=i.useState(""),[p,m]=i.useState(""),A=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),C=E=>{const $=Number(E??0),q=Number.isFinite($)?$.toLocaleString("en-IN"):"0";return`${A?`${A} `:""}${q}`},b=i.useMemo(()=>n?`${Ye.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),f=i.useMemo(()=>n?`${Ye.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:x}=K(t&&b?[b,t]:null,([E,$])=>G(E,$)),{data:R,isLoading:k,mutate:O}=K(t&&f?[f,t]:null,([E,$])=>G(E,$)),_=i.useMemo(()=>Bi(x)[0]??x?.data??x??null,[x]),D=i.useMemo(()=>Bi(R),[R]),u=i.useMemo(()=>[{title:"Month",dataIndex:"month",key:"month",width:120,align:"center"},{title:"Basic Salary",dataIndex:"basic_salary",key:"basic_salary",width:140,align:"center",render:(E,$)=>e.jsx("div",{style:{fontSize:11},children:Ft($?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(E,$)=>e.jsx("div",{style:{fontSize:11},children:Ft($?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(E,$)=>e.jsx("div",{style:{fontSize:11},children:Ft($?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(E,$)=>e.jsx("div",{style:{fontSize:11},children:Ft($?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(E,$)=>e.jsx("div",{style:{cursor:$?.status==="due"?"pointer":"default"},onClick:()=>{$?.status==="due"&&(o($),r(!0))},children:co($?.status)})}],[]),h=i.useMemo(()=>[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"DD",label:"DD"},{value:"Bank",label:"Bank"},{value:"Internet Banking",label:"Internet Banking"},{value:"Cheque",label:"Cheque"}],[]),S=async()=>{if(!l)return;const E={...l,staff_id:n,payment_type:d?.value??"",notes:g,attchement:p};try{await Ge(Ye.payroll.generatePayslip,{arg:E},t),v.success("Success!",{duration:1e3}),r(!1),o(null),y(""),m(""),await O()}catch($){v.error($?.response?.data?.msg??$?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("div",{style:{fontSize:13,color:"#444"},children:_?`${_?.f_name??_?.firstname??""} ${_?.l_name??_?.lastname??""}`.trim():""}),e.jsx(a.Table,{bordered:!0,size:"small",loading:k,rowKey:(E,$)=>String(E?.id??`${E?.month}-${$}`),columns:u,dataSource:D,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(a.Modal,{open:s,onCancel:()=>{r(!1),o(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{label:"Pay",options:h,value:d,onChange:E=>c(E??h[0]),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Note"}),e.jsx(a.Input.TextArea,{rows:4,placeholder:"Note",value:g,onChange:E=>y(E.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(a.Upload,{maxCount:1,action:go(),headers:t?{Authorization:t}:void 0,onChange:E=>{if(E?.file?.status==="done"){const $=ay(E?.file?.response);$&&m($)}E?.file?.status==="removed"&&m("")},children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})}),!!p&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:p})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(a.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(ie,{type:"button",value:l?.Total_Payable_Amount?`Pay ${C(l.Total_Payable_Amount)}`:"Pay",onClick:S})]})]})})]})}function sy({token:t,staffId:n}){const s=i.useMemo(()=>{if(n!=null&&String(n).trim()!=="")return n;if(typeof window>"u")return null;const r=new URLSearchParams(window.location.search).get("id");return r||null},[n]);return s?e.jsx(ny,{token:t,staffId:s}):e.jsx(a.Card,{title:e.jsx(a.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 Qt({onAdd:t,onExport:n,onPrint:s,onDownload:r,onFilter:l,onRefresh:o,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(ee.FileExcelOutlined,{}),onClick:n},{key:"print",title:"Print",icon:e.jsx(ee.PrinterOutlined,{}),onClick:s},{key:"download",title:"Download",icon:e.jsx(ee.DownloadOutlined,{}),onClick:r},{key:"filter",title:"Filter",icon:e.jsx(ee.FilterOutlined,{}),onClick:l},{key:"refresh",title:"Refresh",icon:e.jsx(ee.ReloadOutlined,{}),onClick:o}],[t,n,s,r,l,o]),g=i.useMemo(()=>{const y=Array.isArray(d)&&d.length?new Set(d):null;return y?c.filter(p=>y.has(p.key)):c},[c,d]);return e.jsx(a.Space,{size:8,children:g.map(y=>e.jsx(a.Tooltip,{title:y.title,children:e.jsx(a.Button,{type:"text",icon:y.icon,onClick:y.onClick,disabled:!y.onClick})},y.key))})}const pr=t=>t??localStorage.getItem("authToken")??"",Lt={dashboard:{monthlyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentmonthlyReportgraph",weeklyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentweeklyReportgraph"},dropdowns:{classes:"api/branchapi/academy/classdropdownlist",sectionsByClass:"api/branchapi/academy/sectionoftheClass",sessions:"api/branchapi/generalSettings/sessiondropdown"},studentAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass",save:"api/studentAttendace/addattendencebyBranch",emergencyLeave:"api/StudentAttendace/emergency_leave"},dailyAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass"},monthlyReport:{table:"api/AttendenceReport/studentmonthlyAttendencebyclass",byStudent:"api/branchapi/student/getStududentMonthlyByIdUrlnew"},yearlyReport:{table:"api/AttendenceReport/studentyearlyAttendenceReport"}},Vt=async(t,n)=>G(t,pr(n)),ry=async(t,n,s)=>Ge(t,n,pr(s)),iy=async(t,n,s)=>an(t,{arg:n},pr(s)),nn=(t,n)=>{const s=new URLSearchParams;Object.entries(n??{}).forEach(([l,o])=>{o==null||o===""||s.set(l,String(o))});const r=t.includes("?")?"&":"?";return`${t}${r}${s.toString()}`},Ni=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},ly=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},wo=(t,n)=>{const s=t?.data?.data??t?.data??t??{},r=n?s?.[n]:s;return Array.isArray(r)?r:Array.isArray(s?.student)?s.student:Array.isArray(s?.staff)?s.staff:Array.isArray(s?.data)?s.data:[]},oy=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],dy=t=>{const n={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(s=>{if(Array.isArray(s?.monthly_data)||Array.isArray(s?.month_data)){oy(s).forEach(l=>{const o=l?.[0]?.data?.[0]??l?.data?.[0]??l??{},d=String(o?.attendance_type??o?.attendence_type_id??"").toUpperCase();(d==="P"||d==="1")&&(n.present+=1),(d==="A"||d==="4")&&(n.absent+=1),(d==="L"||d==="3")&&(n.late+=1),(d==="LEAVE"||d==="2")&&(n.leave+=1)});return}const r=String(s?.attendance_type??s?.attendence_type_id??"").toUpperCase();(r==="P"||r==="1")&&(n.present+=1),(r==="A"||r==="4")&&(n.absent+=1),(r==="L"||r==="3")&&(n.late+=1),(r==="LEAVE"||r==="2")&&(n.leave+=1)}),n},mr=(t,n)=>{const{data:s,isLoading:r,error:l}=K(n&&t?[t,n]:null,([o,d])=>Vt(o,d));return{isLoading:r,error:l,data:s,options:i.useMemo(()=>ly(s),[s])}},us=t=>mr(Lt.dropdowns.classes,t),ps=(t,n)=>{const s=t?`${Lt.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return mr(s,n)},cy=t=>mr(Lt.dropdowns.sessions,t),hr=t=>{const n=String(t??"").toUpperCase();return ut(n==="1"||n==="P"||n==="PRESENT"?"P":n==="4"||n==="A"||n==="ABSENT"?"A":n==="3"||n==="L"||n==="LATE"?"L":n==="2"||n==="LEAVE"?"LEAVE":n==="W"?"W":n==="H"?"H":n||"-")},_o=(t,n,s)=>{const r=new Blob([t],{type:n}),l=URL.createObjectURL(r),o=document.createElement("a");o.href=l,o.download=s,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(l)},Li=t=>String(t??"").replace(/"/g,'""'),uy=({rows:t,columns:n,fileName:s})=>{const r=Array.isArray(n)?n:[],l=Array.isArray(t)?t:[],o=r.map(c=>`"${Li(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=l.map((c,g)=>r.map(y=>{const p=y?.dataIndex??y?.selector??y?.key,m=p==="sl"?g+1:c?.[p];return`"${Li(m)}"`}).join(",")).join(`
|
|
61
|
-
`);
|
|
62
|
-
`),"text/csv;charset=utf-8;",s)},py=({value:t,fileName:n})=>{_o(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",n)};function Co({summary:t}){const n=[{key:"present",label:"Present",color:"#52c41a"},{key:"absent",label:"Absent",color:"#ff4d4f"},{key:"leave",label:"Leave",color:"#1677ff"}];return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:12},children:n.map(s=>e.jsxs(a.Card,{size:"small",styles:{body:{padding:12}},children:[e.jsx("div",{style:{fontSize:11,color:"#666",marginBottom:4},children:s.label}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:s.color},children:t?.[s.key]??0})]},s.key))})}function Da({summary:t,title:n="Attendance Overview"}){const s=i.useMemo(()=>[{key:"present",label:"Present",value:Number(t?.present??0),color:"#52c41a"},{key:"absent",label:"Absent",value:Number(t?.absent??0),color:"#ff4d4f"},{key:"leave",label:"Leave",value:Number(t?.leave??0),color:"#1677ff"}],[t]),r=Math.max(...s.map(l=>l.value),1);return e.jsx(a.Card,{size:"small",title:n,children:e.jsx("div",{style:{display:"grid",gap:8},children:s.map(l=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"80px 1fr 40px",gap:8,alignItems:"center"},children:[e.jsx("div",{style:{fontSize:11,color:"#444"},children:l.label}),e.jsx("div",{style:{height:10,background:"#f0f0f0",borderRadius:999},children:e.jsx("div",{style:{width:`${l.value/r*100}%`,height:"100%",background:l.color,borderRadius:999}})}),e.jsx("div",{style:{fontSize:11,fontWeight:600,textAlign:"right"},children:l.value})]},l.key))})})}function my(){const t=[{label:"Present",node:ut("P")},{label:"Absent",node:ut("A")},{label:"Late",node:ut("L")},{label:"Weekly Off",node:ut("W")},{label:"Holiday",node:ut("H")}];return e.jsx(a.Space,{wrap:!0,size:[12,8],children:t.map(n=>e.jsxs(a.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:n.label}),n.node]},n.label))})}function Ht({items:t}){const n=Array.isArray(t)?t.filter(s=>s?.value):[];return n.length?e.jsx(a.Space,{wrap:!0,size:[8,8],children:n.map(s=>e.jsxs(a.Tag,{color:"blue",children:[s.label,": ",s.value]},s.label))}):null}function ms({title:t,subtitle:n,printRef:s,exportRows:r,exportColumns:l,onRefresh:o,onAdd:d,filterSection:c,summary:g,chartContent:y,reportTitle:p,reportExtra:m,children:A,fileBaseName:C="attendance"}){const b=ia.useReactToPrint({content:()=>s?.current});return e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(a.Card,{size:"small",title:e.jsxs("div",{children:[e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:t}),n?e.jsx(a.Typography.Text,{type:"secondary",style:{display:"block",marginTop:2,fontSize:12},children:n}):null]}),extra:e.jsx(Qt,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>uy({rows:r,columns:l,fileName:`${C}.csv`}),onPrint:b,onDownload:()=>py({value:r,fileName:`${C}.json`}),onRefresh:o}),children:c}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:12,alignItems:"start"},children:[e.jsx(Co,{summary:g}),y===!1?null:y||e.jsx(Da,{summary:g})]}),e.jsx(a.Card,{size:"small",title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:p}),extra:m,styles:{body:{padding:0}},children:A})]})}const hy=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function fy({rows:t,loading:n,sunday:s,holiday:r,holidayTitle:l,onChangeRows:o,onEmergency:d}){const c=(y,p)=>{const m=(Array.isArray(t)?t:[]).map((A,C)=>(A?.student_session_id??A?.student_id??A?.id??C)===y?{...A,...p}:A);o?.(m)},g=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(y,p,m)=>m+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(y,p)=>p?.full_name??p?.student_name??p?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(y,p,m)=>{const A=p?.student_session_id??p?.student_id??p?.id??m;return e.jsx(a.Select,{size:"small",style:{width:"100%"},options:hy,value:String(y??"1"),onChange:C=>c(A,{attendence_type_id:C})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:y=>y?se(y).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120},{title:"Emergency Leave",key:"emergency_leave",width:140,render:(y,p)=>e.jsx(a.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(ee.ClockCircleOutlined,{}),onClick:()=>d?.(p),children:"E.L"})}],[d,t]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:l||"--"})]}):e.jsx(a.Table,{bordered:!0,size:"small",rowKey:(y,p)=>String(y?.student_session_id??y?.student_id??y?.id??p),columns:g,dataSource:Array.isArray(t)?t:[],loading:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function yy({rows:t,loading:n,sunday:s,holiday:r,holidayTitle:l}){const o=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,g)=>g+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(d,c)=>c?.full_name??c?.student_name??c?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:120,render:d=>hr(d)},{title:"Date",dataIndex:"date",key:"date",width:120,render:d=>d?se(d).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120}],[]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:l||"--"})]}):e.jsx(a.Table,{bordered:!0,size:"small",rowKey:(d,c)=>String(d?.student_session_id??d?.student_id??d?.id??c),columns:o,dataSource:Array.isArray(t)?t:[],loading:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function gy({data:t,loading:n,onViewStudent:s}){const r=t?.data??t??{},l=Array.isArray(r?.studentAttendance)?r.studentAttendance:Array.isArray(r?.students)?r.students:Array.isArray(r?.report)?r.report:Array.isArray(r?.data?.resultlist)?r.data.resultlist:Array.isArray(r?.resultlist)?r.resultlist:Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[],o=Array.isArray(r?.monthly_holiday)?r.monthly_holiday:[],d=Array.isArray(r?.dateSun)?r.dateSun:[],c=Number(r?.totalDaysMonth??0),g=i.useMemo(()=>{const y=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:20,fixed:"left"},{title:"Name",key:"student_name",fixed:"left",render:(p,m)=>e.jsx(a.Button,{type:"link",style:{padding:0},onClick:()=>s?.(m),children:m?.student_name??m?.full_name??"--"})}];return[...new Array(c).keys()].forEach(p=>{y.push({title:String(p+1),key:`day-${p+1}`,align:"center",render:(m,A)=>{const b=A?.[`${A?.student_id}_${l.indexOf(A)}`]?.[p]??{},f=b?.attendance_date,x=o.find(R=>R?.date===f);return d.includes(f)?Gr("sunday","W"):x?Gr("holiday","H"):hr(b?.attendence_type_id)}})}),y.push({title:"Total",key:"total",fixed:"right",render:(p,m)=>{let A=0,C=0,b=0;return[...new Array(c).keys()].forEach(f=>{const x=m?.[`${m?.student_id}_${l.indexOf(m)}`]?.[f]??{},R=String(x?.attendence_type_id??"");R==="1"&&(A+=1),R==="4"&&(C+=1),R==="3"&&(b+=1)}),e.jsxs("span",{children:["P: ",A," A: ",C," L: ",b]})}}),y},[o,s,l,d,c]);return e.jsx(a.Table,{bordered:!0,size:"small",rowKey:(y,p)=>String(y?.student_id??p),columns:g,dataSource:l,loading:n,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(a.Empty,{description:"No monthly report found"})}})}function xy({open:t,onClose:n,loading:s,data:r,studentName:l}){const o=Array.isArray(r?.data?.report)?r.data.report:[],d=[{title:"Date",dataIndex:"attendance_date",key:"attendance_date",render:c=>c?se(c).format("DD-MM-YYYY"):"--"},{title:"Status",key:"status",render:(c,g)=>hr(g?.attendence_type_id??g?.attendance_type)},{title:"In Time",dataIndex:"intime",key:"intime"},{title:"Out Time",dataIndex:"outtime",key:"outtime"},{title:"Remark",dataIndex:"remark",key:"remark"}];return e.jsx(a.Modal,{open:t,onCancel:n,footer:null,width:900,title:`Monthly Details${l?` - ${l}`:""}`,children:e.jsx(a.Table,{bordered:!0,size:"small",rowKey:(c,g)=>String(c?.attendance_date??g),columns:d,dataSource:o,loading:s,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function by({open:t,onClose:n,onSubmit:s,loading:r}){const[l,o]=a.Modal.useModal(),[d,c]=i.useState(null),[g,y]=i.useState(""),p=async()=>{if(!d){await l.warning({title:"Select time"});return}await s?.({outtime:d.format("h:mm a"),message:g}),c(null),y("")};return e.jsxs(e.Fragment,{children:[o,e.jsx(a.Modal,{title:"Emergency Leave",open:t,onCancel:n,onOk:p,confirmLoading:r,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Select Time"}),e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",value:d,onChange:c,style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Purpose"}),e.jsx(a.Input.TextArea,{rows:4,value:g,onChange:m=>y(m.target.value)})]})]})})]})}const Ao=t=>dy(t),qi=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n.reduce((s,r)=>({present:s.present+Number(r?.present??r?.Present??r?.total_present??0),absent:s.absent+Number(r?.absent??r?.Absent??r?.total_absent??0),late:s.late+Number(r?.late??r?.Late??0),leave:s.leave+Number(r?.leave??r?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(n?.present??n?.Present??n?.total_present??0),absent:Number(n?.absent??n?.Absent??n?.total_absent??0),late:Number(n?.late??n?.Late??0),leave:Number(n?.leave??n?.Leave??0)}};function jy({token:t}){const{data:n}=K(t?[Lt.dashboard.monthlyGraph,t]:null,([o,d])=>Vt(o,d)),{data:s}=K(t?[Lt.dashboard.weeklyGraph,t]:null,([o,d])=>Vt(o,d)),r=i.useMemo(()=>qi(n),[n]),l=i.useMemo(()=>qi(s),[s]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(a.Card,{children:[e.jsx(a.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(a.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(Co,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(Da,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(Da,{summary:l,title:"Weekly Attendance Chart"})]})]})}const Us=Lt.studentAttendance,Sy={width:"100%",height:40};function vy({token:t}){const n=i.useRef(null),[s,r]=i.useState(""),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(se()),[x,R]=i.useState(0),[k,O]=i.useState([]),[_,D]=i.useState(!1),[u,h]=i.useState(null),[S,E]=i.useState(!1),[$,q]=i.useState(!1),T=us(t),F=ps(s,t),j=i.useMemo(()=>!s||!d||x===0?null:nn(Us.list,{cID:s,sID:d,batch_id:p,date:b.format("YYYY-MM-DD")}),[p,s,b,x,d]),{data:P,isLoading:I,mutate:N}=K(t&&j?[j,t]:null,([J,H])=>Vt(J,H));i.useEffect(()=>{O(wo(P,"student"))},[P]);const W=P?.data?.data??P?.data??P??{},Y=!!W?.sunday,B=!!W?.holiday?.holiday,U=W?.holiday?.title??"",M=i.useMemo(()=>Ao(k),[k]),L=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),z=async()=>{if(k.length)try{q(!0),await ry(Us.save,{attendenceData:k,date:b.format("YYYY-MM-DD"),holiday:_?"YES":"NO"},t),v.success("Student attendance saved."),N?.()}catch(J){v.error(J?.message??"Failed to save attendance.")}finally{q(!1)}},ne=async({outtime:J,message:H})=>{if(u?.attendence_id)try{E(!0),await iy(Us.emergencyLeave,{outtime:J,message:H,id:u.attendence_id},t),v.success("Emergency leave updated."),h(null),N?.()}catch(Q){v.error(Q?.message??"Failed to update emergency leave.")}finally{E(!1)}},X=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{options:T.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:J=>{r(J?.value??""),o(J?.label??""),c(""),y(""),m(""),C("")},required:!0}),e.jsx(Z,{options:F.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:J=>{c(J?.value??""),y(J?.label??""),m(""),C("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(a.DatePicker,{value:b,onChange:J=>J&&f(J),style:Sy,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>R(J=>J+1)})})]}),e.jsx(Ht,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{}),e.jsx(ms,{title:"Student Attendance",printRef:n,exportRows:k,exportColumns:L,onRefresh:()=>N?.(),filterSection:X,summary:M,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(a.Button,{size:"small",type:_?"primary":"default",onClick:()=>D(J=>!J),children:_?"Marked":"Mark As Holiday"}),e.jsx(a.Button,{size:"small",type:"primary",onClick:z,loading:$,disabled:!k.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx($t,{}),e.jsx(a.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(a.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Ht,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})})]}),e.jsx(fy,{rows:k,loading:I,sunday:Y,holiday:B,holidayTitle:U,onChangeRows:O,onEmergency:h})]})}),e.jsx(by,{open:!!u,onClose:()=>h(null),onSubmit:ne,loading:S})]})}const wy=Lt.dailyAttendance,_y={width:"100%",height:40};function Cy({token:t}){const n=i.useRef(null),[s,r]=i.useState(""),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(se()),[x,R]=i.useState(0),k=us(t),O=ps(s,t),_=i.useMemo(()=>!s||!d||x===0?null:nn(wy.list,{cID:s,sID:d,batch_id:p,date:b.format("YYYY-MM-DD")}),[p,s,b,x,d]),{data:D,isLoading:u,mutate:h}=K(t&&_?[_,t]:null,([I,N])=>Vt(I,N)),S=i.useMemo(()=>wo(D,"student"),[D]),E=D?.data?.data??D?.data??D??{},$=!!E?.sunday,q=!!E?.holiday?.holiday,T=E?.holiday?.title??"",F=i.useMemo(()=>Ao(S),[S]),j=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),P=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{options:k.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{r(I?.value??""),o(I?.label??""),c(""),y(""),m(""),C("")},required:!0}),e.jsx(Z,{options:O.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{c(I?.value??""),y(I?.label??""),m(""),C("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(a.DatePicker,{value:b,onChange:I=>I&&f(I),style:_y,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>R(I=>I+1)})})]}),e.jsx(Ht,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})]});return e.jsx(ms,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:n,exportRows:S,exportColumns:j,onRefresh:()=>h?.(),filterSection:P,summary:F,chartContent:e.jsx(Da,{summary:F,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx($t,{}),e.jsx(Ht,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})]}),e.jsx(yy,{rows:S,loading:u,sunday:$,holiday:q,holidayTitle:T})]})})}const zi=Lt.monthlyReport,Do=t=>Array.isArray(t?.studentAttendance)?t.studentAttendance:Array.isArray(t?.students)?t.students:Array.isArray(t?.report)?t.report:Array.isArray(t?.data?.resultlist)?t.data.resultlist:Array.isArray(t?.resultlist)?t.resultlist:Array.isArray(t?.data)?t.data:Array.isArray(t)?t:[],Ay=t=>{const n=Do(t),s=Number(t?.totalDaysMonth??0),r={present:0,absent:0,late:0,leave:0};return n.forEach((l,o)=>{[...new Array(s).keys()].forEach(d=>{const c=l?.[`${l?.student_id}_${o}`]?.[d]??{},g=String(c?.attendence_type_id??"");g==="1"&&(r.present+=1),g==="4"&&(r.absent+=1),g==="3"&&(r.late+=1),g==="2"&&(r.leave+=1)})}),r},Dy=t=>{const n=Do(t),s=Number(t?.totalDaysMonth??0);return n.map((r,l)=>{let o=0,d=0,c=0;return[...new Array(s).keys()].forEach(g=>{const y=r?.[`${r?.student_id}_${l}`]?.[g]??{},p=String(y?.attendence_type_id??"");p==="1"&&(o+=1),p==="4"&&(d+=1),p==="3"&&(c+=1)}),{roll_no:r?.roll_no??"",student_name:r?.student_name??r?.full_name??"",present:o,absent:d,late:c}})};function Ty({token:t}){const n=i.useRef(null),[s,r]=i.useState(""),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(String(new Date().getFullYear())),[x,R]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[k,O]=i.useState(0),[_,D]=i.useState(null),u=us(t),h=ps(s,t),S=i.useMemo(()=>cr(Number(b)),[b]),E=i.useMemo(()=>dr(10),[]),$=i.useMemo(()=>!s||!d||!b||!x||k===0?null:nn(zi.table,{session:Ni(),class_id:s,section_id:d,year:b,month:x,batch_id:p}),[p,s,x,k,d,b]),{data:q,isLoading:T,mutate:F}=K(t&&$?[$,t]:null,([M,L])=>Vt(M,L)),j=q?.data?.data??q?.data??q??{},P=i.useMemo(()=>Ay(j),[j]),I=i.useMemo(()=>Dy(j),[j]),N=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Name",dataIndex:"student_name"},{title:"Present",dataIndex:"present"},{title:"Absent",dataIndex:"absent"},{title:"Late",dataIndex:"late"}],[]),W=i.useMemo(()=>_?.student_id?nn(zi.byStudent,{student_id:_.student_id,month:x,year:b,session:Ni()}):null,[x,_,b]),{data:Y,isLoading:B}=K(t&&W?[W,t]:null,([M,L])=>Vt(M,L)),U=e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12,alignItems:"end"},children:[e.jsx(Z,{options:u.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{r(M?.value??""),o(M?.label??""),c(""),y(""),m(""),C("")},required:!0}),e.jsx(Z,{options:h.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{c(M?.value??""),y(M?.label??""),m(""),C("")},required:!0},`section-${s}`),e.jsx(Z,{options:E,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:E.find(M=>String(M?.value)===String(b))??null,onChange:M=>f(String(M?.value??"")),required:!0}),e.jsx(Z,{options:S,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:S.find(M=>String(M?.value)===String(x))??null,onChange:M=>R(String(M?.value??"").padStart(2,"0")),required:!0},`month-${b}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>O(M=>M+1)})})]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:12,alignItems:"center",justifyContent:"space-between"},children:[e.jsx(Ht,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Month",value:S.find(M=>String(M?.value)===String(x))?.label??x},{label:"Year",value:b}]}),e.jsx(my,{})]})]});return e.jsxs(e.Fragment,{children:[e.jsx(ms,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:n,exportRows:I,exportColumns:N,onRefresh:()=>F?.(),filterSection:U,summary:P,chartContent:e.jsx(Da,{summary:P,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx($t,{}),e.jsx(Ht,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Month",value:S.find(M=>String(M?.value)===String(x))?.label??x},{label:"Year",value:b}]})]}),e.jsx(gy,{data:j,loading:T,onViewStudent:D})]})}),e.jsx(xy,{open:!!_,onClose:()=>D(null),loading:B,data:Y,studentName:_?.student_name??_?.full_name})]})}const Ry=Lt.yearlyReport,Iy=t=>{const n=t?.data?.data??t?.data??t??{};return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:Array.isArray(n?.students)?n.students:Array.isArray(n?.report)?n.report:Array.isArray(n?.resultlist)?n.resultlist:[]},ky=t=>(Array.isArray(t)?t:[]).reduce((n,s)=>({present:n.present+Number(s?.singleStudentPresentData??s?.present??0),absent:n.absent+Number(s?.singleStudentAbsentData??s?.absent??0),late:n.late+Number(s?.late??0),leave:n.leave+Number(s?.leave??0)}),{present:0,absent:0,late:0,leave:0});function Py({token:t}){const n=i.useRef(null),[s,r]=i.useState(""),[l,o]=i.useState(""),[d,c]=i.useState(""),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(""),[x,R]=i.useState(""),[k,O]=i.useState(0),_=us(t),D=ps(s,t),u=cy(t),h=i.useMemo(()=>!s||!d||k===0?null:nn(Ry.table,{class_id:s,section_id:d,session_id:p,batch_id:b}),[b,s,k,d,p]),{data:S,isLoading:E,mutate:$}=K(t&&h?[h,t]:null,([I,N])=>Vt(I,N)),q=i.useMemo(()=>Iy(S),[S]),T=i.useMemo(()=>ky(q),[q]),F=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),j=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(I,N,W)=>W+1},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",dataIndex:"full_name",key:"full_name"},{title:"Total Present",dataIndex:"singleStudentPresentData",key:"singleStudentPresentData",width:130},{title:"Total Absent",dataIndex:"singleStudentAbsentData",key:"singleStudentAbsentData",width:130}],[]),P=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{options:_.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{r(I?.value??""),o(I?.label??""),c(""),y(""),f(""),R("")},required:!0}),e.jsx(Z,{options:D.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{c(I?.value??""),y(I?.label??""),f(""),R("")},required:!0},`section-${s}`),e.jsx(Z,{options:u.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{m(I?.value??""),C(I?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>O(I=>I+1)})})]}),e.jsx(Ht,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Session",value:A}]})]});return e.jsx(ms,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:n,exportRows:q,exportColumns:F,onRefresh:()=>$?.(),filterSection:P,summary:T,chartContent:e.jsx(Da,{summary:T,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx($t,{}),e.jsx(Ht,{items:[{label:"Class",value:l},{label:"Section",value:g},{label:"Session",value:A}]})]}),e.jsx(a.Table,{bordered:!0,size:"small",rowKey:(I,N)=>String(I?.student_id??I?.id??N),columns:j,dataSource:q,loading:E,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}const Oy=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},To=t=>{const n=qt(t);if(n)return n;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Yi=(t,n)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=To(n),l=s.startsWith("/")?s.slice(1):s;return Oy(at(),`uploads/school_${r}/branch/income/${l}`)},My=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n.map(s=>({value:s?.value??s?.id??"",label:s?.label??s?.name??s?.income_category??s?.title??""})):[]};function Ey({data:t}){const{handleUpdate:n,token:s}=t||{},r=i.useContext(Mt),{isLoading:l,data:o}=K(s&&r?[`${nu}?id=${r}`,s]:null,([u,h])=>G(u,h)),{data:d}=K(s?[Ql,s]:null,([u,h])=>G(u,h)),c=i.useMemo(()=>My(d),[d]),g=i.useMemo(()=>{if(Array.isArray(o))return o[0];const u=o?.data?.data??o?.data??o??{};return Array.isArray(u)?u[0]:u??{}},[o]),[y,p]=i.useState({income_head:"",name:"",invoice_no:"",date:se(),amount:"",description:"",doc:""}),[m,A]=i.useState(!1),[C,b]=i.useState(!1),[f,x]=i.useState(""),[R,k]=i.useState(""),O=async u=>{u.preventDefault(),A(!0);try{await n(u,r)}finally{A(!1)}};i.useEffect(()=>{g&&p({income_head:g?.inc_head_id||"",name:g?.name||"",invoice_no:g?.invoice_no||"",date:g?.date?se(g.date):se(),amount:g?.amount||"",description:g?.note||"",doc:g?.documents||""})},[g]);const _=(u,h)=>{p(S=>({...S,[u]:h}))},D=c.find(u=>String(u.value)===String(y.income_head))??null;return l?e.jsx(w,{pt:4,pb:1,style:{width:550,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(a.Spin,{tip:"Loading..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:O,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Edit Income"})}),e.jsx(w,{p:2,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(V,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Z,{label:"Income Head",options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0,value:D,onChange:u=>_("income_head",u?.value||"")})]})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0,value:y.name,onChange:u=>_("name",u.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:y.invoice_no,onChange:u=>_("invoice_no",u.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",value:y.date,Desplay:"Date",name:"date",required:!0,onChange:u=>_("date",u)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"amount",type:"number",label:"Amount",required:!0,value:y.amount,onChange:u=>_("amount",u.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(gt,{name:"description",label:"Description",rows:3,value:y.description,onChange:u=>_("description",u.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.Upload,{action:`${at()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${To(s)}/branch/income`},headers:{Authorization:s},maxCount:1,onChange:u=>{if(u.file.status==="removed"&&_("doc",""),u.file.status==="done"){const h=u.file.response?.data??u.file.response?.file??"";_("doc",String(h??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:y.doc?"Change":"Upload"})},y.doc||"empty"),y.doc&&e.jsx("a",{href:Yi(y.doc,s),target:"_blank",rel:"noreferrer",style:{display:"block",marginTop:8,fontSize:12,color:"#1677ff",textDecoration:"underline"},onClick:u=>{u.preventDefault(),x(Yi(y.doc,s)),k(y.doc||"Document"),b(!0)},children:"View existing document"}),e.jsx("input",{type:"hidden",name:"doc",value:y.doc||"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"center",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:m?"Saving...":"Submit",color:"primary",disabled:m})})})})})]})})]})}),e.jsx(a.Modal,{open:C,onCancel:()=>{b(!1),x(""),k("")},footer:null,width:900,closable:!0,children:e.jsxs(w,{p:3,children:[e.jsx(w,{mb:2,children:e.jsx(be,{level:5,children:R||"View Document"})}),f?f.match(/\.pdf(?:[?#]|$)/i)?e.jsx("iframe",{src:f,title:R||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:f,alt:R||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(be,{children:"No document found"})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Fy=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},$y=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Wi=t=>{const n=qt(t);if(n)return n;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}};function Uy({token:t}){const[n,s]=i.useState([]),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState({income_head:"",name:"",invoice_no:"",date:se().format("YYYY-MM-DD"),amount:"",description:"",doc:""}),[y,p]=i.useState(!1),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(T,F)=>{A({...m,page:T,rowsPerPage:parseInt(F,10)})},b=async(T,F)=>{try{await k(Ge(T,F,t),st(F)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},{isLoading:f,error:x,data:R,mutate:k}=K(t?[Gc,t,m.page,m.rowsPerPage]:null,([T,F,j,P])=>G(`${T}?page=${j}&per_page=${P}`,F)),O=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0},{id:"3",name:"Income Category",selector:"income_category",sortable:!0},{id:"4",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"5",name:"Date",selector:"date",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0},{id:"8",name:"File",selector:"documents",sortable:!1,render:T=>{const F=Wi(t),j=T?/^https?:\/\//i.test(T)?T:$y(at(),`uploads/school_${F}/branch/income/${T}`):null;return T?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>j&&window.open(j,"_blank"),children:"View"}):"Not Uploaded"}}],[t]),_=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],D=async T=>{try{await k(Ze(Xc,T,t),nt(T)),v.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{v.error("Failed to delete the item.",{duration:1e3})}},u=async(T,F,j)=>{try{await k(tt(T,F,t)),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await j(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},h=async(T,F)=>{T.preventDefault();const j=new FormData(T.target);await u(Qc,j,F),E(!1)},S=async T=>{if(T.preventDefault(),!T.target.date.value)v.error("Select required dates",{duration:1e3}),T.target?.date?.focus(),d("textDanger");else{const F=new FormData(T.target);await b(Jc,F),T.target.reset(),l(""),g(j=>({...j,date:se().format("YYYY-MM-DD")}))}},E=T=>{p(T)},{data:$}=K(t?[Ql,t]:null,([T,F])=>G(T,F)),q=i.useMemo(()=>Fy($),[$]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Add Income"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:S,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{label:"Income Head",options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",defaultValue:se(),Desplay:"Date",name:"date",status:o===""?"":"error",classnme:o,onChange:()=>d("")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.Upload,{action:`${at()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${Wi(t)}/branch/income`},headers:{Authorization:t},maxCount:1,onChange:T=>{if(T.file.status==="removed"&&l(""),T.file.status==="done"){const F=T.file.response?.data??T.file.response?.file??"";l(String(F??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:r?"Change":"Upload"})},r||"empty"),e.jsx("input",{type:"hidden",name:"doc",value:r||"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(gt,{name:"description",label:"Description",rows:3})})}),e.jsx(a.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(a.Row,{justifyContent:"flex-end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:C,data:{newData:R,columns:O,action:!0,Loading:f,ActionView:_,error:x,editDesign:e.jsx(Ey,{data:{handleUpdate:h,token:t}}),deleteTodoMutation:D,open:y,DrawerUpdate:E}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const Vi={width:"100%",height:40};function By({token:t}){const[n,s]=i.useState(null),[r,l]=i.useState(null),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(_,D)=>{A({...m,page:_,rowsPerPage:parseInt(D,10)})},{isLoading:b,error:f,data:x,mutate:R}=K(t&&o?[o,t,m.page,m.rowsPerPage]:null,([_,D,u,h])=>G(`${_}page=${u}&per_page=${h}`,D)),k=i.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Income Category",selector:"income_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),O=()=>{if(!n){v.error("Select required dates",{duration:1e3}),g("textDanger");return}if(!r){v.error("Select required dates",{duration:1e3}),p("textDanger");return}const _=n.format("YYYY-MM-DD"),D=r.format("YYYY-MM-DD");d(`${ru}?from_date=${_}&to_date=${D}&`),A(u=>({...u,page:1}))};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Search Income"})}),e.jsx(w,{p:3,children:e.jsxs(a.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(a.Col,{xs:24,md:8,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(a.DatePicker,{value:n,onChange:_=>{s(_),g("")},style:Vi,allowClear:!1})]})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(a.DatePicker,{value:r,onChange:_=>{l(_),p("")},style:Vi,allowClear:!1})]})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:O})})]})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:C,data:{newData:x,columns:k,action:!1,Loading:b,error:f,pageController:m}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function Ny({data:t}){const{handleUpdate:n,token:s}=t||{},r=i.useContext(Mt),{isLoading:l,data:o}=K(s&&r?[`${su}?id=${r}`,s]:null,([C,b])=>G(C,b)),d=i.useMemo(()=>{if(Array.isArray(o))return o[0];const C=o?.data?.data??o?.data??o??{};return Array.isArray(C)?C[0]:C??{}},[o]),[c,g]=i.useState({incomehead:"",description:""}),[y,p]=i.useState(!1);i.useEffect(()=>{d&&g({incomehead:d?.income_category||d?.incomehead||"",description:d?.description||""})},[d]);const m=(C,b)=>{g(f=>({...f,[C]:b}))},A=async C=>{C.preventDefault(),p(!0);try{await n(C)}finally{p(!1)}};return l?e.jsx(w,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(a.Spin,{tip:"Loading..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:A,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(w,{children:[e.jsx(V,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(V,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:c.incomehead,onChange:C=>m("incomehead",C.target.value)})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:C=>m("description",C.target.value)})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justifyContent:"flex-end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:y?"Saving...":"Submit",color:"primary",disabled:y})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function Ly({token:t}){const[n,s]=i.useState({incomehead:"",description:""}),[r,l]=i.useState(!1),[o,d]=i.useState(!1),[c,g]=i.useState({page:1,rowsPerPage:10}),y=(u,h)=>{g({...c,page:u,rowsPerPage:parseInt(h,10)})},p=async(u,h)=>{try{await b(Ge(u,h,t),st(h)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},{isLoading:m,error:A,data:C,mutate:b}=K(t?[Zc,t,c.page,c.rowsPerPage]:null,([u,h,S,E])=>G(`${u}?page=${S}&per_page=${E}`,h)),f=i.useMemo(()=>[{id:"1",name:"Name",selector:"income_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],R=async u=>{try{await b(Ze(au,u,t),nt(u)),v.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{v.error("Failed to delete the item.",{duration:1e3})}},k=async(u,h)=>{try{await b(tt(u,h,t)),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{v.error("Failed to update the item.",{duration:1e3})}},O=async u=>{u.preventDefault();const h=new FormData(u.target);await k(tu,h),D(!1)},_=async u=>{u.preventDefault(),d(!0);try{await p(eu,new FormData(u.target)),s({incomehead:"",description:""})}finally{d(!1)}},D=u=>{l(u)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:5,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Income Head"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:_,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:n.incomehead,onChange:u=>s(h=>({...h,incomehead:u.target.value}))})})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description",required:!0,value:n.description,onChange:u=>s(h=>({...h,description:u.target.value}))})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justifyContent:"flex-end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:o?"Saving...":"Save",color:"primary",disabled:o})})})})})]})})})]})}),e.jsx(a.Col,{xs:24,md:19,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Income Head List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:y,data:{newData:C,columns:f,action:!0,Loading:m,ActionView:x,error:A,editDesign:e.jsx(Ny,{data:{handleUpdate:O,token:t}}),deleteTodoMutation:R,open:r,DrawerUpdate:D}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const qy=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Ro=t=>{const n=qt(t);if(n)return n;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Hi=(t,n)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=Ro(n),l=s.startsWith("/")?s.slice(1):s;return qy(at(),`uploads/school_${r}/branch/expense/${l}`)},Ki=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n.map(s=>({value:s?.value??s?.id??"",label:s?.label??s?.name??s?.exp_category??s?.vendor_name??s?.title??""})):[]},Gi=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function zy({data:t}){const{handleUpdate:n,token:s}=t||{},r=i.useContext(Mt),{isLoading:l,data:o}=K(s&&r?[`${hu}?id=${r}`,s]:null,([$,q])=>G($,q)),{data:d}=K(s?[Xl,s]:null,([$,q])=>G($,q)),{data:c}=K(s?[Zl,s]:null,([$,q])=>G($,q)),g=i.useMemo(()=>Ki(d),[d]),y=i.useMemo(()=>Ki(c),[c]),p=i.useMemo(()=>{if(Array.isArray(o))return o[0];const $=o?.data?.data??o?.data??o??{};return Array.isArray($)?$[0]:$??{}},[o]),[m,A]=i.useState(!1),[C,b]=i.useState(!1),[f,x]=i.useState(""),[R,k]=i.useState(""),O=async $=>{$.preventDefault(),A(!0);try{await n($,r)}finally{A(!1)}},[_,D]=i.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:se(),amount:"",payment_mode:"",note:"",doc:""});i.useEffect(()=>{p&&D({expense_head:p?.exp_head_id||"",vendor:p?.fk_vendor_id||"",name:p?.name||"",invoice_no:p?.invoice_no||"",date:p?.date?se(p.date):se(),amount:p?.amount||"",payment_mode:p?.payment_mode||"",note:p?.note||"",doc:p?.documents||""})},[p]);const u=($,q)=>{D(T=>({...T,[$]:q}))},h=g.find($=>String($.value)===String(_.expense_head))??null,S=y.find($=>String($.value)===String(_.vendor))??null,E=Gi.find($=>String($.value)===String(_.payment_mode))??null;return l?e.jsx(w,{pt:4,pb:1,style:{width:550,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(a.Spin,{tip:"Loading..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:O,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Edit Expense"})}),e.jsx(w,{p:2,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(V,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Z,{label:"Expense Head",options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0,value:h,onChange:$=>u("expense_head",$?.value||"")})]})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{label:"Vendor",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor",value:S,onChange:$=>u("vendor",$?.value||"")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0,value:_.name,onChange:$=>u("name",$.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:_.invoice_no,onChange:$=>u("invoice_no",$.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",value:_.date,Desplay:"Date",name:"date",required:!0,onChange:$=>u("date",$)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"amount",type:"number",label:"Amount",required:!0,value:_.amount,onChange:$=>u("amount",$.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{label:"Payment Mode",options:Gi,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0,value:E,onChange:$=>u("payment_mode",$?.value||"")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(gt,{name:"note",label:"Description",rows:3,value:_.note,onChange:$=>u("note",$.target.value)})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.Upload,{action:`${at()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${Ro(s)}/branch/expense`},headers:{Authorization:s},maxCount:1,onChange:$=>{if($.file.status==="removed"&&u("doc",""),$.file.status==="done"){const q=$.file.response?.data??$.file.response?.file??"";u("doc",String(q??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:_.doc?"Change":"Upload"})}),_.doc&&e.jsx("a",{href:Hi(_.doc,s),target:"_blank",rel:"noreferrer",style:{display:"block",marginTop:8,fontSize:12,color:"#1677ff",textDecoration:"underline"},onClick:$=>{$.preventDefault(),x(Hi(_.doc,s)),k(_.doc||"Document"),b(!0)},children:"View existing document"}),e.jsx("input",{type:"hidden",name:"doc",value:_.doc||"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"center",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:m?"Saving...":"Submit",color:"primary",disabled:m})})})})})]})})]})}),e.jsx(a.Modal,{open:C,onCancel:()=>{b(!1),x(""),k("")},footer:null,width:900,closable:!0,children:e.jsxs(w,{p:3,children:[e.jsx(w,{mb:2,children:e.jsx(be,{level:5,children:R||"View Document"})}),f?f.match(/\.pdf(?:[?#]|$)/i)?e.jsx("iframe",{src:f,title:R||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:f,alt:R||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(be,{children:"No document found"})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Ji=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Yy=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Io=t=>{const n=qt(t);if(n)return n;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Wy=(t,n)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=Io(n),l=s.startsWith("/")?s.slice(1):s;return Yy(at(),`uploads/school_${r}/branch/expense/${l}`)},Vy=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function Hy({token:t}){const[n,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:se(),amount:"",payment_mode:"",note:"",doc:""}),[c,g]=i.useState(!1),[y,p]=i.useState(!1),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(j,P)=>{A({...m,page:j,rowsPerPage:parseInt(P,10)})},b=async(j,P)=>{try{await Ge(j,P,t),k(),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},{isLoading:f,error:x,data:R,mutate:k}=K(t?[iu,t,m.page,m.rowsPerPage]:null,([j,P,I,N])=>G(`${j}?page=${I}&per_page=${N}`,P)),O=i.useMemo(()=>[{title:"Sl No",dataIndex:"__serialNumber",key:"sl",sorter:(j,P)=>(j.__serialNumber??0)-(P.__serialNumber??0)},{title:"Name",dataIndex:"name",key:"name",sorter:(j,P)=>String(j.name??"").localeCompare(String(P.name??""))},{title:"Description",dataIndex:"description",key:"description"},{title:"Expense Category",dataIndex:"exp_category",key:"exp_category"},{title:"Invoice No",dataIndex:"invoice_no",key:"invoice_no"},{title:"Note",dataIndex:"note",key:"note"},{title:"Amount",dataIndex:"amount",key:"amount"},{title:"File",dataIndex:"documents",key:"documents",render:(j,P)=>j?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>window.open(Wy(j,t),"_blank"),children:"View"}):"Not Uploaded"}],[t]),_=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],D=async j=>{try{await Ze(du,j,t),k(),v.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{v.error("Failed to delete the item.",{duration:1e3})}},u=async(j,P,I)=>{try{await k(tt(j,P,t)),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await I(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},h=async(j,P)=>{j.preventDefault();const I=new FormData(j.target);await u(ou,I,P),E(!1)},S=async j=>{if(j.preventDefault(),!j.target.date.value)v.error("Select required dates",{duration:1e3}),j.target?.date?.focus(),l("textDanger");else{const P=new FormData(j.target);p(!0);try{await b(lu,P)}finally{p(!1)}j.target.reset(),d(I=>({...I,date:se()})),s("")}},E=j=>{g(j)},{data:$}=K(t?[Xl,t]:null,([j,P])=>G(j,P)),{data:q}=K(t?[Zl,t]:null,([j,P])=>G(j,P)),T=i.useMemo(()=>Ji($),[$]),F=i.useMemo(()=>Ji(q),[q]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Add Expense"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:S,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{label:"Expense Head",options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{label:"Vendor",options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor"})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD",defaultValue:se(),Desplay:"Date",name:"date",status:r===""?"":"error",classnme:r,onChange:()=>l("")})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(V,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Z,{label:"Payment Mode",options:Vy,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(gt,{name:"note",label:"Description",rows:3})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(a.Upload,{action:`${at()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${Io(t)}/branch/expense`},headers:{Authorization:t},maxCount:1,onChange:j=>{if(j.file.status==="removed"&&s(""),j.file.status==="done"){const P=j.file.response?.data??j.file.response?.file??"";s(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:n||"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(a.Row,{justifyContent:"flex-end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:y?"Saving...":"Save",color:"primary",disabled:y})})})})})]})})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:C,data:{newData:R,columns:O,columnstype:"antd",action:!0,Loading:f,ActionView:_,error:x,editDesign:e.jsx(zy,{data:{handleUpdate:h,token:t}}),deleteTodoMutation:D,open:c,DrawerUpdate:E}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const Ky=[{label:"Paid to",key:"vendor_name"},{label:"Address",key:"address"},{label:"GST Number",key:"gst"},{label:"Bussiness Name",key:"business_name"}],Gy=[{label:"Date",key:"date"},{label:"Voucher Number",key:"voucher_number"},{label:"Payment Mode",key:"payment_mode"}];function Jy({onClick:t}){return e.jsx(a.Button,{type:"primary",icon:e.jsx(ee.PrinterOutlined,{}),onClick:t,children:"Print"})}function Qy({data:t}){const n=i.useMemo(()=>{if(!t)return null;if(Array.isArray(t))return t[0];const s=t?.data?.data??t?.data??t??{};return Array.isArray(s)?s[0]:s},[t]);return e.jsx("div",{style:{width:"100%"},children:e.jsxs("div",{style:{border:"1px solid ",margin:"5px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",flexDirection:"column",justifyContent:"center",borderBottom:"1px solid black",fontWeight:"bold",padding:"10px",backgroundColor:"#dfdfdf",fontSize:"18px"},children:"Expense Voucher"}),e.jsx("div",{style:{width:"100%",display:"flex",justifyContent:"center",borderBottom:"1px solid black"},children:e.jsx("div",{style:{width:"90%"},children:e.jsx($t,{})})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(a.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(a.Col,{xs:12,style:{borderRight:"1px solid black",display:"flex",alignItems:"flex-start",flexDirection:"column"},children:Ky.map((s,r)=>e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("span",{style:{fontWeight:"bold"},children:s.label}),":"," ",n?.[s.key]]},`vendor${r}`))}),e.jsx(a.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:Gy.map((s,r)=>e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("span",{style:{fontWeight:"bold"},children:s.label}),":"," ",n?.[s.key]]},`payment${r}`))})]})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(a.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(a.Col,{xs:12,style:{borderRight:"1px solid black",display:"flex",alignItems:"flex-start",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:"Description"}),":"," ",n?.note]})}),e.jsx(a.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsx("div",{children:e.jsx("span",{style:{fontWeight:"bold"},children:"Amount"})})})]})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(a.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(a.Col,{xs:12,style:{borderRight:"1px solid black",display:"flex",alignItems:"flex-start",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:n?.name})," "]})}),e.jsx(a.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsx("div",{children:n?.amount})})]})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(a.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(a.Col,{xs:12,style:{paddingRight:4,borderRight:"1px solid black",display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:"Total"})," "]})}),e.jsx(a.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:n?.amount})," "]})})]})}),e.jsx("div",{style:{width:"100%",height:"75px",display:"flex",alignItems:"flex-end"},children:e.jsxs(a.Row,{style:{paddingLeft:4,paddingRight:4},justify:"flex-end",align:"flex-end",children:[e.jsx(a.Col,{xs:4,style:{borderTop:"1px solid gray",display:"flex",justifyContent:"center"},children:"Approved by"}),e.jsx(a.Col,{xs:1}),e.jsx(a.Col,{xs:4,style:{borderTop:"1px solid gray",display:"flex",justifyContent:"flex-end"},children:"Signature"})]})})]})})}function Xy({token:t}){const n=i.useMemo(()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("id")??null,[]),s=i.useRef(null),r=ia.useReactToPrint({content:()=>s.current}),{isLoading:l,data:o,error:d}=K(t&&n?[fu,n,t]:null,([c,g,y])=>G(`${c}?id=${g}`,y));return e.jsx(w,{pt:4,pb:1,children:e.jsx(a.Row,{gutter:[16,16],children:e.jsx(a.Col,{xs:24,children:e.jsx("div",{style:{width:"75%"},className:"container",children:e.jsx("div",{className:"row",children:e.jsx("div",{className:"col-lg-12",children:e.jsxs("div",{className:"card",ref:s,children:[e.jsx("div",{style:{width:"100%",display:"flex"},children:l?e.jsx("div",{style:{padding:40,textAlign:"center"},children:e.jsx(a.Spin,{tip:"Loading..."})}):d?e.jsx("div",{style:{padding:40,textAlign:"center"},children:"Error loading data"}):o?.Status==="Success"?e.jsx(Qy,{data:o}):e.jsx("div",{style:{padding:40,textAlign:"center"},children:"No Data Found"})}),e.jsxs("div",{className:"d-print-none mt-4",children:[e.jsx("div",{className:"float-end",children:e.jsx(Jy,{onClick:r})}),e.jsx("div",{className:"float-end",style:{marginRight:"2%"},children:e.jsx(a.Button,{type:"text",onClick:()=>window.history.back(),children:"Back"})})]})]})})})})})})})}const Qi={width:"100%",height:40};function Zy({token:t}){const[n,s]=i.useState(null),[r,l]=i.useState(null),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(_,D)=>{A({...m,page:_,rowsPerPage:parseInt(D,10)})},{isLoading:b,error:f,data:x,mutate:R}=K(t&&o?[o,t,m.page,m.rowsPerPage]:null,([_,D,u,h])=>G(`${_}page=${u}&per_page=${h}`,D)),k=i.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Expense Category",selector:"exp_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),O=()=>{if(!n){v.error("Select required dates",{duration:1e3}),g("textDanger");return}if(!r){v.error("Select required dates",{duration:1e3}),p("textDanger");return}const _=n.format("YYYY-MM-DD"),D=r.format("YYYY-MM-DD");d(`${gu}?from_date=${_}&to_date=${D}&`),A(u=>({...u,page:1}))};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Search Expense"})}),e.jsx(w,{p:3,children:e.jsxs(a.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(a.Col,{xs:24,md:8,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(a.DatePicker,{value:n,onChange:_=>{s(_),g("")},style:Qi,allowClear:!1})]})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(a.DatePicker,{value:r,onChange:_=>{l(_),p("")},style:Qi,allowClear:!1})]})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:O})})]})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:C,data:{newData:x,columns:k,action:!1,Loading:b,error:f,pageController:m}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function eg({data:t}){const{handleUpdate:n,token:s}=t||{},r=i.useContext(Mt),{isLoading:l,data:o}=K(s&&r?[`${yu}?id=${r}`,s]:null,([C,b])=>G(C,b)),d=i.useMemo(()=>{if(Array.isArray(o))return o[0];const C=o?.data?.data??o?.data??o??{};return Array.isArray(C)?C[0]:C??{}},[o]),[c,g]=i.useState({expensehead:"",description:""}),[y,p]=i.useState(!1);i.useEffect(()=>{d&&g({expensehead:d?.exp_category||d?.expensehead||"",description:d?.description||""})},[d]);const m=(C,b)=>{g(f=>({...f,[C]:b}))},A=async C=>{C.preventDefault(),p(!0);try{await n(C)}finally{p(!1)}};return l?e.jsx(w,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(a.Spin,{tip:"Loading..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:A,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(w,{children:[e.jsx(V,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(V,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:c.expensehead,onChange:C=>m("expensehead",C.target.value)})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:C=>m("description",C.target.value)})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justifyContent:"flex-end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:y?"Saving...":"Submit",color:"primary",disabled:y})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function tg({token:t}){const[n,s]=i.useState({expensehead:"",description:""}),[r,l]=i.useState(!1),[o,d]=i.useState(!1),[c,g]=i.useState({page:1,rowsPerPage:10}),y=(u,h)=>{g({...c,page:u,rowsPerPage:parseInt(h,10)})},p=async(u,h)=>{try{await b(Ge(u,h,t),st(h)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},{isLoading:m,error:A,data:C,mutate:b}=K(t?[cu,t,c.page,c.rowsPerPage]:null,([u,h,S,E])=>G(`${u}?page=${S}&per_page=${E}`,h)),f=i.useMemo(()=>[{id:"1",name:"Name",selector:"exp_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],R=async u=>{try{await b(Ze(mu,u,t),nt(u)),v.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{v.error("Failed to delete the item.",{duration:1e3})}},k=async(u,h)=>{try{await b(tt(u,h,t)),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{v.error("Failed to update the item.",{duration:1e3})}},O=async u=>{u.preventDefault();const h=new FormData(u.target);await k(pu,h),D(!1)},_=async u=>{u.preventDefault(),d(!0);try{await p(uu,new FormData(u.target)),s({expensehead:"",description:""})}finally{d(!1)}},D=u=>{l(u)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:5,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:_,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:n.expensehead,onChange:u=>s(h=>({...h,expensehead:u.target.value}))})})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(V,{name:"description",type:"text",label:"Description",required:!0,value:n.description,onChange:u=>s(h=>({...h,description:u.target.value}))})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justifyContent:"flex-end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:o?"Saving...":"Save",color:"primary",disabled:o})})})})})]})})})]})}),e.jsx(a.Col,{xs:24,md:19,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:y,data:{newData:C,columns:f,action:!0,Loading:m,ActionView:x,error:A,editDesign:e.jsx(eg,{data:{handleUpdate:O,token:t}}),deleteTodoMutation:R,open:r,DrawerUpdate:D}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function ag({token:t}){const[n,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState(0),[y,p]=i.useState(""),[m,A]=i.useState({page:1,rowsPerPage:10}),C=(E,$)=>{A({...m,page:E,rowsPerPage:parseInt($,10)})},{isLoading:b,error:f,data:x,mutate:R}=K(t&&y?[y,t,m.page,m.rowsPerPage]:null,([E,$,q,T])=>G(`${E}page=${q}&per_page=${T}`,$)),{data:k}=K(t?[un,t]:null,([E,$])=>G(E,$)),{data:O}=K(t&&n?[`${pn}?class_id=${n}`,t]:null,([E,$])=>G(E,$)),_=i.useMemo(()=>k?Array.isArray(k)?k:Array.isArray(k?.data)?k.data:[]:[],[k]),D=i.useMemo(()=>O?Array.isArray(O)?O:Array.isArray(O?.data)?O.data:[]:[],[O]),u=i.useMemo(()=>[{id:"1",name:"First Name",selector:"firstname",sortable:!0},{id:"2",name:"Last Name",selector:"lastname",sortable:!0},{id:"3",name:"Class",selector:"class",sortable:!0},{id:"4",name:"Section",selector:"section",sortable:!0},{id:"5",name:"ID",selector:"username",sortable:!0},{id:"6",name:"Password",selector:"password",sortable:!0}],[]),h=E=>{s(E?.value||""),l(""),g($=>$+1)},S=E=>{if(E.preventDefault(),!n){v.error("Please select class",{duration:1e3});return}if(!r){v.error("Please select section",{duration:1e3});return}const $=`${xu}?class_id=${n}§ion_id=${r}&keyword=${o||""}&`;p($),A(q=>({...q,page:1}))};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Student Login Credential"})}),e.jsx(w,{p:3,children:e.jsxs(a.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{label:"Class",options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:_.find(E=>String(E.value)===String(n))??null,onChange:h})})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{label:"Section",options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:D.find(E=>String(E.value)===String(r))??null,onChange:E=>l(E?.value||"")})})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(V,{name:"keyword",type:"text",label:"Search By Keyword",value:o,onChange:E=>d(E.target.value)})})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:S})})]})})]})}),y&&e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:C,data:{newData:x,columns:u,action:!1,Loading:b,error:f,pageController:m}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function ng({token:t}){const[n,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState(0),[y,p]=i.useState(eo),[m,A]=i.useState(!1),[C,b]=i.useState(null);console.log("Selected Student ID:",m);const[f,x]=i.useState({page:1,rowsPerPage:10}),R=(P,I)=>{x({...f,page:P,rowsPerPage:parseInt(I,10)})},{isLoading:k,error:O,data:_,mutate:D}=K(t&&y?[y,t,f.page,f.rowsPerPage]:null,([P,I,N,W])=>G(`${P}page=${N}&per_page=${W}`,I)),{data:u}=K(t?[un,t]:null,([P,I])=>G(P,I)),{data:h}=K(t&&n?[`${pn}?class_id=${n}`,t]:null,([P,I])=>G(P,I)),S=i.useMemo(()=>u?Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]:[],[u]),E=i.useMemo(()=>h?Array.isArray(h)?h:Array.isArray(h?.data)?h.data:[]:[],[h]),$=i.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Medicine",selector:"Medical",sortable:!1,render:(P,I)=>e.jsx(a.Button,{type:"primary",size:"small",onClick:()=>{b(I.id),A(!0)},children:"Medical"})}],[]),q=P=>{s(P?.value||""),l(""),g(I=>I+1)},T=P=>{if(P.preventDefault(),!n||!r){v.error("Please select class and section",{duration:1e3});return}const I=`${ao}?cID=${n}&sID=${r}&page=${f.page}&per_page=${f.rowsPerPage}&`;p(I),x(N=>({...N,page:1}))},F=P=>{P.preventDefault();const I=P.target.searchField?.value||"";d(I);const N=`${to}?key=${I}&page=${f.page}&per_page=${f.rowsPerPage}&`;p(N),x(W=>({...W,page:1}))},j=async P=>{P.preventDefault();const I=new FormData(P.target),N=bu;try{await D(addData(N,I,t)),v.success("Medicine added successfully",{duration:1e3}),P.target.reset()}catch{v.error("Failed to add medicine",{duration:1e3})}};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Medical Report"})}),e.jsx(w,{p:3,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:T,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(Z,{label:"Class",options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:S.find(P=>String(P.value)===String(n))??null,onChange:q})})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(Z,{label:"Section",options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:E.find(P=>String(P.value)===String(r))??null,onChange:P=>l(P?.value||"")})})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:F,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:16,children:e.jsx(V,{name:"searchField",type:"text",label:"Search By Keyword",value:o,onChange:P=>d(P.target.value)})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(ie,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:R,data:{newData:_,columns:$,action:!1,Loading:k,error:O,pageController:f}})})]})})]}),e.jsx(a.Drawer,{title:"Medical Report",placement:"right",width:600,open:m,footer:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsx(ie,{type:"button",value:"Close",color:"default"})})}),children:e.jsx(sg,{studentId:C,token:t,onAddMedicine:j})}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function sg({studentId:t,token:n,onAddMedicine:s}){const{data:r}=K(n&&t?[`${no}?id=${t}`,n]:null,([g,y])=>G(g,y)),{data:l}=K(n&&t?[`${ju}?student_id=${t}`,n]:null,([g,y])=>G(g,y)),o=r?.studentBasicDetails?.[0];let d=[];Array.isArray(l?.data)?d=l.data:Array.isArray(l)&&(d=l);const c=[{title:"Medicine",dataIndex:"medicine",key:"medicine"},{title:"Notes",dataIndex:"notes",key:"notes"},{title:"Date",dataIndex:"date_time",key:"date_time"}];return e.jsxs(w,{children:[o&&e.jsxs(w,{mb:3,children:[e.jsxs(be,{level:4,children:["Name: ",o?.firstname," ",o?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",o?.class," (",o?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",o?.admission_no]})]}),e.jsx(be,{level:5,style:{marginBottom:8},children:"Add Medicine"}),e.jsx("form",{onSubmit:s,style:{marginBottom:24},children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(w,{children:[e.jsx(V,{name:"medicine",type:"text",label:"Medicine Name",required:!0}),e.jsx("input",{name:"student_id",type:"hidden",value:t||"",readOnly:!0})]})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(gt,{name:"notes",label:"Note",rows:3})})}),e.jsx(a.Col,{xs:24,children:e.jsx(w,{children:e.jsx(He,{format:"YYYY-MM-DD HH:mm",Desplay:"Date",name:"date_time",defaultValue:se()})})}),e.jsx(a.Col,{xs:24,children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Add",color:"primary"})})})})})]})}),e.jsx(be,{level:5,style:{marginBottom:8},children:"Previous Medicine"}),e.jsx(a.Table,{size:"small",dataSource:d,pagination:!1,columns:c})]})}const{Group:Xi}=a.Checkbox;function rg({token:t}){const[n,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState(0),[y,p]=i.useState(eo),[m,A]=i.useState(!1),[C,b]=i.useState(null),[f,x]=i.useState({page:1,rowsPerPage:10}),R=(N,W)=>{x({...f,page:N,rowsPerPage:parseInt(W,10)})},{isLoading:k,error:O,data:_,mutate:D}=K(t&&y?[y,t,f.page,f.rowsPerPage]:null,([N,W,Y,B])=>G(`${N}page=${Y}&per_page=${B}`,W)),{data:u}=K(t?[un,t]:null,([N,W])=>G(N,W)),{data:h}=K(t&&n?[`${pn}?class_id=${n}`,t]:null,([N,W])=>G(N,W)),S=i.useMemo(()=>u?Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]:[],[u]),E=i.useMemo(()=>h?Array.isArray(h)?h:Array.isArray(h?.data)?h.data:[]:[],[h]),$=i.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Assign Subject",selector:"Assign",sortable:!1,render:(N,W)=>e.jsx(a.Button,{type:"primary",size:"small",onClick:()=>{b(W.id),A(!0)},children:"Assign"})}],[]),q=N=>{s(N?.value||""),l(""),g(W=>W+1)},T=N=>{if(N.preventDefault(),!n||!r){v.error("Please select class and section",{duration:1e3});return}const W=`${ao}?cID=${n}&sID=${r}&page=${f.page}&per_page=${f.rowsPerPage}&`;p(W),x(Y=>({...Y,page:1}))},F=N=>{N.preventDefault();const W=N.target.searchField?.value||"";d(W);const Y=`${to}?key=${W}&page=${f.page}&per_page=${f.rowsPerPage}&`;p(Y),x(B=>({...B,page:1}))},j=async N=>{N.preventDefault();const W=new FormData(N.target),Y=vu;try{await D(tt(Y,W,t)),v.success("Subject updated successfully",{duration:1e3}),N.target.reset(),A(!1)}catch{v.error("Failed to update subject",{duration:1e3})}},P=async N=>{N.preventDefault();const W=new FormData(N.target),Y=er;try{await D(tt(Y,W,t)),v.success("Extra curricular updated successfully",{duration:1e3}),N.target.reset(),A(!1)}catch{v.error("Failed to update extra curricular",{duration:1e3})}},I=N=>{A(N)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Assign Student Subject"})}),e.jsx(w,{p:3,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:T,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(Z,{label:"Class",options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:S.find(N=>String(N.value)===String(n))??null,onChange:q})})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(Z,{label:"Section",options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:E.find(N=>String(N.value)===String(r))??null,onChange:N=>l(N?.value||"")})})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(a.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:F,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:16,children:e.jsx(V,{name:"searchField",type:"text",label:"Search By Keyword",value:o,onChange:N=>d(N.target.value)})}),e.jsx(a.Col,{xs:24,md:8,children:e.jsx(ie,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(w,{pt:3,children:e.jsx(ze,{parentCallback:R,data:{newData:_,columns:$,action:!1,Loading:k,error:O,pageController:f}})})]})})]}),m&&e.jsx(ig,{open:m,DrawerUpdate:I,studentId:C,token:t,onUpdate:j,onUpdate2:P}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function ig({open:t,DrawerUpdate:n,studentId:s,token:r,onUpdate:l,onUpdate2:o}){const[d,c]=i.useState([]),[g,y]=i.useState([]),[p,m]=i.useState([]),[A,C]=i.useState(!1),[b,f]=i.useState([]),[x,R]=i.useState([]),[k,O]=i.useState([]),{trigger:_}=pt(no,async($,{arg:q})=>await G(`${$}?id=${q.id}`,r)),{trigger:D}=pt(er,async()=>await G(`${er}?student_id=${s}`,r)),{trigger:u}=pt(Su,async($,{arg:q})=>await G(`${$}?id=${q.id}`,r));i.useEffect(()=>{(async()=>{if(!s)return;C(!0);const q=await _({id:s});q?.studentBasicDetails?.[0];const T=await D(),F=await u({id:s});c(q),m(F),q&&y(T),C(!1)})()},[s,_,D,u]);const h=$=>{R($);const q=d?.data?.filter(T=>!$.includes(T.value));f(JSON.stringify(q))},S=$=>{O($)},E=d?.studentBasicDetails?.[0];return!A&&s?e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsxs(w,{p:3,children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Edit Assigned Subjects"})}),e.jsxs(w,{p:3,children:[E&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs(be,{level:4,children:["Name: ",E?.firstname," ",E?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",E?.class," (",E?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",E?.admission_no]})]}),e.jsx("form",{onSubmit:l,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsxs(a.Col,{xs:24,children:[e.jsx(be,{level:5,children:"Subjects"}),e.jsx(Xi,{options:d?.data?.map($=>({label:$.label||$.name,value:$.value})),value:x,onChange:h,style:{display:"grid",gap:8}})]}),e.jsxs(a.Col,{xs:24,children:[e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0}),e.jsx("input",{name:"subjectUncheck[]",type:"hidden",value:b,readOnly:!0})]}),d?.data?.length===0?e.jsx(a.Col,{xs:24,children:e.jsx("span",{style:{cursor:"pointer",fontSize:15,color:"blue",textDecoration:"underline"},children:"Please Assign Subject"})}):e.jsx(a.Col,{xs:24,className:"buttonCoustom",children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Update",color:"primary"})})})})})]})}),g?.data?.length>0&&e.jsx("form",{onSubmit:o,style:{marginTop:24},children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsxs(a.Col,{xs:24,children:[e.jsx(be,{level:5,children:"Extra Curricular Activities"}),e.jsx(Xi,{options:g?.data?.map($=>({label:$.label||$.name,value:$.value})),value:k,onChange:S,style:{display:"grid",gap:8}})]}),e.jsx(a.Col,{xs:24,children:e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0})}),e.jsx(a.Col,{xs:24,className:"buttonCoustom",children:e.jsx(a.Row,{justify:"end",children:e.jsx(a.Col,{children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:"Update",color:"primary"})})})})})]})})]})]})}):e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsx(w,{p:3,children:e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(a.Spin,{size:"large"})})})})}function lg({token:t}){const[n,s]=i.useState(""),[r,l]=i.useState(""),[o,d]=i.useState(0),[c,g]=i.useState(null),[y,p]=i.useState(!1),{data:m}=K(t?[un,t]:null,([u,h])=>G(u,h)),{data:A}=K(t&&n?[`${pn}?class_id=${n}`,t]:null,([u,h])=>G(u,h)),{data:C}=K(t?[_u,t]:null,([u,h])=>G(`${u}?page=1&per_page=10`,h)),b=i.useMemo(()=>m?Array.isArray(m)?m:Array.isArray(m?.data)?m.data:[]:[],[m]),f=i.useMemo(()=>A?Array.isArray(A)?A:Array.isArray(A?.data)?A.data:[]:[],[A]),x=i.useMemo(()=>[{id:"1",name:"Category Id",selector:"id",sortable:!0},{id:"2",name:"Category",selector:"category",sortable:!0}],[]),R=u=>{s(u?.value||""),l(""),d(h=>h+1)},k=u=>{l(u?.value||"")},O=()=>{const u=document.createElement("a");u.href="/sample_student.xlsx",u.download="sample_student.xlsx",u.click()},_=u=>{u.fileList.length>0?g(u.fileList[0].originFileObj):g(null)},D=async u=>{if(u.preventDefault(),!n){v.error("Please select class",{duration:1e3});return}if(!r){v.error("Please select section",{duration:1e3});return}if(!c){v.error("Please select file",{duration:1e3});return}p(!0);const h=new FormData;h.append("file",c),h.append("class_id",n),h.append("section_id",r);try{const S=await Ca(wu,h,t);S?.Status==="Failed"?v.error(S?.msg||"Upload failed",{duration:2e3}):(v.success(S?.msg||"Upload successful",{duration:2e3}),g(null),s(""),l(""))}catch(S){v.error(S?.response?.data?.msg||"Upload failed",{duration:2e3})}finally{p(!1)}};return e.jsx(w,{pt:5,pb:1,children:e.jsx(a.Row,{gutter:[16,16],children:e.jsx(a.Col,{xs:24,children:e.jsxs(a.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(be,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Students"})}),e.jsxs(w,{p:3,children:[e.jsx(a.Row,{justify:"end",style:{marginBottom:16},children:e.jsx(a.Col,{children:e.jsx(a.Button,{type:"primary",icon:e.jsx(ee.DownloadOutlined,{}),onClick:O,style:{background:"#368fed"},children:"Download Sample Import File"})})}),e.jsxs("div",{style:{marginBottom:16,padding:16,background:"#f5f5f5",borderRadius:8},children:[e.jsx(be,{level:5,style:{marginBottom:8},children:"Information"}),e.jsx("div",{children:"1. Your Excel data should be in the format below. The first line of your Excel file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("div",{children:"2. If the column you are trying to import is date make sure that is formatted in format Y-m-d (2024-01-10)."}),e.jsx("div",{children:"3. Duplicate Admission Number, ec_no, aadhaar_number, (unique) rows will not be imported."}),e.jsx("div",{children:"4. For student Gender use Male, Female value."}),e.jsx("div",{children:"5. For student Blood Group use A+, A-, B+, B-, O+, O-, AB+, AB- value."}),e.jsx("div",{children:"6. * Imported field are admission_no, ec_no, firstname, lastname, roll_no, guardian_phone, aadhaar_number, category_id"})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx(be,{level:5,style:{marginBottom:8},children:"Category Table"}),e.jsx(ze,{parentCallback:()=>{},data:{newData:C,columns:x,action:!1,Loading:!1,error:null,pageController:{page:1,rowsPerPage:10}}})]}),e.jsx("form",{onSubmit:D,children:e.jsxs(a.Row,{gutter:[16,16],children:[e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{label:"Class",options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:b.find(u=>String(u.value)===String(n))??null,onChange:R})})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Z,{label:"Section",options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:f.find(u=>String(u.value)===String(r))??null,onChange:k},`section-${o}`)})}),e.jsx(a.Col,{xs:24,md:6,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"File"}),e.jsx(a.Upload,{beforeUpload:()=>!1,onChange:_,maxCount:1,accept:".xlsx,.xls",children:e.jsx(a.Button,{icon:e.jsx(ee.UploadOutlined,{}),style:{width:"100%"},children:c?c.name:"Select Excel File"})})]})}),e.jsx(a.Col,{xs:24,md:6,style:{display:"flex",alignItems:"flex-end"},children:e.jsx(w,{children:e.jsx(ie,{type:"submit",value:y?"Processing...":"Save",color:"primary",loading:y})})})]})})]})]})})})})}function og(){return null}const hs=t=>t??localStorage.getItem("authToken")??"",ko=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Po=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",Ue={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/assignClassSubjects",list:"api/branchapi/academy/getSubjectsbyClass",update:"api/branchapi/academy/updateAssignSubject",editByClass:"api/branchapi/academy/editSubjectsbyClass"},assignByClass:{teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classWithSection:"api/branchapi/academy/getClasswithSection",assignedSubjectsOfTeacher:"api/branchapi/academy/getassignedSubjectsofTeacher",subjectsOfTeacherByTeacherId:"api/branchapi/academy/getSubjectsofTeacherbyTeacherID",assignClassToTeacher:"api/branchapi/academy/assignClasstoTeacher",deleteTeacherSub:"api/branchapi/academy/deleteTeacherSub"},promoteStudents:{searchByClassSection:"api/branchapi/student/currentSessionStudentlist",sessionDropdown:"api/branchapi/generalSettings/sessiondropdown",promote:"api/branchapi/student/promotestudent"},timeGroup:{table:"api/branchapi/academy/getTimeGroupTable",add:"api/branchapi/academy/addTimeGroup",edit:"api/branchapi/academy/editTimeGroup",remove:"api/branchapi/academy/deleteTimeGroup",show:"api/branchapi/academy/getTimeGroupDataById",dropdown:"api/branchapi/academy/getTimeGroupDropDown"},assignTimeGroup:{classIdByTimeGroup:"api/branchapi/academy/getClassIdByTimeGroup",table:"api/branchapi/academy/getAssignedTimeGroupTable",show:"api/branchapi/academy/getAssignedTimeGroupDataById",assign:"api/branchapi/academy/assignTimeGroup"},timetable:{save:"api/timetable/save",byClassSection:"api/timetable/class",teacherTimetable:"api/timetable/teacher/",teachersBySubject:"api/branchapi/Academy/gettechersSubject"},notes:{table:"api/branchapi/Academy/getNotesTable",add:"api/branchapi/Academy/addNotes"},syllabus:{table:"api/branchapi/Academy/getsyllabusTable",add:"api/branchapi/Academy/addsyllabus",edit:"api/branchapi/Academy/editsyllabus",uploadFile:"api/SuperAdmin/uploadFile"},transferCertificate:{studentList:"api/branchapi/student/getstudenttransferCertificateList",addData:"api/branchapi/academy/addtransferCertificatedata",view:"api/branchapi/academy/gettransferCertificateUrl"},coscholastic:{table:"api/branchapi/academy/getcoscholastic",addSkill:"api/branchapi/academy/add_coscholastic_skill",deleteSkill:"api/branchapi/academy/deleteCoscholastic",categoryDropdown:"api/branchapi/academy/coscholastic_categorydropdown",addCategory:"api/branchapi/academy/addcoscholastic_category",deleteCategory:"api/branchapi/academy/coscholasticCategoryDelete"}},dg=()=>ko(At(),Ue.uploadNotes),cg=()=>ko(At(),Ue.syllabus.uploadFile),ug=async({baseUrl:t,page:n=1,perPage:s=10},r)=>{const l=t.includes("?")?"&":"?",o=`${t}${l}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(s))}`;return G(o,hs(r))},Pt=async(t,n,s,{includeSession:r=!1}={})=>{const l=n instanceof FormData?n:new FormData;return r&&!l.has("session_id")&&l.append("session_id",Po()),Ge(t,l,hs(s))},Kt=async(t,n,s,{includeSession:r=!1}={})=>{const l=n instanceof FormData?n:new FormData;return r&&!l.has("session_id")&&l.append("session_id",Po()),tt(t,l,hs(s))},Gt=async(t,n,s)=>Ze(t,n,hs(s)),Jn=Ue.master.sections,gn=({baseUrl:t,page:n=1,perPage:s=10,token:r})=>K(r&&t?[t,n,s,r]:null,([o,d,c,g])=>ug({baseUrl:o,page:d,perPage:c},g)),pg=({token:t,page:n=1,perPage:s=10})=>gn({token:t,baseUrl:Jn.table,page:n,perPage:s}),mg=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function hg({token:t}){const[n,s]=i.useState({page:1,perPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=a.Form.useForm(),{data:g,isLoading:y,mutate:p}=pg({token:t,page:n.page,perPage:n.perPage}),m=i.useMemo(()=>mg(g),[g]),A=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??m.length??0,[g,m]),C=async k=>{k.preventDefault();const O=new FormData(k.target);try{await Pt(Jn.add,O,t),v.success("Success! Added new item.",{duration:1e3}),k.target.reset(),p()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to add the new item.",{duration:1500})}},b=async k=>{try{await Gt(Jn.remove,k,t),v.success("Success! Deleted item.",{duration:1e3}),p()}catch(O){v.error(O?.response?.data?.msg??O?.message??"Failed to delete the item.",{duration:1500})}},f=k=>{d(k),l(!0),c.setFieldsValue({section:k?.section??""})},x=async k=>{const O=new FormData;O.append("id",String(o?.id??"")),O.append("section",k.section??"");try{await Kt(Jn.edit,O,t),v.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),p()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to update the item.",{duration:1500})}},R=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(k,O)=>e.jsxs(a.Space,{children:[e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>f(O)}),e.jsx(a.Popconfirm,{title:"Delete this section?",onConfirm:()=>b(O?.id),children:e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{title:"Edit Section",open:r,onClose:()=>{l(!1),d(null)},width:420,children:e.jsxs(a.Form,{form:c,layout:"vertical",onFinish:x,children:[e.jsx(a.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(a.Input,{placeholder:"Section Name"})}),e.jsxs(a.Space,{children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(V,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(ie,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(a.Space,{}),children:e.jsx(a.Table,{rowKey:k=>k.id,columns:R,dataSource:m,loading:y,pagination:{current:n.page,pageSize:n.perPage,total:A,showSizeChanger:!0,onChange:(k,O)=>s({page:k,perPage:O})}})})]})}function fg({token:t}){return e.jsx(hg,{token:t})}const Ja=Ue.master.classes,yg=({token:t,page:n=1,perPage:s=10})=>gn({token:t,baseUrl:Ja.table,page:n,perPage:s}),gg=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},xg=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function bg({token:t}){const[n,s]=i.useState({page:1,perPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=a.Form.useForm(),[g]=a.Form.useForm(),{data:y}=K(t?[Ue.master.sections.list,t]:null,([S,E])=>G(S,E)),p=i.useMemo(()=>xg(y),[y]),m=i.useMemo(()=>p.map(S=>({label:S.label??S.section??String(S.value??""),value:String(S.value??S.id??"")})),[p]),{data:A,isLoading:C,mutate:b}=yg({token:t,page:n.page,perPage:n.perPage}),f=i.useMemo(()=>gg(A),[A]),x=i.useMemo(()=>A?.pagination?.total_rows??A?.pagination?.total??f.length??0,[A,f]),{data:R}=K(t&&o?[`${Ja.show}?id=${encodeURIComponent(String(o))}`,t]:null,([S,E])=>G(S,E)),k=i.useMemo(()=>{const S=R?.data??R;return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:S?[S]:[]},[R]),O=S=>{const E=S?.id??S?.class_id;E&&(d(E),l(!0))};i.useEffect(()=>{if(!r||!k.length)return;const S=k[0],E=k.map(T=>T?.section_id??T?.fk_sectionId??T?.sectionId??T?.section).filter(T=>T!=null&&String(T).trim()!=="").map(T=>String(T)),$=Array.isArray(S?.section_ids)?S.section_ids.map(T=>String(T)):typeof S?.section_ids=="string"?S.section_ids.split(",").map(T=>T.trim()).filter(Boolean):Array.isArray(S?.section)?S.section.map(T=>String(T)):[],q=E.length?E:$;g.setFieldsValue({name:S?.class??S?.name??"",section:q})},[r,k,g]);const _=async S=>{const E=new FormData;E.append("name",S.name??""),(S.section??[]).forEach($=>E.append("section[]",String($)));try{await Pt(Ja.add,E,t),v.success("Success! Added new item.",{duration:1e3}),c.resetFields(),b()}catch($){v.error($?.response?.data?.msg??$?.message??"Failed to add the new item.",{duration:1500})}},D=async S=>{const E=new FormData;E.append("id",String(o??"")),E.append("name",S.name??""),(S.section??[]).forEach($=>E.append("section[]",String($)));try{await Kt(Ja.edit,E,t),v.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),b()}catch($){v.error($?.response?.data?.msg??$?.message??"Failed to update the item.",{duration:1500})}},u=async S=>{try{await Gt(Ja.remove,S,t),v.success("Success! Deleted item.",{duration:1e3}),b()}catch(E){v.error(E?.response?.data?.msg??E?.message??"Failed to delete the item.",{duration:1500})}},h=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(S,E)=>S??E?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:S=>S??""},{title:"Actions",key:"actions",width:120,render:(S,E)=>e.jsxs(a.Space,{children:[e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>O(E)}),e.jsx(a.Popconfirm,{title:"Delete this class?",onConfirm:()=>u(E?.id),children:e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{title:"Edit Class",open:r,onClose:()=>{l(!1),d(null)},width:520,children:e.jsxs(a.Form,{form:g,layout:"vertical",onFinish:D,children:[e.jsx(a.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(a.Input,{placeholder:"Class"})}),e.jsx(a.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(a.Checkbox.Group,{options:m})}),e.jsxs(a.Space,{children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(a.Form,{form:c,layout:"vertical",onFinish:_,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(a.Input,{placeholder:"Class"})}),e.jsx(a.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(a.Checkbox.Group,{options:m})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(a.Table,{rowKey:S=>S.id,columns:h,dataSource:f,loading:C,pagination:{current:n.page,pageSize:n.perPage,total:x,showSizeChanger:!0,onChange:(S,E)=>s({page:S,perPage:E})}})})]})}function jg({token:t}){return e.jsx(bg,{token:t})}const Qa=Ue.master.subjects,Sg=({token:t,page:n=1,perPage:s=10})=>gn({token:t,baseUrl:Qa.table,page:n,perPage:s}),vg=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Zi=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],el=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function wg({token:t}){const[n,s]=i.useState({page:1,perPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=a.Form.useForm(),[g]=a.Form.useForm(),{data:y,isLoading:p,mutate:m}=Sg({token:t,page:n.page,perPage:n.perPage}),A=i.useMemo(()=>vg(y),[y]),C=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??A.length??0,[y,A]),{data:b,isLoading:f}=K(t&&o?[`${Qa.show}?id=${encodeURIComponent(String(o))}`,t]:null,([u,h])=>G(u,h)),x=i.useMemo(()=>{const u=b?.data??b;return Array.isArray(u)?u[0]:u??null},[b]);i.useEffect(()=>{if(!r||!x)return;const u=[];["yes","1","true"].includes(String(x?.is_practical??"").toLowerCase())&&u.push("Practical"),["yes","1","true"].includes(String(x?.is_theory??"").toLowerCase())&&u.push("Theory"),g.setFieldsValue({name:x?.name??"",subject_type:x?.subject_type??x?.type??"",subject_types:u,code:x?.code??""})},[r,x,g]);const R=async u=>{const h=u?.subject_type??u?.type??"",S=Array.isArray(u?.subject_types)?u.subject_types:[],E={name:u?.name??"",subject_type:h,subject_types:S,code:u?.code??"",is_practical:S.includes("Practical")?"yes":"no",is_theory:S.includes("Theory")?"yes":"no"};try{await Ge(Qa.add,E,t),v.success("Success! Added new item.",{duration:1e3}),c.resetFields(),m()}catch($){v.error($?.response?.data?.msg??$?.message??"Failed to add the new item.",{duration:1500})}},k=async u=>{const h=new FormData,S=u?.subject_type??u?.type??"",E=Array.isArray(u?.subject_types)?u.subject_types:[];h.append("id",String(o??"")),h.append("name",u.name??""),h.append("subject_type",S),h.append("code",u.code??""),h.append("subject_types",E),h.append("is_practical",E.includes("Practical")?"yes":"no"),h.append("is_theory",E.includes("Theory")?"yes":"no");try{await Kt(Qa.edit,h,t),v.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),m()}catch($){v.error($?.response?.data?.msg??$?.message??"Failed to update the item.",{duration:1500})}},O=async u=>{try{await Gt(Qa.remove,u,t),v.success("Success! Deleted item.",{duration:1e3}),m()}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to delete the item.",{duration:1500})}},_=u=>{const h=u?.id;h&&(d(h),l(!0))},D=i.useMemo(()=>[{title:"Subject Name",dataIndex:"name",key:"name"},{title:"Subject",dataIndex:"subject_type",key:"subject_type"},{title:"Subject Code",dataIndex:"code",key:"code"},{title:"Subject Type",key:"subject_types",render:(u,h)=>{const S=[],E=h?.subject_types;Array.isArray(E)?E.forEach(j=>{const P=String(j??"").trim();if(!P)return;const I=P.toLowerCase();["yes","1","true"].includes(I)||S.push(P)}):typeof E=="string"&&E.split(",").map(j=>j.trim()).filter(Boolean).forEach(j=>{const P=j.toLowerCase();["yes","1","true"].includes(P)||S.push(j)});const $=["yes","1","true"].includes(String(h?.is_practical??"").toLowerCase()),q=["yes","1","true"].includes(String(h?.is_theory??"").toLowerCase());$&&S.push("Practical"),q&&S.push("Theory");const T=S.map(j=>String(j??"").trim()).filter(Boolean).map(j=>j.toLowerCase()==="practical"?"Practical":j.toLowerCase()==="theory"?"Theory":j),F=Array.from(new Set(T));return F.length?F.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(u,h)=>e.jsxs(a.Space,{children:[e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>_(h)}),e.jsx(a.Popconfirm,{title:"Delete this subject?",onConfirm:()=>O(h?.id),children:e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{title:"Edit Subject",open:r,onClose:()=>{l(!1),d(null)},width:560,children:f?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(a.Spin,{size:"large"})}):e.jsxs(a.Form,{form:g,layout:"vertical",onFinish:k,children:[e.jsx(a.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(V,{placeholder:"Subject Name"})}),e.jsx(a.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(a.Radio.Group,{options:el})}),e.jsx(a.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(a.Checkbox.Group,{options:Zi})}),e.jsx(a.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(V,{placeholder:"Subject Code"})}),e.jsxs(a.Space,{children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(a.Form,{form:c,layout:"vertical",onFinish:R,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(V,{placeholder:"Subject Name"})}),e.jsx(a.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(a.Radio.Group,{options:el})}),e.jsx(a.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(a.Checkbox.Group,{options:Zi})}),e.jsx(a.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(V,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(a.Table,{rowKey:u=>u.id,columns:D,dataSource:A,loading:p,pagination:{current:n.page,pageSize:n.perPage,total:C,showSizeChanger:!0,onChange:(u,h)=>s({page:u,perPage:h})}})})]})}function _g({token:t}){return e.jsx(wg,{token:t})}const Xa=Ue.master.holidays,Cg=({token:t,page:n=1,perPage:s=10})=>gn({token:t,baseUrl:Xa.table,page:n,perPage:s}),Ag=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Pn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Dg({token:t}){const[n,s]=i.useState({page:1,perPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=a.Form.useForm(),[g]=a.Form.useForm(),{data:y,isLoading:p,mutate:m}=Cg({token:t,page:n.page,perPage:n.perPage}),A=i.useMemo(()=>Ag(y),[y]),C=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??A.length??0,[y,A]),{data:b}=K(t&&o?[`${Xa.show}?id=${encodeURIComponent(String(o))}`,t]:null,([D,u])=>G(D,u)),f=i.useMemo(()=>{const D=b?.data??b;return Array.isArray(D)?D[0]:D??null},[b]);i.useEffect(()=>{r&&f&&g.setFieldsValue({title:f?.holiday_title??"",description:f?.holiday_description??"",from:f?.start_date?se(f.start_date):null,to:f?.end_date?se(f.end_date):null})},[r,f,g]);const x=async D=>{const u=new FormData;u.append("title",D.title??""),u.append("description",D.description??""),u.append("from",D.from?se(D.from).format("YYYY-MM-DD"):""),u.append("to",D.to?se(D.to).format("YYYY-MM-DD"):"");try{await Pt(Xa.add,u,t,{includeSession:!0}),v.success("Success! Added new item.",{duration:1e3}),c.resetFields(),m()}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to add the new item.",{duration:1500})}},R=async D=>{const u=new FormData;u.append("id",String(o??"")),u.append("title",D.title??""),u.append("description",D.description??""),u.append("from",D.from?se(D.from).format("YYYY-MM-DD"):""),u.append("to",D.to?se(D.to).format("YYYY-MM-DD"):"");try{await Kt(Xa.edit,u,t,{includeSession:!0}),v.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),m()}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to update the item.",{duration:1500})}},k=async D=>{try{await Gt(Xa.remove,D,t),v.success("Success! Deleted item.",{duration:1e3}),m()}catch(u){v.error(u?.response?.data?.msg??u?.message??"Failed to delete the item.",{duration:1500})}},O=D=>{const u=D?.id;u&&(d(u),l(!0))},_=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:(D,u)=>e.jsxs(a.Space,{children:[e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>O(u)}),e.jsx(a.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>k(u?.id),children:e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{title:"Edit Holiday",open:r,onClose:()=>{l(!1),d(null)},width:560,children:e.jsxs(a.Form,{form:g,layout:"vertical",onFinish:R,children:[e.jsx(a.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(V,{placeholder:"Holiday Title"})}),e.jsx(a.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(V,{placeholder:"Holiday Description"})}),e.jsx(a.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(a.DatePicker,{format:"YYYY-MM-DD",style:Pn})}),e.jsx(a.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(a.DatePicker,{format:"YYYY-MM-DD",style:Pn})}),e.jsxs(a.Space,{children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(a.Form,{form:c,layout:"vertical",onFinish:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(V,{placeholder:"Holiday Title"})}),e.jsx(a.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(gt,{placeholder:"Holiday Description"})}),e.jsx(a.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(a.DatePicker,{format:"YYYY-MM-DD",style:Pn})}),e.jsx(a.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(a.DatePicker,{format:"YYYY-MM-DD",style:Pn})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(a.Table,{rowKey:D=>D.id,columns:_,dataSource:A,loading:p,pagination:{current:n.page,pageSize:n.perPage,total:C,showSizeChanger:!0,onChange:(D,u)=>s({page:D,perPage:u})}})})]})}function Tg({token:t}){return e.jsx(Dg,{token:t})}const Qn=Ue.assignSubjects,Rg=({token:t,page:n=1,perPage:s=50})=>gn({token:t,baseUrl:Qn.list,page:n,perPage:s}),tl=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Ig=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function kg({token:t}){const[n,s]=i.useState({page:1,perPage:50}),[r,l]=i.useState(null),[o,d]=i.useState([]),[c,g]=i.useState(!1),[y,p]=i.useState(!1),[m,A]=i.useState(null),[C,b]=i.useState([]),{data:f}=K(t?[Ue.master.classes.dropdown,t]:null,([j,P])=>G(j,P)),{data:x}=K(t?[Ue.master.subjects.dropdown,t]:null,([j,P])=>G(j,P)),R=i.useMemo(()=>tl(f),[f]),k=i.useMemo(()=>tl(x),[x]),O=i.useMemo(()=>k.map(j=>({label:j.label??j.subject??String(j.value??""),value:j.value??j.id})),[k]),{data:_,isLoading:D,mutate:u}=Rg({token:t,page:n.page,perPage:n.perPage}),h=i.useMemo(()=>Ig(_),[_]),S=i.useMemo(()=>_?.pagination?.total_rows??_?.pagination?.total??h.length??0,[_,h]),{data:E}=K(t&&m?[`${Qn.editByClass}?class_id=${encodeURIComponent(String(m))}`,t]:null,([j,P])=>G(j,P));i.useEffect(()=>{if(!y)return;const j=E?.data??E,P=Array.isArray(j)?j:Array.isArray(j?.data)?j.data:[];b(P.map(I=>I.subject_id).filter(Boolean))},[y,E]);const $=async j=>{if(j.preventDefault(),!r?.value){v.error("Please select class",{duration:1200});return}if(!o.length){v.error("Please select subjects",{duration:1200});return}const P=new FormData;P.append("class_id",String(r.value)),o.forEach(I=>P.append("subject[]",String(I)));try{g(!0),await Kt(Qn.assign,P,t),v.success("Success! Updated item.",{duration:1e3}),l(null),d([]),u()}catch(I){v.error(I?.response?.data?.msg??I?.message??"Failed to update the item.",{duration:1500})}finally{g(!1)}},q=j=>{j&&(A(j),p(!0))},T=async()=>{if(!m)return;if(!C.length){v.error("Please select subjects",{duration:1200});return}const j=new FormData;j.append("class_id",String(m)),C.forEach(P=>j.append("subject[]",String(P)));try{await Kt(Qn.update,j,t),v.success("Success! Updated item.",{duration:1e3}),p(!1),A(null),u()}catch(P){v.error(P?.response?.data?.msg??P?.message??"Failed to update the item.",{duration:1500})}},F=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(j,P)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(P?.subject_name??j??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(j,P)=>e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>q(P?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{title:"Edit Assigned Subjects",open:y,onClose:()=>{p(!1),A(null)},width:520,extra:e.jsxs(a.Space,{children:[e.jsx(a.Button,{onClick:()=>p(!1),children:"Cancel"}),e.jsx(a.Button,{type:"primary",onClick:T,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:R.find(j=>String(j.value)===String(m))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(a.Checkbox.Group,{options:O,value:C,onChange:b})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:j=>l(j??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(a.Checkbox.Group,{options:O,value:o,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(a.Table,{rowKey:j=>j.id,columns:F,dataSource:h,loading:D,pagination:{current:n.page,pageSize:n.perPage,total:S,showSizeChanger:!0,onChange:(j,P)=>s({page:j,perPage:P})}})})]})}function Pg({token:t}){return e.jsx(kg,{token:t})}const ja=Ue.assignByClass,Oo=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[]},za=t=>Oo(t),Og=t=>Oo(t),Ya=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Mg({token:t}){const[n,s]=i.useState(null),[r,l]=i.useState(null),[o,d]=i.useState(null),[c,g]=i.useState("No"),[y,p]=i.useState([]),[m,A]=i.useState([]),[C,b]=i.useState(null),[f,x]=i.useState(null),[R,k]=i.useState(!1),[O,_]=i.useState(""),{data:D}=K(t?[ja.teacherDropdown,t]:null,([ue,oe])=>G(ue,oe)),{data:u}=K(t?[Ue.master.classes.dropdown,t]:null,([ue,oe])=>G(ue,oe)),{data:h}=K(t&&f?[f,t]:null,([ue,oe])=>G(ue,oe)),{data:S}=K(t&&C?[C,t]:null,([ue,oe])=>G(ue,oe)),E=i.useMemo(()=>za(D),[D]),$=i.useMemo(()=>za(u),[u]),q=i.useMemo(()=>za(h),[h]),T=i.useMemo(()=>za(S),[S]),{data:F}=K(t&&n&&r&&o?[`${ja.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(n))}&class_id=${encodeURIComponent(String(r))}§ion_id=${encodeURIComponent(String(o))}`,t]:null,([ue,oe])=>G(ue,oe)),j=F?.data??F??null;i.useEffect(()=>{j&&(p(Array.isArray(j?.subject_ids)?j.subject_ids:[]),g(j?.isClassTeacher||"No"),A([]))},[j]);const{data:P}=K(t?[ja.classWithSection,t]:null,([ue,oe])=>G(ue,oe)),I=i.useMemo(()=>za(P),[P]),[N,W]=i.useState(null),[Y,B]=i.useState({page:1,perPage:25});i.useEffect(()=>{N||I?.[0]&&W(`${I[0].class_id}val${I[0].section_id}`)},[I,N]);const U=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),M=i.useMemo(()=>{if(!N)return null;const[ue,oe]=String(N).split("val");if(!ue||!oe)return null;const Ce=Y.page??1,Ne=Y.perPage??25;return`${ja.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(Ce))}&per_page=${encodeURIComponent(String(Ne))}&session_id=${encodeURIComponent(String(U))}&class_id=${encodeURIComponent(String(ue))}§ion_id=${encodeURIComponent(String(oe))}`},[N,Y.page,Y.perPage,U]),{data:L,isLoading:z,mutate:ne}=K(t&&M?[M,t]:null,([ue,oe])=>G(ue,oe),{revalidateOnFocus:!1}),X=i.useMemo(()=>Og(L),[L]),J=i.useMemo(()=>{const ue=L?.pagination??L?.data?.pagination??L?.data?.data?.pagination;return ue?.total_rows??ue?.total??X.length??0},[L,X]),H=async ue=>{if(ue.preventDefault(),_(""),!n||!r||!o){v.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(y)||y.length===0){_("error"),v.error("Please Select Subject",{duration:1200});return}const oe=new FormData;oe.append("teacher_id",String(n)),oe.append("class_id",String(r)),oe.append("section_id",String(o)),oe.append("isClassTeacher",String(c??"No")),Ya(y).forEach(Ce=>oe.append("subject_ids[]",String(Ce))),Ya(m).forEach(Ce=>oe.append("delete_subject[]",String(Ce)));try{await Pt(ja.assignClassToTeacher,oe,t,{includeSession:!0}),v.success("Success! Added new item.",{duration:1e3}),_(""),ne()}catch(Ce){v.error(Ce?.response?.data?.msg??Ce?.message??"Failed to add the new item.",{duration:1500})}},Q=async ue=>{try{await Gt(ja.deleteTeacherSub,ue,t),v.success("Success! Deleted item.",{duration:1e3}),ne(),window.location.reload()}catch(oe){v.error(oe?.response?.data?.msg??oe?.message??"Failed to delete the item.",{duration:1500})}},ce=ue=>{const oe=Array.isArray(ue?.child)?ue.child:[],Ce=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Ne,et)=>e.jsx(a.Popconfirm,{title:"Delete this subject?",onConfirm:()=>Q(et?.id),children:e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(a.Table,{columns:Ce,bordered:!0,size:"small",dataSource:oe,pagination:!1,rowKey:Ne=>Ne.id})})},De=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(ue,oe)=>e.jsxs("div",{children:[oe.teacher_name,oe.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],le=i.useMemo(()=>(I??[]).map(ue=>({label:ue.label??`${ue.class_name??""} ${ue.section_name??""}`.trim(),key:`${ue.class_id}val${ue.section_id}`,children:e.jsx(a.Table,{size:"small",columns:De,bordered:!0,dataSource:Array.isArray(X)?X:[],loading:z,rowKey:oe=>oe.id,expandable:{expandedRowRender:ce},pagination:{current:Y.page,pageSize:Y.perPage,total:J,showSizeChanger:!0,onChange:(oe,Ce)=>B({page:oe,perPage:Ce})}})})),[I,Y.page,Y.perPage,X,z,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(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:H,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:E.find(ue=>String(ue.value)===String(n))??null,onChange:ue=>s(ue?.value??null)}),e.jsx(Z,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:$.find(ue=>String(ue.value)===String(r))??null,onChange:ue=>{const oe=ue?.value??null;l(oe),d(null),b(oe?`${Ue.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(oe))}`:null),x(oe?`${Ue.master.sections.byClass}?class_id=${encodeURIComponent(String(oe))}`:null),k(Ce=>!Ce)}}),e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:q.find(ue=>String(ue.value)===String(o))??null,onChange:ue=>d(ue?.value??null)},`section_${R}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const ue=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(Z,{style:{width:"100%"},options:ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:ue.find(oe=>String(oe.value)===String(c??"No"))??ue[1],onChange:oe=>g(oe?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(Z,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:T,value:(T??[]).filter(ue=>Ya(y).some(oe=>String(oe)===String(ue.value))),onChange:(ue,oe)=>{const Ne=(Array.isArray(ue)?ue:[]).map(Fe=>Fe?.value).filter(Fe=>Fe!=null&&Fe!=="");p(Ne);const et=Array.isArray(j?.subject_ids)?j.subject_ids.map(String):[],we=oe?.removedValue?.value,Ae=oe?.option?.value;(oe?.action==="remove-value"||oe?.action==="pop-value")&&we!=null&&et.includes(String(we))&&A(Fe=>Array.from(new Set([...Ya(Fe).map(String),String(we)]))),oe?.action==="select-option"&&Ae!=null&&et.includes(String(Ae))&&A(Fe=>Ya(Fe).filter(me=>String(me)!==String(Ae)))}},`subjects_${R}`),O?e.jsx("div",{style:{color:"#ff4d4f",marginTop:6,fontSize:12},children:"Please select subject"}):null]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(a.Tabs,{activeKey:N??void 0,onChange:ue=>{W(ue),B(oe=>({...oe,page:1}))},items:le,type:"card",size:"small"})})]})]})}function Eg({token:t}){return e.jsx(Mg,{token:t})}const Wa=Ue.timeGroup,Fg=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Yt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function On(t){if(!t)return null;const n=se(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return n.isValid()?n:null}function Wt(t){return t?se(t).format("h:mm a"):""}function $g({token:t}){const[n,s]=i.useState({page:1,perPage:50}),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c]=a.Form.useForm(),[g]=a.Form.useForm(),y=`${Wa.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:p,isLoading:m,mutate:A}=K(t?[y,t]:null,([h,S])=>G(h,S)),C=i.useMemo(()=>Fg(p),[p]),b=i.useMemo(()=>p?.pagination?.total_rows??p?.pagination?.total??C.length??0,[p,C]),{data:f,isLoading:x}=K(t&&o?[`${Wa.show}?id=${encodeURIComponent(String(o))}`,t]:null,([h,S])=>G(h,S)),R=i.useMemo(()=>{const h=f?.data??f;return Array.isArray(h)?h[0]:h??null},[f]);i.useEffect(()=>{r&&R&&g.setFieldsValue({title:R?.title??"",start_time_from:On(R?.start_time_from),start_time_to:On(R?.start_time_to),end_time_from:On(R?.end_time_from),end_time_to:On(R?.end_time_to)})},[r,R,g]);const k=async h=>{const S=new FormData;S.append("title",h.title??""),S.append("start_time_from",Wt(h.start_time_from)),S.append("start_time_to",Wt(h.start_time_to)),S.append("end_time_from",Wt(h.end_time_from)),S.append("end_time_to",Wt(h.end_time_to));try{await Pt(Wa.add,S,t),v.success("Success! Added new item.",{duration:1e3}),c.resetFields(),A()}catch(E){v.error(E?.response?.data?.msg??E?.message??"Failed to add the new item.",{duration:1500})}},O=async h=>{const S=new FormData;S.append("id",String(o??"")),S.append("title",h.title??""),S.append("start_time_from",Wt(h.start_time_from)),S.append("start_time_to",Wt(h.start_time_to)),S.append("end_time_from",Wt(h.end_time_from)),S.append("end_time_to",Wt(h.end_time_to));try{await Kt(Wa.edit,S,t),v.success("Success! Updated item.",{duration:1e3}),l(!1),d(null),A()}catch(E){v.error(E?.response?.data?.msg??E?.message??"Failed to update the item.",{duration:1500})}},_=async h=>{try{await Gt(Wa.remove,h,t),v.success("Success! Deleted item.",{duration:1e3}),A()}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to delete the item.",{duration:1500})}},D=h=>{h?.id&&(d(h.id),l(!0))},u=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:120,render:(h,S)=>e.jsxs(a.Space,{children:[e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>D(S)}),e.jsx(a.Popconfirm,{title:"Delete this time group?",onConfirm:()=>_(S?.id),children:e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{title:"Edit Time Group",open:r,onClose:()=>{l(!1),d(null)},width:520,children:x?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(a.Spin,{size:"large"})}):e.jsxs(a.Form,{form:g,layout:"vertical",onFinish:O,children:[e.jsx(a.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(V,{placeholder:"Title"})}),e.jsx(a.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",style:Yt})}),e.jsx(a.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",style:Yt})}),e.jsx(a.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",style:Yt})}),e.jsx(a.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",style:Yt})}),e.jsxs(a.Space,{children:[e.jsx(ie,{type:"submit",value:"Submit",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>{l(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(a.Form,{form:c,layout:"vertical",onFinish:k,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(V,{placeholder:"Title"})}),e.jsx(a.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",style:Yt})}),e.jsx(a.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",style:Yt})}),e.jsx(a.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",style:Yt})}),e.jsx(a.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm a",style:Yt})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(a.Table,{rowKey:h=>h.id,columns:u,dataSource:C,loading:m,pagination:{current:n.page,pageSize:n.perPage,total:b,showSizeChanger:!0,onChange:(h,S)=>s({page:h,perPage:S})}})})]})}function Ug({token:t}){return e.jsx($g,{token:t})}const Va=Ue.assignTimeGroup,Bg=Ue.timeGroup.dropdown,Ng=Ue.master.classes.dropdown,al=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Lg=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function qg({token:t}){const[n,s]=i.useState({page:1,perPage:50}),[r,l]=i.useState(null),[o,d]=i.useState([]),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState(null),[C,b]=i.useState(!1),[f,x]=i.useState(!1),[R,k]=i.useState(null),[O,_]=i.useState([]),[D,u]=i.useState(""),[h,S]=i.useState(""),{data:E}=K(t?[Bg,t]:null,([J,H])=>G(J,H)),{data:$}=K(t?[Ng,t]:null,([J,H])=>G(J,H)),q=i.useMemo(()=>al(E?.data??E),[E]),T=i.useMemo(()=>al($),[$]),{data:F}=K(t&&m?[m,t]:null,([J,H])=>G(J,H));i.useEffect(()=>{const J=Array.isArray(F?.data)?F.data.map(H=>H.fk_classId):[];J.length&&d(J)},[F]);const j=`${Va.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:P,isLoading:I,mutate:N}=K(t?[j,t]:null,([J,H])=>G(J,H)),W=i.useMemo(()=>Lg(P),[P]),Y=i.useMemo(()=>P?.pagination?.total_rows??P?.pagination?.total??W.length??0,[P,W]),{data:B,isLoading:U}=K(t&&R?[`${Va.show}?id=${encodeURIComponent(String(R))}`,t]:null,([J,H])=>G(J,H)),M=B?.data??B??null;i.useEffect(()=>{if(!f||!M)return;const J=Array.isArray(M?.class_ids)?M.class_ids:[];_(J);const H=Array.isArray(q)?q.find(Q=>String(Q.value)===String(M?.timegroup_id)):null;H&&S(`${H.start_time_from} -> ${H.end_time_from}`)},[f,M,q]);const L=async J=>{if(J.preventDefault(),g(""),!r?.value){v.error("Select Time Group",{duration:1200});return}if(!o.length){g("error"),v.error("Please Select Classes",{duration:1200});return}const H=new FormData;H.append("timegroup_id",String(r.value)),o.forEach(Q=>H.append("class_ids[]",String(Q)));try{await Pt(Va.assign,H,t),v.success("Success! Added new item.",{duration:1e3}),d([]),l(null),p(""),N()}catch(Q){v.error(Q?.response?.data?.msg??Q?.message??"Failed to add the new item.",{duration:1500})}},z=async()=>{if(u(""),!R)return;if(!O.length){u("error"),v.error("Please Select Classes",{duration:1200});return}const J=new FormData;J.append("id",String(R)),J.append("timegroup_id",String(M?.timegroup_id??"")),O.forEach(H=>J.append("class_ids[]",String(H)));try{await Kt(Va.assign,J,t),v.success("Success! Updated item.",{duration:1e3}),x(!1),k(null),N()}catch(H){v.error(H?.response?.data?.msg??H?.message??"Failed to update the item.",{duration:1500})}},ne=J=>{J&&(k(J),x(!0))},X=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Class Names",dataIndex:"class_names",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:90,render:(J,H)=>H?.class_names?e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>ne(H?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Drawer,{title:"Edit Assigned Time Group",open:f,onClose:()=>{x(!1),k(null)},width:520,extra:e.jsxs(a.Space,{children:[e.jsx(a.Button,{onClick:()=>x(!1),children:"Cancel"}),e.jsx(a.Button,{type:"primary",onClick:z,children:"Submit"})]}),children:U?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(a.Spin,{size:"large"})}):e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{options:Array.isArray(q)?q:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:q.find(J=>String(J.value)===String(M?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:h}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(a.Select,{mode:"multiple",style:{width:"100%"},status:D,value:O,placeholder:"Select Classes",onChange:J=>_(J),options:Array.isArray(T)?T:[]})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(Z,{options:Array.isArray(q)?q:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:J=>{l(J??null),d([]),g(""),J?.value?(A(`${Va.classIdByTimeGroup}?id=${encodeURIComponent(String(J.value))}`),p(`${J.start_time_from} -> ${J.end_time_from}`)):(A(null),p("")),b(H=>!H)}}),e.jsx("div",{style:{marginTop:6},children:y})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(Z,{isMulti:!0,style:{width:"100%"},status:c,value:(T??[]).filter(J=>Array.isArray(o)&&o.some(H=>String(H)===String(J.value))),placeholder:"Select Classes",onChange:J=>{const H=Array.isArray(J)?J:[];d(H.map(Q=>Q?.value).filter(Q=>Q!=null&&Q!==""))},options:Array.isArray(T)?T:[]},`class_${C}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(a.Table,{rowKey:J=>J.id,columns:X,dataSource:W,loading:I,pagination:{current:n.page,pageSize:n.perPage,total:Y,showSizeChanger:!0,onChange:(J,H)=>s({page:J,perPage:H})}})})]})}function zg({token:t}){return e.jsx(qg,{token:t})}const tr=Ue.promoteStudents,Yg=({token:t})=>K(t?[tr.sessionDropdown,t]:null,([n,s])=>G(n,s)),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[]},Wg=(t,n)=>{const s=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,r=s?.total_rows??s?.total??s?.totalItems;return Number.isFinite(Number(r))?Number(r):n};function Vg({token:t}){const[n]=a.Form.useForm(),[s,r]=i.useState({page:1,perPage:300}),[l,o]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[g,y]=i.useState(!1),[p,m]=i.useState([]),A=i.useMemo(()=>new Set(p),[p]),[C,b]=i.useState({}),[f,x]=i.useState({}),{data:R}=K(t?[Ue.master.classes.dropdown,t]:null,([L,z])=>G(L,z)),k=i.useMemo(()=>Mn(R),[R]),O=i.useMemo(()=>l.classId?`${Ue.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:_}=K(t&&O?[O,t]:null,([L,z])=>G(L,z)),D=i.useMemo(()=>Mn(_),[_]),u=i.useMemo(()=>d.classId?`${Ue.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:h}=K(t&&u?[u,t]:null,([L,z])=>G(L,z),{revalidateOnFocus:!1}),S=i.useMemo(()=>Mn(h),[h]),{data:E}=Yg({token:t}),$=i.useMemo(()=>Mn(E),[E]),{trigger:q,data:T,isMutating:F}=pt(t?tr.searchByClassSection:null,(L,{arg:z})=>na(L,{arg:z},t)),j=i.useMemo(()=>{const L=T?.data?.data??T?.data??T??[];return Array.isArray(L)?L:Array.isArray(L?.data)?L.data:[]},[T]),P=i.useMemo(()=>Wg(T,j.length??0),[T,j.length]),I=i.useMemo(()=>{const L=new Map;return(Array.isArray(j)?j:[]).forEach(z=>{z?.id!==void 0&&z?.id!==null&&L.set(String(z.id),z)}),L},[j]),N=i.useCallback((L,z)=>{const ne=String(L);x(X=>({...X,[ne]:{...X?.[ne]??{},...z}}))},[]),W=i.useCallback((L,z)=>{const ne=String(L),X=z==="Leave";b(J=>({...J,[ne]:X}))},[]),Y=L=>{const z=L?.class_id?.value??L?.class_id??null,ne=L?.section_id?.value??L?.section_id??null;if(!z||!ne){v.error("Please select Class and Section",{duration:1200});return}r(X=>({...X,page:1})),o({classId:z,sectionId:ne}),m([]),b({}),x({})},B=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 L=p.map(J=>String(J)).map(J=>{const H=I.get(J)??{},Q=!!C?.[J],ce=f?.[J]??{},De=String(ce.current_result??"Pass");if(Q){const oe=String(ce.leave_date??"");return{student_id:J,current_result:De,next_session_status:"Leave",leave_date:oe}}const le=String(ce.roll_no??H?.roll_no??""),ue=String(ce.section_id??"");return{student_id:J,roll_no:le,section_id:ue,current_result:De,next_session_status:"Continue"}});if(L.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(L.some(J=>J?.next_session_status==="Continue"&&!String(J?.section_id??"").trim())){v.error("Section is required for Continue students.",{duration:1500});return}const X={class_id:String(d.classId),session_id:String(d.sessionId),students:L};try{const J=await tt(tr.promote,X,t);if(J?.Status&&String(J.Status)!=="success")throw new Error(J?.msg||"Failed to update");v.success("Success! Updated.",{duration:1e3});const H=Number(J?.success_count??0)+Number(J?.leave_count??0),Q=s.page===Math.ceil((Number(P)||0)/s.perPage||1),ce=H>0&&H===j.length&&j.length===p.length,De=Q&&ce&&s.page>1?s.page-1:s.page;r(le=>({...le,page:De})),q?.({cID:l.classId,sID:l.sectionId,page:De,per_page:s.perPage}),m([]),b({}),x({})}catch(J){v.error(J?.response?.data?.msg??J?.message??"Failed to update",{duration:1500})}},U=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:120,render:(L,z)=>{const ne=String(z?.id??""),X=A.has(ne),J=!!C?.[ne],Q=(f?.[ne]??{}).roll_no??(J?"":z?.roll_no??"");return e.jsx(a.Input,{value:X?Q:z?.roll_no,style:X?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!X||J,onChange:ce=>N(ne,{roll_no:ce.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(L,z)=>`${z?.firstname??""} ${z?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(L,z)=>{const ne=String(z?.id??""),X=A.has(ne),J=!!C?.[ne],Q=(f?.[ne]??{}).section_id??"",ce=Array.isArray(S)?S:[];return e.jsx(a.Select,{options:ce,placeholder:X&&!J?"Select Section":"Section",disabled:!X||J,value:X&&!J&&Q||void 0,style:{width:"100%"},onChange:De=>N(ne,{section_id:De})},`section_${ne}_${g}_${J?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(L,z)=>{const ne=String(z?.id??""),X=A.has(ne),J=f?.[ne]??{},H=String(J.current_result??"Pass");return e.jsxs(a.Radio.Group,{value:H,disabled:!X,buttonStyle:"solid",onChange:Q=>N(ne,{current_result:Q.target.value}),children:[e.jsx(a.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(a.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(L,z)=>{const ne=String(z?.id??""),X=A.has(ne),J=!!C?.[ne],H=f?.[ne]??{},Q=String(H.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(a.Radio.Group,{value:J?"Leave":"Continue",disabled:!X,buttonStyle:"solid",onChange:ce=>W(ne,ce.target.value),children:[e.jsx(a.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(a.Radio.Button,{value:"Leave",children:"Leave"})]}),X&&J&&e.jsx(a.DatePicker,{style:{width:"100%"},value:Q?se(Q):null,onChange:ce=>N(ne,{leave_date:ce?ce.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[W,C,f,A,g,S,N]),M=i.useMemo(()=>({selectedRowKeys:p,onChange:L=>m((Array.isArray(L)?L:[]).map(z=>String(z)))}),[p]);return i.useEffect(()=>{!l.classId||!l.sectionId||q&&q({cID:l.classId,sID:l.sectionId,page:s.page,per_page:s.perPage})},[s.page,s.perPage,q,l.classId,l.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(a.Form,{form:n,layout:"vertical",onFinish:Y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:L=>L,children:e.jsx(Z,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:L=>{const z=L?.value??null;n.setFieldValue("section_id",null),o({classId:z,sectionId:null})}})}),e.jsx(a.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:L=>L,children:e.jsx(Z,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Qt,{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(a.Typography.Text,{children:["Selected: ",p.length]}),e.jsx(a.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(Z,{label:"Session",options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:$.find(L=>String(L.value)===String(d.sessionId))??null,onChange:L=>c(z=>({...z,sessionId:L?.value??null}))}),e.jsx(Z,{label:"Class",options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:k.find(L=>String(L.value)===String(d.classId))??null,onChange:L=>{const z=L?.value??null;c(ne=>({...ne,classId:z})),y(ne=>!ne)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Save",color:"primary",onClick:B})})]}),e.jsx(a.Table,{rowKey:L=>String(L.id),rowSelection:M,columns:U,dataSource:j,loading:F,pagination:{current:s.page,pageSize:s.perPage,total:P,showSizeChanger:!0,onChange:(L,z)=>{r({page:L,perPage:z}),m([]),b({}),x({})}}})]})})]})}function Hg({token:t}){return e.jsx(Vg,{token:t})}const wa=Ue.coscholastic,Kg=({token:t})=>K(t?[wa.table,t]:null,([n,s])=>G(n,s),{revalidateOnFocus:!1}),Gg=({token:t})=>K(t?[wa.categoryDropdown,t]:null,([n,s])=>G(n,s),{revalidateOnFocus:!1}),nl=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 Jg({token:t}){const[n,s]=i.useState(""),[r,l]=i.useState(null),[o,d]=i.useState(null),c=i.useRef(null),{data:g}=K(t?[Ue.master.classes.dropdown,t]:null,([h,S])=>G(h,S)),y=i.useMemo(()=>nl(g),[g]),{data:p,isLoading:m,mutate:A}=Kg({token:t}),C=i.useMemo(()=>{const h=p?.data?.data??p?.data??p??[];return Array.isArray(h)?h:Array.isArray(h?.data)?h.data:[]},[p]),{data:b,mutate:f}=Gg({token:t}),x=i.useMemo(()=>nl(b),[b]),R=i.useMemo(()=>(Array.isArray(x)?x:[]).map(h=>({value:h?.value??h?.id,label:h?.label??h?.title??""})),[x]),k=async()=>{const h=String(n??"").trim();if(!h){v.error("Please enter category title",{duration:1200});return}try{await Ge(wa.addCategory,{title:h},t),v.success("Success! Added category.",{duration:1e3}),s(""),f()}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to add category",{duration:1500})}},O=async h=>{try{await Gt(wa.deleteCategory,h,t),v.success("Success! Deleted category.",{duration:1e3}),f()}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to delete category",{duration:1500})}},_=async h=>{if(h.preventDefault(),!r){v.error("Please select Category",{duration:1200});return}if(!o){v.error("Please select Class",{duration:1200});return}if(!h?.target?.skill?.value){v.error("Please enter Skill Name",{duration:1200});return}const E=new FormData(h.target);E.append("scholastic_catid",String(r)),E.append("class_id",String(o));try{await Pt(wa.addSkill,E,t),v.success("Success! Added new item.",{duration:1e3}),h.target.reset(),d(null),A()}catch($){v.error($?.response?.data?.msg??$?.message??"Failed to add the new item.",{duration:1500})}},D=async h=>{try{await Gt(wa.deleteSkill,h,t),v.success("Success! Deleted item.",{duration:1e3}),A()}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to delete the item.",{duration:1500})}},u=i.useMemo(()=>[{title:"Skill Category",dataIndex:"title",key:"title"},{title:"Class",dataIndex:"class",key:"class"},{title:"Skill Name",dataIndex:"skill",key:"skill"},{title:"Action",key:"action",width:90,render:(h,S)=>e.jsx(a.Popconfirm,{title:"Delete this skill?",onConfirm:()=>D(S?.id),children:e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Category"}),e.jsx(Z,{style:{width:"100%"},value:R.find(h=>String(h.value)===String(r))??null,placeholder:"Select Category",onChange:h=>l(h?.value??null),options:R}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(V,{placeholder:"New category",ref:c,value:n,onChange:h=>s(h.target.value)}),e.jsx(a.Button,{type:"text",icon:e.jsx(ee.PlusOutlined,{}),onClick:k}),e.jsx(a.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{r&&(O(r),l(null))},children:e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{}),disabled:!r})})]})]}),e.jsx(Z,{label:"Class",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:y.find(h=>String(h.value)===String(o))??null,onChange:h=>d(h?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(V,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Qt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(a.Table,{rowKey:h=>h.id,columns:u,dataSource:C,loading:m,pagination:!1})})]})}function Qg({token:t}){return e.jsx(Jg,{token:t})}const Xg=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Mo=({token:t,value:n,onChange:s,action:r,filePath:l})=>{const o=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),d=r??dg(),c=i.useMemo(()=>{if(!l)return d;const g=d.includes("?")?"&":"?";return`${d}${g}filepath=${encodeURIComponent(l)}`},[d,l]);return e.jsx(a.Upload,{maxCount:1,action:c,headers:o,onChange:g=>{if(g?.file?.status==="done"){const y=Xg(g?.file?.response);y&&s?.(y)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},sl=Ue.notes,Zg=({token:t,url:n})=>K(t&&n?[n,t]:null,([s,r])=>G(s,r),{revalidateOnFocus:!1}),En=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[]},ex=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function tx({token:t}){const[n]=a.Form.useForm(),[s]=a.Form.useForm(),[r,l]=i.useState({page:1,perPage:50}),[o,d]=i.useState({classId:null,sectionId:null}),[c,g]=i.useState(!1),[y,p]=i.useState(""),{data:m}=K(t?[Ue.master.classes.dropdown,t]:null,([M,L])=>G(M,L)),A=i.useMemo(()=>En(m),[m]),C=i.useMemo(()=>o.classId?`${Ue.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:b}=K(t&&C?[C,t]:null,([M,L])=>G(M,L)),f=i.useMemo(()=>En(b),[b]),x=i.useMemo(()=>!o.classId||!o.sectionId?null:`${sl.table}?class_id=${encodeURIComponent(String(o.classId))}§ion_id=${encodeURIComponent(String(o.sectionId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`,[o.classId,o.sectionId,r.page,r.perPage]),{data:R,isLoading:k,mutate:O}=Zg({token:t,url:x}),_=i.useMemo(()=>{const M=R?.data?.data??R?.data??R??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},[R]),D=i.useMemo(()=>R?.pagination?.total_rows??R?.pagination?.total??_.length??0,[R,_.length]),[u,h]=i.useState(null),[S,E]=i.useState(null),[$,q]=i.useState(null),[T,F]=i.useState(!1),{data:j}=K(t&&$?[$,t]:null,([M,L])=>G(M,L),{revalidateOnFocus:!1}),P=i.useMemo(()=>En(j),[j]),{data:I}=K(t&&S?[S,t]:null,([M,L])=>G(M,L)),N=i.useMemo(()=>En(I),[I]),W=M=>{const L=M?.class_id?.value??null,z=M?.section_id?.value??null;!L||!z||(l(ne=>({...ne,page:1})),d({classId:L,sectionId:z}))},Y=()=>{p(""),g(!0),h(null),E(null),q(null),F(M=>!M),s.resetFields()},B=async M=>{const L=M?.class_id?.value??null,z=M?.section_id?.value??null,ne=M?.sub_id?.value??null,X=M?.status?.value??"publish",J=M?.title??"",H=M?.remark??"";if(!L||!z||!ne||!J||!H||!y){v.error("Please fill all fields",{duration:1200});return}const Q=new FormData;Q.append("class_id",String(L)),Q.append("section_id",String(z)),Q.append("sub_id",String(ne)),Q.append("title",String(J)),Q.append("remark",String(H)),Q.append("status",String(X)),Q.append("file",String(y));try{await Pt(sl.add,Q,t),v.success("Success! Added new item.",{duration:1e3}),g(!1),O()}catch(ce){v.error(ce?.response?.data?.msg??ce?.message??"Failed to add the new item.",{duration:1500})}},U=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Remarks",dataIndex:"remark",key:"remark",align:"center"},{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Staff Name",dataIndex:"teacher_name",key:"teacher_name",align:"center"},{title:"Status",key:"status",align:"center",render:(M,L)=>{const z=String(L?.status??"").toLowerCase();return e.jsx(a.Tag,{color:z==="publish"?"green":"red",children:L?.status??"-"})}},{title:"File",key:"file",align:"center",render:(M,L)=>{const z=L?.file;if(!z)return"-";const ne=ex(at(),`uploads/school_${L?.fk_branchID}/student/note/${z}`);return e.jsx("a",{href:ne,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"date",key:"date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{title:"Add Note",open:c,onCancel:()=>g(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(a.Form,{form:s,layout:"vertical",onFinish:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(Z,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const L=M?.value??null;h(L),s.setFieldValue("section_id",null),s.setFieldValue("sub_id",null),q(L?`${Ue.master.sections.byClass}?class_id=${encodeURIComponent(String(L))}`:null),E(L?`${Ue.master.subjects.dropdown}?class_id=${encodeURIComponent(String(L))}`:null),F(z=>!z)}},`class_${T}`)}),e.jsx(a.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:M=>M,children:e.jsx(Z,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${T}_${u??"none"}`)}),e.jsx(a.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:M=>M,children:e.jsx(Z,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${T}_${S??"none"}`)}),e.jsx(a.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(V,{placeholder:"Title"})}),e.jsx(a.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(V,{placeholder:"Remark"})}),e.jsx(a.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:M=>M,children:e.jsx(Z,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(a.Form.Item,{label:"File",required:!0,children:e.jsx(Mo,{token:t,value:y,onChange:p})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(a.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Qt,{actions:["add","export","print","download","filter"],onAdd:Y,onPrint:()=>window.print()})]}),children:e.jsx(a.Form,{form:n,layout:"vertical",onFinish:W,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(Z,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const L=M?.value??null;n.setFieldValue("section_id",null),d({classId:L,sectionId:null})}})}),e.jsx(a.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:M=>M,children:e.jsx(Z,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(a.Table,{rowKey:M=>M.id,columns:U,dataSource:_,loading:k,pagination:{current:r.page,pageSize:r.perPage,total:D,showSizeChanger:!0,onChange:(M,L)=>l({page:M,perPage:L})}})})]})}function ax({token:t}){return e.jsx(tx,{token:t})}const nx=({token:t})=>K(t?[Ue.promoteStudents.sessionDropdown,t]:null,([n,s])=>G(n,s),{revalidateOnFocus:!1}),rl=Ue.transferCertificate,Bs=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[]},sx={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},rx=(t,n)=>t.inputtype==="Select"?null:t.inputtype==="date"?se():"",il=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}],ll=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 ix({token:t,transferCertificateViewPath:n="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:s}){const[r]=a.Form.useForm(),[l]=a.Form.useForm(),[o,d]=i.useState({page:1,perPage:10}),[c,g]=i.useState({classId:null,sectionId:null,sessionId:null}),[y,p]=i.useState(null),[m,A]=i.useState(!1),{data:C}=K(t?[Ue.master.classes.dropdown,t]:null,([U,M])=>G(U,M)),b=i.useMemo(()=>Bs(C),[C]),{data:f}=K(t&&y?[y,t]:null,([U,M])=>G(U,M)),x=i.useMemo(()=>Bs(f),[f]),{data:R}=nx({token:t}),k=i.useMemo(()=>Bs(R),[R]),O=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${rl.studentList}?class_id=${encodeURIComponent(String(c.classId))}§ion_id=${encodeURIComponent(String(c.sectionId))}&session_id=${encodeURIComponent(String(c.sessionId))}&page=${encodeURIComponent(String(o.page))}&per_page=${encodeURIComponent(String(o.perPage))}`,[c.classId,c.sectionId,c.sessionId,o.page,o.perPage]),{data:_,isLoading:D,mutate:u}=K(t&&O?[O,t]:null,([U,M])=>G(U,M),{revalidateOnFocus:!1,onSuccess:U=>{const M=U?.data?.data??U?.data??[];Array.isArray(M)&&M[0]?.transefer_certificate_id&&j(String(M[0].transefer_certificate_id))}}),h=i.useMemo(()=>{const U=_?.data?.data??_?.data??_??[];return Array.isArray(U)?U:Array.isArray(U?.data)?U.data:[]},[_]),S=i.useMemo(()=>_?.pagination?.total_rows??_?.pagination?.total??h.length??0,[_,h.length]),[E,$]=i.useState(!1),[q,T]=i.useState(null),[F,j]=i.useState("1"),P=U=>{T(U);const M=F==="1"?il(U):ll(U),L={};M.forEach(z=>{L[z.name]=z.value??rx(z)}),l.setFieldsValue(L),$(!0)},I=async U=>{if(!U)return;if(typeof s=="function")return s(U);const M=`${n}?id=${encodeURIComponent(String(U))}`;window.location.href=M},N=U=>{const M=U?.class_id?.value??null,L=U?.section_id?.value??null,z=U?.session_id?.value??null;if(!M||!L||!z){v.error("Please select Class, Section and Session",{duration:1200});return}d(ne=>({...ne,page:1})),g({classId:M,sectionId:L,sessionId:z})},W=async U=>{const M=new FormData;Object.entries(U??{}).forEach(([L,z])=>{if(z!=null){if(se.isDayjs(z)){M.append(L,z.format("YYYY-MM-DD"));return}M.append(L,String(z))}});try{await Pt(rl.addData,M,t),v.success("Success! Added new item.",{duration:1e3}),$(!1),T(null),u()}catch(L){v.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},Y=i.useMemo(()=>F==="1"?il(q):ll(q),[F,q]),B=i.useMemo(()=>[{title:"Admission no",dataIndex:"admission_no",key:"admission_no",align:"center"},{title:"Roll NO",dataIndex:"roll_no",key:"roll_no",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",align:"center"},{title:"Class",dataIndex:"class",key:"class",align:"center"},{title:"Section",dataIndex:"section",key:"section",align:"center"},{title:"Guardian Name",dataIndex:"guardian_name",key:"guardian_name",align:"center"},{title:"Mobile No",dataIndex:"mobileno",key:"mobileno",align:"center"},{title:"Action",key:"action",align:"center",width:80,render:(U,M)=>e.jsx(a.Button,{type:"text",icon:M?.transfer_certificate_data==="not_present"?e.jsx(ee.EyeOutlined,{}):e.jsx(ee.CheckOutlined,{}),onClick:()=>{M?.transfer_certificate_data==="not_present"?P(M?.id):I(M?.id)}})}],[F]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{title:"Transfer Certificate",open:E,onCancel:()=>$(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(a.Form,{form:l,layout:"vertical",onFinish:W,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:Y.map(U=>U.inputtype==="hidden"?e.jsx(a.Form.Item,{name:U.name,initialValue:U.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},U.name):U.inputtype==="date"?e.jsx(a.Form.Item,{label:U.label,name:U.name,children:e.jsx(a.DatePicker,{format:"YYYY-MM-DD",style:sx})},U.name):U.inputtype==="radio"?e.jsx(a.Form.Item,{label:U.label,name:U.name,children:e.jsx(a.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},U.name):U.inputtype==="Select"?e.jsx(a.Form.Item,{label:U.label,name:U.name,getValueFromEvent:M=>M,children:e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},U.name):e.jsx(a.Form.Item,{label:U.label,name:U.name,children:e.jsx(V,{placeholder:U.label})},U.name))}),e.jsxs(a.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(ie,{type:"submit",value:"Submit",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>$(!1),children:"Cancel"})]})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(a.Form,{form:r,layout:"vertical",onFinish:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:U=>U,children:e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{const M=U?.value??null;p(M?`${Ue.master.sections.byClass}?class_id=${encodeURIComponent(String(M))}`:null),A(L=>!L),r.setFieldValue("section_id",null)}})}),e.jsx(a.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:U=>U,children:e.jsx(Z,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${m}`)}),e.jsx(a.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:U=>U,children:e.jsx(Z,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Qt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(a.Table,{rowKey:U=>U.id,columns:B,dataSource:h,loading:D,pagination:{current:o.page,pageSize:o.perPage,total:S,showSizeChanger:!0,onChange:(U,M)=>d({page:U,perPage:M})}})})]})}function lx({token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:s}){return e.jsx(ix,{token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:s})}const ox=({token:t,url:n})=>K(t&&n?[n,t]:null,([s,r])=>G(s,r),{revalidateOnFocus:!1}),Ns=Ue.syllabus,ol=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[]},dx=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function cx({token:t}){const[n]=a.Form.useForm(),[s]=a.Form.useForm(),[r,l]=i.useState({page:1,perPage:50}),[o,d]=i.useState({classId:null}),[c,g]=i.useState(!1),[y,p]=i.useState(null),[m,A]=i.useState(""),{data:C}=K(t?[Ue.master.classes.dropdown,t]:null,([I,N])=>G(I,N)),b=i.useMemo(()=>ol(C),[C]),f=i.useMemo(()=>o.classId?`${Ns.table}?class_id=${encodeURIComponent(String(o.classId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`:null,[o.classId,r.page,r.perPage]),{data:x,isLoading:R,mutate:k}=ox({token:t,url:f}),O=i.useMemo(()=>{const I=x?.data?.data??x?.data??x??[];return Array.isArray(I)?I:Array.isArray(I?.data)?I.data:[]},[x]),_=i.useMemo(()=>x?.pagination?.total_rows??x?.pagination?.total??O.length??0,[x,O.length]),[D,u]=i.useState(null),[h,S]=i.useState(!1),{data:E}=K(t&&D?[D,t]:null,([I,N])=>G(I,N),{revalidateOnFocus:!1}),$=i.useMemo(()=>ol(E),[E]),q=I=>{const N=I?.class_id?.value??null;N&&(l(W=>({...W,page:1})),d({classId:N}))},T=()=>{p(null),A(""),u(null),S(I=>!I),s.resetFields(),g(!0)},F=I=>{p(I),A(I?.attchement??"");const N=I?.class_id;u(N?`${Ue.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),S(W=>!W),s.setFieldsValue({class_id:b.find(W=>String(W.value)===String(N))??null,sub_id:$.find(W=>String(W.value)===String(I?.sub_id??I?.subject_id))??(I?.sub_id||I?.subject_id?{label:I?.subject_title??"Subject",value:I?.sub_id??I?.subject_id}:null),title:I?.title??"",description:I?.description??""}),g(!0)},j=async I=>{const N=I?.class_id?.value??null,W=I?.sub_id?.value??null,Y=I?.title??"",B=I?.description??"";if(!N||!W||!Y||!B||!m){v.error("Please fill all fields",{duration:1200});return}const U=new FormData;U.append("class_id",String(N)),U.append("sub_id",String(W)),U.append("title",String(Y)),U.append("description",String(B)),U.append("file",String(m));try{y?.id?(U.append("id",String(y.id)),await Pt(Ns.edit,U,t),v.success("Success! Updated item.",{duration:1e3})):(await Pt(Ns.add,U,t),v.success("Success! Added new item.",{duration:1e3})),g(!1),p(null),k()}catch(M){v.error(M?.response?.data?.msg??M?.message??"Failed to save",{duration:1500})}},P=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Description",dataIndex:"description",key:"description",align:"center"},{title:"Subject",dataIndex:"subject_title",key:"subject_title",align:"center"},{title:"File",key:"file",align:"center",render:(I,N)=>{const W=N?.attchement;if(!W)return"-";const Y=dx(at(),`uploads/school_${N?.fk_branchID}/student/syllabus/${W}`);return e.jsx("a",{href:Y,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(I,N)=>e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>F(N)})}],[$,b]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Modal,{title:y?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{g(!1),p(null),A("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(a.Form,{form:s,layout:"vertical",onFinish:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:I=>I,children:e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{const N=I?.value??null;s.setFieldValue("sub_id",null),u(N?`${Ue.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),S(W=>!W)}},`class_${y?.id??"add"}_${h}`)}),e.jsx(a.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:I=>I,children:e.jsx(Z,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${y?.id??"add"}_${h}_${D??"none"}`)}),e.jsx(a.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(V,{placeholder:"Title"})}),e.jsx(a.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(gt,{placeholder:"Description"})}),e.jsx(a.Form.Item,{label:"File",required:!0,children:e.jsx(Mo,{token:t,value:m,onChange:A,action:cg(),filePath:"student/syllabus"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(a.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(a.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Qt,{actions:["add","export","print","download","filter"],onAdd:T,onPrint:()=>window.print()})]}),children:e.jsx(a.Form,{form:n,layout:"vertical",onFinish:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:I=>I,children:e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(a.Table,{rowKey:I=>I.id,columns:P,dataSource:O,loading:R,pagination:{current:r.page,pageSize:r.perPage,total:_,showSizeChanger:!0,onChange:(I,N)=>l({page:I,perPage:N})}})})]})}function ux({token:t}){return e.jsx(cx,{token:t})}const fs=Ue.timetable,dl=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[]},cl=t=>{if(!t)return"";const n=se(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},px=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let s=0;for(let l=0;l<n.length;l+=1)s=(s*31+n.charCodeAt(l))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]},ul=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],mx=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"};function hx({token:t}){const[n,s]=i.useState(null),[r,l]=i.useState(!1),[o,d]=i.useState(null),[c,g]=i.useState(""),[y,p]=i.useState(""),{data:m}=K(t?[Ue.master.classes.dropdown,t]:null,([u,h])=>G(u,h)),A=i.useMemo(()=>dl(m),[m]),{data:C}=K(t&&n?[n,t]:null,([u,h])=>G(u,h)),b=i.useMemo(()=>dl(C),[C]),{data:f,isLoading:x}=K(t&&o?[o,t]:null,([u,h])=>G(u,h),{revalidateOnFocus:!1}),R=i.useMemo(()=>f?.days??f?.data?.days??f?.data?.data?.days??{},[f]),{dataSource:k,daySpanByFirstKey:O}=i.useMemo(()=>{const u=Object.entries(R||{}).slice().sort((E,$)=>ul.indexOf(String(E[0]).toLowerCase())-ul.indexOf(String($[0]).toLowerCase())),h=new Map,S=[];for(const[E,$]of u){const q=(Array.isArray($)?$:[]).slice().sort((F,j)=>Number(F?.order_no||0)-Number(j?.order_no||0)),T=q.length;for(let F=0;F<T;F+=1){const j=q[F],P=j?.id||`${E}-${j?.order_no}-${F}`;F===0&&h.set(P,T),S.push({key:P,_dayKey:E,...j})}}return{dataSource:S,daySpanByFirstKey:h}},[R]),_=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(u,h)=>{const S=O.get(h.key);return S===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(ee.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(a.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:mx(u)})]}),props:{rowSpan:S}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:u=>e.jsx(a.Tag,{color:"#5080f8",style:{fontWeight:500},children:u})},{title:"Time",key:"time",width:180,render:(u,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(a.Typography.Text,{children:[cl(h?.time_from)," - ",cl(h?.time_to)]})]})},{title:"Subject",key:"subject",render:(u,h)=>{if(String(h?.is_break)==="1")return e.jsx(a.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const E=h?.subject_name||"-";return e.jsx(a.Tag,{color:px(E),style:{fontWeight:500},children:E})}},{title:"Teacher",key:"teacher",render:(u,h)=>{const S=String(h?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(a.Typography.Text,{children:S?"-":h?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(u,h)=>{const S=String(h?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(a.Typography.Text,{children:S?"-":h?.room_no||"-"})]})}}],[O]),D=u=>{u.preventDefault();const h=u.target.class_id?.value,S=u.target.section_id?.value;if(!h||!S)return;const E=A.find(F=>String(F.value)===String(h)),$=b.find(F=>String(F.value)===String(S));g(E?.label||""),p($?.label||"");const T=`${fs.byClassSection}/${h}/section/${S}`;d(T)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Qt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:D,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:u=>{s(`${Ue.master.sections.byClass}?class_id=${encodeURIComponent(String(u?.value??""))}`),l(h=>!h)}}),e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${r}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:c||y?`Timetable: ${c} ${y}`:"Timetable"}),children:e.jsx(a.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:k,columns:_,rowKey:"key",loading:x,scroll:{x:"max-content"}})})]})}const fx=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[]},pl=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],yx=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"},ml=t=>{if(!t)return"";const n=se(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},gx=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let s=0;for(let l=0;l<n.length;l+=1)s=(s*31+n.charCodeAt(l))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]};function xx({token:t}){const[n,s]=i.useState(null),[r,l]=i.useState(null),{data:o}=K(t?[Ue.assignByClass.teacherDropdown,t]:null,([C,b])=>G(C,b)),d=i.useMemo(()=>fx(o),[o]),{data:c,isLoading:g}=K(t&&r?[r,t]:null,([C,b])=>G(C,b),{revalidateOnFocus:!1}),{dataSource:y,daySpanByFirstKey:p}=i.useMemo(()=>{const b=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((k,O)=>{const _=pl.indexOf(String(k?.day_name||"").toLowerCase()),D=pl.indexOf(String(O?.day_name||"").toLowerCase());if(_!==D)return _-D;const u=Number(k?.order_no||0),h=Number(O?.order_no||0);return u!==h?u-h:String(k?.time_from||"").localeCompare(String(O?.time_from||""))}),f=new Map,x=[];let R=0;for(;R<b.length;){const k=String(b[R]?.day_name||"").toLowerCase();let O=R;for(;O<b.length&&String(b[O]?.day_name||"").toLowerCase()===k;)O+=1;const _=O-R;for(let D=R;D<O;D+=1){const u=b[D],h=u?.id||`${k}-${u?.order_no}-${D}`;D===R&&f.set(h,_),x.push({key:h,_dayKey:k,...u})}R=O}return{dataSource:x,daySpanByFirstKey:f}},[c]),m=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(C,b)=>{const f=p.get(b.key);return f===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(ee.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(a.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:yx(C)})]}),props:{rowSpan:f}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:C=>e.jsx(a.Tag,{color:"#5080f8",style:{fontWeight:500},children:C})},{title:"Time",key:"time",width:180,render:(C,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(a.Typography.Text,{children:[ml(b?.time_from)," - ",ml(b?.time_to)]})]})},{title:"Subject",key:"subject",render:(C,b)=>{if(String(b?.is_break)==="1")return e.jsx(a.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const x=b?.subject_name||"-";return e.jsx(a.Tag,{color:gx(x),style:{fontWeight:500},children:x})}},{title:"Class",key:"class",width:160,render:(C,b)=>e.jsxs(a.Tag,{color:"purple",style:{fontWeight:500},children:[b?.class_name||b?.class_id||"-"," ",b?.section_name?`(${b.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(C,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(a.Typography.Text,{children:b?.room_no||"-"})]})}],[p]),A=C=>{C.preventDefault();const b=C.target.teacher_id?.value;if(!b)return;s(b);const x=`${fs.teacherTimetable}${encodeURIComponent(String(b))}`;l(x)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Qt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{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(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(a.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:y,columns:m,rowKey:"key",loading:g,scroll:{x:"max-content"}})})]})}function hl(t){if(!t)return null;const n=String(t).trim().replaceAll(".",":");if(!n)return null;const s=n.toLowerCase(),r=s.includes("am")||s.includes("pm");let l=0,o=0,d=0;if(r){const g=s.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!g)return null;l=Number.parseInt(g[1],10),o=Number.parseInt(g[2],10),d=Number.parseInt(g[3]||"0",10);const y=g[4].toLowerCase();y==="pm"&&l<12&&(l+=12),y==="am"&&l===12&&(l=0)}else{const c=n.split(":").map(g=>g.trim());if(c.length<2)return null;l=Number.parseInt(c[0],10),o=Number.parseInt(c[1],10),d=Number.parseInt(c[2]||"0",10)}return![l,o,d].every(c=>Number.isFinite(c))||l<0||l>23||o<0||o>59||d<0||d>59?null:se().hour(l).minute(o).second(d).millisecond(0)}function Ha(t,n){const s=Number.parseInt(n,10);return!Number.isFinite(s)||s<=0||!t||!t.isValid?.()?null:t.add(s,"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[]},Za={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},bx=t=>{const n=Za[String(t)];return n?n.charAt(0).toUpperCase()+n.slice(1):String(t)},jx=({token:t,classId:n,sectionId:s,subjectId:r,value:l,onChange:o,disabled:d})=>{const c=t&&n&&s&&r?`${fs.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(n))}§ion_id=${encodeURIComponent(String(s))}`:null,{data:g,isLoading:y}=K(c?[c,t]:null,([m,A])=>G(m,A),{revalidateOnFocus:!1}),p=i.useMemo(()=>Xn(g?.data??g).map(A=>({value:A?.value??A?.id,label:A?.label??A?.name??A?.teacher_name??""})),[g]);return e.jsx(a.Select,{placeholder:d?"-":"Select Teacher",loading:y,disabled:d,style:{width:"100%"},options:p,value:l?String(l):void 0,onChange:m=>o?.(m),showSearch:!0,optionFilterProp:"label"})};function Sx({token:t}){const[n]=a.Form.useForm(),[s,r]=i.useState({classId:null,sectionId:null,dayKey:"1",daysEnabled:{0:!1,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}),[l,o]=i.useState({startTime:null,endTime:null,duration:40,interval:0,roomNo:"",tiffinEnabled:!1,tiffinAfterPeriod:3,tiffinDuration:20}),[d,c]=i.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[g,y]=i.useState(!1),p=i.useMemo(()=>t?Ue.master.classes.dropdown:null,[t]),{data:m}=K(p?[p,t]:null,([T,F])=>G(T,F)),A=i.useMemo(()=>Xn(m).map(T=>({value:T?.value??T?.id,label:T?.label??T?.title??""})),[m]),C=i.useMemo(()=>!t||!s.classId?null:`${Ue.master.sections.byClass}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:b}=K(C?[C,t]:null,([T,F])=>G(T,F)),f=i.useMemo(()=>Xn(b).map(T=>({value:T?.value??T?.id,label:T?.label??T?.title??""})),[b]),x=i.useMemo(()=>!t||!s.classId?null:`${Ue.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:R}=K(x?[x,t]:null,([T,F])=>G(T,F)),k=i.useMemo(()=>Xn(R).map(T=>({value:T?.value??T?.id,label:T?.label??T?.title??""})),[R]),O=i.useMemo(()=>Array.isArray(d?.[s.dayKey])?d[s.dayKey]:[],[s.dayKey,d]),_=i.useCallback((T,F,j)=>{c(P=>{const I={...P},N=Array.isArray(I[T])?I[T].slice():[];return N[F]={...N[F]??{},...j},I[T]=N,I})},[]),D=i.useCallback((T,F)=>{c(j=>{const P={...j},I=Array.isArray(P[T])?P[T].slice():[];return I.splice(F,1),P[T]=I.map((N,W)=>({...N,order_no:W+1})),P})},[]),u=i.useCallback(T=>{c(F=>{const j={...F},P=Array.isArray(j[T])?j[T].slice():[];let I=null,N=null;const W=P[P.length-1];if(W?.time_to){const Y=hl(W.time_to),B=Number.parseInt(l.interval,10)||0,U=Number.parseInt(l.duration,10)||0,M=Ha(Y,B),L=U>0?Ha(M,U):null;I=M?.isValid?.()?M.format("HH:mm:ss"):null,N=L?.isValid?.()?L.format("HH:mm:ss"):null}return P.push({order_no:P.length+1,subject_id:"",teacher_id:"",room_no:l.roomNo??"",time_from:I,time_to:N,is_break:!1}),j[T]=P,j})},[l.duration,l.interval,l.roomNo]),h=i.useCallback(()=>{const T=l.startTime,F=l.endTime,j=Number.parseInt(l.duration,10),P=Number.parseInt(l.interval,10);if(!T||!T.isValid?.()){v.error("Start time is required",{duration:1500});return}if(!F||!F.isValid?.()){v.error("End time is required",{duration:1500});return}if(!F.isAfter(T)){v.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(j)||j<=0){v.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(P)||P<0){v.error("Interval must be 0 or more",{duration:1500});return}const I=()=>{const N=[];let W=T;for(let Y=0;Y<50;Y+=1){const B=Ha(W,j);if(!B||!B.isValid?.()||B.isAfter(F))break;N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:l.roomNo??"",time_from:W.format("HH:mm:ss"),time_to:B.format("HH:mm:ss"),is_break:!1});const U=Ha(B,P);if(!U||!U.isValid?.()||U.isAfter(F)||U.isSame(F))break;W=U}if(l.tiffinEnabled){const Y=Math.max(0,Number.parseInt(l.tiffinAfterPeriod,10)||0),B=Math.max(0,Number.parseInt(l.tiffinDuration,10)||0),U=Math.min(Y,N.length);if(U>0&&B>0){const M=N[U-1],L=M?.time_to?hl(M.time_to):null,z=L?Ha(L,B):null;L?.isValid?.()&&z?.isValid?.()&&!z.isAfter(F)&&N.splice(U,0,{order_no:U+1,subject_id:"",teacher_id:"",room_no:l.roomNo??"",time_from:L.format("HH:mm:ss"),time_to:z.format("HH:mm:ss"),is_break:!0})}}return N.map((Y,B)=>({...Y,order_no:B+1}))};c(N=>{const W={...N};return Object.keys(Za).forEach(Y=>{s.daysEnabled?.[Y]&&(W[Y]=I())}),W}),v.success("Generated schedule",{duration:1e3})},[l,s.daysEnabled]),S=i.useCallback(()=>{const T=localStorage.getItem("genrall_settings"),j=(T?JSON.parse(T):{})?.session_id??"1",P=s.classId,I=s.sectionId,N=Object.keys(Za).map(W=>{const Y=(Array.isArray(d?.[W])?d[W]:[]).map((B,U)=>({order_no:U+1,subject_id:B?.is_break?0:B?.subject_id??null,teacher_id:B?.is_break?0:B?.teacher_id??null,room_no:B?.room_no??"",time_from:B?.time_from??null,time_to:B?.time_to??null,is_break:B?.is_break?1:0}));return{day:Za[W],class_id:P,section_id:I,session_id:j,args:Y}});return{class_id:P,section_id:I,session_id:j,days:N}},[s.classId,s.sectionId,d]),E=i.useCallback(async()=>{if(!s.classId||!s.sectionId){v.error("Please select Class and Section",{duration:1500});return}const T=S(),F=Array.isArray(T?.days)?T.days:[];if(!F.some(I=>Array.isArray(I?.args)&&I.args.length>0)){v.error("No timetable rows to submit",{duration:1500});return}const P=I=>{const N=I?.is_break;return N===1||N==="1"||N===!0?!0:String(N??"").toLowerCase()==="true"};F.some(I=>(Array.isArray(I?.args)?I.args:[]).some(N=>String(N?.time_from??"").trim()&&String(N?.time_to??"").trim()?P(N)?!1:!String(N?.subject_id??"").trim()||!String(N?.teacher_id??"").trim():!0)),y(!0);try{const I=fs.save,N=I==="api/timetable/save"?"timetable/save":null,W=async U=>{const M=await os(U,T,t);if(M&&typeof M=="object")return M;throw new Error("No response from server")};let Y;try{Y=await W(I)}catch{Y=await W(N)}const B=String(Y?.msg??"");if(String(Y?.Status)==="Success"){if(Array.isArray(Y?.data)&&Y.data.length===0&&B){v.error(B,{duration:3e3});return}v.success(B||"Weekly Time Table added successfully!",{duration:1200});return}v.error(B||"Failed to add time table",{duration:3e3})}catch(I){v.error(I?.response?.data?.msg??I?.message??"Failed to add time table",{duration:3e3})}finally{y(!1)}},[S,s.classId,s.sectionId,t]),$=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:T=>T?se(T,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:T=>T?se(T,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(T,F,j)=>e.jsx(a.Switch,{checked:!!F?.is_break,onChange:P=>{_(s.dayKey,j,{is_break:P,subject_id:P?"":F?.subject_id??"",teacher_id:P?"":F?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(T,F,j)=>e.jsx(a.Select,{placeholder:F?.is_break?"-":"Select Subject",disabled:!!F?.is_break,style:{width:"100%"},options:k,value:F?.subject_id?String(F.subject_id):void 0,onChange:P=>_(s.dayKey,j,{subject_id:P,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(T,F,j)=>e.jsx(jx,{token:t,classId:s.classId,sectionId:s.sectionId,subjectId:F?.subject_id,disabled:!!F?.is_break||!F?.subject_id,value:F?.teacher_id,onChange:P=>_(s.dayKey,j,{teacher_id:P})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(T,F,j)=>e.jsx(a.Input,{value:F?.room_no??"",onChange:P=>_(s.dayKey,j,{room_no:P.target.value})})},{title:"Action",key:"action",width:90,render:(T,F,j)=>e.jsx(a.Popconfirm,{title:"Delete this row?",onConfirm:()=>D(s.dayKey,j),children:e.jsx(a.Button,{danger:!0,type:"text",children:"Delete"})})}],[s.classId,s.dayKey,s.sectionId,D,k,t,_]),q=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(a.Form,{form:n,layout:"vertical",initialValues:{duration:l.duration,interval:l.interval,roomNo:l.roomNo,tiffinEnabled:l.tiffinEnabled,tiffinAfterPeriod:l.tiffinAfterPeriod,tiffinDuration:l.tiffinDuration},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(a.Form.Item,{label:"Class",required:!0,children:e.jsx(a.Select,{placeholder:"Select Class",options:A,value:s.classId?String(s.classId):void 0,onChange:T=>{r(F=>({...F,classId:T,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(a.Form.Item,{label:"Section",required:!0,children:e.jsx(a.Select,{placeholder:"Select Section",options:f,value:s.sectionId?String(s.sectionId):void 0,onChange:T=>r(F=>({...F,sectionId:T})),disabled:!s.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(a.Form.Item,{label:"Start Time",required:!0,children:e.jsx(a.TimePicker,{value:l.startTime,onChange:T=>o(F=>({...F,startTime:T})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(a.Form.Item,{label:"End Time",required:!0,children:e.jsx(a.TimePicker,{value:l.endTime,onChange:T=>o(F=>({...F,endTime:T})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(a.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(a.InputNumber,{min:1,value:l.duration,onChange:T=>o(F=>({...F,duration:T})),style:{width:"100%"}})}),e.jsx(a.Form.Item,{label:"Interval (min)",children:e.jsx(a.InputNumber,{min:0,value:l.interval,onChange:T=>o(F=>({...F,interval:T})),style:{width:"100%"}})}),e.jsx(a.Form.Item,{label:"Room No",children:e.jsx(a.Input,{value:l.roomNo,onChange:T=>o(F=>({...F,roomNo:T.target.value}))})}),e.jsx(a.Form.Item,{label:"Tiffin Break",children:e.jsxs(a.Space,{children:[e.jsx(a.Switch,{checked:l.tiffinEnabled,onChange:T=>o(F=>({...F,tiffinEnabled:T}))}),e.jsx(a.Typography.Text,{type:"secondary",children:l.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(a.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(a.InputNumber,{min:1,value:l.tiffinAfterPeriod,onChange:T=>o(F=>({...F,tiffinAfterPeriod:T})),style:{width:"100%"},disabled:!l.tiffinEnabled})}),e.jsx(a.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(a.InputNumber,{min:1,value:l.tiffinDuration,onChange:T=>o(F=>({...F,tiffinDuration:T})),style:{width:"100%"},disabled:!l.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(a.Button,{onClick:h,children:"Generate"}),e.jsx(a.Button,{type:"primary",loading:g,onClick:E,children:"Save"})]})]})})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(a.Space,{children:[e.jsx(a.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(a.Select,{style:{width:160},value:s.dayKey,onChange:T=>r(F=>({...F,dayKey:T})),options:Object.keys(Za).map(T=>({value:String(T),label:bx(T)}))}),e.jsx(a.Button,{onClick:()=>u(s.dayKey),children:"Add Row"})]}),children:e.jsx(a.Table,{rowKey:(T,F)=>`${s.dayKey}_${F}`,columns:$,dataSource:O,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(a.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(a.Tabs,{type:"card",items:[{key:"create",label:"Create",children:q},{key:"routine",label:"Routine",children:e.jsx(hx,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(xx,{token:t})}]})]})}function vx({token:t}){return e.jsx(Sx,{token:t})}function wx(){return null}const la=t=>t??localStorage.getItem("authToken")??"",_x=(t,n)=>{const s=String(t??""),r=String(n);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Qe={organization:{get:"api/branchapi/generalSettings/getorganizationsettingsData",save:"api/branchapi/generalSettings/addorganizationSetting",currencyDropdown:"api/branchapi/generalSettings/currencyDropdown",countryCodeDropdown:"api/branchapi/generalSettings/contrycodeDropdown",timezoneDropdown:"api/branchapi/generalSettings/timezoneDropdown",boardsDropdown:"api/branchapi/generalSettings/getAffliatedBoardsDropDown",uploadLogo:"api/superAdmin/upload_logo",uploadSignature:"api/branchapi/generalSettings/upload_signature",uploadFirebaseJson:"api/branchapi/generalSettings/firebaseJsonUpload"},academicYear:{table:"api/branchapi/generalSettings/sessiontable",add:"api/branchapi/generalSettings/addsession",setActive:"api/branchapi/generalSettings/setsession",remove:"api/branchapi/generalSettings/deletesession"},feeReceiptSetting:{get:"api/branchapi/generalSettings/feesReceiptSettingData",save:"api/branchapi/generalSettings/feesReceiptSetting"},marksheetSetting:{templateTypes:"api/branchapi/GeneralSettings/getmarkssheetTemplate",classDropdown:"api/exam/exam/getClassforAssignMarksSheetType",assignedTable:"api/branchapi/GeneralSettings/getassign_templete",assign:"api/branchapi/GeneralSettings/assign_templete",remove:"api/branchapi/GeneralSettings/deleteTemplate"},legalPages:{get:"api/branchapi/generalSettings/getlegalpage",termsSave:"api/branchapi/generalSettings/terms",privacySave:"api/branchapi/generalSettings/privacy",aboutSave:"api/branchapi/generalSettings/about_us"},feesInfo:{get:"api/branchapi/generalSettings/getFeesInfo",save:"api/branchapi/generalSettings/addFeesInfo",statesDropdown:"api/superAdmin/states"},payrollSettings:{table:"api/branchapi/GeneralSettings/getsetting_allowances_dedection",add:"api/branchapi/GeneralSettings/addsetting_allowances_dedection",edit:"api/branchapi/GeneralSettings/updatesetting_allowances_dedection",remove:"api/branchapi/GeneralSettings/deletesetting_allowances_dedection",byId:"api/branchapi/GeneralSettings/getsetting_allowances_dedectionById"},paymentGateway:{get:"api/payment_gateway/PaymentProcess/getPaymentGatewayList",save:"api/payment_gateway/PaymentProcess"},smsGateway:{get:"api/branchapi/generalSettings/smsalertsettingData",save:"api/branchapi/generalSettings/addsmsalertsetting"},smsDetails:{get:"api/branchapi/generalSettings/smsdetailsData",save:"api/branchapi/generalSettings/addsmsdetails"},smsTemplates:{table:"api/branchapi/communication/Sms/templatetableList",add:"api/branchapi/communication/Sms/addtemplate",edit:"api/branchapi/communication/Sms/edittemplate",delete:"api/branchapi/communication/Sms/deletetemplate",changeStatus:"api/branchapi/communication/Sms/changetemplatestatus",templateDropdown:"api/branchapi/communication/Sms/templatedropdown"},smsCompose:{templateDropdown:"api/branchapi/communication/Sms/templatedropdown",classDropdown:"api/branchapi/academy/classdropdownlist",sectionByClass:"api/branchapi/academy/sectionoftheClass",roleDropdown:"api/Branch/getRoledropdownforBranch",staffSearch:"api/branchapi/staff/staffsearchbyKeywords",studentDropdown:"api/branchapi/student/studentDropdown",sendMessage:"api/branchapi/communication/Message"},chat:{whatsappBaseUrl:"",groupList:"api/branchapi/communication/Message/whatappgroupList",groupCreate:"api/branchapi/communication/Message/createWhatsappGroup",teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classDropdown:"api/branchapi/academy/classdropdownlist",sectionByClass:"api/branchapi/academy/sectionoftheClass",roleDropdown:"api/Branch/getRoledropdownforBranch"},getMessages:t=>`${String(t??"")}/api/messages`,getSendMessages:t=>`${String(t??"")}/api/messages/send`},Cx=t=>_x(At(),t),Ax=async({baseUrl:t,page:n=1,perPage:s=10},r)=>{const l=t.includes("?")?"&":"?",o=`${t}${l}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(s))}`;return G(o,la(r))},Dx=async(t,n)=>G(t,la(n)),xn=async(t,n,s)=>Ge(t,n,la(s)),Eo=async(t,n,s)=>tt(t,n,la(s)),fr=async(t,n,s)=>Ze(t,n,la(s)),Tx=async(t,n,s)=>os(t,{arg:n},la(s)),Fo=async(t,n,s)=>an(t,{arg:n},la(s)),$o=({baseUrl:t,page:n=1,perPage:s=10,token:r})=>K(r&&t?[t,n,s,r]:null,([o,d,c,g])=>Ax({baseUrl:o,page:d,perPage:c},g)),Dt=({url:t,token:n})=>K(n&&t?[t,n]:null,([r,l])=>Dx(r,l)),Rx={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function Ix({value:t,onChange:n,placeholder:s}){const[r,l]=i.useState(t??""),o=i.useMemo(()=>typeof t=="string"?t:r,[r,t]);return e.jsx("div",{style:Rx,children:e.jsx(oo,{html:o||"",onChange:d=>{const c=d?.target?.value??"";l(c),n?.(c)},style:{outline:"none",minHeight:280},placeholder:s})})}function Xt({title:t,actions:n,children:s,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:s})}const kx=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function yr({token:t,title:n,fetchUrl:s,saveUrl:r,fieldName:l,initialHtmlFieldName:o}){const d=i.useRef(null),c=Dt({url:s,token:t}),y=i.useMemo(()=>kx(c.data),[c.data])?.[o??l]??"",[p,m]=i.useState("");i.useEffect(()=>{m(typeof y=="string"?y:"")},[y]);const A=()=>m(typeof y=="string"?y:""),C=()=>{const x=new Blob([String(p??"")],{type:"text/html"}),R=URL.createObjectURL(x),k=document.createElement("a");k.href=R,k.download=`${String(n??"legal").toLowerCase().replaceAll(" ","-")}.html`,k.click(),URL.revokeObjectURL(R)},b=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:A},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:C,disabled:!p}],[p,y]),f=async x=>{x.preventDefault();try{(await Fo(r,{[l]:p??""},t))?.Status==="Success"?v.success("Updated successfully.",{duration:1e3}):v.success("Updated.",{duration:1e3}),c.mutate?.()}catch(R){v.error(R?.response?.data?.msg??R?.message??"Failed to update.",{duration:1500})}};return c.isLoading&&!c.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Xt,{title:n,actions:b,children:e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:f,children:[e.jsx(Ix,{value:p,onChange:m,placeholder:`Enter ${n} content...`}),e.jsx(a.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Update"})})]})})})]})}const Px=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ox=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function en({token:t,value:n,onChange:s,action:r,accept:l,maxCount:o=1,previewUrl:d,data:c}){const g=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),y=i.useMemo(()=>n?d||(Ox(n)?n:""):"",[d,n]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[y?e.jsx("img",{src:y,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(a.Upload,{maxCount:o,action:r,data:c,accept:l,headers:g,onChange:p=>{if(p?.file?.status==="removed"&&s?.(""),p?.file?.status==="done"){const m=Px(p?.file?.response);m&&s?.(m)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})]})}const oa=Qe.organization,Mx=()=>Cx(oa.uploadFirebaseJson),Ex=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],Fx=({token:t})=>Dt({url:oa.get,token:t}),$x=({token:t})=>Dt({url:oa.currencyDropdown,token:t}),Ux=({token:t})=>Dt({url:oa.countryCodeDropdown,token:t}),Bx=({token:t})=>Dt({url:oa.timezoneDropdown,token:t}),Nx=({token:t})=>Dt({url:oa.boardsDropdown,token:t}),Fn=t=>Ex(t?.data),Lx=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Uo=t=>{const n=qt(t);if(n)return n;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},qx=(t,n)=>{const s=`${t||""}`.trim();if(!s)return"";if(/^https?:\/\//i.test(s))return s;const r=Uo(n),l=s.startsWith("/")?s.slice(1):s;return Lx(at(),`uploads/school_${r}/schoolFile/${l}`)},fl={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},zx=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),yl=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],gl=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],Yx=t=>{const n=t?.data;return Array.isArray(n?.data)?n.data[0]??null:Array.isArray(n)?n[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},Wx=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,Vx=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function Hx({token:t}){const n=i.useRef(null),s=Fx({token:t}),r=$x({token:t}),l=Ux({token:t}),o=Bx({token:t}),d=Nx({token:t}),c=i.useMemo(()=>Yx(s.data),[s.data]),g=i.useMemo(()=>Wx(s.data),[s.data]),y=i.useMemo(()=>Vx(s.data),[s.data]),p=i.useMemo(()=>Fn(r),[r.data]),m=i.useMemo(()=>Fn(l),[l.data]),A=i.useMemo(()=>Fn(o),[o.data]),C=i.useMemo(()=>Fn(d),[d.data]),[b,f]=i.useState(null),[x,R]=i.useState(null),[k,O]=i.useState(null),[_,D]=i.useState(null),[u,h]=i.useState([]),[S,E]=i.useState("No"),[$,q]=i.useState("yes"),[T,F]=i.useState("no"),[j,P]=i.useState("Yes"),[I,N]=i.useState(""),[W,Y]=i.useState(""),[B,U]=i.useState(!1),[M,L]=i.useState(""),[z,ne]=i.useState(null),[X,J]=i.useState(null),[H,Q]=i.useState(null),[ce,De]=i.useState(null),le=()=>{const we=(()=>{try{const Ae=c?.weekly_off;if(!Ae)return[];const Fe=Array.isArray(Ae)?Ae:JSON.parse(Ae);return Array.isArray(Fe)?Fe.filter(Boolean).map(me=>({value:me,label:me})):[]}catch{return[]}})();h(we),f(p.find(Ae=>Ae?.value===c?.currency)??null),R(m.find(Ae=>Ae?.value===c?.country_code)??null),O(A.find(Ae=>Ae?.value===c?.time_zone)??null),D(C.find(Ae=>Ae?.value===c?.affliated_board_id)??null),N(c?.logo??""),Y(c?.json_file??""),E(c?.attendance_salary_calculation??"No"),q(c?.salary_period??"yes"),F(c?.multiple_shift??"no"),P(c?.readmission_charges??"Yes"),ne(g?.in_from?se(g.in_from,"h:mm A"):null),J(g?.in_to?se(g.in_to,"h:mm A"):null),Q(g?.out_from?se(g.out_from,"h:mm A"):null),De(g?.out_to?se(g.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&le()},[c,p,m,A,C]);const ue=()=>{n.current?.reset?.(),le()},oe=()=>{const we=new FormData(n.current??void 0),Ae=Object.fromEntries(we.entries());Ae.weekly_off_day=u.map(Re=>Re?.value).filter(Boolean);const Fe=new Blob([JSON.stringify(Ae,null,2)],{type:"application/json"}),me=URL.createObjectURL(Fe),de=document.createElement("a");de.href=me,de.download="organization-setting.json",de.click(),URL.revokeObjectURL(me)},Ce=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:ue},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:oe,disabled:!c}],[c,u]),Ne=async we=>{we.preventDefault();try{const Ae=new FormData(we.target);Ae.set("currency",b?.value??""),Ae.set("code",x?.value??""),Ae.set("time_zone",k?.value??""),Ae.set("affliated_board_id",_?.value??""),Ae.set("board_name",_?.label??""),Ae.set("attendance_salary_calculation",S),Ae.set("salary_period",$),Ae.set("multiple_shift",T),Ae.set("readmission_charges",j),u.forEach(de=>{de?.value&&Ae.append("weekly_off_day[]",de.value)}),Ae.set("logo",I??""),Ae.set("json_file",W??""),Ae.set("server_key",y?.server_key??""),Ae.set("in_time_start",z?se(z).format("h:mm A"):""),Ae.set("in_time_end",X?se(X).format("h:mm A"):""),Ae.set("out_time_start",H?se(H).format("h:mm A"):""),Ae.set("out_time_end",ce?se(ce).format("h:mm A"):""),await xn(oa.save,Ae,t);const me={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:I||c?.logo||"",affliated_board_id:_?.value??c?.affliated_board_id??"",board_name:_?.label??c?.board_name??"",multiple_shift:T??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(me)),v.success("Organization settings saved.",{duration:1e3}),s.mutate?.()}catch(Ae){v.error(Ae?.response?.data?.msg??Ae?.message??"Failed to save settings.",{duration:1500})}},et=S==="Yes";return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Xt,{title:"Organization",actions:Ce,children:e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:n,onSubmit:Ne,children:[e.jsxs("div",{style:fl,children:[e.jsx(V,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(Z,{label:"Currency*",options:p,value:b,onChange:we=>f(we)}),e.jsx("input",{type:"hidden",name:"currency",value:b?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Default Country Code*",options:m,value:x,onChange:we=>R(we)}),e.jsx("input",{type:"hidden",name:"code",value:x?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Time Zone*",options:A,value:k,onChange:we=>O(we)}),e.jsx("input",{type:"hidden",name:"time_zone",value:k?.value??""})]}),e.jsx(V,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(V,{type:"number",name:"admission_start_number",label:"Admission Start Number*",required:!0,defaultValue:c?.admission_no_prefix??c?.admission_start_number??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Re-admission Charges"}),e.jsx(a.Radio.Group,{options:yl,optionType:"button",buttonStyle:"solid",value:j,onChange:we=>P(we.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:j})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Weekly off Day",options:zx,isMulti:!0,value:u,onChange:we=>h(we??[])}),u.map(we=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:we.value},we.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm A",value:z,onChange:we=>ne(we),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:z?se(z).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time End*"}),e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm A",value:X,onChange:we=>J(we),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:X?se(X).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time Start*"}),e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm A",value:H,onChange:we=>Q(we),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:H?se(H).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time End*"}),e.jsx(a.TimePicker,{use12Hours:!0,format:"h:mm A",value:ce,onChange:we=>De(we),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:ce?se(ce).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Period"}),e.jsx(a.Radio.Group,{options:gl,optionType:"button",buttonStyle:"solid",value:$,onChange:we=>q(we.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:$})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(a.Radio.Group,{options:yl,optionType:"button",buttonStyle:"solid",value:S,onChange:we=>E(we.target.value)}),e.jsx("input",{type:"hidden",name:"attendance_salary_calculation",value:S})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Multiple Shift"}),e.jsx(a.Radio.Group,{options:gl,optionType:"button",buttonStyle:"solid",value:T,onChange:we=>F(we.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:T})]}),et?e.jsx(V,{type:"number",name:"late_absent_day",label:"No of Late",defaultValue:c?.late_absent_day??""}):e.jsx("input",{type:"hidden",name:"late_absent_day",value:""})]}),e.jsx(a.Divider,{}),e.jsxs("div",{style:fl,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(a.Upload,{action:`${at()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${Uo(t)}/schoolFile`},headers:{Authorization:t},maxCount:1,accept:"image/*",onChange:we=>{if(we.file.status==="removed"&&N(""),we.file.status==="done"){const Ae=we.file.response?.data??we.file.response?.file??"";N(String(Ae??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:I?"Change":"Upload"})}),I&&e.jsxs("div",{style:{marginTop:8,display:"flex",alignItems:"center",gap:8},children:[e.jsx("a",{style:{fontSize:12,color:"#1677ff",textDecoration:"underline",cursor:"pointer"},onClick:()=>{L(qx(I,t)),U(!0)},children:"View existing logo"}),e.jsx("a",{style:{fontSize:12,color:"#1677ff",textDecoration:"underline",cursor:"pointer"},onClick:()=>N(""),children:"Remove"})]}),e.jsx("input",{type:"hidden",name:"logo",value:I??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Select Affiliated Board",options:C,value:_,onChange:we=>D(we)}),e.jsx("input",{type:"hidden",name:"affliated_board_id",value:_?.value??""}),e.jsx("input",{type:"hidden",name:"board_name",value:_?.label??""})]}),e.jsx(gt,{label:"Address",name:"address",rows:3,defaultValue:c?.location_name??c?.address??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Json for Notification"}),e.jsx(en,{token:t,action:Mx(),value:W,accept:".json",onChange:we=>Y(we)}),e.jsx("input",{type:"hidden",name:"json_file",value:W??""})]})]}),e.jsx(a.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(a.Modal,{open:B,onCancel:()=>{U(!1),L("")},footer:null,width:500,closable:!0,children:M?e.jsx("img",{src:M,alt:"Organization Logo",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(be,{children:"No logo found"})})]})}function Kx({token:t}){return e.jsx(Hx,{token:t})}const Zn=Qe.academicYear,Gx=({token:t,page:n=1,perPage:s=10})=>$o({baseUrl:Zn.table,token:t,page:n,perPage:s}),Jx={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Qx=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[],Xx=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function Zx({token:t}){const[n,s]=i.useState({page:1,rowsPerPage:10}),[r,l]=i.useState(!1),[o,d]=i.useState(()=>{const u=se(),h=se().add(1,"year");return`${u.format("YYYY")}-${h.format("YYYY")}`}),[c,g]=i.useState(se()),[y,p]=i.useState(se().add(1,"year")),{isLoading:m,data:A,mutate:C}=Gx({token:t,page:n.page,perPage:n.rowsPerPage}),b=i.useMemo(()=>Qx(A),[A]),f=i.useMemo(()=>Xx(A,b.length),[A,b.length]),x=async()=>{if(!o){v.error("Session name is required.");return}if(y&&c&&se(y).isBefore(c)){v.error("End date must be after start date.");return}try{const u=new FormData;u.set("name",o),u.set("start_date",c?se(c).format("YYYY-MM-DD"):""),u.set("end_date",y?se(y).format("YYYY-MM-DD"):""),await xn(Zn.add,u,t),v.success("Academic year added.",{duration:1e3}),l(!1),C?.()}catch(u){v.error(u?.response?.data?.msg??u?.message??"Failed to add academic year.",{duration:1500})}},R=async u=>{try{const h=new FormData;h.set("session",String(u)),await Eo(Zn.setActive,h,t);const S=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...S,session_id:String(u)})),v.success("Academic year activated.",{duration:1e3}),C?.()}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to activate academic year.",{duration:1500})}},k=async u=>{try{await C(fr(Zn.remove,u,t)),v.success("Academic year deleted.",{duration:1e3})}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to delete academic year.",{duration:1500})}},O=()=>{const u=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),h=URL.createObjectURL(u),S=document.createElement("a");S.href=h,S.download="academic-years.json",S.click(),URL.revokeObjectURL(h)},_=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>l(!0)},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:()=>C?.()},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:O,disabled:b.length===0}],[b.length,C]),D=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name"},{title:"Start Date",dataIndex:"start_date",key:"start_date"},{title:"End Date",dataIndex:"end_date",key:"end_date"},{title:"Active",key:"active",render:(u,h)=>{const S=h.status==="Active";return e.jsxs("span",{children:[e.jsx(a.Popconfirm,{title:S?"Deactivate Academic Year?":"Activate Academic Year?",description:S?"Deactivate is not allowed. Activate another session to switch.":"This will set this year as the current academic session.",onConfirm:()=>{S?v.error("Deactivate is not allowed. Activate another session to switch."):R(h.id)},okText:"Yes",cancelText:"No",children:e.jsx(a.Switch,{checked:S})}),S&&e.jsx(a.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(u,h)=>e.jsx(a.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>k(h.id),okText:"Yes",cancelText:"No",children:e.jsx(a.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,b.length]);return e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Xt,{title:"Academic Year",actions:_,children:e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(a.Table,{rowKey:"id",dataSource:b,columns:D,loading:m,pagination:{current:n.page,pageSize:n.rowsPerPage,total:f,showSizeChanger:!0,onChange:(u,h)=>s({page:u,rowsPerPage:Number(h)})}})})}),e.jsx(a.Modal,{open:r,onCancel:()=>l(!1),footer:null,title:"Add Academic Year",children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:Jx,children:[e.jsx(V,{label:"Session Name*",value:o,onChange:u=>d(u.target.value)}),e.jsxs("div",{children:[e.jsx(He,{Desplay:"Start Date*",value:c,onChange:u=>g(u),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?se(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(He,{Desplay:"End Date*",value:y,onChange:u=>p(u),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:y?se(y).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ie,{value:"Submit",type:"button",onClick:x}),e.jsx(a.Button,{onClick:()=>l(!1),children:"Cancel"})]})]})})]})}function eb({token:t}){return e.jsx(Zx,{token:t})}const Bo=Qe.feeReceiptSetting,tb=({token:t})=>Dt({url:Bo.get,token:t}),Ls={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},ab=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function nb({token:t}){const n=i.useRef(null),s=tb({token:t}),r=i.useMemo(()=>ab(s.data),[s.data]),[l,o]=i.useState(""),[d,c]=i.useState(!1),[g,y]=i.useState(!1),[p,m]=i.useState(!1),[A,C]=i.useState("0"),[b,f]=i.useState("0"),[x,R]=i.useState("0"),[k,O]=i.useState(!1),[_,D]=i.useState(!1),[u,h]=i.useState(""),[S,E]=i.useState("0"),[$,q]=i.useState("0"),[T,F]=i.useState("0"),[j,P]=i.useState(""),[I,N]=i.useState(!1),W=()=>{o(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),y(String(r?.address??"0")==="1"),m(String(r?.gardian_name??"0")==="1"),C(String(r?.authorized_signatory??"0")),f(String(r?.parent_signatory??"0")),R(String(r?.dynamic_qr_code_device??"0")),O(String(r?.sequence_payment??"0")==="1"),D(String(r?.previois_fees??"0")==="1"),h(r?.title??""),E(String(r?.class_id??"0")),q(String(r?.discount??"0")),F(String(r?.sections??"0")),P(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&W()},[r]);const Y=()=>{n.current?.reset?.(),W()},B=()=>{const L={number_of_receipt:l,rollnumber:d?1:0,address:g?1:0,gardianname:p?1:0,authorizedsignatory:A,parentsignatory:b,dynamic_qr_code_device:x,sequence_payment:k?1:0,previois_fees:_?1:0,upfront_payment_months:j,title:u,class_id:S,discount:$,sections:T},z=new Blob([JSON.stringify(L,null,2)],{type:"application/json"}),ne=URL.createObjectURL(z),X=document.createElement("a");X.href=ne,X.download="fee-receipt-setting.json",X.click(),URL.revokeObjectURL(ne)},U=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:Y},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:B,disabled:!r}],[r,l,d,g,p,A,b,x,k,_,j,u,S,$,T]),M=async L=>{L.preventDefault(),N(!0);try{const z=new FormData;z.set("number_of_receipt",String(l??"")),z.set("rollnumber",d?"1":"0"),z.set("address",g?"1":"0"),z.set("gardianname",p?"1":"0"),z.set("authorizedsignatory",String(A??"0")),z.set("parentsignatory",String(b??"0")),z.set("dynamic_qr_code_device",String(x??"0")),z.set("sequence_payment",k?"1":"0"),z.set("previois_fees",_?"1":"0"),z.set("upfront_payment_months",String(j??"")),z.set("title",String(u??"")),z.set("class_id",String(S??"0")),z.set("discount",String($??"0")),z.set("sections",String(T??"0")),await xn(Bo.save,z,t),v.success("Fee receipt settings updated.",{duration:1e3}),s.mutate?.()}catch(z){v.error(z?.response?.data?.msg??z?.message??"Failed to update settings.",{duration:1500})}finally{N(!1)}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Xt,{title:"Fee Receipt Setting",actions:U,children:e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:n,onSubmit:M,children:[e.jsxs("div",{style:Ls,children:[e.jsx(V,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:l,onChange:L=>o(L.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(a.Checkbox,{checked:d,onChange:L=>c(L.target.checked),children:"Show Roll Number in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Address"}),e.jsx(a.Checkbox,{checked:g,onChange:L=>y(L.target.checked),children:"Show address in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Guardian Name"}),e.jsx(a.Checkbox,{checked:p,onChange:L=>m(L.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(a.Divider,{}),e.jsxs("div",{style:Ls,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(a.Radio.Group,{value:A,onChange:L=>C(L.target.value),children:[e.jsx(a.Radio,{value:"1",children:"Enable"}),e.jsx(a.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Parent Signatory"}),e.jsxs(a.Radio.Group,{value:b,onChange:L=>f(L.target.value),children:[e.jsx(a.Radio,{value:"1",children:"Enable"}),e.jsx(a.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Dynamic QR Code Device"}),e.jsxs(a.Radio.Group,{value:x,onChange:L=>R(L.target.value),children:[e.jsx(a.Radio,{value:"1",children:"Enable"}),e.jsx(a.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(a.Divider,{}),e.jsxs("div",{style:Ls,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(a.Checkbox,{checked:k,onChange:L=>O(L.target.checked),children:"Student can pay in sequence"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Previous Fees"}),e.jsx(a.Checkbox,{checked:_,onChange:L=>D(L.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(V,{type:"text",name:"title",label:"Title",value:u,onChange:L=>h(L.target.value)}),e.jsxs("div",{style:{display:"none"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Class"}),e.jsxs(a.Radio.Group,{value:S,onChange:L=>E(L.target.value),children:[e.jsx(a.Radio,{value:"1",children:"Enable"}),e.jsx(a.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Discount"}),e.jsxs(a.Radio.Group,{value:$,onChange:L=>q(L.target.value),children:[e.jsx(a.Radio,{value:"1",children:"Enable"}),e.jsx(a.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sections"}),e.jsxs(a.Radio.Group,{value:T,onChange:L=>F(L.target.value),children:[e.jsx(a.Radio,{value:"1",children:"Enable"}),e.jsx(a.Radio,{value:"0",children:"Disable"})]})]}),e.jsx(V,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:j,onChange:L=>P(L.target.value)})]}),e.jsx(a.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:I?"Updating...":"Done",disabled:I})})]})})})]})}function sb({token:t}){return e.jsx(nb,{token:t})}const sn=Qe.marksheetSetting,rb=({token:t})=>Dt({url:sn.templateTypes,token:t}),ib=({token:t})=>Dt({url:sn.classDropdown,token:t}),lb=({token:t})=>Dt({url:sn.assignedTable,token:t}),ob={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},xl=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],db=Array.from({length:12},(t,n)=>({value:String(n+1),label:`Design ${n+1}`})),cb=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function ub({token:t}){const n=i.useRef(null),s=rb({token:t}),r=ib({token:t}),l=lb({token:t}),o=i.useMemo(()=>xl(s.data),[s.data]),d=i.useMemo(()=>xl(r.data),[r.data]),c=i.useMemo(()=>cb(l.data),[l.data]),[g,y]=i.useState(null),[p,m]=i.useState(null),[A,C]=i.useState([]),b=()=>{n.current?.reset?.(),y(null),m(null),C([])},f=()=>{const _=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),D=URL.createObjectURL(_),u=document.createElement("a");u.href=D,u.download="marksheet-templates.json",u.click(),URL.revokeObjectURL(D)},x=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:b},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:f,disabled:c.length===0}],[c.length]),R=async _=>{if(_.preventDefault(),!g?.value){v.error("Select marksheet type.",{duration:1200});return}if(!p?.value){v.error("Select design.",{duration:1200});return}if(!A?.length){v.error("Select at least one class.",{duration:1200});return}try{const D=new FormData;D.set("temp_id",String(g.value)),D.set("ui_id",String(p.value)),A.forEach(u=>D.append("class_id[]",String(u))),await xn(sn.assign,D,t),v.success("Marksheet template assigned.",{duration:1e3}),l.mutate?.(),b()}catch(D){v.error(D?.response?.data?.msg??D?.message??"Failed to assign template.",{duration:1500})}},k=async _=>{try{await fr(sn.remove,_,t),v.success("Template removed.",{duration:1e3}),l.mutate?.()}catch(D){v.error(D?.response?.data?.msg??D?.message??"Failed to remove template.",{duration:1500})}},O=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class"},{title:"Template Name",dataIndex:"name",key:"name"},{title:"Template Design",dataIndex:"ui_id",key:"ui_id"},{title:"Action",key:"action",render:(_,D)=>e.jsx(wt,{id:D?.id,funcName:k})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Xt,{title:"Marksheet Setting",actions:x,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:n,onSubmit:R,children:[e.jsxs("div",{style:ob,children:[e.jsxs("div",{children:[e.jsx(Z,{label:"Select Marksheet Type",options:o,value:g,onChange:_=>y(_)}),e.jsx("input",{type:"hidden",name:"temp_id",value:g?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Select Design",options:db,value:p,onChange:_=>m(_)}),e.jsx("input",{type:"hidden",name:"ui_id",value:p?.value??""})]})]}),e.jsx(a.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(a.Checkbox.Group,{options:d,value:A,onChange:_=>C(_)})]}),e.jsx(a.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save"})})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(a.Table,{size:"small",rowKey:"id",columns:O,dataSource:c,pagination:!1})})]})})]})}function pb({token:t}){return e.jsx(ub,{token:t})}const qs={fetch:`${Qe.legalPages.get}?page_name=terms`,save:Qe.legalPages.termsSave,fieldName:"terms_data"};function mb({token:t}){return e.jsx(yr,{token:t,title:"Terms",fetchUrl:qs.fetch,saveUrl:qs.save,fieldName:qs.fieldName})}function hb({token:t}){return e.jsx(mb,{token:t})}const zs={fetch:`${Qe.legalPages.get}?page_name=privacy`,save:Qe.legalPages.privacySave,fieldName:"privacy_data"};function fb({token:t}){return e.jsx(yr,{token:t,title:"Privacy",fetchUrl:zs.fetch,saveUrl:zs.save,fieldName:zs.fieldName})}function yb({token:t}){return e.jsx(fb,{token:t})}const Ys={fetch:`${Qe.legalPages.get}?page_name=about_us`,save:Qe.legalPages.aboutSave,fieldName:"about_data"};function gb({token:t}){return e.jsx(yr,{token:t,title:"About",fetchUrl:Ys.fetch,saveUrl:Ys.save,fieldName:Ys.fieldName})}function xb({token:t}){return e.jsx(gb,{token:t})}const gr=Qe.feesInfo,bb=({token:t})=>Dt({url:gr.get,token:t}),jb=({token:t})=>Dt({url:gr.statesDropdown,token:t}),Sb=(t,n)=>{const s=String(t??""),r=String(n??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},tn=t=>{const n=qt(t);if(n)return n;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},No=(t,n,s)=>{const r=`${t||""}`.trim();if(!r)return"";if(/^https?:\/\//i.test(r))return r;const l=tn(n),o=r.startsWith("/")?r.slice(1):r;return Sb(at(),`uploads/school_${l}/${s}/${o}`)},Ws={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},vb=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null,wb=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],_b=(t,n)=>t?No(t,n,"schoolFile"):"",Vs=(t,n)=>t?No(t,n,"schoolFile"):"";function Cb({token:t}){const n=i.useRef(null),s=bb({token:t}),r=jb({token:t}),l=i.useMemo(()=>vb(s.data),[s.data]),o=i.useMemo(()=>wb(r.data),[r.data]),[d,c]=i.useState(null),[g,y]=i.useState(""),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState(""),x=u=>{const h=new FormData(u),S=Object.fromEntries(h.entries());return S.state_id=d?.value??"",S.fees_receipt_logo=g,S.manager_signature=p,S.principal_signature=A,S.stamp=b,S},R=()=>{c(o.find(u=>String(u?.value)===String(l?.fk_state_id??l?.state_id??l?.country_code??""))??null),y(l?.logo??l?.fees_receipt_logo??""),m(l?.manager_signature??""),C(l?.principal_signature??""),f(l?.stamp??"")};i.useEffect(()=>{l&&R()},[l,o]);const k=()=>{n.current?.reset?.(),R()},O=()=>{const u=x(n.current),h=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),S=URL.createObjectURL(h),E=document.createElement("a");E.href=S,E.download="fees-info.json",E.click(),URL.revokeObjectURL(S)},_=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:k},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:O,disabled:!l}],[l,d,g,p,A,b]),D=async u=>{u.preventDefault();try{const h=x(u.target);await Tx(gr.save,h,t),v.success("Fees info saved.",{duration:1e3}),s.mutate?.()}catch(h){v.error(h?.response?.data?.msg??h?.message??"Failed to save fees info.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Xt,{title:"Fees Info",actions:_,children:e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:n,onSubmit:D,children:[e.jsxs("div",{style:Ws,children:[e.jsx(V,{name:"Bussiness_name",label:"Business Name*",defaultValue:l?.name??"",required:!0}),e.jsx(V,{name:"cin",label:"Sub Heading",defaultValue:l?.cin??""}),e.jsx(V,{name:"school_no",type:"number",label:"School Number",defaultValue:l?.school_no??""}),e.jsx(V,{name:"website",label:"Website",defaultValue:l?.website??""}),e.jsx(V,{name:"school_Code",label:"School Code",defaultValue:l?.school_Code??""}),e.jsx(V,{name:"offical_number",label:"Official Number",defaultValue:l?.offical_number??""}),e.jsx(V,{name:"email_id",label:"Email",defaultValue:l?.email_id??""}),e.jsx(V,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:l?.admission_prefix??l?.receipt_prefix??""}),e.jsx(V,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:l?.admission_no_prefix??l?.admission_start_number??l?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(Z,{label:"State",options:o,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(V,{name:"affiliation_no",label:"Affiliation Number",defaultValue:l?.affiliation_no??""}),e.jsx(V,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:l?.affiliation_desc??l?.affliated_description??""}),e.jsx(V,{name:"udise_code",label:"UDISE Code",defaultValue:l?.udise_code??""}),e.jsx(V,{name:"color_code",label:"Primary Color",defaultValue:l?.color_code??""}),e.jsx(V,{name:"fontcolor_code",label:"Font Color",defaultValue:l?.fontcolor_code??""})]}),e.jsx(a.Divider,{}),e.jsxs("div",{style:Ws,children:[e.jsx(gt,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:l?.Bussiness_address??l?.bussiness_address??l?.address??l?.location_name??""}),e.jsx(gt,{name:"note",rows:3,label:"Note",defaultValue:l?.note??""})]}),e.jsx(a.Divider,{}),e.jsxs("div",{style:Ws,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(en,{token:t,action:`${at()}/uploadfile.php`,data:{filepath:`uploads/school_${tn(t)}/schoolFile`},value:g,previewUrl:_b(g,t),accept:"image/*",onChange:y}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:g})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(en,{token:t,action:`${at()}/uploadfile.php`,data:{filepath:`uploads/school_${tn(t)}/schoolFile`},value:p,previewUrl:Vs(p,t),accept:"image/*",onChange:m}),e.jsx("input",{type:"hidden",name:"manager_signature",value:p})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Principal Signature"}),e.jsx(en,{token:t,action:`${at()}/uploadfile.php`,data:{filepath:`uploads/school_${tn(t)}/schoolFile`},value:A,previewUrl:Vs(A,t),accept:"image/*",onChange:C}),e.jsx("input",{type:"hidden",name:"principal_signature",value:A})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(en,{token:t,action:`${at()}/uploadfile.php`,data:{filepath:`uploads/school_${tn(t)}/schoolFile`},value:b,previewUrl:Vs(b,t),accept:"image/*",onChange:f}),e.jsx("input",{type:"hidden",name:"stamp",value:b})]})]}),e.jsx(a.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save"})})]})})})]})}function Ab({token:t}){return e.jsx(Cb,{token:t})}const es=Qe.payrollSettings,Db=({token:t,page:n=1,perPage:s=10})=>$o({baseUrl:es.table,token:t,page:n,perPage:s}),Tb={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Ka=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],Hs=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],Rb=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Ib=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function kb({token:t}){const n=i.useRef(null),s=i.useRef(null),[r,l]=i.useState({page:1,rowsPerPage:10}),[o,d]=i.useState(!1),[c,g]=i.useState(null),[y,p]=i.useState(Ka[0]),[m,A]=i.useState(null),[C,b]=i.useState(null),[f,x]=i.useState(null),[R,k]=i.useState(!1),[O,_]=i.useState(!1),D=Db({token:t,page:r.page,perPage:r.rowsPerPage}),u=i.useMemo(()=>Rb(D.data),[D.data]),h=i.useMemo(()=>Ib(D.data,u.length),[D.data,u.length]),S=async P=>{P.preventDefault(),_(!0);try{const I=new FormData(P.target);I.set("type",y?.value??""),I.set("amount_type",m?.value??""),await xn(es.add,I,t),v.success("Payroll setting added.",{duration:1e3}),D.mutate?.(),P.target.reset(),A(null),p(Ka[0])}catch(I){v.error(I?.response?.data?.msg??I?.message??"Failed to add payroll setting.",{duration:1500})}finally{_(!1)}},E=P=>{g(P),b(Ka.find(I=>I.value===P?.type)??null),x(Hs.find(I=>I.value===P?.amount_type)??null),d(!0)},$=async P=>{P.preventDefault(),k(!0);try{const I=new FormData(P.target);I.set("id",String(c?.id??"")),I.set("type",C?.value??""),I.set("amount_type",f?.value??""),await Eo(es.edit,I,t),v.success("Payroll setting updated.",{duration:1e3}),d(!1),D.mutate?.()}catch(I){v.error(I?.response?.data?.msg??I?.message??"Failed to update payroll setting.",{duration:1500})}finally{k(!1)}},q=async P=>{try{await fr(es.remove,P,t),v.success("Payroll setting deleted.",{duration:1e3}),D.mutate?.()}catch(I){v.error(I?.response?.data?.msg??I?.message??"Failed to delete payroll setting.",{duration:1500})}},T=()=>{const P=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),I=URL.createObjectURL(P),N=document.createElement("a");N.href=I,N.download="payroll-settings.json",N.click(),URL.revokeObjectURL(I)},F=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:()=>D.mutate?.()},{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:T,disabled:u.length===0}],[u.length]),j=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title"},{title:"Type",dataIndex:"type",key:"type"},{title:"Amount Type",dataIndex:"amount_type",key:"amount_type"},{title:"Amount",dataIndex:"Amount",key:"Amount"},{title:"Action",key:"action",render:(P,I)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>E(I)}),e.jsx(a.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>q(I.id),children:e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Xt,{title:"Payroll Settings",actions:F,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:n,onSubmit:S,children:[e.jsxs("div",{style:Tb,children:[e.jsx(V,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(Z,{label:"Type",options:Ka,value:y,onChange:p}),e.jsx("input",{type:"hidden",name:"type",value:y?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Amount Type",options:Hs,value:m,onChange:A}),e.jsx("input",{type:"hidden",name:"amount_type",value:m?.value??""})]}),e.jsx(V,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(ie,{type:"submit",value:O?"Adding...":"Submit",disabled:O,loading:O})})]})}),e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(a.Table,{rowKey:"id",columns:j,dataSource:u,loading:D.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:h,showSizeChanger:!0,onChange:(P,I)=>l({page:P,rowsPerPage:Number(I)})}})})]})}),e.jsx(a.Drawer,{open:o,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,destroyOnClose:!0,footer:e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(a.Button,{onClick:()=>d(!1),disabled:R,children:"Cancel"}),e.jsx(ie,{type:"submit",value:R?"Updating...":"Update",disabled:R,loading:R,form:"payroll-edit-form"})]}),children:e.jsx(a.Spin,{spinning:R,tip:"Updating...",children:e.jsx("form",{id:"payroll-edit-form",ref:s,onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(V,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(Z,{label:"Type",options:Ka,value:C,onChange:b}),e.jsx("input",{type:"hidden",name:"type",value:C?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Amount Type",options:Hs,value:f,onChange:x}),e.jsx("input",{type:"hidden",name:"amount_type",value:f?.value??""})]}),e.jsx(V,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""})]})},c?.id??"new")})})]})}function Pb({token:t}){return e.jsx(kb,{token:t})}const Lo=Qe.paymentGateway,Ob=({token:t})=>Dt({url:Lo.get,token:t}),Mb=[{id:"Razorpay",title:"Razorpay",fields:["keyId","keySecret"]},{id:"PhonePe",title:"Pine Labs",fields:["merchantId","saltKey","saltIndex"]},{id:"Paytm",title:"HDFC",fields:["merchantId","merchantKey"]},{id:"SabPaisa",title:"SabPaisa",fields:["clientCode","transUserName","transUserPassword","authKey","authIV"]}],ea={Razorpay:{keyId:"",keySecret:"",isActive:!0},PhonePe:{merchantId:"",saltKey:"",saltIndex:"1",isActive:!1},Paytm:{merchantId:"",merchantKey:"",isActive:!1},SabPaisa:{clientCode:"",transUserName:"",transUserPassword:"",authKey:"",authIV:"",isActive:!1}},bl=t=>{const n=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!n?.data)return ea;try{const s=JSON.parse(n.data||"{}"),r=s?.data&&typeof s.data=="object"?s.data:s;return{Razorpay:{...ea.Razorpay,...r?.Razorpay??{}},PhonePe:{...ea.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...ea.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...ea.SabPaisa,...r?.SabPaisa??{}}}}catch{return ea}};function Eb({token:t}){const n=i.useRef(null),s=Ob({token:t}),[r,l]=i.useState(ea);i.useEffect(()=>{s.data&&l(bl(s.data))},[s.data]);const o=(p,m,A)=>{l(C=>({...C,[p]:{...C[p],[m]:A}}))},d=()=>l(bl(s.data)),c=()=>{const p=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),m=URL.createObjectURL(p),A=document.createElement("a");A.href=m,A.download="payment-gateway-settings.json",A.click(),URL.revokeObjectURL(m)},g=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:c}],[r,s.data]),y=async p=>{p.preventDefault();try{await Fo(Lo.save,{data:r},t),v.success("Payment gateway settings saved.",{duration:1e3}),s.mutate?.()}catch(m){v.error(m?.response?.data?.msg??m?.message??"Failed to save gateway settings.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Xt,{title:"Payment Gateway",actions:g,children:e.jsxs("form",{ref:n,onSubmit:y,style:{display:"grid",gap:20},children:[Mb.map(p=>{const m=r[p.id]??{};return e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:p.title}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:500},children:["Enable ",p.title]}),e.jsx(a.Switch,{checked:!!m.isActive,onChange:A=>o(p.id,"isActive",A)})]}),e.jsx(a.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:p.fields.map(A=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:A}),e.jsx(a.Input,{value:m[A]??"",type:A.toLowerCase().includes("secret")||A.toLowerCase().includes("password")?"password":"text",onChange:C=>o(p.id,A,C.target.value)})]},A))})]})},p.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save"})})]})})]})}function Fb({token:t}){return e.jsx(Eb,{token:t})}const $b="{{student_name}} {{parent_name}} {{amount}} {{date}} {{time}} {{id}} {{school_name}} {{date_time}}",Sa=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:[]};function Ub({token:t}){const[n,s]=i.useState("1"),[r,l]=i.useState(""),[o,d]=i.useState(""),[c,g]=i.useState(""),[y,p]=i.useState(""),[m,A]=i.useState(""),[C,b]=i.useState([]),[f,x]=i.useState(""),[R,k]=i.useState(""),[O,_]=i.useState(""),[D,u]=i.useState([]),[h,S]=i.useState({label:"",value:""}),[E,$]=i.useState(!1),[q,T]=i.useState(""),[F,j]=i.useState([]),[P,I]=i.useState([]),[N,W]=i.useState(!1),{data:Y}=K(t?[Qe.smsCompose.templateDropdown,t]:null,([me,de])=>G(me,de)),B=i.useMemo(()=>Sa(Y).map(de=>({label:de.name??de.title??"",value:String(de.id??de.value??""),template_body:de.template_body??de.body??""})),[Y]),{data:U}=K(t?[Qe.smsCompose.roleDropdown,t]:null,([me,de])=>G(me,de)),M=i.useMemo(()=>Sa(U).map(de=>({label:de.role_name??de.name??de.label??"",value:String(de.id??de.role_id??de.value??"")})),[U]),L=i.useMemo(()=>[{label:"Student",value:"Student"},...M],[M]),{data:z}=K(t?[Qe.smsCompose.classDropdown,t]:null,([me,de])=>G(me,de)),ne=i.useMemo(()=>Sa(z).map(de=>({label:de.class_name??de.name??de.label??"",value:String(de.id??de.class_id??de.value??""),...de})),[z]),X=i.useMemo(()=>q?`${Qe.smsCompose.sectionByClass}?class_id=${encodeURIComponent(q)}`:null,[q]),{data:J}=K(t&&X?[X,t]:null,([me,de])=>G(me,de)),H=i.useMemo(()=>Sa(J).map(de=>({label:de.section_name??de.name??de.label??"",value:String(de.id??de.section_id??de.value??""),...de})),[J]),Q=me=>{const de=ne.find(Re=>Re.value===me)||{label:"",value:me};S({label:de.label,value:de.value}),T(de.value),$(Re=>!Re),j([])},ce=()=>{if(!h.value||F.length===0)return;const me=P.find(Re=>Re.kind==="class"&&Re.class_id===h.value),de=F;if(me){const Re=Array.from(new Set([...me.section_ids,...de]));I(Be=>Be.map($e=>$e.kind==="class"&&$e.class_id===h.value?{...$e,section_ids:Re}:$e))}else I(Re=>[...Re,{kind:"class",label:`Class: ${h.label}`,class_id:h.value,class_label:h.label,section_ids:de}]);j([])},De=async me=>{if(A(me),!me){b([]);return}try{const de=`${Qe.smsCompose.staffSearch}?name=${encodeURIComponent(me)}&role=${encodeURIComponent(y)}`,Re=await G(de,t),Be=Sa(Re);b(Be.map($e=>({label:$e.staff_name??$e.name??$e.full_name??"",value:String($e.id??$e.staff_id??$e.employee_id??$e.value??""),...$e})))}catch{b([])}},le=(me,de)=>{P.find(Be=>Be.kind==="staff"&&Be.value===de.value)||I(Be=>[...Be,{kind:"staff",label:de.label,value:de.value,type:c}])},ue=async me=>{if(_(me),!me){u([]);return}try{const de=`${Qe.smsCompose.studentDropdown}?class=${encodeURIComponent(f)}§ion=${encodeURIComponent(R)}&name=${encodeURIComponent(me)}`,Re=await G(de,t),Be=Sa(Re);u(Be.map($e=>({label:$e.student_name??$e.name??"",value:String($e.roll_no??$e.roll??$e.value??""),id:String($e.id??$e.student_id??$e.value??""),...$e})))}catch{u([])}},oe=(me,de)=>{P.find(Be=>Be.kind==="student"&&Be.id===de.id)||I(Be=>[...Be,{kind:"student",label:de.label,value:de.value,id:de.id}])},Ce=me=>{I(de=>de.filter((Re,Be)=>Be!==me))},Ne=i.useMemo(()=>{if(!o)return[];const de=(o.match(/\{\{\s*[^{}]+\s*\}\}/g)||[]).map(Re=>Re.replace(/\s+/g,""));return Array.from(new Set(de))},[o]),et=async()=>{if(!r||P.length===0)return;const me=new FormData;me.append("is_individual",n==="1"?"1":"0"),me.append("is_class",n==="2"?"1":"0"),me.append("message",o),me.append("template_id",r),P.forEach((de,Re)=>{de.kind==="staff"?me.append("staff_ids[]",de.value):de.kind==="student"?me.append("student_ids[]",de.id):de.kind==="class"&&(me.append(`classArr[${Re}][class_id]`,de.class_id),de.section_ids.forEach(Be=>me.append(`classArr[${Re}][section_ids][]`,Be)))}),W(!0);try{const de=await Ca(Qe.smsCompose.sendMessage,me,t);de?.Status==="Success"?(a.message.success("SMS sent successfully!"),I([]),$(!1),S({label:"",value:""}),j([])):a.message.error(de?.msg??"Failed to send SMS")}catch(de){a.message.error(de?.message??"Failed to send SMS")}finally{W(!1)}},we=P.length,Ae=[{title:"Recipient",key:"label",render:(me,de)=>de.kind==="student"?e.jsxs(e.Fragment,{children:[e.jsx(a.Tag,{color:"blue",children:"Student"}),de.label]}):de.kind==="class"?e.jsxs(e.Fragment,{children:[e.jsx(a.Tag,{color:"purple",children:"Class"}),de.label," — ",de.section_ids.length," section(s)"]}):e.jsxs(e.Fragment,{children:[e.jsx(a.Tag,{color:"green",children:de.type||"Staff"}),de.label]})},{title:"Actions",key:"actions",render:(me,de,Re)=>e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>Ce(Re)})}],Fe=me=>{s(me),I([]),g(""),p(""),A(""),b([]),x(""),k(""),_(""),u([]),S({label:"",value:""}),$(!1),j([])};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:e.jsxs(a.Space,{children:[e.jsx(ee.MailOutlined,{}),e.jsx("span",{children:"SMS Campaign Composer"})]})}),children:[e.jsx("div",{style:{marginBottom:16},children:e.jsxs(a.Typography.Text,{type:"secondary",children:["Available placeholders: ",e.jsx("code",{children:$b})]})}),e.jsx(a.Tabs,{size:"small",type:"card",value:n,onChange:Fe,items:[{key:"1",label:"Individual"},{key:"2",label:"Class"}]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:24},children:[e.jsx(a.Card,{size:"small",title:"Message Details",children:e.jsxs(a.Space,{direction:"vertical",size:16,style:{width:"100%"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Choose Template*"}),e.jsx(a.Select,{style:{width:"100%"},placeholder:"Select a template",value:r||void 0,onChange:me=>{l(me);const de=B.find(Re=>Re.value===me);d(de?.template_body??"")},options:B,showSearch:!0,optionFilterProp:"label"}),B.length===0&&e.jsx(a.Typography.Text,{type:"secondary",style:{display:"block",marginTop:6},children:"No active templates available. Add one in SMS Alert Setting."})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Message*"}),e.jsx(a.Input.TextArea,{rows:5,value:o,readOnly:!0,placeholder:"Select a template to preview the message"})]}),Ne.length>0&&e.jsxs("div",{children:[e.jsx(a.Typography.Text,{strong:!0,style:{display:"block",marginBottom:8},children:"Available placeholders"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:Ne.map(me=>e.jsx(a.Tag,{color:"blue",children:me},me))}),e.jsx(a.Typography.Text,{type:"secondary",style:{display:"block",marginTop:6},children:"The server replaces these placeholders per recipient."})]})]})}),e.jsx(a.Card,{size:"small",title:"Recipient Selection",children:e.jsxs(a.Space,{direction:"vertical",size:16,style:{width:"100%"},children:[n==="1"&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Message To*"}),e.jsx(a.Select,{style:{width:"100%"},placeholder:"Select recipient type",value:c||void 0,onChange:me=>{g(me),p(me==="Student"?"Student":""),A(""),b([]),_(""),u([]),x(""),k("")},options:L}),c&&c!=="Student"&&e.jsx("div",{style:{marginTop:16},children:e.jsx(a.AutoComplete,{style:{width:"100%"},value:m,placeholder:`Search ${c} by name`,options:C,onSearch:De,onSelect:le,notFoundContent:m?"No staff found":""})}),c==="Student"&&e.jsxs("div",{style:{marginTop:16,display:"grid",gap:12},children:[e.jsx(a.Select,{placeholder:"Class",value:f||void 0,onChange:me=>{x(me),T(me),k(""),_(""),u([])},options:ne,showSearch:!0,optionFilterProp:"label"}),f&&e.jsx(a.Select,{placeholder:"Section",value:R||void 0,onChange:me=>{k(me),_(""),u([])},options:H}),f&&R&&e.jsx(a.AutoComplete,{placeholder:"Search student",value:O,options:D,onSearch:ue,onSelect:oe,notFoundContent:O?"No student found":""})]})]}),n==="2"&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Class*"}),e.jsx(a.Select,{style:{width:"100%"},placeholder:"Select class",value:h.value||void 0,onChange:Q,options:ne,showSearch:!0,optionFilterProp:"label"}),h.value&&H.length>0&&e.jsxs("div",{style:{marginTop:16},children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Sections"}),e.jsx(a.Select,{style:{width:"100%"},mode:"multiple",placeholder:"Select sections",value:F,onChange:j,options:H.map(me=>({label:me.label,value:me.value}))}),e.jsx(a.Button,{type:"primary",size:"small",style:{marginTop:8},onClick:ce,disabled:F.length===0,children:"Add Class Recipients"})]})]}),e.jsxs("div",{children:[e.jsxs(a.Typography.Text,{strong:!0,style:{display:"block",marginBottom:10},children:["Selected Recipients (",we,")"]}),e.jsx(a.Table,{bordered:!0,size:"small",columns:Ae,dataSource:P,rowKey:(me,de)=>`${me.kind}-${de}`,pagination:!1,scroll:{y:200},locale:{emptyText:"No recipients selected"}})]})]})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12,alignItems:"center"},children:[e.jsxs(a.Typography.Text,{type:"secondary",children:["Mode: ",n==="1"?"Individual":"Class"," | ",we," recipients selected"]}),e.jsx(ie,{type:"button",value:N?"Sending...":"Send SMS",color:"primary",onClick:et,disabled:N||!r||we===0})]})]})]})}const Ga=Qe.smsTemplates,Bb=Qe.smsGateway,Nb="{{student_name}} {{parent_name}} {{amount}} {{date}} {{time}} {{id}} {{school_name}} {{date_time}}";function Lb({token:t}){const[n,s]=i.useState(!1),[r,l]=i.useState(""),[o,d]=i.useState(!1),[c,g]=i.useState(""),[y,p]=i.useState(!1),[m,A]=i.useState(!1),[C,b]=i.useState([]),[f,x]=i.useState(!0),[R,k]=i.useState(1),[O]=i.useState(10),[_,D]=i.useState(""),[u,h]=i.useState(""),[S,E]=i.useState(""),[$,q]=i.useState({current_page:1,total_pages:1,total_rows:0}),[T,F]=i.useState(null),[j,P]=i.useState({name:!1,template_body:!1}),[I,N]=i.useState(!1),W=async()=>{try{const H=await G(Bb.get,t);if(H?.Status==="Success"){const Q=H?.data?.[0]??H?.data??null;if(!Q)return;l(Q.header??Q.header_key??""),g(Q.api_key??""),s(!0)}}catch(H){console.log(H)}},Y=async H=>{const Q={},ce={page:Q.page??R,perPage:Q.perPage??O,search:Q.search??u,status:Q.status??S},De=new URLSearchParams;De.set("page",ce.page),De.set("per_page",ce.perPage),ce.search&&De.set("search",ce.search),ce.status&&De.set("status",ce.status),x(!0);try{const le=await G(`${Ga.table}?${De.toString()}`,t);le?.Status==="Success"?(b(Array.isArray(le.data)?le.data:[]),q({current_page:le?.pagination?.current_page??1,total_pages:le?.pagination?.total_pages??1,total_rows:le?.pagination?.total_rows??(Array.isArray(le.data)?le.data.length:0)})):(b([]),q({current_page:1,total_pages:1,total_rows:0}),le?.msg==="Invalid page number"&&Number(ce.page)>1?k(1):le?.msg&&le.msg!=="No data found."&&v.error(le.msg,{duration:1500}))}catch(le){console.log(le),b([]),q({current_page:1,total_pages:1,total_rows:0}),v.error(le?.message??"Failed to load templates",{duration:1500})}finally{x(!1)}};i.useEffect(()=>{W()},[]),i.useEffect(()=>{Y()},[R,O,u,S]);const B=()=>{F({name:"",template_body:"",status:"Active"}),P({name:!1,template_body:!1})},U=H=>{F({id:H.id,name:H.name,template_body:H.template_body,status:H.status}),P({name:!1,template_body:!1})},M=()=>{F(null),P({name:!1,template_body:!1})},L=()=>{const H={name:!T?.name?.trim(),template_body:!T?.template_body?.trim()};return P(H),!H.name&&!H.template_body},z=async()=>{if(!(!T||!L())){N(!0);try{const H={name:T.name.trim(),template_body:T.template_body,status:T.status||"Active"},Q=T.id?Ga.edit:Ga.add;await Ca(Q,{id:T.id??"",...H},t),v.success(T.id?"Template updated!":"Template added!",{duration:1e3}),M(),Y()}catch(H){v.error(H?.message??"Failed to save template",{duration:1500})}finally{N(!1)}}},ne=async H=>{const Q=H.status==="Active"?"Deactive":"Active";try{const ce=await Ca(Ga.changeStatus,{id:H.id,status:Q},t);ce?.Status==="Success"?(v.success(`Template ${Q}`,{duration:1e3}),Y()):v.error(ce?.msg??"Failed to update status",{duration:1500})}catch(ce){v.error(ce?.message??"Failed to update status",{duration:1500})}},X=async H=>{if(window.confirm(`Delete template "${H.name}"?`))try{const Q=await Ze(Ga.delete,H.id,t);Q?.Status==="Success"?(v.success("Template deleted",{duration:1e3}),Y()):v.error(Q?.msg??"Failed to delete template",{duration:1500})}catch(Q){v.error(Q?.message??"Failed to delete template",{duration:1500})}},J=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Template Body",dataIndex:"template_body",key:"template_body",ellipsis:!0},{title:"Status",key:"status",width:140,render:(H,Q)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.Tag,{color:Q?.status==="Active"?"green":"red",children:Q?.status??""}),e.jsx(a.Switch,{size:"small",checked:Q?.status==="Active",onChange:()=>ne(Q)})]})},{title:"Actions",key:"actions",width:120,render:(H,Q)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>U(Q)}),e.jsx(a.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>X(Q)})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"SMS Templates"}),children:[e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:{fontSize:14,color:"#666",marginBottom:8},children:["Available placeholders: ",e.jsx("code",{children:Nb})]})}),T?e.jsxs(a.Card,{style:{borderRadius:8,border:"1px solid #B7D4FF",backgroundColor:"#F7FBFF",padding:16,marginBottom:16},children:[e.jsx(a.Typography.Title,{level:7,style:{margin:0,marginBottom:16},children:T.id?`Edit Template #${T.id}`:"New Template"}),e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Template Name*"}),e.jsx(a.Input,{maxLength:45,value:T.name,onChange:H=>F(Q=>({...Q,name:H.target.value})),status:j.name?"error":"",placeholder:"Template name"}),j.name&&e.jsx("div",{style:{color:"red",fontSize:12,marginTop:4},children:"Required field"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Template Body*"}),e.jsx(a.Input.TextArea,{rows:4,value:T.template_body,onChange:H=>F(Q=>({...Q,template_body:H.target.value})),status:j.template_body?"error":"",placeholder:"Template body"}),j.template_body&&e.jsx("div",{style:{color:"red",fontSize:12,marginTop:4},children:"Required field"})]}),e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx(a.Button,{size:"small",onClick:M,disabled:I,children:"Cancel"}),e.jsx(a.Button,{size:"small",type:"primary",loading:I,onClick:z,children:I?"Saving...":"Save"})]})]})]}):e.jsx(a.Button,{icon:e.jsx(ee.PlusOutlined,{}),type:"primary",style:{marginBottom:16},onClick:B,children:"Add Template"}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(a.Input,{placeholder:"Search by name or body",value:_,onChange:H=>D(H.target.value),onKeyDown:H=>{H.key==="Enter"&&(k(1),h(_.trim()))},style:{width:280}}),e.jsxs("select",{value:S,onChange:H=>{k(1),E(H.target.value)},style:{padding:"6px 12px",borderRadius:6,border:"1px solid #d9d9d9"},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"Active",children:"Active"}),e.jsx("option",{value:"Deactive",children:"Deactive"})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsxs("span",{style:{fontSize:13,color:"#666"},children:["Page ",$.current_page," of ",Math.max($.total_pages,1)," - ",$.total_rows," total"]}),e.jsx(a.Button,{size:"small",onClick:()=>k(H=>Math.max(1,H-1)),disabled:$.current_page<=1||f,children:"Prev"}),e.jsx(a.Button,{size:"small",onClick:()=>k(H=>H+1),disabled:$.current_page>=$.total_pages||f,children:"Next"})]})]}),e.jsx(a.Table,{bordered:!0,size:"small",columns:J,dataSource:C,loading:f,rowKey:H=>H.id,pagination:!1,scroll:{x:"max-content"}})]})]})}const jl=Qe.smsDetails,Sl=t=>{try{const n=new URL(t.trim());return(n.protocol==="http:"||n.protocol==="https:")&&!!n.hostname}catch{return!1}};function qb({token:t}){const[n,s]=i.useState(!1),[r,l]=i.useState(!1),[o,d]=i.useState({api_key:!1,url:!1}),[c,g]=i.useState(!1),[y,p]=i.useState({api_key:"",url:"",header_key:""}),[m,A]=i.useState("");i.useEffect(()=>{C()},[]);const C=async()=>{try{const R=await Ca(jl.get,{},t);if(R?.Status==="Success"){const k=R?.data?.[0]??R?.data??null;if(!k){s(!1);return}p({api_key:"",url:k.url||"",header_key:k.header_key||""}),A(k.api_key||""),s(!0)}}catch(R){console.error("SMS settings fetch error:",R)}},b=R=>{const{name:k,value:O}=R.target;p(_=>({..._,[k]:O})),o[k]&&d(_=>({..._,[k]:!1}))},f=()=>{s(!1),p(R=>({...R,api_key:""})),g(!1)},x=async()=>{const R={api_key:!y.api_key.trim(),url:!y.url.trim()||!Sl(y.url)};if(d(R),!Object.values(R).some(Boolean)){l(!0);try{const O={api_key:y.api_key.trim(),url:y.url.trim(),header_key:y.header_key.trim()},_=await Ca(jl.save,O,t);_?.Status==="Success"?(a.message.success("Data Updated successfully!"),await C()):a.message.error(_?.msg??"Failed to update SMS settings")}catch(O){console.error("SMS settings save error:",O),a.message.error("Failed to update SMS settings.")}finally{l(!1)}}};return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsx(a.Card,{title:e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"SMS Details Setting"}),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("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"API Key"}),e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"flex-end"},children:[e.jsx(a.Input,{name:"api_key",value:n?"*****":y.api_key,onChange:b,disabled:n,status:o.api_key?"error":"",placeholder:"Enter API key",style:{paddingRight:n?40:0}}),n&&e.jsx(a.Button,{type:"text",icon:e.jsx(ee.EyeOutlined,{}),size:"small",style:{position:"absolute",right:4,padding:0,height:"auto"},onClick:()=>g(!c)})]}),n&&c&&e.jsx("div",{style:{marginTop:4,fontSize:12,wordBreak:"break-all"},children:m||"No key saved"}),o.api_key&&e.jsx("div",{style:{color:"red",fontSize:12,marginTop:4},children:"Required field"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"URL"}),e.jsx(a.Input,{name:"url",value:y.url,onChange:b,onBlur:()=>{y.url&&!Sl(y.url)&&d(R=>({...R,url:!0}))},disabled:n,status:o.url?"error":"",placeholder:"https://example.com"}),o.url&&e.jsx("div",{style:{color:"red",fontSize:12,marginTop:4},children:"Please enter a valid URL (e.g. https://example.com)"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Header Key"}),e.jsx(a.Input,{name:"header_key",value:y.header_key,onChange:b,disabled:n,placeholder:"Enter header key"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:n?e.jsx(a.Button,{type:"primary",onClick:f,children:"Edit"}):e.jsx(ie,{type:"button",value:r?"Saving...":"Save",color:"primary",onClick:x,disabled:r})})]})})})}const Zt=Qe.chat,zb=t=>Qe.getMessages(t),Yb=t=>Qe.getSendMessages(t),vl=t=>{try{return t?JSON.parse(t):null}catch{return null}},Wb=t=>/\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i.test(t);function wl(t,n){if(!t)return"";try{const s=new URL(n),r=new URL(t,n);return(r.hostname==="localhost"||r.hostname==="127.0.0.1")&&(r.protocol=s.protocol,r.host=s.host),r.toString()}catch{return t}}function Vb(t){if(!t)return"";const n=new Date(t);return Number.isNaN(n.getTime())?"":n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Hb(t){return t?.fromMe?"You":t?.senderName??t?.contactName??t?.senderJid??t?.chatJid??"Unknown"}function _l(t){return{phone:t?.phone??t?.mobile??t?.mobileno??t?.whatsapp_number??"",jid:t?.jid??t?.chatJid??t?.whatsapp_jid??t?.whatsapp_group_id??""}}const Kb=["😀","😃","😄","😅","😂","😊","😍","😎","😢","🙏","👍","❤️","🔥","🎉"],Cl={people:["😀","😁","😂","🤣","🙂","🙃","😉","😊","😌","😍","🥰","😘","😋","😛","😝","😜","🤪","🤓","😎","🤩","🥳","😏","😒","😞","😔","😟"],nature:["😺","😻","🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸"],food:["🍔","🍕","🌭","🍿","🧁","🍰","🎂","🍪","🍪","🍫","🍬","🍩","🍓","🍎","🍌"],activities:["⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎱","🏓","🏸","🥅","🏒","🏑","🎯","🎯"],travel:["✈️","🚗","🚕","🚌","🚆","🚗","🏍️","🚲","🛳️","🚢","🚁","🚂"],objects:["📱","💻","📺","🔊","🎧","📷","📹","💾","💿","📠","📠","🖨️"],symbols:["⭐","🌟","✅","❌","❓","❔","🔴","🟢","🔵","⚪","⚫","🔶"],flags:["🏁","🚩","🎌","🏴","🏳️"]},Gb={people:"People",nature:"Nature",food:"Food & Drink",activities:"Activities",travel:"Travel",objects:"Objects",symbols:"Symbols",flags:"Flags"};function qo({token:t}){const n=i.useMemo(()=>vl(localStorage.getItem("Userdata"))||{},[]),s=i.useMemo(()=>vl(localStorage.getItem("genrall_settings"))||{},[]),r=i.useMemo(()=>n?.branch_id??"",[n?.branch_id]),l=i.useMemo(()=>s?.session_id??"1",[s?.session_id]),o=Zt.whatsappBaseUrl,[d,c]=i.useState("teacher"),[g,y]=i.useState({}),[p,m]=i.useState(""),[A,C]=i.useState(""),[b,f]=i.useState([]),[x,R]=i.useState(!1),[k,O]=i.useState("people"),[_,D]=i.useState(""),[u,h]=i.useState(!1),[S,E]=i.useState(0),[$,q]=i.useState(!1),[T,F]=i.useState(!1),[j,P]=i.useState("Staff"),[I,N]=i.useState([]),[W,Y]=i.useState([]),[B,U]=i.useState(""),[M,L]=i.useState(null),z=i.useRef(null),ne=i.useRef(null),X=i.useRef(null),J=i.useRef(new Set),H=i.useRef(new Set),Q=i.useRef(""),[ce,De]=i.useState({}),{data:le}=K(t?[Zt.teacherDropdown,t]:null,([ae,pe])=>G(ae,pe)),ue=i.useMemo(()=>{const ae=le?.data?.data??le?.data??le??[];return Array.isArray(ae)?ae.map(pe=>({label:pe.staff_name??pe.name??pe.full_name??"",value:String(pe.id??pe.staff_id??pe.employee_id??pe.value??""),...pe})):[]},[le]),{data:oe}=K(t?[Zt.classDropdown,t]:null,([ae,pe])=>G(ae,pe)),Ce=i.useMemo(()=>{const ae=oe?.data?.data??oe?.data??oe??[];return Array.isArray(ae)?ae.map(pe=>({label:pe.class_name??pe.name??pe.label??"",value:String(pe.id??pe.class_id??pe.value??""),...pe})):[]},[oe]),{data:Ne}=K(M?[M,t]:null,([ae,pe])=>G(ae,pe)),et=i.useMemo(()=>{const ae=Ne?.data?.data??Ne?.data??Ne??[];return Array.isArray(ae)?ae.map(pe=>({label:pe.section_name??pe.name??pe.label??"",value:String(pe.id??pe.section_id??pe.value??""),...pe})):[]},[Ne]),{data:we}=K(t?[`${Zt.groupList}?type=staff`,t]:null,([ae,pe])=>G(ae,pe)),{data:Ae}=K(t?[`${Zt.groupList}?type=student`,t]:null,([ae,pe])=>G(ae,pe)),Fe=d==="teacher"?Array.isArray(we?.data)?we.data:[]:Array.isArray(Ae?.data)?Ae.data:[];i.useEffect(()=>{if(!Fe||Fe.length===0){m("");return}Fe.some(ae=>ae.id===p)||m(Fe[0].id)},[Fe,p]);const me=Fe.find(ae=>ae.id===p)??Fe[0]??null,de=me?.id??null,Re=me?g[me.id]??[]:[],Be=async ae=>{const{jid:pe}=_l(ae);if(pe)try{const Pe=`${zb(o)}?schoolCode=${encodeURIComponent(r)}&chatJid=${encodeURIComponent(pe)}`,Ee=await Xe.get(Pe),it=Array.isArray(Ee?.data?.messages)?Ee.data.messages:[];y(lt=>({...lt,[ae.id]:it.map(ft=>({...ft,fromMe:ft.direction==="outbound",text:ft.body||""}))}))}catch(Pe){const Ee=Pe?.response?.data?.message||Pe?.message||"Failed to load messages.";message.error(Ee)}};i.useEffect(()=>{!de||g[de]||Be(me)},[g,me,de]);const $e=ae=>{y(pe=>{const Pe={...pe},Ee=Pe[p]??[];return Pe[p]=[...Ee,{id:Date.now(),fromMe:!0,text:ae}],Pe})},ge=(ae="smooth")=>{if(typeof X.current?.scrollIntoView=="function"){X.current.scrollIntoView({behavior:ae,block:"end"});return}ne.current&&(ne.current.scrollTop=ne.current.scrollHeight)},_e=()=>{const ae=ne.current;return ae?ae.scrollHeight-ae.scrollTop-ae.clientHeight:0},ve=()=>{const ae=_e()<100;h(!ae),ae&&E(0)};i.useEffect(()=>{Q.current="",h(!1),E(0);const ae=globalThis.setTimeout(()=>{ge("auto"),ve()},0);return()=>globalThis.clearTimeout(ae)},[de]),i.useEffect(()=>{const ae=Re[Re.length-1];if(!ae)return;const pe=`${ae.id}-${ae.createdAt||""}-${Re.length}`,Pe=Q.current,Ee=_e()<100;if(!Pe||Ee||ae.fromMe){const it=globalThis.setTimeout(()=>{ge(Pe?"smooth":"auto"),ve()},0);return Q.current=pe,()=>globalThis.clearTimeout(it)}Pe!==pe&&!ae.fromMe&&(h(!0),E(it=>it+1)),Q.current=pe},[Re]);const[re,xe]=i.useState({});i.useEffect(()=>{const ae=Re.filter(Ee=>Ee?.messageType==="image"&&Ee?.mediaUrl&&!ce[Ee.id]&&!re[Ee.id]);if(ae.length===0)return;let pe=!1;return(async()=>{for(const Ee of ae){const it=wl(Ee.mediaUrl,o);try{const lt=await Xe.get(it,{responseType:"blob"}),ft=URL.createObjectURL(lt.data);H.current.add(ft),pe||De(he=>({...he,[Ee.id]:ft}))}catch{pe||xe(lt=>({...lt,[Ee.id]:it}))}}})(),()=>{pe=!0}},[Re,ce,re,o]);const je=()=>{f(ae=>(ae.forEach(pe=>{pe?.previewUrl&&(URL.revokeObjectURL(pe.previewUrl),J.current.delete(pe.previewUrl))}),[]))},Le=ae=>{f(pe=>{const Pe=[...pe],[Ee]=Pe.splice(ae,1);return Ee?.previewUrl&&(URL.revokeObjectURL(Ee.previewUrl),J.current.delete(Ee.previewUrl)),Pe})};i.useEffect(()=>()=>{J.current.forEach(ae=>URL.revokeObjectURL(ae)),J.current.clear(),H.current.forEach(ae=>URL.revokeObjectURL(ae)),H.current.clear()},[]);const qe=ae=>{if(!ae||ae.length===0)return;const pe=ae.filter(Boolean).filter(Pe=>Pe.type?.startsWith("image/")||Pe.type==="application/pdf").map(Pe=>{const Ee=Pe.type?.startsWith("image/")?URL.createObjectURL(Pe):"";return Ee&&J.current.add(Ee),{file:Pe,name:Pe.name||"Attachment",previewUrl:Ee,type:Pe.type||""}});f(Pe=>[...Pe,...pe])},fe=({url:ae,trimmedMessage:pe,attachments:Pe,schoolCode:Ee,sessionId:it,phone:lt,jid:ft})=>{if(Pe.length>0){const Te=new FormData;return Te.append(Ee?"schoolCode":"sessionId",Ee||it),Te.append(lt?"phone":"jid",lt||ft),Te.append("queue","false"),pe&&Te.append("text",pe),Pe.forEach(Ke=>{Te.append("file",Ke.file)}),Xe.post(ae,Te,{headers:{"Content-Type":"multipart/form-data"}})}const he={text:pe,queue:!1,[Ee?"schoolCode":"sessionId"]:Ee||it,[lt?"phone":"jid"]:lt||ft};return Xe.post(ae,he,{headers:{"Content-Type":"application/json"}})},Ie=({selectedItem:ae,trimmedMessage:pe,attachments:Pe,schoolCode:Ee,sessionId:it,phone:lt,jid:ft})=>!pe&&Pe.length===0||!ae?{shouldProceed:!1,message:""}:!Ee&&!it?{shouldProceed:!1,message:"School code or session id is required."}:!lt&&!ft?{shouldProceed:!1,message:"Phone or jid is required for the selected chat."}:{shouldProceed:!0,message:""},Je=async()=>{const ae=A.trim(),{phone:pe,jid:Pe}=_l(me),Ee=Ie({selectedItem:me,trimmedMessage:ae,attachments:b,schoolCode:r,sessionId:l,phone:pe,jid:Pe});if(!Ee.shouldProceed){Ee.message&&message.error(Ee.message);return}try{await fe({url:`${Yb(o)}`,trimmedMessage:ae,attachments:b,schoolCode:r,sessionId:l,phone:pe,jid:Pe}),$e(ae),C(""),je(),R(!1),message.success("Message sent.")}catch(it){const lt=it?.response?.data?.message||it?.message||"Failed to send message.";message.error(lt)}},mt=[{value:"Staff",label:"Staff"},{value:"Class",label:"Class"}],Et=async ae=>{ae.preventDefault(),F(!0);const pe=new FormData(ae.target);pe.append("session_id",l),pe.set("type",j),j==="Staff"?Array.isArray(I)&&I.forEach(Pe=>{Pe!=null&&Pe!==""&&pe.append("staff_id[]",Pe)}):(B!=null&&B!==""&&pe.set("class_id",B),Array.isArray(W)&&W.forEach(Pe=>{Pe!=null&&Pe!==""&&pe.append("section_id[]",Pe)}));try{await Oc(Zt.groupCreate,pe,t)?(message.success("Group created successfully!"),q(!1),N([]),Y([]),U("")):message.error("Failed to create group.")}catch{message.error("Failed to create group.")}finally{F(!1)}ae.target.reset()},Tt=()=>q(!1),ye=ae=>{C(pe=>pe+ae),R(!1)},ke=(g[me?.id]??[]).slice(-1)[0]?.text??"No messages";return e.jsxs("div",{style:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[e.jsx(a.Modal,{title:"Create Group",footer:null,open:$,onCancel:Tt,children:e.jsx("form",{onSubmit:Et,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Group Name*"}),e.jsx(a.Input,{name:"name",type:"text",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Type*"}),e.jsx(a.Select,{value:j,onChange:P,options:mt,style:{width:"100%"}})]}),j==="Staff"?e.jsx(a.Select,{mode:"multiple",label:"Staff",options:ue,closeMenuOnSelect:!0,value:I,onChange:N,placeholder:"Select staff"}):e.jsxs(e.Fragment,{children:[e.jsx(a.Select,{label:"Class",options:Ce,closeMenuOnSelect:!0,value:B||void 0,onChange:ae=>{U(ae),L(`${Zt.sectionByClass}?class_id=${ae}`),Y([])},placeholder:"Select class"}),e.jsx(a.Select,{mode:"multiple",label:"Section",options:et.map(ae=>({label:ae.label,value:ae.value})),placeholder:"Select sections",value:W,onChange:Y})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(a.Button,{onClick:Tt,children:"Cancel"}),e.jsx(a.Button,{type:"primary",htmlType:"submit",loading:T,children:"Create"})]})]})})}),e.jsxs("div",{style:{flex:1,overflow:"hidden",display:"grid",gridTemplateColumns:"350px 1fr"},children:[e.jsxs("div",{style:{borderRight:"1px solid #e0e0e0",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid #eee",display:"flex",gap:8,justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(a.Space,{children:[e.jsx(a.Button,{type:d==="teacher"?"primary":"default",onClick:()=>c("teacher"),children:"Teacher"}),e.jsx(a.Button,{type:d==="class"?"primary":"default",onClick:()=>c("class"),children:"Student"})]}),e.jsx(a.Button,{type:"primary",onClick:()=>q(!0),children:"Create Group"})]}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:Fe.map(ae=>{const pe=p===ae.id;return e.jsxs("div",{onClick:()=>m(ae.id),style:{display:"flex",alignItems:"center",gap:8,padding:"12px 16px",cursor:"pointer",backgroundColor:pe?"#f5f9ff":"transparent",borderBottom:"1px solid #f0f0f0"},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:"50%",backgroundColor:"#e0e0e0",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:"bold",color:"#555"},children:(ae.group_name||ae.name||"?").charAt(0)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(a.Typography.Text,{strong:!0,style:{display:"block"},children:ae.group_name||ae.name||""}),e.jsx(a.Typography.Text,{type:"secondary",style:{fontSize:12,display:"block"},children:ke})]})]},ae.id)})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid #eee",display:"flex",gap:8,alignItems:"center"},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:"50%",backgroundColor:"#e0e0e0",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:"bold",color:"#555"},children:(me?.group_name||"?").charAt(0)}),e.jsxs("div",{children:[e.jsx(a.Typography.Text,{strong:!0,style:{display:"block"},children:me?.group_name||"Select a chat"}),e.jsx(a.Typography.Text,{type:"secondary",style:{fontSize:11},children:d==="teacher"?"Teacher":"Class"})]})]}),e.jsxs("div",{ref:ne,onScroll:ve,style:{flex:1,minHeight:0,padding:"12px 16px",overflowY:"auto",backgroundColor:"#f7f8fa"},children:[Re.length===0?e.jsx(a.Typography.Text,{type:"secondary",children:"No messages yet"}):Re.map((ae,pe)=>e.jsx("div",{style:{display:"flex",justifyContent:ae.fromMe?"flex-end":"flex-start",marginBottom:16},children:e.jsxs("div",{style:{maxWidth:"75%",padding:"10px 14px",borderRadius:12,backgroundColor:ae.fromMe?"#d1e7ff":"#ffffff",border:"1px solid #e6e6e6"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:4,marginBottom:ae.text?6:0},children:[e.jsx(a.Typography.Text,{style:{fontSize:12,fontWeight:500,color:"#555"},children:Hb(ae)}),e.jsx(a.Typography.Text,{style:{fontSize:11,color:"#999"},children:Vb(ae.createdAt)})]}),(ae.text||ae.body)&&e.jsx(a.Typography.Text,{style:{display:"block",fontSize:14},children:ae.text||ae.body}),ae.messageType==="image"&&(ae.mediaUrl||ae?._data?.body)&&(ce[ae.id]?e.jsx("img",{alt:"Chat attachment",src:ce[ae.id],style:{marginTop:8,width:180,maxWidth:"100%",borderRadius:8,border:"1px solid #ddd"}}):re[ae.id]?e.jsx("img",{alt:"Chat attachment",src:re[ae.id],style:{marginTop:8,width:180,maxWidth:"100%",borderRadius:8,border:"1px solid #ddd"}}):ae.mediaUrl?e.jsx("img",{alt:"Chat attachment",src:wl(ae.mediaUrl,o),style:{marginTop:8,width:180,maxWidth:"100%",borderRadius:8,border:"1px solid #ddd"}}):null)]})},ae.id??pe)),e.jsx("div",{ref:X})]}),u?e.jsx(a.Button,{onClick:()=>{ge("smooth"),h(!1),E(0)},style:{position:"absolute",right:16,bottom:b.length>0?160:80,minWidth:44,width:44,height:44,borderRadius:"50%",backgroundColor:"#fff",color:"#1976d2",border:"1px solid #d9e3f0",boxShadow:"0 6px 18px rgba(0,0,0,0.14)",zIndex:3},"aria-label":"Scroll to bottom",children:e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[e.jsx(ee.DownOutlined,{}),S>0?e.jsx("span",{style:{position:"absolute",top:-12,right:-18,minWidth:18,height:18,borderRadius:999,background:"#f44336",color:"#fff",fontSize:10,lineHeight:"18px",padding:"0 5px",textAlign:"center",fontWeight:700},children:S}):null]})}):null,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,borderTop:"1px solid #eee",backgroundColor:"#fff",borderRadius:9999,width:"100%",flexShrink:0,padding:"8px 8px 8px 12px",boxSizing:"border-box"},onDragOver:ae=>ae.preventDefault(),onDrop:ae=>{ae.preventDefault();const pe=Array.from(ae.dataTransfer?.files||[]);qe(pe)},children:[e.jsx("input",{type:"file",multiple:!0,ref:z,style:{display:"none"},accept:"image/*,application/pdf",capture:"environment",onChange:ae=>{const pe=Array.from(ae.target.files||[]);qe(pe),ae.target.value=""}}),e.jsx(a.Button,{type:"text",onClick:()=>z.current?.click(),style:{minWidth:0,width:38,height:38,borderRadius:"50%"},"aria-label":"Attach",icon:e.jsx(ee.PlusOutlined,{})}),e.jsx(a.Button,{type:"text",onClick:()=>R(!x),style:{minWidth:0,width:38,height:38,borderRadius:"50%"},"aria-label":"Emoji",icon:e.jsx(ee.SmileOutlined,{})}),e.jsx(a.Input,{placeholder:"Type a message",value:A,onChange:ae=>C(ae.target.value),onPaste:ae=>{const Pe=Array.from(ae.clipboardData?.items||[]).filter(Ee=>Ee.kind==="file").map(Ee=>Ee.getAsFile()).filter(Boolean);Pe.length&&qe(Pe)},style:{flex:1,borderRadius:9999},onPressEnter:Je}),e.jsx(a.Button,{type:"primary",onClick:Je,disabled:!A.trim()&&b.length===0||!me,style:{minWidth:0,width:40,height:40,borderRadius:"50%",backgroundColor:"#25D366",border:"none"},"aria-label":"Send",icon:e.jsx(ee.SendOutlined,{})})]}),x&&e.jsx("div",{style:{borderTop:"1px solid #eee",display:"flex",flexWrap:"wrap",gap:2,padding:"6px 8px",maxHeight:180,overflowY:"auto"},children:Kb.map((ae,pe)=>e.jsx("button",{type:"button",onClick:()=>ye(ae),style:{fontSize:20,background:"none",border:"none",cursor:"pointer",padding:2},children:ae},pe))}),x&&e.jsxs("div",{style:{borderTop:"1px solid #eee",padding:"8px",maxHeight:200,overflowY:"auto"},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:6},children:Gb[k]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gap:2},children:(_.trim()?Object.values(Cl).flat().filter(ae=>ae.toLowerCase().includes(_.toLowerCase())):Cl[k]).map((ae,pe)=>e.jsx("button",{type:"button",onClick:()=>ye(ae),style:{fontSize:20,background:"none",border:"none",cursor:"pointer",padding:2,textAlign:"center"},children:ae},`emoji-${ae}-${pe}`))})]}),b.length>0&&e.jsx("div",{style:{borderTop:"1px solid #eee",display:"flex",flexWrap:"wrap",gap:8,padding:8},children:b.map((ae,pe)=>ae?.previewUrl||Wb(ae?.name||"")?e.jsxs("div",{style:{position:"relative"},children:[e.jsx("img",{alt:"Attachment preview",src:ae.previewUrl,style:{width:80,height:80,objectFit:"cover",borderRadius:6,border:"1px solid #eee"}}),e.jsx(a.Button,{type:"text",danger:!0,onClick:()=>Le(pe),style:{position:"absolute",top:0,right:0,minWidth:0,padding:"2px 6px"},icon:e.jsx(ee.DeleteOutlined,{})})]},pe):e.jsxs("div",{style:{padding:"4px 8px",borderRadius:6,border:"1px solid #ddd",backgroundColor:"#fafafa",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[ae?.name||"Attachment",e.jsx(a.Button,{type:"text",danger:!0,onClick:()=>Le(pe),style:{minWidth:0,padding:"2px 6px"},icon:e.jsx(ee.DeleteOutlined,{})})]},pe))})]})]})]})}function Jb({token:t}){return e.jsx("div",{style:{display:"grid",gap:20,height:"calc(100vh - 140px)"},children:e.jsx(a.Card,{title:e.jsxs(a.Space,{children:[e.jsx(ee.MailOutlined,{}),e.jsx(a.Typography.Title,{level:5,style:{margin:0},children:"Send Whatsapp Message"})]}),style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:e.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden",padding:24},children:e.jsx(qo,{token:t})})})})}const Qb=({routes:t=[],onNavigate:n})=>e.jsx(a.Row,{gutter:[16,16],children:t.map((s,r)=>e.jsx(a.Col,{xs:24,md:8,lg:8,children:e.jsx(w,{children:e.jsx(Tl,{icon:s?.icon??"",title:s?.title??"",path:s?.path??"",onClick:n})})},`${r}route001`))});exports.About=xb;exports.AcademicYear=eb;exports.Academics=og;exports.AddBook=Tm;exports.AddDriver=bm;exports.AddExpense=Hy;exports.AddHomework=Cm;exports.AddIncome=Uy;exports.AddStaff=Xh;exports.AdmissionEnquiry=Qu;exports.ApplyLeave=$f;exports.AprroveLeaveRequest=If;exports.AssignByClass=Eg;exports.AssignStudentSubject=rg;exports.AssignStudentToTransport=xm;exports.AssignSubjects=Pg;exports.AssignTimeGroup=zg;exports.AssignVehicles=dm;exports.AttendanceDashboard=jy;exports.BookList=Rm;exports.BulkUpload=lg;exports.BuySellProduct=ph;exports.Category=th;exports.Chat=Jb;exports.ChatBar=qo;exports.Class=jg;exports.CoScholasticArea=Qg;exports.Complain=Gp;exports.CreateTimeGroup=Ug;exports.DailyAttendance=Cy;exports.Department=zf;exports.Designation=Vf;exports.DownloadExpense=Xy;exports.ErpDashboard=Vo;exports.ExpenseHead=tg;exports.FeeReceiptSetting=sb;exports.FeesInfo=Ab;exports.GatePass=rm;exports.GeneralSetting=wx;exports.Holidays=Tg;exports.IncomeHead=Ly;exports.IssueReturn=km;exports.LeaveType=Nf;exports.LibraryAssignStudent=Pm;exports.LibraryCategory=Om;exports.LibraryRenewalReport=Em;exports.LibraryReport=Mm;exports.ManageStock=Ch;exports.MarksheetSetting=pb;exports.MedicalReport=ng;exports.MenuSubmenu=Ou;exports.MonthlyReport=Ty;exports.Notes=ax;exports.NpmReport=kh;exports.Organization=Kx;exports.PaymentGateway=Fb;exports.Payroll=Cf;exports.PayrollReceiptDetails=sy;exports.PayrollSettings=Pb;exports.PhoneCallLog=Dp;exports.PostalDispatch=Op;exports.PostalReceive=Bp;exports.Privacy=yb;exports.Products=Qm;exports.PromoteStudents=Hg;exports.RoutePage=Qb;exports.RouteTimeTable=jm;exports.SearchExpense=Zy;exports.SearchIncome=By;exports.Sections=fg;exports.SellReports=vh;exports.SetupFrontOffice=am;exports.Shift=Gf;exports.Sms=Ub;exports.SmsAlertSetting=Lb;exports.SmsSetting=qb;exports.StaffAttendance=yf;exports.StaffAttendanceReport=jf;exports.StaffDailyAttendance=ty;exports.StaffDirectory=nf;exports.StockReport=Ih;exports.Stoppage=vm;exports.StudentAttendance=vy;exports.StudentLoginCredential=ag;exports.SubCategory=lh;exports.Subjects=_g;exports.SubmissionDetails=Am;exports.Syllabus=ux;exports.Terms=hb;exports.TimeTable=vx;exports.TransferCertificate=lx;exports.TransportBulkUpload=wm;exports.TransportRoutes=im;exports.TransportVehicles=lm;exports.Unit=yh;exports.Vendor=zm;exports.VisitorBook=xp;exports.YearlyReport=Py;exports.getImageBaseUrl=at;exports.setBaseUrl=Rc;exports.setImageBaseUrl=Ic;
|
|
59
|
+
`}),e.jsx(w,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(Jt,{data:{tableRef:$}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:$,style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,flexWrap:"wrap",marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#222"},children:[e.jsx("span",{children:"Show"}),e.jsx(s.Select,{size:"small",value:L.rowsPerPage,onChange:ce=>N(1,ce),options:[10,25,50,100].map(ce=>({label:ce,value:ce})),style:{width:72}}),e.jsx("span",{children:"entries"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:12,color:"#222"},children:"Search:"}),e.jsx(s.Input,{size:"small",allowClear:!0,value:C,onChange:ce=>{E(ce.target.value),B(ve=>({...ve,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(da,{})}),Te]}),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 ${we} to ${ke} of ${me} entries`}),e.jsx(s.Pagination,{current:L.page,pageSize:L.rowsPerPage,total:me||0,showSizeChanger:!1,onChange:N})]})]})]})},xg=({token:t,type:a})=>{const[n,r]=i.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${n.page}&per_page=${n.rowsPerPage}`,{isLoading:c,data:h,error:f}=q(t?[d,t]:null,([R,I])=>W(R,I)),[p,m]=i.useState(!1),v=(R,I)=>{r({page:R,rowsPerPage:parseInt(I)})},S=async R=>{},y=R=>{console.log("dsdsdsdsd",R),m(R)},g=()=>{},b=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],D=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(R,I)=>R.name.localeCompare(I.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(R,I)=>(R.contact||"").localeCompare(I.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(R,I)=>(R.description||"").localeCompare(I.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(R,I)=>(R.source_name||"").localeCompare(I.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(R,I)=>new Date(R.date)-new Date(I.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(R,I)=>new Date(R.follow_up_date)-new Date(I.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Ke,{parentCallback:v,data:{newData:h,columns:D,action:!0,Loading:c,error:f,open:p,viewDetails:g,deleteTodoMutation:S,DrawerUpdate:y,ActionView:b}})})};var bg=au();const yi=Zc(bg),uu=()=>{};class ho extends i.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=a=>{this.selectRef=a};componentDidUpdate(a){a.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(a,n)=>{this.props.onChange(a,n),this.setState({value:a})};getValue=()=>{const{value:a}=this.state;return a?Array.isArray(a)?a.length?"valid":"":typeof a=="object"?a.value||"":a:""};render(){const{SelectComponent:a,required:n,...r}=this.props,{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(a,{...r,ref:this.setSelectRef,onChange:this.onChange}),l&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:uu,onFocus:()=>this.selectRef.focus(),required:n})]})}}ho.defaultProps={onChange:uu};ho.protoTypes={selectComponent:yi.func.isRequired,onChange:yi.func,required:yi.bool};const jg={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Sg={menuPortal:t=>({...t,zIndex:9999}),control:(t,a)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#a8a8a8"}`}}),valueContainer:t=>({...t,height:40,padding:"0 0",display:"flex",alignItems:"center"}),input:t=>({...t,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),indicatorsContainer:t=>({...t,height:40}),dropdownIndicator:(t,a)=>({...t,padding:"0 0 0 8px",color:a.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,a)=>({...t,fontSize:"14px",backgroundColor:a.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},pu=t=>e.jsx(jc.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),wg=t=>e.jsx(ho,{...t,SelectComponent:jc,components:{Input:pu},options:t.options}),ae=i.forwardRef(({...t},a)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:jg,children:t?.label}),e.jsx(wg,{components:{Input:pu},menuPortalTarget:document.body,styles:Sg,className:"input-cont",...t,ref:a})]})),vg={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Cg={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},_g=(t,a,n)=>a?t>ne(n).endOf("day")||t<ne(a).endOf("day"):!1,Ge=i.forwardRef(function(a,n){const{...r}=a;return e.jsxs("div",{className:"form-group",children:[r.Desplay&&e.jsx("label",{className:`labelfont ${r.classnme?r.classnme:""}`,style:vg,children:r.Desplay}),e.jsx(s.DatePicker,{...r,style:{...Cg,...r.style||{}},className:"form-group",disabledDate:o=>_g(o,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:n})]})}),Ag={minWidth:160,height:36,padding:"0 28px",border:"none",borderRadius:999,background:"linear-gradient(90deg, #f59b1c 0%, #ef3e7b 100%)",color:"#fff",fontSize:14,fontWeight:700,textTransform:"uppercase",cursor:"pointer",boxShadow:"none"},de=i.forwardRef(({error:t,success:a,disabled:n,loading:r,style:o,...l},d)=>e.jsxs("div",{className:"form-group",style:{marginBottom:0,position:"relative"},children:[e.jsx("input",{...l,ref:d,disabled:n||r,style:{...Ag,opacity:n||r?.7:1,cursor:n||r?"not-allowed":"pointer",...o||{}}}),r?e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",opacity:.8,children:e.jsx("animateTransform",{attributeName:"transform",type:"rotate",dur:"0.8s",values:"0 0 0 0;360 0 0 0",repeatCount:"indefinite",children:e.jsx("circle",{cx:"8",cy:"8",r:"6",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeDasharray:"60",strokeLinecap:"round",children:e.jsx("animate",{attributeName:"stroke-dashoffset",type:"subtract",from:"60",to:"0",dur:"0.8s",repeatCount:"indefinite"})})})})}):null]})),Tg={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Dg={width:"100%",minHeight:80,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",resize:"vertical",transition:"border-color 0.2s ease"},kt=({style:t,onFocus:a,onBlur:n,...r})=>{const[o,l]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:Tg,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{l(!0),a?.(d)},onBlur:d=>{l(!1),n?.(d)},style:{...Dg,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},pt=t=>({optimisticData:a=>[...a.data,t],populateCache:(a,n)=>[...n.data,a]}),ot=t=>({optimisticData:a=>a.data.filter(n=>n.id!==t),populateCache:(a,n)=>n.data.filter(r=>r.id!==t)}),kg=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Rg="api/branchapi/Frontoffice/visitorbookShowdata",Ig="api/branchapi/Frontoffice/purposedropdown";function Pg({data:t}){const{handleUpdate:a,token:n}=t||{},r=i.useContext(ta),o=Rg.replace(/\?.*$/,""),{isLoading:l,data:d}=q(n&&r?[o,r,n]:null,([g,b,D])=>An(g,{id:b},D)),{isLoading:c,data:h}=q(n?[Ig,n]:null,([g,b])=>W(g,b)),f=i.useMemo(()=>kg(h),[h]),p=d?.data?.[0],[m,v]=i.useState({purpose:void 0,name:"",phone:"",id_card:"",number_of_person:1,date:null,in_time:null,out_time:null,note:"",address:"",image:""});i.useEffect(()=>{p&&v({purpose:p?.purpose,name:p?.name||"",phone:p?.contact||"",id_card:p?.id_proof||"",number_of_person:p?.no_of_pepple||1,date:p?.date?ne(p.date):null,in_time:p?.in_time?ne(p.in_time,"h:mm a"):null,out_time:p?.out_time?ne(p.out_time,"h:mm a"):null,note:p?.note||"",address:p?.address||"",image:p?.image||""})},[p]);const S=(g,b)=>{v(D=>({...D,[g]:b}))},y=`${Nt()}/branchapi/frontoffice/uploadfrontofficeDocument`;return l||c?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:g=>a(g,r),children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Visitor"})}),e.jsx(w,{p:2,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",allowSelectAll:!1,value:m.purpose,onChange:g=>S("purpose",g)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"name",type:"text",label:"Name",required:!0,value:m.name,onChange:g=>S("name",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"phone",type:"text",label:"Phone No.",required:!0,value:m.phone,onChange:g=>S("phone",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"id_card",type:"text",label:"ID Card",value:m.id_card,onChange:g=>S("id_card",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"number_of_person",type:"number",label:"Number of Person",value:m.number_of_person,onChange:g=>S("number_of_person",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",value:m.date,Desplay:"Date",id:"date",name:"date",required:!0,onChange:g=>S("date",g)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",value:m.in_time,onChange:g=>S("in_time",g),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:m.in_time?m.in_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",value:m.out_time,onChange:g=>S("out_time",g),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time",value:m.out_time?m.out_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note",value:m.note,onChange:g=>S("note",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(kt,{type:"text",label:"Address",name:"address",rows:3,required:!0,value:m.address,onChange:g=>S("address",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.Upload,{action:y,headers:{Authorization:n},maxCount:1,onChange:g=>{if(g.file.status==="removed"&&S("image",""),g.file.status==="done"){const b=g.file.response?.data??g.file.response?.file??"";S("image",String(b??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:m.image?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:m.image||"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; }"})]})}const Mg=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},nn="api/branchapi/Frontoffice/visitortablelist",Eg="api/branchapi/Frontoffice/purposedropdown",Og="api/branchapi/frontoffice/addvisitors",$g="api/branchapi/frontoffice/editvisitorsdata",Fg="api/branchapi/frontoffice/deletevisitors",Bg=`${Nt()}/branchapi/frontoffice/uploadfrontofficeDocument`;function Lg({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,h]=i.useState(""),[f,p]=i.useState("03:30 PM"),m=(k,F)=>{n({page:k,rowsPerPage:Number.parseInt(F,10)})},v=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],S=i.useMemo(()=>{const k=nn.includes("?")?nn.endsWith("?")||nn.endsWith("&")?"":"&":"?";return`${nn}${k}page=${a.page}&per_page=${a.rowsPerPage}`},[nn,a.page,a.rowsPerPage]),{isLoading:y,error:g,data:b,mutate:D}=q(t?[S,t]:null,([k,F])=>W(k,F)),{isLoading:R,data:I}=q(t?[Eg,t]:null,([k,F])=>W(k,F)),A=i.useMemo(()=>Mg(I),[I]),_=async(k,F)=>{try{await D(Ze(k,F,t),pt(F)),T.success("Success! Added new item.")}catch{T.error("Failed to add the new item.")}},u=async k=>{try{await D(st(Fg,k,t),ot(k)),T.success("Success! Deleted item.")}catch{T.error("Failed to delete the item.")}},x=async(k,F,C)=>{try{const E=await ct(k,F,t);D(E),Array.isArray(E?.data)&&D(`${nn.replace(/\?.*$/,"")}?id=${C}`,E),T.success("Success! Updated item.")}catch{T.error("Failed to update the item.")}},j=async(k,F)=>{k.preventDefault();const C=new FormData(k.target);await x($g,C,F),k.target.reset(),d(""),o(!1)},P=async k=>{if(k.preventDefault(),!k.target?.date?.value)T.error("Select required dates"),k.target?.date?.focus(),h("textDanger");else{const F=new FormData(k.target);await _(Og,F),k.target.reset(),h(""),d(""),p("03:30 PM")}},O=k=>{o(k)},z=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Address",selector:"address",sortable:!0},{id:"5",name:"In Time",selector:"in_time",sortable:!0},{id:"6",name:"Out Time",selector:"out_time",sortable:!0}],[]);return e.jsxs("div",{children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Visitor"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:P,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",required:!0,allowSelectAll:!1})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone No.",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"id_card",type:"text",label:"ID Card"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{defaultValue:1,name:"number_of_person",type:"number",label:"Number of Person"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",defaultValue:ne(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>h("")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.TimePicker,{defaultValue:ne("2022-04-17T15:30","h:mm a"),id:"in_time",use12Hours:!0,format:"h:mm a",onChange:(k,F)=>p(F),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:f,readOnly:!0})]})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(kt,{type:"text",label:"Address*",name:"address",rows:3,required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.Upload,{action:Bg,headers:{Authorization:t},maxCount:1,onChange:k=>{if(k.file.status==="removed"&&d(""),k.file.status==="done"){const F=k.file.response?.data??k.file.response?.file??"";d(String(F??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:l?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Visitor List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:m,data:{newData:b,columns:z,action:!0,ActionView:v,Loading:y,error:g,editDesign:e.jsx(Pg,{data:{handleUpdate:j,token:t}}),deleteTodoMutation:u,open:r,DrawerUpdate:O,viewDetails:""}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Ug="api/branchapi/frontoffice/generalcallsShowdata",Ng=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}];function zg({data:t}){const{handleUpdate:a,token:n}=t||{},r=i.useContext(ta),o=Ug.replace(/\?.*$/,""),{isLoading:l,data:d}=q(n&&r?[o,r,n]:null,([m,v,S])=>An(m,{id:v},S)),c=d?.data?.[0],[h,f]=i.useState({name:"",phone:"",description:"",date:null,next_follow_up_date:null,call_duration:"",note:"",call_type:""});i.useEffect(()=>{c&&f({name:c?.name||"",phone:c?.contact||"",description:c?.description||"",date:c?.date?ne(c.date):null,next_follow_up_date:c?.follow_up_date?ne(c.follow_up_date):null,call_duration:c?.call_dureation||"",note:c?.note||"",call_type:c?.call_type||""})},[c]);const p=(m,v)=>{f(S=>({...S,[m]:v}))};return l?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,r),children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Call Log"})}),e.jsx(w,{p:2,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"name",type:"text",label:"Name",required:!0,value:h.name,onChange:m=>p("name",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",value:h.phone,onChange:m=>p("phone",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description",value:h.description,onChange:m=>p("description",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",value:h.date,Desplay:"Date",id:"date",name:"date",onChange:m=>p("date",m)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",value:h.next_follow_up_date,Desplay:"Next Follow Up Date",id:"fdate",name:"next_follow_up_date",onChange:m=>p("next_follow_up_date",m)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"call_duration",type:"text",label:"Call Duration",value:h.call_duration,onChange:m=>p("call_duration",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note",value:h.note,onChange:m=>p("note",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:Ng,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:h.call_type?{value:h.call_type,label:h.call_type}:null,onChange:m=>p("call_type",m?.value||"")})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const sn="api/branchapi/frontoffice/generalcalltablelist",qg="api/branchapi/frontoffice/addgenaralcalls",Yg="api/branchapi/frontoffice/editgeneralcall",Wg="api/branchapi/frontoffice/deletegeneralcall",Vg=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}],Hg=[{key:"all",label:"All Calls"},{key:"Incoming",label:"Incoming"},{key:"Outgoing",label:"Outgoing"}];function Kg({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,h]=i.useState(""),[f,p]=i.useState("all"),[m,v]=i.useState(""),S=i.useRef(null),y=(k,F)=>{n({page:k,rowsPerPage:Number.parseInt(F,10)})},g=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],b=i.useMemo(()=>{const k=sn.includes("?")?sn.endsWith("?")||sn.endsWith("&")?"":"&":"?",F=new URLSearchParams;return F.set("page",String(a.page)),F.set("per_page",String(a.rowsPerPage)),f!=="all"&&F.set("call_type",f),`${sn}${k}${F.toString()}`},[sn,a.page,a.rowsPerPage,f]),{isLoading:D,error:R,data:I,mutate:A}=q(t?[b,t]:null,([k,F])=>W(k,F)),_=async(k,F)=>{try{await A(Ze(k,F,t),pt(F)),T.success("Success! Added new item.")}catch{T.error("Failed to add the new item.")}},u=async k=>{try{await A(st(Wg,k,t),ot(k)),T.success("Success! Deleted item.")}catch{T.error("Failed to delete the item.")}},x=async(k,F,C)=>{try{const E=await ct(k,F,t);A(E),Array.isArray(E?.data)&&A(`${sn.replace(/\?.*$/,"")}?id=${C}`,E),T.success("Success! Updated item.")}catch{T.error("Failed to update the item.")}},j=async(k,F)=>{k.preventDefault();const C=new FormData(k.target);await x(Yg,C,F),k.target.reset(),d(""),o(!1)},P=async k=>{if(k.preventDefault(),!k.target?.date?.value)T.error("Select required dates"),k.target?.date?.focus(),h("textDanger");else{const F=new FormData(k.target);await _(qg,F),k.target.reset(),h(""),d(""),v("")}},O=k=>{o(k)},z=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Phone",selector:"contact",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Follow Up Date",selector:"follow_up_date",sortable:!0},{id:"6",name:"Call Duration",selector:"call_dureation",sortable:!0}],[]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Phone Call Log"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:P,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",defaultValue:ne(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>h("")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",Desplay:"Next Follow Up Date",id:"fdate",name:"follow_up_date"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"call_dureation",type:"text",label:"Call Duration"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:Vg,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:m?{value:m,label:m}:null,onChange:k=>v(k?.value||"")})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Phone Call Log List"})}),e.jsxs(w,{pt:3,children:[e.jsx(s.Tabs,{activeKey:f,onChange:p,items:Hg}),e.jsx(Jt,{data:{tableRef:S}}),e.jsx(Ke,{parentCallback:y,data:{newData:I,columns:z,action:!0,ActionView:g,Loading:D,error:R,editDesign:e.jsx(zg,{data:{handleUpdate:j,token:t}}),deleteTodoMutation:u,open:r,DrawerUpdate:O,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Gg="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function Jg({data:t}){const{handleUpdate:a,token:n}=t||{},r=i.useContext(ta),o=Gg.replace(/\?.*$/,""),{isLoading:l,data:d}=q(n&&r?[o,r,n]:null,([m,v,S])=>An(m,{id:v},S)),c=d?.data?.[0],[h,f]=i.useState({to_title:"",refernce:"",address:"",note:"",from_title:"",date:null,image:""});i.useEffect(()=>{c&&f({to_title:c?.to_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",from_title:c?.from_title||"",date:c?.date?ne(c.date):null,image:c?.image||""})},[c]);const p=(m,v)=>{f(S=>({...S,[m]:v}))};return l?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,r),children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Dispatch"})}),e.jsx(w,{p:2,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"title",type:"text",label:"To Title *",required:!0,value:h.to_title,onChange:m=>p("to_title",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"refernce",type:"text",label:"Reference No",value:h.refernce,onChange:m=>p("refernce",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"address",type:"text",label:"Address",required:!0,value:h.address,onChange:m=>p("address",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note",value:h.note,onChange:m=>p("note",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"from_title",type:"text",label:"From Title",required:!0,value:h.from_title,onChange:m=>p("from_title",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",value:h.date,Desplay:"Date",id:"date",name:"date",onChange:m=>p("date",m)})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const rn="api/branchapi/frontoffice/postaldispatchtablelist",Qg="api/branchapi/frontoffice/addpostaldispatch",Xg="api/branchapi/frontoffice/editpostaldispatch",Zg="api/branchapi/frontoffice/deletepostalreceivedispatch";function ey({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,h]=i.useState(""),f=i.useRef(null),p=(j,P)=>{n({page:j,rowsPerPage:Number.parseInt(P,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],v=i.useMemo(()=>{const j=rn.includes("?")?rn.endsWith("?")||rn.endsWith("&")?"":"&":"?";return`${rn}${j}page=${a.page}&per_page=${a.rowsPerPage}`},[rn,a.page,a.rowsPerPage]),{isLoading:S,error:y,data:g,mutate:b}=q(t?[v,t]:null,([j,P])=>W(j,P)),D=async(j,P)=>{try{await b(Ze(j,P,t),pt(P)),T.success("Success! Added new item.")}catch{T.error("Failed to add the new item.")}},R=async j=>{try{await b(st(Zg,j,t),ot(j)),T.success("Success! Deleted item.")}catch{T.error("Failed to delete the item.")}},I=async(j,P,O)=>{try{const z=await ct(j,P,t);b(z),Array.isArray(z?.data)&&b(`${rn.replace(/\?.*$/,"")}?id=${O}`,z),T.success("Success! Updated item.")}catch{T.error("Failed to update the item.")}},A=async(j,P)=>{j.preventDefault();const O=new FormData(j.target);await I(Xg,O,P),j.target.reset(),d(""),o(!1)},_=async j=>{if(j.preventDefault(),!j.target?.date?.value)T.error("Select required dates"),j.target?.date?.focus(),h("textDanger");else{const P=new FormData(j.target);await D(Qg,P),j.target.reset(),h(""),d("")}},u=j=>{o(j)},x=i.useMemo(()=>[{id:"1",name:"To Title",selector:"to_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"From Title",selector:"from_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Dispatch"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:_,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:"title",type:"text",label:"To Title *"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:"from_title",type:"text",label:"From Title"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",defaultValue:ne(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>h("")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Dispatch List"})}),e.jsxs(w,{pt:3,children:[e.jsx(Jt,{data:{tableRef:f}}),e.jsx(Ke,{parentCallback:p,data:{newData:g,columns:x,action:!0,ActionView:m,Loading:S,error:y,editDesign:e.jsx(Jg,{data:{handleUpdate:A,token:t}}),deleteTodoMutation:R,open:r,DrawerUpdate:u,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const ty="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function ay({data:t}){const{handleUpdate:a,token:n}=t||{},r=i.useContext(ta),o=ty.replace(/\?.*$/,""),{isLoading:l,data:d}=q(n&&r?[o,r,n]:null,([m,v,S])=>An(m,{id:v},S)),c=d?.data?.[0],[h,f]=i.useState({from_title:"",refernce:"",address:"",note:"",title:"",date:null,image:""});i.useEffect(()=>{c&&f({from_title:c?.from_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",title:c?.to_title||"",date:c?.date?ne(c.date):null,image:c?.image||""})},[c]);const p=(m,v)=>{f(S=>({...S,[m]:v}))};return l?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,r),children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Receive"})}),e.jsx(w,{p:2,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"from_title",type:"text",label:"From Title *",required:!0,value:h.from_title,onChange:m=>p("from_title",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"refernce",type:"text",label:"Reference No",required:!0,value:h.refernce,onChange:m=>p("refernce",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"address",type:"text",label:"Address",required:!0,value:h.address,onChange:m=>p("address",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note",value:h.note,onChange:m=>p("note",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"title",type:"text",label:"To Title",required:!0,value:h.title,onChange:m=>p("title",m.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",value:h.date,Desplay:"Date",id:"date",name:"date",onChange:m=>p("date",m)})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const on="api/branchapi/frontoffice/postalrecivetablelist",ny="api/branchapi/frontoffice/addpostalrecive",sy="api/branchapi/frontoffice/editpostalrecive",ry="api/branchapi/frontoffice/deletepostalreceivedispatch";function iy({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,h]=i.useState(""),f=i.useRef(null),p=(j,P)=>{n({page:j,rowsPerPage:Number.parseInt(P,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],v=i.useMemo(()=>{const j=on.includes("?")?on.endsWith("?")||on.endsWith("&")?"":"&":"?";return`${on}${j}page=${a.page}&per_page=${a.rowsPerPage}`},[on,a.page,a.rowsPerPage]),{isLoading:S,error:y,data:g,mutate:b}=q(t?[v,t]:null,([j,P])=>W(j,P)),D=async(j,P)=>{try{await b(Ze(j,P,t),pt(P)),T.success("Success! Added new item.")}catch{T.error("Failed to add the new item.")}},R=async j=>{try{await b(st(ry,j,t),ot(j)),T.success("Success! Deleted item.")}catch{T.error("Failed to delete the item.")}},I=async(j,P,O)=>{try{const z=await ct(j,P,t);b(z),Array.isArray(z?.data)&&b(`${on.replace(/\?.*$/,"")}?id=${O}`,z),T.success("Success! Updated item.")}catch{T.error("Failed to update the item.")}},A=async(j,P)=>{j.preventDefault();const O=new FormData(j.target);await I(sy,O,P),j.target.reset(),d(""),o(!1)},_=async j=>{if(j.preventDefault(),!j.target?.date?.value)T.error("Select required dates"),j.target?.date?.focus(),h("textDanger");else{const P=new FormData(j.target);await D(ny,P),j.target.reset(),h(""),d("")}},u=j=>{o(j)},x=i.useMemo(()=>[{id:"1",name:"From Title",selector:"from_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"To Title",selector:"to_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Receive"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:_,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:"from_title",type:"text",label:"From Title *"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:"title",type:"text",label:"To Title"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",defaultValue:ne(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>h("")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Receive List"})}),e.jsxs(w,{pt:3,children:[e.jsx(Jt,{data:{tableRef:f}}),e.jsx(Ke,{parentCallback:p,data:{newData:g,columns:x,action:!0,ActionView:m,Loading:S,error:y,editDesign:e.jsx(ay,{data:{handleUpdate:A,token:t}}),deleteTodoMutation:R,open:r,DrawerUpdate:u,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const oy="api/branchapi/frontoffice/complaintShowdata",ly="api/branchapi/frontoffice/complainttypedropdown",dy=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function cy({data:t}){const{handleUpdate:a,token:n}=t||{},r=i.useContext(ta),o=oy.replace(/\?.*$/,""),{isLoading:l,data:d}=q(n&&r?[o,r,n]:null,([g,b,D])=>An(g,{id:b},D)),{isLoading:c,data:h}=q(n?[ly,n]:null,([g,b])=>W(g,b)),f=i.useMemo(()=>dy(h).map(b=>({value:b?.value??b?.id??b?.complaint_type??"",label:b?.complaint_type??b?.label??""})),[h]),p=d?.data?.[0],[m,v]=i.useState({complain_type:"",complain_by_name:"",phone:"",date:null,description:"",action_token:"",assigned:"",note:"",file:""});i.useEffect(()=>{p&&v({complain_type:p?.complaint_type??"",complain_by_name:p?.name??"",phone:p?.contact??"",date:p?.date?ne(p.date):null,description:p?.description??"",action_token:p?.action_taken??"",assigned:p?.assigned??"",note:p?.note??"",file:p?.image??""})},[p]);const S=(g,b)=>{v(D=>({...D,[g]:b}))},y=i.useMemo(()=>f.find(g=>g.value===m.complain_type)||null,[f,m.complain_type]);return l||c?e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsx(w,{pt:4,pb:1,style:{width:550},children:e.jsxs("form",{onSubmit:g=>a(g,r),children:[e.jsx("input",{type:"hidden",name:"id",value:r??""}),e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Complaint"})}),e.jsx(w,{p:2,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",allowSelectAll:!1,value:y,onChange:g=>S("complain_type",g?.value??"")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0,value:m.complain_by_name,onChange:g=>S("complain_by_name",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{10}",value:m.phone,onChange:g=>S("phone",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",value:m.date,Desplay:"Enquiry Date",id:"date",name:"date",onChange:g=>S("date",g)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description",value:m.description,onChange:g=>S("description",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"action_token",type:"text",label:"Action Taken",value:m.action_token,onChange:g=>S("action_token",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"assigned",type:"text",label:"Assigned",value:m.assigned,onChange:g=>S("assigned",g.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note",value:m.note,onChange:g=>S("note",g.target.value)})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})]})})}const ln="api/branchapi/frontoffice/complainttablelist",uy="api/branchapi/frontoffice/complainttypedropdown",py="api/branchapi/frontoffice/addcomplaint",my="api/branchapi/frontoffice/editcomplaint",hy="api/branchapi/frontoffice/deletecomplaint",fy=[{key:"all",label:"All Complaints"},{key:"pending",label:"Pending"},{key:"resolved",label:"Resolved"}];function gy({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,h]=i.useState(""),[f,p]=i.useState("all"),m=i.useRef(null),v=(F,C)=>{n({page:F,rowsPerPage:Number.parseInt(C,10)})},S=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],y=i.useMemo(()=>{const F=ln.includes("?")?ln.endsWith("?")||ln.endsWith("&")?"":"&":"?",C=new URLSearchParams;return C.set("page",String(a.page)),C.set("per_page",String(a.rowsPerPage)),f!=="all"&&C.set("status",f),`${ln}${F}${C.toString()}`},[ln,a.page,a.rowsPerPage,f]),{isLoading:g,error:b,data:D,mutate:R}=q(t?[y,t]:null,([F,C])=>W(F,C)),{isLoading:I,data:A}=q(t?[uy,t]:null,([F,C])=>W(F,C)),_=i.useMemo(()=>{const F=A?.data??A??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},[A]),u=async(F,C)=>{try{await R(Ze(F,C,t),pt(C)),T.success("Success! Added new item.")}catch{T.error("Failed to add the new item.")}},x=async F=>{try{await R(st(hy,F,t),ot(F)),T.success("Success! Deleted item.")}catch{T.error("Failed to delete the item.")}},j=async(F,C,E)=>{try{const M=await ct(F,C,t);R(M),Array.isArray(M?.data)&&R(`${ln.replace(/\?.*$/,"")}?id=${E}`,M),T.success("Success! Updated item.")}catch{T.error("Failed to update the item.")}},P=async(F,C)=>{F.preventDefault();const E=new FormData(F.target);await j(my,E,C),F.target.reset(),d(""),o(!1)},O=async F=>{if(F.preventDefault(),!F.target?.date?.value)T.error("Select required dates"),F.target?.date?.focus(),h("textDanger");else{const C=new FormData(F.target);await u(py,C),F.target.reset(),h(""),d("")}},z=F=>{o(F)},k=i.useMemo(()=>[{id:"1",name:"Complain Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Action Taken",selector:"action_taken",sortable:!0},{id:"6",name:"Assigned",selector:"assigned",sortable:!0}],[]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Complaint"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:O,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",required:!0,allowSelectAll:!1})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",defaultValue:ne(),Desplay:"Complain Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>h("")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"action_token",type:"text",label:"Action Taken"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"assigned",type:"text",label:"Assigned"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"note",type:"text",label:"Note"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx("input",{type:"hidden",name:"file",value:l||"",readOnly:!0})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Complaint List"})}),e.jsxs(w,{pt:3,children:[e.jsx(s.Tabs,{activeKey:f,onChange:p,items:fy}),e.jsx(Jt,{data:{tableRef:m}}),e.jsx(Ke,{parentCallback:v,data:{newData:D,columns:k,action:!0,ActionView:S,Loading:g,error:b,editDesign:e.jsx(cy,{data:{handleUpdate:P,token:t}}),deleteTodoMutation:x,open:r,DrawerUpdate:z,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Ml="api/branchapi/Frontoffice/purposetablelist",yy="api/branchapi/Frontoffice/complaint_typetablelist",xy="api/branchapi/Frontoffice/sourcetablelist",by="api/branchapi/Frontoffice/referencetablelist",El="api/branchapi/frontoffice/visitorpurposeShowdata",jy="api/branchapi/frontoffice/complaintTypeShowdata",Sy="api/branchapi/frontoffice/sourceShowdata",wy="api/branchapi/frontoffice/referenceShowdata",fn=[{key:"purpose",label:"Purpose"},{key:"complainType",label:"Complain Type"},{key:"source",label:"Source"},{key:"reference",label:"Reference"}],Ol={purpose:[{id:"1",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],complainType:[{id:"1",name:"Complaint Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],source:[{id:"1",name:"Source",selector:"source",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],reference:[{id:"1",name:"Reference",selector:"reference",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}]};function vy({token:t}){const[a,n]=i.useState("purpose"),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),c=i.useRef(null),h=(O,z)=>{o({page:O,rowsPerPage:Number.parseInt(z,10)})},f=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],p=()=>{switch(a){case"purpose":return Ml;case"complainType":return yy;case"source":return xy;case"reference":return by;default:return Ml}},m=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/addvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/addcomplaint_type";case"source":return"api/branchapi/frontoffice/addsource";case"reference":return"api/branchapi/frontoffice/addreference";default:return"api/branchapi/frontoffice/addvisitors_purpose"}},v=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/editvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/editcomplaint_type";case"source":return"api/branchapi/frontoffice/editsource";case"reference":return"api/branchapi/frontoffice/editreference";default:return"api/branchapi/frontoffice/editvisitors_purpose"}},S=O=>{switch(a){case"purpose":return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:O};case"complainType":return{url:"api/branchapi/frontoffice/deletecomplaint_type",id:O};case"source":return{url:"api/branchapi/frontoffice/deletesource",id:O};case"reference":return{url:"api/branchapi/frontoffice/deletereference",id:O};default:return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:O}}},y=i.useMemo(()=>{const O=p(),z=O.includes("?")?O.endsWith("?")||O.endsWith("&")?"":"&":"?";return`${O}${z}page=${r.page}&per_page=${r.rowsPerPage}`},[a,r.page,r.rowsPerPage]),{isLoading:g,error:b,data:D,mutate:R}=q(t?[y,t]:null,([O,z])=>W(O,z)),I=async(O,z)=>{try{await Ze(O,z,t),await R(),T.success("Success! Added new item.")}catch{T.error("Failed to add the new item.")}},A=async O=>{const{url:z,id:k}=S(O);try{await st(z,k,t),await R(),T.success("Success! Deleted item.")}catch{T.error("Failed to delete the item.")}},_=async(O,z,k)=>{try{const F=await ct(O,z,t);R(F),Array.isArray(F?.data)&&R(`${p().replace(/\?.*$/,"")}?id=${k}`,F),T.success("Success! Updated item.")}catch{T.error("Failed to update the item.")}},u=async(O,z)=>{O.preventDefault();const k=new FormData(O.target),F=v();await _(F,k,z),O.target.reset(),d(!1)},x=async O=>{O.preventDefault();const z=new FormData(O.target),k=m();await I(k,z),O.target.reset()},j=O=>{d(O)},P=i.useMemo(()=>Ol[a]||Ol.purpose,[a]);return e.jsx(w,{pt:5,pb:1,children:e.jsx(s.Row,{gutter:[16,16],children:e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Setup Front Office"})}),e.jsxs(w,{p:3,children:[e.jsx(s.Tabs,{activeKey:a,onChange:O=>{n(O),o({page:1,rowsPerPage:10})},items:fn}),e.jsxs(s.Row,{gutter:[16,16],mt:3,children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsx("form",{onSubmit:x,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Add ",fn.find(O=>O.key===a)?.label]})}),e.jsx(w,{p:3,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{required:!0,name:a==="reference"?"title":"name",type:"text",label:fn.find(O=>O.key===a)?.label+" *"})})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description"})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Add",color:"primary"})})})})]})})]})})}),e.jsx(s.Col,{xs:24,md:16,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:[fn.find(O=>O.key===a)?.label," List"]})}),e.jsxs(w,{pt:3,children:[e.jsx(Jt,{data:{tableRef:c}}),e.jsx(Ke,{parentCallback:h,data:{newData:D,columns:P,action:!0,ActionView:f,Loading:g,error:b,editDesign:e.jsx(Cy,{data:{handleUpdate:u,token:t,activeTab:a}}),deleteTodoMutation:A,open:l,DrawerUpdate:j,viewDetails:""}})]})]})})]})]})]})})})})}function Cy({data:t}){const{handleUpdate:a,token:n,activeTab:r}=t||{},o=i.useContext(ta),d=(g=>{switch(g){case"purpose":return El;case"complainType":return jy;case"source":return Sy;case"reference":return wy;default:return El}})(r).replace(/\?.*$/,""),{isLoading:c,data:h}=q(n&&o?[d,o,n]:null,([g,b,D])=>An(g,{id:b},D)),f=h?.data?.[0],[p,m]=i.useState({name:"",description:""});i.useEffect(()=>{f&&m({name:f?.visitors_purpose||f?.complaint_type||f?.source||f?.reference||"",description:f?.description||""})},[f]);const v=(g,b)=>{m(D=>({...D,[g]:b}))};if(c)return e.jsx(w,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(s.Spin,{size:"large"})});const y={purpose:"title",complainType:"title",source:"title",reference:"title"}[r]||"name";return e.jsxs(w,{pt:4,pb:1,style:{width:350},children:[e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Edit ",fn.find(g=>g.key===r)?.label]})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:g=>a(g,o),children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{type:"text",value:o,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{name:y,type:"text",label:fn.find(g=>g.key===r)?.label+" *",required:!0,value:p.name,onChange:g=>v("name",g.target.value)})})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description",value:p.description,onChange:g=>v("description",g.target.value)})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"center",children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})]})})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const _y="api/branchapi/Student/studentGatePass",Ln="api/branchapi/Student/studentGatePassList";function Ay({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:25}),[r,o]=i.useState(!1),l=i.useRef(null),d=(I,A)=>{n({page:I,rowsPerPage:Number.parseInt(A,10)})},c=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],{data:h,mutate:f}=q(t?[_y,t]:null,([I,A])=>W(I,A)),p=i.useMemo(()=>{const I=Ln.includes("?")?Ln.endsWith("?")||Ln.endsWith("&")?"":"&":"?";return`${Ln}${I}page=${a.page}&per_page=${a.rowsPerPage}`},[Ln,a.page,a.rowsPerPage]),{isLoading:m,error:v,data:S,mutate:y}=q(t?[p,t]:null,([I,A])=>W(I,A)),g=async I=>{const A="api/branchapi/frontoffice/deletevisitors";try{await y(deleteData(A,I,t),ot(I)),T.success("Success! Deleted item.")}catch{T.error("Failed to delete the item.")}},b=I=>{o(I)},D=()=>{},R=[{title:"Name",dataIndex:"lastname",key:"lastname",render:(I,A)=>`${A?.lastname||""} ${A?.firstname||""}`.trim()},{title:"Class",dataIndex:"class_name",key:"class_name",render:(I,A)=>`${A?.class_name||""}-${A?.section_name||""}`},{title:"Father Name",dataIndex:"father_name",key:"father_name"},{title:"Authorized Persons",dataIndex:"authorized_persons_fullname",key:"authorized_persons_fullname"},{title:"Relation",dataIndex:"authorized_persons_relation",key:"authorized_persons_relation"},{title:"Generated Date",dataIndex:"genrated_date_time",key:"genrated_date_time"},{title:"Return Date",dataIndex:"expected_return_date_time",key:"expected_return_date_time"},{title:"Reason",dataIndex:"reason",key:"reason"},{title:"Action",key:"action",render:(I,A)=>e.jsx(s.Tag,{color:A?.status==="Generated"?"green":"blue",children:A?.status||"Pending"})},{title:"Print",key:"print",render:(I,A)=>e.jsx(re.PrinterOutlined,{style:{color:"#3892ee",cursor:"pointer"},onClick:()=>window.print()})}];return e.jsx(w,{pt:5,pb:1,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Today Gate Pass"})}),e.jsx(w,{pt:3,children:e.jsx(s.List,{grid:{column:4,gutter:16},dataSource:h?.data||[],style:{padding:0},renderItem:I=>e.jsx(s.List.Item,{style:{padding:0},children:e.jsx(s.Card,{size:"small",style:{marginBottom:8,width:"100%"},children:e.jsxs(w,{children:[e.jsxs(s.Typography.Text,{strong:!0,children:[I?.lastname," ",I?.firstname]}),e.jsx("br",{}),e.jsxs(s.Typography.Text,{type:"secondary",children:[I?.class_name,"-",I?.section_name]}),e.jsx("br",{}),e.jsxs(s.Typography.Text,{type:"secondary",children:["Return: ",I?.expected_return_date_time]}),e.jsx("br",{}),e.jsx(de,{type:"button",value:"Print",color:"primary",size:"small",onClick:()=>window.print(),style:{marginTop:4}})]})})})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Gate Pass List"})}),e.jsxs(w,{pt:3,children:[e.jsx(Jt,{data:{tableRef:l}}),e.jsx(Ke,{parentCallback:d,data:{newData:S,columns:R,action:!1,ActionView:c,Loading:m,error:v,editDesign:"",deleteTodoMutation:g,open:r,DrawerUpdate:b,viewDetails:D}})]})]})})]})})}const At=({id:t,funcName:a,disabled:n=!1})=>{const r="Data",[o,l]=i.useState(!1),d=()=>{l(!0),a(t),s.message.success(`${r} deleted successfully!`)},c=()=>{s.message.info(`Deletion of ${r} cancelled`)};return e.jsx(s.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:n||o,children:e.jsx(s.Button,{danger:!0,disabled:n,loading:o,icon:e.jsx(re.DeleteOutlined,{}),size:"small"})})},$l={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ty({token:t,sampleTemplateUrl:a=sf}){const[n,r]=i.useState({pagination:{current:1,pageSize:10}}),[o,l]=i.useState(!1),[d,c]=i.useState(null),[h,f]=i.useState(null),[p,m]=i.useState(!1),[v,S]=i.useState([]),y=`api/branchapi/Transport/routeTableList?page=${n.pagination.current}&per_page=${n.pagination.pageSize}`,g="api/branchapi/Transport/addroute",b="api/branchapi/Transport/editroute",D="api/branchapi/Transport/deleteroute",R=void 0,{isLoading:I,data:A,error:_,mutate:u}=q(t?[y,t]:null,([V,L])=>W(V,L)),x=i.useMemo(()=>!A?.data||Array.isArray(A.data)?[]:A.data?.rows||[],[A]),j=A?.data?.pagination?.total_rows||A?.pagination?.total_rows||0,P=async(V,L)=>{try{await u(Ze(V,L,t),pt(L)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{T.error("Failed to add the new item.",{duration:1e3})}},O=V=>{V.preventDefault();const L=new FormData(V.target);P(g,L),V.target.reset()},z=(V,L)=>{r(B=>({...B,pagination:{current:V,pageSize:parseInt(L,10)}}))},k=async V=>{try{await u(st(D,V,t),ot(V)),T.success("Success! Deleted item.",{duration:1e3})}catch{T.error("Failed to delete the item.",{duration:1e3})}},F=V=>{c(V),l(!0)},C=async V=>{try{const L=await ct(b,V,t);u(L),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),c(null)}catch{T.error("Failed to update the item.",{duration:1e3})}},E=async V=>{V.preventDefault();const L=new FormData(V.target);L.append("id",d?.id),C(L)},M=async()=>{if(!h){T.error("Please select an Excel file to upload.",{duration:1e3});return}m(!0),S([]);try{const V=new FormData;V.append("file",h);const B=await(await fetch(`${R}`,{method:"POST",headers:{Authorization:t},body:V})).json();if(B.Status==="Success"){const $=B.data?.rows||[];S($);const N=B.data?.success_count||0,H=B.data?.failed_count||0;T.success(B.message||`Route bulk upload completed. ${N} succeeded, ${H} failed.`,{duration:1e3}),N>0&&u()}else T.error(B.message||"Failed to upload routes.",{duration:1e3})}catch(V){T.error(V?.message||"Something went wrong.",{duration:1e3})}finally{m(!1),f(null)}},U=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(V,L)=>(V.route_title||"").localeCompare(L.route_title||"")}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(V,L)=>Number(V.fare||0)-Number(L.fare||0)}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(V,L)=>(V.note||"").localeCompare(L.note||"")}},{title:"Action",key:"action",render:(V,L)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>F(L),style:{padding:2}}),e.jsx(At,{id:L?.id,funcName:k})]})}],Y=d?.route_title?`Edit ${d.route_title}`:"Edit Route";return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Routes"})}),e.jsxs(w,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(s.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:V=>(f(V),!1),children:e.jsx(s.Button,{icon:e.jsx(re.UploadOutlined,{}),disabled:p,children:h?h.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(s.Button,{type:"primary",onClick:M,disabled:p||!h,loading:p,children:p?"Uploading...":"Upload Routes"})})})]}),v.length>0&&e.jsxs(w,{mt:3,children:[e.jsx(he,{level:5,children:"Upload Results"}),e.jsx(s.Table,{dataSource:v.map((V,L)=>({...V,key:L})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Title",dataIndex:"title"},{title:"Status",dataIndex:"status",render:V=>e.jsx("span",{style:{color:V==="Success"?"green":"red",fontWeight:500},children:V})},{title:"Message",dataIndex:"message"}]})]}),a&&e.jsx(w,{mt:2,children:e.jsx("a",{href:a,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Add Route"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:O,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(G,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"})})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(G,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"})})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(G,{type:"text",name:"note",label:"Note"})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(w,{children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:$l,children:"Cancel"})]})})})})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Route List"})}),e.jsx(w,{p:3,children:e.jsx(Ke,{parentCallback:z,data:{newData:{data:x,pagination:{total_rows:j}},columns:U,columnstype:"antd",action:!1,Loading:I,error:_,deleteTodoMutation:k}})})]})})]}),e.jsx(s.Drawer,{open:o,title:Y,placement:"right",width:420,onClose:()=>{l(!1),c(null)},children:e.jsx("form",{onSubmit:E,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(G,{type:"text",name:"title",label:"Title",defaultValue:d?.route_title||"",required:"required"}),e.jsx(G,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:d?.fare||"",required:"required"}),e.jsx(G,{type:"text",name:"note",label:"Note",defaultValue:d?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(G,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{l(!1),c(null)},style:$l,children:"Cancel"})]})]})})})]})}const Fl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Dy({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${a.page}&per_page=${a.rowsPerPage}`,h="api/branchapi/Transport/addvehicles",f="api/branchapi/Transport/editvehicle",p="api/branchapi/Transport/deletevehicle",{isLoading:m,data:v,error:S,mutate:y}=q(t?[c,t]:null,([j,P])=>W(j,P)),g=async(j,P)=>{try{await y(Ze(j,P,t),pt(P)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{T.error("Failed to add the new item.",{duration:1e3})}},b=j=>{j.preventDefault();const P=new FormData(j.target);g(h,P),j.target.reset()},D=async j=>{try{await y(st(p,j,t),ot(j)),T.success("Success! Deleted item.",{duration:1e3})}catch{T.error("Failed to delete the item.",{duration:1e3})}},R=j=>{d(j),o(!0)},I=async j=>{try{await ct(f,j,t),await y(),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{T.error("Failed to update the item.",{duration:1e3})}},A=async j=>{j.preventDefault();const P=new FormData(j.target);P.append("id",l?.id),I(P)},_=(j,P)=>{n({page:j,rowsPerPage:parseInt(P,10)})},u=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(j,P)=>j.vehicle_no.localeCompare(P.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(j,P)=>j.vehicle_model.localeCompare(P.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(j,P)=>j.seating_capacity-P.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(j,P)=>j.manufacture_year-P.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(j,P)=>j.gps_url.localeCompare(P.gps_url)},render:(j,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:(j,P)=>j.note.localeCompare(P.note)}},{title:"Action",key:"action",render:(j,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>R(P),style:{padding:2}}),e.jsx(At,{id:P?.id,funcName:D})]})}],x=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,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(G,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(G,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(G,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(G,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(G,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(G,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Fl,children:"Cancel"})]})]})})}),e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(w,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(G,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(G,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(G,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(G,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(G,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(G,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:Fl,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(w,{children:e.jsx(Ke,{parentCallback:_,data:{newData:v,columns:u,columnstype:"antd",action:!1,Loading:m,error:S,deleteTodoMutation:D}})})]})})]})})]})}const ky={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Bl=({dataIndex:t,title:a,record:n,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function Ry({token:t}){const[a,n]=i.useState(!1),[r,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,h]=i.useState([]),f="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleDropdown",m="api/branchapi/Transport/getchechkedVehicleData",v="api/branchapi/Transport/assignedVehicleTable",S="api/branchapi/transport/assignvehicle",y="api/branchapi/Transport/deleteassignvehicle",g=l?`${m}?route_id=${l}`:null,{isLoading:b,data:D,mutate:R}=q(t?[`${v}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([B,$])=>W(B,$)),{data:I}=q(t&&f?[f,t]:null,([B,$])=>W(B,$)),{data:A}=q(t&&p?[p,t]:null,([B,$])=>W(B,$)),_=t&&g?[g,t]:null,{isLoading:u,data:x}=q(_,([B,$])=>W(B,$)),{Status:j="Failed",pagination:{total_rows:P=0}={}}=D||{},{data:O=[]}=j==="Success"?D:{},z=i.useMemo(()=>{const B=I?.data??I??[];return Array.isArray(B)?B:[]},[I]),k=i.useMemo(()=>{const B=A?.data??A??[];return(Array.isArray(B)?B:[]).map(N=>{if(N==null)return null;if(typeof N=="string"||typeof N=="number")return{label:String(N),value:N};const H=N.value??N.vehicle_id??N.id??N.vehicleID,Q=N.label??N.vehicle_name??N.vehicle_no??N.vehicle_number??N.name??String(H??"");return H==null||Q===""?null:{label:String(Q),value:H}}).filter(Boolean)},[A]),F=i.useMemo(()=>{const B=x?.data??x??[];return(Array.isArray(B)?B:[]).map(N=>N?.value??N?.vehicle_id??N?.id??N).filter(N=>N!=null)},[x]);i.useEffect(()=>{h(F)},[F,a]);const C=async(B,$,N)=>{try{await R(Ze(B,$,t),pt($)),g&&q.mutate(_),n(H=>!H),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(H){T.error(H?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},E=B=>{B.preventDefault();const $=new FormData;$.append("route_id",l??""),c.length?c.forEach(N=>$.append("vehicle_ids[]",N)):$.append("vehicle_ids[]",""),C(S,$)},M=B=>{o($=>({...$,pagination:{current:B,pageSize:$.pagination.pageSize}}))},U=async B=>{try{await R(st(y,B,t),ot(B)),g&&q.mutate(_),T.success("Success! Deleted item.",{duration:1e3})}catch{T.error("Failed to delete the item.",{duration:1e3})}},Y=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(B,$,N)=>e.jsx(e.Fragment,{children:$.children.map((H,Q,X)=>e.jsx("span",{children:`${H.vehicle_name} ${Q+1===X.length?"":","}`},`${Q}vehicle001`))})},{title:"Action",render:(B,$,N)=>e.jsx(e.Fragment,{children:e.jsx(At,{id:$?.route_id,funcName:U})})}],V=B=>{const $=["route_id","index"];for(let N=0;N<$.length;N++)if(B[$[N]])return B[$[N]]},L=B=>{const{children:$=[]}=B||{},N=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:H=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:H=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:H=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:H=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:H=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:H=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:H=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(s.Table,{components:{body:{cell:Bl}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:N,rowKey:H=>V(H)+"cell01",dataSource:$,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(w,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:E,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(ae,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:B=>{d(B?.value??null),n($=>!$)}})}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:e.jsx(s.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:k,value:c,onChange:B=>h(B),disabled:!l||u})},`check001${a}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),h([]),n(B=>!B)},style:ky,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(w,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:Bl}},columns:Y,bordered:!0,rowKey:B=>V(B),dataSource:Array.isArray(O)?O:[],loading:b,expandable:{expandedRowRender:L,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:P,showSizeChanger:!0,onChange:M,onShowSizeChange:(B,$)=>{o(N=>({...N,pagination:{current:1,pageSize:$}}))},showTotal:(B,$)=>`${$[0]}-${$[1]} of ${B} items`}})})]})})]})})]})}const Ll={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},xi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},dn=(t,a,n)=>{if(a==null||a==="")return null;const r=t.find(o=>String(o.value)===String(a));return r||(n?{label:String(n),value:a}:{label:String(a),value:a})},Iy=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Py=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(n=>n!=null&&n!==""&&String(n).toLowerCase()!=="null"&&String(n).toLowerCase()!=="undefined").join(", ");const a=String(t).trim();return!a||a.toLowerCase()==="null"||a.toLowerCase()==="undefined"?"":a};function My({token:t,assignmentId:a,studentName:n,onClose:r,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",h="api/branchapi/Transport/getvehicleListByRouteIdwithCount",f="api/branchapi/Transport/getStoppageDropdown",p="api/branchapi/Transport/routeShowdata",[m,v]=i.useState(null),[S,y]=i.useState(null),[g,b]=i.useState(null),[D,R]=i.useState(ne()),[I,A]=i.useState(""),[_,u]=i.useState(0),[x,j]=i.useState(0),{data:P,isLoading:O}=q(t&&a?[`${l}?id=${a}`,t]:null,([le,Ce])=>W(le,Ce)),z=i.useMemo(()=>{if(!P||P?.Status&&P.Status!=="Success")return null;const le=P?.data??P;return Array.isArray(le)?le[0]??null:le},[P]);i.useEffect(()=>{const le=z?.fk_route_id??z?.route_id;le!=null&&v(le),z?.vehicle_id!=null&&y(z.vehicle_id),z?.stop_id!=null&&b(z.stop_id),R(z?.start_date?ne(z.start_date):ne()),A(Py(z?.service_push))},[z]);const k=t&&m?`${h}?route_id=${m}`:null,F=t&&m?`${p}?id=${m}`:null,C=t&&m?`${f}?route_id=${m}`:null,{data:E}=q(t&&c?[c,t]:null,([le,Ce])=>W(le,Ce)),{data:M,isLoading:U}=q(k?[k,t]:null,([le,Ce])=>W(le,Ce)),{data:Y,isLoading:V}=q(C?[C,t]:null,([le,Ce])=>W(le,Ce)),{data:L}=q(F?[F,t]:null,([le,Ce])=>W(le,Ce)),B=i.useMemo(()=>xi(E),[E]),$=i.useMemo(()=>xi(M),[M]),N=i.useMemo(()=>xi(Y),[Y]),H=P?.data[0]?.rootCost,Q=Iy(),X=n||[z?.firstname,z?.lastname].filter(Boolean).join(" ")||"",J=(le,Ce)=>{switch(Ce){case"route_id":v(le?.value??null),y(null),b(null),u(Le=>Le+1),j(Le=>Le+1);break;case"vehicle_id":y(le?.value??null),b(null),j(Le=>Le+1);break;case"stop_id":b(le?.value??null);break}},K=async le=>{if(le.preventDefault(),!m||!S||!g){T.error("Please select Route, Vehicle and Stop",{duration:1200});return}const Ce=new FormData;Ce.append("id",String(a)),Ce.append("student_id",String(z?.fk_student_id??z?.student_id??"")),Ce.append("fk_route_id",String(m)),Ce.append("vehicle_id",String(S)),Ce.append("stop_id",String(g)),Ce.append("rootCost",String(H??"")),Ce.append("start_date",D?.isValid?.()?D.format("YYYY-MM-DD"):ne().format("YYYY-MM-DD")),Ce.append("puse_service",String(I??""));try{await ct(d,Ce,t),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),r?.()}catch(Le){T.error(Le?.message??"Failed to update the item.",{duration:1e3})}};if(O||!(z&&!O&&(!m||!U&&!V)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(s.Spin,{})});if(!z)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(s.Button,{type:"text",onClick:r,style:Ll,children:"Close"})]});const ee=z.fk_route_id??z.route_id,pe=dn(B,ee,z.route_title),te=dn($,z.vehicle_id,z.vehicle_name??z.vehicle_no),se=dn(N,z.stop_id,z.stop_name??z.stoppage_name);return e.jsx("form",{onSubmit:K,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(G,{type:"text",name:"title",label:"Student",defaultValue:X,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:z.fk_student_id??z.student_id??""}),e.jsx(ae,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:dn(B,m,pe?.label)??null,onChange:le=>J(le,"route_id")}),e.jsx(ae,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:dn($,S,te?.label)??null,onChange:le=>J(le,"vehicle_id")},`edit-vehicle-${_}`),e.jsx(ae,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:dn(N,g,se?.label)??null,onChange:le=>J(le,"stop_id")},`edit-stop-${x}`),e.jsx(G,{type:"text",label:"Route Cost",value:H!=null?`${Q}${H}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:H??""}),e.jsx(Ge,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:D,onChange:le=>R(le)}),e.jsx(G,{type:"text",label:"Pause Service",value:I,onChange:le=>A(le?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:r,style:Ll,children:"Cancel"})]})]})},`edit-${a}-${_}`)}const Ul={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ey=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[]},Un=t=>Ey(t),Oy=t=>t||"",$y=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Fy=t=>{const a=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return a==="page"||a==="sendpage"?"page":"drawer"},By=(t,a)=>{const n=a||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",o=encodeURIComponent(String(r));if(n.includes("{id}"))return n.replaceAll("{id}",o);if(n.includes(":id"))return n.replace(":id",o);try{const d=new URL(n,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(r)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=n.includes("?")?"&":"?";return`${n}${l}id=${o}`};function Ly({token:t,editType:a,onNavigate:n,editPagePath:r,sampleTemplateUrl:o=rf}){const d=Fy(a)==="drawer",c="api/branchapi/academy/classdropdownlist",h="api/branchapi/academy/sectionoftheClass",f="api/branchapi/Transport/routeStudentList",p="api/branchapi/Transport/getrouteDropdown",m="api/branchapi/Transport/getvehicleListByRouteIdwithCount",v="api/branchapi/Transport/getStoppageDropdown",S="api/branchapi/Transport/routeShowdata",y="api/branchapi/Transport/assignTransportRoutesStudent",g="api/branchapi/transport/removeStudentTransport",b="api/branchapi/transport/assignTransportRoutesStudentBulk",[D,R]=i.useState(null),[I,A]=i.useState(!1),[_,u]=i.useState(!1),[x,j]=i.useState(null),[P,O]=i.useState(null),[z,k]=i.useState(null),[F,C]=i.useState(null),[E,M]=i.useState(!1),[U,Y]=i.useState(!1),[V,L]=i.useState({page:1,rowsPerPage:50}),[B,$]=i.useState(null),[N,H]=i.useState(!1),[Q,X]=i.useState(null),[J,K]=i.useState(null),[Z,ee]=i.useState(null),[pe,te]=i.useState(null),[se,le]=i.useState(null),[Ce,Le]=i.useState(null),[Re,xe]=i.useState(null),[De,Ue]=i.useState(ne()),[ye,me]=i.useState(""),[Pe,Ye]=i.useState(null),[ze,we]=i.useState(!1),[ke,Te]=i.useState([]),ce=(Ae,Fe)=>{const bt=Ae?.value??null;switch(Fe){case"class_id":ee(bt),te(null),$(bt?`${h}?class_id=${encodeURIComponent(String(bt))}`:null),A(ua=>!ua);break;case"route_id":le(bt),Le(null),xe(null),K(bt),O(bt?`${m}?route_id=${encodeURIComponent(String(bt))}`:null),k(bt?`${S}?id=${encodeURIComponent(String(bt))}`:null),C(null),M(ua=>!ua),Y(ua=>!ua);break;case"vehicle_id":Le(bt),xe(null),C(se?`${v}?route_id=${encodeURIComponent(String(se))}`:null),Y(ua=>!ua);break;case"stop_id":xe(bt);break}},ve=Ae=>{if(d){j(Ae),u(!0);return}const Fe=By(Ae,r);if(typeof n=="function"){n(Fe,Ae);return}typeof window<"u"&&Fe&&window.location.assign(Fe)},_e=()=>{u(!1),j(null)},Ve=x?`Edit — ${x.firstname??""} ${x.lastname??""}`.trim():"Edit Student Transport",{data:He}=q(t&&c?[c,t]:null,([Ae,Fe])=>W(Ae,Fe)),{data:je}=q(t&&B?[B,t]:null,([Ae,Fe])=>W(Ae,Fe)),{data:Me}=q(t&&P?[P,t]:null,([Ae,Fe])=>W(Ae,Fe)),{data:rt}=q(t&&F?[F,t]:null,([Ae,Fe])=>W(Ae,Fe)),{data:vt}=q(t&&z?[z,t]:null,([Ae,Fe])=>W(Ae,Fe)),{data:na}=q(t&&p?[p,t]:null,([Ae,Fe])=>W(Ae,Fe)),Vt=t&&D?`${D}&page=${V.page}&per_page=${V.rowsPerPage}`:null,{isLoading:Se,error:Oe,data:oe,mutate:ge}=q(Vt?[Vt,t]:null,([Ae,Fe])=>W(Ae,Fe)),$e=i.useMemo(()=>Un(He),[He]),Ne=i.useMemo(()=>Un(je),[je]),ht=i.useMemo(()=>Un(Me),[Me]),yt=i.useMemo(()=>Un(rt),[rt]),Tt=i.useMemo(()=>Un(na),[na]),be=vt?.data?.[0]?.fare??vt?.data?.fare??vt?.fare??vt?.data?.data?.[0]?.fare??vt?.data?.data?.fare;i.useEffect(()=>{be==null||be===""||me(String(be))},[be]);const Ie=async Ae=>{try{await ge(st(g,Ae,t),ot(Ae)),T.success("Success! Deleted item.",{duration:1e3})}catch{T.error("Failed to delete the item.",{duration:1e3})}},at=async()=>{if(!Pe){T.error("Please select an Excel file to upload.",{duration:1e3});return}we(!0),Te([]);try{const Ae=new FormData;Ae.append("file",Pe);const bt=await(await fetch(`${b}`,{method:"POST",headers:{Authorization:t},body:Ae})).json();if(bt.Status==="Success"){const ua=bt.data?.rows||[];Te(ua);const Ko=bt.data?.success_count||0,tm=bt.data?.failed_count||0;T.success(bt.message||`Transport bulk upload completed. ${Ko} succeeded, ${tm} failed.`,{duration:1e3}),Ko>0&&ge()}else T.error(bt.message||"Failed to upload student transport assignments.",{duration:1e3})}catch(Ae){T.error(Ae?.message||"Something went wrong.",{duration:1e3})}finally{we(!1),Ye(null)}},xt=[{title:"Route Status",key:"route_status",render:(Ae,Fe)=>Fe.fk_route_id?e.jsx("span",{children:Fe.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(Ae,Fe)=>Oy(Fe.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:(Ae,Fe)=>`${Fe.firstname} ${Fe.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(Ae,Fe)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:Fe.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(At,{id:Fe?.id,funcName:Ie}),e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>ve(Fe),style:{padding:2}})]}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.PlusOutlined,{}),onClick:()=>ti(Fe.student_id),style:{padding:2}})})}],It=async(Ae,Fe)=>{try{await ge(Ze(Ae,Fe,t),pt(Fe)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),H(!1),ai()}catch{T.error("Failed to add the new item.",{duration:1e3})}},Lt=Ae=>{if(Ae.preventDefault(),!Z||!pe){T.error("Please select Class and Section",{duration:1200});return}R(`${f}?cID=${encodeURIComponent(String(Z))}&sID=${encodeURIComponent(String(pe))}`),L(Fe=>({...Fe,page:1}))},ei=(Ae,Fe)=>{L({page:Ae,rowsPerPage:parseInt(Fe,10)})},ti=Ae=>{X(Ae),H(!0)},En=Ae=>{if(Ae.preventDefault(),!Q){T.error("Student is required",{duration:1200});return}if(!se||!Ce||!Re){T.error("Please select Route, Vehicle and Stop",{duration:1300});return}const Fe=new FormData;Fe.append("student_id",String(Q)),Fe.append("fk_route_id",String(se)),Fe.append("vehicle_id",String(Ce)),Fe.append("stop_id",String(Re)),Fe.append("start_date",De?.isValid?.()?De.format("YYYY-MM-DD"):ne().format("YYYY-MM-DD")),Fe.append("rootCost",String(ye??"")),It(y,Fe)},ai=()=>{H(!1),O(null),k(null),C(null),K(null),le(null),Le(null),xe(null),Ue(ne()),me(""),M(Ae=>!Ae),Y(Ae=>!Ae)},em=$y();return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Assign Students to Transport"})}),e.jsxs(w,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(s.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:Ae=>(Ye(Ae),!1),children:e.jsx(s.Button,{icon:e.jsx(re.UploadOutlined,{}),disabled:ze,children:Pe?Pe.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(s.Button,{type:"primary",onClick:at,disabled:ze||!Pe,loading:ze,children:ze?"Uploading...":"Upload Students"})})})]}),o&&e.jsx(w,{mt:2,children:e.jsx("a",{href:o,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})}),ke.length>0&&e.jsxs(w,{mt:3,children:[e.jsx(he,{level:5,children:"Upload Results"}),e.jsx(s.Table,{dataSource:ke.map((Ae,Fe)=>({...Ae,key:Fe})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Student ID",dataIndex:"student_id"},{title:"Status",dataIndex:"status",render:Ae=>e.jsx("span",{style:{color:Ae==="Success"?"green":"red",fontWeight:500},children:Ae})},{title:"Message",dataIndex:"message"}]})]})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Search Students"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:Lt,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(ae,{options:$e,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:Ae=>ce(Ae,"class_id"),required:!0,allowSelectAll:!1,value:$e.find(Ae=>String(Ae.value)===String(Z))??null})})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(ae,{options:Ne,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:Ne.find(Ae=>String(Ae.value)===String(pe))??null,onChange:Ae=>te(Ae?.value??null)},`section1${I}`)})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsxs(w,{display:"flex",alignItems:"center",height:"100%",mt:2,children:[e.jsx(de,{type:"submit",value:"Search",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{R(null),$(null),ee(null),te(null),A(Ae=>!Ae)},style:Ul,children:"Cancel"})]})})]})})})]})}),D&&e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(w,{p:3,children:e.jsx(Ke,{parentCallback:ei,data:{newData:oe,columns:xt,columnstype:"antd",action:!1,Loading:Se,error:Oe,deleteTodoMutation:Ie,pageController:V}})})]})})]}),e.jsx(s.Drawer,{open:_,title:Ve,placement:"right",width:420,destroyOnClose:!0,onClose:_e,children:x?.id&&e.jsx(My,{token:t,assignmentId:x.id,studentName:`${x.firstname??""} ${x.lastname??""}`.trim(),onClose:_e,onSuccess:()=>ge()})}),e.jsx(s.Modal,{open:N,title:"Assign Student to Transport",onCancel:ai,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:En,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:Tt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:Tt.find(Ae=>String(Ae.value)===String(se))??null,onChange:Ae=>ce(Ae,"route_id")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:ht,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:ht.find(Ae=>String(Ae.value)===String(Ce))??null,onChange:Ae=>ce(Ae,"vehicle_id")},`vehicle001${E}`)})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:yt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:yt.find(Ae=>String(Ae.value)===String(Re))??null,onChange:Ae=>ce(Ae,"stop_id")},`stop001${U}`)})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:De,onChange:Ae=>Ue(Ae)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{type:"text",name:"rootCost",label:"Route Cost",value:ye,onChange:Ae=>me(Ae?.target?.value??"")})})}),e.jsx(s.Col,{xs:24,children:e.jsxs(w,{display:"flex",alignItems:"center",gap:12,children:[e.jsx(de,{type:"submit",value:String(ye??"").trim()?`${em}${ye} — Assign`:"Assign",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:ai,style:Ul,children:"Cancel"})]})})]})})})]})}const Nl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Es={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Uy({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,h]=i.useState(""),[f,p]=i.useState(""),[m,v]=i.useState(""),[S,y]=i.useState(!1),g=`api/branchapi/Transport/getdriverTable?page=${a.page}&per_page=${a.rowsPerPage}`,b="api/branchapi/Transport/add_driver",D="api/branchapi/Transport/edit_driver",R="api/branchapi/Transport/deletedriver",I="api/branchapi/staff/uploadDocuments",A=i.useMemo(()=>String(I).startsWith("http")?I:`${Nt()??""}${String(I).replace(/^\/+/,"")}`,[I]),_=Nt()??"",{isLoading:u,data:x,error:j,mutate:P}=q(t?[g,t]:null,([V,L])=>W(V,L)),O=async(V,L)=>{try{await Ze(V,L,t),await P(),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),h("")}catch(B){T.error(B?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},z=V=>{V.preventDefault();const L=new FormData(V.target);O(b,L),V.target.reset()},k=async V=>{try{await P(st(R,V,t),ot(V)),T.success("Success! Deleted item.",{duration:1e3})}catch{T.error("Failed to delete the item.",{duration:1e3})}},F=V=>{d(V),h(V?.image??""),o(!0)},C=async V=>{try{await ct(D,V,t),await P(),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),h("")}catch(L){T.error(L?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},E=V=>{V.preventDefault();const L=new FormData(V.target);L.append("id",l?.id??""),C(L)},M=(V,L)=>{n({page:V,rowsPerPage:parseInt(L,10)})},U=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(V,L)=>String(V?.name??"").localeCompare(String(L?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(V,L)=>String(V?.Driver_licence??"").localeCompare(String(L?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(V,L)=>Number(V?.contact_number??0)-Number(L?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(V,L)=>String(V?.address??"").localeCompare(String(L?.address??""))}},{title:"Image",key:"image",width:100,render:(V,L)=>{const B=L?.image?`${_}staff/document/${L.image}`:"";return B?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(s.Image,{width:80,src:B,preview:{visible:!1,onVisibleChange:()=>{y(!0),p(B),v(L?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(V,L)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>F(L),style:{padding:2}}),e.jsx(At,{id:L?.id,funcName:k})]})}],Y=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:Y,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),h("")},children:e.jsx("form",{onSubmit:E,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(G,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(G,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(G,{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:Es,children:"Address"}),e.jsx(s.Input.TextArea,{name:"address",defaultValue:l?.address??"",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Es,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:A,headers:t?{Authorization:t}:void 0,onChange:V=>{if(V?.file?.status!=="done")return;const L=V?.file?.response,B=L?.data??L?.filename??L?.file??L?.path??"";B&&h(String(B))},children:e.jsx(s.Button,{icon:e.jsx(re.UploadOutlined,{}),disabled:!A,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),h("")},style:Nl,children:"Cancel"})]})]})})}),e.jsx(s.Modal,{zIndex:9999,open:S,title:m,footer:null,onCancel:()=>y(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:f})}),e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(w,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(G,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(G,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(G,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Es,children:"Address"}),e.jsx(s.Input.TextArea,{name:"address",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Es,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:A,headers:t?{Authorization:t}:void 0,onChange:V=>{if(V?.file?.status!=="done")return;const L=V?.file?.response,B=L?.data??L?.filename??L?.file??L?.path??"";B&&h(String(B))},children:e.jsx(s.Button,{icon:e.jsx(re.UploadOutlined,{}),disabled:!A,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>h(""),style:Nl,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(w,{children:e.jsx(Ke,{parentCallback:M,data:{newData:x,columns:U,columnstype:"antd",action:!1,Loading:u,error:j,deleteTodoMutation:k}})})]})})]})})]})}const zl={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"},Os={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ql=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],$s=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Ny({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,h]=i.useState(null),[f,p]=i.useState(null),[m,v]=i.useState(null),[S,y]=i.useState(null),[g,b]=i.useState(ne()),[D,R]=i.useState(ne()),[I,A]=i.useState("pick"),[_,u]=i.useState(!1),[x,j]=i.useState(null),[P,O]=i.useState(null),[z,k]=i.useState(!1),[F,C]=i.useState(null),[E,M]=i.useState(null),[U,Y]=i.useState(null),[V,L]=i.useState(null),[B,$]=i.useState(ne()),[N,H]=i.useState(ne()),[Q,X]=i.useState("pick"),J=`api/branchapi/Transport/assignRouteTimeList?page=${a.page}&per_page=${a.rowsPerPage}`,K="api/branchapi/Transport/assignRouteTime",Z="api/branchapi/Transport/editAssignRouteTime",ee="api/branchapi/Transport/deleteAssignRouteTime",pe="api/branchapi/Transport/driverDropdown",te="api/branchapi/transport/routeTimetableShowdata",se="api/branchapi/Transport/getrouteDropdown",le="api/branchapi/Transport/getvehicleDropdown",{isLoading:Ce,data:Le,error:Re,mutate:xe}=q(t?[J,t]:null,([Se,Oe])=>W(Se,Oe)),{data:De}=q(t&&se?[se,t]:null,([Se,Oe])=>W(Se,Oe)),{data:Ue}=q(t&&pe?[pe,t]:null,([Se,Oe])=>W(Se,Oe)),ye=i.useMemo(()=>c?`${le}?route_id=${c}`:null,[c,le]),{data:me}=q(t&&ye?[ye,t]:null,([Se,Oe])=>W(Se,Oe)),Pe=i.useMemo(()=>$s(De),[De]),Ye=i.useMemo(()=>$s(Ue),[Ue]),ze=i.useMemo(()=>$s(me),[me]),we=(Se,Oe)=>{n({page:Se,rowsPerPage:parseInt(Oe,10)})},ke=async Se=>{Se.preventDefault();const Oe=new FormData(Se.target);Oe.set("route_id",f?.value??c??""),Oe.set("driver_id",m?.value??""),Oe.set("vehicle_id",S?.value??""),Oe.set("start_time",g?g.format("h:mm a"):""),Oe.set("drop_time",D?D.format("h:mm a"):""),Oe.set("type",I);try{await Ze(K,Oe,t),await xe(),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),Se.target.reset(),h(null),p(null),v(null),y(null),d(oe=>!oe),b(ne()),R(ne()),A("pick"),o(oe=>!oe)}catch(oe){T.error(oe?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},Te=async Se=>{try{await st(ee,Se,t),await xe(),T.success("Success! Deleted item.",{duration:1e3})}catch(Oe){T.error(Oe?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ce=Se=>{j(Se),u(!0);const Oe=Se?.id??Se?.route_time_id??Se?.routeId??null;O(Oe);const oe=Se?.route_id??Se?.routeId??Se?.fk_route_id;C(oe??null),M(Pe.find(ge=>ge?.value===(oe??Se?.route_id))??null),Y(Ye.find(ge=>ge?.value===(Se?.driver_id??Se?.driverId))??null),L(null),k(ge=>!ge),$(Se?.start_time?ne(Se.start_time,["h:mm a","HH:mm"]):ne()),H(Se?.drop_time?ne(Se.drop_time,["h:mm a","HH:mm"]):ne()),X(Se?.type??"pick")},ve=i.useMemo(()=>{if(!P)return null;const Se=String(te).includes("?")?"&":"?";return`${te}${Se}id=${encodeURIComponent(String(P))}`},[P,te]),{data:_e,isLoading:Ve}=q(t&&ve?[ve,t]:null,([Se,Oe])=>W(Se,Oe)),He=i.useMemo(()=>{const Se=_e?.data??_e;return Array.isArray(Se)?Se[0]??null:Array.isArray(Se?.data)?Se.data[0]??null:Se??null},[_e]),je=i.useMemo(()=>F?`${le}?route_id=${F}`:null,[F,le]),{data:Me}=q(t&&je?[je,t]:null,([Se,Oe])=>W(Se,Oe)),rt=i.useMemo(()=>$s(Me),[Me]);i.useEffect(()=>{if(!He)return;const Se=He?.route_id??He?.fk_route_id??He?.routeId;C(Se??null),M(Pe.find(Oe=>Oe?.value===Se)??null),Y(Ye.find(Oe=>Oe?.value===He?.driver_id)??null),L(null),$(He?.start_time?ne(He.start_time,["h:mm a","HH:mm"]):ne()),H(He?.drop_time?ne(He.drop_time,["h:mm a","HH:mm"]):ne()),X(He?.type??"pick"),k(Oe=>!Oe)},[Ye,He,Pe]),i.useEffect(()=>{if(!He)return;const Se=He?.vehicle_id??He?.vehicleId;Se&&L(rt.find(Oe=>Oe?.value===Se)??null)},[He,rt]);const vt=async Se=>{if(Se.preventDefault(),!P)return;const Oe=new FormData(Se.target);Oe.set("id",String(P)),Oe.set("route_id",E?.value??F??""),Oe.set("driver_id",U?.value??""),Oe.set("vehicle_id",V?.value??""),Oe.set("start_time",B?B.format("h:mm a"):""),Oe.set("drop_time",N?N.format("h:mm a"):""),Oe.set("type",Q);try{await ct(Z,Oe,t),await xe(),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),u(!1),j(null)}catch(oe){T.error(oe?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},na=[{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:(Se,Oe)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>ce(Oe),style:{padding:2}}),e.jsx(At,{id:Oe?.id??Oe?.routeId??Oe?.route_time_id,funcName:Te})]})}],Vt=x?.route_title?`Edit ${x.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:_,title:Vt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{u(!1),j(null),O(null),C(null),M(null),Y(null),L(null)},children:e.jsx("form",{onSubmit:vt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Ve?.6:1},children:[e.jsx(ae,{options:Pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:E,onChange:Se=>{C(Se?.value??null),M(Se??null),L(null),k(Oe=>!Oe)}}),e.jsx(ae,{options:Ye,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:U,onChange:Se=>Y(Se??null)}),e.jsx(ae,{options:rt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:V,onChange:Se=>L(Se??null)},`edit-vehicle-${z}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:cn,children:"Start Time"}),e.jsx(s.TimePicker,{value:B,onChange:Se=>$(Se),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Os})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:cn,children:"Drop Time"}),e.jsx(s.TimePicker,{value:N,onChange:Se=>H(Se),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Os})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:cn,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:ql,optionType:"button",buttonStyle:"solid",value:Q,onChange:Se=>X(Se.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{u(!1),j(null)},style:zl,children:"Cancel"})]})]})})}),e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(w,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:ke,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{options:Pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:f,onChange:Se=>{h(Se?.value??null),p(Se??null),y(null),d(Oe=>!Oe)},allowSelectAll:!1,required:!0}),e.jsx(ae,{options:Ye,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:m,onChange:Se=>v(Se??null),allowSelectAll:!1,required:!0}),e.jsx(ae,{options:ze,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:S,onChange:Se=>y(Se??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:cn,children:"Start Time"}),e.jsx(s.TimePicker,{value:g,onChange:Se=>b(Se),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Os})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:cn,children:"Drop Time"}),e.jsx(s.TimePicker,{value:D,onChange:Se=>R(Se),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Os})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:cn,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:ql,optionType:"button",buttonStyle:"solid",value:I,onChange:Se=>A(Se.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>{h(null),p(null),v(null),y(null),d(Se=>!Se),b(ne()),R(ne()),A("pick"),o(Se=>!Se)},style:zl,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(w,{children:e.jsx(Ke,{parentCallback:we,data:{newData:Le,columns:na,columnstype:"antd",action:!1,Loading:Ce,error:Re,deleteTodoMutation:Te}})})]})})]})})]})}const zy={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Yl={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Wl={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Vl=({dataIndex:t,title:a,record:n,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let Hl=2;function qy({token:t}){const[a,n]=i.useState([]),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,h]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:f,data:p,mutate:m}=q(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([C,E])=>W(C,E)),{Status:v="Failed",pagination:{total_rows:S=0}={}}=p||{},{data:y=[]}=v==="Success"?p:{},{data:g}=q(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([C,E])=>W(C,E)),b=i.useMemo(()=>{const C=g?.data??g??[];if(Array.isArray(C))return C;if(C&&typeof C=="object"){if(Array.isArray(C?.data))return C.data;if(Array.isArray(C?.data?.data))return C.data.data}return[]},[g]),{data:D}=q(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([C,E])=>W(C,E)),{Status:R="Failed"}=D||{},I=async(C,E)=>{try{await m(Ze(C,E,t),pt(E)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{T.error("Failed to add the new item.",{duration:1e3})}},A=C=>C?typeof C=="string"?C:C?.isValid?.()?C.format("h:mm a"):"":"",_=(C,E=[])=>{const M=(Array.isArray(C)?C:[]).map(V=>({id:V?.id??"",name:String(V?.stop_name??V?.name??"").trim(),pickTime:A(V?.pickup_time??V?.pickTime??V?.pickupTime),drop_time:A(V?.drop_time??V?.dropTime)})),U=M.filter(V=>V?.id!=null&&String(V.id).trim()!==""),Y=M.filter(V=>!(V?.id!=null&&String(V.id).trim()!==""));return{route_id:r??"",edit_stoppage:U,add_stoppage:Y,delete_stoppage:Array.isArray(E)?E:[]}},u=C=>{C.preventDefault();const E="/api/branchapi/transport/addstoppageToRoute",M=_(a,l);I(E,M)},x=()=>{n(C=>[...Array.isArray(C)?C:[],{idKey:Hl++,stop_name:"",pickup_time:ne().format("h:mm a"),drop_time:ne().format("h:mm a")}])},j=C=>{if(a.length===1)return;const E=a[C];E?.id!=null&&String(E.id).trim()!==""&&!E?.idKey&&d(M=>{const U=Array.isArray(M)?M:[];return U.some(V=>String(V)===String(E.id))?U:[...U,E.id]}),n(M=>{const U=[...M];return U.splice(C,1),U})},P=C=>{h(E=>({...E,pagination:{current:C,pageSize:E.pagination.pageSize}}))},O=async C=>{const E="/api/branchapi/Transport/deletevehicle";try{await m(st(E,C,t),ot(C)),T.success("Success! Deleted item.",{duration:1e3})}catch{T.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(R==="Success"){const C=Array.isArray(D?.data)?D.data:[];C.length>0?(n(C),d([])):r&&(n([{idKey:Hl++,stop_name:"",pickup_time:ne().format("h:mm a"),drop_time:ne().format("h:mm a")}]),d([]))}},[R,D,r]);const z=C=>{const{children:E=[]}=C||{},M=[{title:"Stop Name",dataIndex:"stop_name",onCell:U=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:U=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:U=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(s.Table,{components:{body:{cell:Vl}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:M,rowKey:U=>k(U)+"cell01",dataSource:E,pagination:!1})})})},k=C=>{const E=["id","index"];for(let M=0;M<E.length;M++)if(C[E[M]])return C[E[M]]},F=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(C,E,M)=>e.jsx(e.Fragment,{children:(Array.isArray(E.children)?E.children:[]).map((U,Y,V)=>e.jsx("span",{children:`${U.stop_name} ${Y+1===V.length?"":","}`},`${Y}vehicle001`))})},{title:"Action",render:(C,E,M)=>e.jsx(e.Fragment,{children:e.jsx(At,{id:E?.route_id,funcName:O})})}];return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(w,{pt:5,pb:1,children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(w,{px:3,pb:2,children:e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(ae,{options:b,value:b.find(C=>String(C.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:C=>{o(C?.value??null),n([]),d([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:r&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:x,children:e.jsx(re.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(de,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),n([]),d([])},style:zy,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:a.length>0&&a.map((C,E)=>{const M=C.pickup_time?ne(C.pickup_time,"h:mm a"):null,U=C.drop_time?ne(C.drop_time,"h:mm a"):null;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx(G,{value:C.stop_name??"",type:"text",name:`stoppage[${E}][name]`,label:"Place Name*",required:"required",onChange:Y=>{const V=Y?.target?.value??"";n(L=>{const B=[...L];return B[E]={...B[E]??{},stop_name:V},B})}}),C?.id!=null&&String(C.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${E}][id]`,value:String(C.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Yl,children:"Pick Time"}),e.jsx(s.TimePicker,{value:M,use12Hours:!0,format:"h:mm a",name:`stoppage[${E}][pickTime]`,allowClear:!1,style:Wl,onChange:Y=>{const V=Y?Y.format("h:mm a"):"";n(L=>{const B=[...L];return B[E]={...B[E]??{},pickup_time:V},B})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Yl,children:"Drop Time"}),e.jsx(s.TimePicker,{value:U,use12Hours:!0,format:"h:mm a",name:`stoppage[${E}][drop_time]`,allowClear:!1,style:Wl,onChange:Y=>{const V=Y?Y.format("h:mm a"):"";n(L=>{const B=[...L];return B[E]={...B[E]??{},drop_time:V},B})}})]}),e.jsx("div",{style:{marginBottom:8},children:a.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>j(E),children:e.jsx(re.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},C.idKey?C.idKey+"exp":C.id+"exp")})})]})}),e.jsx(w,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(w,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:Vl}},columns:F,bordered:!0,size:"small",rowKey:C=>k(C),dataSource:y,loading:f,expandable:{expandedRowRender:z,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:S,showSizeChanger:!0,onChange:P,onShowSizeChange:(C,E)=>{h(M=>({...M,pagination:{current:1,pageSize:E}}))},showTotal:(C,E)=>`${E[0]}-${E[1]} of ${C} items`}})})]})]})}const{Step:Fs}=s.Steps;function Yy({token:t}){const[a,n]=i.useState(0),[r,o]=i.useState(void 0),[l,d]=i.useState(void 0),[c,h]=i.useState(!1),[f,p]=i.useState(null),[m,v]=i.useState(!1),[S,y]=i.useState(!1),[g,b]=i.useState(!1),[D,R]=i.useState([]),[I,A]=i.useState(null),[_,u]=i.useState(null),[x,j]=i.useState(!1),{isLoading:P,data:O}=q(t?[oa,t]:null,([$,N])=>W($,N)),{isLoading:z,data:k}=q(x?[x,t]:null,([$,N])=>W($,N)),{data:F}=q(c?[c,t]:null,([$,N])=>W($,N)),C=i.useMemo(()=>[{title:"Excel Row",dataIndex:"row",width:90,render:$=>$??"-"},{title:"Student Name",dataIndex:"student_name_system",render:$=>$?e.jsx("span",{style:{color:"#d97706"},children:$}):"-"},{title:"Route",dataIndex:"route",render:$=>$||"-"},{title:"Vehicle",dataIndex:"vehicle",render:$=>$||"-"},{title:"Stop",dataIndex:"stop",render:$=>$||"-"},{title:"Start Date",dataIndex:"start_date",render:$=>$||"-"},{title:"Transport Fee",dataIndex:"transport_fee",render:$=>$??"-"},{title:"Status",dataIndex:"status",width:110,render:$=>{const H={Valid:"success",Invalid:"error",Duplicate:"warning",Imported:"success",Skipped:"warning",Failed:"error"}[$]||"default";return e.jsx("span",{style:{color:H,fontWeight:500},children:$})}},{title:"Message",dataIndex:"message",render:$=>$?e.jsx("span",{style:{color:"#dc2626"},children:$}):"-"}],[]),E=()=>{p(null),v(!1),y(!1),b(!1),R([]),A(null),u(null),o(void 0),d(void 0),h(!1),n(0)},M=async()=>{try{const $=await Nf({class_id:r?.value,section_id:l?.value},t),N=window.URL.createObjectURL($),H=document.createElement("a");H.href=N,H.download="transport-bulk-template.xlsx",document.body.appendChild(H),H.click(),document.body.removeChild(H),window.URL.revokeObjectURL(N),T.success("Template downloaded.",{duration:1e3})}catch($){T.error($?.message||"Failed to download template.",{duration:1e3})}},U=async()=>{if(!f){T.error("Please select an Excel file to upload.",{duration:1e3});return}y(!0),R([]),A(null),u(null);try{const $=await zf(f,t);if($.Status!=="Success"){T.error($.msg||"Validation failed.",{duration:1e3}),y(!1);return}A($.data?.summary||null),R($.data?.rows||[]),n(2),T.success($.msg||"Validation complete.",{duration:1e3})}catch($){T.error($?.message||"Validation failed.",{duration:1e3})}finally{y(!1)}},Y=async()=>{if(!D.length){T.error("No rows provided to import.",{duration:1e3});return}b(!0),u(null);try{const $=await qf(D,t,"skip");if($.Status!=="Success"){T.error($.msg||"Import failed.",{duration:1e3}),b(!1);return}u($.data||null),n(3),T.success($.msg||"Import completed.",{duration:1e3})}catch($){T.error($?.message||"Import failed.",{duration:1e3})}finally{b(!1)}},V=async $=>{if(!$||!$.length){T.error("No rows provided.",{duration:1e3});return}try{const N=await Yf($,t),H=window.URL.createObjectURL(N),Q=document.createElement("a");Q.href=H,Q.download="transport-bulk-error-report.xlsx",document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),window.URL.revokeObjectURL(H),T.success("Error report downloaded.",{duration:1e3})}catch(N){T.error(N?.message||"Failed to download error report.",{duration:1e3})}},L=i.useMemo(()=>D.length?(_?_.rows:D).filter(N=>!["Valid","Imported"].includes(N.status)):[],[D,_]),B={background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"};return e.jsx(w,{pt:5,pb:1,children:e.jsx(s.Row,{gutter:[16,16],children:e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:B,children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Transport / Bulk Upload"})}),e.jsxs(w,{p:3,children:[e.jsxs(s.Steps,{current:a,style:{marginBottom:16},children:[e.jsx(Fs,{title:"Download Template"}),e.jsx(Fs,{title:"Upload & Validate"}),e.jsx(Fs,{title:"Review"}),e.jsx(Fs,{title:"Import Result"})]}),a===0&&e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:4,children:e.jsx(w,{children:e.jsx(ae,{label:"Class",options:Array.isArray(O)?O:[],value:r,onChange:$=>{o($),$?h(`${la}?class_id=${$.value}`):(d(void 0),h(!1))},showSearch:!0,allowClear:!0})})}),e.jsx(s.Col,{xs:24,md:4,children:e.jsx(w,{children:e.jsx(ae,{label:"Section",options:Array.isArray(F)?F:[],value:l,onChange:d,showSearch:!0,allowClear:!0})})}),e.jsx(s.Col,{xs:24,md:4,style:{marginTop:20},children:e.jsx(w,{children:e.jsx(s.Button,{type:"primary",onClick:M,block:!0,children:"Download Excel Template"})})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{mt:1,children:e.jsx(s.Button,{type:"primary",onClick:()=>n(1),children:"Next: Upload Excel"})})})]}),a===1&&e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsxs(w,{children:[e.jsx(s.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:$=>(p($),!1),children:e.jsx(s.Button,{icon:e.jsx(re.UploadOutlined,{}),block:!0,disabled:m||S,children:f?f.name:"Choose Excel File (.xlsx)"})}),f&&e.jsxs(w,{mt:.5,display:"flex",alignItems:"center",gap:1,children:[e.jsxs(he,{level:6,color:"textSecondary",children:[(f.size/1024).toFixed(1)," KB"]}),e.jsx(s.Button,{size:"small",danger:!0,onClick:()=>p(null),children:"Remove"})]})]})}),e.jsx(s.Col,{xs:24,md:3,children:e.jsx(w,{children:e.jsx(de,{type:"button",value:S?"Validating...":"Validate & Preview",color:"primary",onClick:U,disabled:S||!f})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Button,{type:"text",size:"small",onClick:()=>{E(),n(0)},children:"Back"})})]}),a===2&&e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:6,md:3,children:e.jsx(s.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsx(he,{level:6,color:"textSecondary",children:"Total"}),e.jsx(he,{level:4,children:I?.total??D.length})]})})}),e.jsx(s.Col,{xs:6,md:3,children:e.jsx(s.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsx(he,{level:6,color:"textSecondary",children:"Valid"}),e.jsx(he,{level:4,style:{color:"#52c41a"},children:I?.valid??0})]})})}),e.jsx(s.Col,{xs:6,md:3,children:e.jsx(s.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsx(he,{level:6,color:"textSecondary",children:"Invalid"}),e.jsx(he,{level:4,style:{color:"#ff4d4f"},children:I?.invalid??0})]})})}),e.jsx(s.Col,{xs:6,md:3,children:e.jsx(s.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsx(he,{level:6,color:"textSecondary",children:"Duplicate"}),e.jsx(he,{level:4,style:{color:"#faad14"},children:I?.duplicate??0})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(s.Table,{dataSource:D.map(($,N)=>({...$,key:`${$.row}-${N}`})),columns:C,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:($,N)=>`${N[0]}-${N[1]} of ${$} items`}})})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Row,{gutter:[8,8],align:"middle",children:[e.jsx(s.Col,{children:e.jsx(de,{type:"button",value:g?"Importing...":"Import Valid Rows",color:"primary",onClick:Y,disabled:g})}),e.jsx(s.Col,{children:e.jsx(s.Button,{size:"small",onClick:()=>V(L),disabled:!L.length,children:"Download Error Report"})}),e.jsx(s.Col,{children:e.jsx(s.Button,{type:"text",size:"small",onClick:()=>{E(),n(1)},children:"Upload Another File"})})]})})]}),a===3&&e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:6,md:3,children:e.jsx(s.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsxs(he,{level:6,color:"textSecondary",children:["Total "," "]}),e.jsx(he,{level:4,children:_?.total??0})]})})}),e.jsx(s.Col,{xs:6,md:3,children:e.jsx(s.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsxs(he,{level:6,color:"textSecondary",children:["Imported "," "]}),e.jsx(he,{level:4,style:{color:"#52c41a"},children:_?.imported??0})]})})}),e.jsx(s.Col,{xs:6,md:3,children:e.jsx(s.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsxs(he,{level:6,color:"textSecondary",children:["Skipped "," "]}),e.jsx(he,{level:4,style:{color:"#faad14"},children:_?.skipped??0})]})})}),e.jsx(s.Col,{xs:6,md:3,children:e.jsx(s.Card,{children:e.jsxs(w,{p:1.5,children:[e.jsxs(he,{level:6,color:"textSecondary",children:["Failed "," "]}),e.jsx(he,{level:4,style:{color:"#ff4d4f"},children:_?.failed??0})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(s.Table,{dataSource:(_?.rows||[]).map(($,N)=>({...$,key:`${$.row}-${N}`})),columns:C,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:($,N)=>`${N[0]}-${N[1]} of ${$} items`}})})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Row,{gutter:[8,8],align:"middle",children:[e.jsx(s.Col,{children:e.jsx(s.Button,{size:"small",onClick:()=>V(L),disabled:!L.length,children:"Download Error Report"})}),e.jsx(s.Col,{children:e.jsx(s.Button,{type:"primary",size:"small",onClick:E,children:"Upload Another File"})})]})})]})]})]})})})})}const Wy=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},mu=t=>{const a=ya(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Kl=(t,a,n)=>{const r=`${t||""}`.trim();if(!r)return"";if(/^https?:\/\//i.test(r))return r;const o=a?.fk_branchID??mu(n),l=r.startsWith("/")?r.slice(1):r;return Wy(ut(),`uploads/school_${o}/student/homework/${l}`)},Gl={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Nn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Vy({token:t}){const[a,n]=i.useState("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(null),[c,h]=i.useState(null),[f,p]=i.useState(null),[m,v]=i.useState(null),[S,y]=i.useState(!1),[g,b]=i.useState(null),[D,R]=i.useState(null),[I,A]=i.useState(null),[_,u]=i.useState(null),[x,j]=i.useState(null),[P,O]=i.useState(null),[z,k]=i.useState(!1),[F,C]=i.useState(""),[E,M]=i.useState(""),[U,Y]=i.useState(""),[V,L]=i.useState(!1),B=(je,Me)=>{const rt=je?.value??null;switch(Me){case"class_id":d(rt),h(null),p(null);break;case"section_id":h(rt);break;case"subject_id":p(rt);break}},{data:$}=q(t?["api/branchapi/academy/classdropdownlist",t]:null,([je,Me])=>W(je,Me)),{data:N}=q(t&&x?[x,t]:null,([je,Me])=>W(je,Me)),{data:H}=q(t&&P?[P,t]:null,([je,Me])=>W(je,Me)),Q=l?`api/branchapi/academy/sectionoftheClass?class_id=${l}`:null,{data:X}=q(t&&Q?[Q,t]:null,([je,Me])=>W(je,Me)),J=l?`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${l}`:null,{data:K}=q(t&&J?[J,t]:null,([je,Me])=>W(je,Me)),Z=i.useMemo(()=>Nn($),[$]),ee=i.useMemo(()=>Nn(N),[N]),pe=i.useMemo(()=>Nn(H),[H]),te=i.useMemo(()=>Nn(X),[X]),se=i.useMemo(()=>Nn(K),[K]),le=t&&a?`${a}class_id=${l||""}&subject_id=${f||""}§ion_id=${c||""}&date=${m?.format("YYYY-MM-DD")||""}&page=${r.page}&per_page=${r.rowsPerPage}`:null,{isLoading:Ce,error:Le,data:Re,mutate:xe}=q(le?[le,t]:null,([je,Me])=>W(je,Me)),De=async(je,Me)=>{try{await xe(Ze(je,Me,t),pt(Me)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),ze()}catch(rt){console.error(rt),T.error("Failed to add the new item.",{duration:1e3})}},Ue=async je=>{try{await xe(st("api/student/Homework/deleteHomework",je,t),ot(je)),T.success("Success! Deleted item.",{duration:1e3})}catch(Me){console.error(Me),T.error("Failed to delete the item.",{duration:1e3})}},ye=async je=>{try{const Me=await ct("api/student/Homework/updateHomework",je,t);xe(Me),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),ze()}catch(Me){console.error(Me),T.error("Failed to update the item.",{duration:1e3})}},me=je=>{je.preventDefault();const Me=new FormData(je.target),rt=Me.get("class_id")||l,vt=Me.get("section_id")||c,na=Me.get("subject_id")||f,Vt=m?.format("YYYY-MM-DD");n(`api/branchapi/homeworks/gethomeworklistByClassSectionBranch?class_id=${rt||""}&subject_id=${na||""}§ion_id=${vt||""}${Vt?`&date=${Vt}`:""}&`),o(Se=>({...Se,page:1}))},Pe=je=>{je.preventDefault();const Me=new FormData(je.target);De("api/branchapi/homeworks/addHomework",Me),Y("")},Ye=async(je,Me)=>{je.preventDefault();const rt=new FormData(je.target);rt.append("id",Me),L(!0);try{await ye(rt)}finally{L(!1)}},ze=()=>{y(!1),b(null),R(null),A(null),u(null),j(null),O(null),Y("")},we=je=>{b(je);const Me=je?.class_id??je?.classId??null,rt=je?.section_id??je?.sectionId??null,vt=je?.subject_id??je?.subjectId??null;R(Me),A(rt),u(vt),Me?(j(`api/branchapi/academy/sectionoftheClass?class_id=${Me}`),O(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${Me}`)):(j(null),O(null)),Y(je?.file||je?.document||""),y(!0)},ke=je=>{const Me=je?.value??null;R(Me),A(null),u(null),Me?(j(`api/branchapi/academy/sectionoftheClass?class_id=${Me}`),O(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${Me}`)):(j(null),O(null))},Te=je=>{A(je?.value??null)},ce=je=>{u(je?.value??null)},ve=(je,Me)=>{o({page:je,rowsPerPage:parseInt(Me,10)})},_e=()=>{k(!1),C(""),M("")},Ve=(je,Me)=>{if(!je){T.error("No document found.",{duration:1e3});return}C(je),M(Me||"Document"),k(!0)},He=[{title:"Date",dataIndex:"homework_date",key:"homework_date"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission Date",dataIndex:"submit_date",key:"submit_date"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Document",key:"document",render:(je,Me)=>{const rt=Me?.document||Me?.file||"";if(!rt)return e.jsx("span",{style:{color:"#999",fontSize:12},children:"Not Uploaded"});const vt=Kl(rt,Me,t);return e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>Ve(vt,rt),children:"View"})}},{title:"Action",key:"action",render:(je,Me)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>we(Me),style:{padding:2}}),e.jsx(At,{id:Me?.id,funcName:Ue})]})}];return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Search Homework"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:me,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{options:Z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:Z.find(je=>String(je.value)===String(l))??null,onChange:je=>B(je,"class_id")})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{options:te,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:te.find(je=>String(je.value)===String(c))??null,onChange:je=>B(je,"section_id")})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{options:se,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:se.find(je=>String(je.value)===String(f))??null,onChange:je=>B(je,"subject_id")})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(Ge,{Desplay:"Date",format:"YYYY-MM-DD",allowClear:!1,value:m,onChange:je=>v(je)})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(w,{children:[e.jsx(de,{type:"submit",value:"Search",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{n("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),d(null),h(null),p(null),v(null)},style:Gl,children:"Cancel"})]})})})})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Homework List"})}),e.jsx(w,{p:3,children:e.jsx(Ke,{parentCallback:ve,data:{newData:Re,columns:He,columnstype:"antd",action:!1,Loading:Ce,error:Le,deleteTodoMutation:Ue,pageController:r}})})]})})]}),e.jsx(s.Drawer,{open:S,title:g?"Edit Homework":"Add Homework",placement:"right",width:600,destroyOnClose:!0,onClose:ze,children:e.jsx("form",{onSubmit:g?je=>Ye(je,g.id):Pe,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:Z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,placeholder:"Select Class",value:Z.find(je=>String(je.value)===String(D))??null,onChange:ke})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:ee,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,placeholder:D?"Select Section":"Select Class First",value:ee.find(je=>String(je.value)===String(I))??null,onChange:Te,isDisabled:!D})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{options:pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"sub_id",required:!0,allowSelectAll:!1,placeholder:D?"Select Subject":"Select Class First",value:pe.find(je=>String(je.value)===String(_))??null,onChange:ce,isDisabled:!D})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",defaultValue:g?.homew_date?ne(g?.homew_date):ne(),Desplay:"From",name:"homew_date"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",defaultValue:g?.submission_date?ne(g?.submission_date):ne(),Desplay:"Deadline",name:"submission_date"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{type:"text",label:"Title",name:"title",defaultValue:g?.title||"",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(kt,{type:"text",label:"Description",name:"description",defaultValue:g?.description||"",rows:3,required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.Upload,{action:`${ut()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${mu(t)}/student/homework`},headers:{Authorization:t},maxCount:1,onChange:je=>{if(je.file.status==="removed"&&Y(""),je.file.status==="done"){const Me=je.file.response?.data??je.file.response?.file??"";Y(String(Me??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:U?"Change":"Upload"})}),U&&g&&e.jsx("a",{href:Kl(U,g,t),target:"_blank",rel:"noreferrer",style:{display:"block",marginTop:8,fontSize:12,color:"#1677ff",textDecoration:"underline"},children:"View existing document"}),e.jsx("input",{type:"hidden",name:"file",value:U||"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(w,{children:[e.jsx(de,{type:"submit",value:V?"Saving...":"Save",color:"primary",disabled:V}),e.jsx(s.Button,{type:"text",onClick:ze,style:Gl,children:"Cancel"})]})})})})]})})}),e.jsx(s.Modal,{open:z,onCancel:_e,footer:null,width:900,closable:!0,children:e.jsxs(w,{p:3,children:[e.jsx(w,{mb:2,children:e.jsx(he,{level:5,children:E||"View Document"})}),F?F.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:F,title:E||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:F,alt:E||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(he,{children:"No document found"})]})}),e.jsx(w,{style:{position:"fixed",bottom:24,right:24,zIndex:1e3},children:e.jsx(s.Button,{type:"primary",size:"large",onClick:()=>{b(null),R(null),A(null),u(null),j(null),O(null),Y(""),y(!0)},style:{borderRadius:"50%",width:56,height:56,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24},children:"+"})})]})}const bi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Hy({token:t}){const[a,n]=i.useState(!1),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,h]=i.useState({page:1,rowsPerPage:10}),[f,p]=i.useState(!1),[m,v]=i.useState(""),[S,y]=i.useState(""),[g,b]=i.useState({label:"",value:""}),[D,R]=i.useState({label:"",value:""}),[I,A]=i.useState({label:"",value:""}),[_,u]=i.useState(!1),[x,j]=i.useState(!1),{data:P}=q(t?["api/branchapi/academy/classdropdownlist",t]:null,([X,J])=>W(X,J)),{data:O}=q(t&&a?[a,t]:null,([X,J])=>W(X,J)),{data:z}=q(t&&(r||!0)?[r||"api/branchapi/academy/subjecttableList",t]:null,([X,J])=>W(X,J)),k=i.useMemo(()=>bi(P),[P]),F=i.useMemo(()=>bi(O),[O]),C=i.useMemo(()=>bi(z),[z]),E=t&&l?`${l}page=${c.page}&per_page=${c.rowsPerPage}`:null,{isLoading:M,error:U,data:Y,mutate:V}=q(E?[E,t]:null,([X,J])=>W(X,J)),L=(X,J)=>{switch(J){case"class_id":b(X||{label:"",value:""}),R({label:"",value:""}),A({label:"",value:""}),o(`/api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${X?.value??""}`),n(`/api/branchapi/academy/sectionoftheClass?class_id=${X?.value??""}`),u(K=>!K),j(K=>!K);break;case"section_id":R(X||{label:"",value:""});break;case"subject_id":A(X||{label:"",value:""});break}},B=async X=>{X.preventDefault();const J="/api/branchapi/homeworks/gethomeworklistByClassSectionBranch",K=new URLSearchParams;g.value&&K.append("class_id",String(g.value)),D.value&&K.append("section_id",String(D.value)),I.value&&K.append("subject_id",String(I.value));const Z=K.toString(),ee=Z?`${J}?${Z}&`:`${J}?`;h(pe=>({...pe,page:1})),d(ee),await V()},$=(X,J)=>{h({page:X,rowsPerPage:parseInt(J,10)})},N=()=>{p(!1),v(""),y("")},H=(X,J)=>{v(X),y(J||"Document"),p(!0)},Q=[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Assign By",dataIndex:"staff_name",key:"staff_name"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission",dataIndex:"total_submission",key:"total_submission"},{title:"View Document",key:"document",render:(X,J)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>H(J.document_url,J.document),children:"View"})}];return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Submission Details"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:B,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:k.find(X=>String(X.value)===String(g.value))??null,onChange:X=>L(X,"class_id")})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:F.find(X=>String(X.value)===String(D.value))??null,onChange:X=>R(X||{label:"",value:""})},`sections1${_}`)})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:C.find(X=>String(X.value)===String(I.value))??null,onChange:X=>A(X||{label:"",value:""})},`subjects1${x}`)})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})})]})})})]})}),l&&e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Students List"})}),e.jsx(w,{p:3,children:e.jsx(Ke,{parentCallback:$,data:{newData:Y,columns:Q,columnstype:"antd",action:!1,Loading:M,error:U,pageController:c}})})]})})]}),e.jsx(s.Modal,{open:f,onClose:N,footer:null,width:900,children:e.jsxs(w,{p:3,children:[e.jsxs(w,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(he,{level:5,children:S||"View Document"}),e.jsx(de,{type:"button",value:"Close",color:"primary",onClick:N})]}),m?m.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:m,title:S||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:m,alt:S||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(he,{children:"No document found"})]})})]})}const Ky=(t,a)=>{const n=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${n}/${r}`};function Gy({token:t,sampleFileUrl:a}){const n=t??localStorage.getItem("authToken")??"",[r,o]=i.useState(null),[l,d]=i.useState(null),[c,h]=i.useState(null),[f,p]=i.useState(null),[m,v]=i.useState(null),[S,y]=i.useState(null),[g,b]=i.useState(null),D="api/branchapi/library/bookCategorydropdown",R="api/branchapi/academy/classdropdownlist",I="api/branchapi/Academy/getClassSubjectdropdown",A="api/branchapi/library/addBook",_="api/branchapi/library/uploadcsv",{data:u}=q(n?[D,n]:null,([E,M])=>W(E,M)),{data:x}=q(n&&R?[R,n]:null,([E,M])=>W(E,M)),{data:j}=q(n&&I?[I,n]:null,([E,M])=>W(E,M)),P=i.useMemo(()=>Ky(Nt(),_),[_]),O=async E=>{E.preventDefault();const M=new FormData(E.target);M.set("cat_id",m?.value??""),M.set("class_id",S?.value??""),M.set("subject_id",g?.value??"");try{await Ze(A,M,n),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),E.target.reset(),v(null),y(null),b(null)}catch(U){T.error(U?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},z=async E=>{if(E.preventDefault(),!r){T.error("Please select a CSV file.",{duration:1e3});return}const M=new FormData;M.append("file",r),M.append("cat_id",l?.value??""),M.append("class_id",c?.value??""),M.append("subject_id",f?.value??"");try{const U=await dt.post(P,M,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});U?.data?.Status==="Failed"?T.error(String(U?.data?.msg??"Upload failed."),{duration:1e3}):(T.success(String(U?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),o(null),E.target.reset(),d(null),h(null),p(null))}catch(U){T.error(U?.response?.data?.msg??"Upload failed.",{duration:1e3})}},k=()=>["title,author,publisher,quantity,price,fine,subject_id,barcode,class_id",...["Advanced Chemistry,Rahul Mondal,RM PUBLISHER,10,210,20,1,,1","Advanced Chemistry,Rahul Mondal,RM PUBLISHER,10,210,20,1,123321,1"]].join(`
|
|
60
|
+
`),F=()=>{if(a)return a;const E=Nt();return E?`${E.replace(/\/+$/,"")}/books.csv`:"/books.csv"},C=()=>{const E=F();fetch(E).then(M=>{if(!M.ok)throw new Error("Sample file not found");const U=M.headers.get("content-type")||"";return!U.includes("csv")&&!U.includes("text/plain")&&!U.includes("application/octet-stream")?M.text().then(Y=>{if(Y.trim().startsWith("<")||Y.includes("<!doctype")||Y.includes("<html"))throw new Error("Sample file URL returned HTML. Host the CSV at a public URL and pass it via sampleFileUrl prop.");return new Blob([Y],{type:"text/csv"})}):M.blob()}).then(M=>{const U=window.URL.createObjectURL(M),Y=document.createElement("a");Y.href=U,Y.download="books.csv",Y.click(),window.URL.revokeObjectURL(U)}).catch(()=>{const M=k(),U=new Blob([M],{type:"text/csv"}),Y=window.URL.createObjectURL(U),V=document.createElement("a");V.href=Y,V.download="books.csv",V.click(),window.URL.revokeObjectURL(Y)})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(s.Button,{type:"link",icon:e.jsx(re.DownloadOutlined,{}),onClick:C,children:"Download Sample"}),children:[e.jsx(s.Divider,{children:"Information"}),e.jsx(s.Typography.Paragraph,{style:{marginBottom:16},children:"1. Your CSV data should be in the format below. The first line of your CSV file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("form",{onSubmit:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:l,onChange:E=>d(E??null)}),e.jsx(ae,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:c,onChange:E=>h(E??null)}),e.jsx(ae,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:f,onChange:E=>p(E??null)}),e.jsx(G,{type:"file",label:"Upload CSV/Excel",name:"csv",accept:".csv,.xlsx,.xls",onChange:E=>o(E.target.files?.[0]??null),required:!0}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(G,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(G,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(G,{type:"text",label:"Publication",name:"publisher"}),e.jsx(G,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(G,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(G,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(G,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(ae,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:m,onChange:E=>v(E??null)}),e.jsx(ae,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:S,onChange:E=>y(E??null)}),e.jsx(ae,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:g,onChange:E=>b(E??null)}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})})]})}const ji={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Si=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Jy({token:t}){const a=t??localStorage.getItem("authToken")??"",[n,r]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:n,onChange:(K,Z)=>{r(K),l(Z)}},h=Ka.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),f=()=>{if(!(typeof window>"u")){if(!o.length){T.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){T.error("Nothing to print.",{duration:1e3});return}h?.()}},[p,m]=i.useState(!1),[v,S]=i.useState(null),[y,g]=i.useState(null),[b,D]=i.useState(null),[R,I]=i.useState(null),[A,_]=i.useState({page:1,rowsPerPage:10}),u=(K,Z)=>{_({page:K,rowsPerPage:parseInt(Z,10)})},x="api/branchapi/library/booktable",j="api/branchapi/library/deletebooks",P="api/branchapi/library/editbook",O=`${x}?page=${A.page}&per_page=${A.rowsPerPage}`,{isLoading:z,error:k,data:F,mutate:C}=q(a?[O,a]:null,([K,Z])=>W(K,Z)),E="api/branchapi/library/bookCategorydropdown",M="api/branchapi/academy/classdropdownlist",U="api/branchapi/Academy/getClassSubjectdropdown",{data:Y}=q(a?[E,a]:null,([K,Z])=>W(K,Z)),{data:V}=q(a&&M?[M,a]:null,([K,Z])=>W(K,Z)),{data:L}=q(a&&U?[U,a]:null,([K,Z])=>W(K,Z)),B=i.useMemo(()=>Si(Y),[Y]),$=i.useMemo(()=>Si(V),[V]),N=i.useMemo(()=>Si(L),[L]),H=async K=>{try{await st(j,K,a),await C(),T.success("Success! Deleted item.",{duration:1e3})}catch(Z){T.error(Z?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},Q=K=>{S(K??null);const Z=K?.cat_id??K?.fk_cat_id??K?.category_id,ee=K?.class_id??K?.fk_class_id,pe=K?.subject_id??K?.fk_subject_id;g(B.find(te=>te?.value===Z)??null),D($.find(te=>te?.value===ee)??null),I(N.find(te=>te?.value===pe)??null),m(!0)},X=async K=>{K.preventDefault();const Z=v?.id??v?.book_id??v?._id;if(!Z)return;const ee=new FormData(K.target);ee.set("id",String(Z)),ee.set("cat_id",y?.value??""),ee.set("class_id",b?.value??""),ee.set("subject_id",R?.value??"");try{await ct(P,ee,a),await C(),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),m(!1),S(null)}catch(pe){T.error(pe?.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:(K,Z)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>Q(Z),style:{padding:2}}),e.jsx(s.Button,{type:"text",size:"small",danger:!0,onClick:()=>H(Z?.id??Z?.book_id??Z?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[B,$,H,N]);return e.jsxs("div",{style:{},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:p,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{m(!1),S(null)},children:e.jsx("form",{onSubmit:X,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(G,{label:"Book Name",name:"title",defaultValue:v?.book_title??"",required:!0}),e.jsx(G,{label:"Author",name:"author",defaultValue:v?.author??"",required:!0}),e.jsx(G,{label:"Publication",name:"publish",defaultValue:v?.publish??""}),e.jsx(G,{label:"Qty",name:"quantity",type:"number",defaultValue:v?.quantity??""}),e.jsx(G,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:v?.perunitcost??""}),e.jsx(G,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:v?.fine_amount??""}),e.jsx(G,{label:"Barcode",name:"barcode",defaultValue:v?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ji,children:"Category"}),e.jsx(ae,{options:B,value:y,onChange:K=>g(K??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ji,children:"Class"}),e.jsx(ae,{options:$,value:b,onChange:K=>D(K??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ji,children:"Subject"}),e.jsx(ae,{options:N,value:R,onChange:K=>I(K??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{m(!1),S(null)},children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(s.Button,{type:"primary",onClick:f,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Ke,{parentCallback:u,data:{newData:F,columns:J,columnstype:"antd",action:!1,Loading:z,error:k,rowSelection:c}})}),e.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:e.jsx("div",{ref:d,style:{padding:"20px"},children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:o.map((K,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:K.book_title}),e.jsx(Sc,{value:K.barcode?String(K.barcode):String(K.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},Z))})})})]})}const Qy=(t,a)=>{const n=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${n}/${r}`},Sa=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},Bs=t=>ne(t).add(1,"month").format("YYYY-MM-DD"),Xy=i.forwardRef(({token:t,onReturn:a},n)=>{const r=t??localStorage.getItem("authToken")??"",[o,l]=i.useState("issue"),d=o==="return",[c,h]=i.useState(!1),[f,p]=i.useState(!1),[m,v]=i.useState(null),[S,y]=i.useState([]),[g,b]=i.useState([]),[D,R]=i.useState([]),[I,A]=i.useState(0),[_,u]=i.useState(!1),[x,j]=i.useState(null),[P,O]=i.useState(null),[z,k]=i.useState(null),[F,C]=i.useState(!1),[E,M]=i.useState("Cash"),[U,Y]=i.useState(""),[V,L]=i.useState(""),[B,$]=i.useState(0),[N,H]=i.useState("NO_FINE"),Q=i.useRef(null),[X]=s.Form.useForm(),[J]=s.Form.useForm(),K="api/branchapi/library/bookCategorydropdown",Z="api/branchapi/academy/classdropdownlist",ee="api/branchapi/Academy/getClassSubjectdropdown",{data:pe}=q(r?[K,r]:null,([be,Ie])=>W(be,Ie)),{data:te}=q(r&&Z?[Z,r]:null,([be,Ie])=>W(be,Ie)),{data:se}=q(r&&ee?[ee,r]:null,([be,Ie])=>W(be,Ie)),le=i.useMemo(()=>Sa(pe),[pe]),Ce=i.useMemo(()=>Sa(te),[te]),Le=i.useMemo(()=>Sa(se),[se]),Re="api/branchapi/library/studentsearchByNameID",xe="api/branchapi/library/booksearchBybookname",De="api/branchapi/library/issuedBookList",Ue="api/branchapi/library/issueLibrarybook",ye="api/branchapi/library/returnedLibrarybook",{trigger:me,data:Pe}=it(Re,(be,Ie)=>Ta(be,Ie,r)),{trigger:Ye,data:ze}=it(xe,(be,Ie)=>Ta(be,Ie,r)),{trigger:we,data:ke}=it(De,(be,Ie)=>Ta(be,Ie,r)),{trigger:Te}=it(d?ye:Ue,(be,Ie)=>hs(be,Ie,r)),ce=i.useMemo(()=>Sa(Pe),[Pe]),ve=i.useMemo(()=>Sa(ze),[ze]),_e=i.useMemo(()=>Sa(ke),[ke]),Ve=be=>{const Ie=Bs(ne());y(at=>at.some(xt=>String(xt?.id)===String(be?.id))?at:[...at,{...be,return_date:be?.return_date?be.return_date:Ie}])},He=async()=>{console.log("Reloading IssueReturn..."),T.success("Success",{duration:1e3}),b([]),R([]),A(0),H("FINE_PAY_LATER"),await we({id:m?.student_id})};i.useImperativeHandle(n,()=>({reloadPayLater:He}));const je=be=>{y(Ie=>Ie.filter(at=>String(at?.id)!==String(be)))},Me=async be=>{if(r){if(!be){v(null);return}c||await me({id:be})}},rt=async({search:be})=>{if(!r||!c)return;const Ie=await me({id:be}),at=Sa(Ie);at.length===1&&(v(at[0]),await we({id:at[0]?.student_id}),X.resetFields())},vt=async(be,Ie)=>{v(Ie??null),y([]),b([]),R([]),A(0),H("NO_FINE"),$(0),Ie?.student_id&&await we({id:Ie.student_id}),X.resetFields()},na=async be=>{r&&be&&(f||await Ye({book:be}))},Vt=async({search_book:be})=>{if(!r||!f)return;const Ie=await Ye({book:be,catID:x?.value??"",sID:z?.value??"",cID:P?.value??""}),at=Sa(Ie);at.length&&(Ve(at[0]),J.resetFields())},Se=(be,Ie)=>{Ve(Ie),J.resetFields()},Oe=async()=>{if(!m?.member_id){T.error("Select a student first.",{duration:1e3});return}if(!S.length){T.error("Select at least one book.",{duration:1e3});return}const be=await Te({member_id:m.member_id,fine:!1,books:S});be?.Status==="Success"&&(T.success(String(be?.msg??"Success"),{duration:1e3}),y([]),v(null),b([]),R([]),A(0))},oe=async()=>{if(!m?.member_id){T.error("Select a student first.",{duration:1e3});return}if(!D.length){T.error("Select at least one book to return.",{duration:1e3});return}if(Number(I)>0){H("FINE_PAID"),C(!0);return}const be=await Te({member_id:m.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(D)});be?.Status==="Success"?(T.success(String(be?.msg??"Success"),{duration:1e3}),b([]),R([]),A(0),await we({id:m?.student_id})):T.error(String(be?.msg??"Failed"),{duration:1e3})},ge=async()=>{if(!m?.member_id)return;const be=Math.max(0,Number(I)-Number(B||0)),Ie={member_id:m.member_id,collection_type:N,amount:N==="FINE_PAID"?be:0,payment_type:E,notes:U,attchement:V,discount:B||0,books:JSON.stringify(D)},at=await Te(Ie);C(!1),at?.Status==="Success"?(T.success(String(at?.msg??"Success"),{duration:1e3}),b([]),R([]),A(0),$(0),Y(""),L(""),H("NO_FINE"),await we({id:m?.student_id})):T.error(String(at?.msg??"Failed"),{duration:1e3})},$e=async()=>{if(!m?.member_id){T.error("Select a student first.",{duration:1e3});return}if(!D.length){T.error("Select at least one book to return.",{duration:1e3});return}const be={member_id:m.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(D)};a(be)},Ne=i.useMemo(()=>Qy(Nt(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),ht=[{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:(be,Ie)=>e.jsx(Ge,{defaultValue:ne(Ie?.return_date||ne().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(at,xt)=>{y(It=>It.map(Lt=>String(Lt?.id)===String(Ie?.id)?{...Lt,return_date:xt}:Lt))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(be,Ie)=>e.jsx(s.Button,{type:"text",danger:!0,onClick:()=>je(Ie?.id),children:"Remove"})}],yt={selectedRowKeys:g,onChange:(be,Ie)=>{b(be),R(Ie);const at=(Ie??[]).reduce((xt,It)=>xt+Number(It?.totalfine??0),0);A(at)},onSelect:(be,Ie,at)=>{if(Ie){const xt=at.map(It=>({...It,return_date:It?.return_date?It.return_date:Bs(It?.issue_date||ne())}));R(xt)}},onSelectAll:(be,Ie)=>{if(be){const at=Ie.map(xt=>({...xt,return_date:xt?.return_date?xt.return_date:Bs(xt?.issue_date||ne())}));R(at)}}},Tt=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(be,Ie)=>{const xt=D.find(Lt=>String(Lt?.id)===String(Ie?.id))?.return_date||Ie?.return_date,It=Bs(Ie?.issue_date||ne());return e.jsx(Ge,{defaultValue:ne(xt||It),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(Lt,ei)=>{R(ti=>ti.map(En=>String(En?.id)===String(Ie?.id)?{...En,return_date:ei}:En))}})}},{title:"Days",key:"days",width:100,render:(be,Ie)=>{const xt=D.find(Lt=>String(Lt?.id)===String(Ie?.id))?.return_date||Ie?.return_date,It=Ie?.issue_date;if(It&&xt){const Lt=ne(xt).diff(ne(It),"day");return Lt>=0?Lt:0}return"-"}},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:be=>e.jsxs("span",{children:["₹ ",be]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:F,onCancel:()=>C(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(s.Radio.Group,{value:E,onChange:be=>M(be.target.value),options:[{label:"Cash",value:"Cash"},{label:"UPI",value:"UPI"},{label:"DD",value:"DD"},{label:"Bank",value:"Bank"},{label:"Internet Banking",value:"Internet Banking"},{label:"Cheque",value:"Cheque"}]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Note"}),e.jsx(s.Input.TextArea,{rows:3,value:U,onChange:be=>Y(be.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(s.Upload,{action:Ne,headers:{Authorization:r},maxCount:1,onChange:be=>{if(be.file.status==="done"){const Ie=be.file.response?.data??be.file.response?.file??"";L(String(Ie??""))}},children:e.jsx(s.Button,{icon:e.jsx(re.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(s.Input,{type:"number",value:B,onChange:be=>$(be.target.value),placeholder:"0"})]}),e.jsxs(s.Button,{type:"primary",onClick:ge,children:["Collect ₹",Math.max(0,Number(I)-Number(B||0))]}),e.jsx(s.Button,{onClick:()=>C(!1),children:"Cancel"})]})}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:10,children:e.jsx(s.Radio.Group,{value:o,onChange:be=>{const Ie=be.target.value;l(Ie),y([]),b([]),R([]),A(0),H("NO_FINE"),$(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(s.Col,{xs:24,md:14,children:e.jsx(s.Form,{form:X,onFinish:rt,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search",label:"Search Student",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:c?e.jsx(s.Input,{autoFocus:!0,addonBefore:e.jsxs(s.Space,{children:[e.jsx(re.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:c,onChange:be=>h(be.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{options:ce,onSelect:vt,onSearch:Me,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(re.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:c,onChange:be=>h(be.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),m?e.jsxs(e.Fragment,{children:[e.jsx(s.Divider,{}),e.jsxs(s.Row,{gutter:[12,12],children:[e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Name:"})," ",m?.value??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Card No:"})," ",m?.library_card_no??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Member ID:"})," ",m?.member_id??""]})]})]}):null,e.jsx(s.Divider,{}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(s.Table,{dataSource:_e,columns:Tt,rowSelection:yt,pagination:!1,rowKey:be=>be?.id??be?.issue_id??be?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(s.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(s.Typography.Text,{strong:!0,children:["Total Fine: ₹",I]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(s.Button,{type:"primary",onClick:oe,disabled:!D.length,children:I>0?`Pay Now ₹ ${Math.max(0,Number(I)-Number(B||0))}`:"Return Selected"}),I>0?e.jsx(s.Button,{onClick:$e,disabled:!D.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:18,children:e.jsx(s.Form,{form:J,onFinish:Vt,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:f?e.jsx(s.Input,{autoFocus:!0,disabled:!m,addonBefore:e.jsxs(s.Space,{children:[e.jsx(re.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:f,onChange:be=>p(be.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{disabled:!m,options:ve,onSelect:Se,onSearch:na,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(re.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:f,onChange:be=>p(be.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(s.Button,{style:{width:"100%"},icon:e.jsx(re.FilterOutlined,{}),onClick:()=>u(!0),children:"Filter"})})]}),e.jsx(s.Drawer,{open:_,onClose:()=>u(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ae,{label:"Category",options:le,value:x,onChange:be=>j(be??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(ae,{label:"Class",options:Ce,value:P,onChange:be=>O(be??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(ae,{label:"Subjects",options:Le,value:z,onChange:be=>k(be??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(s.Button,{type:"primary",onClick:()=>u(!1),children:"Apply"})]})}),e.jsx(s.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(s.Table,{dataSource:S,columns:ht,pagination:!1,rowKey:be=>be?.id??be?.book_id??be?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Issue",onClick:Oe})})]})]}),e.jsx("div",{ref:Q,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}),Jl=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Zy({token:t}){const a=t??localStorage.getItem("authToken")??"",[n,r]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,c]=i.useState(null),[h,f]=i.useState(!1),[p,m]=i.useState(!1),[v,S]=i.useState(null),[y,g]=i.useState(!1),b="api/branchapi/academy/classdropdownlist",D="api/branchapi/academy/sectionoftheClass",R="api/branchapi/library/studenttableForLibrary",I="api/branchapi/library/addmembershipforStudent",A="api/branchapi/library/removemembershipforStudent",_=i.useMemo(()=>{if(!o?.value)return null;const L=D.includes("?")?"&":"?";return`${D}${L}class_id=${encodeURIComponent(String(o.value))}`},[D,o?.value]),u=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const L=R.includes("?")?"&":"?";return`${R}${L}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${n.page}&per_page=${n.rowsPerPage}`},[n.page,n.rowsPerPage,o?.value,d?.value,R]),{data:x}=q(a&&b?[b,a]:null,([L,B])=>W(L,B)),{data:j}=q(a&&_?[_,a]:null,([L,B])=>W(L,B)),{isLoading:P,error:O,data:z,mutate:k}=q(a&&u?[u,a]:null,([L,B])=>W(L,B)),F=i.useMemo(()=>Jl(x),[x]),C=i.useMemo(()=>Jl(j),[j]),E=(L,B)=>{r({page:L,rowsPerPage:parseInt(B,10)})},M=L=>{const B=L?.id??L?.student_id??L?.member_id;S(B??null),m(!0),g($=>!$)},U=async L=>{if(L.preventDefault(),!v)return;const B=new FormData(L.target);B.set("id",String(v));try{await Ze(I,B,a),T.success("Success! Added member.",{duration:1e3,icon:"🎉"}),m(!1),S(null),await k()}catch($){T.error($?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},Y=async L=>{try{await st(A,L,a),T.success("Success! Removed member.",{duration:1e3}),await k()}catch(B){T.error(B?.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:(L,B)=>(console.log("data______________",B),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:B?.library_card_no==null?e.jsx(s.Button,{type:"primary",size:"small",icon:e.jsx(re.UserAddOutlined,{}),onClick:()=>M(B)}):e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{}),onClick:()=>Y(B?.id??B?.student_id??B?.member_id)})}))}],[Y]);return e.jsxs("div",{style:{},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:p,title:"Add Member",onCancel:()=>{m(!1),S(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:U,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(G,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Add",color:"primary"})})]})},`add-${y}`)}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Student"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ae,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:L=>{l(L??null),c(null),f(B=>!B)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(ae,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:L=>c(L??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${h}`),e.jsx(de,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){T.error("Select class and section.",{duration:1e3});return}r(L=>({...L,page:1}))}})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Ke,{parentCallback:E,data:{newData:z,columns:V,columnstype:"antd",action:!1,Loading:P,error:O}})})]})}function ex({token:t}){const a=t??localStorage.getItem("authToken")??"",[n,r]=i.useState({page:1,rowsPerPage:10}),[o]=s.Form.useForm(),[l]=s.Form.useForm(),[d,c]=i.useState(!1),[h,f]=i.useState(null),p="api/branchapi/library/BookCategorytable",m="api/branchapi/library/addBookCategory",v="api/branchapi/library/editBookCategory",S="api/branchapi/library/deleteBookCategory",y=i.useMemo(()=>{const O=p.includes("?")?"&":"?";return`${p}${O}page=${n.page}&per_page=${n.rowsPerPage}`},[p,n.page,n.rowsPerPage]),{isLoading:g,error:b,data:D,mutate:R}=q(a&&y?[y,a]:null,([O,z])=>W(O,z)),I=(O,z)=>{r({page:O,rowsPerPage:parseInt(z,10)})},A=async O=>{const z=new FormData;z.set("title",O?.title??"");try{await Ze(m,z,a),T.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await R()}catch(k){T.error(k?.response?.data?.msg??k?.message??"Failed to add category.",{duration:1e3})}},_=O=>{f(O??null),l.setFieldsValue({title:O?.name??""}),c(!0)},u=()=>{c(!1),f(null),l.resetFields()},x=async O=>{const z=h?.id??h?.category_id??h?.cat_id;if(!z){T.error("Missing category id.",{duration:1e3});return}const k=new FormData;k.set("id",String(z)),k.set("title",O?.title??"");try{await ct(v,k,a),T.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),u(),await R()}catch(F){T.error(F?.response?.data?.msg??F?.message??"Failed to update category.",{duration:1e3})}},j=async O=>{const z=O?.id??O?.category_id??O?.cat_id;if(!z){T.error("Missing category id.",{duration:1e3});return}try{await st(S,z,a),T.success("Success! Deleted category.",{duration:1e3}),await R()}catch(k){T.error(k?.response?.data?.msg??k?.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:(O,z)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>_(z)}),e.jsx(s.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>j(z),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[j]);return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:d,title:"Edit Category",onCancel:u,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:l,layout:"vertical",onFinish:x,children:[e.jsx(s.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(s.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:u,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,lg:8,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:A,children:[e.jsx(s.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(s.Input,{placeholder:"Enter category name"})}),e.jsx(de,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(s.Col,{xs:24,lg:16,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Ke,{parentCallback:I,data:{newData:D,columns:P,columnstype:"antd",action:!1,Loading:g,error:b}})})})]})]})}const wi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function tx({token:t}){const[a,n]=i.useState([ne().format("YYYY-MM-DD"),ne().format("YYYY-MM-DD")]),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,h]=i.useState(null),[f,p]=i.useState(!1),[m,v]=i.useState(!1),S="api/branchapi/academy/classdropdownlist",y="api/branchapi/academy/sectionoftheClass",g="api/branchapi/library/memberDropdown",b="api/report/libraryReport/libraryReport",D=i.useMemo(()=>{if(!r?.value)return null;const M=y.includes("?")?"&":"?";return`${y}${M}class_id=${encodeURIComponent(String(r.value))}`},[y,r?.value]),R=i.useMemo(()=>{if(!r?.value)return null;const M=g.includes("?")?"&":"?",U=`${g}${M}class=${encodeURIComponent(String(r.value))}`;return l?.value?`${U}§ion=${encodeURIComponent(String(l.value))}`:U},[g,r?.value,l?.value]),{isLoading:I,error:A,data:_,mutate:u}=q(t&&S?[S,t]:null,([M,U])=>W(M,U)),{data:x}=q(t&&D?[D,t]:null,([M,U])=>W(M,U)),{data:j}=q(t&&R?[R,t]:null,([M,U])=>W(M,U)),P=i.useMemo(()=>wi(_),[_]),O=i.useMemo(()=>wi(x),[x]),z=i.useMemo(()=>wi(j),[j]),{trigger:k,data:F}=it(b,(M,U)=>co(M,U,t));i.useEffect(()=>{(async()=>{v(!0);try{await k({duration:a})}catch(U){console.error(U?.message||"Failed to fetch report")}finally{v(!1)}})()},[]);const C=async()=>{v(!0);try{await k({duration:a,class:r?.value??"",section:l?.value??"",student_id:c?.value??""})}catch(M){console.error(M?.message||"Failed to fetch report")}finally{v(!1)}},E=[{title:"Name",dataIndex:"full_name",render:(M,U)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:U?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(M,U)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:U?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(M,U)=>e.jsxs(s.Typography.Text,{style:{fontSize:12},children:[U?.class??"","(",U?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(M,U)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:U?.book_title??""})},{title:"Issue Date",key:"date",render:(M,U,Y)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:U?.issue_date??""})},{title:"Due Return Date",key:"date",render:(M,U,Y)=>e.jsx(s.Tag,{color:"orange",children:U?.return_date??""})},{title:"Return Date",key:"date",render:(M,U,Y)=>U?.retured_by_user?e.jsx(s.Tag,{color:"green",children:U?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(M,U,Y)=>String(U?.is_returned??"")==="1"?e.jsx(s.Tag,{color:"green",children:"Return"}):e.jsx(s.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(M,U,Y)=>{const V=U?.late_fine?Number(U.late_fine):0;return V?e.jsx(s.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:V}):null}}];return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(s.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(s.DatePicker.RangePicker,{style:{width:"100%"},value:[ne(a[0],"YYYY-MM-DD"),ne(a[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(M,U)=>{Array.isArray(U)&&U.length===2&&n([U[0],U[1]])}})]})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ae,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:M=>{o(M??null),d(null),h(null),p(U=>!U)},allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ae,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:M=>{d(M??null),h(null)},allowSelectAll:!1},`section1${f}`)}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ae,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:M=>h(M??null),allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:1,children:e.jsx(s.Button,{type:"primary",icon:e.jsx(re.SearchOutlined,{}),onClick:C,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(s.Table,{columns:E,pagination:!1,dataSource:Array.isArray(F?.data)?F.data:[],size:"small",rowKey:(M,U)=>M?.id??M?.issue_id??M?.fees_receipt_id??U,loading:m,scroll:{x:"max-content"},summary:M=>{const U=M.reduce((V,L)=>V+Number(L?.late_fine??0),0),Y=M.reduce((V,L)=>V+Number(L?.is_returned??0),0);return e.jsxs(s.Table.Summary.Row,{children:[e.jsx(s.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",M.length]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(M.length-Y)]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",Y]})}),e.jsx(s.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",U.toLocaleString("en-IN")]})})]})}})})]})]})}const Ql=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],Xl=[{key:"renewalHistory",label:"Renewal History"},{key:"renewalFineReport",label:"Renewal + Fine"},{key:"currentlyRenewedBooks",label:"Currently Renewed"},{key:"upcomingRenewalDue",label:"Upcoming Due"},{key:"overdueRenewalReport",label:"Overdue"},{key:"renewalLimitReport",label:"Renewal Limit"},{key:"renewalStatusReport",label:"Renewal Status"},{key:"studentWiseReport",label:"Student-wise"},{key:"bookWiseReport",label:"Book-wise"},{key:"classWiseReport",label:"Class-wise"},{key:"staffWiseReport",label:"Staff-wise"},{key:"renewalStatisticsByDate",label:"Statistics by Date"}];function ax({token:t}){const a=t??localStorage.getItem("authToken")??"",[n,r]=i.useState("renewalHistory"),[o,l]=i.useState("This Month"),[d,c]=i.useState(""),[h,f]=i.useState(""),[p,m]=i.useState(7),[v,S]=i.useState(1),[y,g]=i.useState(20),[b,D]=i.useState(""),[R,I]=i.useState("DESC"),A=i.useRef(null),_=U=>{const Y=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(n)&&(Y.set("date_range",o),o==="Custom"&&d&&h&&(Y.set("from_date",d),Y.set("to_date",h))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(n)&&(Y.set("page",String(v)),Y.set("per_page",String(y))),n==="upcomingRenewalDue"&&Y.set("days_ahead",String(p)),b&&Y.set("sort_by",b),R&&Y.set("sort_dir",R),`${U}?${Y.toString()}`},u=i.useMemo(()=>{switch(n){case"renewalHistory":return _(Vh);case"renewalFineReport":return _(Hh);case"currentlyRenewedBooks":return _(Kh);case"upcomingRenewalDue":return _(Gh);case"overdueRenewalReport":return _(Jh);case"renewalLimitReport":return _(Qh);case"renewalStatusReport":return _(Xh);case"studentWiseReport":return _(Zh);case"bookWiseReport":return _(ef);case"classWiseReport":return _(tf);case"staffWiseReport":return _(af);case"renewalStatisticsByDate":return _(nf);default:return null}},[n,o,d,h,p,v,y]),{data:x,isLoading:j}=q(a?[u,a]:null,([U,Y])=>W(U,Y)),P=x?.data||{},O=P?.rows||[],z=P?.pagination||{},k=U=>{r(U),S(1),g(20)},F=()=>{S(1)},C=()=>{switch(n){case"renewalHistory":case"renewalFineReport":return[{title:"Renewal ID",dataIndex:"renewal_id",key:"renewal_id"},{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Renewal No",dataIndex:"renewal_no",key:"renewal_no"},{title:"Old Due Date",dataIndex:"old_due_date",key:"old_due_date"},{title:"New Due Date",dataIndex:"new_due_date",key:"new_due_date"},{title:"Renewal Date",dataIndex:"renewal_date",key:"renewal_date"},{title:"Status",dataIndex:"status",key:"status",render:U=>e.jsx(s.Tag,{color:U==="renewed"?"green":"red",children:U})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:U=>U??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:U=>U??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:U=>U??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:U=>U?e.jsx(s.Tag,{color:U==="paid"?"green":U==="partial"?"orange":"red",children:U}):"-"}];case"currentlyRenewedBooks":case"upcomingRenewalDue":case"overdueRenewalReport":case"renewalLimitReport":case"renewalStatusReport":return[{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Due Date",dataIndex:"return_date",key:"return_date"},{title:"Renewal Count",dataIndex:"renewal_count",key:"renewal_count"},{title:"Max Renewal",dataIndex:"maximum_renewal",key:"maximum_renewal"},{title:"Days Remaining",dataIndex:"days_remaining",key:"days_remaining",render:U=>U??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:U=>U??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:U=>U??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:U=>U??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:U=>e.jsx(s.Tag,{color:U?"green":"red",children:U?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:U=>Array.isArray(U)?U.join("; "):"-"}];case"studentWiseReport":return[{title:"Student ID",dataIndex:"student_id",key:"student_id"},{title:"Student Name",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Books",dataIndex:"unique_books_renewed",key:"unique_books_renewed"},{title:"First Renewal",dataIndex:"first_renewal_date",key:"first_renewal_date"},{title:"Last Renewal",dataIndex:"last_renewal_date",key:"last_renewal_date"}];case"bookWiseReport":return[{title:"Book ID",dataIndex:"book_id",key:"book_id"},{title:"Title",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Category",dataIndex:"category",key:"category"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"classWiseReport":return[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"staffWiseReport":return[{title:"Staff",dataIndex:"renewed_by",key:"renewed_by"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];case"renewalStatisticsByDate":return[{title:"Period",dataIndex:"period",key:"period"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];default:return[]}},E=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(n),M=i.useMemo(()=>C(),[n]);return e.jsx(w,{pt:5,pb:1,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,padding:"4px 8px",color:"#fff",display:"inline-block"}}),e.jsxs(w,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],mb:3,children:[E&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(ae,{options:Ql,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:Ql.find(U=>U.value===o)||null,onChange:U=>l(U?.value||"This Month")})}),o==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(Ge,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:U=>c(U?U.format("YYYY-MM-DD"):"")})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(Ge,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:U=>f(U?U.format("YYYY-MM-DD"):"")})})]})]}),n==="upcomingRenewalDue"&&e.jsx(s.Col,{xs:24,md:6,children:e.jsx(ae,{options:[{label:"7 Days",value:7},{label:"14 Days",value:14},{label:"30 Days",value:30}],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Days Ahead",allowSelectAll:!1,value:{label:p+" Days",value:p},onChange:U=>m(U?.value||7)})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:F})})})]}),e.jsx(s.Tabs,{activeKey:n,onChange:k,items:Xl})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:Xl.find(U=>U.key===n)?.label||"Report"})}),e.jsxs(w,{p:3,children:[e.jsx(Jt,{data:{tableRef:A}}),j?e.jsx(w,{py:8,textAlign:"center",children:e.jsx(s.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(s.Table,{size:"small",dataSource:O,columns:M,loading:j,pagination:!1,bordered:!0,rowKey:U=>U.renewal_id||U.id||JSON.stringify(U),ref:A}),O.length>0&&e.jsx(s.Pagination,{current:v,pageSize:y,total:z.total_rows||O.length,onChange:(U,Y)=>{S(U),g(Y)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const Br=t=>t??localStorage.getItem("authToken")??"",nx=(t,a)=>{const n=String(t??""),r=String(a);return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},mt={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"}},sx=()=>nx(Nt(),mt.upload),rx=async({baseUrl:t,page:a=1,perPage:n=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(n))}`;return W(l,Br(r))},fs=async(t,a,n)=>Ze(t,a,Br(n)),Tn=async(t,a,n)=>ct(t,a,Br(n)),gs=async(t,a,n)=>st(t,a,Br(n)),ix=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Sn=({token:t,value:a,onChange:n})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:sx(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=ix(o?.file?.response);l&&n?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},er=mt.vendor,ys=({baseUrl:t,page:a=1,perPage:n=10,token:r})=>q(r&&t?[t,a,n,r]:null,([l,d,c,h])=>rx({baseUrl:l,page:d,perPage:c},h)),ox=({token:t,page:a=1,perPage:n=10})=>ys({baseUrl:er.list,page:a,perPage:n,token:t}),lx={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Zl=[{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 dx({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,h]=i.useState(""),{isLoading:f,error:p,data:m,mutate:v}=ox({token:t,page:a.page,perPage:a.rowsPerPage}),S=async A=>{try{await v(fs(er.add,A,t),pt(A)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(_){T.error(_?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},y=A=>{A.preventDefault();const _=new FormData(A.target);c&&_.set("image",c),S(_),A.target.reset(),h("")},g=(A,_)=>{n({page:A,rowsPerPage:parseInt(_,10)})},b=async A=>{try{await v(gs(er.remove,A,t),ot(A)),T.success("Success! Deleted item.",{duration:1e3})}catch(_){T.error(_?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=A=>{d(A),o(!0),h("")},R=async A=>{A.preventDefault();const _=new FormData(A.target);_.set("id",String(l?.id??"")),c&&_.set("image",c);try{await Tn(er.edit,_,t),await v(),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),h("")}catch(u){T.error(u?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},I=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,_)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>D(_),style:{padding:2}}),e.jsx(At,{id:_?.id,funcName:b})]})}],[b]);return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),h("")},children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[Zl.map(A=>e.jsx(G,{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(Sn,{token:t,value:c,onChange:h})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),h("")},style:lx,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[Zl.map(A=>e.jsx(G,{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(Sn,{token:t,value:c,onChange:h})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:g,data:{newData:m,columns:I,columnstype:"antd",action:!1,Loading:f,error:p}})})]})]})]})}const cx=({token:t})=>e.jsx(dx,{token:t}),tr=mt.product,ed=mt.vendor.dropdown,td=mt.category.dropdown,ux=mt.subCategory.dropdown,ad=mt.unit.dropdown,hu=({token:t,page:a=1,perPage:n=10})=>ys({baseUrl:tr.list,page:a,perPage:n,token:t}),px=({token:t})=>q(t&&ed?[ed,t]:null,([n,r])=>W(n,r)),mx=({token:t})=>q(t&&td?[td,t]:null,([n,r])=>W(n,r)),hx=({token:t})=>q(t&&ad?[ad,t]:null,([n,r])=>W(n,r)),fx=({token:t,categoryId:a})=>{const n=t&&a?`${ux}?category_id=${encodeURIComponent(String(a))}`:null;return q(n?[n,t]:null,([o,l])=>W(o,l))},Ls=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},gx={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function yx({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,h]=i.useState(""),[f,p]=i.useState(""),[m,v]=i.useState(""),[S,y]=i.useState(""),[g,b]=i.useState(""),{isLoading:D,error:R,data:I,mutate:A}=hu({token:t,page:a.page,perPage:a.rowsPerPage}),{data:_}=px({token:t}),{data:u}=mx({token:t}),{data:x}=hx({token:t}),{data:j}=fx({token:t,categoryId:f}),P=i.useMemo(()=>Ls(_),[_]),O=i.useMemo(()=>Ls(u),[u]),z=i.useMemo(()=>Ls(x),[x]),k=i.useMemo(()=>Ls(j),[j]),F=async L=>{try{await A(fs(tr.add,L,t),pt(L)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(B){T.error(B?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},C=L=>{L.preventDefault();const B=new FormData(L.target);f&&B.set("fk_categoryID",String(f)),m&&B.set("fk_sub_categoryID",String(m)),S&&B.set("vendor_id",String(S)),g&&B.set("unit",String(g)),c&&B.set("image",c),F(B),L.target.reset(),h(""),p(""),v(""),y(""),b("")},E=(L,B)=>{n({page:L,rowsPerPage:parseInt(B,10)})},M=async L=>{try{await A(gs(tr.remove,L,t),ot(L)),T.success("Success! Deleted item.",{duration:1e3})}catch(B){T.error(B?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},U=L=>{d(L),o(!0),h(""),p(L?.fk_categoryID??L?.category_id??""),v(L?.fk_sub_categoryID??L?.sub_category_id??""),y(L?.vendor_id??""),b(L?.unit??L?.unit_id??"")},Y=async L=>{L.preventDefault();const B=new FormData(L.target);B.set("id",String(l?.id??"")),f&&B.set("fk_categoryID",String(f)),m&&B.set("fk_sub_categoryID",String(m)),S&&B.set("vendor_id",String(S)),g&&B.set("unit",String(g)),c&&B.set("image",c);try{await Tn(tr.edit,B,t),await A(),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),h("")}catch($){T.error($?.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:(L,B)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>U(B),style:{padding:2}}),e.jsx(At,{id:B?.id,funcName:M})]})}],[M]);return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),h("")},children:e.jsx("form",{onSubmit:Y,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(G,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(ae,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:L=>{const B=L?.value??"";p(B),v("")},defaultValue:f?O.find(L=>String(L?.value)===String(f)):null}),e.jsx(ae,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:L=>v(L?.value??""),defaultValue:m?k.find(L=>String(L?.value)===String(m)):null}),e.jsx(G,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(ae,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:L=>b(L?.value??""),defaultValue:g?z.find(L=>String(L?.value)===String(g)):null}),e.jsx(G,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(G,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(ae,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:L=>y(L?.value??""),defaultValue:S?P.find(L=>String(L?.value)===String(S)):null}),e.jsx(G,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(kt,{type:"text",label:"Description",name:"description",rows:3,defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(Sn,{token:t,value:c,onChange:h})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),h("")},style:gx,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(G,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(ae,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:L=>{const B=L?.value??"";p(B),v("")}}),e.jsx(ae,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:L=>v(L?.value??"")},`subcat_${f}`),e.jsx(G,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(ae,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:L=>b(L?.value??"")}),e.jsx(G,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(G,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(ae,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:L=>y(L?.value??"")}),e.jsx(G,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(kt,{type:"text",label:"Description",name:"description",rows:3}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(Sn,{token:t,value:c,onChange:h})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:E,data:{newData:I,columns:V,columnstype:"antd",action:!1,Loading:D,error:R}})})]})]})]})}const xx=({token:t})=>e.jsx(yx,{token:t}),ar=mt.category,bx=({token:t,page:a=1,perPage:n=10})=>ys({baseUrl:ar.list,page:a,perPage:n,token:t}),jx={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Sx({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:h,data:f,mutate:p}=bx({token:t,page:a.page,perPage:a.rowsPerPage}),m=async R=>{try{await p(fs(ar.add,R,t),pt(R)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(I){T.error(I?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=R=>{R.preventDefault();const I=new FormData(R.target);m(I),R.target.reset()},S=(R,I)=>{n({page:R,rowsPerPage:parseInt(I,10)})},y=async R=>{try{await p(gs(ar.remove,R,t),ot(R)),T.success("Success! Deleted item.",{duration:1e3})}catch(I){T.error(I?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},g=R=>{d(R),o(!0)},b=async R=>{R.preventDefault();const I=new FormData(R.target);I.set("id",String(l?.id??""));try{await Tn(ar.edit,I,t),await p(),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(A){T.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,I)=>String(R?.name??"").localeCompare(String(I?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,I)=>String(R?.description??"").localeCompare(String(I?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,I)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>g(I),style:{padding:2}}),e.jsx(At,{id:I?.id,funcName:y})]})}],[y]);return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(G,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(G,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:jx,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(G,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(G,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:S,data:{newData:f,columns:D,columnstype:"antd",action:!1,Loading:c,error:h}})})]})]})]})}const wx=({token:t})=>e.jsx(Sx,{token:t}),nr=mt.subCategory,nd=mt.category.dropdown,vx=({token:t,page:a=1,perPage:n=10})=>ys({baseUrl:nr.list,page:a,perPage:n,token:t}),Cx=({token:t})=>q(t&&nd?[nd,t]:null,([n,r])=>W(n,r)),_x=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},Ax={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Tx({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,h]=i.useState(""),{isLoading:f,error:p,data:m,mutate:v}=vx({token:t,page:a.page,perPage:a.rowsPerPage}),{data:S}=Cx({token:t}),y=i.useMemo(()=>_x(S),[S]),g=async u=>{try{await v(fs(nr.add,u,t),pt(u)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(x){T.error(x?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},b=u=>{u.preventDefault();const x=new FormData(u.target);x.set("status","active"),x.set("img",c||""),g(x),u.target.reset(),h("")},D=(u,x)=>{n({page:u,rowsPerPage:parseInt(x,10)})},R=async u=>{try{await v(gs(nr.remove,u,t),ot(u)),T.success("Success! Deleted item.",{duration:1e3})}catch(x){T.error(x?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},I=u=>{d(u),o(!0)},A=async u=>{u.preventDefault();const x=new FormData(u.target);x.set("id",String(l?.id??"")),c&&x.set("img",c);try{await Tn(nr.edit,x,t),await v(),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),h("")}catch(j){T.error(j?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},_=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(u,x)=>String(u?.name??"").localeCompare(String(x?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(u,x)=>String(u?.description??"").localeCompare(String(x?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(u,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>I(x),style:{padding:2}}),e.jsx(At,{id:x?.id,funcName:R})]})}],[R]);return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),h("")},children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(ae,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?y.find(u=>String(u?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(G,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(G,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(Sn,{token:t,value:c,onChange:h})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),h("")},style:Ax,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(G,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(G,{type:"text",name:"description",label:"Description"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(Sn,{token:t,value:c,onChange:h})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:D,data:{newData:m,columns:_,columnstype:"antd",action:!1,Loading:f,error:p}})})]})]})]})}const Dx=({token:t})=>e.jsx(Tx,{token:t}),vi=mt.product,kx=mt.academy.classes,Rx=mt.academy.sections,Ix=mt.student.dropdown;function zn(t){const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]}function Us(t,a){const n=Math.trunc(Number(t)||1),r=Math.max(1,n);return!Number.isFinite(Number(a))||Number(a)<=0?r:Math.min(r,Math.trunc(Number(a)))}function Et(t){return String(t??"")}function Px({token:t}){const[a,n]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,h]=i.useState(!1),[f,p]=i.useState(""),[m,v]=i.useState([]),[S,y]=i.useState({}),[g,b]=i.useState({}),[D,R]=i.useState(!1),[I,A]=i.useState(""),[_,u]=i.useState(0),[x,j]=i.useState(""),[P,O]=i.useState(ne()),[z,k]=i.useState([]),F={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},C=!!(a&&r&&l),{data:E}=q(t?[kx,t]:null,([we,ke])=>W(we,ke)),M=i.useMemo(()=>zn(E),[E]),U=t&&a?`${Rx}?class_id=${encodeURIComponent(String(a))}`:null,{data:Y}=q(U?[U,t]:null,([we,ke])=>W(we,ke)),V=i.useMemo(()=>zn(Y),[Y]),L=t&&a&&r?`${Ix}?class=${encodeURIComponent(String(a))}§ion=${encodeURIComponent(String(r))}`:null,{data:B}=q(L?[L,t]:null,([we,ke])=>W(we,ke)),$=i.useMemo(()=>zn(B),[B]),N=C?`${vi.list}?page=1&per_page=10000`:null,{data:H,isLoading:Q}=q(t&&N?[N,t]:null,([we,ke])=>W(we,ke),{revalidateOnFocus:!1}),X=i.useMemo(()=>zn(H),[H]),J=i.useMemo(()=>{const we=new Map;return(Array.isArray(X)?X:[]).forEach(ke=>{we.set(Et(ke?.id),ke)}),we},[X]),K=i.useMemo(()=>{const we=Object.entries(g||{});return we.length===0?[]:we.map(([ke,Te])=>{const ce=J.get(Et(ke));return ce?{id:ce?.id,name:ce?.name,barcode:ce?.barcode,stock:Number(ce?.quantity||0),price:Number(ce?.price||0),quantity:Us(Te,Number(ce?.quantity||0))}:null}).filter(Boolean)},[g,J]),Z=i.useMemo(()=>new Set(K.map(we=>Et(we?.id))),[K]),ee=i.useMemo(()=>(Array.isArray(K)?K:[]).reduce((ke,Te)=>ke+Number(Te?.price||0)*Number(Te?.quantity||1),0),[K]),pe=i.useMemo(()=>{const we=Number(_||0);return!Number.isFinite(we)||we<=0?0:Math.min(we,ee)},[_,ee]),te=i.useMemo(()=>Math.max(0,ee-pe),[pe,ee]),se=i.useMemo(()=>(Array.isArray(X)?X:[]).slice(0,30).map(we=>({value:Et(we?.id),label:`${we?.name??""}${we?.barcode?` • ${we.barcode}`:""}${we?.quantity!==void 0&&we?.quantity!==null?` • Stock: ${we.quantity}`:""}`,product:we})),[X]),{trigger:le}=it(t&&C?vi.search:null,(we,{arg:ke})=>Ta(we,{arg:ke},t));i.useEffect(()=>{if(!C){v([]);return}const we=String(f||"").trim();if(we.length<2){v(se);return}let ke=!0;const Te=setTimeout(async()=>{let ce=[];try{if(le){const _e=await le({search:we});ce=zn(_e)}}catch{ce=[]}if(!Array.isArray(ce)||ce.length===0){const _e=we.toLowerCase();ce=(Array.isArray(X)?X:[]).filter(Ve=>{const He=String(Ve?.name??"").toLowerCase(),je=String(Ve?.barcode??"").toLowerCase();return He.includes(_e)||je.includes(_e)}).slice(0,30)}const ve=ce.slice(0,30).map(_e=>({value:Et(_e?.id),label:`${_e?.name??""}${_e?.barcode?` • ${_e.barcode}`:""}${_e?.quantity!==void 0&&_e?.quantity!==null?` • Stock: ${_e.quantity}`:""}`,product:_e}));ke&&v(ve)},250);return()=>{ke=!1,clearTimeout(Te)}},[se,C,le,X,f]),i.useEffect(()=>{b({}),y({}),p(""),v([]),R(!1),A(""),u(0),j(""),O(ne()),k([])},[a,r,l]);const Ce=i.useCallback((we,ke=1)=>{const Te=we?.id;if(!Te)return;const ce=Number(we?.quantity||0);if(ce<=0){T.error("Out of stock.",{duration:1e3});return}const ve=Us(ke,ce);b(_e=>{const Ve=_e||{};return Object.prototype.hasOwnProperty.call(Ve,Et(Te))?(T.error("Product already added.",{duration:1e3}),Ve):{...Ve,[Et(Te)]:ve}})},[b]),Le=i.useCallback((we,ke,Te)=>{b(ce=>{const ve=ce||{},_e=Et(we);return Object.prototype.hasOwnProperty.call(ve,_e)?{...ve,[_e]:Us(ke,Te)}:ve})},[]),Re=i.useCallback(we=>{b(ke=>{const Te=ke||{},ce=Et(we);if(!Object.prototype.hasOwnProperty.call(Te,ce))return Te;const ve={...Te};return delete ve[ce],ve})},[]),xe=i.useCallback((we,ke,Te)=>{y(ce=>({...ce||{},[Et(we)]:Us(ke,Te)}))},[]),De=i.useCallback((we,ke)=>{ke?.product&&Ce(ke.product,1),p(""),v(se)},[Ce,se]),Ue=i.useCallback(we=>{if(we.key!=="Enter")return;we.preventDefault();const ke=Array.isArray(m)&&m.length>0?m[0]:null;if(ke?.product){Ce(ke.product,1),p(""),v(se);return}const Te=String(f||"").trim().toLowerCase();if(Te.length===0)return;const ce=(Array.isArray(X)?X:[]).find(ve=>{const _e=String(ve?.name??"").toLowerCase(),Ve=String(ve?.barcode??"").toLowerCase();return _e.includes(Te)||Ve.includes(Te)});ce&&(Ce(ce,1),p(""),v(se))},[Ce,se,X,m,f]),ye=()=>{if(!t){T.error("Missing token.",{duration:1e3});return}if(!a){T.error("Select class.",{duration:1e3});return}if(!r){T.error("Select section.",{duration:1e3});return}if(!l){T.error("Select student.",{duration:1e3});return}if(!K||K.length===0){T.error("Add at least one product.",{duration:1e3});return}R(!0)},{trigger:me,isMutating:Pe}=it(t?vi.sellProduct:null,(we,{arg:ke})=>hs(we,{arg:ke},t)),Ye=async()=>{if(!I){T.error("Select payment type.",{duration:1e3});return}const we=(Array.isArray(K)?K:[]).map(Te=>({id:Te?.id,quantity:Number(Te?.quantity||1),price:Number(Te?.price||0),total_price:Number(Te?.total_price||0),fk_vendor_id:Te?.fk_vendor_id||"",fk_categoryID:Te?.fk_categoryID||"",name:Te?.name||"",class_id:Te?.class_id||"",fk_sub_categoryID:Te?.fk_sub_categoryID||"",description:Te?.description||"",min_quantity:Number(Te?.min_quantity||0),storecategory:Number(Te?.storecategory||0),barcode:Te?.barcode||""})),ke={amount:ee,class:a,section:r,student_id:l,payment_type:I,discount:pe,notes:x||"",receipt_date:P?ne(P).format("YYYY-MM-DD"):"",product:JSON.stringify(we),total_payable_amount:ee,attchement:z[0]?.originFileObj||""};try{const ce=Array.isArray(z)&&z.length>0&&z[0]?.originFileObj?(()=>{const _e=new FormData;return Object.entries(ke).forEach(([Ve,He])=>{if(Ve==="products"){_e.append("product",JSON.stringify(He));return}_e.append(Ve,String(He??""))}),_e.append("attachment",z[0].originFileObj),_e})():ke,ve=await me(ce);ve?.Status==="Success"?(T.success("Success! Product sold.",{duration:1e3}),R(!1),b({}),y({}),p(""),v(se),A(""),u(0),j(""),O(ne()),k([])):T.error(ve?.msg??"Failed to submit.",{duration:1e3})}catch{T.error("Failed to submit.",{duration:1e3})}},ze=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:(we,ke)=>{const Te=Et(ke?.id),ce=Number(ke?.quantity||0),ve=Z.has(Te),_e=(ve?g?.[Te]:S?.[Te])??1;return e.jsx(s.InputNumber,{min:1,max:Number.isFinite(ce)&&ce>0?ce:void 0,value:_e,onChange:Ve=>{ve?Le(Te,Ve,ce):xe(Te,Ve,ce)},disabled:ce<=0})}},{title:"Amount",key:"amount",width:140,render:(we,ke)=>{const Te=Et(ke?.id),ce=(Z.has(Te)?g?.[Te]:S?.[Te])??1;return Number(ke?.price||0)*Number(ce||1)}},{title:"Action",key:"action",width:120,render:(we,ke)=>{const Te=Et(ke?.id),ce=Number(ke?.quantity||0),ve=Z.has(Te),_e=(ve?g?.[Te]:S?.[Te])??1;return ve?e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(re.DeleteOutlined,{}),onClick:()=>Re(Te),style:{padding:2}}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.PlusOutlined,{}),disabled:ce<=0,onClick:()=>Ce(ke,_e),style:{padding:2}})}}],[Ce,Z,g,S,Re,xe,Le]);return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(w,{pt:5,pb:2,children:[e.jsxs(w,{style:{padding:"12px 16px"},children:[e.jsx(w,{children:"Sell Product"}),e.jsx(s.Card,{style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ae,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:we=>{const ke=we?.value??"";n(ke),o(""),d(""),h(Te=>!Te)}}),e.jsx(ae,{options:V,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:we=>{const ke=we?.value??"";o(ke),d("")}},`section_${c}`),e.jsx(ae,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:we=>d(we?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(s.Card,{style:{borderRadius:16,marginTop:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(260px, 520px) 1fr",gap:12,alignItems:"center",marginBottom:12},children:[e.jsx(w,{style:{marginTop:12},children:"Product Section"}),e.jsx(s.AutoComplete,{value:f,options:m,onSearch:p,onFocus:()=>{C&&String(f||"").trim().length<2&&v(se)},onSelect:De,disabled:!C,children:e.jsx(s.Input,{placeholder:"Search by product name or barcode",onKeyDown:Ue,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",ra(ee)]})]}),e.jsx(s.Table,{rowKey:we=>Et(we?.id),columns:ze,dataSource:X,loading:Q,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:K.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:ra(ee)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(de,{type:"button",value:"Submit",disabled:!C||K.length===0,onClick:ye,style:{flex:1,minWidth:140}}),e.jsx(s.Button,{type:"text",style:F,onClick:()=>{b({}),y({}),p(""),v(se)},disabled:K.length===0,children:"Clear"})]})]})]})})]}),e.jsx(s.Modal,{open:D,title:"Payment",onCancel:()=>R(!1),onOk:Ye,confirmLoading:Pe,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(s.Select,{value:I||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(s.DatePicker,{value:P,onChange:we=>O(we),style:{width:"100%"},format:"YYYY-MM-DD"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Discount"}),e.jsx(s.InputNumber,{min:0,max:ee,value:_,onChange:we=>u(Number(we||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(s.Upload,{fileList:z,beforeUpload:()=>!1,onChange:({fileList:we})=>k((we||[]).slice(-1)),maxCount:1,children:e.jsx(s.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(s.Input.TextArea,{value:x,onChange:we=>j(we.target.value),rows:3})]}),e.jsx(s.Card,{style:{borderRadius:12,background:"#fafcff"},children:e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:ra(ee)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:ra(pe)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:ra(te)})]})]})})]})})]})}const Mx=({token:t})=>e.jsx(Px,{token:t}),sr=mt.unit,Ex=({token:t,page:a=1,perPage:n=10})=>ys({baseUrl:sr.list,page:a,perPage:n,token:t}),Ox={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function $x({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:h,data:f,mutate:p}=Ex({token:t,page:a.page,perPage:a.rowsPerPage}),m=async R=>{try{await p(fs(sr.add,R,t),pt(R)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(I){T.error(I?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=R=>{R.preventDefault();const I=new FormData(R.target);m(I),R.target.reset()},S=(R,I)=>{n({page:R,rowsPerPage:parseInt(I,10)})},y=async R=>{try{await p(gs(sr.remove,R,t),ot(R)),T.success("Success! Deleted item.",{duration:1e3})}catch(I){T.error(I?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},g=R=>{d(R),o(!0)},b=async R=>{R.preventDefault();const I=new FormData(R.target);I.set("id",String(l?.id??""));try{await Tn(sr.edit,I,t),await p(),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(A){T.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,I)=>String(R?.name??"").localeCompare(String(I?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,I)=>String(R?.description??"").localeCompare(String(I?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,I)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>g(I),style:{padding:2}}),e.jsx(At,{id:I?.id,funcName:y})]})}],[y]);return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(G,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(G,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Ox,children:"Cancel"})]})]})})}),e.jsxs(w,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(w,{px:3,pb:2,children:e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(G,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(G,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:S,data:{newData:f,columns:D,columnstype:"antd",action:!1,Loading:c,error:h}})})]})]})]})}const Fx=({token:t})=>e.jsx($x,{token:t}),Bx=mt.product.sellReports,Lx=mt.academy.classes,Ux=mt.academy.sections,Nx=mt.student.dropdown,sd=t=>{const a=Number(t??0);return Number.isFinite(a)?a.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function zx({token:t}){const a=i.useRef(null),[n,r]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[h,f]=i.useState(""),[p,m]=i.useState(!1),v=k=>{const F=k?.data?.data??k?.data??k??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},{data:S}=q(t?[Lx,t]:null,([k,F])=>W(k,F)),y=i.useMemo(()=>v(S),[S]),g=t&&o?`${Ux}?class_id=${encodeURIComponent(String(o))}`:null,{data:b}=q(g?[g,t]:null,([k,F])=>W(k,F)),D=i.useMemo(()=>v(b),[b]),R=t&&o&&d?`${Nx}?class=${encodeURIComponent(String(o))}§ion=${encodeURIComponent(String(d))}`:null,{data:I}=q(R?[R,t]:null,([k,F])=>W(k,F)),A=i.useMemo(()=>v(I),[I]),{trigger:_,isMutating:u,data:x}=it(Bx,(k,{arg:F})=>co(k,{arg:F},t));i.useEffect(()=>{const F=new Date().toISOString().slice(0,10);_({duration:[F,F]})},[_]);const j=i.useMemo(()=>{const k=x?.data??x??[];return Array.isArray(k)?k:[]},[x]),P=k=>{const F=Array.isArray(k?.product_details)?k.product_details:[];return F.length===0?null:e.jsx(s.Table,{size:"small",bordered:!0,pagination:!1,rowKey:C=>`${k?.receipt_id??"r"}_${C?.product_name??C?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:C=>sd(C)}],dataSource:F})},O=[{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:k=>sd(k)}],z=async()=>{if(!n||n.length!==2)return;const[k,F]=n;await _({duration:[k.format("YYYY-MM-DD"),F.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:h||""})};return e.jsx("div",{children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,lg:8,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Filters"}),style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Duration"}),e.jsx(s.DatePicker.RangePicker,{value:n,onChange:r,style:{width:"100%"}})]}),e.jsx(ae,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:k=>{const F=k?.value??"";l(F),c(""),f(""),m(C=>!C)}}),e.jsx(ae,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:k=>{const F=k?.value??"";c(F),f("")}},`section_${p}`),e.jsx(ae,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:k=>f(k?.value??"")}),e.jsx(de,{type:"button",value:u?"Searching...":"Search",disabled:u,onClick:z,style:{width:"100%"}})]})})}),e.jsx(s.Col,{xs:24,lg:16,children:e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(Jt,{data:{tableRef:a}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(da,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:u,rowKey:k=>String(k?.receipt_id??k?.receipt_no??Math.random()),columns:O,expandable:{expandedRowRender:P},dataSource:j,pagination:{pageSize:20}})]})})})]})})}const qx=({token:t})=>e.jsx(zx,{token:t}),Yx=mt.product;function Wx({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState([]),[l,d]=i.useState([]),[c,h]=i.useState(!1),[f,p]=i.useState(!1),[m,v]=i.useState(null),[S,y]=i.useState(0),[g,b]=i.useState(null),[D,R]=i.useState(""),I=i.useRef(null),A=Ka.useReactToPrint({contentRef:I,documentTitle:"Stock Barcodes"}),{isLoading:_,error:u,data:x,mutate:j}=hu({token:t,page:a.page,perPage:a.rowsPerPage}),P=(E,M)=>{n({page:E,rowsPerPage:parseInt(M,10)})},O={selectedRowKeys:r,onChange:(E,M)=>{o(E),d(M)}},z=E=>{v(E),y(Number(E?.quantity??0)),b(null),R(""),h(!0)},k=()=>{h(!1),v(null),y(0),b(null),R("")},F=async()=>{if(!m?.id)return;p(!0);const E=new FormData;E.append("product_id",String(m.id)),E.append("qty",String(S??0)),g&&E.append("tran_date",g.format("YYYY-MM-DD")),D&&E.append("remarks",D);try{const M=await Tn(Yx.addStock,E,t);M?.Status==="Success"?(T.success("Success! Updated quantity.",{duration:1e3}),k(),await j()):T.error(M?.msg??"Failed to update quantity.",{duration:1e3})}catch{T.error("Failed to update quantity.",{duration:1e3})}finally{p(!1)}},C=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",width:100},{title:"Unit",dataIndex:"unit_name",key:"unit_name",width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["lg"]},{title:"Action",key:"action",width:160,fixed:"right",render:(E,M)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(s.Button,{size:"small",onClick:()=>z(M),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:m?.name?`Update Stock: ${m.name}`:"Update Stock",open:c,onCancel:k,onOk:F,okButtonProps:{loading:f},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(s.InputNumber,{min:0,style:{width:"100%"},value:S,onChange:E=>y(E??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{style:{width:"100%"},value:g,onChange:b})]}),e.jsx(kt,{label:"Remarks",name:"remarks",rows:3,value:D,onChange:E=>R(E.target.value)})]})}),e.jsxs(w,{pt:5,pb:2,children:[e.jsxs(w,{children:["Manage Stock",e.jsx(de,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>A?.(),style:{minWidth:170}})]}),e.jsx(w,{style:{padding:"12px 16px"},children:e.jsx(s.Card,{style:{borderRadius:16},children:e.jsx(Ke,{parentCallback:P,data:{newData:x,columns:C,columnstype:"antd",action:!1,Loading:_,error:u,rowSelection:O}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:I,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map(E=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:E?.name??""}),e.jsx(Sc,{value:String(E?.barcode??E?.id??""),height:50,width:1.6,displayValue:!0})]},E?.id??E?.barcode??E?.name))})})})]})}const Vx=({token:t})=>e.jsx(Wx,{token:t}),Hx=mt.report.stock,Kx=mt.product.dropdown,Gx=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Jx({token:t}){const a=i.useRef(null),[n,r]=i.useState(null),[o,l]=i.useState(""),{data:d}=q(t?[Kx,t]:null,([y,g])=>W(y,g)),c=i.useMemo(()=>Gx(d),[d]),{trigger:h,isMutating:f,data:p}=it(Hx,(y,{arg:g})=>co(y,{arg:g},t));i.useEffect(()=>{const g=new Date().toISOString().slice(0,10);h({duration:[g,g]})},[h]);const m=i.useMemo(()=>{const y=p?.data??p??[];return(Array.isArray(y)?y:[]).flatMap(b=>(Array.isArray(b?.ledger)?b.ledger:[]).map((D,R)=>({key:`${b.product_id??b.product_name??"p"}-${R}`,date:D?.date,product:b?.product_name,opening:D?.opening,inward:D?.inward,outward:D?.outward,closing:D?.closing})))},[p]),v=[{title:"Date",dataIndex:"date",key:"date"},{title:"Product",dataIndex:"product",key:"product"},{title:"Opening",dataIndex:"opening",key:"opening"},{title:"Inward",dataIndex:"inward",key:"inward"},{title:"Outward",dataIndex:"outward",key:"outward"},{title:"Closing",dataIndex:"closing",key:"closing",render:y=>e.jsx("span",{style:{color:Number(y)<0?"red":"green"},children:y})}],S=async()=>{if(!n||n.length!==2)return;const[y,g]=n;await h({duration:[y.format("YYYY-MM-DD"),g.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Stock Report"}),style:{borderRadius:16},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[e.jsx(s.DatePicker.RangePicker,{value:n,onChange:r}),e.jsxs("select",{value:o,onChange:y=>l(y.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(y=>e.jsx("option",{value:String(y?.value??""),children:String(y?.label??"")},String(y?.value??y?.id??y?.label)))]}),e.jsx(s.Button,{type:"primary",onClick:S,loading:f,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(Jt,{data:{tableRef:a}})})]}),e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(da,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:f,rowKey:"key",columns:v,dataSource:m,pagination:{pageSize:50}})]})]})}const Qx=({token:t})=>e.jsx(Jx,{token:t}),rd=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],pa={total_packages:124,total_downloads:45892,active_packages:118,deprecated_packages:6,pending_approval:3,published_this_month:12,published_this_week:4,packages_needing_update:8,packages_with_issues:2},id=[{npm_id:"NPM-001",package_name:"@ubk/erp-core",version:"1.2.1",description:"Core ERP utilities and shared types",author:"UBK Infotech",repository:"https://github.com/ubk/erp-core",license:"MIT",status:"published",created_at:"2024-01-15",updated_at:"2025-06-20"},{npm_id:"NPM-002",package_name:"@ubk/erp-components",version:"2.0.0",description:"Reusable Ant Design ERP component library",author:"UBK Infotech",repository:"https://github.com/ubk/erp-components",license:"ISC",status:"published",created_at:"2024-03-10",updated_at:"2025-08-01"},{npm_id:"NPM-003",package_name:"@ubk/erp-api-client",version:"0.9.5",description:"Axios-based API client for UBK ERP backends",author:"UBK Infotech",repository:"https://github.com/ubk/erp-api-client",license:"MIT",status:"draft",created_at:"2025-05-22",updated_at:"2025-07-14"},{npm_id:"NPM-004",package_name:"@ubk/erp-hooks",version:"1.1.0",description:"Custom React hooks for ERP workflows",author:"UBK Infotech",repository:"https://github.com/ubk/erp-hooks",license:"MIT",status:"published",created_at:"2024-08-05",updated_at:"2025-04-30"},{npm_id:"NPM-005",package_name:"@ubk/erp-utils",version:"3.2.1",description:"Utility functions for date, currency, and validation",author:"UBK Infotech",repository:"https://github.com/ubk/erp-utils",license:"ISC",status:"deprecated",created_at:"2023-11-20",updated_at:"2025-02-10"}],od=[{key:"dashboard",label:"Dashboard"},{key:"allPackages",label:"All Packages"},{key:"published",label:"Published"},{key:"draft",label:"Draft"},{key:"deprecated",label:"Deprecated"},{key:"pendingApproval",label:"Pending Approval"}];function Xx(){const[t,a]=i.useState("dashboard"),[n,r]=i.useState("This Month"),[o,l]=i.useState(""),[d,c]=i.useState(""),[h,f]=i.useState(1),[p,m]=i.useState(10),[v,S]=i.useState(""),y=i.useRef(null),g=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),b=i.useMemo(()=>{if(!v.trim())return id;const _=v.toLowerCase();return id.filter(u=>Object.values(u).some(x=>String(x??"").toLowerCase().includes(_)))},[v]),D=i.useMemo(()=>{const _=(h-1)*p;return b.slice(_,_+p)},[b,h,p]),R=()=>{f(1)},I=()=>{const _=[{title:"Total Packages",value:pa.total_packages,icon:e.jsx(re.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:pa.total_downloads.toLocaleString(),icon:e.jsx(re.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:pa.active_packages,icon:e.jsx(re.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:pa.deprecated_packages,icon:e.jsx(re.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:pa.pending_approval,icon:e.jsx(re.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:pa.published_this_month,icon:e.jsx(re.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:pa.published_this_week,icon:e.jsx(re.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:pa.packages_needing_update,icon:e.jsx(re.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:pa.packages_with_issues,icon:e.jsx(re.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(s.Row,{gutter:[16,16],children:_.map((u,x)=>e.jsx(s.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(s.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${u.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(w,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${u.color}15`,color:u.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:u.icon}),e.jsxs(w,{children:[e.jsx(s.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:u.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:u.value})]})]})},x))})},A=()=>{const _=[{title:"NPM ID",dataIndex:"npm_id",key:"npm_id",width:100},{title:"Package Name",dataIndex:"package_name",key:"package_name",ellipsis:!0},{title:"Version",dataIndex:"version",key:"version",width:100},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["md"]},{title:"Author",dataIndex:"author",key:"author",width:140,responsive:["lg"]},{title:"License",dataIndex:"license",key:"license",width:100},{title:"Status",dataIndex:"status",key:"status",width:120,render:u=>{let x="default";return u==="published"?x="green":u==="draft"?x="orange":u==="deprecated"?x="red":u==="pending"&&(x="blue"),e.jsx(s.Tag,{color:x,children:u.toUpperCase()})}},{title:"Created Date",dataIndex:"created_at",key:"created_at",width:120,responsive:["lg"]},{title:"Updated Date",dataIndex:"updated_at",key:"updated_at",width:120,responsive:["lg"]},{title:"Actions",key:"action",width:120,fixed:"right",render:(u,x)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:_};return e.jsx(w,{pt:5,pb:1,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(w,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],mb:3,children:[g&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(ae,{options:rd,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:rd.find(_=>_.value===n)||null,onChange:_=>r(_?.value||"This Month")})}),n==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(Ge,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:_=>l(_?_.format("YYYY-MM-DD"):"")})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(Ge,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:_=>c(_?_.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:R})})})]}),e.jsx(s.Tabs,{activeKey:t,onChange:a,items:od})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:od.find(_=>_.key===t)?.label||"Report"})}),e.jsxs(w,{p:3,children:[t!=="dashboard"&&e.jsx(Jt,{data:{tableRef:y}}),t==="dashboard"?I():e.jsx(s.Table,{size:"small",dataSource:D,columns:A(),loading:!1,pagination:!1,bordered:!0,rowKey:_=>_.npm_id||_.package_name||Math.random(),ref:y}),t!=="dashboard"&&b.length>0&&e.jsx(s.Pagination,{current:h,pageSize:p,total:b.length,onChange:(_,u)=>{f(_),m(u)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const Lr=t=>t??localStorage.getItem("authToken")??"",Zx=(t,a)=>{const n=String(t??""),r=String(a);return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},Je={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",roleDropdown:"api/Branch/getRoledropdownforBranch",staff:{list:"api/branchapi/staff/stafflist",searchByRole:"api/branchapi/staff/staffsearchbyRole",searchByKeywords:"api/branchapi/staff/staffsearchbyKeywords",deactivate:"api/branchapi/staff/staff_deactive",basicById:"api/branchapi/staff/getbasicdetailsbyID",experienceById:"api/branchapi/staff/getworkexperencebyID",payrollById:"api/branchapi/staff/getpayrollbyID",lastEmpNo:"api/branchapi/staff/getLastStaffEMPnumber",addBasic:"api/branchapi/staff/addstaffbasicdetails",editBasic:"api/branchapi/staff/editstaffbasicdetails",addExperience:"api/branchapi/staff/addstaffExperience",editExperience:"api/branchapi/staff/editstaffExperience",addPayroll:"api/branchapi/staff/addstaffpayroll",editPayroll:"api/branchapi/staff/editstaffpayroll",uploadProfile:"api/branchapi/staff/uploadstaffProfilepicture",uploadDocuments:"api/branchapi/staff/uploadDocuments"},master:{shift:{dropdown:"api/branchapi/generalSettings/shiftDropdown",table:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/editshift",remove:"api/branchapi/generalSettings/deleteshift",show:"api/branchapi/generalSettings/shiftShowdata"},department:{dropdown:"api/branchapi/humanResource/departmentDropdown",table:"api/branchapi/humanResource/departmenttypeTable",add:"api/branchapi/humanResource/adddepartment",edit:"api/branchapi/humanResource/editdepartment",remove:"api/branchapi/humanResource/deletedepartment",show:"api/branchapi/humanResource/departmentShowdata"},designation:{dropdown:"api/branchapi/humanResource/designationDropdown",table:"api/branchapi/humanResource/designationTable",add:"api/branchapi/humanResource/adddesignation",edit:"api/branchapi/humanResource/editdesignation",remove:"api/branchapi/humanResource/deletedesignation",show:"api/branchapi/humanResource/designationShowdata"},leaveType:{dropdown:"api/branchapi/humanResource/leavetypeDropdown",table:"api/branchapi/humanResource/LeavetypeTable",add:"api/branchapi/humanResource/addleavetype",edit:"api/branchapi/humanResource/editleavetype",remove:"api/branchapi/humanResource/deleteleavetype",show:"api/branchapi/humanResource/leavetypeShowdata"}},leave:{table:"api/branchapi/humanResource/LeaveTable",apply:"api/branchapi/humanResource/applyLeave",requestTable:"api/branchapi/humanResource/leaverequestTable",approveRequest:"api/branchapi/humanResource/approveleaveRequest"},attendance:{staffListForAttendance:"api/staff/attendence/stafflistforAttendence",staffDropdownByRole:"api/staff/attendence/getStaffDropDownByRoleId",addAttendanceToStaffByBranch:"api/staff/attendence/addattendencetoStaffbyBranch",manualAttendance:"api/staff/attendence/staffMenualAttendance",staffShiftByStaffId:"api/branchapi/staff/getStaffShiftByStaffId",dailyAttendance:"api/staff_attendance/attendance/report/daily",dailyAttendanceMultipleShift:"api/staff/attendence/dailyAttendanceMultipleShift"},attendanceReport:{monthlyStaffReport:"api/AttendenceReport/staffmonthlyAttendenceReport_new",staffAttendanceList:"api/AttendenceReport/staffAttendanceList",overallStaffReport:"api/staff/attendence/getAlloverAttendenceReportofStaff"},payroll:{monthlyGraph:"api/branchapi/reportGraph/monthlyPayroleReportgraph",staffPayrollByStaffId:"api/branchapi/humanResource/getStaffPayroleByStaffID",generatePayslip:"api/branchapi/humanResource/generatePayslip",payrollByRole:"api/branchapi/humanResource/getpayrolebyRole",monthlyReport:"api/branchapi/humanResource/monthlyPayRolereport"}},fu=()=>Zx(Nt(),Je.upload),eb=async({baseUrl:t,page:a=1,perPage:n=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(n))}`;return W(l,Lr(r))},ca=async(t,a,n)=>Ze(t,a,Lr(n)),Pa=async(t,a,n)=>ct(t,a,Lr(n)),xs=async(t,a,n)=>st(t,a,Lr(n)),Ya=Je.staff,tb=Je.master.shift.dropdown,ab=Je.master.department.dropdown,nb=Je.master.designation.dropdown,sb=Je.roleDropdown,rb=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},gu=t=>{const a=ya(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},ib=(t,a)=>{const n=`${t||""}`.trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;const r=gu(a),o=n.startsWith("/")?n.slice(1):n;return rb(ut(),`uploads/school_${r}/staff/Profile_picture/${o}`)},ob=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:"),rr=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},lb=t=>rr(t).map(n=>{if(n?.value!==void 0&&n?.label!==void 0)return{...n,value:String(n.value),label:String(n.label)};const r=String(n?.shift_id??n?.id??n?.value??""),o=String(n?.shift_name??n?.label??n?.name??n?.title??r);return{...n,value:r,label:o}}),db=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",qn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ld=[{value:"A+",label:"A+"},{value:"A-",label:"A-"},{value:"B+",label:"B+"},{value:"B-",label:"B-"},{value:"O+",label:"O+"},{value:"O-",label:"O-"},{value:"AB+",label:"AB+"},{value:"AB-",label:"AB-"}],dd={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function cb({token:t,mode:a,staffId:n,initialValues:r,onSubmitted:o}){const[l,d]=i.useState(!1),c=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),h=String(c?.multiple_shift??"").toLowerCase()==="yes",[f,p]=i.useState(r?.roleValue??null),[m,v]=i.useState(r?.departmentValue??null),[S,y]=i.useState(r?.designationValue??null),[g,b]=i.useState(r?.genderValue??null),[D,R]=i.useState(r?.shiftValue??(h?[]:null)),[I,A]=i.useState(r?.dob?ne(r.dob):null),[_,u]=i.useState(r?.doj?ne(r.doj):null),[x,j]=i.useState(r?.file??""),[P,O]=i.useState(r?.bloodGroup??"");i.useEffect(()=>{r&&(p(r?.roleValue??null),v(r?.departmentValue??null),y(r?.designationValue??null),b(r?.genderValue??null),R(r?.shiftValue??(h?[]:null)),A(r?.dob?ne(r.dob):null),u(r?.doj?ne(r.doj):null),j(r?.file??""),O(r?.bloodGroup??""))},[r,h]);const{data:z}=q(t?[tb,t]:null,([$,N])=>W($,N)),{data:k}=q(t?[ab,t]:null,([$,N])=>W($,N)),{data:F}=q(t?[nb,t]:null,([$,N])=>W($,N)),{data:C}=q(t?[sb,t]:null,([$,N])=>W($,N)),{data:E}=q(t?[Ya.lastEmpNo,t]:null,([$,N])=>W($,N)),M=i.useMemo(()=>lb(z),[z]),U=i.useMemo(()=>rr(k),[k]),Y=i.useMemo(()=>rr(F),[F]),V=i.useMemo(()=>rr(C),[C]),L=i.useMemo(()=>{const $=E?.data?.emp_number??E?.emp_number??E?.data??"";return String($??"")},[E]),B=async $=>{$.preventDefault(),d(!0);const N=new FormData($.target);N.set("role",f?.value??f??""),N.set("department",m?.value??m??""),N.set("designation",S?.value??S??""),N.set("gender",g?.value??g??""),N.set("dob",I?I.format("YYYY-MM-DD"):""),N.set("doj",_?_.format("YYYY-MM-DD"):""),h?(N.delete("shift_id"),(Array.isArray(D)?D:[]).forEach(Q=>{N.append("shift_id[]",Q?.value??Q??"")})):N.set("shift_id",D?.value??D??""),x&&N.set("file",x);try{const H=a==="edit"&&n,Q=H?Ya.editBasic:Ya.addBasic;H&&N.set("staff_id",String(n));const X=H?await Pa(Q,N,t):await ca(Q,N,t),J=X?.ID??X?.id??n??null;T.success("Success!",{duration:1e3}),o?.({staffId:J,basic:{roleValue:f,departmentValue:m,designationValue:S,genderValue:g,shiftValue:D,dob:I,doj:_,file:x}})}catch(H){T.error(H?.response?.data?.msg??H?.message??"Failed.",{duration:1e3})}finally{d(!1)}};return e.jsx("form",{onSubmit:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(G,{type:"number",name:"emp_number",label:"EMP No",defaultValue:r?.emp_number??L,required:!0}),e.jsx(G,{type:"text",name:"f_name",label:"First Name",defaultValue:r?.f_name??"",required:!0}),e.jsx(G,{type:"text",name:"l_name",label:"Last Name",defaultValue:r?.l_name??"",required:!0}),e.jsx(G,{type:"text",name:"pan_no",label:"PAN",defaultValue:r?.pan_no??"",pattern:"[A-Z]{5}[0-9]{4}[A-Z]",title:"Enter valid PAN (e.g., ABCDE1234D)"}),e.jsx(G,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??"",pattern:"[0-9]{12}",title:"Enter 12-digit Aadhaar number"}),e.jsx(ae,{label:"Role",options:V,value:f,onChange:$=>p($??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ae,{label:"Department",options:U,value:m,onChange:$=>v($??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ae,{label:"Designation",options:Y,value:S,onChange:$=>y($??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ae,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:g,onChange:$=>b($??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(G,{type:"email",name:"email",label:"Email",defaultValue:r?.email??"",title:"Enter a valid email address"}),e.jsxs("div",{children:[e.jsx("div",{style:qn,children:"DOB"}),e.jsx(s.DatePicker,{value:I,onChange:$=>A($),style:dd,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:qn,children:"DOJ"}),e.jsx(s.DatePicker,{value:_,onChange:$=>u($),style:dd,placeholder:"Select DOJ"})]}),e.jsxs("div",{children:[e.jsx(ae,{label:"Blood Group",options:ld,value:ld.find($=>$.value===P)??null,onChange:$=>O($?.value??""),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsx("input",{type:"hidden",name:"bloodGroup",value:P})]}),e.jsx(G,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0,pattern:"[0-9]{10}",title:"Enter 10-digit contact number"}),e.jsx(G,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:qn,children:"Shift"}),e.jsx(ae,{options:M,value:Array.isArray(D)&&h?M.filter($=>D.some(N=>String(N?.value??N)===String($?.value??$))):M.find($=>String(D?.value??D)===String($?.value??$))??(D&&!h?D:null),onChange:$=>R($??(h?[]:null)),isMulti:h,closeMenuOnSelect:!h,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:qn,children:"Profile Picture"}),e.jsxs("div",{style:{display:"grid",gap:8},children:[x?e.jsx("img",{src:ob(x)?x:ib(x,t),alt:"profile-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(s.Upload,{action:`${ut()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${gu(t)}/staff/Profile_picture`},headers:t?{Authorization:t}:void 0,maxCount:1,accept:"image/*",onChange:$=>{if($?.file?.status==="done"){const N=db($?.file?.response);N&&j(N)}$?.file?.status==="removed"&&j("")},children:e.jsx(s.Button,{type:"link",style:{paddingLeft:0},children:x?"Change":"Upload"})})]}),e.jsx("input",{type:"hidden",name:"file",value:x??""})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:qn,children:"Address"}),e.jsx("textarea",{name:"address",rows:3,defaultValue:r?.address??"",placeholder:"Address",style:{width:"100%",resize:"vertical",padding:10,border:"1px solid #d9d9d9",borderRadius:8,outline:"none"}})]}),e.jsx("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:l?"Saving...":"Save & Next",color:"primary",disabled:l,loading:l})})]})})}const ub=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},yu=t=>{const a=ya(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},pb=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:"),mb=(t,a)=>{const n=`${t||""}`.trim();if(!n)return"";if(pb(n))return n;const r=yu(a),o=n.startsWith("/")?n.slice(1):n;return ub(ut(),`uploads/school_${r}/staff/document/${o}`)},Ns={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},cd={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},hb=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ud=t=>{if(!t)return null;const a=ne(t);return a.isValid()?a:null};function fb({token:t,mode:a,staffId:n,initialRows:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(!1),[h,f]=i.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(b=>({name:b?.name??"",from:ud(b?.from_date??b?.from),to:ud(b?.to_date??b?.to),image:b?.image??""}))),p=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),m=(g,b)=>{f(D=>D.map((R,I)=>I===g?{...R,...b}:R))},v=()=>f(g=>[...g,{name:"",from:null,to:null,image:""}]),S=g=>f(b=>b.length<=1?b:b.filter((D,R)=>R!==g)),y=async g=>{if(g.preventDefault(),c(!0),!n){T.error("Missing staff id.",{duration:1e3}),c(!1);return}const b=new FormData;b.append("staff_id",String(n)),h.forEach((D,R)=>{b.append(`experience[${R}][name]`,String(D?.name??"")),b.append(`experience[${R}][from]`,D?.from?D.from.format("YYYY-MM-DD"):""),b.append(`experience[${R}][to]`,D?.to?D.to.format("YYYY-MM-DD"):""),b.append(`experience[${R}][image]`,String(D?.image??""))});try{const D=a==="edit",R=D?Ya.editExperience:Ya.addExperience,I=D?await Pa(R,b,t):await ca(R,b,t);T.success("Success!",{duration:1e3}),o?.({experience:h,result:I})}catch(D){T.error(D?.response?.data?.msg??D?.message??"Failed.",{duration:1e3})}finally{c(!1)}};return e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[h.map((g,b)=>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:Ns,children:"Name"}),e.jsx("input",{value:g.name,onChange:D=>m(b,{name:D.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:Ns,children:"From"}),e.jsx(s.DatePicker,{value:g.from,onChange:D=>m(b,{from:D}),style:cd})]}),e.jsxs("div",{children:[e.jsx("div",{style:Ns,children:"To"}),e.jsx(s.DatePicker,{value:g.to,onChange:D=>m(b,{to:D}),style:cd})]}),e.jsxs("div",{children:[e.jsx("div",{style:Ns,children:"Document"}),e.jsx(s.Upload,{maxCount:1,action:`${ut()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${yu(t)}/staff/document`},headers:p,onChange:D=>{if(D?.file?.status==="done"){const R=hb(D?.file?.response);R&&m(b,{image:R})}D?.file?.status==="removed"&&m(b,{image:""})},children:e.jsx(s.Button,{icon:e.jsx(re.UploadOutlined,{}),children:"Upload"})}),!!g.image&&e.jsx("a",{href:mb(g.image,t),target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"#1677ff",textDecoration:"underline",cursor:"pointer"},children:"View document"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(s.Button,{type:"text",icon:e.jsx(re.DeleteOutlined,{}),danger:!0,onClick:()=>S(b),disabled:h.length<=1})})]},`exp-${b}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(s.Button,{icon:e.jsx(re.PlusOutlined,{}),onClick:v,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(s.Button,{onClick:l,children:"Back"}),e.jsx(de,{type:"submit",value:d?"Saving...":"Save & Next",color:"primary",disabled:d,loading:d})]})]})]})})}const pd=(t,a=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const n=a.length?a:["allowances","Allowances","dedection","Dedection","deductions","Deductions"],r=[t];t?.data&&typeof t.data=="object"&&r.push(t.data);for(const l of r)for(const d of n){const c=l?.[d]??l?.[d.toLowerCase()]??l?.[d.toUpperCase()];if(Array.isArray(c)&&c.length>0)return c}const o=t?.data;if(Array.isArray(o)&&o.length>0)return o}return[]},Yn=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function gb({token:t,mode:a,staffId:n,initialValues:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(!1),[h,f]=i.useState(r?.type??"Permanent"),[p,m]=i.useState(r?.salary_type??Yn[0]?.value),[v,S]=i.useState(Number(r?.amount??0)),[y,g]=i.useState(Number(r?.basic_pay)||0),[b,D]=i.useState(r?.declarationPERyear??""),{data:R}=q(t?[Wh,t]:null,([j,P])=>W(j,P),{revalidateOnFocus:!1}),I=i.useMemo(()=>r?.allowances&&Array.isArray(r.allowances)&&r.allowances.length>0?r.allowances:pd(R,["allowances","Allowances"]),[R,r]),A=i.useMemo(()=>r?.deductions&&Array.isArray(r.deductions)&&r.deductions.length>0?r.deductions:pd(R,["dedection","Dedection","deductions","Deductions"]),[R,r]),_=i.useMemo(()=>{const j=Number(y||0),P=(Array.isArray(I)?I:[]).map(C=>{const E=C?.amount_type??C?.amountType??C?.type??"",M=Number(C?.Amount??C?.amount??0),Y=String(E).trim().toLowerCase()==="flat"?M:Number(j)/100*Number(M||0);return{...C,value:Number.isFinite(Y)?Y:0}}),O=(Array.isArray(A)?A:[]).map(C=>{const E=C?.amount_type??C?.amountType??C?.type??"",M=Number(C?.Amount??C?.amount??0),Y=String(E).trim().toLowerCase()==="flat"?M:Number(j)/100*Number(M||0);return{...C,value:Number.isFinite(Y)?Y:0}}),z=P.reduce((C,E)=>C+Number(E?.value||0),0),k=O.reduce((C,E)=>C+Number(E?.value||0),0),F=Math.max(0,Number(j)+z-k);return{allowances:P,deductions:O,netAmount:F}},[I,A,y]),u=async j=>{if(j.preventDefault(),c(!0),!n){T.error("Missing staff id.",{duration:1e3}),c(!1);return}const P=new FormData;P.append("staff_id",String(n)),P.append("type",h),h==="Nonpermanent"?(P.append("salary_type",p??""),P.append("amount",String(v||"")),P.append("Allowances",JSON.stringify([])),P.append("Dedection",JSON.stringify([]))):(P.append("basic_pay",String(y??0)),P.append("declarationPERyear",String(b??"")),P.append("Allowances",JSON.stringify(_.allowances||[])),P.append("Dedection",JSON.stringify(_.deductions||[])),P.append("amount",String(_.netAmount||0)));try{const O=a==="edit",z=O?Ya.editPayroll:Ya.addPayroll,k=O?await Pa(z,P,t):await ca(z,P,t);T.success("Success!",{duration:1e3}),o?.({payroll:{staffType:h,salaryType:p,amount:v,basicPay:y,declaration:b},result:k})}catch(O){T.error(O?.response?.data?.msg??O?.message??"Failed.",{duration:1e3})}finally{c(!1)}},x=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(j,P)=>`${P?.Amount??""} / ${P?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:u,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:h==="Nonpermanent"?"Non Permanent":"Permanent",value:h},onChange:j=>f(j?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),h==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(ae,{label:"Type",options:Yn,value:Yn.find(j=>j.value===p)??Yn[0],onChange:j=>m(j?.value??Yn[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(G,{type:"number",label:"Amount",value:v,onChange:j=>S(Number(j.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{type:"number",label:"Basic Pay",value:y,onChange:j=>g(Number(j.target.value||0)),required:!0}),e.jsx(G,{type:"text",label:"IT Declarations/Year",value:b,onChange:j=>D(j.target.value)}),e.jsx(G,{type:"number",label:"Net Amount",value:_.netAmount,disabled:!0})]})]}),h==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(j,P)=>`${j?.title??"a"}-${P}`,columns:x,dataSource:_.allowances,pagination:!1})}),e.jsx(s.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(j,P)=>`${j?.title??"d"}-${P}`,columns:x,dataSource:_.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(de,{type:"submit",value:d?"Finishing...":"Finish",color:"primary",disabled:d,loading:d})})]})})}const yb=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function xu({token:t,mode:a="add",staffId:n,onFinished:r}){const[o,l]=i.useState(0),[d,c]=i.useState(n??null),[h,f]=i.useState(null),[p,m]=i.useState(null),[v,S]=i.useState(null),y=a==="edit"?n??d:null,g=i.useMemo(()=>y?`${Je.staff.basicById}?staff_id=${encodeURIComponent(String(y))}`:null,[y]),b=i.useMemo(()=>y?`${Je.staff.experienceById}?staff_id=${encodeURIComponent(String(y))}`:null,[y]),D=i.useMemo(()=>y?`${Je.staff.payrollById}?staff_id=${encodeURIComponent(String(y))}`:null,[y]),R=q(t&&g?[g,t]:null,([C,E])=>W(C,E)),I=q(t&&b?[b,t]:null,([C,E])=>W(C,E)),A=q(t&&D?[D,t]:null,([C,E])=>W(C,E)),_=R?.data,u=I?.data,x=A?.data,j=!!R?.isLoading;I?.isLoading,A?.isLoading;const P=i.useMemo(()=>{try{const C=JSON.parse(localStorage.getItem("genrall_settings")??"null");return String(C?.multiple_shift??"").toLowerCase()==="yes"}catch{return!1}},[]),O=i.useMemo(()=>{const C=yb(_)[0]??_?.data??_??null;if(!C)return null;let E=null;const M=C?.shift_id??C?.shift_ids??C?.shift;if(M)if(P){const U=String(M).split(",").map(Y=>Y.trim()).filter(Boolean);U.length>0&&(E=U.map(Y=>({value:String(Y),label:Y})))}else C?.shift_id?E={value:String(C.shift_id),label:C?.shift??""}:C?.shift&&(E={value:String(C.shift),label:C.shift});return{emp_number:C?.emp_number??C?.empNo??C?.employee_id??"",f_name:C?.f_name??C?.firstname??C?.first_name??C?.name??"",l_name:C?.l_name??C?.lastname??C?.last_name??C?.surname??"",pan_no:C?.pan_no??C?.pan??"",adhar_no:C?.adhar_no??C?.aadhar_no??"",email:C?.email??C?.email_id??"",dob:C?.dob??C?.date_of_birth??"",doj:C?.doj??C?.date_of_joining??C?.joining_date??"",bloodGroup:C?.bloodGroup??C?.blood_group??"",contact_no:C?.contact_no??C?.phone??C?.contact??"",education:C?.education??C?.qualification??"",address:C?.address??C?.bussiness_address??C?.business_address??"",file:C?.file??C?.profile_picture??C?.profile_pic??C?.image??"",genderValue:C?.gender?{value:C.gender,label:C.gender}:null,roleValue:C?.role_id?{value:String(C.role_id),label:C?.role??""}:C?.fk_roleid?{value:String(C.fk_roleid),label:C?.role??""}:null,departmentValue:C?.department?{value:String(C.department),label:C?.departments??""}:null,designationValue:C?.designation?{value:String(C.designation),label:C?.designations??""}:null,shiftValue:E}},[_,P]),z=i.useMemo(()=>{const C=u?.data??u??null;return(Array.isArray(C?.experience)?C.experience:Array.isArray(C)?C:[]).map(M=>({name:M?.name??"",from:M?.from_date??M?.from??"",to:M?.to_date??M?.to??"",image:M?.image??""}))},[u]),k=i.useMemo(()=>{const C=x?.data??x??null,M=(Array.isArray(C)?C:C?.data&&Array.isArray(C.data)?C.data:[])[0]??null;if(!M)return null;const U=x?.allowances??C?.allowances??[],Y=x?.dedection??C?.dedection??x?.deductions??C?.deductions??[];return{type:M?.type??"Permanent",salary_type:M?.salary_type??"Hourly",amount:Number(M?.amount??0),basic_pay:Number(M?.basic_pay??0),declarationPERyear:M?.declarationPERyear??M?.it_declarationPERyear??"",allowances:Array.isArray(U)?U:[],deductions:Array.isArray(Y)?Y:[]}},[x]),F=i.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:a==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(s.Steps,{current:o,items:F}),o===0&&(a==="edit"&&j?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:40},children:e.jsx(s.Spin,{tip:"Loading staff data...",size:"large"})}):e.jsx(cb,{token:t,mode:a,staffId:y,initialValues:O,onSubmitted:({staffId:C})=>{C&&c(C),l(1)}})),o===1&&e.jsx(fb,{token:t,mode:a,staffId:y??d,initialRows:z,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(gb,{token:t,mode:a,staffId:y??d,initialValues:k,onBack:()=>l(1),onSubmitted:()=>{T.success("Completed.",{duration:1e3}),r?.({staffId:y??d}),l(0),a!=="edit"&&(c(null),f(null),m(null),S(null))}})]})})]})}function xb({token:t}){return e.jsx(xu,{token:t,mode:"add"})}const bb=({token:t})=>e.jsx(xb,{token:t}),zs=Je.staff,jb=Je.roleDropdown,Sb=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},wb=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function vb({token:t,onNavigate:a}){const[n,r]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(""),[d,c]=i.useState(""),[h,f]=i.useState(!1),[p,m]=i.useState(null),{data:v}=q(t?[jb,t]:null,([u,x])=>W(u,x)),S=i.useMemo(()=>Sb(v),[v]),y=i.useMemo(()=>{const u=n.page,x=n.rowsPerPage,j=o&&!d?`${zs.searchByRole}?role_id=${encodeURIComponent(String(o))}`:d?`${zs.searchByKeywords}?key=${encodeURIComponent(String(d))}`:zs.list,P=j.includes("?")?"&":"?";return`${j}${P}page=${encodeURIComponent(String(u))}&per_page=${encodeURIComponent(String(x))}`},[n.page,n.rowsPerPage,d,o]),{isLoading:g,error:b,data:D,mutate:R}=q(t?[y,t]:null,([u,x])=>W(u,x)),I=i.useMemo(()=>wb(D),[D]),A=async u=>{const x=u?.id??u?.fk_staffID??u?.staff_id;if(x)try{await xs(zs.deactivate,x,t),T.success("Success! Staff deactivated.",{duration:1e3}),await R()}catch(j){T.error(j?.response?.data?.msg??j?.message??"Failed to deactivate staff.",{duration:1e3})}},_=i.useMemo(()=>[{title:"Emp ID",dataIndex:"employee_id",key:"employee_id",width:120,responsive:["lg"]},{title:"Name",key:"name",ellipsis:!0,render:(u,x)=>`${x?.name||""} ${x?.surname||""}`.trim()},{title:"Role",dataIndex:"role",key:"role",ellipsis:!0,responsive:["md"]},{title:"Department",dataIndex:"departments",key:"departments",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"contact_no",key:"contact_no",ellipsis:!0,responsive:["md"]},{title:"Status",key:"steps",width:140,responsive:["lg"],render:(u,x)=>{const j=Number(x?.steps??x?.status??1),P=j<=1?30:j===2?60:100;return e.jsx(s.Progress,{percent:P,size:"small",format:O=>`${O}%`,style:{margin:"-4px 0"}})}},{title:"Action",key:"action",width:110,fixed:"right",render:(u,x)=>e.jsxs(s.Space,{size:"middle",children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>{typeof a=="function"?a("staff-edit",x):(m(x?.id??x?.fk_staffID??x?.staff_id??""),f(!0))}}),e.jsx(s.Popconfirm,{title:"Delete staff?",description:"Are you sure you want to deactivate this staff member?",okText:"Yes",cancelText:"No",onConfirm:()=>A(x),children:e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(re.DeleteOutlined,{}),style:{padding:2}})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:2,style:{margin:0},children:"Filters"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{options:[{value:"",label:"All Roles"},...S],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:u=>{l(u?.value??""),r(x=>({...x,page:1}))}}),e.jsx(G,{type:"text",label:"Keyword",value:d,onChange:u=>c(u.target.value),placeholder:"Search by keywords"}),e.jsx(de,{type:"button",value:"Refresh",onClick:()=>R()})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:8,style:{margin:0},children:"Staff Directory"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:g,rowKey:u=>String(u?.id??u?.fk_staffID??u?.staff_id??Math.random()),columns:_,dataSource:I,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(u,x)=>r({page:u,rowsPerPage:x}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]}),e.jsx(s.Drawer,{open:h,onClose:()=>{f(!1),m(null)},title:"Edit Staff",width:"80%",destroyOnClose:!0,footer:null,children:p!=null&&e.jsx(xu,{token:t,mode:"edit",staffId:String(p),onFinished:()=>{f(!1),m(null),R()}})})]})}const Cb=({token:t,onNavigate:a})=>e.jsx(vb,{token:t,onNavigate:a}),_b=Je.attendance,Ab=Je.roleDropdown,md=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},qs={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},hd={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Tb({token:t,open:a,onClose:n,roleId:r,onSaved:o}){const[l,d]=i.useState(null),[c,h]=i.useState(""),[f,p]=i.useState(ne()),[m,v]=i.useState(ne()),[S,y]=i.useState(ne()),g=i.useMemo(()=>r?`${Je.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:b}=q(t&&g?[g,t]:null,([u,x])=>W(u,x)),D=i.useMemo(()=>md(b),[b]),{trigger:R,data:I}=it(t?Je.attendance.staffShiftByStaffId:null,(u,{arg:x})=>Ta(u,{arg:x},t)),A=i.useMemo(()=>md(I),[I]),_=async()=>{if(!l?.value){T.error("Select staff.",{duration:1e3});return}if(!c){T.error("Select shift.",{duration:1e3});return}const u=new FormData;u.set("staffID",String(l.value)),u.set("shift_id",String(c)),u.set("attendance_date",f?f.format("YYYY-MM-DD"):""),u.set("intime",m?m.format("h:mm a"):""),u.set("outime",S?S.format("h:mm a"):"");try{await ca(Je.attendance.manualAttendance,u,t),T.success("Success!",{duration:1e3}),o?.(),n?.(),d(null),h(""),p(ne()),v(ne()),y(ne())}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed.",{duration:1e3})}};return e.jsx(s.Modal,{open:a,onCancel:n,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(s.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ae,{label:"Staff",options:D,value:l,onChange:async u=>{if(d(u??null),h(""),u?.value&&R)try{await R({staff_id:u.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:qs,children:"Shift"}),e.jsx(s.Radio.Group,{value:c,onChange:u=>h(u.target.value),style:{display:"grid",gap:8},children:A.map(u=>e.jsx(s.Radio,{value:u?.value,children:u?.label??u?.name??u?.title??String(u?.value??"")},String(u?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:qs,children:"Date"}),e.jsx(s.DatePicker,{value:f,onChange:u=>u&&p(u),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:qs,children:"Start Time"}),e.jsx(s.TimePicker,{value:m,onChange:u=>u&&v(u),use12Hours:!0,format:"h:mm a",style:hd})]}),e.jsxs("div",{children:[e.jsx("div",{style:qs,children:"End Time"}),e.jsx(s.TimePicker,{value:S,onChange:u=>u&&y(u),use12Hours:!0,format:"h:mm a",style:hd})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(s.Button,{onClick:n,children:"Cancel"}),e.jsx(de,{type:"button",value:"Save",color:"primary",onClick:_})]})]})})})}const Db=({tableRef:t,excelDisabled:a})=>{const n=new Date().getTime(),r=Ka.useReactToPrint({content:()=>t?.current});return e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(s.Row,{gutter:8,children:[e.jsx(s.Col,{children:e.jsx(s.Button,{type:"text",icon:e.jsx(re.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:a?e.jsx(s.Button,{type:"text",icon:e.jsx(re.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>T.error("You must save attendance before download",{duration:2e3})}):e.jsx(cu.DownloadTableExcel,{filename:n,sheet:"users",currentTableRef:t?.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(re.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},kb=(t,a)=>{const n=t?.data?.data??t?.data??t??null;return n?a==="student"?Array.isArray(n?.student)?n.student:[]:Array.isArray(n?.staff)?n.staff:[]:[]},Rb=t=>{const a=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,n=Number(a);return Number.isFinite(n)&&n>=0?n:0},Ib=(t,a)=>{const n=t?.data?.data??t?.data??t??null;return n?a==="student"?{sunday:String(n?.sunday??"").toLowerCase()==="yes",holiday:String(n?.holiday??"").toLowerCase()==="yes"}:{sunday:!!n?.sunday,holiday:!!n?.holiday}:{sunday:!1,holiday:!1}};function Pb({token:t,url:a,columns:n,reload:r,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:h="staff"}){const f=i.useRef(null),[p,m]=i.useState({page:0,rowsPerPage:10}),[v,S]=i.useState(!1),[y,g]=i.useState(!1),[b,D]=i.useState(null),[R,I]=i.useState([]),[A,_]=i.useState({sunday:!1,holiday:!1}),[u,x]=i.useState(!0);i.useEffect(()=>{m(z=>({...z,page:0}))},[a]),i.useEffect(()=>{let z=!0;return(async()=>{if(!(!t||!a)){S(!0);try{const F=String(a).includes("?")?"&":"?",C=`${a}${F}page=${p.page+1}&per_page=${p.rowsPerPage}`,E=await W(C,t);if(!z)return;D(E),E?.Status==="Success"?(d?.(!1),I(kb(E,h)),_(Ib(E,h))):(d?.(!0),I([]),_({sunday:!1,holiday:!1}))}catch{if(!z)return;d?.(!0),I([])}finally{z&&S(!1)}}})(),()=>{z=!1}},[p.page,p.rowsPerPage,r,d,t,h,a]);const j=i.useMemo(()=>Rb(b),[b]);i.useEffect(()=>{const z=(Array.isArray(R)?R:[]).find(k=>k?.attendence_type_id===null);x(!!z)},[R]);const P=async()=>{if(t){g(!0);try{if(h==="staff"){const z=(Array.isArray(R)?R:[]).map(k=>({staff_id:k?.staff_id,attendence_type_id:k?.attendence_type_id?k.attendence_type_id:"1",in_time:k?.intime,out_time:k?.outtime,date:c}));await ca(Je.attendance.addAttendanceToStaffByBranch,z,t),T.success("Attendance saved successfully",{duration:2e3}),o?.(k=>!k)}else T.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(z){T.error(z?.response?.data?.msg??z?.message??"Failed required dates",{duration:2e3})}finally{g(!1)}}},O=i.useMemo(()=>(Array.isArray(n)?n:[]).map(k=>k?.selector==="attendence_type_id"?{title:k?.name??"Attendance",dataIndex:k.selector,key:k.selector,render:F=>F==null||F===""?e.jsx(s.Tag,{color:"orange",children:"Not Set"}):String(F)==="1"?e.jsx(s.Tag,{color:"green",children:"Present"}):String(F)==="4"?e.jsx(s.Tag,{color:"red",children:"Absent"}):String(F)==="3"?e.jsx(s.Tag,{color:"orange",children:"Late"}):e.jsx(s.Tag,{children:String(F)})}:k?.selector==="snum"?{title:k?.name??"Sl",key:k.selector,render:(F,C,E)=>E+1}:{title:k?.name??k?.selector,dataIndex:k?.selector,key:k?.selector}),[n]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{children:[e.jsx(Db,{tableRef:f,excelDisabled:u}),e.jsx(s.Modal,{open:y,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(s.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),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:f,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(z,k)=>String(z?.id??z?.staff_id??k),columns:O,dataSource:R,loading:v,pagination:{current:p.page+1,pageSize:p.rowsPerPage,total:j,showSizeChanger:!0,onChange:(z,k)=>m({page:z-1,rowsPerPage:k})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:P,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const Mb=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Eb={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ob({token:t}){const[a,n]=i.useState(""),[r,o]=i.useState(ne().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,h]=i.useState(null),[f,p]=i.useState(!1),[m,v]=i.useState(!0),[S,y]=i.useState(!1),g=i.useRef(null),{data:b}=q(t?[Ab,t]:null,([I,A])=>W(I,A)),D=i.useMemo(()=>Mb(b),[b]),R=i.useMemo(()=>[{id:"1",name:"Staff Id",selector:"employee_id",sortable:!0},{id:"2",name:"Name",selector:"full_name",sortable:!0},{id:"4",name:"Contact",selector:"contact_no",sortable:!0},{id:"3",name:"Attendance",selector:"attendence_type_id",sortable:!0},{id:"5",name:"In Time",selector:"intime",sortable:!0},{id:"6",name:"Out Time",selector:"outtime",sortable:!0}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:I=>n(I?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{defaultValue:ne(),onChange:I=>I&&o(I.format("YYYY-MM-DD")),style:Eb,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>{!a||!r||(h(`${_b.staffListForAttendance}?role=${encodeURIComponent(String(a))}&date=${encodeURIComponent(String(r))}`),d(I=>!I))}})})]})}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:12},children:[e.jsx(s.Button,{size:"small",type:f?"primary":"default",onClick:()=>p(I=>!I),children:f?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"default",disabled:m,onClick:()=>y(!0),children:"Give Attendance"})]}),c?e.jsx(Pb,{token:t,url:c,columns:R,reload:l,setReload:d,saveBtnRef:g,setSaveBtnDisabled:v,date:r,type:"staff",holidayChecked:f}):null]}),e.jsx(Tb,{token:t,open:S,onClose:()=>y(!1),roleId:a,onSaved:()=>d(I=>!I)})]})}const $b=({token:t})=>e.jsx(Ob,{token:t}),fd=Je.attendanceReport.monthlyStaffReport,Fb=Je.roleDropdown,Bb=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Lb({token:t}){const a=i.useRef(null),[n,r]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),h=i.useMemo(()=>po(5),[]),{data:f}=q(t?[Fb,t]:null,([z,k])=>W(z,k)),p=i.useMemo(()=>Bb(f),[f]),[m,v]=i.useState([]),[S,y]=i.useState(1),[g,b]=i.useState(!1),[D,R]=i.useState(!1),[I,A]=i.useState(null),_=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:u}=it(t&&fd?`${fd}?page=${S}&per_page=3`:null,(z,{arg:k})=>Ta(z,{arg:k},t),{onSuccess:z=>{b(!1);const k=Array.isArray(z)?z:[];k.length>0&&v(F=>[...F||[],...k]),k.length>1?y(F=>F+1):R(!1)},onError:()=>{b(!1),R(!1)}});i.useEffect(()=>{D&&u&&I&&u(I)},[D,S,I,u]);const x=i.useMemo(()=>{const z=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(k,F)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:F?.full_name??""})}];return Array.isArray(m)&&m.length>0&&((m[0]?.monthly_data??[]).forEach((F,C)=>{z.push({title:C+1,align:"center",key:String(C+1),render:(E,M)=>{const U=M?.monthly_data?.[C]?.[0]?.data?.[0]??{},Y=U?.intime??"",V=U?.outtime??"",L=U?.attendance_type??"";return e.jsx(s.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",Y]}),e.jsxs("div",{children:["Out Time ",V]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:St(L)})})}})}),z.push({title:"Total",key:"Total",render:(F,C)=>{const E=C?.monthly_data??[],M=E.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="A").length,U=E.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",M," P : ",U]})})}})),z},[m]),j=i.useMemo(()=>[{label:"Present",el:St("P")},{label:"Absent",el:St("A")},{label:"Leave",el:St("L")},{label:"Weekly Off",el:St("W")},{label:"Holiday",el:St("H")}],[]),P=i.useMemo(()=>d.month?o.find(z=>z?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),O=async z=>{if(z.preventDefault(),!d.role||!d.year||!d.month)return;y(1),b(!0),v([]);const k={session:_,year:d.year,month:d.month,day:"01",role:d.role};A(k),R(!0),await u?.(k)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{className:"d-print-none",title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:z=>c(k=>({...k,role:z?.value??"",rolllabel:z?.label??""}))}),e.jsx(ae,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:z=>{const k=mo(z?.value);l(k),r(F=>!F),c(F=>({...F,year:z?.label??""}))}}),e.jsx(ae,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:z=>c(k=>({...k,month:z?.value??""}))},`month-${n}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(da,{})}),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(Jt,{data:{tableRef:a}})})]}),e.jsx("div",{style:{marginTop:14,paddingTop:14,borderTop:"1px solid #e0e0e0"},children:e.jsx("div",{style:{display:"flex",justifyContent:"center",flexWrap:"wrap",gap:12,fontSize:12},children:j.map(z=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[z.label," :"]}),e.jsx("div",{children:z.el})]},z.label))})})]}),e.jsx(s.Skeleton,{active:!0,loading:g,paragraph:{rows:10},children:e.jsx(s.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:x,dataSource:m,pagination:!1,scroll:{x:"max-content"},rowKey:(z,k)=>String(z?.staff_id??z?.id??k)})})]})})]})}const Ub=({token:t})=>e.jsx(Lb,{token:t}),gd=Je.payroll,Nb=Je.roleDropdown,zb=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},qb=t=>t?.data?.data??t?.data??t??[];function Yb({token:t,receiptDetailsPath:a="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:n}){const[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,h]=i.useState([]),[f,p]=i.useState({role:"",roleLabel:"",year:"",month:""}),[m,v]=i.useState(null),S=x=>{if(!x)return;if(typeof n=="function"){n(x);return}const j=`${a}?id=${encodeURIComponent(String(x))}`;typeof window<"u"&&window?.location&&(window.location.href=j)},{data:y}=q(t?[Nb,t]:null,([x,j])=>W(x,j)),g=i.useMemo(()=>zb(y),[y]),b=i.useMemo(()=>po(5),[]),{isLoading:D,error:R,data:I}=q(t&&m?[m,t]:null,([x,j])=>W(x,j)),A=i.useMemo(()=>{const x=qb(I);return Array.isArray(x)?x:[]},[I]),_=i.useMemo(()=>{const x=I?.pagination?.total_rows??I?.data?.pagination?.total_rows??I?.total??I?.total_rows,j=Number(x);return Number.isFinite(j)&&j>=0?j:A.length},[I,A.length]),u=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(x,j,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,j)=>{const P=j?.id??j?.staff_id??j?.staffId;return e.jsx(s.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{S(P)},children:lu(j?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:x=>{if(x.preventDefault(),!f.role||!f.year||!f.month)return;const j=`${gd.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(f.role))}&year=${encodeURIComponent(String(f.year))}&month=${encodeURIComponent(String(f.month))}`;v(j)},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(ae,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:x=>p(j=>({...j,role:x?.value??"",roleLabel:x?.label??""}))}),e.jsx(ae,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:x=>{const j=mo(x?.value);h(j),d(P=>!P),p(P=>({...P,year:x?.label??"",month:""}))}}),e.jsx(ae,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:x=>p(j=>({...j,month:x?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary",onClick:()=>o(x=>({...x,page:1}))})})]})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:D,rowKey:(x,j)=>String(x?.id??x?.staff_id??j),columns:u,dataSource:A,pagination:{current:r.page,pageSize:r.rowsPerPage,total:_,showSizeChanger:!0,onChange:(x,j)=>{o({page:x,rowsPerPage:j}),!(!f.role||!f.year||!f.month)&&v(`${gd.payrollByRole}?page=${encodeURIComponent(String(x))}&per_page=${encodeURIComponent(String(j))}&role=${encodeURIComponent(String(f.role))}&year=${encodeURIComponent(String(f.year))}&month=${encodeURIComponent(String(f.month))}`)}},scroll:{x:"max-content"}})]})})}const Wb=({token:t})=>e.jsx(Yb,{token:t}),bu=Je.leave,Dn=({baseUrl:t,page:a=1,perPage:n=10,token:r})=>q(r&&t?[t,a,n,r]:null,([l,d,c,h])=>eb({baseUrl:l,page:d,perPage:c},h)),Vb=({token:t,page:a=1,perPage:n=10})=>Dn({token:t,baseUrl:bu.requestTable,page:a,perPage:n}),Hb=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Kb=(t,a)=>{const n=new FormData;return Object.entries(t??{}).forEach(([r,o])=>{o!=null&&n.append(r,String(o))}),n.set("status",a),n};function Gb({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:o,data:l,mutate:d}=Vb({token:t,page:a.page,perPage:a.rowsPerPage}),c=i.useMemo(()=>Hb(l),[l]),h=async(p,m)=>{try{const v=Kb(p,m),S=await Pa(bu.approveRequest,v,t);S?.Status==="Success"?T.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):T.error(S?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(v){T.error(v?.response?.data?.msg??v?.message??"Failed to update request.",{duration:1e3})}},f=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(p,m)=>m?.full_name??m?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(p,m)=>m?.leave_from??m?.from_date??""},{title:"To",key:"leave_to",width:120,render:(p,m)=>m?.leave_to??m?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(p,m)=>m?.leavetype??m?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(p,m)=>m?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(p,m)=>m?.employee_remark??m?.reason??""},{title:"View",key:"document_file",width:140,render:(p,m)=>{const v=m?.document_file;return v?e.jsx(s.Button,{size:"small",onClick:()=>window.open(v,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(p,m)=>{const v=String(m?.status??"").toLowerCase();return v==="approved"?e.jsx(s.Tag,{color:"green",children:"Approved"}):v==="declined"?e.jsx(s.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(s.Button,{type:"text",size:"small",onClick:()=>h(m,"approved"),icon:e.jsx(re.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(s.Button,{type:"text",size:"small",onClick:()=>h(m,"declined"),icon:e.jsx(re.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:r,rowKey:(p,m)=>String(p?.id??p?.leave_id??m),columns:f,dataSource:c,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(p,m)=>n({page:p,rowsPerPage:m}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Jb=({token:t})=>e.jsx(Gb,{token:t}),Qb=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Xb=({token:t,value:a,onChange:n})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:fu(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Qb(o?.file?.response);l&&n?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},ju=Je.leave,Zb=Je.master.leaveType.dropdown,ej=({token:t,page:a=1,perPage:n=10})=>Dn({token:t,baseUrl:ju.table,page:a,perPage:n}),tj=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ci={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function aj({token:t,userType:a}){const[n,r]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(!1),[d,c]=i.useState(""),[h]=s.Form.useForm();console.log("ApplyLeavePage render",a);const{isLoading:f,error:p,data:m,mutate:v}=ej({token:t,page:n.page,perPage:n.rowsPerPage}),{data:S}=q(t?[Zb,t]:null,([u,x])=>W(u,x)),y=i.useMemo(()=>tj(S),[S]),g=(u,x)=>r({page:u,rowsPerPage:parseInt(x,10)}),b=()=>{c(""),h.resetFields(),h.setFieldsValue({apply_date:ne()}),l(!0)},D=()=>{l(!1),c(""),h.resetFields()},R=async u=>{const x=new FormData;x.set("apply_date",u?.apply_date?u.apply_date.format("YYYY-MM-DD"):""),x.set("leave_type",u?.leave_type?.value??u?.leave_type??""),x.set("from_date",u?.from_date?u.from_date.format("YYYY-MM-DD"):""),x.set("to_date",u?.to_date?u.to_date.format("YYYY-MM-DD"):""),x.set("reason",u?.reason??""),d&&x.set("file",d);try{await ca(ju.apply,x,t),T.success("Success! Leave request submitted.",{duration:1e3}),D(),await v()}catch(j){T.error(j?.response?.data?.msg??j?.message??"Failed to submit leave request.",{duration:1e3})}},I=i.useMemo(()=>{const u=m?.data??m??[];return Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]},[m]),A=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(u,x)=>x?.leavetype??x?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(u,x)=>x?.date??x?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(u,x)=>x?.leave_from??x?.from_date??""},{title:"To",key:"leave_to",width:130,render:(u,x)=>x?.leave_to??x?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(u,x)=>x?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]),_=a==="staff";return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:o,title:"Add Leave Request",onCancel:D,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:h,layout:"vertical",onFinish:R,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.Form.Item,{name:"apply_date",rules:[{required:!0,message:"Select date"}],style:{marginBottom:0},children:e.jsx(s.DatePicker,{style:Ci})})]}),e.jsx(s.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(ae,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From"}),e.jsx(s.Form.Item,{name:"from_date",rules:[{required:!0,message:"Select from date"}],style:{marginBottom:0},children:e.jsx(s.DatePicker,{style:Ci})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To"}),e.jsx(s.Form.Item,{name:"to_date",rules:[{required:!0,message:"Select to date"}],style:{marginBottom:0},children:e.jsx(s.DatePicker,{style:Ci})})]}),e.jsx(s.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(G,{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(Xb,{token:t,value:d,onChange:c})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(s.Button,{onClick:D,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})]})}),_&&e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(de,{type:"button",value:"Add Leave Request",onClick:b})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:f,rowKey:(u,x)=>String(u?.id??u?.leave_id??x),columns:A,dataSource:I,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(u,x)=>g(u,x),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const nj=({token:t,userType:a})=>e.jsx(aj,{token:t,userType:a}),ir=Je.master.leaveType,sj=({token:t,page:a=1,perPage:n=10})=>Dn({token:t,baseUrl:ir.table,page:a,perPage:n});function rj({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,h]=i.useState(null),{isLoading:f,error:p,data:m,mutate:v}=sj({token:t,page:a.page,perPage:a.rowsPerPage}),S=(A,_)=>{n({page:A,rowsPerPage:parseInt(_,10)})},y=async A=>{const _=new FormData;_.set("title",A?.title??"");try{await v(ca(ir.add,_,t),pt(_)),T.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(u){T.error(u?.response?.data?.msg??u?.message??"Failed to add leave type.",{duration:1e3})}},g=A=>{h(A??null),o.setFieldsValue({title:A?.leave_type_name??A?.name??""}),d(!0)},b=()=>{d(!1),h(null),o.resetFields()},D=async A=>{const _=c?.id??c?.leave_type_id;if(!_){T.error("Missing leave type id.",{duration:1e3});return}const u=new FormData;u.set("id",String(_)),u.set("title",A?.title??"");try{await Pa(ir.edit,u,t),await v(),T.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),b()}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to update leave type.",{duration:1e3})}},R=async A=>{const _=A?.id??A?.leave_type_id;if(_)try{await v(xs(ir.remove,_,t),ot(_)),T.success("Success! Deleted leave type.",{duration:1e3})}catch(u){T.error(u?.response?.data?.msg??u?.message??"Failed to delete leave type.",{duration:1e3})}},I=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(A,_)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>g(_)}),e.jsx(s.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>R(_),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Leave Type",onCancel:b,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(G,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:b,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:y,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(G,{type:"text",label:"Name"})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Ke,{parentCallback:S,data:{newData:m,columns:I,columnstype:"antd",action:!1,Loading:f,error:p}})})]})}const ij=({token:t})=>e.jsx(rj,{token:t}),or=Je.master.department,oj=({token:t,page:a=1,perPage:n=10})=>Dn({token:t,baseUrl:or.table,page:a,perPage:n});function lj({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,h]=i.useState(null),{isLoading:f,error:p,data:m,mutate:v}=oj({token:t,page:a.page,perPage:a.rowsPerPage}),S=(A,_)=>{n({page:A,rowsPerPage:parseInt(_,10)})},y=async A=>{const _=new FormData;_.set("title",A?.title??"");try{await v(ca(or.add,_,t),pt(_)),T.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(u){T.error(u?.response?.data?.msg??u?.message??"Failed to add department.",{duration:1e3})}},g=A=>{h(A??null),o.setFieldsValue({title:A?.department_name??A?.name??""}),d(!0)},b=()=>{d(!1),h(null),o.resetFields()},D=async A=>{const _=c?.id??c?.department_id;if(!_){T.error("Missing department id.",{duration:1e3});return}const u=new FormData;u.set("id",String(_)),u.set("title",A?.title??"");try{await Pa(or.edit,u,t),await v(),T.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),b()}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to update department.",{duration:1e3})}},R=async A=>{const _=A?.id??A?.department_id;if(_)try{await v(xs(or.remove,_,t),ot(_)),T.success("Success! Deleted department.",{duration:1e3})}catch(u){T.error(u?.response?.data?.msg??u?.message??"Failed to delete department.",{duration:1e3})}},I=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(A,_)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>g(_)}),e.jsx(s.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>R(_),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Department",onCancel:b,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(G,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:b,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:y,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(G,{type:"text",label:"Name"})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Ke,{parentCallback:S,data:{newData:m,columns:I,columnstype:"antd",action:!1,Loading:f,error:p}})})]})}const dj=({token:t})=>e.jsx(lj,{token:t}),lr=Je.master.designation,cj=({token:t,page:a=1,perPage:n=10})=>Dn({token:t,baseUrl:lr.table,page:a,perPage:n});function uj({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,h]=i.useState(null),{isLoading:f,error:p,data:m,mutate:v}=cj({token:t,page:a.page,perPage:a.rowsPerPage}),S=(A,_)=>{n({page:A,rowsPerPage:parseInt(_,10)})},y=async A=>{const _=new FormData;_.set("title",A?.title??"");try{await v(ca(lr.add,_,t),pt(_)),T.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(u){T.error(u?.response?.data?.msg??u?.message??"Failed to add designation.",{duration:1e3})}},g=A=>{h(A??null),o.setFieldsValue({title:A?.designation??""}),d(!0)},b=()=>{d(!1),h(null),o.resetFields()},D=async A=>{const _=c?.id??c?.designation_id;if(!_){T.error("Missing designation id.",{duration:1e3});return}const u=new FormData;u.set("id",String(_)),u.set("title",A?.title??"");try{await Pa(lr.edit,u,t),await v(),T.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),b()}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to update designation.",{duration:1e3})}},R=async A=>{const _=A?.id??A?.designation_id;if(_)try{await v(xs(lr.remove,_,t),ot(_)),T.success("Success! Deleted designation.",{duration:1e3})}catch(u){T.error(u?.response?.data?.msg??u?.message??"Failed to delete designation.",{duration:1e3})}},I=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(A,_)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>g(_)}),e.jsx(s.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>R(_),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Designation",onCancel:b,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(G,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:b,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:y,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(G,{type:"text",label:"Name"})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Ke,{parentCallback:S,data:{newData:m,columns:I,columnstype:"antd",action:!1,Loading:f,error:p}})})]})}const pj=({token:t})=>e.jsx(uj,{token:t}),dr=Je.master.shift,mj=({token:t,page:a=1,perPage:n=10})=>Dn({token:t,baseUrl:dr.table,page:a,perPage:n}),Ot="hh:mm A",un=t=>{const a=String(t??"");if(!a)return null;const n=ne(a,[Ot,"HH:mm","HH:mm:ss"],!0);return n.isValid()?n:null},pn=t=>t?t.format(Ot):"",Kt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function hj({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,h]=i.useState(null),{isLoading:f,error:p,data:m,mutate:v}=mj({token:t,page:a.page,perPage:a.rowsPerPage}),S=(u,x)=>{n({page:u,rowsPerPage:parseInt(x,10)})},y=(u,x)=>{const j=new FormData;return x&&j.set("id",String(x)),j.set("name",u?.name??""),j.set("start_time",pn(u?.start_time)),j.set("end_time",pn(u?.end_time)),j.set("shift_start_from",pn(u?.shift_start_from)),j.set("shift_start_to",pn(u?.shift_start_to)),j.set("shift_end_from",pn(u?.shift_end_from)),j.set("shift_end_to",pn(u?.shift_end_to)),j},g=async u=>{const x=y(u);try{await v(ca(dr.add,x,t)),T.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(j){T.error(j?.response?.data?.msg??j?.message??"Failed to add shift.",{duration:1e3})}},b=u=>{h(u??null),o.setFieldsValue({name:u?.shift_name??u?.name??"",start_time:un(u?.start_time),end_time:un(u?.end_time),shift_start_from:un(u?.shift_start_from),shift_start_to:un(u?.shift_start_to),shift_end_from:un(u?.shift_end_from),shift_end_to:un(u?.shift_end_to)}),d(!0)},D=()=>{d(!1),h(null),o.resetFields()},R=async u=>{const x=c?.id??c?.shift_id;if(!x){T.error("Missing shift id.",{duration:1e3});return}try{const j=y(u,x);await v(Pa(dr.edit,j,t)),T.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),D()}catch(j){T.error(j?.response?.data?.msg??j?.message??"Failed to update shift.",{duration:1e3})}},I=async u=>{const x=u?.id??u?.shift_id;if(x)try{await v(xs(dr.remove,x,t)),T.success("Success! Deleted shift.",{duration:1e3})}catch(j){T.error(j?.response?.data?.msg??j?.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:(u,x)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(re.EditOutlined,{}),onClick:()=>b(x)}),e.jsx(s.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>I(x),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]),_=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Shift",onCancel:D,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:R,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(G,{type:"text",label:"Name"})}),e.jsx(s.Form.Item,{name:"start_time",label:"Start Time",rules:_,children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:_,children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:D,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(s.Form,{form:r,layout:"vertical",onFinish:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(G,{type:"text",label:"Name"})}),e.jsx(s.Form.Item,{name:"start_time",label:"Start Time",rules:_,children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:_,children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Ot,use12Hours:!0,style:Kt})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Ke,{parentCallback:S,data:{newData:m,columns:A,columnstype:"antd",action:!1,Loading:f,error:p}})})]})}const fj=({token:t})=>e.jsx(hj,{token:t}),gj=Je.attendance;function yj({data:t}){return t?e.jsx("div",{style:{margin:15,fontSize:13,padding:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{}),(t?.shifts??[]).map((a,n)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:a?.shift_name??""},`${n}heading1`))]}),e.jsxs("tr",{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Sl.No"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Teacher's Name"}),(t?.shifts??[]).map((a,n)=>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"})]},`${n}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((a,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:n+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${a?.name??""} ${a?.surname??""}`.trim()})}),(t?.shifts??[]).map((r,o)=>e.jsxs(i.Fragment,{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkintime??"").toUpperCase():""})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${n}`))]},`${n}row`))})]})}):null}const xj=t=>{const a=t?.data??t??{};return Array.isArray(a)?a:Array.isArray(a?.items)?a.items:Array.isArray(a?.data)?a.data:[]},bj=t=>{const a=String(t??"").toLowerCase();return a==="present"?e.jsx(s.Tag,{color:"green",children:"Present"}):a==="absent"?e.jsx(s.Tag,{color:"red",children:"Absent"}):a==="leave"?e.jsx(s.Tag,{color:"orange",children:"Leave"}):e.jsx(s.Tag,{children:t??""})};function jj({token:t}){const[a,n]=i.useState(ne()),[r,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${gj.dailyAttendance}?attendance_date=${encodeURIComponent(a.format("YYYY-MM-DD"))}`,[a,r,l]),{isLoading:h,error:f,data:p}=q(t?[c,t]:null,([g,b])=>W(g,b)),m=i.useMemo(()=>xj(p),[p]),v=i.useMemo(()=>r?p?.data?.data??p?.data??p??null:null,[p,r]),S=Ka.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),y=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(g,b,D)=>D+1},{title:"Name",key:"name",render:(g,b)=>b?.staff_name??`${b?.name??""} ${b?.surname??""}`.trim(),ellipsis:!0},{title:"Department",dataIndex:"department",key:"department",ellipsis:!0,responsive:["md"]},{title:"Designation",dataIndex:"designation",key:"designation",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(g,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[bj(b?.attendance_status??b?.attendance),b?.is_week_off?e.jsx(s.Tag,{color:"blue",children:"W/O"}):null]})},{title:"In Time",key:"intime",width:120,render:(g,b)=>{const D=b?.attendance_data?.[0];return b?.check_in??D?.intime??""}},{title:"Out Time",key:"outtime",width:120,render:(g,b)=>{const D=b?.attendance_data?.[0];return b?.check_out??D?.outtime??""}}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Staff Daily Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{value:a,onChange:g=>g&&n(g),style:{width:"100%"},allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",onClick:()=>d(g=>g+1)})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(re.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:S}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(da,{})}),r?e.jsx(yj,{data:v}):e.jsx(s.Table,{bordered:!0,size:"small",loading:h,rowKey:(g,b)=>String(g?.id??g?.staff_id??b),columns:y,dataSource:m,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const Sj=({token:t})=>e.jsx(jj,{token:t}),yd=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},wj=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 vj({token:t,staffId:a}){const[n,r]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[h,f]=i.useState(""),[p,m]=i.useState(""),v=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),S=P=>{const O=Number(P??0),z=Number.isFinite(O)?O.toLocaleString("en-IN"):"0";return`${v?`${v} `:""}${z}`},y=i.useMemo(()=>a?`${Je.staff.basicById}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),g=i.useMemo(()=>a?`${Je.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),{data:b}=q(t&&y?[y,t]:null,([P,O])=>W(P,O)),{data:D,isLoading:R,mutate:I}=q(t&&g?[g,t]:null,([P,O])=>W(P,O)),A=i.useMemo(()=>yd(b)[0]??b?.data??b??null,[b]),_=i.useMemo(()=>yd(D),[D]),u=i.useMemo(()=>[{title:"Month",dataIndex:"month",key:"month",width:120,align:"center"},{title:"Basic Salary",dataIndex:"basic_salary",key:"basic_salary",width:140,align:"center",render:(P,O)=>e.jsx("div",{style:{fontSize:11},children:ra(O?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(P,O)=>e.jsx("div",{style:{fontSize:11},children:ra(O?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(P,O)=>e.jsx("div",{style:{fontSize:11},children:ra(O?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(P,O)=>e.jsx("div",{style:{fontSize:11},children:ra(O?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(P,O)=>e.jsx("div",{style:{cursor:O?.status==="due"?"pointer":"default"},onClick:()=>{O?.status==="due"&&(l(O),r(!0))},children:lu(O?.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"}],[]),j=async()=>{if(!o)return;const P={...o,staff_id:a,payment_type:d?.value??"",notes:h,attchement:p};try{await Ze(Je.payroll.generatePayslip,{arg:P},t),T.success("Success!",{duration:1e3}),r(!1),l(null),f(""),m(""),await I()}catch(O){T.error(O?.response?.data?.msg??O?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("div",{style:{fontSize:13,color:"#444"},children:A?`${A?.f_name??A?.firstname??""} ${A?.l_name??A?.lastname??""}`.trim():""}),e.jsx(s.Table,{bordered:!0,size:"small",loading:R,rowKey:(P,O)=>String(P?.id??`${P?.month}-${O}`),columns:u,dataSource:_,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(s.Modal,{open:n,onCancel:()=>{r(!1),l(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ae,{label:"Pay",options:x,value:d,onChange:P=>c(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(s.Input.TextArea,{rows:4,placeholder:"Note",value:h,onChange:P=>f(P.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(s.Upload,{maxCount:1,action:fu(),headers:t?{Authorization:t}:void 0,onChange:P=>{if(P?.file?.status==="done"){const O=wj(P?.file?.response);O&&m(O)}P?.file?.status==="removed"&&m("")},children:e.jsx(s.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(s.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(de,{type:"button",value:o?.Total_Payable_Amount?`Pay ${S(o.Total_Payable_Amount)}`:"Pay",onClick:j})]})]})})]})}function Cj({token:t,staffId:a}){const n=i.useMemo(()=>{if(a!=null&&String(a).trim()!=="")return a;if(typeof window>"u")return null;const r=new URLSearchParams(window.location.search).get("id");return r||null},[a]);return n?e.jsx(vj,{token:t,staffId:n}):e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsx("div",{style:{fontSize:13,color:"#666"},children:"Missing staff id."})})}function Ma({onAdd:t,onExport:a,onPrint:n,onDownload:r,onFilter:o,onRefresh:l,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(re.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(re.FileExcelOutlined,{}),onClick:a},{key:"print",title:"Print",icon:e.jsx(re.PrinterOutlined,{}),onClick:n},{key:"download",title:"Download",icon:e.jsx(re.DownloadOutlined,{}),onClick:r},{key:"filter",title:"Filter",icon:e.jsx(re.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(re.ReloadOutlined,{}),onClick:l}],[t,a,n,r,o,l]),h=i.useMemo(()=>{const f=Array.isArray(d)&&d.length?new Set(d):null;return f?c.filter(p=>f.has(p.key)):c},[c,d]);return e.jsx(s.Space,{size:8,children:h.map(f=>e.jsx(s.Tooltip,{title:f.title,children:e.jsx(s.Button,{type:"text",icon:f.icon,onClick:f.onClick,disabled:!f.onClick})},f.key))})}const fo=t=>t??localStorage.getItem("authToken")??"",fa={dashboard:{monthlyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentmonthlyReportgraph",weeklyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentweeklyReportgraph"},dropdowns:{classes:"api/branchapi/academy/classdropdownlist",sectionsByClass:"api/branchapi/academy/sectionoftheClass",sessions:"api/branchapi/generalSettings/sessiondropdown"},studentAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass",save:"api/studentAttendace/addattendencebyBranch",emergencyLeave:"api/StudentAttendace/emergency_leave"},dailyAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass"},monthlyReport:{table:"api/AttendenceReport/studentmonthlyAttendencebyclass",byStudent:"api/branchapi/student/getStududentMonthlyByIdUrlnew"},yearlyReport:{table:"api/AttendenceReport/studentyearlyAttendenceReport"}},Da=async(t,a)=>W(t,fo(a)),_j=async(t,a,n)=>Ze(t,a,fo(n)),Aj=async(t,a,n)=>gn(t,{arg:a},fo(n)),os=(t,a)=>{const n=new URLSearchParams;Object.entries(a??{}).forEach(([o,l])=>{l==null||l===""||n.set(o,String(l))});const r=t.includes("?")?"&":"?";return`${t}${r}${n.toString()}`},xd=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},Tj=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Su=(t,a)=>{const n=t?.data?.data??t?.data??t??{},r=a?n?.[a]:n;return Array.isArray(r)?r:Array.isArray(n?.student)?n.student:Array.isArray(n?.staff)?n.staff:Array.isArray(n?.data)?n.data:[]},Dj=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],kj=t=>{const a={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(n=>{if(Array.isArray(n?.monthly_data)||Array.isArray(n?.month_data)){Dj(n).forEach(o=>{const l=o?.[0]?.data?.[0]??o?.data?.[0]??o??{},d=String(l?.attendance_type??l?.attendence_type_id??"").toUpperCase();(d==="P"||d==="1")&&(a.present+=1),(d==="A"||d==="4")&&(a.absent+=1),(d==="L"||d==="3")&&(a.late+=1),(d==="LEAVE"||d==="2")&&(a.leave+=1)});return}const r=String(n?.attendance_type??n?.attendence_type_id??"").toUpperCase();(r==="P"||r==="1")&&(a.present+=1),(r==="A"||r==="4")&&(a.absent+=1),(r==="L"||r==="3")&&(a.late+=1),(r==="LEAVE"||r==="2")&&(a.leave+=1)}),a},go=(t,a)=>{const{data:n,isLoading:r,error:o}=q(a&&t?[t,a]:null,([l,d])=>Da(l,d));return{isLoading:r,error:o,data:n,options:i.useMemo(()=>Tj(n),[n])}},Ur=t=>go(fa.dropdowns.classes,t),Nr=(t,a)=>{const n=t?`${fa.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return go(n,a)},Rj=t=>go(fa.dropdowns.sessions,t),yo=t=>{const a=String(t??"").toUpperCase();return St(a==="1"||a==="P"||a==="PRESENT"?"P":a==="4"||a==="A"||a==="ABSENT"?"A":a==="3"||a==="L"||a==="LATE"?"L":a==="2"||a==="LEAVE"?"LEAVE":a==="W"?"W":a==="H"?"H":a||"-")},wu=(t,a,n)=>{const r=new Blob([t],{type:a}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.download=n,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},bd=t=>String(t??"").replace(/"/g,'""'),Ij=({rows:t,columns:a,fileName:n})=>{const r=Array.isArray(a)?a:[],o=Array.isArray(t)?t:[],l=r.map(c=>`"${bd(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,h)=>r.map(f=>{const p=f?.dataIndex??f?.selector??f?.key,m=p==="sl"?h+1:c?.[p];return`"${bd(m)}"`}).join(",")).join(`
|
|
61
|
+
`);wu([l,d].filter(Boolean).join(`
|
|
62
|
+
`),"text/csv;charset=utf-8;",n)},Pj=({value:t,fileName:a})=>{wu(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",a)};function vu({summary:t}){const a=[{key:"present",label:"Present",color:"#52c41a"},{key:"absent",label:"Absent",color:"#ff4d4f"},{key:"leave",label:"Leave",color:"#1677ff"}];return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:12},children:a.map(n=>e.jsxs(s.Card,{size:"small",styles:{body:{padding:12}},children:[e.jsx("div",{style:{fontSize:11,color:"#666",marginBottom:4},children:n.label}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:n.color},children:t?.[n.key]??0})]},n.key))})}function wn({summary:t,title:a="Attendance Overview"}){const n=i.useMemo(()=>[{key:"present",label:"Present",value:Number(t?.present??0),color:"#52c41a"},{key:"absent",label:"Absent",value:Number(t?.absent??0),color:"#ff4d4f"},{key:"leave",label:"Leave",value:Number(t?.leave??0),color:"#1677ff"}],[t]),r=Math.max(...n.map(o=>o.value),1);return e.jsx(s.Card,{size:"small",title:a,children:e.jsx("div",{style:{display:"grid",gap:8},children:n.map(o=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"80px 1fr 40px",gap:8,alignItems:"center"},children:[e.jsx("div",{style:{fontSize:11,color:"#444"},children:o.label}),e.jsx("div",{style:{height:10,background:"#f0f0f0",borderRadius:999},children:e.jsx("div",{style:{width:`${o.value/r*100}%`,height:"100%",background:o.color,borderRadius:999}})}),e.jsx("div",{style:{fontSize:11,fontWeight:600,textAlign:"right"},children:o.value})]},o.key))})})}function Mj(){const t=[{label:"Present",node:St("P")},{label:"Absent",node:St("A")},{label:"Late",node:St("L")},{label:"Weekly Off",node:St("W")},{label:"Holiday",node:St("H")}];return e.jsx(s.Space,{wrap:!0,size:[12,8],children:t.map(a=>e.jsxs(s.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:a.label}),a.node]},a.label))})}function ka({items:t}){const a=Array.isArray(t)?t.filter(n=>n?.value):[];return a.length?e.jsx(s.Space,{wrap:!0,size:[8,8],children:a.map(n=>e.jsxs(s.Tag,{color:"blue",children:[n.label,": ",n.value]},n.label))}):null}function zr({title:t,subtitle:a,printRef:n,exportRows:r,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:h,chartContent:f,reportTitle:p,reportExtra:m,children:v,fileBaseName:S="attendance"}){const y=Ka.useReactToPrint({content:()=>n?.current});return e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(s.Card,{size:"small",title:e.jsxs("div",{children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:t}),a?e.jsx(s.Typography.Text,{type:"secondary",style:{display:"block",marginTop:2,fontSize:12},children:a}):null]}),extra:e.jsx(Ma,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>Ij({rows:r,columns:o,fileName:`${S}.csv`}),onPrint:y,onDownload:()=>Pj({value:r,fileName:`${S}.json`}),onRefresh:l}),children:c}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:12,alignItems:"start"},children:[e.jsx(vu,{summary:h}),f===!1?null:f||e.jsx(wn,{summary:h})]}),e.jsx(s.Card,{size:"small",title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:p}),extra:m,styles:{body:{padding:0}},children:v})]})}const Ej=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function Oj({rows:t,loading:a,sunday:n,holiday:r,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(f,p)=>{const m=(Array.isArray(t)?t:[]).map((v,S)=>(v?.student_session_id??v?.student_id??v?.id??S)===f?{...v,...p}:v);l?.(m)},h=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(f,p,m)=>m+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(f,p)=>p?.full_name??p?.student_name??p?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(f,p,m)=>{const v=p?.student_session_id??p?.student_id??p?.id??m;return e.jsx(s.Select,{size:"small",style:{width:"100%"},options:Ej,value:String(f??"1"),onChange:S=>c(v,{attendence_type_id:S})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:f=>f?ne(f).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120},{title:"Emergency Leave",key:"emergency_leave",width:140,render:(f,p)=>e.jsx(s.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(re.ClockCircleOutlined,{}),onClick:()=>d?.(p),children:"E.L"})}],[d,t]);return n?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(f,p)=>String(f?.student_session_id??f?.student_id??f?.id??p),columns:h,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function $j({rows:t,loading:a,sunday:n,holiday:r,holidayTitle:o}){const l=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,h)=>h+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(d,c)=>c?.full_name??c?.student_name??c?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:120,render:d=>yo(d)},{title:"Date",dataIndex:"date",key:"date",width:120,render:d=>d?ne(d).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120}],[]);return n?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(d,c)=>String(d?.student_session_id??d?.student_id??d?.id??c),columns:l,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function Fj({data:t,loading:a,onViewStudent:n}){const r=t?.data??t??{},o=Array.isArray(r?.studentAttendance)?r.studentAttendance:Array.isArray(r?.students)?r.students:Array.isArray(r?.report)?r.report:Array.isArray(r?.data?.resultlist)?r.data.resultlist:Array.isArray(r?.resultlist)?r.resultlist:Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[],l=Array.isArray(r?.monthly_holiday)?r.monthly_holiday:[],d=Array.isArray(r?.dateSun)?r.dateSun:[],c=Number(r?.totalDaysMonth??0),h=i.useMemo(()=>{const f=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:20,fixed:"left"},{title:"Name",key:"student_name",fixed:"left",render:(p,m)=>e.jsx(s.Button,{type:"link",style:{padding:0},onClick:()=>n?.(m),children:m?.student_name??m?.full_name??"--"})}];return[...new Array(c).keys()].forEach(p=>{f.push({title:String(p+1),key:`day-${p+1}`,align:"center",render:(m,v)=>{const y=v?.[`${v?.student_id}_${o.indexOf(v)}`]?.[p]??{},g=y?.attendance_date,b=l.find(D=>D?.date===g);return d.includes(g)?Tl("sunday","W"):b?Tl("holiday","H"):yo(y?.attendence_type_id)}})}),f.push({title:"Total",key:"total",fixed:"right",render:(p,m)=>{let v=0,S=0,y=0;return[...new Array(c).keys()].forEach(g=>{const b=m?.[`${m?.student_id}_${o.indexOf(m)}`]?.[g]??{},D=String(b?.attendence_type_id??"");D==="1"&&(v+=1),D==="4"&&(S+=1),D==="3"&&(y+=1)}),e.jsxs("span",{children:["P: ",v," A: ",S," L: ",y]})}}),f},[l,n,o,d,c]);return e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(f,p)=>String(f?.student_id??p),columns:h,dataSource:o,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(s.Empty,{description:"No monthly report found"})}})}function Bj({open:t,onClose:a,loading:n,data:r,studentName:o}){const l=Array.isArray(r?.data?.report)?r.data.report:[],d=[{title:"Date",dataIndex:"attendance_date",key:"attendance_date",render:c=>c?ne(c).format("DD-MM-YYYY"):"--"},{title:"Status",key:"status",render:(c,h)=>yo(h?.attendence_type_id??h?.attendance_type)},{title:"In Time",dataIndex:"intime",key:"intime"},{title:"Out Time",dataIndex:"outtime",key:"outtime"},{title:"Remark",dataIndex:"remark",key:"remark"}];return e.jsx(s.Modal,{open:t,onCancel:a,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(c,h)=>String(c?.attendance_date??h),columns:d,dataSource:l,loading:n,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function Lj({open:t,onClose:a,onSubmit:n,loading:r}){const[o,l]=s.Modal.useModal(),[d,c]=i.useState(null),[h,f]=i.useState(""),p=async()=>{if(!d){await o.warning({title:"Select time"});return}await n?.({outtime:d.format("h:mm a"),message:h}),c(null),f("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(s.Modal,{title:"Emergency Leave",open:t,onCancel:a,onOk:p,confirmLoading:r,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Select Time"}),e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",value:d,onChange:c,style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Purpose"}),e.jsx(s.Input.TextArea,{rows:4,value:h,onChange:m=>f(m.target.value)})]})]})})]})}const Cu=t=>kj(t),jd=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.reduce((n,r)=>({present:n.present+Number(r?.present??r?.Present??r?.total_present??0),absent:n.absent+Number(r?.absent??r?.Absent??r?.total_absent??0),late:n.late+Number(r?.late??r?.Late??0),leave:n.leave+Number(r?.leave??r?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(a?.present??a?.Present??a?.total_present??0),absent:Number(a?.absent??a?.Absent??a?.total_absent??0),late:Number(a?.late??a?.Late??0),leave:Number(a?.leave??a?.Leave??0)}};function Uj({token:t}){const{data:a}=q(t?[fa.dashboard.monthlyGraph,t]:null,([l,d])=>Da(l,d)),{data:n}=q(t?[fa.dashboard.weeklyGraph,t]:null,([l,d])=>Da(l,d)),r=i.useMemo(()=>jd(a),[a]),o=i.useMemo(()=>jd(n),[n]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(s.Card,{children:[e.jsx(s.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(s.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(vu,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(wn,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(wn,{summary:o,title:"Weekly Attendance Chart"})]})]})}const _i=fa.studentAttendance,Nj={width:"100%",height:40};function zj({token:t}){const a=i.useRef(null),[n,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[h,f]=i.useState(""),[p,m]=i.useState(""),[v,S]=i.useState(""),[y,g]=i.useState(ne()),[b,D]=i.useState(0),[R,I]=i.useState([]),[A,_]=i.useState(!1),[u,x]=i.useState(null),[j,P]=i.useState(!1),[O,z]=i.useState(!1),k=Ur(t),F=Nr(n,t),C=i.useMemo(()=>!n||!d||b===0?null:os(_i.list,{cID:n,sID:d,batch_id:p,date:y.format("YYYY-MM-DD")}),[p,n,y,b,d]),{data:E,isLoading:M,mutate:U}=q(t&&C?[C,t]:null,([J,K])=>Da(J,K));i.useEffect(()=>{I(Su(E,"student"))},[E]);const Y=E?.data?.data??E?.data??E??{},V=!!Y?.sunday,L=!!Y?.holiday?.holiday,B=Y?.holiday?.title??"",$=i.useMemo(()=>Cu(R),[R]),N=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),H=async()=>{if(R.length)try{z(!0),await _j(_i.save,{attendenceData:R,date:y.format("YYYY-MM-DD"),holiday:A?"YES":"NO"},t),T.success("Student attendance saved."),U?.()}catch(J){T.error(J?.message??"Failed to save attendance.")}finally{z(!1)}},Q=async({outtime:J,message:K})=>{if(u?.attendence_id)try{P(!0),await Aj(_i.emergencyLeave,{outtime:J,message:K,id:u.attendence_id},t),T.success("Emergency leave updated."),x(null),U?.()}catch(Z){T.error(Z?.message??"Failed to update emergency leave.")}finally{P(!1)}},X=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ae,{options:k.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:J=>{r(J?.value??""),l(J?.label??""),c(""),f(""),m(""),S("")},required:!0}),e.jsx(ae,{options:F.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:J=>{c(J?.value??""),f(J?.label??""),m(""),S("")},required:!0},`section-${n}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{value:y,onChange:J=>J&&g(J),style:Nj,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>D(J=>J+1)})})]}),e.jsx(ka,{items:[{label:"Class",value:o},{label:"Section",value:h},{label:"Date",value:y.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(T.Toaster,{}),e.jsx(zr,{title:"Student Attendance",printRef:a,exportRows:R,exportColumns:N,onRefresh:()=>U?.(),filterSection:X,summary:$,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{size:"small",type:A?"primary":"default",onClick:()=>_(J=>!J),children:A?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"primary",onClick:H,loading:O,disabled:!R.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(da,{}),e.jsx(s.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(s.Card,{size:"small",style:{marginBottom:12},children:e.jsx(ka,{items:[{label:"Class",value:o},{label:"Section",value:h},{label:"Date",value:y.format("DD-MM-YYYY")}]})})]}),e.jsx(Oj,{rows:R,loading:M,sunday:V,holiday:L,holidayTitle:B,onChangeRows:I,onEmergency:x})]})}),e.jsx(Lj,{open:!!u,onClose:()=>x(null),onSubmit:Q,loading:j})]})}const qj=fa.dailyAttendance,Yj={width:"100%",height:40};function Wj({token:t}){const a=i.useRef(null),[n,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[h,f]=i.useState(""),[p,m]=i.useState(""),[v,S]=i.useState(""),[y,g]=i.useState(ne()),[b,D]=i.useState(0),R=Ur(t),I=Nr(n,t),A=i.useMemo(()=>!n||!d||b===0?null:os(qj.list,{cID:n,sID:d,batch_id:p,date:y.format("YYYY-MM-DD")}),[p,n,y,b,d]),{data:_,isLoading:u,mutate:x}=q(t&&A?[A,t]:null,([M,U])=>Da(M,U)),j=i.useMemo(()=>Su(_,"student"),[_]),P=_?.data?.data??_?.data??_??{},O=!!P?.sunday,z=!!P?.holiday?.holiday,k=P?.holiday?.title??"",F=i.useMemo(()=>Cu(j),[j]),C=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),E=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ae,{options:R.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{r(M?.value??""),l(M?.label??""),c(""),f(""),m(""),S("")},required:!0}),e.jsx(ae,{options:I.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{c(M?.value??""),f(M?.label??""),m(""),S("")},required:!0},`section-${n}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{value:y,onChange:M=>M&&g(M),style:Yj,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>D(M=>M+1)})})]}),e.jsx(ka,{items:[{label:"Class",value:o},{label:"Section",value:h},{label:"Date",value:y.format("DD-MM-YYYY")}]})]});return e.jsx(zr,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:a,exportRows:j,exportColumns:C,onRefresh:()=>x?.(),filterSection:E,summary:F,chartContent:e.jsx(wn,{summary:F,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(da,{}),e.jsx(ka,{items:[{label:"Class",value:o},{label:"Section",value:h},{label:"Date",value:y.format("DD-MM-YYYY")}]})]}),e.jsx($j,{rows:j,loading:u,sunday:O,holiday:z,holidayTitle:k})]})})}const Sd=fa.monthlyReport,_u=t=>Array.isArray(t?.studentAttendance)?t.studentAttendance:Array.isArray(t?.students)?t.students:Array.isArray(t?.report)?t.report:Array.isArray(t?.data?.resultlist)?t.data.resultlist:Array.isArray(t?.resultlist)?t.resultlist:Array.isArray(t?.data)?t.data:Array.isArray(t)?t:[],Vj=t=>{const a=_u(t),n=Number(t?.totalDaysMonth??0),r={present:0,absent:0,late:0,leave:0};return a.forEach((o,l)=>{[...new Array(n).keys()].forEach(d=>{const c=o?.[`${o?.student_id}_${l}`]?.[d]??{},h=String(c?.attendence_type_id??"");h==="1"&&(r.present+=1),h==="4"&&(r.absent+=1),h==="3"&&(r.late+=1),h==="2"&&(r.leave+=1)})}),r},Hj=t=>{const a=_u(t),n=Number(t?.totalDaysMonth??0);return a.map((r,o)=>{let l=0,d=0,c=0;return[...new Array(n).keys()].forEach(h=>{const f=r?.[`${r?.student_id}_${o}`]?.[h]??{},p=String(f?.attendence_type_id??"");p==="1"&&(l+=1),p==="4"&&(d+=1),p==="3"&&(c+=1)}),{roll_no:r?.roll_no??"",student_name:r?.student_name??r?.full_name??"",present:l,absent:d,late:c}})};function Kj({token:t}){const a=i.useRef(null),[n,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[h,f]=i.useState(""),[p,m]=i.useState(""),[v,S]=i.useState(""),[y,g]=i.useState(String(new Date().getFullYear())),[b,D]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[R,I]=i.useState(0),[A,_]=i.useState(null),u=Ur(t),x=Nr(n,t),j=i.useMemo(()=>mo(Number(y)),[y]),P=i.useMemo(()=>po(10),[]),O=i.useMemo(()=>!n||!d||!y||!b||R===0?null:os(Sd.table,{session:xd(),class_id:n,section_id:d,year:y,month:b,batch_id:p}),[p,n,b,R,d,y]),{data:z,isLoading:k,mutate:F}=q(t&&O?[O,t]:null,([$,N])=>Da($,N)),C=z?.data?.data??z?.data??z??{},E=i.useMemo(()=>Vj(C),[C]),M=i.useMemo(()=>Hj(C),[C]),U=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Name",dataIndex:"student_name"},{title:"Present",dataIndex:"present"},{title:"Absent",dataIndex:"absent"},{title:"Late",dataIndex:"late"}],[]),Y=i.useMemo(()=>A?.student_id?os(Sd.byStudent,{student_id:A.student_id,month:b,year:y,session:xd()}):null,[b,A,y]),{data:V,isLoading:L}=q(t&&Y?[Y,t]:null,([$,N])=>Da($,N)),B=e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12,alignItems:"end"},children:[e.jsx(ae,{options:u.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{r($?.value??""),l($?.label??""),c(""),f(""),m(""),S("")},required:!0}),e.jsx(ae,{options:x.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{c($?.value??""),f($?.label??""),m(""),S("")},required:!0},`section-${n}`),e.jsx(ae,{options:P,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:P.find($=>String($?.value)===String(y))??null,onChange:$=>g(String($?.value??"")),required:!0}),e.jsx(ae,{options:j,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:j.find($=>String($?.value)===String(b))??null,onChange:$=>D(String($?.value??"").padStart(2,"0")),required:!0},`month-${y}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>I($=>$+1)})})]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:12,alignItems:"center",justifyContent:"space-between"},children:[e.jsx(ka,{items:[{label:"Class",value:o},{label:"Section",value:h},{label:"Month",value:j.find($=>String($?.value)===String(b))?.label??b},{label:"Year",value:y}]}),e.jsx(Mj,{})]})]});return e.jsxs(e.Fragment,{children:[e.jsx(zr,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:a,exportRows:M,exportColumns:U,onRefresh:()=>F?.(),filterSection:B,summary:E,chartContent:e.jsx(wn,{summary:E,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(da,{}),e.jsx(ka,{items:[{label:"Class",value:o},{label:"Section",value:h},{label:"Month",value:j.find($=>String($?.value)===String(b))?.label??b},{label:"Year",value:y}]})]}),e.jsx(Fj,{data:C,loading:k,onViewStudent:_})]})}),e.jsx(Bj,{open:!!A,onClose:()=>_(null),loading:L,data:V,studentName:A?.student_name??A?.full_name})]})}const Gj=fa.yearlyReport,Jj=t=>{const a=t?.data?.data??t?.data??t??{};return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:Array.isArray(a?.students)?a.students:Array.isArray(a?.report)?a.report:Array.isArray(a?.resultlist)?a.resultlist:[]},Qj=t=>(Array.isArray(t)?t:[]).reduce((a,n)=>({present:a.present+Number(n?.singleStudentPresentData??n?.present??0),absent:a.absent+Number(n?.singleStudentAbsentData??n?.absent??0),late:a.late+Number(n?.late??0),leave:a.leave+Number(n?.leave??0)}),{present:0,absent:0,late:0,leave:0});function Xj({token:t}){const a=i.useRef(null),[n,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[h,f]=i.useState(""),[p,m]=i.useState(""),[v,S]=i.useState(""),[y,g]=i.useState(""),[b,D]=i.useState(""),[R,I]=i.useState(0),A=Ur(t),_=Nr(n,t),u=Rj(t),x=i.useMemo(()=>!n||!d||R===0?null:os(Gj.table,{class_id:n,section_id:d,session_id:p,batch_id:y}),[y,n,R,d,p]),{data:j,isLoading:P,mutate:O}=q(t&&x?[x,t]:null,([M,U])=>Da(M,U)),z=i.useMemo(()=>Jj(j),[j]),k=i.useMemo(()=>Qj(z),[z]),F=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),C=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(M,U,Y)=>Y+1},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",dataIndex:"full_name",key:"full_name"},{title:"Total Present",dataIndex:"singleStudentPresentData",key:"singleStudentPresentData",width:130},{title:"Total Absent",dataIndex:"singleStudentAbsentData",key:"singleStudentAbsentData",width:130}],[]),E=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ae,{options:A.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{r(M?.value??""),l(M?.label??""),c(""),f(""),g(""),D("")},required:!0}),e.jsx(ae,{options:_.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{c(M?.value??""),f(M?.label??""),g(""),D("")},required:!0},`section-${n}`),e.jsx(ae,{options:u.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{m(M?.value??""),S(M?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>I(M=>M+1)})})]}),e.jsx(ka,{items:[{label:"Class",value:o},{label:"Section",value:h},{label:"Session",value:v}]})]});return e.jsx(zr,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:a,exportRows:z,exportColumns:F,onRefresh:()=>O?.(),filterSection:E,summary:k,chartContent:e.jsx(wn,{summary:k,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(da,{}),e.jsx(ka,{items:[{label:"Class",value:o},{label:"Section",value:h},{label:"Session",value:v}]})]}),e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(M,U)=>String(M?.student_id??M?.id??U),columns:C,dataSource:z,loading:P,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}const Zj=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},Au=t=>{const a=ya(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},wd=(t,a)=>{const n=`${t||""}`.trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;const r=Au(a),o=n.startsWith("/")?n.slice(1):n;return Zj(ut(),`uploads/school_${r}/branch/income/${o}`)},eS=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.map(n=>({value:n?.value??n?.id??"",label:n?.label??n?.name??n?.income_category??n?.title??""})):[]};function tS({data:t}){const{handleUpdate:a,token:n}=t||{},r=i.useContext(ta),{isLoading:o,data:l}=q(n&&r?[`${ff}?id=${r}`,n]:null,([u,x])=>W(u,x)),{data:d}=q(n?[Vc,n]:null,([u,x])=>W(u,x)),c=i.useMemo(()=>eS(d),[d]),h=i.useMemo(()=>{if(Array.isArray(l))return l[0];const u=l?.data?.data??l?.data??l??{};return Array.isArray(u)?u[0]:u??{}},[l]),[f,p]=i.useState({income_head:"",name:"",invoice_no:"",date:ne(),amount:"",description:"",doc:""}),[m,v]=i.useState(!1),[S,y]=i.useState(!1),[g,b]=i.useState(""),[D,R]=i.useState(""),I=async u=>{u.preventDefault(),v(!0);try{await a(u,r)}finally{v(!1)}};i.useEffect(()=>{h&&p({income_head:h?.inc_head_id||"",name:h?.name||"",invoice_no:h?.invoice_no||"",date:h?.date?ne(h.date):ne(),amount:h?.amount||"",description:h?.note||"",doc:h?.documents||""})},[h]);const A=(u,x)=>{p(j=>({...j,[u]:x}))},_=c.find(u=>String(u.value)===String(f.income_head))??null;return o?e.jsx(w,{pt:4,pb:1,style:{width:550,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(s.Spin,{tip:"Loading..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:I,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Edit Income"})}),e.jsx(w,{p:2,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(G,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(ae,{label:"Income Head",options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0,value:_,onChange:u=>A("income_head",u?.value||"")})]})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"name",type:"text",label:"Name",required:!0,value:f.name,onChange:u=>A("name",u.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:f.invoice_no,onChange:u=>A("invoice_no",u.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",value:f.date,Desplay:"Date",name:"date",required:!0,onChange:u=>A("date",u)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"amount",type:"number",label:"Amount",required:!0,value:f.amount,onChange:u=>A("amount",u.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(kt,{name:"description",label:"Description",rows:3,value:f.description,onChange:u=>A("description",u.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.Upload,{action:`${ut()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${Au(n)}/branch/income`},headers:{Authorization:n},maxCount:1,onChange:u=>{if(u.file.status==="removed"&&A("doc",""),u.file.status==="done"){const x=u.file.response?.data??u.file.response?.file??"";A("doc",String(x??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:f.doc?"Change":"Upload"})},f.doc||"empty"),f.doc&&e.jsx("a",{href:wd(f.doc,n),target:"_blank",rel:"noreferrer",style:{display:"block",marginTop:8,fontSize:12,color:"#1677ff",textDecoration:"underline"},onClick:u=>{u.preventDefault(),b(wd(f.doc,n)),R(f.doc||"Document"),y(!0)},children:"View existing document"}),e.jsx("input",{type:"hidden",name:"doc",value:f.doc||"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:m?"Saving...":"Submit",color:"primary",disabled:m})})})})})]})})]})}),e.jsx(s.Modal,{open:S,onCancel:()=>{y(!1),b(""),R("")},footer:null,width:900,closable:!0,children:e.jsxs(w,{p:3,children:[e.jsx(w,{mb:2,children:e.jsx(he,{level:5,children:D||"View Document"})}),g?g.match(/\.pdf(?:[?#]|$)/i)?e.jsx("iframe",{src:g,title:D||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:g,alt:D||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(he,{children:"No document found"})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const aS=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},nS=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},vd=t=>{const a=ya(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}};function sS({token:t}){const[a,n]=i.useState([]),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,h]=i.useState({income_head:"",name:"",invoice_no:"",date:ne().format("YYYY-MM-DD"),amount:"",description:"",doc:""}),[f,p]=i.useState(!1),[m,v]=i.useState({page:1,rowsPerPage:10}),S=(k,F)=>{v({...m,page:k,rowsPerPage:parseInt(F,10)})},y=async(k,F)=>{try{await R(Ze(k,F,t),pt(F)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{T.error("Failed to add the new item.",{duration:1e3})}},{isLoading:g,error:b,data:D,mutate:R}=q(t?[of,t,m.page,m.rowsPerPage]:null,([k,F,C,E])=>W(`${k}?page=${C}&per_page=${E}`,F)),I=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0},{id:"3",name:"Income Category",selector:"income_category",sortable:!0},{id:"4",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"5",name:"Date",selector:"date",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0},{id:"8",name:"File",selector:"documents",sortable:!1,render:k=>{const F=vd(t),C=k?/^https?:\/\//i.test(k)?k:nS(ut(),`uploads/school_${F}/branch/income/${k}`):null;return k?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>C&&window.open(C,"_blank"),children:"View"}):"Not Uploaded"}}],[t]),A=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],_=async k=>{try{await R(st(cf,k,t),ot(k)),T.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{T.error("Failed to delete the item.",{duration:1e3})}},u=async(k,F,C)=>{try{await R(ct(k,F,t)),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await C(null)}catch{T.error("Failed to update the item.",{duration:1e3})}},x=async(k,F)=>{k.preventDefault();const C=new FormData(k.target);await u(df,C,F),P(!1)},j=async k=>{if(k.preventDefault(),!k.target.date.value)T.error("Select required dates",{duration:1e3}),k.target?.date?.focus(),d("textDanger");else{const F=new FormData(k.target);await y(lf,F),k.target.reset(),o(""),h(C=>({...C,date:ne().format("YYYY-MM-DD")}))}},P=k=>{p(k)},{data:O}=q(t?[Vc,t]:null,([k,F])=>W(k,F)),z=i.useMemo(()=>aS(O),[O]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Add Income"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:j,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{label:"Income Head",options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",defaultValue:ne(),Desplay:"Date",name:"date",status:l===""?"":"error",classnme:l,onChange:()=>d("")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.Upload,{action:`${ut()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${vd(t)}/branch/income`},headers:{Authorization:t},maxCount:1,onChange:k=>{if(k.file.status==="removed"&&o(""),k.file.status==="done"){const F=k.file.response?.data??k.file.response?.file??"";o(String(F??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:r?"Change":"Upload"})},r||"empty"),e.jsx("input",{type:"hidden",name:"doc",value:r||"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(kt,{name:"description",label:"Description",rows:3})})}),e.jsx(s.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(s.Row,{justifyContent:"flex-end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:S,data:{newData:D,columns:I,action:!0,Loading:g,ActionView:A,error:b,editDesign:e.jsx(tS,{data:{handleUpdate:x,token:t}}),deleteTodoMutation:_,open:f,DrawerUpdate:P}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const Cd={width:"100%",height:40};function rS({token:t}){const[a,n]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(""),[c,h]=i.useState(""),[f,p]=i.useState(""),[m,v]=i.useState({page:1,rowsPerPage:10}),S=(A,_)=>{v({...m,page:A,rowsPerPage:parseInt(_,10)})},{isLoading:y,error:g,data:b,mutate:D}=q(t&&l?[l,t,m.page,m.rowsPerPage]:null,([A,_,u,x])=>W(`${A}page=${u}&per_page=${x}`,_)),R=i.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Income Category",selector:"income_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),I=()=>{if(!a){T.error("Select required dates",{duration:1e3}),h("textDanger");return}if(!r){T.error("Select required dates",{duration:1e3}),p("textDanger");return}const A=a.format("YYYY-MM-DD"),_=r.format("YYYY-MM-DD");d(`${yf}?from_date=${A}&to_date=${_}&`),v(u=>({...u,page:1}))};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Search Income"})}),e.jsx(w,{p:3,children:e.jsxs(s.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(s.DatePicker,{value:a,onChange:A=>{n(A),h("")},style:Cd,allowClear:!1})]})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(s.DatePicker,{value:r,onChange:A=>{o(A),p("")},style:Cd,allowClear:!1})]})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:I})})]})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:S,data:{newData:b,columns:R,action:!1,Loading:y,error:g,pageController:m}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function iS({data:t}){const{handleUpdate:a,token:n}=t||{},r=i.useContext(ta),{isLoading:o,data:l}=q(n&&r?[`${gf}?id=${r}`,n]:null,([S,y])=>W(S,y)),d=i.useMemo(()=>{if(Array.isArray(l))return l[0];const S=l?.data?.data??l?.data??l??{};return Array.isArray(S)?S[0]:S??{}},[l]),[c,h]=i.useState({incomehead:"",description:""}),[f,p]=i.useState(!1);i.useEffect(()=>{d&&h({incomehead:d?.income_category||d?.incomehead||"",description:d?.description||""})},[d]);const m=(S,y)=>{h(g=>({...g,[S]:y}))},v=async S=>{S.preventDefault(),p(!0);try{await a(S)}finally{p(!1)}};return o?e.jsx(w,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(s.Spin,{tip:"Loading..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:v,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(w,{children:[e.jsx(G,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(G,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:c.incomehead,onChange:S=>m("incomehead",S.target.value)})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:S=>m("description",S.target.value)})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justifyContent:"flex-end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:f?"Saving...":"Submit",color:"primary",disabled:f})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function oS({token:t}){const[a,n]=i.useState({incomehead:"",description:""}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,h]=i.useState({page:1,rowsPerPage:10}),f=(u,x)=>{h({...c,page:u,rowsPerPage:parseInt(x,10)})},p=async(u,x)=>{try{await y(Ze(u,x,t),pt(x)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{T.error("Failed to add the new item.",{duration:1e3})}},{isLoading:m,error:v,data:S,mutate:y}=q(t?[uf,t,c.page,c.rowsPerPage]:null,([u,x,j,P])=>W(`${u}?page=${j}&per_page=${P}`,x)),g=i.useMemo(()=>[{id:"1",name:"Name",selector:"income_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),b=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],D=async u=>{try{await y(st(hf,u,t),ot(u)),T.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{T.error("Failed to delete the item.",{duration:1e3})}},R=async(u,x)=>{try{await y(ct(u,x,t)),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{T.error("Failed to update the item.",{duration:1e3})}},I=async u=>{u.preventDefault();const x=new FormData(u.target);await R(mf,x),_(!1)},A=async u=>{u.preventDefault(),d(!0);try{await p(pf,new FormData(u.target)),n({incomehead:"",description:""})}finally{d(!1)}},_=u=>{o(u)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:5,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Income Head"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:A,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:a.incomehead,onChange:u=>n(x=>({...x,incomehead:u.target.value}))})})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:u=>n(x=>({...x,description:u.target.value}))})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justifyContent:"flex-end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:l?"Saving...":"Save",color:"primary",disabled:l})})})})})]})})})]})}),e.jsx(s.Col,{xs:24,md:19,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Income Head List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:f,data:{newData:S,columns:g,action:!0,Loading:m,ActionView:b,error:v,editDesign:e.jsx(iS,{data:{handleUpdate:I,token:t}}),deleteTodoMutation:D,open:r,DrawerUpdate:_}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const lS=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},Tu=t=>{const a=ya(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},_d=(t,a)=>{const n=`${t||""}`.trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;const r=Tu(a),o=n.startsWith("/")?n.slice(1):n;return lS(ut(),`uploads/school_${r}/branch/expense/${o}`)},Ad=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.map(n=>({value:n?.value??n?.id??"",label:n?.label??n?.name??n?.exp_category??n?.vendor_name??n?.title??""})):[]},Td=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function dS({data:t}){const{handleUpdate:a,token:n}=t||{},r=i.useContext(ta),{isLoading:o,data:l}=q(n&&r?[`${Af}?id=${r}`,n]:null,([O,z])=>W(O,z)),{data:d}=q(n?[Hc,n]:null,([O,z])=>W(O,z)),{data:c}=q(n?[Kc,n]:null,([O,z])=>W(O,z)),h=i.useMemo(()=>Ad(d),[d]),f=i.useMemo(()=>Ad(c),[c]),p=i.useMemo(()=>{if(Array.isArray(l))return l[0];const O=l?.data?.data??l?.data??l??{};return Array.isArray(O)?O[0]:O??{}},[l]),[m,v]=i.useState(!1),[S,y]=i.useState(!1),[g,b]=i.useState(""),[D,R]=i.useState(""),I=async O=>{O.preventDefault(),v(!0);try{await a(O,r)}finally{v(!1)}},[A,_]=i.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:ne(),amount:"",payment_mode:"",note:"",doc:""});i.useEffect(()=>{p&&_({expense_head:p?.exp_head_id||"",vendor:p?.fk_vendor_id||"",name:p?.name||"",invoice_no:p?.invoice_no||"",date:p?.date?ne(p.date):ne(),amount:p?.amount||"",payment_mode:p?.payment_mode||"",note:p?.note||"",doc:p?.documents||""})},[p]);const u=(O,z)=>{_(k=>({...k,[O]:z}))},x=h.find(O=>String(O.value)===String(A.expense_head))??null,j=f.find(O=>String(O.value)===String(A.vendor))??null,P=Td.find(O=>String(O.value)===String(A.payment_mode))??null;return o?e.jsx(w,{pt:4,pb:1,style:{width:550,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(s.Spin,{tip:"Loading..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:I,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Edit Expense"})}),e.jsx(w,{p:2,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(G,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(ae,{label:"Expense Head",options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0,value:x,onChange:O=>u("expense_head",O?.value||"")})]})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{label:"Vendor",options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor",value:j,onChange:O=>u("vendor",O?.value||"")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"name",type:"text",label:"Name",required:!0,value:A.name,onChange:O=>u("name",O.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:A.invoice_no,onChange:O=>u("invoice_no",O.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",value:A.date,Desplay:"Date",name:"date",required:!0,onChange:O=>u("date",O)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"amount",type:"number",label:"Amount",required:!0,value:A.amount,onChange:O=>u("amount",O.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{label:"Payment Mode",options:Td,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0,value:P,onChange:O=>u("payment_mode",O?.value||"")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(kt,{name:"note",label:"Description",rows:3,value:A.note,onChange:O=>u("note",O.target.value)})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.Upload,{action:`${ut()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${Tu(n)}/branch/expense`},headers:{Authorization:n},maxCount:1,onChange:O=>{if(O.file.status==="removed"&&u("doc",""),O.file.status==="done"){const z=O.file.response?.data??O.file.response?.file??"";u("doc",String(z??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:A.doc?"Change":"Upload"})}),A.doc&&e.jsx("a",{href:_d(A.doc,n),target:"_blank",rel:"noreferrer",style:{display:"block",marginTop:8,fontSize:12,color:"#1677ff",textDecoration:"underline"},onClick:O=>{O.preventDefault(),b(_d(A.doc,n)),R(A.doc||"Document"),y(!0)},children:"View existing document"}),e.jsx("input",{type:"hidden",name:"doc",value:A.doc||"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:m?"Saving...":"Submit",color:"primary",disabled:m})})})})})]})})]})}),e.jsx(s.Modal,{open:S,onCancel:()=>{y(!1),b(""),R("")},footer:null,width:900,closable:!0,children:e.jsxs(w,{p:3,children:[e.jsx(w,{mb:2,children:e.jsx(he,{level:5,children:D||"View Document"})}),g?g.match(/\.pdf(?:[?#]|$)/i)?e.jsx("iframe",{src:g,title:D||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:g,alt:D||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(he,{children:"No document found"})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Dd=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},cS=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},Du=t=>{const a=ya(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},uS=(t,a)=>{const n=`${t||""}`.trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;const r=Du(a),o=n.startsWith("/")?n.slice(1):n;return cS(ut(),`uploads/school_${r}/branch/expense/${o}`)},pS=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function mS({token:t}){const[a,n]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:ne(),amount:"",payment_mode:"",note:"",doc:""}),[c,h]=i.useState(!1),[f,p]=i.useState(!1),[m,v]=i.useState({page:1,rowsPerPage:10}),S=(C,E)=>{v({...m,page:C,rowsPerPage:parseInt(E,10)})},y=async(C,E)=>{try{await Ze(C,E,t),R(),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{T.error("Failed to add the new item.",{duration:1e3})}},{isLoading:g,error:b,data:D,mutate:R}=q(t?[xf,t,m.page,m.rowsPerPage]:null,([C,E,M,U])=>W(`${C}?page=${M}&per_page=${U}`,E)),I=i.useMemo(()=>[{title:"Sl No",dataIndex:"__serialNumber",key:"sl",sorter:(C,E)=>(C.__serialNumber??0)-(E.__serialNumber??0)},{title:"Name",dataIndex:"name",key:"name",sorter:(C,E)=>String(C.name??"").localeCompare(String(E.name??""))},{title:"Description",dataIndex:"description",key:"description"},{title:"Expense Category",dataIndex:"exp_category",key:"exp_category"},{title:"Invoice No",dataIndex:"invoice_no",key:"invoice_no"},{title:"Note",dataIndex:"note",key:"note"},{title:"Amount",dataIndex:"amount",key:"amount"},{title:"File",dataIndex:"documents",key:"documents",render:(C,E)=>C?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>window.open(uS(C,t),"_blank"),children:"View"}):"Not Uploaded"}],[t]),A=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],_=async C=>{try{await st(Sf,C,t),R(),T.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{T.error("Failed to delete the item.",{duration:1e3})}},u=async(C,E,M)=>{try{await R(ct(C,E,t)),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await M(null)}catch{T.error("Failed to update the item.",{duration:1e3})}},x=async(C,E)=>{C.preventDefault();const M=new FormData(C.target);await u(jf,M,E),P(!1)},j=async C=>{if(C.preventDefault(),!C.target.date.value)T.error("Select required dates",{duration:1e3}),C.target?.date?.focus(),o("textDanger");else{const E=new FormData(C.target);p(!0);try{await y(bf,E)}finally{p(!1)}C.target.reset(),d(M=>({...M,date:ne()})),n("")}},P=C=>{h(C)},{data:O}=q(t?[Hc,t]:null,([C,E])=>W(C,E)),{data:z}=q(t?[Kc,t]:null,([C,E])=>W(C,E)),k=i.useMemo(()=>Dd(O),[O]),F=i.useMemo(()=>Dd(z),[z]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Add Expense"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:j,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{label:"Expense Head",options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{label:"Vendor",options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor"})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD",defaultValue:ne(),Desplay:"Date",name:"date",status:r===""?"":"error",classnme:r,onChange:()=>o("")})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(G,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(ae,{label:"Payment Mode",options:pS,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx(w,{children:e.jsx(kt,{name:"note",label:"Description",rows:3})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsxs(w,{children:[e.jsx(s.Upload,{action:`${ut()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${Du(t)}/branch/expense`},headers:{Authorization:t},maxCount:1,onChange:C=>{if(C.file.status==="removed"&&n(""),C.file.status==="done"){const E=C.file.response?.data??C.file.response?.file??"";n(String(E??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:a||"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(s.Row,{justifyContent:"flex-end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:f?"Saving...":"Save",color:"primary",disabled:f})})})})})]})})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:S,data:{newData:D,columns:I,columnstype:"antd",action:!0,Loading:g,ActionView:A,error:b,editDesign:e.jsx(dS,{data:{handleUpdate:x,token:t}}),deleteTodoMutation:_,open:c,DrawerUpdate:P}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const hS=[{label:"Paid to",key:"vendor_name"},{label:"Address",key:"address"},{label:"GST Number",key:"gst"},{label:"Bussiness Name",key:"business_name"}],fS=[{label:"Date",key:"date"},{label:"Voucher Number",key:"voucher_number"},{label:"Payment Mode",key:"payment_mode"}];function gS({onClick:t}){return e.jsx(s.Button,{type:"primary",icon:e.jsx(re.PrinterOutlined,{}),onClick:t,children:"Print"})}function yS({data:t}){const a=i.useMemo(()=>{if(!t)return null;if(Array.isArray(t))return t[0];const n=t?.data?.data??t?.data??t??{};return Array.isArray(n)?n[0]:n},[t]);return e.jsx("div",{style:{width:"100%"},children:e.jsxs("div",{style:{border:"1px solid ",margin:"5px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",flexDirection:"column",justifyContent:"center",borderBottom:"1px solid black",fontWeight:"bold",padding:"10px",backgroundColor:"#dfdfdf",fontSize:"18px"},children:"Expense Voucher"}),e.jsx("div",{style:{width:"100%",display:"flex",justifyContent:"center",borderBottom:"1px solid black"},children:e.jsx("div",{style:{width:"90%"},children:e.jsx(da,{})})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(s.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(s.Col,{xs:12,style:{borderRight:"1px solid black",display:"flex",alignItems:"flex-start",flexDirection:"column"},children:hS.map((n,r)=>e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("span",{style:{fontWeight:"bold"},children:n.label}),":"," ",a?.[n.key]]},`vendor${r}`))}),e.jsx(s.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:fS.map((n,r)=>e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("span",{style:{fontWeight:"bold"},children:n.label}),":"," ",a?.[n.key]]},`payment${r}`))})]})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(s.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(s.Col,{xs:12,style:{borderRight:"1px solid black",display:"flex",alignItems:"flex-start",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:"Description"}),":"," ",a?.note]})}),e.jsx(s.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsx("div",{children:e.jsx("span",{style:{fontWeight:"bold"},children:"Amount"})})})]})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(s.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(s.Col,{xs:12,style:{borderRight:"1px solid black",display:"flex",alignItems:"flex-start",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:a?.name})," "]})}),e.jsx(s.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsx("div",{children:a?.amount})})]})}),e.jsx("div",{style:{width:"100%",borderBottom:"1px solid black"},children:e.jsxs(s.Row,{style:{paddingLeft:4,paddingRight:4},children:[e.jsx(s.Col,{xs:12,style:{paddingRight:4,borderRight:"1px solid black",display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:"Total"})," "]})}),e.jsx(s.Col,{xs:12,style:{display:"flex",alignItems:"flex-end",flexDirection:"column"},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"bold"},children:a?.amount})," "]})})]})}),e.jsx("div",{style:{width:"100%",height:"75px",display:"flex",alignItems:"flex-end"},children:e.jsxs(s.Row,{style:{paddingLeft:4,paddingRight:4},justify:"flex-end",align:"flex-end",children:[e.jsx(s.Col,{xs:4,style:{borderTop:"1px solid gray",display:"flex",justifyContent:"center"},children:"Approved by"}),e.jsx(s.Col,{xs:1}),e.jsx(s.Col,{xs:4,style:{borderTop:"1px solid gray",display:"flex",justifyContent:"flex-end"},children:"Signature"})]})})]})})}function xS({token:t}){const a=i.useMemo(()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("id")??null,[]),n=i.useRef(null),r=Ka.useReactToPrint({content:()=>n.current}),{isLoading:o,data:l,error:d}=q(t&&a?[Tf,a,t]:null,([c,h,f])=>W(`${c}?id=${h}`,f));return e.jsx(w,{pt:4,pb:1,children:e.jsx(s.Row,{gutter:[16,16],children:e.jsx(s.Col,{xs:24,children:e.jsx("div",{style:{width:"75%"},className:"container",children:e.jsx("div",{className:"row",children:e.jsx("div",{className:"col-lg-12",children:e.jsxs("div",{className:"card",ref:n,children:[e.jsx("div",{style:{width:"100%",display:"flex"},children:o?e.jsx("div",{style:{padding:40,textAlign:"center"},children:e.jsx(s.Spin,{tip:"Loading..."})}):d?e.jsx("div",{style:{padding:40,textAlign:"center"},children:"Error loading data"}):l?.Status==="Success"?e.jsx(yS,{data:l}):e.jsx("div",{style:{padding:40,textAlign:"center"},children:"No Data Found"})}),e.jsxs("div",{className:"d-print-none mt-4",children:[e.jsx("div",{className:"float-end",children:e.jsx(gS,{onClick:r})}),e.jsx("div",{className:"float-end",style:{marginRight:"2%"},children:e.jsx(s.Button,{type:"text",onClick:()=>window.history.back(),children:"Back"})})]})]})})})})})})})}const kd={width:"100%",height:40};function bS({token:t}){const[a,n]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(""),[c,h]=i.useState(""),[f,p]=i.useState(""),[m,v]=i.useState({page:1,rowsPerPage:10}),S=(A,_)=>{v({...m,page:A,rowsPerPage:parseInt(_,10)})},{isLoading:y,error:g,data:b,mutate:D}=q(t&&l?[l,t,m.page,m.rowsPerPage]:null,([A,_,u,x])=>W(`${A}page=${u}&per_page=${x}`,_)),R=i.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Expense Category",selector:"exp_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),I=()=>{if(!a){T.error("Select required dates",{duration:1e3}),h("textDanger");return}if(!r){T.error("Select required dates",{duration:1e3}),p("textDanger");return}const A=a.format("YYYY-MM-DD"),_=r.format("YYYY-MM-DD");d(`${kf}?from_date=${A}&to_date=${_}&`),v(u=>({...u,page:1}))};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Search Expense"})}),e.jsx(w,{p:3,children:e.jsxs(s.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(s.DatePicker,{value:a,onChange:A=>{n(A),h("")},style:kd,allowClear:!1})]})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(s.DatePicker,{value:r,onChange:A=>{o(A),p("")},style:kd,allowClear:!1})]})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:I})})]})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:S,data:{newData:b,columns:R,action:!1,Loading:y,error:g,pageController:m}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function jS({data:t}){const{handleUpdate:a,token:n}=t||{},r=i.useContext(ta),{isLoading:o,data:l}=q(n&&r?[`${Df}?id=${r}`,n]:null,([S,y])=>W(S,y)),d=i.useMemo(()=>{if(Array.isArray(l))return l[0];const S=l?.data?.data??l?.data??l??{};return Array.isArray(S)?S[0]:S??{}},[l]),[c,h]=i.useState({expensehead:"",description:""}),[f,p]=i.useState(!1);i.useEffect(()=>{d&&h({expensehead:d?.exp_category||d?.expensehead||"",description:d?.description||""})},[d]);const m=(S,y)=>{h(g=>({...g,[S]:y}))},v=async S=>{S.preventDefault(),p(!0);try{await a(S)}finally{p(!1)}};return o?e.jsx(w,{pt:4,pb:1,style:{width:350,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(s.Spin,{tip:"Loading..."})}):e.jsxs(w,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:v,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(w,{children:[e.jsx(G,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(G,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:c.expensehead,onChange:S=>m("expensehead",S.target.value)})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:S=>m("description",S.target.value)})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justifyContent:"flex-end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:f?"Saving...":"Submit",color:"primary",disabled:f})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function SS({token:t}){const[a,n]=i.useState({expensehead:"",description:""}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,h]=i.useState({page:1,rowsPerPage:10}),f=(u,x)=>{h({...c,page:u,rowsPerPage:parseInt(x,10)})},p=async(u,x)=>{try{await y(Ze(u,x,t),pt(x)),T.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{T.error("Failed to add the new item.",{duration:1e3})}},{isLoading:m,error:v,data:S,mutate:y}=q(t?[wf,t,c.page,c.rowsPerPage]:null,([u,x,j,P])=>W(`${u}?page=${j}&per_page=${P}`,x)),g=i.useMemo(()=>[{id:"1",name:"Name",selector:"exp_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),b=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],D=async u=>{try{await y(st(_f,u,t),ot(u)),T.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{T.error("Failed to delete the item.",{duration:1e3})}},R=async(u,x)=>{try{await y(ct(u,x,t)),T.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{T.error("Failed to update the item.",{duration:1e3})}},I=async u=>{u.preventDefault();const x=new FormData(u.target);await R(Cf,x),_(!1)},A=async u=>{u.preventDefault(),d(!0);try{await p(vf,new FormData(u.target)),n({expensehead:"",description:""})}finally{d(!1)}},_=u=>{o(u)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:5,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head"})}),e.jsx(w,{p:3,children:e.jsx("form",{onSubmit:A,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:a.expensehead,onChange:u=>n(x=>({...x,expensehead:u.target.value}))})})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(G,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:u=>n(x=>({...x,description:u.target.value}))})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justifyContent:"flex-end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:l?"Saving...":"Save",color:"primary",disabled:l})})})})})]})})})]})}),e.jsx(s.Col,{xs:24,md:19,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:f,data:{newData:S,columns:g,action:!0,Loading:m,ActionView:b,error:v,editDesign:e.jsx(jS,{data:{handleUpdate:I,token:t}}),deleteTodoMutation:D,open:r,DrawerUpdate:_}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function wS({token:t}){const[a,n]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,h]=i.useState(0),[f,p]=i.useState(""),[m,v]=i.useState({page:1,rowsPerPage:10}),S=(P,O)=>{v({...m,page:P,rowsPerPage:parseInt(O,10)})},{isLoading:y,error:g,data:b,mutate:D}=q(t&&f?[f,t,m.page,m.rowsPerPage]:null,([P,O,z,k])=>W(`${P}page=${z}&per_page=${k}`,O)),{data:R}=q(t?[oa,t]:null,([P,O])=>W(P,O)),{data:I}=q(t&&a?[`${la}?class_id=${a}`,t]:null,([P,O])=>W(P,O)),A=i.useMemo(()=>R?Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[]:[],[R]),_=i.useMemo(()=>I?Array.isArray(I)?I:Array.isArray(I?.data)?I.data:[]:[],[I]),u=i.useMemo(()=>[{id:"1",name:"First Name",selector:"firstname",sortable:!0},{id:"2",name:"Last Name",selector:"lastname",sortable:!0},{id:"3",name:"Class",selector:"class",sortable:!0},{id:"4",name:"Section",selector:"section",sortable:!0},{id:"5",name:"ID",selector:"username",sortable:!0},{id:"6",name:"Password",selector:"password",sortable:!0}],[]),x=P=>{n(P?.value||""),o(""),h(O=>O+1)},j=P=>{if(P.preventDefault(),!a){T.error("Please select class",{duration:1e3});return}if(!r){T.error("Please select section",{duration:1e3});return}const O=`${Rf}?class_id=${a}§ion_id=${r}&keyword=${l||""}&`;p(O),v(z=>({...z,page:1}))};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Student Login Credential"})}),e.jsx(w,{p:3,children:e.jsxs(s.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{label:"Class",options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:A.find(P=>String(P.value)===String(a))??null,onChange:x})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{label:"Section",options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:_.find(P=>String(P.value)===String(r))??null,onChange:P=>o(P?.value||"")})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(G,{name:"keyword",type:"text",label:"Search By Keyword",value:l,onChange:P=>d(P.target.value)})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:j})})]})})]})}),f&&e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:S,data:{newData:b,columns:u,action:!1,Loading:y,error:g,pageController:m}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function vS({token:t}){const[a,n]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,h]=i.useState(0),[f,p]=i.useState(Gc),[m,v]=i.useState(!1),[S,y]=i.useState(null);console.log("Selected Student ID:",m);const[g,b]=i.useState({page:1,rowsPerPage:10}),D=(E,M)=>{b({...g,page:E,rowsPerPage:parseInt(M,10)})},{isLoading:R,error:I,data:A,mutate:_}=q(t&&f?[f,t,g.page,g.rowsPerPage]:null,([E,M,U,Y])=>W(`${E}page=${U}&per_page=${Y}`,M)),{data:u}=q(t?[oa,t]:null,([E,M])=>W(E,M)),{data:x}=q(t&&a?[`${la}?class_id=${a}`,t]:null,([E,M])=>W(E,M)),j=i.useMemo(()=>u?Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]:[],[u]),P=i.useMemo(()=>x?Array.isArray(x)?x:Array.isArray(x?.data)?x.data:[]:[],[x]),O=i.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Medicine",selector:"Medical",sortable:!1,render:(E,M)=>e.jsx(s.Button,{type:"primary",size:"small",onClick:()=>{y(M.id),v(!0)},children:"Medical"})}],[]),z=E=>{n(E?.value||""),o(""),h(M=>M+1)},k=E=>{if(E.preventDefault(),!a||!r){T.error("Please select class and section",{duration:1e3});return}const M=`${Qc}?cID=${a}&sID=${r}&page=${g.page}&per_page=${g.rowsPerPage}&`;p(M),b(U=>({...U,page:1}))},F=E=>{E.preventDefault();const M=E.target.searchField?.value||"";d(M);const U=`${Jc}?key=${M}&page=${g.page}&per_page=${g.rowsPerPage}&`;p(U),b(Y=>({...Y,page:1}))},C=async E=>{E.preventDefault();const M=new FormData(E.target),U=If;try{await _(addData(U,M,t)),T.success("Medicine added successfully",{duration:1e3}),E.target.reset()}catch{T.error("Failed to add medicine",{duration:1e3})}};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Medical Report"})}),e.jsx(w,{p:3,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:k,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(ae,{label:"Class",options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:j.find(E=>String(E.value)===String(a))??null,onChange:z})})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(ae,{label:"Section",options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:P.find(E=>String(E.value)===String(r))??null,onChange:E=>o(E?.value||"")})})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:F,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:16,children:e.jsx(G,{name:"searchField",type:"text",label:"Search By Keyword",value:l,onChange:E=>d(E.target.value)})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(de,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:D,data:{newData:A,columns:O,action:!1,Loading:R,error:I,pageController:g}})})]})})]}),e.jsx(s.Drawer,{title:"Medical Report",placement:"right",width:600,open:m,footer:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsx(de,{type:"button",value:"Close",color:"default"})})}),children:e.jsx(CS,{studentId:S,token:t,onAddMedicine:C})}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function CS({studentId:t,token:a,onAddMedicine:n}){const{data:r}=q(a&&t?[`${Xc}?id=${t}`,a]:null,([h,f])=>W(h,f)),{data:o}=q(a&&t?[`${Pf}?student_id=${t}`,a]:null,([h,f])=>W(h,f)),l=r?.studentBasicDetails?.[0];let d=[];Array.isArray(o?.data)?d=o.data:Array.isArray(o)&&(d=o);const c=[{title:"Medicine",dataIndex:"medicine",key:"medicine"},{title:"Notes",dataIndex:"notes",key:"notes"},{title:"Date",dataIndex:"date_time",key:"date_time"}];return e.jsxs(w,{children:[l&&e.jsxs(w,{mb:3,children:[e.jsxs(he,{level:4,children:["Name: ",l?.firstname," ",l?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",l?.class," (",l?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",l?.admission_no]})]}),e.jsx(he,{level:5,style:{marginBottom:8},children:"Add Medicine"}),e.jsx("form",{onSubmit:n,style:{marginBottom:24},children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(w,{children:[e.jsx(G,{name:"medicine",type:"text",label:"Medicine Name",required:!0}),e.jsx("input",{name:"student_id",type:"hidden",value:t||"",readOnly:!0})]})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(kt,{name:"notes",label:"Note",rows:3})})}),e.jsx(s.Col,{xs:24,children:e.jsx(w,{children:e.jsx(Ge,{format:"YYYY-MM-DD HH:mm",Desplay:"Date",name:"date_time",defaultValue:ne()})})}),e.jsx(s.Col,{xs:24,children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Add",color:"primary"})})})})})]})}),e.jsx(he,{level:5,style:{marginBottom:8},children:"Previous Medicine"}),e.jsx(s.Table,{size:"small",dataSource:d,pagination:!1,columns:c})]})}const{Group:Rd}=s.Checkbox;function _S({token:t}){const[a,n]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,h]=i.useState(0),[f,p]=i.useState(Gc),[m,v]=i.useState(!1),[S,y]=i.useState(null),[g,b]=i.useState({page:1,rowsPerPage:10}),D=(U,Y)=>{b({...g,page:U,rowsPerPage:parseInt(Y,10)})},{isLoading:R,error:I,data:A,mutate:_}=q(t&&f?[f,t,g.page,g.rowsPerPage]:null,([U,Y,V,L])=>W(`${U}page=${V}&per_page=${L}`,Y)),{data:u}=q(t?[oa,t]:null,([U,Y])=>W(U,Y)),{data:x}=q(t&&a?[`${la}?class_id=${a}`,t]:null,([U,Y])=>W(U,Y)),j=i.useMemo(()=>u?Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]:[],[u]),P=i.useMemo(()=>x?Array.isArray(x)?x:Array.isArray(x?.data)?x.data:[]:[],[x]),O=i.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Assign Subject",selector:"Assign",sortable:!1,render:(U,Y)=>e.jsx(s.Button,{type:"primary",size:"small",onClick:()=>{y(Y.id),v(!0)},children:"Assign"})}],[]),z=U=>{n(U?.value||""),o(""),h(Y=>Y+1)},k=U=>{if(U.preventDefault(),!a||!r){T.error("Please select class and section",{duration:1e3});return}const Y=`${Qc}?cID=${a}&sID=${r}&page=${g.page}&per_page=${g.rowsPerPage}&`;p(Y),b(V=>({...V,page:1}))},F=U=>{U.preventDefault();const Y=U.target.searchField?.value||"";d(Y);const V=`${Jc}?key=${Y}&page=${g.page}&per_page=${g.rowsPerPage}&`;p(V),b(L=>({...L,page:1}))},C=async U=>{U.preventDefault();const Y=new FormData(U.target),V=Ef;try{await _(ct(V,Y,t)),T.success("Subject updated successfully",{duration:1e3}),U.target.reset(),v(!1)}catch{T.error("Failed to update subject",{duration:1e3})}},E=async U=>{U.preventDefault();const Y=new FormData(U.target),V=Hi;try{await _(ct(V,Y,t)),T.success("Extra curricular updated successfully",{duration:1e3}),U.target.reset(),v(!1)}catch{T.error("Failed to update extra curricular",{duration:1e3})}},M=U=>{v(U)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Assign Student Subject"})}),e.jsx(w,{p:3,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:k,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(ae,{label:"Class",options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:j.find(U=>String(U.value)===String(a))??null,onChange:z})})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(w,{children:e.jsx(ae,{label:"Section",options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:P.find(U=>String(U.value)===String(r))??null,onChange:U=>o(U?.value||"")})})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:F,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:16,children:e.jsx(G,{name:"searchField",type:"text",label:"Search By Keyword",value:l,onChange:U=>d(U.target.value)})}),e.jsx(s.Col,{xs:24,md:8,children:e.jsx(de,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(w,{pt:3,children:e.jsx(Ke,{parentCallback:D,data:{newData:A,columns:O,action:!1,Loading:R,error:I,pageController:g}})})]})})]}),m&&e.jsx(AS,{open:m,DrawerUpdate:M,studentId:S,token:t,onUpdate:C,onUpdate2:E}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function AS({open:t,DrawerUpdate:a,studentId:n,token:r,onUpdate:o,onUpdate2:l}){const[d,c]=i.useState([]),[h,f]=i.useState([]),[p,m]=i.useState([]),[v,S]=i.useState(!1),[y,g]=i.useState([]),[b,D]=i.useState([]),[R,I]=i.useState([]),{trigger:A}=it(Xc,async(O,{arg:z})=>await W(`${O}?id=${z.id}`,r)),{trigger:_}=it(Hi,async()=>await W(`${Hi}?student_id=${n}`,r)),{trigger:u}=it(Mf,async(O,{arg:z})=>await W(`${O}?id=${z.id}`,r));i.useEffect(()=>{(async()=>{if(!n)return;S(!0);const z=await A({id:n});z?.studentBasicDetails?.[0];const k=await _(),F=await u({id:n});c(z),m(F),z&&f(k),S(!1)})()},[n,A,_,u]);const x=O=>{D(O);const z=d?.data?.filter(k=>!O.includes(k.value));g(JSON.stringify(z))},j=O=>{I(O)},P=d?.studentBasicDetails?.[0];return!v&&n?e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsxs(w,{p:3,children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Edit Assigned Subjects"})}),e.jsxs(w,{p:3,children:[P&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs(he,{level:4,children:["Name: ",P?.firstname," ",P?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",P?.class," (",P?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",P?.admission_no]})]}),e.jsx("form",{onSubmit:o,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsxs(s.Col,{xs:24,children:[e.jsx(he,{level:5,children:"Subjects"}),e.jsx(Rd,{options:d?.data?.map(O=>({label:O.label||O.name,value:O.value})),value:b,onChange:x,style:{display:"grid",gap:8}})]}),e.jsxs(s.Col,{xs:24,children:[e.jsx("input",{name:"student_id",type:"hidden",value:n||"",readOnly:!0}),e.jsx("input",{name:"subjectUncheck[]",type:"hidden",value:y,readOnly:!0})]}),d?.data?.length===0?e.jsx(s.Col,{xs:24,children:e.jsx("span",{style:{cursor:"pointer",fontSize:15,color:"blue",textDecoration:"underline"},children:"Please Assign Subject"})}):e.jsx(s.Col,{xs:24,className:"buttonCoustom",children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Update",color:"primary"})})})})})]})}),h?.data?.length>0&&e.jsx("form",{onSubmit:l,style:{marginTop:24},children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsxs(s.Col,{xs:24,children:[e.jsx(he,{level:5,children:"Extra Curricular Activities"}),e.jsx(Rd,{options:h?.data?.map(O=>({label:O.label||O.name,value:O.value})),value:R,onChange:j,style:{display:"grid",gap:8}})]}),e.jsx(s.Col,{xs:24,children:e.jsx("input",{name:"student_id",type:"hidden",value:n||"",readOnly:!0})}),e.jsx(s.Col,{xs:24,className:"buttonCoustom",children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Update",color:"primary"})})})})})]})})]})]})}):e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsx(w,{p:3,children:e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(s.Spin,{size:"large"})})})})}function TS({token:t}){const[a,n]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(0),[c,h]=i.useState(null),[f,p]=i.useState(!1),{data:m}=q(t?[oa,t]:null,([u,x])=>W(u,x)),{data:v}=q(t&&a?[`${la}?class_id=${a}`,t]:null,([u,x])=>W(u,x)),{data:S}=q(t?[$f,t]:null,([u,x])=>W(`${u}?page=1&per_page=10`,x)),y=i.useMemo(()=>m?Array.isArray(m)?m:Array.isArray(m?.data)?m.data:[]:[],[m]),g=i.useMemo(()=>v?Array.isArray(v)?v:Array.isArray(v?.data)?v.data:[]:[],[v]),b=i.useMemo(()=>[{id:"1",name:"Category Id",selector:"id",sortable:!0},{id:"2",name:"Category",selector:"category",sortable:!0}],[]),D=u=>{n(u?.value||""),o(""),d(x=>x+1)},R=u=>{o(u?.value||"")},I=()=>{const u=document.createElement("a");u.href="/sample_student.xlsx",u.download="sample_student.xlsx",u.click()},A=u=>{u.fileList.length>0?h(u.fileList[0].originFileObj):h(null)},_=async u=>{if(u.preventDefault(),!a){T.error("Please select class",{duration:1e3});return}if(!r){T.error("Please select section",{duration:1e3});return}if(!c){T.error("Please select file",{duration:1e3});return}p(!0);const x=new FormData;x.append("file",c),x.append("class_id",a),x.append("section_id",r);try{const j=await bn(Of,x,t);j?.Status==="Failed"?T.error(j?.msg||"Upload failed",{duration:2e3}):(T.success(j?.msg||"Upload successful",{duration:2e3}),h(null),n(""),o(""))}catch(j){T.error(j?.response?.data?.msg||"Upload failed",{duration:2e3})}finally{p(!1)}};return e.jsx(w,{pt:5,pb:1,children:e.jsx(s.Row,{gutter:[16,16],children:e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(he,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Students"})}),e.jsxs(w,{p:3,children:[e.jsx(s.Row,{justify:"end",style:{marginBottom:16},children:e.jsx(s.Col,{children:e.jsx(s.Button,{type:"primary",icon:e.jsx(re.DownloadOutlined,{}),onClick:I,style:{background:"#368fed"},children:"Download Sample Import File"})})}),e.jsxs("div",{style:{marginBottom:16,padding:16,background:"#f5f5f5",borderRadius:8},children:[e.jsx(he,{level:5,style:{marginBottom:8},children:"Information"}),e.jsx("div",{children:"1. Your Excel data should be in the format below. The first line of your Excel file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("div",{children:"2. If the column you are trying to import is date make sure that is formatted in format Y-m-d (2024-01-10)."}),e.jsx("div",{children:"3. Duplicate Admission Number, ec_no, aadhaar_number, (unique) rows will not be imported."}),e.jsx("div",{children:"4. For student Gender use Male, Female value."}),e.jsx("div",{children:"5. For student Blood Group use A+, A-, B+, B-, O+, O-, AB+, AB- value."}),e.jsx("div",{children:"6. * Imported field are admission_no, ec_no, firstname, lastname, roll_no, guardian_phone, aadhaar_number, category_id"})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx(he,{level:5,style:{marginBottom:8},children:"Category Table"}),e.jsx(Ke,{parentCallback:()=>{},data:{newData:S,columns:b,action:!1,Loading:!1,error:null,pageController:{page:1,rowsPerPage:10}}})]}),e.jsx("form",{onSubmit:_,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{label:"Class",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:y.find(u=>String(u.value)===String(a))??null,onChange:D})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(w,{children:e.jsx(ae,{label:"Section",options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:g.find(u=>String(u.value)===String(r))??null,onChange:R},`section-${l}`)})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsxs(w,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"File"}),e.jsx(s.Upload,{beforeUpload:()=>!1,onChange:A,maxCount:1,accept:".xlsx,.xls",children:e.jsx(s.Button,{icon:e.jsx(re.UploadOutlined,{}),style:{width:"100%"},children:c?c.name:"Select Excel File"})})]})}),e.jsx(s.Col,{xs:24,md:6,style:{display:"flex",alignItems:"flex-end"},children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:f?"Processing...":"Save",color:"primary",loading:f})})})]})})]})]})})})})}function DS(){return null}const qr=t=>t??localStorage.getItem("authToken")??"",ku=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},Ru=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",qe={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/assignClassSubjects",list:"api/branchapi/academy/getSubjectsbyClass",update:"api/branchapi/academy/updateAssignSubject",editByClass:"api/branchapi/academy/editSubjectsbyClass"},assignByClass:{teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classWithSection:"api/branchapi/academy/getClasswithSection",assignedSubjectsOfTeacher:"api/branchapi/academy/getassignedSubjectsofTeacher",subjectsOfTeacherByTeacherId:"api/branchapi/academy/getSubjectsofTeacherbyTeacherID",assignClassToTeacher:"api/branchapi/academy/assignClasstoTeacher",deleteTeacherSub:"api/branchapi/academy/deleteTeacherSub"},promoteStudents:{searchByClassSection:"api/branchapi/student/currentSessionStudentlist",sessionDropdown:"api/branchapi/generalSettings/sessiondropdown",promote:"api/branchapi/student/promotestudent"},timeGroup:{table:"api/branchapi/academy/getTimeGroupTable",add:"api/branchapi/academy/addTimeGroup",edit:"api/branchapi/academy/editTimeGroup",remove:"api/branchapi/academy/deleteTimeGroup",show:"api/branchapi/academy/getTimeGroupDataById",dropdown:"api/branchapi/academy/getTimeGroupDropDown"},assignTimeGroup:{classIdByTimeGroup:"api/branchapi/academy/getClassIdByTimeGroup",table:"api/branchapi/academy/getAssignedTimeGroupTable",show:"api/branchapi/academy/getAssignedTimeGroupDataById",assign:"api/branchapi/academy/assignTimeGroup"},timetable:{save:"api/timetable/save",byClassSection:"api/timetable/class",teacherTimetable:"api/timetable/teacher/",teachersBySubject:"api/branchapi/Academy/gettechersSubject"},notes:{table:"api/branchapi/Academy/getNotesTable",add:"api/branchapi/Academy/addNotes"},syllabus:{table:"api/branchapi/Academy/getsyllabusTable",add:"api/branchapi/Academy/addsyllabus",edit:"api/branchapi/Academy/editsyllabus",uploadFile:"api/SuperAdmin/uploadFile"},transferCertificate:{studentList:"api/branchapi/student/getstudenttransferCertificateList",addData:"api/branchapi/academy/addtransferCertificatedata",view:"api/branchapi/academy/gettransferCertificateUrl"},coscholastic:{table:"api/branchapi/academy/getcoscholastic",addSkill:"api/branchapi/academy/addCoscholasticSkill",deleteSkill:"api/branchapi/academy/deleteCoscholastic",categoryDropdown:"api/branchapi/academy/coscholasticCategoryDropdown",addCategory:"api/branchapi/academy/addCoscholasticCategory",deleteCategory:"api/branchapi/academy/coscholasticCategoryDelete"}},kS=()=>ku(Nt(),qe.uploadNotes),RS=()=>ku(Nt(),qe.syllabus.uploadFile),IS=async({baseUrl:t,page:a=1,perPage:n=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(n))}`;return W(l,qr(r))},Zt=async(t,a,n,{includeSession:r=!1}={})=>{const o=a instanceof FormData?a:new FormData;return r&&!o.has("session_id")&&o.append("session_id",Ru()),Ze(t,o,qr(n))},Ra=async(t,a,n,{includeSession:r=!1}={})=>{const o=a instanceof FormData?a:new FormData;return r&&!o.has("session_id")&&o.append("session_id",Ru()),ct(t,o,qr(n))},Ga=async(t,a,n)=>st(t,a,qr(n)),cr=qe.master.sections,bs=({baseUrl:t,page:a=1,perPage:n=10,token:r})=>q(r&&t?[t,a,n,r]:null,([l,d,c,h])=>IS({baseUrl:l,page:d,perPage:c},h)),PS=({token:t,page:a=1,perPage:n=10})=>bs({token:t,baseUrl:cr.table,page:a,perPage:n}),MS=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function ES({token:t}){const[a,n]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),{data:h,isLoading:f,mutate:p}=PS({token:t,page:a.page,perPage:a.perPage}),m=i.useMemo(()=>MS(h),[h]),v=i.useMemo(()=>h?.pagination?.total_rows??h?.pagination?.total??m.length??0,[h,m]),S=async R=>{R.preventDefault();const I=new FormData(R.target);try{await Zt(cr.add,I,t),T.success("Success! Added new item.",{duration:1e3}),R.target.reset(),p()}catch(A){T.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},y=async R=>{try{await Ga(cr.remove,R,t),T.success("Success! Deleted item.",{duration:1e3}),p()}catch(I){T.error(I?.response?.data?.msg??I?.message??"Failed to delete the item.",{duration:1500})}},g=R=>{d(R),o(!0),c.setFieldsValue({section:R?.section??""})},b=async R=>{const I=new FormData;I.append("id",String(l?.id??"")),I.append("section",R.section??"");try{await Ra(cr.edit,I,t),T.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(A){T.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},D=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(R,I)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>g(I)}),e.jsx(s.Popconfirm,{title:"Delete this section?",onConfirm:()=>y(I?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Section",open:r,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(s.Form,{form:c,layout:"vertical",onFinish:b,children:[e.jsx(s.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(s.Input,{placeholder:"Section Name"})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),children:e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(G,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(de,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(s.Space,{}),children:e.jsx(s.Table,{rowKey:R=>R.id,columns:D,dataSource:m,loading:f,pagination:{current:a.page,pageSize:a.perPage,total:v,showSizeChanger:!0,onChange:(R,I)=>n({page:R,perPage:I})}})})]})}function OS({token:t}){return e.jsx(ES,{token:t})}const es=qe.master.classes,$S=({token:t,page:a=1,perPage:n=10})=>bs({token:t,baseUrl:es.table,page:a,perPage:n}),FS=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},BS=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function LS({token:t}){const[a,n]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[h]=s.Form.useForm(),{data:f}=q(t?[qe.master.sections.list,t]:null,([j,P])=>W(j,P)),p=i.useMemo(()=>BS(f),[f]),m=i.useMemo(()=>p.map(j=>({label:j.label??j.section??String(j.value??""),value:String(j.value??j.id??"")})),[p]),{data:v,isLoading:S,mutate:y}=$S({token:t,page:a.page,perPage:a.perPage}),g=i.useMemo(()=>FS(v),[v]),b=i.useMemo(()=>v?.pagination?.total_rows??v?.pagination?.total??g.length??0,[v,g]),{data:D}=q(t&&l?[`${es.show}?id=${encodeURIComponent(String(l))}`,t]:null,([j,P])=>W(j,P)),R=i.useMemo(()=>{const j=D?.data??D;return Array.isArray(j)?j:Array.isArray(j?.data)?j.data:j?[j]:[]},[D]),I=j=>{const P=j?.id??j?.class_id;P&&(d(P),o(!0))};i.useEffect(()=>{if(!r||!R.length)return;const j=R[0],P=R.map(k=>k?.section_id??k?.fk_sectionId??k?.sectionId??k?.section).filter(k=>k!=null&&String(k).trim()!=="").map(k=>String(k)),O=Array.isArray(j?.section_ids)?j.section_ids.map(k=>String(k)):typeof j?.section_ids=="string"?j.section_ids.split(",").map(k=>k.trim()).filter(Boolean):Array.isArray(j?.section)?j.section.map(k=>String(k)):[],z=P.length?P:O;h.setFieldsValue({name:j?.class??j?.name??"",section:z})},[r,R,h]);const A=async j=>{const P=new FormData;P.append("name",j.name??""),(j.section??[]).forEach(O=>P.append("section[]",String(O)));try{await Zt(es.add,P,t),T.success("Success! Added new item.",{duration:1e3}),c.resetFields(),y()}catch(O){T.error(O?.response?.data?.msg??O?.message??"Failed to add the new item.",{duration:1500})}},_=async j=>{const P=new FormData;P.append("id",String(l??"")),P.append("name",j.name??""),(j.section??[]).forEach(O=>P.append("section[]",String(O)));try{await Ra(es.edit,P,t),T.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),y()}catch(O){T.error(O?.response?.data?.msg??O?.message??"Failed to update the item.",{duration:1500})}},u=async j=>{try{await Ga(es.remove,j,t),T.success("Success! Deleted item.",{duration:1e3}),y()}catch(P){T.error(P?.response?.data?.msg??P?.message??"Failed to delete the item.",{duration:1500})}},x=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(j,P)=>j??P?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:j=>j??""},{title:"Actions",key:"actions",width:120,render:(j,P)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>I(P)}),e.jsx(s.Popconfirm,{title:"Delete this class?",onConfirm:()=>u(P?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Class",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(s.Form,{form:h,layout:"vertical",onFinish:_,children:[e.jsx(s.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(s.Input,{placeholder:"Class"})}),e.jsx(s.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(s.Checkbox.Group,{options:m})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(s.Input,{placeholder:"Class"})}),e.jsx(s.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(s.Checkbox.Group,{options:m})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(s.Table,{rowKey:j=>j.id,columns:x,dataSource:g,loading:S,pagination:{current:a.page,pageSize:a.perPage,total:b,showSizeChanger:!0,onChange:(j,P)=>n({page:j,perPage:P})}})})]})}function US({token:t}){return e.jsx(LS,{token:t})}const ts=qe.master.subjects,NS=({token:t,page:a=1,perPage:n=10})=>bs({token:t,baseUrl:ts.table,page:a,perPage:n}),zS=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Id=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],Pd=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function qS({token:t}){const[a,n]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[h]=s.Form.useForm(),{data:f,isLoading:p,mutate:m}=NS({token:t,page:a.page,perPage:a.perPage}),v=i.useMemo(()=>zS(f),[f]),S=i.useMemo(()=>f?.pagination?.total_rows??f?.pagination?.total??v.length??0,[f,v]),{data:y,isLoading:g}=q(t&&l?[`${ts.show}?id=${encodeURIComponent(String(l))}`,t]:null,([u,x])=>W(u,x)),b=i.useMemo(()=>{const u=y?.data??y;return Array.isArray(u)?u[0]:u??null},[y]);i.useEffect(()=>{if(!r||!b)return;const u=[];["yes","1","true"].includes(String(b?.is_practical??"").toLowerCase())&&u.push("Practical"),["yes","1","true"].includes(String(b?.is_theory??"").toLowerCase())&&u.push("Theory"),h.setFieldsValue({name:b?.name??"",subject_type:b?.subject_type??b?.type??"",subject_types:u,code:b?.code??""})},[r,b,h]);const D=async u=>{const x=u?.subject_type??u?.type??"",j=Array.isArray(u?.subject_types)?u.subject_types:[],P={name:u?.name??"",subject_type:x,subject_types:j,code:u?.code??"",is_practical:j.includes("Practical")?"yes":"no",is_theory:j.includes("Theory")?"yes":"no"};try{await m(Ze(ts.add,P,t)),T.success("Success! Added new item.",{duration:1e3}),c.resetFields()}catch(O){T.error(O?.response?.data?.msg??O?.message??"Failed to add the new item.",{duration:1500})}},R=async u=>{const x=new FormData,j=u?.subject_type??u?.type??"",P=Array.isArray(u?.subject_types)?u.subject_types:[];x.append("id",String(l??"")),x.append("name",u.name??""),x.append("subject_type",j),x.append("code",u.code??""),x.append("subject_types",P),x.append("is_practical",P.includes("Practical")?"yes":"no"),x.append("is_theory",P.includes("Theory")?"yes":"no");try{await m(Ra(ts.edit,x,t)),T.success("Success! Updated item.",{duration:1e3}),o(!1),d(null)}catch(O){T.error(O?.response?.data?.msg??O?.message??"Failed to update the item.",{duration:1500})}},I=async u=>{try{await m(Ga(ts.remove,u,t)),T.success("Success! Deleted item.",{duration:1e3})}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to delete the item.",{duration:1500})}},A=u=>{const x=u?.id;x&&(d(x),o(!0))},_=i.useMemo(()=>[{title:"Subject Name",dataIndex:"name",key:"name"},{title:"Subject",dataIndex:"subject_type",key:"subject_type"},{title:"Subject Code",dataIndex:"code",key:"code"},{title:"Subject Type",key:"subject_types",render:(u,x)=>{const j=[],P=x?.subject_types;Array.isArray(P)?P.forEach(C=>{const E=String(C??"").trim();if(!E)return;const M=E.toLowerCase();["yes","1","true"].includes(M)||j.push(E)}):typeof P=="string"&&P.split(",").map(C=>C.trim()).filter(Boolean).forEach(C=>{const E=C.toLowerCase();["yes","1","true"].includes(E)||j.push(C)});const O=["yes","1","true"].includes(String(x?.is_practical??"").toLowerCase()),z=["yes","1","true"].includes(String(x?.is_theory??"").toLowerCase());O&&j.push("Practical"),z&&j.push("Theory");const k=j.map(C=>String(C??"").trim()).filter(Boolean).map(C=>C.toLowerCase()==="practical"?"Practical":C.toLowerCase()==="theory"?"Theory":C),F=Array.from(new Set(k));return F.length?F.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(u,x)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>A(x)}),e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>I(x?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Subject",open:r,onClose:()=>{o(!1),d(null)},width:560,children:g?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(s.Spin,{size:"large"})}):e.jsxs(s.Form,{form:h,layout:"vertical",onFinish:R,children:[e.jsx(s.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(G,{placeholder:"Subject Name"})}),e.jsx(s.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(s.Radio.Group,{options:Pd})}),e.jsx(s.Form.Item,{label:"Subject Type",name:"subject_types",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(s.Checkbox.Group,{options:Id})}),e.jsx(s.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(G,{placeholder:"Subject Code"})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:D,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(G,{placeholder:"Subject Name"})}),e.jsx(s.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(s.Radio.Group,{options:Pd})}),e.jsx(s.Form.Item,{name:"subject_types",label:"Subject Type",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(s.Checkbox.Group,{options:Id})}),e.jsx(s.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(G,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(s.Table,{rowKey:u=>u.id,columns:_,dataSource:v,loading:p,pagination:{current:a.page,pageSize:a.perPage,total:S,showSizeChanger:!0,onChange:(u,x)=>n({page:u,perPage:x})}})})]})}function YS({token:t}){return e.jsx(qS,{token:t})}const as=qe.master.holidays,WS=({token:t,page:a=1,perPage:n=10})=>bs({token:t,baseUrl:as.table,page:a,perPage:n}),VS=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ys={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function HS({token:t}){const[a,n]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[h]=s.Form.useForm(),{data:f,isLoading:p,mutate:m}=WS({token:t,page:a.page,perPage:a.perPage}),v=i.useMemo(()=>VS(f),[f]),S=i.useMemo(()=>f?.pagination?.total_rows??f?.pagination?.total??v.length??0,[f,v]),{data:y}=q(t&&l?[`${as.show}?id=${encodeURIComponent(String(l))}`,t]:null,([_,u])=>W(_,u)),g=i.useMemo(()=>{const _=y?.data??y;return Array.isArray(_)?_[0]:_??null},[y]);i.useEffect(()=>{r&&g&&h.setFieldsValue({title:g?.holiday_title??"",description:g?.holiday_description??"",from:g?.start_date?ne(g.start_date):null,to:g?.end_date?ne(g.end_date):null})},[r,g,h]);const b=async _=>{const u=new FormData;u.append("title",_.title??""),u.append("description",_.description??""),u.append("from",_.from?ne(_.from).format("YYYY-MM-DD"):""),u.append("to",_.to?ne(_.to).format("YYYY-MM-DD"):"");try{await Zt(as.add,u,t,{includeSession:!0}),T.success("Success! Added new item.",{duration:1e3}),c.resetFields(),m()}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to add the new item.",{duration:1500})}},D=async _=>{const u=new FormData;u.append("id",String(l??"")),u.append("title",_.title??""),u.append("description",_.description??""),u.append("from",_.from?ne(_.from).format("YYYY-MM-DD"):""),u.append("to",_.to?ne(_.to).format("YYYY-MM-DD"):"");try{await Ra(as.edit,u,t,{includeSession:!0}),T.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),m()}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to update the item.",{duration:1500})}},R=async _=>{try{await Ga(as.remove,_,t),T.success("Success! Deleted item.",{duration:1e3}),m()}catch(u){T.error(u?.response?.data?.msg??u?.message??"Failed to delete the item.",{duration:1500})}},I=_=>{const u=_?.id;u&&(d(u),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:(_,u)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>I(u)}),e.jsx(s.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>R(u?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Holiday",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(s.Form,{form:h,layout:"vertical",onFinish:D,children:[e.jsx(s.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(G,{placeholder:"Holiday Title"})}),e.jsx(s.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(G,{placeholder:"Holiday Description"})}),e.jsx(s.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:Ys})}),e.jsx(s.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:Ys})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:b,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(G,{placeholder:"Holiday Title"})}),e.jsx(s.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(kt,{placeholder:"Holiday Description"})}),e.jsx(s.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:Ys})}),e.jsx(s.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:Ys})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(s.Table,{rowKey:_=>_.id,columns:A,dataSource:v,loading:p,pagination:{current:a.page,pageSize:a.perPage,total:S,showSizeChanger:!0,onChange:(_,u)=>n({page:_,perPage:u})}})})]})}function KS({token:t}){return e.jsx(HS,{token:t})}const ur=qe.assignSubjects,GS=({token:t,page:a=1,perPage:n=50})=>bs({token:t,baseUrl:ur.list,page:a,perPage:n}),Md=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],JS=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function QS({token:t}){const[a,n]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,h]=i.useState(!1),[f,p]=i.useState(!1),[m,v]=i.useState(null),[S,y]=i.useState([]),{data:g}=q(t?[qe.master.classes.dropdown,t]:null,([C,E])=>W(C,E)),{data:b}=q(t?[qe.master.subjects.dropdown,t]:null,([C,E])=>W(C,E)),D=i.useMemo(()=>Md(g),[g]),R=i.useMemo(()=>Md(b),[b]),I=i.useMemo(()=>R.map(C=>({label:C.label??C.subject??String(C.value??""),value:C.value??C.id})),[R]),{data:A,isLoading:_,mutate:u}=GS({token:t,page:a.page,perPage:a.perPage}),x=i.useMemo(()=>JS(A),[A]),j=i.useMemo(()=>A?.pagination?.total_rows??A?.pagination?.total??x.length??0,[A,x]),{data:P}=q(t&&m?[`${ur.editByClass}?class_id=${encodeURIComponent(String(m))}`,t]:null,([C,E])=>W(C,E));i.useEffect(()=>{if(!f)return;const C=P?.data??P,E=Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[];y(E.map(M=>M.subject_id).filter(Boolean))},[f,P]);const O=async C=>{if(C.preventDefault(),!r?.value){T.error("Please select class",{duration:1200});return}if(!l.length){T.error("Please select subjects",{duration:1200});return}const E=new FormData;E.append("class_id",String(r.value)),l.forEach(M=>E.append("subject[]",String(M)));try{h(!0),await Ra(ur.assign,E,t),T.success("Success! Updated item.",{duration:1e3}),o(null),d([]),u()}catch(M){T.error(M?.response?.data?.msg??M?.message??"Failed to update the item.",{duration:1500})}finally{h(!1)}},z=C=>{C&&(v(C),p(!0))},k=async()=>{if(!m)return;if(!S.length){T.error("Please select subjects",{duration:1200});return}const C=new FormData;C.append("class_id",String(m)),S.forEach(E=>C.append("subject[]",String(E)));try{await Ra(ur.update,C,t),T.success("Success! Updated item.",{duration:1e3}),p(!1),v(null),u()}catch(E){T.error(E?.response?.data?.msg??E?.message??"Failed to update the item.",{duration:1500})}},F=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(C,E)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(E?.subject_name??C??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(C,E)=>e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>z(E?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Assigned Subjects",open:f,onClose:()=>{p(!1),v(null)},width:520,extra:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>p(!1),children:"Cancel"}),e.jsx(s.Button,{type:"primary",onClick:k,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ae,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:D.find(C=>String(C.value)===String(m))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(s.Checkbox.Group,{options:I,value:S,onChange:y})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:C=>o(C??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(s.Checkbox.Group,{options:I,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(s.Table,{rowKey:C=>C.id,columns:F,dataSource:x,loading:_,pagination:{current:a.page,pageSize:a.perPage,total:j,showSizeChanger:!0,onChange:(C,E)=>n({page:C,perPage:E})}})})]})}function XS({token:t}){return e.jsx(QS,{token:t})}const mn=qe.assignByClass,Iu=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[]},Wn=t=>Iu(t),ZS=t=>Iu(t),Vn=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function ew({token:t}){const[a,n]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,h]=i.useState("No"),[f,p]=i.useState([]),[m,v]=i.useState([]),[S,y]=i.useState(null),[g,b]=i.useState(null),[D,R]=i.useState(!1),[I,A]=i.useState(""),{data:_}=q(t?[mn.teacherDropdown,t]:null,([se,le])=>W(se,le)),{data:u}=q(t?[qe.master.classes.dropdown,t]:null,([se,le])=>W(se,le)),{data:x}=q(t&&g?[g,t]:null,([se,le])=>W(se,le)),{data:j}=q(t&&S?[S,t]:null,([se,le])=>W(se,le)),P=i.useMemo(()=>Wn(_),[_]),O=i.useMemo(()=>Wn(u),[u]),z=i.useMemo(()=>Wn(x),[x]),k=i.useMemo(()=>Wn(j),[j]),{data:F}=q(t&&a&&r&&l?[`${mn.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(a))}&class_id=${encodeURIComponent(String(r))}§ion_id=${encodeURIComponent(String(l))}`,t]:null,([se,le])=>W(se,le)),C=F?.data??F??null;i.useEffect(()=>{C&&(p(Array.isArray(C?.subject_ids)?C.subject_ids:[]),h(C?.isClassTeacher||"No"),v([]))},[C]);const{data:E}=q(t?[mn.classWithSection,t]:null,([se,le])=>W(se,le)),M=i.useMemo(()=>Wn(E),[E]),[U,Y]=i.useState(null),[V,L]=i.useState({page:1,perPage:25});i.useEffect(()=>{U||M?.[0]&&Y(`${M[0].class_id}val${M[0].section_id}`)},[M,U]);const B=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),$=i.useMemo(()=>{if(!U)return null;const[se,le]=String(U).split("val");if(!se||!le)return null;const Ce=V.page??1,Le=V.perPage??25;return`${mn.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(Ce))}&per_page=${encodeURIComponent(String(Le))}&session_id=${encodeURIComponent(String(B))}&class_id=${encodeURIComponent(String(se))}§ion_id=${encodeURIComponent(String(le))}`},[U,V.page,V.perPage,B]),{data:N,isLoading:H,mutate:Q}=q(t&&$?[$,t]:null,([se,le])=>W(se,le),{revalidateOnFocus:!1}),X=i.useMemo(()=>ZS(N),[N]),J=i.useMemo(()=>{const se=N?.pagination??N?.data?.pagination??N?.data?.data?.pagination;return se?.total_rows??se?.total??X.length??0},[N,X]),K=async se=>{if(se.preventDefault(),A(""),!a||!r||!l){T.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(f)||f.length===0){A("error"),T.error("Please Select Subject",{duration:1200});return}const le=new FormData;le.append("teacher_id",String(a)),le.append("class_id",String(r)),le.append("section_id",String(l)),le.append("isClassTeacher",String(c??"No")),Vn(f).forEach(Ce=>le.append("subject_ids[]",String(Ce))),Vn(m).forEach(Ce=>le.append("delete_subject[]",String(Ce)));try{await Zt(mn.assignClassToTeacher,le,t,{includeSession:!0}),T.success("Success! Added new item.",{duration:1e3}),A(""),Q()}catch(Ce){T.error(Ce?.response?.data?.msg??Ce?.message??"Failed to add the new item.",{duration:1500})}},Z=async se=>{try{await Ga(mn.deleteTeacherSub,se,t),T.success("Success! Deleted item.",{duration:1e3}),Q(),window.location.reload()}catch(le){T.error(le?.response?.data?.msg??le?.message??"Failed to delete the item.",{duration:1500})}},ee=se=>{const le=Array.isArray(se?.child)?se.child:[],Ce=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Le,Re)=>e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>Z(Re?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(s.Table,{columns:Ce,bordered:!0,size:"small",dataSource:le,pagination:!1,rowKey:Le=>Le.id})})},pe=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(se,le)=>e.jsxs("div",{children:[le.teacher_name,le.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],te=i.useMemo(()=>(M??[]).map(se=>({label:se.label??`${se.class_name??""} ${se.section_name??""}`.trim(),key:`${se.class_id}val${se.section_id}`,children:e.jsx(s.Table,{size:"small",columns:pe,bordered:!0,dataSource:Array.isArray(X)?X:[],loading:H,rowKey:le=>le.id,expandable:{expandedRowRender:ee},pagination:{current:V.page,pageSize:V.perPage,total:J,showSizeChanger:!0,onChange:(le,Ce)=>L({page:le,perPage:Ce})}})})),[M,V.page,V.perPage,X,H,J]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(320px, 380px) 1fr",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:K,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ae,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:P.find(se=>String(se.value)===String(a))??null,onChange:se=>n(se?.value??null)}),e.jsx(ae,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:O.find(se=>String(se.value)===String(r))??null,onChange:se=>{const le=se?.value??null;o(le),d(null),y(le?`${qe.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(le))}`:null),b(le?`${qe.master.sections.byClass}?class_id=${encodeURIComponent(String(le))}`:null),R(Ce=>!Ce)}}),e.jsx(ae,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:z.find(se=>String(se.value)===String(l))??null,onChange:se=>d(se?.value??null)},`section_${D}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const se=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(ae,{style:{width:"100%"},options:se,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:se.find(le=>String(le.value)===String(c??"No"))??se[1],onChange:le=>h(le?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(ae,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:k,value:(k??[]).filter(se=>Vn(f).some(le=>String(le)===String(se.value))),onChange:(se,le)=>{const Le=(Array.isArray(se)?se:[]).map(Ue=>Ue?.value).filter(Ue=>Ue!=null&&Ue!=="");p(Le);const Re=Array.isArray(C?.subject_ids)?C.subject_ids.map(String):[],xe=le?.removedValue?.value,De=le?.option?.value;(le?.action==="remove-value"||le?.action==="pop-value")&&xe!=null&&Re.includes(String(xe))&&v(Ue=>Array.from(new Set([...Vn(Ue).map(String),String(xe)]))),le?.action==="select-option"&&De!=null&&Re.includes(String(De))&&v(Ue=>Vn(Ue).filter(ye=>String(ye)!==String(De)))}},`subjects_${D}`),I?e.jsx("div",{style:{color:"#ff4d4f",marginTop:6,fontSize:12},children:"Please select subject"}):null]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(s.Tabs,{activeKey:U??void 0,onChange:se=>{Y(se),L(le=>({...le,page:1}))},items:te,type:"card",size:"small"})})]})]})}function tw({token:t}){return e.jsx(ew,{token:t})}const Hn=qe.timeGroup,aw=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},wa={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ws(t){if(!t)return null;const a=ne(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return a.isValid()?a:null}function va(t){return t?ne(t).format("h:mm a"):""}function nw({token:t}){const[a,n]=i.useState({page:1,perPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[h]=s.Form.useForm(),f=`${Hn.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:p,isLoading:m,mutate:v}=q(t?[f,t]:null,([x,j])=>W(x,j)),S=i.useMemo(()=>aw(p),[p]),y=i.useMemo(()=>p?.pagination?.total_rows??p?.pagination?.total??S.length??0,[p,S]),{data:g,isLoading:b}=q(t&&l?[`${Hn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([x,j])=>W(x,j)),D=i.useMemo(()=>{const x=g?.data??g;return Array.isArray(x)?x[0]:x??null},[g]);i.useEffect(()=>{r&&D&&h.setFieldsValue({title:D?.title??"",start_time_from:Ws(D?.start_time_from),start_time_to:Ws(D?.start_time_to),end_time_from:Ws(D?.end_time_from),end_time_to:Ws(D?.end_time_to)})},[r,D,h]);const R=async x=>{const j=new FormData;j.append("title",x.title??""),j.append("start_time_from",va(x.start_time_from)),j.append("start_time_to",va(x.start_time_to)),j.append("end_time_from",va(x.end_time_from)),j.append("end_time_to",va(x.end_time_to));try{await Zt(Hn.add,j,t),T.success("Success! Added new item.",{duration:1e3}),c.resetFields(),v()}catch(P){T.error(P?.response?.data?.msg??P?.message??"Failed to add the new item.",{duration:1500})}},I=async x=>{const j=new FormData;j.append("id",String(l??"")),j.append("title",x.title??""),j.append("start_time_from",va(x.start_time_from)),j.append("start_time_to",va(x.start_time_to)),j.append("end_time_from",va(x.end_time_from)),j.append("end_time_to",va(x.end_time_to));try{await Ra(Hn.edit,j,t),T.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),v()}catch(P){T.error(P?.response?.data?.msg??P?.message??"Failed to update the item.",{duration:1500})}},A=async x=>{try{await Ga(Hn.remove,x,t),T.success("Success! Deleted item.",{duration:1e3}),v()}catch(j){T.error(j?.response?.data?.msg??j?.message??"Failed to delete the item.",{duration:1500})}},_=x=>{x?.id&&(d(x.id),o(!0))},u=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:120,render:(x,j)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>_(j)}),e.jsx(s.Popconfirm,{title:"Delete this time group?",onConfirm:()=>A(j?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Time Group",open:r,onClose:()=>{o(!1),d(null)},width:520,children:b?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(s.Spin,{size:"large"})}):e.jsxs(s.Form,{form:h,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(G,{placeholder:"Title"})}),e.jsx(s.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:wa})}),e.jsx(s.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:wa})}),e.jsx(s.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:wa})}),e.jsx(s.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:wa})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Submit",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:R,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(G,{placeholder:"Title"})}),e.jsx(s.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:wa})}),e.jsx(s.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:wa})}),e.jsx(s.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:wa})}),e.jsx(s.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:wa})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(s.Table,{rowKey:x=>x.id,columns:u,dataSource:S,loading:m,pagination:{current:a.page,pageSize:a.perPage,total:y,showSizeChanger:!0,onChange:(x,j)=>n({page:x,perPage:j})}})})]})}function sw({token:t}){return e.jsx(nw,{token:t})}const Kn=qe.assignTimeGroup,rw=qe.timeGroup.dropdown,iw=qe.master.classes.dropdown,Ed=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],ow=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function lw({token:t}){const[a,n]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,h]=i.useState(""),[f,p]=i.useState(""),[m,v]=i.useState(null),[S,y]=i.useState(!1),[g,b]=i.useState(!1),[D,R]=i.useState(null),[I,A]=i.useState([]),[_,u]=i.useState(""),[x,j]=i.useState(""),{data:P}=q(t?[rw,t]:null,([J,K])=>W(J,K)),{data:O}=q(t?[iw,t]:null,([J,K])=>W(J,K)),z=i.useMemo(()=>Ed(P?.data??P),[P]),k=i.useMemo(()=>Ed(O),[O]),{data:F}=q(t&&m?[m,t]:null,([J,K])=>W(J,K));i.useEffect(()=>{const J=Array.isArray(F?.data)?F.data.map(K=>K.fk_classId):[];J.length&&d(J)},[F]);const C=`${Kn.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:E,isLoading:M,mutate:U}=q(t?[C,t]:null,([J,K])=>W(J,K)),Y=i.useMemo(()=>ow(E),[E]),V=i.useMemo(()=>E?.pagination?.total_rows??E?.pagination?.total??Y.length??0,[E,Y]),{data:L,isLoading:B}=q(t&&D?[`${Kn.show}?id=${encodeURIComponent(String(D))}`,t]:null,([J,K])=>W(J,K)),$=L?.data??L??null;i.useEffect(()=>{if(!g||!$)return;const J=Array.isArray($?.class_ids)?$.class_ids:[];A(J);const K=Array.isArray(z)?z.find(Z=>String(Z.value)===String($?.timegroup_id)):null;K&&j(`${K.start_time_from} -> ${K.end_time_from}`)},[g,$,z]);const N=async J=>{if(J.preventDefault(),h(""),!r?.value){T.error("Select Time Group",{duration:1200});return}if(!l.length){h("error"),T.error("Please Select Classes",{duration:1200});return}const K=new FormData;K.append("timegroup_id",String(r.value)),l.forEach(Z=>K.append("class_ids[]",String(Z)));try{await Zt(Kn.assign,K,t),T.success("Success! Added new item.",{duration:1e3}),d([]),o(null),p(""),U()}catch(Z){T.error(Z?.response?.data?.msg??Z?.message??"Failed to add the new item.",{duration:1500})}},H=async()=>{if(u(""),!D)return;if(!I.length){u("error"),T.error("Please Select Classes",{duration:1200});return}const J=new FormData;J.append("id",String(D)),J.append("timegroup_id",String($?.timegroup_id??"")),I.forEach(K=>J.append("class_ids[]",String(K)));try{await Ra(Kn.assign,J,t),T.success("Success! Updated item.",{duration:1e3}),b(!1),R(null),U()}catch(K){T.error(K?.response?.data?.msg??K?.message??"Failed to update the item.",{duration:1500})}},Q=J=>{J&&(R(J),b(!0))},X=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Class Names",dataIndex:"class_names",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:90,render:(J,K)=>K?.class_names?e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>Q(K?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Assigned Time Group",open:g,onClose:()=>{b(!1),R(null)},width:520,extra:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>b(!1),children:"Cancel"}),e.jsx(s.Button,{type:"primary",onClick:H,children:"Submit"})]}),children:B?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e.jsx(s.Spin,{size:"large"})}):e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ae,{options:Array.isArray(z)?z:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:z.find(J=>String(J.value)===String($?.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(s.Select,{mode:"multiple",style:{width:"100%"},status:_,value:I,placeholder:"Select Classes",onChange:J=>A(J),options:Array.isArray(k)?k:[]})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(ae,{options:Array.isArray(z)?z:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:J=>{o(J??null),d([]),h(""),J?.value?(v(`${Kn.classIdByTimeGroup}?id=${encodeURIComponent(String(J.value))}`),p(`${J.start_time_from} -> ${J.end_time_from}`)):(v(null),p("")),y(K=>!K)}}),e.jsx("div",{style:{marginTop:6},children:f})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(ae,{isMulti:!0,style:{width:"100%"},status:c,value:(k??[]).filter(J=>Array.isArray(l)&&l.some(K=>String(K)===String(J.value))),placeholder:"Select Classes",onChange:J=>{const K=Array.isArray(J)?J:[];d(K.map(Z=>Z?.value).filter(Z=>Z!=null&&Z!==""))},options:Array.isArray(k)?k:[]},`class_${S}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(s.Table,{rowKey:J=>J.id,columns:X,dataSource:Y,loading:M,pagination:{current:a.page,pageSize:a.perPage,total:V,showSizeChanger:!0,onChange:(J,K)=>n({page:J,perPage:K})}})})]})}function dw({token:t}){return e.jsx(lw,{token:t})}const Xi=qe.promoteStudents,cw=({token:t})=>q(t?[Xi.sessionDropdown,t]:null,([a,n])=>W(a,n)),Vs=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[]},uw=(t,a)=>{const n=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,r=n?.total_rows??n?.total??n?.totalItems;return Number.isFinite(Number(r))?Number(r):a};function pw({token:t}){const[a]=s.Form.useForm(),[n,r]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[h,f]=i.useState(!1),[p,m]=i.useState([]),v=i.useMemo(()=>new Set(p),[p]),[S,y]=i.useState({}),[g,b]=i.useState({}),{data:D}=q(t?[qe.master.classes.dropdown,t]:null,([N,H])=>W(N,H)),R=i.useMemo(()=>Vs(D),[D]),I=i.useMemo(()=>o.classId?`${qe.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:A}=q(t&&I?[I,t]:null,([N,H])=>W(N,H)),_=i.useMemo(()=>Vs(A),[A]),u=i.useMemo(()=>d.classId?`${qe.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:x}=q(t&&u?[u,t]:null,([N,H])=>W(N,H),{revalidateOnFocus:!1}),j=i.useMemo(()=>Vs(x),[x]),{data:P}=cw({token:t}),O=i.useMemo(()=>Vs(P),[P]),{trigger:z,data:k,isMutating:F}=it(t?Xi.searchByClassSection:null,(N,{arg:H})=>Ta(N,{arg:H},t)),C=i.useMemo(()=>{const N=k?.data?.data??k?.data??k??[];return Array.isArray(N)?N:Array.isArray(N?.data)?N.data:[]},[k]),E=i.useMemo(()=>uw(k,C.length??0),[k,C.length]),M=i.useMemo(()=>{const N=new Map;return(Array.isArray(C)?C:[]).forEach(H=>{H?.id!==void 0&&H?.id!==null&&N.set(String(H.id),H)}),N},[C]),U=i.useCallback((N,H)=>{const Q=String(N);b(X=>({...X,[Q]:{...X?.[Q]??{},...H}}))},[]),Y=i.useCallback((N,H)=>{const Q=String(N),X=H==="Leave";y(J=>({...J,[Q]:X}))},[]),V=N=>{const H=N?.class_id?.value??N?.class_id??null,Q=N?.section_id?.value??N?.section_id??null;if(!H||!Q){T.error("Please select Class and Section",{duration:1200});return}r(X=>({...X,page:1})),l({classId:H,sectionId:Q}),m([]),y({}),b({})},L=async()=>{if(!d.sessionId||!d.classId){T.error("Please select Session and Class for promotion",{duration:1300});return}if(!Array.isArray(p)||p.length===0){T.error("Please select students to promote",{duration:1200});return}const N=p.map(J=>String(J)).map(J=>{const K=M.get(J)??{},Z=!!S?.[J],ee=g?.[J]??{},pe=String(ee.current_result??"Pass");if(Z){const le=String(ee.leave_date??"");return{student_id:J,current_result:pe,next_session_status:"Leave",leave_date:le}}const te=String(ee.roll_no??K?.roll_no??""),se=String(ee.section_id??"");return{student_id:J,roll_no:te,section_id:se,current_result:pe,next_session_status:"Continue"}});if(N.some(J=>J?.next_session_status==="Leave"&&!String(J?.leave_date??"").trim())){T.error("Leave date is required for Leave students.",{duration:1500});return}if(N.some(J=>J?.next_session_status==="Continue"&&!String(J?.section_id??"").trim())){T.error("Section is required for Continue students.",{duration:1500});return}const X={class_id:String(d.classId),session_id:String(d.sessionId),students:N};try{const J=await ct(Xi.promote,X,t);if(J?.Status&&String(J.Status)!=="success")throw new Error(J?.msg||"Failed to update");T.success("Success! Updated.",{duration:1e3});const K=Number(J?.success_count??0)+Number(J?.leave_count??0),Z=n.page===Math.ceil((Number(E)||0)/n.perPage||1),ee=K>0&&K===C.length&&C.length===p.length,pe=Z&&ee&&n.page>1?n.page-1:n.page;r(te=>({...te,page:pe})),z?.({cID:o.classId,sID:o.sectionId,page:pe,per_page:n.perPage}),m([]),y({}),b({})}catch(J){T.error(J?.response?.data?.msg??J?.message??"Failed to update",{duration:1500})}},B=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:(N,H)=>{const Q=String(H?.id??""),X=v.has(Q),J=!!S?.[Q],Z=(g?.[Q]??{}).roll_no??(J?"":H?.roll_no??"");return e.jsx(s.Input,{value:X?Z:H?.roll_no,style:X?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!X||J,onChange:ee=>U(Q,{roll_no:ee.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(N,H)=>`${H?.firstname??""} ${H?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(N,H)=>{const Q=String(H?.id??""),X=v.has(Q),J=!!S?.[Q],Z=(g?.[Q]??{}).section_id??"",ee=Array.isArray(j)?j:[];return e.jsx(s.Select,{options:ee,placeholder:X&&!J?"Select Section":"Section",disabled:!X||J,value:X&&!J&&Z||void 0,style:{width:"100%"},onChange:pe=>U(Q,{section_id:pe})},`section_${Q}_${h}_${J?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(N,H)=>{const Q=String(H?.id??""),X=v.has(Q),J=g?.[Q]??{},K=String(J.current_result??"Pass");return e.jsxs(s.Radio.Group,{value:K,disabled:!X,buttonStyle:"solid",onChange:Z=>U(Q,{current_result:Z.target.value}),children:[e.jsx(s.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(s.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(N,H)=>{const Q=String(H?.id??""),X=v.has(Q),J=!!S?.[Q],K=g?.[Q]??{},Z=String(K.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(s.Radio.Group,{value:J?"Leave":"Continue",disabled:!X,buttonStyle:"solid",onChange:ee=>Y(Q,ee.target.value),children:[e.jsx(s.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(s.Radio.Button,{value:"Leave",children:"Leave"})]}),X&&J&&e.jsx(s.DatePicker,{style:{width:"100%"},value:Z?ne(Z):null,onChange:ee=>U(Q,{leave_date:ee?ee.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[Y,S,g,v,h,j,U]),$=i.useMemo(()=>({selectedRowKeys:p,onChange:N=>m((Array.isArray(N)?N:[]).map(H=>String(H)))}),[p]);return i.useEffect(()=>{!o.classId||!o.sectionId||z&&z({cID:o.classId,sID:o.sectionId,page:n.page,per_page:n.perPage})},[n.page,n.perPage,z,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(s.Form,{form:a,layout:"vertical",onFinish:V,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:N=>N,children:e.jsx(ae,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:N=>{const H=N?.value??null;a.setFieldValue("section_id",null),l({classId:H,sectionId:null})}})}),e.jsx(s.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:N=>N,children:e.jsx(ae,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Ma,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(s.Typography.Text,{children:["Selected: ",p.length]}),e.jsx(s.Typography.Text,{type:"secondary",children:"Select students → set Continue/Leave → Save"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{label:"Session",options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:O.find(N=>String(N.value)===String(d.sessionId))??null,onChange:N=>c(H=>({...H,sessionId:N?.value??null}))}),e.jsx(ae,{label:"Class",options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(N=>String(N.value)===String(d.classId))??null,onChange:N=>{const H=N?.value??null;c(Q=>({...Q,classId:H})),f(Q=>!Q)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Save",color:"primary",onClick:L})})]}),e.jsx(s.Table,{rowKey:N=>String(N.id),rowSelection:$,columns:B,dataSource:C,loading:F,pagination:{current:n.page,pageSize:n.perPage,total:E,showSizeChanger:!0,onChange:(N,H)=>{r({page:N,perPage:H}),m([]),y({}),b({})}}})]})})]})}function mw({token:t}){return e.jsx(pw,{token:t})}const is=qe.coscholastic,hw=({token:t})=>q(t?[is.table,t]:null,([a,n])=>W(a,n),{revalidateOnFocus:!1}),fw=({token:t})=>q(t?[is.categoryDropdown,t]:null,([a,n])=>W(a,n),{revalidateOnFocus:!1}),Od=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 gw({token:t}){const[a,n]=i.useState(""),[r,o]=i.useState(null),[l,d]=i.useState(null),c=i.useRef(null),{data:h}=q(t?[qe.master.classes.dropdown,t]:null,([u,x])=>W(u,x)),f=i.useMemo(()=>Od(h),[h]),{data:p,isLoading:m,mutate:v}=hw({token:t}),S=i.useMemo(()=>{const u=p?.data?.data??p?.data??p??[];return Array.isArray(u)?u:Array.isArray(u?.data)?u.data:[]},[p]),{data:y,mutate:g}=fw({token:t}),b=i.useMemo(()=>Od(y),[y]),D=i.useMemo(()=>(Array.isArray(b)?b:[]).map(u=>({value:u?.value??u?.id,label:u?.label??u?.title??""})),[b]),R=async()=>{const u=String(a??"").trim();if(!u){T.error("Please enter category title",{duration:1200});return}try{await Ze(is.addCategory,{title:u},t),T.success("Success! Added category.",{duration:1e3}),n(""),g()}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to add category",{duration:1500})}},I=async u=>{if(u.preventDefault(),!r){T.error("Please select Category",{duration:1200});return}if(!l){T.error("Please select Class",{duration:1200});return}if(!u?.target?.skill?.value){T.error("Please enter Skill Name",{duration:1200});return}const j=new FormData(u.target);j.append("scholastic_catid",String(r)),j.append("class_id",String(l));try{await Zt(is.addSkill,j,t),T.success("Success! Added new item.",{duration:1e3}),u.target.reset(),d(null),v()}catch(P){T.error(P?.response?.data?.msg??P?.message??"Failed to add the new item.",{duration:1500})}},A=async u=>{try{await Ga(is.deleteSkill,u,t),T.success("Success! Deleted item.",{duration:1e3}),v()}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to delete the item.",{duration:1500})}},_=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:(u,x)=>e.jsx(s.Popconfirm,{title:"Delete this skill?",onConfirm:()=>A(x?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),children:e.jsx("form",{onSubmit:I,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(ae,{style:{width:"100%"},value:D.find(u=>String(u.value)===String(r))??null,placeholder:"Select Category",onChange:u=>o(u?.value??null),options:D}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(G,{placeholder:"New category",ref:c,value:a,onChange:u=>n(u.target.value)}),e.jsx(s.Button,{type:"text",icon:e.jsx(re.PlusOutlined,{}),onClick:R})]})]}),e.jsx(ae,{label:"Class",options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:f.find(u=>String(u.value)===String(l))??null,onChange:u=>d(u?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(G,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Ma,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:u=>u.id,columns:_,dataSource:S,loading:m,pagination:!1})})]})}function yw({token:t}){return e.jsx(gw,{token:t})}const xw=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Pu=({token:t,value:a,onChange:n,action:r,filePath:o})=>{const l=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),d=r??kS(),c=i.useMemo(()=>{if(!o)return d;const h=d.includes("?")?"&":"?";return`${d}${h}filepath=${encodeURIComponent(o)}`},[d,o]);return e.jsx(s.Upload,{maxCount:1,action:c,headers:l,onChange:h=>{if(h?.file?.status==="done"){const f=xw(h?.file?.response);f&&n?.(f)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},$d=qe.notes,bw=({token:t,url:a})=>q(t&&a?[a,t]:null,([n,r])=>W(n,r),{revalidateOnFocus:!1}),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[]},jw=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r};function Sw({token:t}){const[a]=s.Form.useForm(),[n]=s.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null,sectionId:null}),[c,h]=i.useState(!1),[f,p]=i.useState(""),{data:m}=q(t?[qe.master.classes.dropdown,t]:null,([$,N])=>W($,N)),v=i.useMemo(()=>Hs(m),[m]),S=i.useMemo(()=>l.classId?`${qe.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:y}=q(t&&S?[S,t]:null,([$,N])=>W($,N)),g=i.useMemo(()=>Hs(y),[y]),b=i.useMemo(()=>!l.classId||!l.sectionId?null:`${$d.table}?class_id=${encodeURIComponent(String(l.classId))}§ion_id=${encodeURIComponent(String(l.sectionId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`,[l.classId,l.sectionId,r.page,r.perPage]),{data:D,isLoading:R,mutate:I}=bw({token:t,url:b}),A=i.useMemo(()=>{const $=D?.data?.data??D?.data??D??[];return Array.isArray($)?$:Array.isArray($?.data)?$.data:[]},[D]),_=i.useMemo(()=>D?.pagination?.total_rows??D?.pagination?.total??A.length??0,[D,A.length]),[u,x]=i.useState(null),[j,P]=i.useState(null),[O,z]=i.useState(null),[k,F]=i.useState(!1),{data:C}=q(t&&O?[O,t]:null,([$,N])=>W($,N),{revalidateOnFocus:!1}),E=i.useMemo(()=>Hs(C),[C]),{data:M}=q(t&&j?[j,t]:null,([$,N])=>W($,N)),U=i.useMemo(()=>Hs(M),[M]),Y=$=>{const N=$?.class_id?.value??null,H=$?.section_id?.value??null;!N||!H||(o(Q=>({...Q,page:1})),d({classId:N,sectionId:H}))},V=()=>{p(""),h(!0),x(null),P(null),z(null),F($=>!$),n.resetFields()},L=async $=>{const N=$?.class_id?.value??null,H=$?.section_id?.value??null,Q=$?.sub_id?.value??null,X=$?.status?.value??"publish",J=$?.title??"",K=$?.remark??"";if(!N||!H||!Q||!J||!K||!f){T.error("Please fill all fields",{duration:1200});return}const Z=new FormData;Z.append("class_id",String(N)),Z.append("section_id",String(H)),Z.append("sub_id",String(Q)),Z.append("title",String(J)),Z.append("remark",String(K)),Z.append("status",String(X)),Z.append("file",String(f));try{await Zt($d.add,Z,t),T.success("Success! Added new item.",{duration:1e3}),h(!1),I()}catch(ee){T.error(ee?.response?.data?.msg??ee?.message??"Failed to add the new item.",{duration:1500})}},B=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:($,N)=>{const H=String(N?.status??"").toLowerCase();return e.jsx(s.Tag,{color:H==="publish"?"green":"red",children:N?.status??"-"})}},{title:"File",key:"file",align:"center",render:($,N)=>{const H=N?.file;if(!H)return"-";const Q=jw(ut(),`uploads/school_${N?.fk_branchID}/student/note/${H}`);return e.jsx("a",{href:Q,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"date",key:"date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:"Add Note",open:c,onCancel:()=>h(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(s.Form,{form:n,layout:"vertical",onFinish:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(ae,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const N=$?.value??null;x(N),n.setFieldValue("section_id",null),n.setFieldValue("sub_id",null),z(N?`${qe.master.sections.byClass}?class_id=${encodeURIComponent(String(N))}`:null),P(N?`${qe.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),F(H=>!H)}},`class_${k}`)}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(ae,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${k}_${u??"none"}`)}),e.jsx(s.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:$=>$,children:e.jsx(ae,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${k}_${j??"none"}`)}),e.jsx(s.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(G,{placeholder:"Title"})}),e.jsx(s.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(G,{placeholder:"Remark"})}),e.jsx(s.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:$=>$,children:e.jsx(ae,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(s.Form.Item,{label:"File",required:!0,children:e.jsx(Pu,{token:t,value:f,onChange:p})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>h(!1),children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Ma,{actions:["add","export","print","download","filter"],onAdd:V,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:a,layout:"vertical",onFinish:Y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(ae,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const N=$?.value??null;a.setFieldValue("section_id",null),d({classId:N,sectionId:null})}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(ae,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(s.Table,{rowKey:$=>$.id,columns:B,dataSource:A,loading:R,pagination:{current:r.page,pageSize:r.perPage,total:_,showSizeChanger:!0,onChange:($,N)=>o({page:$,perPage:N})}})})]})}function ww({token:t}){return e.jsx(Sw,{token:t})}const vw=({token:t})=>q(t?[qe.promoteStudents.sessionDropdown,t]:null,([a,n])=>W(a,n),{revalidateOnFocus:!1}),Fd=qe.transferCertificate,Ai=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[]},Cw={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},_w=(t,a)=>t.inputtype==="Select"?null:t.inputtype==="date"?ne():"",Bd=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}],Ld=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 Aw({token:t,transferCertificateViewPath:a="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:n}){const[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState({page:1,perPage:10}),[c,h]=i.useState({classId:null,sectionId:null,sessionId:null}),[f,p]=i.useState(null),[m,v]=i.useState(!1),{data:S}=q(t?[qe.master.classes.dropdown,t]:null,([B,$])=>W(B,$)),y=i.useMemo(()=>Ai(S),[S]),{data:g}=q(t&&f?[f,t]:null,([B,$])=>W(B,$)),b=i.useMemo(()=>Ai(g),[g]),{data:D}=vw({token:t}),R=i.useMemo(()=>Ai(D),[D]),I=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${Fd.studentList}?class_id=${encodeURIComponent(String(c.classId))}§ion_id=${encodeURIComponent(String(c.sectionId))}&session_id=${encodeURIComponent(String(c.sessionId))}&page=${encodeURIComponent(String(l.page))}&per_page=${encodeURIComponent(String(l.perPage))}`,[c.classId,c.sectionId,c.sessionId,l.page,l.perPage]),{data:A,isLoading:_,mutate:u}=q(t&&I?[I,t]:null,([B,$])=>W(B,$),{revalidateOnFocus:!1,onSuccess:B=>{const $=B?.data?.data??B?.data??[];Array.isArray($)&&$[0]?.transefer_certificate_id&&C(String($[0].transefer_certificate_id))}}),x=i.useMemo(()=>{const B=A?.data?.data??A?.data??A??[];return Array.isArray(B)?B:Array.isArray(B?.data)?B.data:[]},[A]),j=i.useMemo(()=>A?.pagination?.total_rows??A?.pagination?.total??x.length??0,[A,x.length]),[P,O]=i.useState(!1),[z,k]=i.useState(null),[F,C]=i.useState("1"),E=B=>{k(B);const $=F==="1"?Bd(B):Ld(B),N={};$.forEach(H=>{N[H.name]=H.value??_w(H)}),o.setFieldsValue(N),O(!0)},M=async B=>{if(!B)return;if(typeof n=="function")return n(B);const $=`${a}?id=${encodeURIComponent(String(B))}`;window.location.href=$},U=B=>{const $=B?.class_id?.value??null,N=B?.section_id?.value??null,H=B?.session_id?.value??null;if(!$||!N||!H){T.error("Please select Class, Section and Session",{duration:1200});return}d(Q=>({...Q,page:1})),h({classId:$,sectionId:N,sessionId:H})},Y=async B=>{const $=new FormData;Object.entries(B??{}).forEach(([N,H])=>{if(H!=null){if(ne.isDayjs(H)){$.append(N,H.format("YYYY-MM-DD"));return}$.append(N,String(H))}});try{await Zt(Fd.addData,$,t),T.success("Success! Added new item.",{duration:1e3}),O(!1),k(null),u()}catch(N){T.error(N?.response?.data?.msg??N?.message??"Failed to add the new item.",{duration:1500})}},V=i.useMemo(()=>F==="1"?Bd(z):Ld(z),[F,z]),L=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:(B,$)=>e.jsx(s.Button,{type:"text",icon:$?.transfer_certificate_data==="not_present"?e.jsx(re.EyeOutlined,{}):e.jsx(re.CheckOutlined,{}),onClick:()=>{$?.transfer_certificate_data==="not_present"?E($?.id):M($?.id)}})}],[F]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:"Transfer Certificate",open:P,onCancel:()=>O(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:Y,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:V.map(B=>B.inputtype==="hidden"?e.jsx(s.Form.Item,{name:B.name,initialValue:B.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},B.name):B.inputtype==="date"?e.jsx(s.Form.Item,{label:B.label,name:B.name,children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:Cw})},B.name):B.inputtype==="radio"?e.jsx(s.Form.Item,{label:B.label,name:B.name,children:e.jsx(s.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},B.name):B.inputtype==="Select"?e.jsx(s.Form.Item,{label:B.label,name:B.name,getValueFromEvent:$=>$,children:e.jsx(ae,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},B.name):e.jsx(s.Form.Item,{label:B.label,name:B.name,children:e.jsx(G,{placeholder:B.label})},B.name))}),e.jsxs(s.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(de,{type:"submit",value:"Submit",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>O(!1),children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(s.Form,{form:r,layout:"vertical",onFinish:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:B=>B,children:e.jsx(ae,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{const $=B?.value??null;p($?`${qe.master.sections.byClass}?class_id=${encodeURIComponent(String($))}`:null),v(N=>!N),r.setFieldValue("section_id",null)}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:B=>B,children:e.jsx(ae,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${m}`)}),e.jsx(s.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:B=>B,children:e.jsx(ae,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Ma,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:B=>B.id,columns:L,dataSource:x,loading:_,pagination:{current:l.page,pageSize:l.perPage,total:j,showSizeChanger:!0,onChange:(B,$)=>d({page:B,perPage:$})}})})]})}function Tw({token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:n}){return e.jsx(Aw,{token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:n})}const Dw=({token:t,url:a})=>q(t&&a?[a,t]:null,([n,r])=>W(n,r),{revalidateOnFocus:!1}),Ti=qe.syllabus,Ud=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[]},kw=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r};function Rw({token:t}){const[a]=s.Form.useForm(),[n]=s.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null}),[c,h]=i.useState(!1),[f,p]=i.useState(null),[m,v]=i.useState(""),{data:S}=q(t?[qe.master.classes.dropdown,t]:null,([M,U])=>W(M,U)),y=i.useMemo(()=>Ud(S),[S]),g=i.useMemo(()=>l.classId?`${Ti.table}?class_id=${encodeURIComponent(String(l.classId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`:null,[l.classId,r.page,r.perPage]),{data:b,isLoading:D,mutate:R}=Dw({token:t,url:g}),I=i.useMemo(()=>{const M=b?.data?.data??b?.data??b??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},[b]),A=i.useMemo(()=>b?.pagination?.total_rows??b?.pagination?.total??I.length??0,[b,I.length]),[_,u]=i.useState(null),[x,j]=i.useState(!1),{data:P}=q(t&&_?[_,t]:null,([M,U])=>W(M,U),{revalidateOnFocus:!1}),O=i.useMemo(()=>Ud(P),[P]),z=M=>{const U=M?.class_id?.value??null;U&&(o(Y=>({...Y,page:1})),d({classId:U}))},k=()=>{p(null),v(""),u(null),j(M=>!M),n.resetFields(),h(!0)},F=M=>{p(M),v(M?.attchement??"");const U=M?.class_id;u(U?`${qe.master.subjects.dropdown}?class_id=${encodeURIComponent(String(U))}`:null),j(Y=>!Y),n.setFieldsValue({class_id:y.find(Y=>String(Y.value)===String(U))??null,sub_id:O.find(Y=>String(Y.value)===String(M?.sub_id??M?.subject_id))??(M?.sub_id||M?.subject_id?{label:M?.subject_title??"Subject",value:M?.sub_id??M?.subject_id}:null),title:M?.title??"",description:M?.description??""}),h(!0)},C=async M=>{const U=M?.class_id?.value??null,Y=M?.sub_id?.value??null,V=M?.title??"",L=M?.description??"";if(!U||!Y||!V||!L||!m){T.error("Please fill all fields",{duration:1200});return}const B=new FormData;B.append("class_id",String(U)),B.append("sub_id",String(Y)),B.append("title",String(V)),B.append("description",String(L)),B.append("file",String(m));try{f?.id?(B.append("id",String(f.id)),await Zt(Ti.edit,B,t),T.success("Success! Updated item.",{duration:1e3})):(await Zt(Ti.add,B,t),T.success("Success! Added new item.",{duration:1e3})),h(!1),p(null),R()}catch($){T.error($?.response?.data?.msg??$?.message??"Failed to save",{duration:1500})}},E=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:(M,U)=>{const Y=U?.attchement;if(!Y)return"-";const V=kw(ut(),`uploads/school_${U?.fk_branchID}/student/syllabus/${Y}`);return e.jsx("a",{href:V,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(M,U)=>e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>F(U)})}],[O,y]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:f?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{h(!1),p(null),v("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(s.Form,{form:n,layout:"vertical",onFinish:C,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(ae,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const U=M?.value??null;n.setFieldValue("sub_id",null),u(U?`${qe.master.subjects.dropdown}?class_id=${encodeURIComponent(String(U))}`:null),j(Y=>!Y)}},`class_${f?.id??"add"}_${x}`)}),e.jsx(s.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:M=>M,children:e.jsx(ae,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${f?.id??"add"}_${x}_${_??"none"}`)}),e.jsx(s.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(G,{placeholder:"Title"})}),e.jsx(s.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(kt,{placeholder:"Description"})}),e.jsx(s.Form.Item,{label:"File",required:!0,children:e.jsx(Pu,{token:t,value:m,onChange:v,action:RS(),filePath:"student/syllabus"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>h(!1),children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Ma,{actions:["add","export","print","download","filter"],onAdd:k,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:a,layout:"vertical",onFinish:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(ae,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(s.Table,{rowKey:M=>M.id,columns:E,dataSource:I,loading:D,pagination:{current:r.page,pageSize:r.perPage,total:A,showSizeChanger:!0,onChange:(M,U)=>o({page:M,perPage:U})}})})]})}function Iw({token:t}){return e.jsx(Rw,{token:t})}const Yr=qe.timetable,Nd=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[]},zd=t=>{if(!t)return"";const a=ne(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},Pw=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let n=0;for(let o=0;o<a.length;o+=1)n=(n*31+a.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[n%r.length]},qd=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Mw=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"};function Ew({token:t}){const[a,n]=i.useState(null),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,h]=i.useState(""),[f,p]=i.useState(""),{data:m}=q(t?[qe.master.classes.dropdown,t]:null,([u,x])=>W(u,x)),v=i.useMemo(()=>Nd(m),[m]),{data:S}=q(t&&a?[a,t]:null,([u,x])=>W(u,x)),y=i.useMemo(()=>Nd(S),[S]),{data:g,isLoading:b}=q(t&&l?[l,t]:null,([u,x])=>W(u,x),{revalidateOnFocus:!1}),D=i.useMemo(()=>g?.days??g?.data?.days??g?.data?.data?.days??{},[g]),{dataSource:R,daySpanByFirstKey:I}=i.useMemo(()=>{const u=Object.entries(D||{}).slice().sort((P,O)=>qd.indexOf(String(P[0]).toLowerCase())-qd.indexOf(String(O[0]).toLowerCase())),x=new Map,j=[];for(const[P,O]of u){const z=(Array.isArray(O)?O:[]).slice().sort((F,C)=>Number(F?.order_no||0)-Number(C?.order_no||0)),k=z.length;for(let F=0;F<k;F+=1){const C=z[F],E=C?.id||`${P}-${C?.order_no}-${F}`;F===0&&x.set(E,k),j.push({key:E,_dayKey:P,...C})}}return{dataSource:j,daySpanByFirstKey:x}},[D]),A=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(u,x)=>{const j=I.get(x.key);return j===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(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Mw(u)})]}),props:{rowSpan:j}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:u=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:u})},{title:"Time",key:"time",width:180,render:(u,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(re.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[zd(x?.time_from)," - ",zd(x?.time_to)]})]})},{title:"Subject",key:"subject",render:(u,x)=>{if(String(x?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const P=x?.subject_name||"-";return e.jsx(s.Tag,{color:Pw(P),style:{fontWeight:500},children:P})}},{title:"Teacher",key:"teacher",render:(u,x)=>{const j=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(s.Typography.Text,{children:j?"-":x?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(u,x)=>{const j=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(s.Typography.Text,{children:j?"-":x?.room_no||"-"})]})}}],[I]),_=u=>{u.preventDefault();const x=u.target.class_id?.value,j=u.target.section_id?.value;if(!x||!j)return;const P=v.find(F=>String(F.value)===String(x)),O=y.find(F=>String(F.value)===String(j));h(P?.label||""),p(O?.label||"");const k=`${Yr.byClassSection}/${x}/section/${j}`;d(k)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Ma,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:u=>{n(`${qe.master.sections.byClass}?class_id=${encodeURIComponent(String(u?.value??""))}`),o(x=>!x)}}),e.jsx(ae,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${r}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:c||f?`Timetable: ${c} ${f}`:"Timetable"}),children:e.jsx(s.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:R,columns:A,rowKey:"key",loading:b,scroll:{x:"max-content"}})})]})}const Ow=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[]},Yd=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],$w=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"},Wd=t=>{if(!t)return"";const a=ne(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},Fw=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let n=0;for(let o=0;o<a.length;o+=1)n=(n*31+a.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[n%r.length]};function Bw({token:t}){const[a,n]=i.useState(null),[r,o]=i.useState(null),{data:l}=q(t?[qe.assignByClass.teacherDropdown,t]:null,([S,y])=>W(S,y)),d=i.useMemo(()=>Ow(l),[l]),{data:c,isLoading:h}=q(t&&r?[r,t]:null,([S,y])=>W(S,y),{revalidateOnFocus:!1}),{dataSource:f,daySpanByFirstKey:p}=i.useMemo(()=>{const y=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((R,I)=>{const A=Yd.indexOf(String(R?.day_name||"").toLowerCase()),_=Yd.indexOf(String(I?.day_name||"").toLowerCase());if(A!==_)return A-_;const u=Number(R?.order_no||0),x=Number(I?.order_no||0);return u!==x?u-x:String(R?.time_from||"").localeCompare(String(I?.time_from||""))}),g=new Map,b=[];let D=0;for(;D<y.length;){const R=String(y[D]?.day_name||"").toLowerCase();let I=D;for(;I<y.length&&String(y[I]?.day_name||"").toLowerCase()===R;)I+=1;const A=I-D;for(let _=D;_<I;_+=1){const u=y[_],x=u?.id||`${R}-${u?.order_no}-${_}`;_===D&&g.set(x,A),b.push({key:x,_dayKey:R,...u})}D=I}return{dataSource:b,daySpanByFirstKey:g}},[c]),m=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(S,y)=>{const g=p.get(y.key);return g===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(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:$w(S)})]}),props:{rowSpan:g}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:S=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:S})},{title:"Time",key:"time",width:180,render:(S,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(re.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[Wd(y?.time_from)," - ",Wd(y?.time_to)]})]})},{title:"Subject",key:"subject",render:(S,y)=>{if(String(y?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const b=y?.subject_name||"-";return e.jsx(s.Tag,{color:Fw(b),style:{fontWeight:500},children:b})}},{title:"Class",key:"class",width:160,render:(S,y)=>e.jsxs(s.Tag,{color:"purple",style:{fontWeight:500},children:[y?.class_name||y?.class_id||"-"," ",y?.section_name?`(${y.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(S,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(re.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:y?.room_no||"-"})]})}],[p]),v=S=>{S.preventDefault();const y=S.target.teacher_id?.value;if(!y)return;n(y);const b=`${Yr.teacherTimetable}${encodeURIComponent(String(y))}`;o(b)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Ma,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ae,{options:d,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teacher",name:"teacher_id",allowSelectAll:!1,required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(s.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:f,columns:m,rowKey:"key",loading:h,scroll:{x:"max-content"}})})]})}function Vd(t){if(!t)return null;const a=String(t).trim().replaceAll(".",":");if(!a)return null;const n=a.toLowerCase(),r=n.includes("am")||n.includes("pm");let o=0,l=0,d=0;if(r){const h=n.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!h)return null;o=Number.parseInt(h[1],10),l=Number.parseInt(h[2],10),d=Number.parseInt(h[3]||"0",10);const f=h[4].toLowerCase();f==="pm"&&o<12&&(o+=12),f==="am"&&o===12&&(o=0)}else{const c=a.split(":").map(h=>h.trim());if(c.length<2)return null;o=Number.parseInt(c[0],10),l=Number.parseInt(c[1],10),d=Number.parseInt(c[2]||"0",10)}return![o,l,d].every(c=>Number.isFinite(c))||o<0||o>23||l<0||l>59||d<0||d>59?null:ne().hour(o).minute(l).second(d).millisecond(0)}function Gn(t,a){const n=Number.parseInt(a,10);return!Number.isFinite(n)||n<0||!t||!t.isValid?.()?null:t.add(n,"minute")}const pr=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[]},ns={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},Lw=t=>{const a=ns[String(t)];return a?a.charAt(0).toUpperCase()+a.slice(1):String(t)},Uw=({token:t,classId:a,sectionId:n,subjectId:r,value:o,onChange:l,disabled:d,showError:c})=>{const h=t&&a&&n&&r?`${Yr.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(a))}§ion_id=${encodeURIComponent(String(n))}`:null,{data:f,isLoading:p}=q(h?[h,t]:null,([v,S])=>W(v,S),{revalidateOnFocus:!1}),m=i.useMemo(()=>pr(f?.data??f).map(S=>({value:S?.value??S?.id,label:S?.label??S?.name??S?.teacher_name??""})),[f]);return e.jsx(s.Select,{placeholder:d?"-":"Select Teacher",loading:p,disabled:d,style:{width:"100%"},options:m,value:o?String(o):void 0,onChange:v=>l?.(v),showSearch:!0,optionFilterProp:"label",status:c?"error":void 0})};function Nw({token:t}){const[a]=s.Form.useForm(),[n,r]=i.useState({classId:null,sectionId:null,dayKey:"1",daysEnabled:{0:!1,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}),[o,l]=i.useState({startTime:null,endTime:null,duration:40,interval:0,roomNo:"",tiffinEnabled:!1,tiffinAfterPeriod:3,tiffinDuration:20}),[d,c]=i.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[h,f]=i.useState(!1),p=i.useMemo(()=>t?qe.master.classes.dropdown:null,[t]),{data:m}=q(p?[p,t]:null,([k,F])=>W(k,F)),v=i.useMemo(()=>pr(m).map(k=>({value:k?.value??k?.id,label:k?.label??k?.title??""})),[m]),S=i.useMemo(()=>!t||!n.classId?null:`${qe.master.sections.byClass}?class_id=${encodeURIComponent(String(n.classId))}`,[n.classId,t]),{data:y}=q(S?[S,t]:null,([k,F])=>W(k,F)),g=i.useMemo(()=>pr(y).map(k=>({value:k?.value??k?.id,label:k?.label??k?.title??""})),[y]),b=i.useMemo(()=>!t||!n.classId?null:`${qe.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(n.classId))}`,[n.classId,t]),{data:D}=q(b?[b,t]:null,([k,F])=>W(k,F)),R=i.useMemo(()=>pr(D).map(k=>({value:k?.value??k?.id,label:k?.label??k?.title??""})),[D]),I=i.useMemo(()=>Array.isArray(d?.[n.dayKey])?d[n.dayKey]:[],[n.dayKey,d]),A=i.useCallback((k,F,C)=>{c(E=>{const M={...E},U=Array.isArray(M[k])?M[k].slice():[];return U[F]={...U[F]??{},...C},M[k]=U,M})},[]),_=i.useCallback((k,F)=>{c(C=>{const E={...C},M=Array.isArray(E[k])?E[k].slice():[];return M.splice(F,1),E[k]=M.map((U,Y)=>({...U,order_no:Y+1})),E})},[]),u=i.useCallback(k=>{c(F=>{const C={...F},E=Array.isArray(C[k])?C[k].slice():[];let M=null,U=null;const Y=E[E.length-1];if(Y?.time_to){const V=Vd(Y.time_to),L=Number.parseInt(o.interval,10)||0,B=Number.parseInt(o.duration,10)||0,$=Gn(V,L),N=B>0?Gn($,B):null;M=$?.isValid?.()?$.format("HH:mm:ss"):null,U=N?.isValid?.()?N.format("HH:mm:ss"):null}return E.push({order_no:E.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:M,time_to:U,is_break:!1}),C[k]=E,C})},[o.duration,o.interval,o.roomNo]),x=i.useCallback(()=>{const k=o.startTime,F=o.endTime,C=Number.parseInt(o.duration,10),E=Number.parseInt(o.interval,10);if(!k||!k.isValid?.()){T.error("Start time is required",{duration:1500});return}if(!F||!F.isValid?.()){T.error("End time is required",{duration:1500});return}if(!F.isAfter(k)){T.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(C)||C<=0){T.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(E)||E<0){T.error("Interval must be 0 or more",{duration:1500});return}const M=()=>{const U=[];let Y=k;for(let V=0;V<50;V+=1){const L=Gn(Y,C);if(!L||!L.isValid?.()||L.isAfter(F))break;U.push({order_no:U.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:Y.format("HH:mm:ss"),time_to:L.format("HH:mm:ss"),is_break:!1});const B=Gn(L,E);if(!B||!B.isValid?.()||B.isAfter(F)||B.isSame(F))break;Y=B}if(o.tiffinEnabled){const V=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),L=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),B=Math.min(V,U.length);if(B>0&&L>0){const $=U[B-1],N=$?.time_to?Vd($.time_to):null,H=N?Gn(N,L):null;N?.isValid?.()&&H?.isValid?.()&&!H.isAfter(F)&&U.splice(B,0,{order_no:B+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:N.format("HH:mm:ss"),time_to:H.format("HH:mm:ss"),is_break:!0})}}return U.map((V,L)=>({...V,order_no:L+1}))};c(U=>{const Y={...U};return Object.keys(ns).forEach(V=>{n.daysEnabled?.[V]?Y[V]=M():Y[V]=[]}),Y}),T.success("Generated schedule",{duration:1e3})},[o,n.daysEnabled]),j=i.useCallback(()=>{const k=localStorage.getItem("genrall_settings"),C=(k?JSON.parse(k):{})?.session_id??"1",E=n.classId,M=n.sectionId,U=Object.keys(ns).map(Y=>{const V=(Array.isArray(d?.[Y])?d[Y]:[]).map((L,B)=>({order_no:B+1,subject_id:L?.is_break?0:L?.subject_id??null,teacher_id:L?.is_break?0:L?.teacher_id??null,room_no:L?.room_no??"",time_from:L?.time_from??null,time_to:L?.time_to??null,is_break:L?.is_break?1:0}));return{day:ns[Y],class_id:E,section_id:M,session_id:C,args:V}});return{class_id:E,section_id:M,session_id:C,days:U}},[n.classId,n.sectionId,d]),P=i.useCallback(async()=>{if(!n.classId||!n.sectionId){T.error("Please select Class and Section",{duration:1500});return}const k=j(),F=Array.isArray(k?.days)?k.days:[];if(!F.some(U=>Array.isArray(U?.args)&&U.args.length>0)){T.error("No timetable rows to submit",{duration:1500});return}const E=U=>{const Y=U?.is_break;return Y===1||Y==="1"||Y===!0?!0:String(Y??"").toLowerCase()==="true"};if(F.some(U=>(Array.isArray(U?.args)?U.args:[]).some(Y=>!(String(Y?.time_from??"").trim()&&String(Y?.time_to??"").trim())||E(Y)?!1:!String(Y?.subject_id??"").trim()||!String(Y?.teacher_id??"").trim()))){T.error("Fill Time for all rows, and Subject/Teacher for non-break rows",{duration:2e3});return}f(!0);try{const U=Yr.save,Y=U==="api/timetable/save"?"timetable/save":null,V=async $=>{const N=await hs($,k,t);if(N&&typeof N=="object")return N;throw new Error("No response from server")};let L;try{L=await V(U)}catch{L=await V(Y)}const B=String(L?.msg??"");if(String(L?.Status)==="Success"){if(Array.isArray(L?.data)&&L.data.length===0&&B){T.success(B,{duration:3e3});return}T.success(B||"Weekly Time Table added successfully!",{duration:1200});return}T.error(B||"Failed to add time table",{duration:3e3})}catch(U){T.error(U?.response?.data?.msg??U?.message??"Failed to add time table",{duration:3e3})}finally{f(!1)}},[j,n.classId,n.sectionId,t]),O=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:k=>k?ne(k,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:k=>k?ne(k,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(k,F,C)=>e.jsx(s.Switch,{checked:!!F?.is_break,onChange:E=>{A(n.dayKey,C,{is_break:E,subject_id:E?"":F?.subject_id??"",teacher_id:E?"":F?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(k,F,C)=>{const E=!!F?.is_break,M=String(F?.subject_id??"").trim()!=="",U=String(F?.time_from??"").trim()&&String(F?.time_to??"").trim(),Y=!E&&U&&!M;return e.jsx(s.Select,{placeholder:E?"-":"Select Subject",disabled:E,style:{width:"100%"},options:R,value:F?.subject_id?String(F.subject_id):void 0,onChange:V=>A(n.dayKey,C,{subject_id:V,teacher_id:""}),showSearch:!0,optionFilterProp:"label",status:Y?"error":void 0})}},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(k,F,C)=>{const E=!!F?.is_break,M=String(F?.subject_id??"").trim()!=="",U=String(F?.teacher_id??"").trim()!=="",Y=String(F?.time_from??"").trim()&&String(F?.time_to??"").trim(),V=!E&&Y&&M&&!U;return e.jsx(Uw,{token:t,classId:n.classId,sectionId:n.sectionId,subjectId:F?.subject_id,disabled:!!F?.is_break||!F?.subject_id,value:F?.teacher_id,onChange:L=>A(n.dayKey,C,{teacher_id:L}),showError:V})}},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(k,F,C)=>e.jsx(s.Input,{value:F?.room_no??"",onChange:E=>A(n.dayKey,C,{room_no:E.target.value})})},{title:"Action",key:"action",width:90,render:(k,F,C)=>e.jsx(s.Popconfirm,{title:"Delete this row?",onConfirm:()=>_(n.dayKey,C),children:e.jsx(s.Button,{danger:!0,type:"text",children:"Delete"})})}],[n.classId,n.dayKey,n.sectionId,_,R,t,A]),z=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsxs(s.Form,{form:a,layout:"vertical",initialValues:{duration:o.duration,interval:o.interval,roomNo:o.roomNo,tiffinEnabled:o.tiffinEnabled,tiffinAfterPeriod:o.tiffinAfterPeriod,tiffinDuration:o.tiffinDuration},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",required:!0,children:e.jsx(s.Select,{placeholder:"Select Class",options:v,value:n.classId?String(n.classId):void 0,onChange:k=>{r(F=>({...F,classId:k,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(s.Form.Item,{label:"Section",required:!0,children:e.jsx(s.Select,{placeholder:"Select Section",options:g,value:n.sectionId?String(n.sectionId):void 0,onChange:k=>r(F=>({...F,sectionId:k})),disabled:!n.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(s.Form.Item,{label:"Start Time",required:!0,children:e.jsx(s.TimePicker,{value:o.startTime,onChange:k=>l(F=>({...F,startTime:k})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"End Time",required:!0,children:e.jsx(s.TimePicker,{value:o.endTime,onChange:k=>l(F=>({...F,endTime:k})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(s.InputNumber,{min:1,value:o.duration,onChange:k=>l(F=>({...F,duration:k})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Interval (min)",children:e.jsx(s.InputNumber,{min:0,value:o.interval,onChange:k=>l(F=>({...F,interval:k})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Room No",children:e.jsx(s.Input,{value:o.roomNo,onChange:k=>l(F=>({...F,roomNo:k.target.value}))})}),e.jsx(s.Form.Item,{label:"Tiffin Break",children:e.jsxs(s.Space,{children:[e.jsx(s.Switch,{checked:o.tiffinEnabled,onChange:k=>l(F=>({...F,tiffinEnabled:k}))}),e.jsx(s.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(s.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(s.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:k=>l(F=>({...F,tiffinAfterPeriod:k})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(s.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(s.InputNumber,{min:1,value:o.tiffinDuration,onChange:k=>l(F=>({...F,tiffinDuration:k})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(s.Button,{onClick:x,children:"Generate"}),e.jsx(s.Button,{type:"primary",loading:h,onClick:P,children:"Save"})]})]}),e.jsx(s.Divider,{style:{margin:"16px 0"},children:"Weekly Day Set"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"flex-end"}})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(s.Space,{children:[e.jsx(s.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(s.Select,{style:{width:160},value:n.dayKey,onChange:k=>r(F=>({...F,dayKey:k})),options:Object.keys(ns).map(k=>({value:String(k),label:Lw(k)}))}),e.jsx(s.Button,{onClick:()=>u(n.dayKey),children:"Add Row"})]}),children:e.jsx(s.Table,{rowKey:(k,F)=>`${n.dayKey}_${F}`,columns:O,dataSource:I,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(s.Tabs,{type:"card",items:[{key:"create",label:"Create",children:z},{key:"routine",label:"Routine",children:e.jsx(Ew,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(Bw,{token:t})}]})]})}function zw({token:t}){return e.jsx(Nw,{token:t})}function qw(){return null}const Ja=t=>t??localStorage.getItem("authToken")??"",Yw=(t,a)=>{const n=String(t??""),r=String(a);return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},lt={organization:{get:"api/branchapi/generalSettings/getorganizationsettingsData",save:"api/branchapi/generalSettings/addorganizationSetting",currencyDropdown:"api/branchapi/generalSettings/currencyDropdown",countryCodeDropdown:"api/branchapi/generalSettings/contrycodeDropdown",timezoneDropdown:"api/branchapi/generalSettings/timezoneDropdown",boardsDropdown:"api/branchapi/generalSettings/getAffliatedBoardsDropDown",uploadLogo:"api/superAdmin/upload_logo",uploadSignature:"api/branchapi/generalSettings/upload_signature",uploadFirebaseJson:"api/branchapi/generalSettings/firebaseJsonUpload"},academicYear:{table:"api/branchapi/generalSettings/sessiontable",add:"api/branchapi/generalSettings/addsession",setActive:"api/branchapi/generalSettings/setsession",remove:"api/branchapi/generalSettings/deletesession"},feeReceiptSetting:{get:"api/branchapi/generalSettings/feesReceiptSettingData",save:"api/branchapi/generalSettings/feesReceiptSetting"},marksheetSetting:{templateTypes:"api/branchapi/GeneralSettings/getmarkssheetTemplate",classDropdown:"api/exam/exam/getClassforAssignMarksSheetType",assignedTable:"api/branchapi/GeneralSettings/getassign_templete",assign:"api/branchapi/GeneralSettings/assign_templete",remove:"api/branchapi/GeneralSettings/deleteTemplate"},legalPages:{get:"api/branchapi/generalSettings/getlegalpage",termsSave:"api/branchapi/generalSettings/terms",privacySave:"api/branchapi/generalSettings/privacy",aboutSave:"api/branchapi/generalSettings/about_us"},feesInfo:{get:"api/branchapi/generalSettings/getFeesInfo",save:"api/branchapi/generalSettings/addFeesInfo",statesDropdown:"api/superAdmin/states"},payrollSettings:{table:"api/branchapi/GeneralSettings/getsetting_allowances_dedection",add:"api/branchapi/GeneralSettings/addsetting_allowances_dedection",edit:"api/branchapi/GeneralSettings/updatesetting_allowances_dedection",remove:"api/branchapi/GeneralSettings/deletesetting_allowances_dedection",byId:"api/branchapi/GeneralSettings/getsetting_allowances_dedectionById"},paymentGateway:{get:"api/payment_gateway/PaymentProcess/getPaymentGatewayList",save:"api/payment_gateway/PaymentProcess"},smsGateway:{get:"api/branchapi/generalSettings/smsalertsettingData",save:"api/branchapi/generalSettings/addsmsalertsetting"},smsDetails:{get:"api/branchapi/generalSettings/smsdetailsData",save:"api/branchapi/generalSettings/addsmsdetails"},smsTemplates:{table:"api/branchapi/communication/Sms/templatetableList",add:"api/branchapi/communication/Sms/addtemplate",edit:"api/branchapi/communication/Sms/edittemplate",delete:"api/branchapi/communication/Sms/deletetemplate",changeStatus:"api/branchapi/communication/Sms/changetemplatestatus",templateDropdown:"api/branchapi/communication/Sms/templatedropdown"},smsCompose:{templateDropdown:"api/branchapi/communication/Sms/templatedropdown",classDropdown:"api/branchapi/academy/classdropdownlist",sectionByClass:"api/branchapi/academy/sectionoftheClass",roleDropdown:"api/Branch/getRoledropdownforBranch",staffSearch:"api/branchapi/staff/staffsearchbyKeywords",studentDropdown:"api/branchapi/student/studentDropdown",sendMessage:"api/branchapi/communication/Message"},chat:{whatsappBaseUrl:"",groupList:"api/branchapi/communication/Message/whatappgroupList",groupCreate:"api/branchapi/communication/Message/createWhatsappGroup",teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classDropdown:"api/branchapi/academy/classdropdownlist",sectionByClass:"api/branchapi/academy/sectionoftheClass",roleDropdown:"api/Branch/getRoledropdownforBranch"},getMessages:t=>`${String(t??"")}/api/messages`,getSendMessages:t=>`${String(t??"")}/api/messages/send`},Ww=t=>Yw(Nt(),t),Vw=async({baseUrl:t,page:a=1,perPage:n=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(n))}`;return W(l,Ja(r))},Hw=async(t,a)=>W(t,Ja(a)),js=async(t,a,n)=>Ze(t,a,Ja(n)),Mu=async(t,a,n)=>ct(t,a,Ja(n)),xo=async(t,a,n)=>st(t,a,Ja(n)),Kw=async(t,a,n)=>hs(t,{arg:a},Ja(n)),Eu=async(t,a,n)=>gn(t,{arg:a},Ja(n)),Ou=({baseUrl:t,page:a=1,perPage:n=10,token:r})=>q(r&&t?[t,a,n,r]:null,([l,d,c,h])=>Vw({baseUrl:l,page:d,perPage:c},h)),qt=({url:t,token:a})=>q(a&&t?[t,a]:null,([r,o])=>Hw(r,o)),Gw={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function Jw({value:t,onChange:a,placeholder:n}){const[r,o]=i.useState(t??""),l=i.useMemo(()=>typeof t=="string"?t:r,[r,t]);return e.jsx("div",{style:Gw,children:e.jsx(nu,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),a?.(c)},style:{outline:"none",minHeight:280},placeholder:n})})}function Ea({title:t,actions:a,children:n,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:n})}const Qw=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function bo({token:t,title:a,fetchUrl:n,saveUrl:r,fieldName:o,initialHtmlFieldName:l}){const d=i.useRef(null),c=qt({url:n,token:t}),f=i.useMemo(()=>Qw(c.data),[c.data])?.[l??o]??"",[p,m]=i.useState("");i.useEffect(()=>{m(typeof f=="string"?f:"")},[f]);const v=()=>m(typeof f=="string"?f:""),S=()=>{const b=new Blob([String(p??"")],{type:"text/html"}),D=URL.createObjectURL(b),R=document.createElement("a");R.href=D,R.download=`${String(a??"legal").toLowerCase().replaceAll(" ","-")}.html`,R.click(),URL.revokeObjectURL(D)},y=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(re.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(re.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(re.ReloadOutlined,{}),onClick:v},{key:"export",label:"Export",icon:e.jsx(re.ExportOutlined,{}),onClick:S,disabled:!p}],[p,f]),g=async b=>{b.preventDefault();try{(await Eu(r,{[o]:p??""},t))?.Status==="Success"?T.success("Updated successfully.",{duration:1e3}):T.success("Updated.",{duration:1e3}),c.mutate?.()}catch(D){T.error(D?.response?.data?.msg??D?.message??"Failed to update.",{duration:1500})}};return c.isLoading&&!c.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ea,{title:a,actions:y,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:g,children:[e.jsx(Jw,{value:p,onChange:m,placeholder:`Enter ${a} content...`}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Update"})})]})})})]})}const Xw=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Zw=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function ss({token:t,value:a,onChange:n,action:r,accept:o,maxCount:l=1,previewUrl:d,data:c}){const h=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),f=i.useMemo(()=>a?d||(Zw(a)?a:""):"",[d,a]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[f?e.jsx("img",{src:f,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(s.Upload,{maxCount:l,action:r,data:c,accept:o,headers:h,onChange:p=>{if(p?.file?.status==="removed"&&n?.(""),p?.file?.status==="done"){const m=Xw(p?.file?.response);m&&n?.(m)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})]})}const Qa=lt.organization,ev=()=>Ww(Qa.uploadFirebaseJson),tv=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],av=({token:t})=>qt({url:Qa.get,token:t}),nv=({token:t})=>qt({url:Qa.currencyDropdown,token:t}),sv=({token:t})=>qt({url:Qa.countryCodeDropdown,token:t}),rv=({token:t})=>qt({url:Qa.timezoneDropdown,token:t}),iv=({token:t})=>qt({url:Qa.boardsDropdown,token:t}),Ks=t=>tv(t?.data),ov=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},$u=t=>{const a=ya(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},lv=(t,a)=>{const n=`${t||""}`.trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;const r=$u(a),o=n.startsWith("/")?n.slice(1):n;return ov(ut(),`uploads/school_${r}/schoolFile/${o}`)},Hd={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},dv=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),Kd=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],Gd=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],cv=t=>{const a=t?.data;return Array.isArray(a?.data)?a.data[0]??null:Array.isArray(a)?a[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},uv=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,pv=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function mv({token:t}){const a=i.useRef(null),n=av({token:t}),r=nv({token:t}),o=sv({token:t}),l=rv({token:t}),d=iv({token:t}),c=i.useMemo(()=>cv(n.data),[n.data]),h=i.useMemo(()=>uv(n.data),[n.data]),f=i.useMemo(()=>pv(n.data),[n.data]),p=i.useMemo(()=>Ks(r),[r.data]),m=i.useMemo(()=>Ks(o),[o.data]),v=i.useMemo(()=>Ks(l),[l.data]),S=i.useMemo(()=>Ks(d),[d.data]),[y,g]=i.useState(null),[b,D]=i.useState(null),[R,I]=i.useState(null),[A,_]=i.useState(null),[u,x]=i.useState([]),[j,P]=i.useState("No"),[O,z]=i.useState("yes"),[k,F]=i.useState("no"),[C,E]=i.useState("Yes"),[M,U]=i.useState(""),[Y,V]=i.useState(""),[L,B]=i.useState(!1),[$,N]=i.useState(""),[H,Q]=i.useState(null),[X,J]=i.useState(null),[K,Z]=i.useState(null),[ee,pe]=i.useState(null),te=()=>{const xe=(()=>{try{const De=c?.weekly_off;if(!De)return[];const Ue=Array.isArray(De)?De:JSON.parse(De);return Array.isArray(Ue)?Ue.filter(Boolean).map(ye=>({value:ye,label:ye})):[]}catch{return[]}})();x(xe),g(p.find(De=>De?.value===c?.currency)??null),D(m.find(De=>De?.value===c?.country_code)??null),I(v.find(De=>De?.value===c?.time_zone)??null),_(S.find(De=>De?.value===c?.affliated_board_id)??null),U(c?.logo??""),V(c?.json_file??""),P(c?.attendance_salary_calculation??"No"),z(c?.salary_period??"yes"),F(c?.multiple_shift??"no"),E(c?.readmission_charges??"Yes"),Q(h?.in_from?ne(h.in_from,"h:mm A"):null),J(h?.in_to?ne(h.in_to,"h:mm A"):null),Z(h?.out_from?ne(h.out_from,"h:mm A"):null),pe(h?.out_to?ne(h.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&te()},[c,p,m,v,S]);const se=()=>{a.current?.reset?.(),te()},le=()=>{const xe=new FormData(a.current??void 0),De=Object.fromEntries(xe.entries());De.weekly_off_day=u.map(Pe=>Pe?.value).filter(Boolean);const Ue=new Blob([JSON.stringify(De,null,2)],{type:"application/json"}),ye=URL.createObjectURL(Ue),me=document.createElement("a");me.href=ye,me.download="organization-setting.json",me.click(),URL.revokeObjectURL(ye)},Ce=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(re.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(re.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(re.ReloadOutlined,{}),onClick:se},{key:"export",label:"Export",icon:e.jsx(re.ExportOutlined,{}),onClick:le,disabled:!c}],[c,u]),Le=async xe=>{xe.preventDefault();try{const De=new FormData(xe.target);De.set("currency",y?.value??""),De.set("code",b?.value??""),De.set("time_zone",R?.value??""),De.set("affliated_board_id",A?.value??""),De.set("board_name",A?.label??""),De.set("attendance_salary_calculation",j),De.set("salary_period",O),De.set("multiple_shift",k),De.set("readmission_charges",C),u.forEach(me=>{me?.value&&De.append("weekly_off_day[]",me.value)}),De.set("logo",M??""),De.set("json_file",Y??""),De.set("server_key",f?.server_key??""),De.set("in_time_start",H?ne(H).format("h:mm A"):""),De.set("in_time_end",X?ne(X).format("h:mm A"):""),De.set("out_time_start",K?ne(K).format("h:mm A"):""),De.set("out_time_end",ee?ne(ee).format("h:mm A"):""),await js(Qa.save,De,t);const ye={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:M||c?.logo||"",affliated_board_id:A?.value??c?.affliated_board_id??"",board_name:A?.label??c?.board_name??"",multiple_shift:k??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(ye)),T.success("Organization settings saved.",{duration:1e3}),n.mutate?.()}catch(De){T.error(De?.response?.data?.msg??De?.message??"Failed to save settings.",{duration:1500})}},Re=j==="Yes";return n.isLoading&&!n.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ea,{title:"Organization",actions:Ce,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:a,onSubmit:Le,children:[e.jsxs("div",{style:Hd,children:[e.jsx(G,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(ae,{label:"Currency*",options:p,value:y,onChange:xe=>g(xe)}),e.jsx("input",{type:"hidden",name:"currency",value:y?.value??""})]}),e.jsxs("div",{children:[e.jsx(ae,{label:"Default Country Code*",options:m,value:b,onChange:xe=>D(xe)}),e.jsx("input",{type:"hidden",name:"code",value:b?.value??""})]}),e.jsxs("div",{children:[e.jsx(ae,{label:"Time Zone*",options:v,value:R,onChange:xe=>I(xe)}),e.jsx("input",{type:"hidden",name:"time_zone",value:R?.value??""})]}),e.jsx(G,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(G,{type:"number",name:"admission_start_number",label:"Admission Start Number*",required:!0,defaultValue:c?.admission_no_prefix??c?.admission_start_number??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Re-admission Charges"}),e.jsx(s.Radio.Group,{options:Kd,optionType:"button",buttonStyle:"solid",value:C,onChange:xe=>E(xe.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:C})]}),e.jsxs("div",{children:[e.jsx(ae,{label:"Weekly off Day",options:dv,isMulti:!0,value:u,onChange:xe=>x(xe??[])}),u.map(xe=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:xe.value},xe.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:H,onChange:xe=>Q(xe),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:H?ne(H).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time End*"}),e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:X,onChange:xe=>J(xe),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:X?ne(X).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time Start*"}),e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:K,onChange:xe=>Z(xe),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:K?ne(K).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time End*"}),e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:ee,onChange:xe=>pe(xe),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:ee?ne(ee).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Period"}),e.jsx(s.Radio.Group,{options:Gd,optionType:"button",buttonStyle:"solid",value:O,onChange:xe=>z(xe.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:O})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(s.Radio.Group,{options:Kd,optionType:"button",buttonStyle:"solid",value:j,onChange:xe=>P(xe.target.value)}),e.jsx("input",{type:"hidden",name:"attendance_salary_calculation",value:j})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Multiple Shift"}),e.jsx(s.Radio.Group,{options:Gd,optionType:"button",buttonStyle:"solid",value:k,onChange:xe=>F(xe.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:k})]}),Re?e.jsx(G,{type:"number",name:"late_absent_day",label:"No of Late",defaultValue:c?.late_absent_day??""}):e.jsx("input",{type:"hidden",name:"late_absent_day",value:""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:Hd,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(s.Upload,{action:`${ut()}/uploadfile.php`,name:"file",data:{filepath:`uploads/school_${$u(t)}/schoolFile`},headers:{Authorization:t},maxCount:1,accept:"image/*",onChange:xe=>{if(xe.file.status==="removed"&&U(""),xe.file.status==="done"){const De=xe.file.response?.data??xe.file.response?.file??"";U(String(De??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:M?"Change":"Upload"})}),M&&e.jsxs("div",{style:{marginTop:8,display:"flex",alignItems:"center",gap:8},children:[e.jsx("a",{style:{fontSize:12,color:"#1677ff",textDecoration:"underline",cursor:"pointer"},onClick:()=>{N(lv(M,t)),B(!0)},children:"View existing logo"}),e.jsx("a",{style:{fontSize:12,color:"#1677ff",textDecoration:"underline",cursor:"pointer"},onClick:()=>U(""),children:"Remove"})]}),e.jsx("input",{type:"hidden",name:"logo",value:M??""})]}),e.jsxs("div",{children:[e.jsx(ae,{label:"Select Affiliated Board",options:S,value:A,onChange:xe=>_(xe)}),e.jsx("input",{type:"hidden",name:"affliated_board_id",value:A?.value??""}),e.jsx("input",{type:"hidden",name:"board_name",value:A?.label??""})]}),e.jsx(kt,{label:"Address",name:"address",rows:3,defaultValue:c?.location_name??c?.address??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Json for Notification"}),e.jsx(ss,{token:t,action:ev(),value:Y,accept:".json",onChange:xe=>V(xe)}),e.jsx("input",{type:"hidden",name:"json_file",value:Y??""})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Modal,{open:L,onCancel:()=>{B(!1),N("")},footer:null,width:500,closable:!0,children:$?e.jsx("img",{src:$,alt:"Organization Logo",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(he,{children:"No logo found"})})]})}function hv({token:t}){return e.jsx(mv,{token:t})}const mr=lt.academicYear,fv=({token:t,page:a=1,perPage:n=10})=>Ou({baseUrl:mr.table,token:t,page:a,perPage:n}),gv={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},yv=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[],xv=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function bv({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(()=>{const u=ne(),x=ne().add(1,"year");return`${u.format("YYYY")}-${x.format("YYYY")}`}),[c,h]=i.useState(ne()),[f,p]=i.useState(ne().add(1,"year")),{isLoading:m,data:v,mutate:S}=fv({token:t,page:a.page,perPage:a.rowsPerPage}),y=i.useMemo(()=>yv(v),[v]),g=i.useMemo(()=>xv(v,y.length),[v,y.length]),b=async()=>{if(!l){T.error("Session name is required.");return}if(f&&c&&ne(f).isBefore(c)){T.error("End date must be after start date.");return}try{const u=new FormData;u.set("name",l),u.set("start_date",c?ne(c).format("YYYY-MM-DD"):""),u.set("end_date",f?ne(f).format("YYYY-MM-DD"):""),await js(mr.add,u,t),T.success("Academic year added.",{duration:1e3}),o(!1),S?.()}catch(u){T.error(u?.response?.data?.msg??u?.message??"Failed to add academic year.",{duration:1500})}},D=async u=>{try{const x=new FormData;x.set("session",String(u)),await Mu(mr.setActive,x,t);const j=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...j,session_id:String(u)})),T.success("Academic year activated.",{duration:1e3}),S?.()}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to activate academic year.",{duration:1500})}},R=async u=>{try{await S(xo(mr.remove,u,t)),T.success("Academic year deleted.",{duration:1e3})}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to delete academic year.",{duration:1500})}},I=()=>{const u=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),x=URL.createObjectURL(u),j=document.createElement("a");j.href=x,j.download="academic-years.json",j.click(),URL.revokeObjectURL(x)},A=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(re.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(re.ReloadOutlined,{}),onClick:()=>S?.()},{key:"export",label:"Export",icon:e.jsx(re.ExportOutlined,{}),onClick:I,disabled:y.length===0}],[y.length,S]),_=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name"},{title:"Start Date",dataIndex:"start_date",key:"start_date"},{title:"End Date",dataIndex:"end_date",key:"end_date"},{title:"Active",key:"active",render:(u,x)=>{const j=x.status==="Active";return e.jsxs("span",{children:[e.jsx(s.Popconfirm,{title:j?"Deactivate Academic Year?":"Activate Academic Year?",description:j?"Deactivate is not allowed. Activate another session to switch.":"This will set this year as the current academic session.",onConfirm:()=>{j?T.error("Deactivate is not allowed. Activate another session to switch."):D(x.id)},okText:"Yes",cancelText:"No",children:e.jsx(s.Switch,{checked:j})}),j&&e.jsx(s.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(u,x)=>e.jsx(s.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>R(x.id),okText:"Yes",cancelText:"No",children:e.jsx(s.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,y.length]);return e.jsxs(e.Fragment,{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ea,{title:"Academic Year",actions:A,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(s.Table,{rowKey:"id",dataSource:y,columns:_,loading:m,pagination:{current:a.page,pageSize:a.rowsPerPage,total:g,showSizeChanger:!0,onChange:(u,x)=>n({page:u,rowsPerPage:Number(x)})}})})}),e.jsx(s.Modal,{open:r,onCancel:()=>o(!1),footer:null,title:"Add Academic Year",children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:gv,children:[e.jsx(G,{label:"Session Name*",value:l,onChange:u=>d(u.target.value)}),e.jsxs("div",{children:[e.jsx(Ge,{Desplay:"Start Date*",value:c,onChange:u=>h(u),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?ne(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(Ge,{Desplay:"End Date*",value:f,onChange:u=>p(u),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:f?ne(f).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{value:"Submit",type:"button",onClick:b}),e.jsx(s.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function jv({token:t}){return e.jsx(bv,{token:t})}const Fu=lt.feeReceiptSetting,Sv=({token:t})=>qt({url:Fu.get,token:t}),Di={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},wv=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function vv({token:t}){const a=i.useRef(null),n=Sv({token:t}),r=i.useMemo(()=>wv(n.data),[n.data]),[o,l]=i.useState(""),[d,c]=i.useState(!1),[h,f]=i.useState(!1),[p,m]=i.useState(!1),[v,S]=i.useState("0"),[y,g]=i.useState("0"),[b,D]=i.useState("0"),[R,I]=i.useState(!1),[A,_]=i.useState(!1),[u,x]=i.useState(""),[j,P]=i.useState("0"),[O,z]=i.useState("0"),[k,F]=i.useState("0"),[C,E]=i.useState(""),[M,U]=i.useState(!1),Y=()=>{l(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),f(String(r?.address??"0")==="1"),m(String(r?.gardian_name??"0")==="1"),S(String(r?.authorized_signatory??"0")),g(String(r?.parent_signatory??"0")),D(String(r?.dynamic_qr_code_device??"0")),I(String(r?.sequence_payment??"0")==="1"),_(String(r?.previois_fees??"0")==="1"),x(r?.title??""),P(String(r?.class_id??"0")),z(String(r?.discount??"0")),F(String(r?.sections??"0")),E(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&Y()},[r]);const V=()=>{a.current?.reset?.(),Y()},L=()=>{const N={number_of_receipt:o,rollnumber:d?1:0,address:h?1:0,gardianname:p?1:0,authorizedsignatory:v,parentsignatory:y,dynamic_qr_code_device:b,sequence_payment:R?1:0,previois_fees:A?1:0,upfront_payment_months:C,title:u,class_id:j,discount:O,sections:k},H=new Blob([JSON.stringify(N,null,2)],{type:"application/json"}),Q=URL.createObjectURL(H),X=document.createElement("a");X.href=Q,X.download="fee-receipt-setting.json",X.click(),URL.revokeObjectURL(Q)},B=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(re.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(re.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(re.ReloadOutlined,{}),onClick:V},{key:"export",label:"Export",icon:e.jsx(re.ExportOutlined,{}),onClick:L,disabled:!r}],[r,o,d,h,p,v,y,b,R,A,C,u,j,O,k]),$=async N=>{N.preventDefault(),U(!0);try{const H=new FormData;H.set("number_of_receipt",String(o??"")),H.set("rollnumber",d?"1":"0"),H.set("address",h?"1":"0"),H.set("gardianname",p?"1":"0"),H.set("authorizedsignatory",String(v??"0")),H.set("parentsignatory",String(y??"0")),H.set("dynamic_qr_code_device",String(b??"0")),H.set("sequence_payment",R?"1":"0"),H.set("previois_fees",A?"1":"0"),H.set("upfront_payment_months",String(C??"")),H.set("title",String(u??"")),H.set("class_id",String(j??"0")),H.set("discount",String(O??"0")),H.set("sections",String(k??"0")),await js(Fu.save,H,t),T.success("Fee receipt settings updated.",{duration:1e3}),n.mutate?.()}catch(H){T.error(H?.response?.data?.msg??H?.message??"Failed to update settings.",{duration:1500})}finally{U(!1)}};return n.isLoading&&!n.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ea,{title:"Fee Receipt Setting",actions:B,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:a,onSubmit:$,children:[e.jsxs("div",{style:Di,children:[e.jsx(G,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:N=>l(N.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(s.Checkbox,{checked:d,onChange:N=>c(N.target.checked),children:"Show Roll Number in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Address"}),e.jsx(s.Checkbox,{checked:h,onChange:N=>f(N.target.checked),children:"Show address in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Guardian Name"}),e.jsx(s.Checkbox,{checked:p,onChange:N=>m(N.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:Di,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(s.Radio.Group,{value:v,onChange:N=>S(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Parent Signatory"}),e.jsxs(s.Radio.Group,{value:y,onChange:N=>g(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Dynamic QR Code Device"}),e.jsxs(s.Radio.Group,{value:b,onChange:N=>D(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:Di,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(s.Checkbox,{checked:R,onChange:N=>I(N.target.checked),children:"Student can pay in sequence"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Previous Fees"}),e.jsx(s.Checkbox,{checked:A,onChange:N=>_(N.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(G,{type:"text",name:"title",label:"Title",value:u,onChange:N=>x(N.target.value)}),e.jsxs("div",{style:{display:"none"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Class"}),e.jsxs(s.Radio.Group,{value:j,onChange:N=>P(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Discount"}),e.jsxs(s.Radio.Group,{value:O,onChange:N=>z(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sections"}),e.jsxs(s.Radio.Group,{value:k,onChange:N=>F(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.Radio,{value:"0",children:"Disable"})]})]}),e.jsx(G,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:C,onChange:N=>E(N.target.value)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:M?"Updating...":"Done",disabled:M})})]})})})]})}function Cv({token:t}){return e.jsx(vv,{token:t})}const ls=lt.marksheetSetting,_v=({token:t})=>qt({url:ls.templateTypes,token:t}),Av=({token:t})=>qt({url:ls.classDropdown,token:t}),Tv=({token:t})=>qt({url:ls.assignedTable,token:t}),Dv={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},Jd=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],kv=Array.from({length:12},(t,a)=>({value:String(a+1),label:`Design ${a+1}`})),Rv=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function Iv({token:t}){const a=i.useRef(null),n=_v({token:t}),r=Av({token:t}),o=Tv({token:t}),l=i.useMemo(()=>Jd(n.data),[n.data]),d=i.useMemo(()=>Jd(r.data),[r.data]),c=i.useMemo(()=>Rv(o.data),[o.data]),[h,f]=i.useState(null),[p,m]=i.useState(null),[v,S]=i.useState([]),y=()=>{a.current?.reset?.(),f(null),m(null),S([])},g=()=>{const A=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),_=URL.createObjectURL(A),u=document.createElement("a");u.href=_,u.download="marksheet-templates.json",u.click(),URL.revokeObjectURL(_)},b=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(re.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(re.ReloadOutlined,{}),onClick:y},{key:"export",label:"Export",icon:e.jsx(re.ExportOutlined,{}),onClick:g,disabled:c.length===0}],[c.length]),D=async A=>{if(A.preventDefault(),!h?.value){T.error("Select marksheet type.",{duration:1200});return}if(!p?.value){T.error("Select design.",{duration:1200});return}if(!v?.length){T.error("Select at least one class.",{duration:1200});return}try{const _=new FormData;_.set("temp_id",String(h.value)),_.set("ui_id",String(p.value)),v.forEach(u=>_.append("class_id[]",String(u))),await js(ls.assign,_,t),T.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),y()}catch(_){T.error(_?.response?.data?.msg??_?.message??"Failed to assign template.",{duration:1500})}},R=async A=>{try{await xo(ls.remove,A,t),T.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(_){T.error(_?.response?.data?.msg??_?.message??"Failed to remove template.",{duration:1500})}},I=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class"},{title:"Template Name",dataIndex:"name",key:"name"},{title:"Template Design",dataIndex:"ui_id",key:"ui_id"},{title:"Action",key:"action",render:(A,_)=>e.jsx(At,{id:_?.id,funcName:R})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ea,{title:"Marksheet Setting",actions:b,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:a,onSubmit:D,children:[e.jsxs("div",{style:Dv,children:[e.jsxs("div",{children:[e.jsx(ae,{label:"Select Marksheet Type",options:l,value:h,onChange:A=>f(A)}),e.jsx("input",{type:"hidden",name:"temp_id",value:h?.value??""})]}),e.jsxs("div",{children:[e.jsx(ae,{label:"Select Design",options:kv,value:p,onChange:A=>m(A)}),e.jsx("input",{type:"hidden",name:"ui_id",value:p?.value??""})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(s.Checkbox.Group,{options:d,value:v,onChange:A=>S(A)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(s.Table,{size:"small",rowKey:"id",columns:I,dataSource:c,pagination:!1})})]})})]})}function Pv({token:t}){return e.jsx(Iv,{token:t})}const ki={fetch:`${lt.legalPages.get}?page_name=terms`,save:lt.legalPages.termsSave,fieldName:"terms_data"};function Mv({token:t}){return e.jsx(bo,{token:t,title:"Terms",fetchUrl:ki.fetch,saveUrl:ki.save,fieldName:ki.fieldName})}function Ev({token:t}){return e.jsx(Mv,{token:t})}const Ri={fetch:`${lt.legalPages.get}?page_name=privacy`,save:lt.legalPages.privacySave,fieldName:"privacy_data"};function Ov({token:t}){return e.jsx(bo,{token:t,title:"Privacy",fetchUrl:Ri.fetch,saveUrl:Ri.save,fieldName:Ri.fieldName})}function $v({token:t}){return e.jsx(Ov,{token:t})}const Ii={fetch:`${lt.legalPages.get}?page_name=about_us`,save:lt.legalPages.aboutSave,fieldName:"about_data"};function Fv({token:t}){return e.jsx(bo,{token:t,title:"About",fetchUrl:Ii.fetch,saveUrl:Ii.save,fieldName:Ii.fieldName})}function Bv({token:t}){return e.jsx(Fv,{token:t})}const jo=lt.feesInfo,Lv=({token:t})=>qt({url:jo.get,token:t}),Uv=({token:t})=>qt({url:jo.statesDropdown,token:t}),Nv=(t,a)=>{const n=String(t??""),r=String(a??"");return n?r?n.endsWith("/")&&r.startsWith("/")?`${n}${r.slice(1)}`:!n.endsWith("/")&&!r.startsWith("/")?`${n}/${r}`:`${n}${r}`:n:r},rs=t=>{const a=ya(t);if(a)return a;try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.fk_branchID??JSON.parse(localStorage.getItem("Userdata")??"null")?.branch_id??""}catch{return""}},Bu=(t,a,n)=>{const r=`${t||""}`.trim();if(!r)return"";if(/^https?:\/\//i.test(r))return r;const o=rs(a),l=r.startsWith("/")?r.slice(1):r;return Nv(ut(),`uploads/school_${o}/${n}/${l}`)},Pi={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},zv=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null,qv=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],Yv=(t,a)=>t?Bu(t,a,"schoolFile"):"",Mi=(t,a)=>t?Bu(t,a,"schoolFile"):"";function Wv({token:t}){const a=i.useRef(null),n=Lv({token:t}),r=Uv({token:t}),o=i.useMemo(()=>zv(n.data),[n.data]),l=i.useMemo(()=>qv(r.data),[r.data]),[d,c]=i.useState(null),[h,f]=i.useState(""),[p,m]=i.useState(""),[v,S]=i.useState(""),[y,g]=i.useState(""),b=u=>{const x=new FormData(u),j=Object.fromEntries(x.entries());return j.state_id=d?.value??"",j.fees_receipt_logo=h,j.manager_signature=p,j.principal_signature=v,j.stamp=y,j},D=()=>{c(l.find(u=>String(u?.value)===String(o?.fk_state_id??o?.state_id??o?.country_code??""))??null),f(o?.logo??o?.fees_receipt_logo??""),m(o?.manager_signature??""),S(o?.principal_signature??""),g(o?.stamp??"")};i.useEffect(()=>{o&&D()},[o,l]);const R=()=>{a.current?.reset?.(),D()},I=()=>{const u=b(a.current),x=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),j=URL.createObjectURL(x),P=document.createElement("a");P.href=j,P.download="fees-info.json",P.click(),URL.revokeObjectURL(j)},A=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(re.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(re.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(re.ReloadOutlined,{}),onClick:R},{key:"export",label:"Export",icon:e.jsx(re.ExportOutlined,{}),onClick:I,disabled:!o}],[o,d,h,p,v,y]),_=async u=>{u.preventDefault();try{const x=b(u.target);await Kw(jo.save,x,t),T.success("Fees info saved.",{duration:1e3}),n.mutate?.()}catch(x){T.error(x?.response?.data?.msg??x?.message??"Failed to save fees info.",{duration:1500})}};return n.isLoading&&!n.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ea,{title:"Fees Info",actions:A,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:a,onSubmit:_,children:[e.jsxs("div",{style:Pi,children:[e.jsx(G,{name:"Bussiness_name",label:"Business Name*",defaultValue:o?.name??"",required:!0}),e.jsx(G,{name:"cin",label:"Sub Heading",defaultValue:o?.cin??""}),e.jsx(G,{name:"school_no",type:"number",label:"School Number",defaultValue:o?.school_no??""}),e.jsx(G,{name:"website",label:"Website",defaultValue:o?.website??""}),e.jsx(G,{name:"school_Code",label:"School Code",defaultValue:o?.school_Code??""}),e.jsx(G,{name:"offical_number",label:"Official Number",defaultValue:o?.offical_number??""}),e.jsx(G,{name:"email_id",label:"Email",defaultValue:o?.email_id??""}),e.jsx(G,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:o?.admission_prefix??o?.receipt_prefix??""}),e.jsx(G,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:o?.admission_no_prefix??o?.admission_start_number??o?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(ae,{label:"State",options:l,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(G,{name:"affiliation_no",label:"Affiliation Number",defaultValue:o?.affiliation_no??""}),e.jsx(G,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:o?.affiliation_desc??o?.affliated_description??""}),e.jsx(G,{name:"udise_code",label:"UDISE Code",defaultValue:o?.udise_code??""}),e.jsx(G,{name:"color_code",label:"Primary Color",defaultValue:o?.color_code??""}),e.jsx(G,{name:"fontcolor_code",label:"Font Color",defaultValue:o?.fontcolor_code??""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:Pi,children:[e.jsx(kt,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??o?.address??o?.location_name??""}),e.jsx(kt,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:Pi,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(ss,{token:t,action:`${ut()}/uploadfile.php`,data:{filepath:`uploads/school_${rs(t)}/schoolFile`},value:h,previewUrl:Yv(h,t),accept:"image/*",onChange:f}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:h})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(ss,{token:t,action:`${ut()}/uploadfile.php`,data:{filepath:`uploads/school_${rs(t)}/schoolFile`},value:p,previewUrl:Mi(p,t),accept:"image/*",onChange:m}),e.jsx("input",{type:"hidden",name:"manager_signature",value:p})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Principal Signature"}),e.jsx(ss,{token:t,action:`${ut()}/uploadfile.php`,data:{filepath:`uploads/school_${rs(t)}/schoolFile`},value:v,previewUrl:Mi(v,t),accept:"image/*",onChange:S}),e.jsx("input",{type:"hidden",name:"principal_signature",value:v})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(ss,{token:t,action:`${ut()}/uploadfile.php`,data:{filepath:`uploads/school_${rs(t)}/schoolFile`},value:y,previewUrl:Mi(y,t),accept:"image/*",onChange:g}),e.jsx("input",{type:"hidden",name:"stamp",value:y})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})})})]})}function Vv({token:t}){return e.jsx(Wv,{token:t})}const hr=lt.payrollSettings,Hv=({token:t,page:a=1,perPage:n=10})=>Ou({baseUrl:hr.table,token:t,page:a,perPage:n}),Kv={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Jn=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],Ei=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],Gv=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Jv=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function Qv({token:t}){const a=i.useRef(null),n=i.useRef(null),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,h]=i.useState(null),[f,p]=i.useState(Jn[0]),[m,v]=i.useState(null),[S,y]=i.useState(null),[g,b]=i.useState(null),[D,R]=i.useState(!1),[I,A]=i.useState(!1),_=Hv({token:t,page:r.page,perPage:r.rowsPerPage}),u=i.useMemo(()=>Gv(_.data),[_.data]),x=i.useMemo(()=>Jv(_.data,u.length),[_.data,u.length]),j=async E=>{E.preventDefault(),A(!0);try{const M=new FormData(E.target);M.set("type",f?.value??""),M.set("amount_type",m?.value??""),await js(hr.add,M,t),T.success("Payroll setting added.",{duration:1e3}),_.mutate?.(),E.target.reset(),v(null),p(Jn[0])}catch(M){T.error(M?.response?.data?.msg??M?.message??"Failed to add payroll setting.",{duration:1500})}finally{A(!1)}},P=E=>{h(E),y(Jn.find(M=>M.value===E?.type)??null),b(Ei.find(M=>M.value===E?.amount_type)??null),d(!0)},O=async E=>{E.preventDefault(),R(!0);try{const M=new FormData(E.target);M.set("id",String(c?.id??"")),M.set("type",S?.value??""),M.set("amount_type",g?.value??""),await Mu(hr.edit,M,t),T.success("Payroll setting updated.",{duration:1e3}),d(!1),_.mutate?.()}catch(M){T.error(M?.response?.data?.msg??M?.message??"Failed to update payroll setting.",{duration:1500})}finally{R(!1)}},z=async E=>{try{await xo(hr.remove,E,t),T.success("Payroll setting deleted.",{duration:1e3}),_.mutate?.()}catch(M){T.error(M?.response?.data?.msg??M?.message??"Failed to delete payroll setting.",{duration:1500})}},k=()=>{const E=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),M=URL.createObjectURL(E),U=document.createElement("a");U.href=M,U.download="payroll-settings.json",U.click(),URL.revokeObjectURL(M)},F=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(re.PlusOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(re.ReloadOutlined,{}),onClick:()=>_.mutate?.()},{key:"save",label:"Save",icon:e.jsx(re.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(re.ExportOutlined,{}),onClick:k,disabled:u.length===0}],[u.length]),C=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title"},{title:"Type",dataIndex:"type",key:"type"},{title:"Amount Type",dataIndex:"amount_type",key:"amount_type"},{title:"Amount",dataIndex:"Amount",key:"Amount"},{title:"Action",key:"action",render:(E,M)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>P(M)}),e.jsx(s.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>z(M.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ea,{title:"Payroll Settings",actions:F,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:a,onSubmit:j,children:[e.jsxs("div",{style:Kv,children:[e.jsx(G,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(ae,{label:"Type",options:Jn,value:f,onChange:p}),e.jsx("input",{type:"hidden",name:"type",value:f?.value??""})]}),e.jsxs("div",{children:[e.jsx(ae,{label:"Amount Type",options:Ei,value:m,onChange:v}),e.jsx("input",{type:"hidden",name:"amount_type",value:m?.value??""})]}),e.jsx(G,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(de,{type:"submit",value:I?"Adding...":"Submit",disabled:I,loading:I})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(s.Table,{rowKey:"id",columns:C,dataSource:u,loading:_.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:x,showSizeChanger:!0,onChange:(E,M)=>o({page:E,rowsPerPage:Number(M)})}})})]})}),e.jsx(s.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,destroyOnClose:!0,footer:e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:()=>d(!1),disabled:D,children:"Cancel"}),e.jsx(de,{type:"submit",value:D?"Updating...":"Update",disabled:D,loading:D,form:"payroll-edit-form"})]}),children:e.jsx(s.Spin,{spinning:D,tip:"Updating...",children:e.jsx("form",{id:"payroll-edit-form",ref:n,onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(G,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(ae,{label:"Type",options:Jn,value:S,onChange:y}),e.jsx("input",{type:"hidden",name:"type",value:S?.value??""})]}),e.jsxs("div",{children:[e.jsx(ae,{label:"Amount Type",options:Ei,value:g,onChange:b}),e.jsx("input",{type:"hidden",name:"amount_type",value:g?.value??""})]}),e.jsx(G,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""})]})},c?.id??"new")})})]})}function Xv({token:t}){return e.jsx(Qv,{token:t})}const Lu=lt.paymentGateway,Zv=({token:t})=>qt({url:Lu.get,token:t}),e0=[{id:"Razorpay",title:"Razorpay",fields:["keyId","keySecret"]},{id:"PhonePe",title:"Pine Labs",fields:["merchantId","saltKey","saltIndex"]},{id:"Paytm",title:"HDFC",fields:["merchantId","merchantKey"]},{id:"SabPaisa",title:"SabPaisa",fields:["clientCode","transUserName","transUserPassword","authKey","authIV"]}],Na={Razorpay:{keyId:"",keySecret:"",isActive:!0},PhonePe:{merchantId:"",saltKey:"",saltIndex:"1",isActive:!1},Paytm:{merchantId:"",merchantKey:"",isActive:!1},SabPaisa:{clientCode:"",transUserName:"",transUserPassword:"",authKey:"",authIV:"",isActive:!1}},Qd=t=>{const a=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!a?.data)return Na;try{const n=JSON.parse(a.data||"{}"),r=n?.data&&typeof n.data=="object"?n.data:n;return{Razorpay:{...Na.Razorpay,...r?.Razorpay??{}},PhonePe:{...Na.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...Na.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...Na.SabPaisa,...r?.SabPaisa??{}}}}catch{return Na}};function t0({token:t}){const a=i.useRef(null),n=Zv({token:t}),[r,o]=i.useState(Na);i.useEffect(()=>{n.data&&o(Qd(n.data))},[n.data]);const l=(p,m,v)=>{o(S=>({...S,[p]:{...S[p],[m]:v}}))},d=()=>o(Qd(n.data)),c=()=>{const p=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),m=URL.createObjectURL(p),v=document.createElement("a");v.href=m,v.download="payment-gateway-settings.json",v.click(),URL.revokeObjectURL(m)},h=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(re.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(re.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(re.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(re.ExportOutlined,{}),onClick:c}],[r,n.data]),f=async p=>{p.preventDefault();try{await Eu(Lu.save,{data:r},t),T.success("Payment gateway settings saved.",{duration:1e3}),n.mutate?.()}catch(m){T.error(m?.response?.data?.msg??m?.message??"Failed to save gateway settings.",{duration:1500})}};return n.isLoading&&!n.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Ea,{title:"Payment Gateway",actions:h,children:e.jsxs("form",{ref:a,onSubmit:f,style:{display:"grid",gap:20},children:[e0.map(p=>{const m=r[p.id]??{};return e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:p.title}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:500},children:["Enable ",p.title]}),e.jsx(s.Switch,{checked:!!m.isActive,onChange:v=>l(p.id,"isActive",v)})]}),e.jsx(s.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:p.fields.map(v=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:v}),e.jsx(s.Input,{value:m[v]??"",type:v.toLowerCase().includes("secret")||v.toLowerCase().includes("password")?"password":"text",onChange:S=>l(p.id,v,S.target.value)})]},v))})]})},p.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})})]})}function a0({token:t}){return e.jsx(t0,{token:t})}const n0="{{student_name}} {{parent_name}} {{amount}} {{date}} {{time}} {{id}} {{school_name}} {{date_time}}",hn=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:[]};function s0({token:t}){const[a,n]=i.useState("1"),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,h]=i.useState(""),[f,p]=i.useState(""),[m,v]=i.useState(""),[S,y]=i.useState([]),[g,b]=i.useState(""),[D,R]=i.useState(""),[I,A]=i.useState(""),[_,u]=i.useState([]),[x,j]=i.useState({label:"",value:""}),[P,O]=i.useState(!1),[z,k]=i.useState(""),[F,C]=i.useState([]),[E,M]=i.useState([]),[U,Y]=i.useState(!1),{data:V}=q(t?[lt.smsCompose.templateDropdown,t]:null,([ye,me])=>W(ye,me)),L=i.useMemo(()=>hn(V).map(me=>({label:me.name??me.title??"",value:String(me.id??me.value??""),template_body:me.template_body??me.body??""})),[V]),{data:B}=q(t?[lt.smsCompose.roleDropdown,t]:null,([ye,me])=>W(ye,me)),$=i.useMemo(()=>hn(B).map(me=>({label:me.role_name??me.name??me.label??"",value:String(me.id??me.role_id??me.value??"")})),[B]),N=i.useMemo(()=>[{label:"Student",value:"Student"},...$],[$]),{data:H}=q(t?[lt.smsCompose.classDropdown,t]:null,([ye,me])=>W(ye,me)),Q=i.useMemo(()=>hn(H).map(me=>({label:me.class_name??me.name??me.label??"",value:String(me.id??me.class_id??me.value??""),...me})),[H]),X=i.useMemo(()=>z?`${lt.smsCompose.sectionByClass}?class_id=${encodeURIComponent(z)}`:null,[z]),{data:J}=q(t&&X?[X,t]:null,([ye,me])=>W(ye,me)),K=i.useMemo(()=>hn(J).map(me=>({label:me.section_name??me.name??me.label??"",value:String(me.id??me.section_id??me.value??""),...me})),[J]),Z=ye=>{const me=Q.find(Pe=>Pe.value===ye)||{label:"",value:ye};j({label:me.label,value:me.value}),k(me.value),O(Pe=>!Pe),C([])},ee=()=>{if(!x.value||F.length===0)return;const ye=E.find(Pe=>Pe.kind==="class"&&Pe.class_id===x.value),me=F;if(ye){const Pe=Array.from(new Set([...ye.section_ids,...me]));M(Ye=>Ye.map(ze=>ze.kind==="class"&&ze.class_id===x.value?{...ze,section_ids:Pe}:ze))}else M(Pe=>[...Pe,{kind:"class",label:`Class: ${x.label}`,class_id:x.value,class_label:x.label,section_ids:me}]);C([])},pe=async ye=>{if(v(ye),!ye){y([]);return}try{const me=`${lt.smsCompose.staffSearch}?name=${encodeURIComponent(ye)}&role=${encodeURIComponent(f)}`,Pe=await W(me,t),Ye=hn(Pe);y(Ye.map(ze=>({label:ze.staff_name??ze.name??ze.full_name??"",value:String(ze.id??ze.staff_id??ze.employee_id??ze.value??""),...ze})))}catch{y([])}},te=(ye,me)=>{E.find(Ye=>Ye.kind==="staff"&&Ye.value===me.value)||M(Ye=>[...Ye,{kind:"staff",label:me.label,value:me.value,type:c}])},se=async ye=>{if(A(ye),!ye){u([]);return}try{const me=`${lt.smsCompose.studentDropdown}?class=${encodeURIComponent(g)}§ion=${encodeURIComponent(D)}&name=${encodeURIComponent(ye)}`,Pe=await W(me,t),Ye=hn(Pe);u(Ye.map(ze=>({label:ze.student_name??ze.name??"",value:String(ze.roll_no??ze.roll??ze.value??""),id:String(ze.id??ze.student_id??ze.value??""),...ze})))}catch{u([])}},le=(ye,me)=>{E.find(Ye=>Ye.kind==="student"&&Ye.id===me.id)||M(Ye=>[...Ye,{kind:"student",label:me.label,value:me.value,id:me.id}])},Ce=ye=>{M(me=>me.filter((Pe,Ye)=>Ye!==ye))},Le=i.useMemo(()=>{if(!l)return[];const me=(l.match(/\{\{\s*[^{}]+\s*\}\}/g)||[]).map(Pe=>Pe.replace(/\s+/g,""));return Array.from(new Set(me))},[l]),Re=async()=>{if(!r||E.length===0)return;const ye=new FormData;ye.append("is_individual",a==="1"?"1":"0"),ye.append("is_class",a==="2"?"1":"0"),ye.append("message",l),ye.append("template_id",r),E.forEach((me,Pe)=>{me.kind==="staff"?ye.append("staff_ids[]",me.value):me.kind==="student"?ye.append("student_ids[]",me.id):me.kind==="class"&&(ye.append(`classArr[${Pe}][class_id]`,me.class_id),me.section_ids.forEach(Ye=>ye.append(`classArr[${Pe}][section_ids][]`,Ye)))}),Y(!0);try{const me=await bn(lt.smsCompose.sendMessage,ye,t);me?.Status==="Success"?(s.message.success("SMS sent successfully!"),M([]),O(!1),j({label:"",value:""}),C([])):s.message.error(me?.msg??"Failed to send SMS")}catch(me){s.message.error(me?.message??"Failed to send SMS")}finally{Y(!1)}},xe=E.length,De=[{title:"Recipient",key:"label",render:(ye,me)=>me.kind==="student"?e.jsxs(e.Fragment,{children:[e.jsx(s.Tag,{color:"blue",children:"Student"}),me.label]}):me.kind==="class"?e.jsxs(e.Fragment,{children:[e.jsx(s.Tag,{color:"purple",children:"Class"}),me.label," — ",me.section_ids.length," section(s)"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Tag,{color:"green",children:me.type||"Staff"}),me.label]})},{title:"Actions",key:"actions",render:(ye,me,Pe)=>e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{}),onClick:()=>Ce(Pe)})}],Ue=ye=>{n(ye),M([]),h(""),p(""),v(""),y([]),b(""),R(""),A(""),u([]),j({label:"",value:""}),O(!1),C([])};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:e.jsxs(s.Space,{children:[e.jsx(re.MailOutlined,{}),e.jsx("span",{children:"SMS Campaign Composer"})]})}),children:[e.jsx("div",{style:{marginBottom:16},children:e.jsxs(s.Typography.Text,{type:"secondary",children:["Available placeholders: ",e.jsx("code",{children:n0})]})}),e.jsx(s.Tabs,{size:"small",type:"card",value:a,onChange:Ue,items:[{key:"1",label:"Individual"},{key:"2",label:"Class"}]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:24},children:[e.jsx(s.Card,{size:"small",title:"Message Details",children:e.jsxs(s.Space,{direction:"vertical",size:16,style:{width:"100%"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Choose Template*"}),e.jsx(s.Select,{style:{width:"100%"},placeholder:"Select a template",value:r||void 0,onChange:ye=>{o(ye);const me=L.find(Pe=>Pe.value===ye);d(me?.template_body??"")},options:L,showSearch:!0,optionFilterProp:"label"}),L.length===0&&e.jsx(s.Typography.Text,{type:"secondary",style:{display:"block",marginTop:6},children:"No active templates available. Add one in SMS Alert Setting."})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Message*"}),e.jsx(s.Input.TextArea,{rows:5,value:l,readOnly:!0,placeholder:"Select a template to preview the message"})]}),Le.length>0&&e.jsxs("div",{children:[e.jsx(s.Typography.Text,{strong:!0,style:{display:"block",marginBottom:8},children:"Available placeholders"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:Le.map(ye=>e.jsx(s.Tag,{color:"blue",children:ye},ye))}),e.jsx(s.Typography.Text,{type:"secondary",style:{display:"block",marginTop:6},children:"The server replaces these placeholders per recipient."})]})]})}),e.jsx(s.Card,{size:"small",title:"Recipient Selection",children:e.jsxs(s.Space,{direction:"vertical",size:16,style:{width:"100%"},children:[a==="1"&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Message To*"}),e.jsx(s.Select,{style:{width:"100%"},placeholder:"Select recipient type",value:c||void 0,onChange:ye=>{h(ye),p(ye==="Student"?"Student":""),v(""),y([]),A(""),u([]),b(""),R("")},options:N}),c&&c!=="Student"&&e.jsx("div",{style:{marginTop:16},children:e.jsx(s.AutoComplete,{style:{width:"100%"},value:m,placeholder:`Search ${c} by name`,options:S,onSearch:pe,onSelect:te,notFoundContent:m?"No staff found":""})}),c==="Student"&&e.jsxs("div",{style:{marginTop:16,display:"grid",gap:12},children:[e.jsx(s.Select,{placeholder:"Class",value:g||void 0,onChange:ye=>{b(ye),k(ye),R(""),A(""),u([])},options:Q,showSearch:!0,optionFilterProp:"label"}),g&&e.jsx(s.Select,{placeholder:"Section",value:D||void 0,onChange:ye=>{R(ye),A(""),u([])},options:K}),g&&D&&e.jsx(s.AutoComplete,{placeholder:"Search student",value:I,options:_,onSearch:se,onSelect:le,notFoundContent:I?"No student found":""})]})]}),a==="2"&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Class*"}),e.jsx(s.Select,{style:{width:"100%"},placeholder:"Select class",value:x.value||void 0,onChange:Z,options:Q,showSearch:!0,optionFilterProp:"label"}),x.value&&K.length>0&&e.jsxs("div",{style:{marginTop:16},children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Sections"}),e.jsx(s.Select,{style:{width:"100%"},mode:"multiple",placeholder:"Select sections",value:F,onChange:C,options:K.map(ye=>({label:ye.label,value:ye.value}))}),e.jsx(s.Button,{type:"primary",size:"small",style:{marginTop:8},onClick:ee,disabled:F.length===0,children:"Add Class Recipients"})]})]}),e.jsxs("div",{children:[e.jsxs(s.Typography.Text,{strong:!0,style:{display:"block",marginBottom:10},children:["Selected Recipients (",xe,")"]}),e.jsx(s.Table,{bordered:!0,size:"small",columns:De,dataSource:E,rowKey:(ye,me)=>`${ye.kind}-${me}`,pagination:!1,scroll:{y:200},locale:{emptyText:"No recipients selected"}})]})]})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12,alignItems:"center"},children:[e.jsxs(s.Typography.Text,{type:"secondary",children:["Mode: ",a==="1"?"Individual":"Class"," | ",xe," recipients selected"]}),e.jsx(de,{type:"button",value:U?"Sending...":"Send SMS",color:"primary",onClick:Re,disabled:U||!r||xe===0})]})]})]})}const Qn=lt.smsTemplates,r0=lt.smsGateway,i0="{{student_name}} {{parent_name}} {{amount}} {{date}} {{time}} {{id}} {{school_name}} {{date_time}}";function o0({token:t}){const[a,n]=i.useState(!1),[r,o]=i.useState(""),[l,d]=i.useState(!1),[c,h]=i.useState(""),[f,p]=i.useState(!1),[m,v]=i.useState(!1),[S,y]=i.useState([]),[g,b]=i.useState(!0),[D,R]=i.useState(1),[I]=i.useState(10),[A,_]=i.useState(""),[u,x]=i.useState(""),[j,P]=i.useState(""),[O,z]=i.useState({current_page:1,total_pages:1,total_rows:0}),[k,F]=i.useState(null),[C,E]=i.useState({name:!1,template_body:!1}),[M,U]=i.useState(!1),Y=async()=>{try{const K=await W(r0.get,t);if(K?.Status==="Success"){const Z=K?.data?.[0]??K?.data??null;if(!Z)return;o(Z.header??Z.header_key??""),h(Z.api_key??""),n(!0)}}catch(K){console.log(K)}},V=async K=>{const Z={},ee={page:Z.page??D,perPage:Z.perPage??I,search:Z.search??u,status:Z.status??j},pe=new URLSearchParams;pe.set("page",ee.page),pe.set("per_page",ee.perPage),ee.search&&pe.set("search",ee.search),ee.status&&pe.set("status",ee.status),b(!0);try{const te=await W(`${Qn.table}?${pe.toString()}`,t);te?.Status==="Success"?(y(Array.isArray(te.data)?te.data:[]),z({current_page:te?.pagination?.current_page??1,total_pages:te?.pagination?.total_pages??1,total_rows:te?.pagination?.total_rows??(Array.isArray(te.data)?te.data.length:0)})):(y([]),z({current_page:1,total_pages:1,total_rows:0}),te?.msg==="Invalid page number"&&Number(ee.page)>1?R(1):te?.msg&&te.msg!=="No data found."&&T.error(te.msg,{duration:1500}))}catch(te){console.log(te),y([]),z({current_page:1,total_pages:1,total_rows:0}),T.error(te?.message??"Failed to load templates",{duration:1500})}finally{b(!1)}};i.useEffect(()=>{Y()},[]),i.useEffect(()=>{V()},[D,I,u,j]);const L=()=>{F({name:"",template_body:"",status:"Active"}),E({name:!1,template_body:!1})},B=K=>{F({id:K.id,name:K.name,template_body:K.template_body,status:K.status}),E({name:!1,template_body:!1})},$=()=>{F(null),E({name:!1,template_body:!1})},N=()=>{const K={name:!k?.name?.trim(),template_body:!k?.template_body?.trim()};return E(K),!K.name&&!K.template_body},H=async()=>{if(!(!k||!N())){U(!0);try{const K={name:k.name.trim(),template_body:k.template_body,status:k.status||"Active"},Z=k.id?Qn.edit:Qn.add;await bn(Z,{id:k.id??"",...K},t),T.success(k.id?"Template updated!":"Template added!",{duration:1e3}),$(),V()}catch(K){T.error(K?.message??"Failed to save template",{duration:1500})}finally{U(!1)}}},Q=async K=>{const Z=K.status==="Active"?"Deactive":"Active";try{const ee=await bn(Qn.changeStatus,{id:K.id,status:Z},t);ee?.Status==="Success"?(T.success(`Template ${Z}`,{duration:1e3}),V()):T.error(ee?.msg??"Failed to update status",{duration:1500})}catch(ee){T.error(ee?.message??"Failed to update status",{duration:1500})}},X=async K=>{if(window.confirm(`Delete template "${K.name}"?`))try{const Z=await st(Qn.delete,K.id,t);Z?.Status==="Success"?(T.success("Template deleted",{duration:1e3}),V()):T.error(Z?.msg??"Failed to delete template",{duration:1500})}catch(Z){T.error(Z?.message??"Failed to delete template",{duration:1500})}},J=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Template Body",dataIndex:"template_body",key:"template_body",ellipsis:!0},{title:"Status",key:"status",width:140,render:(K,Z)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Tag,{color:Z?.status==="Active"?"green":"red",children:Z?.status??""}),e.jsx(s.Switch,{size:"small",checked:Z?.status==="Active",onChange:()=>Q(Z)})]})},{title:"Actions",key:"actions",width:120,render:(K,Z)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),onClick:()=>B(Z)}),e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(re.DeleteOutlined,{}),onClick:()=>X(Z)})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"SMS Templates"}),children:[e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:{fontSize:14,color:"#666",marginBottom:8},children:["Available placeholders: ",e.jsx("code",{children:i0})]})}),k?e.jsxs(s.Card,{style:{borderRadius:8,border:"1px solid #B7D4FF",backgroundColor:"#F7FBFF",padding:16,marginBottom:16},children:[e.jsx(s.Typography.Title,{level:7,style:{margin:0,marginBottom:16},children:k.id?`Edit Template #${k.id}`:"New Template"}),e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Template Name*"}),e.jsx(s.Input,{maxLength:45,value:k.name,onChange:K=>F(Z=>({...Z,name:K.target.value})),status:C.name?"error":"",placeholder:"Template name"}),C.name&&e.jsx("div",{style:{color:"red",fontSize:12,marginTop:4},children:"Required field"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Template Body*"}),e.jsx(s.Input.TextArea,{rows:4,value:k.template_body,onChange:K=>F(Z=>({...Z,template_body:K.target.value})),status:C.template_body?"error":"",placeholder:"Template body"}),C.template_body&&e.jsx("div",{style:{color:"red",fontSize:12,marginTop:4},children:"Required field"})]}),e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx(s.Button,{size:"small",onClick:$,disabled:M,children:"Cancel"}),e.jsx(s.Button,{size:"small",type:"primary",loading:M,onClick:H,children:M?"Saving...":"Save"})]})]})]}):e.jsx(s.Button,{icon:e.jsx(re.PlusOutlined,{}),type:"primary",style:{marginBottom:16},onClick:L,children:"Add Template"}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(s.Input,{placeholder:"Search by name or body",value:A,onChange:K=>_(K.target.value),onKeyDown:K=>{K.key==="Enter"&&(R(1),x(A.trim()))},style:{width:280}}),e.jsxs("select",{value:j,onChange:K=>{R(1),P(K.target.value)},style:{padding:"6px 12px",borderRadius:6,border:"1px solid #d9d9d9"},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"Active",children:"Active"}),e.jsx("option",{value:"Deactive",children:"Deactive"})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsxs("span",{style:{fontSize:13,color:"#666"},children:["Page ",O.current_page," of ",Math.max(O.total_pages,1)," - ",O.total_rows," total"]}),e.jsx(s.Button,{size:"small",onClick:()=>R(K=>Math.max(1,K-1)),disabled:O.current_page<=1||g,children:"Prev"}),e.jsx(s.Button,{size:"small",onClick:()=>R(K=>K+1),disabled:O.current_page>=O.total_pages||g,children:"Next"})]})]}),e.jsx(s.Table,{bordered:!0,size:"small",columns:J,dataSource:S,loading:g,rowKey:K=>K.id,pagination:!1,scroll:{x:"max-content"}})]})]})}const Xd=lt.smsDetails,Zd=t=>{try{const a=new URL(t.trim());return(a.protocol==="http:"||a.protocol==="https:")&&!!a.hostname}catch{return!1}};function l0({token:t}){const[a,n]=i.useState(!1),[r,o]=i.useState(!1),[l,d]=i.useState({api_key:!1,url:!1}),[c,h]=i.useState(!1),[f,p]=i.useState({api_key:"",url:"",header_key:""}),[m,v]=i.useState("");i.useEffect(()=>{S()},[]);const S=async()=>{try{const D=await bn(Xd.get,{},t);if(D?.Status==="Success"){const R=D?.data?.[0]??D?.data??null;if(!R){n(!1);return}p({api_key:"",url:R.url||"",header_key:R.header_key||""}),v(R.api_key||""),n(!0)}}catch(D){console.error("SMS settings fetch error:",D)}},y=D=>{const{name:R,value:I}=D.target;p(A=>({...A,[R]:I})),l[R]&&d(A=>({...A,[R]:!1}))},g=()=>{n(!1),p(D=>({...D,api_key:""})),h(!1)},b=async()=>{const D={api_key:!f.api_key.trim(),url:!f.url.trim()||!Zd(f.url)};if(d(D),!Object.values(D).some(Boolean)){o(!0);try{const I={api_key:f.api_key.trim(),url:f.url.trim(),header_key:f.header_key.trim()},A=await bn(Xd.save,I,t);A?.Status==="Success"?(s.message.success("Data Updated successfully!"),await S()):s.message.error(A?.msg??"Failed to update SMS settings")}catch(I){console.error("SMS settings save error:",I),s.message.error("Failed to update SMS settings.")}finally{o(!1)}}};return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"SMS Details Setting"}),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("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"API Key"}),e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"flex-end"},children:[e.jsx(s.Input,{name:"api_key",value:a?"*****":f.api_key,onChange:y,disabled:a,status:l.api_key?"error":"",placeholder:"Enter API key",style:{paddingRight:a?40:0}}),a&&e.jsx(s.Button,{type:"text",icon:e.jsx(re.EyeOutlined,{}),size:"small",style:{position:"absolute",right:4,padding:0,height:"auto"},onClick:()=>h(!c)})]}),a&&c&&e.jsx("div",{style:{marginTop:4,fontSize:12,wordBreak:"break-all"},children:m||"No key saved"}),l.api_key&&e.jsx("div",{style:{color:"red",fontSize:12,marginTop:4},children:"Required field"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"URL"}),e.jsx(s.Input,{name:"url",value:f.url,onChange:y,onBlur:()=>{f.url&&!Zd(f.url)&&d(D=>({...D,url:!0}))},disabled:a,status:l.url?"error":"",placeholder:"https://example.com"}),l.url&&e.jsx("div",{style:{color:"red",fontSize:12,marginTop:4},children:"Please enter a valid URL (e.g. https://example.com)"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Header Key"}),e.jsx(s.Input,{name:"header_key",value:f.header_key,onChange:y,disabled:a,placeholder:"Enter header key"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:a?e.jsx(s.Button,{type:"primary",onClick:g,children:"Edit"}):e.jsx(de,{type:"button",value:r?"Saving...":"Save",color:"primary",onClick:b,disabled:r})})]})})})}const La=lt.chat,d0=t=>lt.getMessages(t),c0=t=>lt.getSendMessages(t),ec=t=>{try{return t?JSON.parse(t):null}catch{return null}},u0=t=>/\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i.test(t);function tc(t,a){if(!t)return"";try{const n=new URL(a),r=new URL(t,a);return(r.hostname==="localhost"||r.hostname==="127.0.0.1")&&(r.protocol=n.protocol,r.host=n.host),r.toString()}catch{return t}}function p0(t){if(!t)return"";const a=new Date(t);return Number.isNaN(a.getTime())?"":a.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function m0(t){return t?.fromMe?"You":t?.senderName??t?.contactName??t?.senderJid??t?.chatJid??"Unknown"}function ac(t){return{phone:t?.phone??t?.mobile??t?.mobileno??t?.whatsapp_number??"",jid:t?.jid??t?.chatJid??t?.whatsapp_jid??t?.whatsapp_group_id??""}}const h0=["😀","😃","😄","😅","😂","😊","😍","😎","😢","🙏","👍","❤️","🔥","🎉"],nc={people:["😀","😁","😂","🤣","🙂","🙃","😉","😊","😌","😍","🥰","😘","😋","😛","😝","😜","🤪","🤓","😎","🤩","🥳","😏","😒","😞","😔","😟"],nature:["😺","😻","🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸"],food:["🍔","🍕","🌭","🍿","🧁","🍰","🎂","🍪","🍪","🍫","🍬","🍩","🍓","🍎","🍌"],activities:["⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎱","🏓","🏸","🥅","🏒","🏑","🎯","🎯"],travel:["✈️","🚗","🚕","🚌","🚆","🚗","🏍️","🚲","🛳️","🚢","🚁","🚂"],objects:["📱","💻","📺","🔊","🎧","📷","📹","💾","💿","📠","📠","🖨️"],symbols:["⭐","🌟","✅","❌","❓","❔","🔴","🟢","🔵","⚪","⚫","🔶"],flags:["🏁","🚩","🎌","🏴","🏳️"]},f0={people:"People",nature:"Nature",food:"Food & Drink",activities:"Activities",travel:"Travel",objects:"Objects",symbols:"Symbols",flags:"Flags"};function Uu({token:t}){const a=i.useMemo(()=>ec(localStorage.getItem("Userdata"))||{},[]),n=i.useMemo(()=>ec(localStorage.getItem("genrall_settings"))||{},[]),r=i.useMemo(()=>a?.branch_id??"",[a?.branch_id]),o=i.useMemo(()=>n?.session_id??"1",[n?.session_id]),l=La.whatsappBaseUrl,[d,c]=i.useState("teacher"),[h,f]=i.useState({}),[p,m]=i.useState(""),[v,S]=i.useState(""),[y,g]=i.useState([]),[b,D]=i.useState(!1),[R,I]=i.useState("people"),[A,_]=i.useState(""),[u,x]=i.useState(!1),[j,P]=i.useState(0),[O,z]=i.useState(!1),[k,F]=i.useState(!1),[C,E]=i.useState("Staff"),[M,U]=i.useState([]),[Y,V]=i.useState([]),[L,B]=i.useState(""),[$,N]=i.useState(null),H=i.useRef(null),Q=i.useRef(null),X=i.useRef(null),J=i.useRef(new Set),K=i.useRef(new Set),Z=i.useRef(""),[ee,pe]=i.useState({}),{data:te}=q(t?[La.teacherDropdown,t]:null,([oe,ge])=>W(oe,ge)),se=i.useMemo(()=>{const oe=te?.data?.data??te?.data??te??[];return Array.isArray(oe)?oe.map(ge=>({label:ge.staff_name??ge.name??ge.full_name??"",value:String(ge.id??ge.staff_id??ge.employee_id??ge.value??""),...ge})):[]},[te]),{data:le}=q(t?[La.classDropdown,t]:null,([oe,ge])=>W(oe,ge)),Ce=i.useMemo(()=>{const oe=le?.data?.data??le?.data??le??[];return Array.isArray(oe)?oe.map(ge=>({label:ge.class_name??ge.name??ge.label??"",value:String(ge.id??ge.class_id??ge.value??""),...ge})):[]},[le]),{data:Le}=q($?[$,t]:null,([oe,ge])=>W(oe,ge)),Re=i.useMemo(()=>{const oe=Le?.data?.data??Le?.data??Le??[];return Array.isArray(oe)?oe.map(ge=>({label:ge.section_name??ge.name??ge.label??"",value:String(ge.id??ge.section_id??ge.value??""),...ge})):[]},[Le]),{data:xe}=q(t?[`${La.groupList}?type=staff`,t]:null,([oe,ge])=>W(oe,ge)),{data:De}=q(t?[`${La.groupList}?type=student`,t]:null,([oe,ge])=>W(oe,ge)),Ue=d==="teacher"?Array.isArray(xe?.data)?xe.data:[]:Array.isArray(De?.data)?De.data:[];i.useEffect(()=>{if(!Ue||Ue.length===0){m("");return}Ue.some(oe=>oe.id===p)||m(Ue[0].id)},[Ue,p]);const ye=Ue.find(oe=>oe.id===p)??Ue[0]??null,me=ye?.id??null,Pe=ye?h[ye.id]??[]:[],Ye=async oe=>{const{jid:ge}=ac(oe);if(ge)try{const $e=`${d0(l)}?schoolCode=${encodeURIComponent(r)}&chatJid=${encodeURIComponent(ge)}`,Ne=await dt.get($e),ht=Array.isArray(Ne?.data?.messages)?Ne.data.messages:[];f(yt=>({...yt,[oe.id]:ht.map(Tt=>({...Tt,fromMe:Tt.direction==="outbound",text:Tt.body||""}))}))}catch($e){const Ne=$e?.response?.data?.message||$e?.message||"Failed to load messages.";message.error(Ne)}};i.useEffect(()=>{!me||h[me]||Ye(ye)},[h,ye,me]);const ze=oe=>{f(ge=>{const $e={...ge},Ne=$e[p]??[];return $e[p]=[...Ne,{id:Date.now(),fromMe:!0,text:oe}],$e})},we=(oe="smooth")=>{if(typeof X.current?.scrollIntoView=="function"){X.current.scrollIntoView({behavior:oe,block:"end"});return}Q.current&&(Q.current.scrollTop=Q.current.scrollHeight)},ke=()=>{const oe=Q.current;return oe?oe.scrollHeight-oe.scrollTop-oe.clientHeight:0},Te=()=>{const oe=ke()<100;x(!oe),oe&&P(0)};i.useEffect(()=>{Z.current="",x(!1),P(0);const oe=globalThis.setTimeout(()=>{we("auto"),Te()},0);return()=>globalThis.clearTimeout(oe)},[me]),i.useEffect(()=>{const oe=Pe[Pe.length-1];if(!oe)return;const ge=`${oe.id}-${oe.createdAt||""}-${Pe.length}`,$e=Z.current,Ne=ke()<100;if(!$e||Ne||oe.fromMe){const ht=globalThis.setTimeout(()=>{we($e?"smooth":"auto"),Te()},0);return Z.current=ge,()=>globalThis.clearTimeout(ht)}$e!==ge&&!oe.fromMe&&(x(!0),P(ht=>ht+1)),Z.current=ge},[Pe]);const[ce,ve]=i.useState({});i.useEffect(()=>{const oe=Pe.filter(Ne=>Ne?.messageType==="image"&&Ne?.mediaUrl&&!ee[Ne.id]&&!ce[Ne.id]);if(oe.length===0)return;let ge=!1;return(async()=>{for(const Ne of oe){const ht=tc(Ne.mediaUrl,l);try{const yt=await dt.get(ht,{responseType:"blob"}),Tt=URL.createObjectURL(yt.data);K.current.add(Tt),ge||pe(be=>({...be,[Ne.id]:Tt}))}catch{ge||ve(yt=>({...yt,[Ne.id]:ht}))}}})(),()=>{ge=!0}},[Pe,ee,ce,l]);const _e=()=>{g(oe=>(oe.forEach(ge=>{ge?.previewUrl&&(URL.revokeObjectURL(ge.previewUrl),J.current.delete(ge.previewUrl))}),[]))},Ve=oe=>{g(ge=>{const $e=[...ge],[Ne]=$e.splice(oe,1);return Ne?.previewUrl&&(URL.revokeObjectURL(Ne.previewUrl),J.current.delete(Ne.previewUrl)),$e})};i.useEffect(()=>()=>{J.current.forEach(oe=>URL.revokeObjectURL(oe)),J.current.clear(),K.current.forEach(oe=>URL.revokeObjectURL(oe)),K.current.clear()},[]);const He=oe=>{if(!oe||oe.length===0)return;const ge=oe.filter(Boolean).filter($e=>$e.type?.startsWith("image/")||$e.type==="application/pdf").map($e=>{const Ne=$e.type?.startsWith("image/")?URL.createObjectURL($e):"";return Ne&&J.current.add(Ne),{file:$e,name:$e.name||"Attachment",previewUrl:Ne,type:$e.type||""}});g($e=>[...$e,...ge])},je=({url:oe,trimmedMessage:ge,attachments:$e,schoolCode:Ne,sessionId:ht,phone:yt,jid:Tt})=>{if($e.length>0){const Ie=new FormData;return Ie.append(Ne?"schoolCode":"sessionId",Ne||ht),Ie.append(yt?"phone":"jid",yt||Tt),Ie.append("queue","false"),ge&&Ie.append("text",ge),$e.forEach(at=>{Ie.append("file",at.file)}),dt.post(oe,Ie,{headers:{"Content-Type":"multipart/form-data"}})}const be={text:ge,queue:!1,[Ne?"schoolCode":"sessionId"]:Ne||ht,[yt?"phone":"jid"]:yt||Tt};return dt.post(oe,be,{headers:{"Content-Type":"application/json"}})},Me=({selectedItem:oe,trimmedMessage:ge,attachments:$e,schoolCode:Ne,sessionId:ht,phone:yt,jid:Tt})=>!ge&&$e.length===0||!oe?{shouldProceed:!1,message:""}:!Ne&&!ht?{shouldProceed:!1,message:"School code or session id is required."}:!yt&&!Tt?{shouldProceed:!1,message:"Phone or jid is required for the selected chat."}:{shouldProceed:!0,message:""},rt=async()=>{const oe=v.trim(),{phone:ge,jid:$e}=ac(ye),Ne=Me({selectedItem:ye,trimmedMessage:oe,attachments:y,schoolCode:r,sessionId:o,phone:ge,jid:$e});if(!Ne.shouldProceed){Ne.message&&message.error(Ne.message);return}try{await je({url:`${c0(l)}`,trimmedMessage:oe,attachments:y,schoolCode:r,sessionId:o,phone:ge,jid:$e}),ze(oe),S(""),_e(),D(!1),message.success("Message sent.")}catch(ht){const yt=ht?.response?.data?.message||ht?.message||"Failed to send message.";message.error(yt)}},vt=[{value:"Staff",label:"Staff"},{value:"Class",label:"Class"}],na=async oe=>{oe.preventDefault(),F(!0);const ge=new FormData(oe.target);ge.append("session_id",o),ge.set("type",C),C==="Staff"?Array.isArray(M)&&M.forEach($e=>{$e!=null&&$e!==""&&ge.append("staff_id[]",$e)}):(L!=null&&L!==""&&ge.set("class_id",L),Array.isArray(Y)&&Y.forEach($e=>{$e!=null&&$e!==""&&ge.append("section_id[]",$e)}));try{await Wc(La.groupCreate,ge,t)?(message.success("Group created successfully!"),z(!1),U([]),V([]),B("")):message.error("Failed to create group.")}catch{message.error("Failed to create group.")}finally{F(!1)}oe.target.reset()},Vt=()=>z(!1),Se=oe=>{S(ge=>ge+oe),D(!1)},Oe=(h[ye?.id]??[]).slice(-1)[0]?.text??"No messages";return e.jsxs("div",{style:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[e.jsx(s.Modal,{title:"Create Group",footer:null,open:O,onCancel:Vt,children:e.jsx("form",{onSubmit:na,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Group Name*"}),e.jsx(s.Input,{name:"name",type:"text",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,marginBottom:6},children:"Type*"}),e.jsx(s.Select,{value:C,onChange:E,options:vt,style:{width:"100%"}})]}),C==="Staff"?e.jsx(s.Select,{mode:"multiple",label:"Staff",options:se,closeMenuOnSelect:!0,value:M,onChange:U,placeholder:"Select staff"}):e.jsxs(e.Fragment,{children:[e.jsx(s.Select,{label:"Class",options:Ce,closeMenuOnSelect:!0,value:L||void 0,onChange:oe=>{B(oe),N(`${La.sectionByClass}?class_id=${oe}`),V([])},placeholder:"Select class"}),e.jsx(s.Select,{mode:"multiple",label:"Section",options:Re.map(oe=>({label:oe.label,value:oe.value})),placeholder:"Select sections",value:Y,onChange:V})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(s.Button,{onClick:Vt,children:"Cancel"}),e.jsx(s.Button,{type:"primary",htmlType:"submit",loading:k,children:"Create"})]})]})})}),e.jsxs("div",{style:{flex:1,overflow:"hidden",display:"grid",gridTemplateColumns:"350px 1fr"},children:[e.jsxs("div",{style:{borderRight:"1px solid #e0e0e0",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid #eee",display:"flex",gap:8,justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:d==="teacher"?"primary":"default",onClick:()=>c("teacher"),children:"Teacher"}),e.jsx(s.Button,{type:d==="class"?"primary":"default",onClick:()=>c("class"),children:"Student"})]}),e.jsx(s.Button,{type:"primary",onClick:()=>z(!0),children:"Create Group"})]}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:Ue.map(oe=>{const ge=p===oe.id;return e.jsxs("div",{onClick:()=>m(oe.id),style:{display:"flex",alignItems:"center",gap:8,padding:"12px 16px",cursor:"pointer",backgroundColor:ge?"#f5f9ff":"transparent",borderBottom:"1px solid #f0f0f0"},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:"50%",backgroundColor:"#e0e0e0",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:"bold",color:"#555"},children:(oe.group_name||oe.name||"?").charAt(0)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(s.Typography.Text,{strong:!0,style:{display:"block"},children:oe.group_name||oe.name||""}),e.jsx(s.Typography.Text,{type:"secondary",style:{fontSize:12,display:"block"},children:Oe})]})]},oe.id)})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid #eee",display:"flex",gap:8,alignItems:"center"},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:"50%",backgroundColor:"#e0e0e0",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:"bold",color:"#555"},children:(ye?.group_name||"?").charAt(0)}),e.jsxs("div",{children:[e.jsx(s.Typography.Text,{strong:!0,style:{display:"block"},children:ye?.group_name||"Select a chat"}),e.jsx(s.Typography.Text,{type:"secondary",style:{fontSize:11},children:d==="teacher"?"Teacher":"Class"})]})]}),e.jsxs("div",{ref:Q,onScroll:Te,style:{flex:1,minHeight:0,padding:"12px 16px",overflowY:"auto",backgroundColor:"#f7f8fa"},children:[Pe.length===0?e.jsx(s.Typography.Text,{type:"secondary",children:"No messages yet"}):Pe.map((oe,ge)=>e.jsx("div",{style:{display:"flex",justifyContent:oe.fromMe?"flex-end":"flex-start",marginBottom:16},children:e.jsxs("div",{style:{maxWidth:"75%",padding:"10px 14px",borderRadius:12,backgroundColor:oe.fromMe?"#d1e7ff":"#ffffff",border:"1px solid #e6e6e6"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:4,marginBottom:oe.text?6:0},children:[e.jsx(s.Typography.Text,{style:{fontSize:12,fontWeight:500,color:"#555"},children:m0(oe)}),e.jsx(s.Typography.Text,{style:{fontSize:11,color:"#999"},children:p0(oe.createdAt)})]}),(oe.text||oe.body)&&e.jsx(s.Typography.Text,{style:{display:"block",fontSize:14},children:oe.text||oe.body}),oe.messageType==="image"&&(oe.mediaUrl||oe?._data?.body)&&(ee[oe.id]?e.jsx("img",{alt:"Chat attachment",src:ee[oe.id],style:{marginTop:8,width:180,maxWidth:"100%",borderRadius:8,border:"1px solid #ddd"}}):ce[oe.id]?e.jsx("img",{alt:"Chat attachment",src:ce[oe.id],style:{marginTop:8,width:180,maxWidth:"100%",borderRadius:8,border:"1px solid #ddd"}}):oe.mediaUrl?e.jsx("img",{alt:"Chat attachment",src:tc(oe.mediaUrl,l),style:{marginTop:8,width:180,maxWidth:"100%",borderRadius:8,border:"1px solid #ddd"}}):null)]})},oe.id??ge)),e.jsx("div",{ref:X})]}),u?e.jsx(s.Button,{onClick:()=>{we("smooth"),x(!1),P(0)},style:{position:"absolute",right:16,bottom:y.length>0?160:80,minWidth:44,width:44,height:44,borderRadius:"50%",backgroundColor:"#fff",color:"#1976d2",border:"1px solid #d9e3f0",boxShadow:"0 6px 18px rgba(0,0,0,0.14)",zIndex:3},"aria-label":"Scroll to bottom",children:e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[e.jsx(re.DownOutlined,{}),j>0?e.jsx("span",{style:{position:"absolute",top:-12,right:-18,minWidth:18,height:18,borderRadius:999,background:"#f44336",color:"#fff",fontSize:10,lineHeight:"18px",padding:"0 5px",textAlign:"center",fontWeight:700},children:j}):null]})}):null,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,borderTop:"1px solid #eee",backgroundColor:"#fff",borderRadius:9999,width:"100%",flexShrink:0,padding:"8px 8px 8px 12px",boxSizing:"border-box"},onDragOver:oe=>oe.preventDefault(),onDrop:oe=>{oe.preventDefault();const ge=Array.from(oe.dataTransfer?.files||[]);He(ge)},children:[e.jsx("input",{type:"file",multiple:!0,ref:H,style:{display:"none"},accept:"image/*,application/pdf",capture:"environment",onChange:oe=>{const ge=Array.from(oe.target.files||[]);He(ge),oe.target.value=""}}),e.jsx(s.Button,{type:"text",onClick:()=>H.current?.click(),style:{minWidth:0,width:38,height:38,borderRadius:"50%"},"aria-label":"Attach",icon:e.jsx(re.PlusOutlined,{})}),e.jsx(s.Button,{type:"text",onClick:()=>D(!b),style:{minWidth:0,width:38,height:38,borderRadius:"50%"},"aria-label":"Emoji",icon:e.jsx(re.SmileOutlined,{})}),e.jsx(s.Input,{placeholder:"Type a message",value:v,onChange:oe=>S(oe.target.value),onPaste:oe=>{const $e=Array.from(oe.clipboardData?.items||[]).filter(Ne=>Ne.kind==="file").map(Ne=>Ne.getAsFile()).filter(Boolean);$e.length&&He($e)},style:{flex:1,borderRadius:9999},onPressEnter:rt}),e.jsx(s.Button,{type:"primary",onClick:rt,disabled:!v.trim()&&y.length===0||!ye,style:{minWidth:0,width:40,height:40,borderRadius:"50%",backgroundColor:"#25D366",border:"none"},"aria-label":"Send",icon:e.jsx(re.SendOutlined,{})})]}),b&&e.jsx("div",{style:{borderTop:"1px solid #eee",display:"flex",flexWrap:"wrap",gap:2,padding:"6px 8px",maxHeight:180,overflowY:"auto"},children:h0.map((oe,ge)=>e.jsx("button",{type:"button",onClick:()=>Se(oe),style:{fontSize:20,background:"none",border:"none",cursor:"pointer",padding:2},children:oe},ge))}),b&&e.jsxs("div",{style:{borderTop:"1px solid #eee",padding:"8px",maxHeight:200,overflowY:"auto"},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:6},children:f0[R]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gap:2},children:(A.trim()?Object.values(nc).flat().filter(oe=>oe.toLowerCase().includes(A.toLowerCase())):nc[R]).map((oe,ge)=>e.jsx("button",{type:"button",onClick:()=>Se(oe),style:{fontSize:20,background:"none",border:"none",cursor:"pointer",padding:2,textAlign:"center"},children:oe},`emoji-${oe}-${ge}`))})]}),y.length>0&&e.jsx("div",{style:{borderTop:"1px solid #eee",display:"flex",flexWrap:"wrap",gap:8,padding:8},children:y.map((oe,ge)=>oe?.previewUrl||u0(oe?.name||"")?e.jsxs("div",{style:{position:"relative"},children:[e.jsx("img",{alt:"Attachment preview",src:oe.previewUrl,style:{width:80,height:80,objectFit:"cover",borderRadius:6,border:"1px solid #eee"}}),e.jsx(s.Button,{type:"text",danger:!0,onClick:()=>Ve(ge),style:{position:"absolute",top:0,right:0,minWidth:0,padding:"2px 6px"},icon:e.jsx(re.DeleteOutlined,{})})]},ge):e.jsxs("div",{style:{padding:"4px 8px",borderRadius:6,border:"1px solid #ddd",backgroundColor:"#fafafa",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[oe?.name||"Attachment",e.jsx(s.Button,{type:"text",danger:!0,onClick:()=>Ve(ge),style:{minWidth:0,padding:"2px 6px"},icon:e.jsx(re.DeleteOutlined,{})})]},ge))})]})]})]})}function g0({token:t}){return e.jsx("div",{style:{display:"grid",gap:20,height:"calc(100vh - 140px)"},children:e.jsx(s.Card,{title:e.jsxs(s.Space,{children:[e.jsx(re.MailOutlined,{}),e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Send Whatsapp Message"})]}),style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:e.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden",padding:24},children:e.jsx(Uu,{token:t})})})})}function Ct(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function ga(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function Zi({pathname:t="/",search:a="",hash:n=""}){return a&&a!=="?"&&(t+=a.charAt(0)==="?"?a:"?"+a),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function So(t){let a={};if(t){let n=t.indexOf("#");n>=0&&(a.hash=t.substring(n),t=t.substring(0,n));let r=t.indexOf("?");r>=0&&(a.search=t.substring(r),t=t.substring(0,r)),t&&(a.pathname=t)}return a}function Nu(t,a,n="/"){return y0(t,a,n,!1)}function y0(t,a,n,r){let o=typeof a=="string"?So(a):a,l=Ia(o.pathname||"/",n);if(l==null)return null;let d=zu(t);x0(d);let c=null;for(let h=0;c==null&&h<d.length;++h){let f=k0(l);c=T0(d[h],f,r)}return c}function zu(t,a=[],n=[],r="",o=!1){let l=(d,c,h=o,f)=>{let p={relativePath:f===void 0?d.path||"":f,caseSensitive:d.caseSensitive===!0,childrenIndex:c,route:d};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(r)&&h)return;Ct(p.relativePath.startsWith(r),`Absolute route path "${p.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(r.length)}let m=Xt([r,p.relativePath]),v=n.concat(p);d.children&&d.children.length>0&&(Ct(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),zu(d.children,a,v,m,h)),!(d.path==null&&!d.index)&&a.push({path:m,score:_0(m,d.index),routesMeta:v})};return t.forEach((d,c)=>{if(d.path===""||!d.path?.includes("?"))l(d,c);else for(let h of qu(d.path))l(d,c,!0,h)}),a}function qu(t){let a=t.split("/");if(a.length===0)return[];let[n,...r]=a,o=n.endsWith("?"),l=n.replace(/\?$/,"");if(r.length===0)return o?[l,""]:[l];let d=qu(r.join("/")),c=[];return c.push(...d.map(h=>h===""?l:[l,h].join("/"))),o&&c.push(...d),c.map(h=>t.startsWith("/")&&h===""?"/":h)}function x0(t){t.sort((a,n)=>a.score!==n.score?n.score-a.score:A0(a.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var b0=/^:[\w-]+$/,j0=3,S0=2,w0=1,v0=10,C0=-2,sc=t=>t==="*";function _0(t,a){let n=t.split("/"),r=n.length;return n.some(sc)&&(r+=C0),a&&(r+=S0),n.filter(o=>!sc(o)).reduce((o,l)=>o+(b0.test(l)?j0:l===""?w0:v0),r)}function A0(t,a){return t.length===a.length&&t.slice(0,-1).every((r,o)=>r===a[o])?t[t.length-1]-a[a.length-1]:0}function T0(t,a,n=!1){let{routesMeta:r}=t,o={},l="/",d=[];for(let c=0;c<r.length;++c){let h=r[c],f=c===r.length-1,p=l==="/"?a:a.slice(l.length)||"/",m=jr({path:h.relativePath,caseSensitive:h.caseSensitive,end:f},p),v=h.route;if(!m&&f&&n&&!r[r.length-1].route.index&&(m=jr({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},p)),!m)return null;Object.assign(o,m.params),d.push({params:o,pathname:Xt([l,m.pathname]),pathnameBase:M0(Xt([l,m.pathnameBase])),route:v}),m.pathnameBase!=="/"&&(l=Xt([l,m.pathnameBase]))}return d}function jr(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=D0(t.path,t.caseSensitive,t.end),o=a.match(n);if(!o)return null;let l=o[0],d=l.replace(/(.)\/+$/,"$1"),c=o.slice(1);return{params:r.reduce((f,{paramName:p,isOptional:m},v)=>{if(p==="*"){let y=c[v]||"";d=l.slice(0,l.length-y.length).replace(/(.)\/+$/,"$1")}const S=c[v];return m&&!S?f[p]=void 0:f[p]=(S||"").replace(/%2F/g,"/"),f},{}),pathname:l,pathnameBase:d,pattern:t}}function D0(t,a=!1,n=!0){ga(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],o="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,c,h,f,p)=>{if(r.push({paramName:c,isOptional:h!=null}),h){let m=p.charAt(f+d.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),o+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":t!==""&&t!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,a?void 0:"i"),r]}function k0(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return ga(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${a}).`),t}}function Ia(t,a){if(a==="/")return t;if(!t.toLowerCase().startsWith(a.toLowerCase()))return null;let n=a.endsWith("/")?a.length-1:a.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}var R0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function I0(t,a="/"){let{pathname:n,search:r="",hash:o=""}=typeof t=="string"?So(t):t,l;return n?(n=Wu(n),n.startsWith("/")?l=rc(n.substring(1),"/"):l=rc(n,a)):l=a,{pathname:l,search:E0(r),hash:O0(o)}}function rc(t,a){let n=Sr(a).split("/");return t.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function Oi(t,a,n,r){return`Cannot include a '${t}' character in a manually specified \`to.${a}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function P0(t){return t.filter((a,n)=>n===0||a.route.path&&a.route.path.length>0)}function Yu(t){let a=P0(t);return a.map((n,r)=>r===a.length-1?n.pathname:n.pathnameBase)}function wo(t,a,n,r=!1){let o;typeof t=="string"?o=So(t):(o={...t},Ct(!o.pathname||!o.pathname.includes("?"),Oi("?","pathname","search",o)),Ct(!o.pathname||!o.pathname.includes("#"),Oi("#","pathname","hash",o)),Ct(!o.search||!o.search.includes("#"),Oi("#","search","hash",o)));let l=t===""||o.pathname==="",d=l?"/":o.pathname,c;if(d==null)c=n;else{let m=a.length-1;if(!r&&d.startsWith("..")){let v=d.split("/");for(;v[0]==="..";)v.shift(),m-=1;o.pathname=v.join("/")}c=m>=0?a[m]:"/"}let h=I0(o,c),f=d&&d!=="/"&&d.endsWith("/"),p=(l||d===".")&&n.endsWith("/");return!h.pathname.endsWith("/")&&(f||p)&&(h.pathname+="/"),h}var Wu=t=>t.replace(/\/\/+/g,"/"),Xt=t=>Wu(t.join("/")),Sr=t=>t.replace(/\/+$/,""),M0=t=>Sr(t).replace(/^\/*/,"/"),E0=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,O0=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,$0=class{constructor(t,a,n,r=!1){this.status=t,this.statusText=a||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function F0(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function B0(t){let a=t.map(n=>n.route.path).filter(Boolean);return Xt(a)||"/"}var Vu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Hu(t,a){let n=t;if(typeof n!="string"||!R0.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,o=!1;if(Vu)try{let l=new URL(window.location.href),d=n.startsWith("//")?new URL(l.protocol+n):new URL(n),c=Ia(d.pathname,a);d.origin===l.origin&&c!=null?n=c+d.search+d.hash:o=!0}catch{ga(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:o,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ku=["POST","PUT","PATCH","DELETE"];new Set(Ku);var L0=["GET",...Ku];new Set(L0);var kn=fe.createContext(null);kn.displayName="DataRouter";var Wr=fe.createContext(null);Wr.displayName="DataRouterState";var Gu=fe.createContext(!1);function U0(){return fe.useContext(Gu)}var Ju=fe.createContext({isTransitioning:!1});Ju.displayName="ViewTransition";var N0=fe.createContext(new Map);N0.displayName="Fetchers";var z0=fe.createContext(null);z0.displayName="Await";var aa=fe.createContext(null);aa.displayName="Navigation";var vo=fe.createContext(null);vo.displayName="Location";var xa=fe.createContext({outlet:null,matches:[],isDataRoute:!1});xa.displayName="Route";var Co=fe.createContext(null);Co.displayName="RouteError";var Qu="REACT_ROUTER_ERROR",q0="REDIRECT",Y0="ROUTE_ERROR_RESPONSE";function W0(t){if(t.startsWith(`${Qu}:${q0}:{`))try{let a=JSON.parse(t.slice(28));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string"&&typeof a.location=="string"&&typeof a.reloadDocument=="boolean"&&typeof a.replace=="boolean")return a}catch{}}function V0(t){if(t.startsWith(`${Qu}:${Y0}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new $0(a.status,a.statusText,a.data)}catch{}}function H0(t,{relative:a}={}){Ct(Vr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=fe.useContext(aa),{hash:o,pathname:l,search:d}=ws(t,{relative:a}),c=l;return n!=="/"&&(c=l==="/"?n:Xt([n,l])),r.createHref({pathname:c,search:d,hash:o})}function Vr(){return fe.useContext(vo)!=null}function ba(){return Ct(Vr(),"useLocation() may be used only in the context of a <Router> component."),fe.useContext(vo).location}var Xu="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Zu(t){fe.useContext(aa).static||fe.useLayoutEffect(t)}function Ss(){let{isDataRoute:t}=fe.useContext(xa);return t?i1():K0()}function K0(){Ct(Vr(),"useNavigate() may be used only in the context of a <Router> component.");let t=fe.useContext(kn),{basename:a,navigator:n}=fe.useContext(aa),{matches:r}=fe.useContext(xa),{pathname:o}=ba(),l=JSON.stringify(Yu(r)),d=fe.useRef(!1);return Zu(()=>{d.current=!0}),fe.useCallback((h,f={})=>{if(ga(d.current,Xu),!d.current)return;if(typeof h=="number"){n.go(h);return}let p=wo(h,JSON.parse(l),o,f.relative==="path");t==null&&a!=="/"&&(p.pathname=p.pathname==="/"?a:Xt([a,p.pathname])),(f.replace?n.replace:n.push)(p,f.state,f)},[a,n,l,o,t])}fe.createContext(null);function ws(t,{relative:a}={}){let{matches:n}=fe.useContext(xa),{pathname:r}=ba(),o=JSON.stringify(Yu(n));return fe.useMemo(()=>wo(t,JSON.parse(o),r,a==="path"),[t,o,r,a])}function G0(t,a,n){Ct(Vr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=fe.useContext(aa),{matches:o}=fe.useContext(xa),l=o[o.length-1],d=l?l.params:{},c=l?l.pathname:"/",h=l?l.pathnameBase:"/",f=l&&l.route;{let b=f&&f.path||"";tp(c,!f||b.endsWith("*")||b.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${b}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
63
|
+
|
|
64
|
+
Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}/*`}">.`)}let p=ba(),m;m=p;let v=m.pathname||"/",S=v;if(h!=="/"){let b=h.replace(/^\//,"").split("/");S="/"+v.replace(/^\//,"").split("/").slice(b.length).join("/")}let y=Nu(t,{pathname:S});return ga(f||y!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),ga(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),e1(y&&y.map(b=>Object.assign({},b,{params:Object.assign({},d,b.params),pathname:Xt([h,r.encodeLocation?r.encodeLocation(b.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?h:Xt([h,r.encodeLocation?r.encodeLocation(b.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathnameBase])})),o,n)}function J0(){let t=r1(),a=F0(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},l={padding:"2px 4px",backgroundColor:r},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=fe.createElement(fe.Fragment,null,fe.createElement("p",null,"💿 Hey developer 👋"),fe.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",fe.createElement("code",{style:l},"ErrorBoundary")," or"," ",fe.createElement("code",{style:l},"errorElement")," prop on your route.")),fe.createElement(fe.Fragment,null,fe.createElement("h2",null,"Unexpected Application Error!"),fe.createElement("h3",{style:{fontStyle:"italic"}},a),n?fe.createElement("pre",{style:o},n):null,d)}var Q0=fe.createElement(J0,null),ep=class extends fe.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,a){return a.location!==t.location||a.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:a.error,location:a.location,revalidation:t.revalidation||a.revalidation}}componentDidCatch(t,a){this.props.onError?this.props.onError(t,a):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=V0(t.digest);n&&(t=n)}let a=t!==void 0?fe.createElement(xa.Provider,{value:this.props.routeContext},fe.createElement(Co.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?fe.createElement(X0,{error:t},a):a}};ep.contextType=Gu;var $i=new WeakMap;function X0({children:t,error:a}){let{basename:n}=fe.useContext(aa);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let r=W0(a.digest);if(r){let o=$i.get(a);if(o)throw o;let l=Hu(r.location,n);if(Vu&&!$i.get(a))if(l.isExternal||r.reloadDocument)window.location.href=l.absoluteURL||l.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(l.to,{replace:r.replace}));throw $i.set(a,d),d}return fe.createElement("meta",{httpEquiv:"refresh",content:`0;url=${l.absoluteURL||l.to}`})}}return t}function Z0({routeContext:t,match:a,children:n}){let r=fe.useContext(kn);return r&&r.static&&r.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=a.route.id),fe.createElement(xa.Provider,{value:t},n)}function e1(t,a=[],n){let r=n?.state;if(t==null){if(!r)return null;if(r.errors)t=r.matches;else if(a.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let o=t,l=r?.errors;if(l!=null){let p=o.findIndex(m=>m.route.id&&l?.[m.route.id]!==void 0);Ct(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),o=o.slice(0,Math.min(o.length,p+1))}let d=!1,c=-1;if(n&&r){d=r.renderFallback;for(let p=0;p<o.length;p++){let m=o[p];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(c=p),m.route.id){let{loaderData:v,errors:S}=r,y=m.route.loader&&!v.hasOwnProperty(m.route.id)&&(!S||S[m.route.id]===void 0);if(m.route.lazy||y){n.isStatic&&(d=!0),c>=0?o=o.slice(0,c+1):o=[o[0]];break}}}}let h=n?.onError,f=r&&h?(p,m)=>{h(p,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:B0(r.matches),errorInfo:m})}:void 0;return o.reduceRight((p,m,v)=>{let S,y=!1,g=null,b=null;r&&(S=l&&m.route.id?l[m.route.id]:void 0,g=m.route.errorElement||Q0,d&&(c<0&&v===0?(tp("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,b=null):c===v&&(y=!0,b=m.route.hydrateFallbackElement||null)));let D=a.concat(o.slice(0,v+1)),R=()=>{let I;return S?I=g:y?I=b:m.route.Component?I=fe.createElement(m.route.Component,null):m.route.element?I=m.route.element:I=p,fe.createElement(Z0,{match:m,routeContext:{outlet:p,matches:D,isDataRoute:r!=null},children:I})};return r&&(m.route.ErrorBoundary||m.route.errorElement||v===0)?fe.createElement(ep,{location:r.location,revalidation:r.revalidation,component:g,error:S,children:R(),routeContext:{outlet:null,matches:D,isDataRoute:!0},onError:f}):R()},null)}function _o(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function t1(t){let a=fe.useContext(kn);return Ct(a,_o(t)),a}function a1(t){let a=fe.useContext(Wr);return Ct(a,_o(t)),a}function n1(t){let a=fe.useContext(xa);return Ct(a,_o(t)),a}function Ao(t){let a=n1(t),n=a.matches[a.matches.length-1];return Ct(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function s1(){return Ao("useRouteId")}function r1(){let t=fe.useContext(Co),a=a1("useRouteError"),n=Ao("useRouteError");return t!==void 0?t:a.errors?.[n]}function i1(){let{router:t}=t1("useNavigate"),a=Ao("useNavigate"),n=fe.useRef(!1);return Zu(()=>{n.current=!0}),fe.useCallback(async(o,l={})=>{ga(n.current,Xu),n.current&&(typeof o=="number"?await t.navigate(o):await t.navigate(o,{fromRouteId:a,...l}))},[t,a])}var ic={};function tp(t,a,n){!a&&!ic[t]&&(ic[t]=!0,ga(!1,n))}fe.memo(o1);function o1({routes:t,future:a,state:n,isStatic:r,onError:o}){return G0(t,void 0,{state:n,isStatic:r,onError:o})}var fr="get",gr="application/x-www-form-urlencoded";function Hr(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function l1(t){return Hr(t)&&t.tagName.toLowerCase()==="button"}function d1(t){return Hr(t)&&t.tagName.toLowerCase()==="form"}function c1(t){return Hr(t)&&t.tagName.toLowerCase()==="input"}function u1(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function p1(t,a){return t.button===0&&(!a||a==="_self")&&!u1(t)}var Gs=null;function m1(){if(Gs===null)try{new FormData(document.createElement("form"),0),Gs=!1}catch{Gs=!0}return Gs}var h1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Fi(t){return t!=null&&!h1.has(t)?(ga(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${gr}"`),null):t}function f1(t,a){let n,r,o,l,d;if(d1(t)){let c=t.getAttribute("action");r=c?Ia(c,a):null,n=t.getAttribute("method")||fr,o=Fi(t.getAttribute("enctype"))||gr,l=new FormData(t)}else if(l1(t)||c1(t)&&(t.type==="submit"||t.type==="image")){let c=t.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=t.getAttribute("formaction")||c.getAttribute("action");if(r=h?Ia(h,a):null,n=t.getAttribute("formmethod")||c.getAttribute("method")||fr,o=Fi(t.getAttribute("formenctype"))||Fi(c.getAttribute("enctype"))||gr,l=new FormData(c,t),!m1()){let{name:f,type:p,value:m}=t;if(p==="image"){let v=f?`${f}.`:"";l.append(`${v}x`,"0"),l.append(`${v}y`,"0")}else f&&l.append(f,m)}}else{if(Hr(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=fr,r=null,o=gr,d=t}return l&&o==="text/plain"&&(d=l,l=void 0),{action:r,method:n.toLowerCase(),encType:o,formData:l,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function To(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function ap(t,a,n,r){let o=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${r}`:o.pathname=`${o.pathname}.${r}`:o.pathname==="/"?o.pathname=`_root.${r}`:a&&Ia(o.pathname,a)==="/"?o.pathname=`${Sr(a)}/_root.${r}`:o.pathname=`${Sr(o.pathname)}.${r}`,o}async function g1(t,a){if(t.id in a)return a[t.id];try{let n=await import(t.module);return a[t.id]=n,n}catch(n){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function y1(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function x1(t,a,n){let r=await Promise.all(t.map(async o=>{let l=a.routes[o.route.id];if(l){let d=await g1(l,n);return d.links?d.links():[]}return[]}));return w1(r.flat(1).filter(y1).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function oc(t,a,n,r,o,l){let d=(h,f)=>n[f]?h.route.id!==n[f].route.id:!0,c=(h,f)=>n[f].pathname!==h.pathname||n[f].route.path?.endsWith("*")&&n[f].params["*"]!==h.params["*"];return l==="assets"?a.filter((h,f)=>d(h,f)||c(h,f)):l==="data"?a.filter((h,f)=>{let p=r.routes[h.route.id];if(!p||!p.hasLoader)return!1;if(d(h,f)||c(h,f))return!0;if(h.route.shouldRevalidate){let m=h.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:h.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function b1(t,a,{includeHydrateFallback:n}={}){return j1(t.map(r=>{let o=a.routes[r.route.id];if(!o)return[];let l=[o.module];return o.clientActionModule&&(l=l.concat(o.clientActionModule)),o.clientLoaderModule&&(l=l.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(l=l.concat(o.hydrateFallbackModule)),o.imports&&(l=l.concat(o.imports)),l}).flat(1))}function j1(t){return[...new Set(t)]}function S1(t){let a={},n=Object.keys(t).sort();for(let r of n)a[r]=t[r];return a}function w1(t,a){let n=new Set;return new Set(a),t.reduce((r,o)=>{let l=JSON.stringify(S1(o));return n.has(l)||(n.add(l),r.push({key:l,link:o})),r},[])}function Do(){let t=fe.useContext(kn);return To(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function v1(){let t=fe.useContext(Wr);return To(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var ko=fe.createContext(void 0);ko.displayName="FrameworkContext";function Ro(){let t=fe.useContext(ko);return To(t,"You must render this element inside a <HydratedRouter> element"),t}function C1(t,a){let n=fe.useContext(ko),[r,o]=fe.useState(!1),[l,d]=fe.useState(!1),{onFocus:c,onBlur:h,onMouseEnter:f,onMouseLeave:p,onTouchStart:m}=a,v=fe.useRef(null);fe.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let g=D=>{D.forEach(R=>{d(R.isIntersecting)})},b=new IntersectionObserver(g,{threshold:.5});return v.current&&b.observe(v.current),()=>{b.disconnect()}}},[t]),fe.useEffect(()=>{if(r){let g=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(g)}}},[r]);let S=()=>{o(!0)},y=()=>{o(!1),d(!1)};return n?t!=="intent"?[l,v,{}]:[l,v,{onFocus:Xn(c,S),onBlur:Xn(h,y),onMouseEnter:Xn(f,S),onMouseLeave:Xn(p,y),onTouchStart:Xn(m,S)}]:[!1,v,{}]}function Xn(t,a){return n=>{t&&t(n),n.defaultPrevented||a(n)}}function _1({page:t,...a}){let n=U0(),{router:r}=Do(),o=fe.useMemo(()=>Nu(r.routes,t,r.basename),[r.routes,t,r.basename]);return o?n?fe.createElement(T1,{page:t,matches:o,...a}):fe.createElement(D1,{page:t,matches:o,...a}):null}function A1(t){let{manifest:a,routeModules:n}=Ro(),[r,o]=fe.useState([]);return fe.useEffect(()=>{let l=!1;return x1(t,a,n).then(d=>{l||o(d)}),()=>{l=!0}},[t,a,n]),r}function T1({page:t,matches:a,...n}){let r=ba(),{future:o}=Ro(),{basename:l}=Do(),d=fe.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let c=ap(t,l,o.unstable_trailingSlashAwareDataRequests,"rsc"),h=!1,f=[];for(let p of a)typeof p.route.shouldRevalidate=="function"?h=!0:f.push(p.route.id);return h&&f.length>0&&c.searchParams.set("_routes",f.join(",")),[c.pathname+c.search]},[l,o.unstable_trailingSlashAwareDataRequests,t,r,a]);return fe.createElement(fe.Fragment,null,d.map(c=>fe.createElement("link",{key:c,rel:"prefetch",as:"fetch",href:c,...n})))}function D1({page:t,matches:a,...n}){let r=ba(),{future:o,manifest:l,routeModules:d}=Ro(),{basename:c}=Do(),{loaderData:h,matches:f}=v1(),p=fe.useMemo(()=>oc(t,a,f,l,r,"data"),[t,a,f,l,r]),m=fe.useMemo(()=>oc(t,a,f,l,r,"assets"),[t,a,f,l,r]),v=fe.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let g=new Set,b=!1;if(a.forEach(R=>{let I=l.routes[R.route.id];!I||!I.hasLoader||(!p.some(A=>A.route.id===R.route.id)&&R.route.id in h&&d[R.route.id]?.shouldRevalidate||I.hasClientLoader?b=!0:g.add(R.route.id))}),g.size===0)return[];let D=ap(t,c,o.unstable_trailingSlashAwareDataRequests,"data");return b&&g.size>0&&D.searchParams.set("_routes",a.filter(R=>g.has(R.route.id)).map(R=>R.route.id).join(",")),[D.pathname+D.search]},[c,o.unstable_trailingSlashAwareDataRequests,h,r,l,p,a,t,d]),S=fe.useMemo(()=>b1(m,l),[m,l]),y=A1(m);return fe.createElement(fe.Fragment,null,v.map(g=>fe.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...n})),S.map(g=>fe.createElement("link",{key:g,rel:"modulepreload",href:g,...n})),y.map(({key:g,link:b})=>fe.createElement("link",{key:g,nonce:n.nonce,...b,crossOrigin:b.crossOrigin??n.crossOrigin})))}function k1(...t){return a=>{t.forEach(n=>{typeof n=="function"?n(a):n!=null&&(n.current=a)})}}var R1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{R1&&(window.__reactRouterVersion="7.14.2")}catch{}var np=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,sp=fe.forwardRef(function({onClick:a,discover:n="render",prefetch:r="none",relative:o,reloadDocument:l,replace:d,unstable_mask:c,state:h,target:f,to:p,preventScrollReset:m,viewTransition:v,unstable_defaultShouldRevalidate:S,...y},g){let{basename:b,navigator:D,unstable_useTransitions:R}=fe.useContext(aa),I=typeof p=="string"&&np.test(p),A=Hu(p,b);p=A.to;let _=H0(p,{relative:o}),u=ba(),x=null;if(c){let E=wo(c,[],u.unstable_mask?u.unstable_mask.pathname:"/",!0);b!=="/"&&(E.pathname=E.pathname==="/"?b:Xt([b,E.pathname])),x=D.createHref(E)}let[j,P,O]=C1(r,y),z=E1(p,{replace:d,unstable_mask:c,state:h,target:f,preventScrollReset:m,relative:o,viewTransition:v,unstable_defaultShouldRevalidate:S,unstable_useTransitions:R});function k(E){a&&a(E),E.defaultPrevented||z(E)}let F=!(A.isExternal||l),C=fe.createElement("a",{...y,...O,href:(F?x:void 0)||A.absoluteURL||_,onClick:F?k:a,ref:k1(g,P),target:f,"data-discover":!I&&n==="render"?"true":void 0});return j&&!I?fe.createElement(fe.Fragment,null,C,fe.createElement(_1,{page:_})):C});sp.displayName="Link";var I1=fe.forwardRef(function({"aria-current":a="page",caseSensitive:n=!1,className:r="",end:o=!1,style:l,to:d,viewTransition:c,children:h,...f},p){let m=ws(d,{relative:f.relative}),v=ba(),S=fe.useContext(Wr),{navigator:y,basename:g}=fe.useContext(aa),b=S!=null&&L1(m)&&c===!0,D=y.encodeLocation?y.encodeLocation(m).pathname:m.pathname,R=v.pathname,I=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;n||(R=R.toLowerCase(),I=I?I.toLowerCase():null,D=D.toLowerCase()),I&&g&&(I=Ia(I,g)||I);const A=D!=="/"&&D.endsWith("/")?D.length-1:D.length;let _=R===D||!o&&R.startsWith(D)&&R.charAt(A)==="/",u=I!=null&&(I===D||!o&&I.startsWith(D)&&I.charAt(D.length)==="/"),x={isActive:_,isPending:u,isTransitioning:b},j=_?a:void 0,P;typeof r=="function"?P=r(x):P=[r,_?"active":null,u?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let O=typeof l=="function"?l(x):l;return fe.createElement(sp,{...f,"aria-current":j,className:P,ref:p,style:O,to:d,viewTransition:c},typeof h=="function"?h(x):h)});I1.displayName="NavLink";var P1=fe.forwardRef(({discover:t="render",fetcherKey:a,navigate:n,reloadDocument:r,replace:o,state:l,method:d=fr,action:c,onSubmit:h,relative:f,preventScrollReset:p,viewTransition:m,unstable_defaultShouldRevalidate:v,...S},y)=>{let{unstable_useTransitions:g}=fe.useContext(aa),b=F1(),D=B1(c,{relative:f}),R=d.toLowerCase()==="get"?"get":"post",I=typeof c=="string"&&np.test(c),A=_=>{if(h&&h(_),_.defaultPrevented)return;_.preventDefault();let u=_.nativeEvent.submitter,x=u?.getAttribute("formmethod")||d,j=()=>b(u||_.currentTarget,{fetcherKey:a,method:x,navigate:n,replace:o,state:l,relative:f,preventScrollReset:p,viewTransition:m,unstable_defaultShouldRevalidate:v});g&&n!==!1?fe.startTransition(()=>j()):j()};return fe.createElement("form",{ref:y,method:R,action:D,onSubmit:r?h:A,...S,"data-discover":!I&&t==="render"?"true":void 0})});P1.displayName="Form";function M1(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function rp(t){let a=fe.useContext(kn);return Ct(a,M1(t)),a}function E1(t,{target:a,replace:n,unstable_mask:r,state:o,preventScrollReset:l,relative:d,viewTransition:c,unstable_defaultShouldRevalidate:h,unstable_useTransitions:f}={}){let p=Ss(),m=ba(),v=ws(t,{relative:d});return fe.useCallback(S=>{if(p1(S,a)){S.preventDefault();let y=n!==void 0?n:Zi(m)===Zi(v),g=()=>p(t,{replace:y,unstable_mask:r,state:o,preventScrollReset:l,relative:d,viewTransition:c,unstable_defaultShouldRevalidate:h});f?fe.startTransition(()=>g()):g()}},[m,p,v,n,r,o,a,t,l,d,c,h,f])}var O1=0,$1=()=>`__${String(++O1)}__`;function F1(){let{router:t}=rp("useSubmit"),{basename:a}=fe.useContext(aa),n=s1(),r=t.fetch,o=t.navigate;return fe.useCallback(async(l,d={})=>{let{action:c,method:h,encType:f,formData:p,body:m}=f1(l,a);if(d.navigate===!1){let v=d.fetcherKey||$1();await r(v,n,d.action||c,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:p,body:m,formMethod:d.method||h,formEncType:d.encType||f,flushSync:d.flushSync})}else await o(d.action||c,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:p,body:m,formMethod:d.method||h,formEncType:d.encType||f,replace:d.replace,state:d.state,fromRouteId:n,flushSync:d.flushSync,viewTransition:d.viewTransition})},[r,o,a,n])}function B1(t,{relative:a}={}){let{basename:n}=fe.useContext(aa),r=fe.useContext(xa);Ct(r,"useFormAction must be used inside a RouteContext");let[o]=r.matches.slice(-1),l={...ws(t||".",{relative:a})},d=ba();if(t==null){l.search=d.search;let c=new URLSearchParams(l.search),h=c.getAll("index");if(h.some(p=>p==="")){c.delete("index"),h.filter(m=>m).forEach(m=>c.append("index",m));let p=c.toString();l.search=p?`?${p}`:""}}return(!t||t===".")&&o.route.index&&(l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(l.pathname=l.pathname==="/"?n:Xt([n,l.pathname])),Zi(l)}function L1(t,{relative:a}={}){let n=fe.useContext(Ju);Ct(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=rp("useViewTransitionState"),o=ws(t,{relative:a});if(!n.isTransitioning)return!1;let l=Ia(n.currentLocation.pathname,r)||n.currentLocation.pathname,d=Ia(n.nextLocation.pathname,r)||n.nextLocation.pathname;return jr(o.pathname,d)!=null||jr(o.pathname,l)!=null}const Io=t=>t??localStorage.getItem("authToken")??"",We={examType:{dropdown:"/exam/exam/getExamTypeDropdown",table:"/exam/exam/getExamtypeTable",add:"/exam/exam/addExamType",edit:"/exam/exam/editExamtype",remove:"/exam/exam/deleteExamType"},examSchedule:{add:"/exam/exam/addExamSchedule",edit:"/exam/exam/editExamSchedule",getById:"/exam/exam/getExamData",list:"/exam/exam/examlist",dropdown:"/exam/exam/examdropdown",groupDropdown:"/exam/exam/examGroupdropdown",groupList:"/exam/exam/getExamGrouplist",addGroup:"/exam/exam/addExamgroup",slUpdate:"/exam/exam/examSlUpdate",subjectGroup:"/exam/exam/examSubjectGroup",mainAdditional:"/exam/exam/examisMainadditional"},examInstruction:{dropdown:"/exam/exam/examdropdownInstraction",get:"/exam/exam/getExamInstraction",update:"/exam/exam/updateExamInstraction"},examSetting:{table:"/exam/exam/getExamSettingTable",add:"/exam/exam/addExamSetting",uploadSignature:"/exam/exam/upload_signature",typeByExamId:"/exam/exam/getExamTypeBYExamId",assignMarksheetClass:"/exam/exam/assign_marksheetClass"},assessment:{table:"/exam/assesment/getAssesmentTable",dropdown:"/exam/assesment/assesmentDropdown",delete:"/exam/assesment/deleteAssesment",getById:"/exam/assesment/getAssesmentDatabyID",dropdownSelect:"/exam/assesment/getAssesmentDropDown"},studentResult:{marklistUrl:"/exam/mark/getstudentMarklistNew",marklistBulkUrl:"/exam/mark/getstudentMarklistBulk",getSubjectsAccordingToExam:"/exam/mark/getSubjectsaccordingtoExam",getExamSubject:"/exam/mark/getExamSubject",marksheetDetailNew:"/exam/mark/getmarkssheetDetailsNew",templeteDetails:"/exam/Exam/templeteDetails",studentExamRemarks:"/exam/exam/studentExamRemarks",getStudentListForExam:"/exam/exam/getstudentlistforExam",getStudentListForCoscholastic:"/exam/exam/getstudentlistforCoscholastic",addExamMarks:"/exam/exam/addexamMarks",getGradeTable:"/exam/exam/getgradeTable",getGradeTableCoScholastic:"/exam/exam/getgradeTableCoScholastic",getAdmitCard:"/exam/exam/getAdmitCard"},admitCardSetting:{get:"/api/exam/exam/getAdmitCardSettings",update:"/api/exam/exam/updateAdmitCardSettings"},roomManagement:{list:"/api/exam/exam/removeClassRoom",remove:"/api/exam/exam/remove_exam_class_room",assign:"/api/exam/exam/assignClassRoom",add:"/api/exam/exam/addClassRoom",roomDropdown:"/api/exam/exam/roomDropdown"},examDropdown:"/api/exam/exam/examdropdown",examDropdownInstruction:"/api/exam/exam/examdropdownInstraction",observation:{dropdown:"/api/exam/Observation/getObservationTypeDropdown",delete:"/api/exam/Observation/deleteObservation",deleteType:"/api/exam/Observation/deleteObservationType",editType:"/api/exam/Observation/editObservationType",addType:"/api/exam/Observation/addObservationType",add:"/api/exam/Observation/addObservation"},coscholasticCategoryDropdown:"/branchapi/academy/getscholasticCategoryByClassId",templateType:{get:"/branchapi/GeneralSettings/getmarkssheetTemplate",assignClassDropdown:"/api/exam/exam/getClassforAssignMarksSheetType",assignTable:"/branchapi/GeneralSettings/getassign_templete",assign:"/branchapi/GeneralSettings/assign_templete",remove:"/branchapi/GeneralSettings/deleteTemplate"},classSubjectDropdown:"/api/exam/exam/getClassSubjectWithmarksheetTemplete",sectionDropdown:"/api/exam/exam/getSectionDropdown",getStudentListForExam:"/api/exam/exam/getstudentlistforExam",getStudentListForCoscholastic:"/api/exam/exam/getstudentlistforCoscholastic",marksheetTemplate:"/api/exam/Exam/templeteDetails",assignMarksheetClass:"/branchapi/GeneralSettings/getClassforAssignMarksSheetType",examDropdownUrl:"/api/exam/exam/examdropdown",classSubjectDropdownUrl:"/api/exam/exam/getClassSubjectWithmarksheetTemplete",studentMarklist:"/api/exam/mark/getstudentMarklistNew",studentMarklistBulk:"/api/exam/mark/getstudentMarklistBulk"},Bi=async(t,a,n)=>Ta(t,{arg:a},Io(n)),Kr=async(t,a,n)=>hs(t,{arg:a},Io(n)),ip=async(t,a,n)=>gn(t,{arg:a},Io(n)),U1=t=>{let a=0;return t.forEach(n=>{n.is_theory==="yes"&&n.is_practical==="yes"&&(n.theory_marks&&parseFloat(n.theory_marks)!==0&&(a+=.5),n.practical_marks&&parseFloat(n.practical_marks)!==0&&(a+=.5)),n.is_theory==="yes"&&n.is_practical==="no"&&n.theory_marks&&parseFloat(n.theory_marks)!==0&&(a+=1),n.is_theory==="no"&&n.is_practical==="yes"&&n.practical_marks&&parseFloat(n.practical_marks)!==0&&(a+=1)}),parseFloat(a/t.length*100).toFixed(2)};function N1({token:t}){Ss();const[a,n]=i.useState(!1),[r,o]=i.useState(null),[l,d]=i.useState(1),[c,h]=i.useState(!1),[f,p]=i.useState(!1),[m,v]=i.useState({pagination:{current:1,pageSize:2}}),[S,y]=i.useState(null),[g,b]=i.useState(!1),[D,R]=i.useState(null),[I,A]=i.useState([]),[_,u]=i.useState(!1),[x,j]=i.useState({current:0,total:1}),[P,O]=i.useState(""),[z,k]=i.useState(!1),[F,C]=i.useState(null),[E,M]=i.useState(!1),[U,Y]=i.useState(!1),{isLoading:V,data:L}=q(t!=null?[oa,t]:null,([Re,xe])=>W(Re,xe)),[B,$]=i.useState({exam_id:""}),{isLoading:N,errorExam:H,data:Q}=q(r,W),{TextArea:X}=s.Input,{isLoading:J,error:K,data:Z,mutate:ee}=q(S!=null?`${S}&page=${m.pagination.current}&per_page=${m.pagination.pageSize}`:null,W,{onSuccess:Re=>{const xe=Array.isArray(Re?.data)?Re.data:[];A(xe)}}),{data:pe}=q("/branchapi/GeneralSettings/getassign_templete",W),te=(Re,xe)=>{if(xe==="class_id"){n(`${la}?class_id=${Re.value}`),o(`${We.examSchedule.dropdown}?class_id=${Re.value}`),h(Ue=>!Ue),b(Ue=>!Ue);const De=pe?.data?.find(Ue=>Ue.class_id===Re.value);d(De?.ui_id||1)}},{isLoading:se,data:le}=q(a,W),Ce=async Re=>{Re.preventDefault(),y(`${We.studentResult.marklistUrl}?class_id=${Re.target.class_id.value}§ion_id=${Re.target.section_id.value}&exam_id=${Re.target.exam_id.value}`),d(Re.target.template.value),O(Re.target.exam_id.value),$(xe=>({...xe,exam_id:Re.target.exam_id.value})),E||M(!0),Re.target.reset()};i.useRef(null),Math.round(x.current/x.total*100);const Le=Re=>{C(Re),k(!0)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Student Result"})}),e.jsx(w,{p:3,children:e.jsxs(s.Grid,{container:!0,spacing:3,children:[e.jsx(s.Grid,{item:!0,xs:12,children:e.jsx("form",{onSubmit:Ce,children:e.jsxs(s.Grid,{container:!0,spacing:3,children:[e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(w,{children:e.jsx(ae,{required:!0,options:Array.isArray(L)?L:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",onChange:Re=>{te(Re,"class_id")},allowSelectAll:!1})})}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(ae,{options:Array.isArray(le)?le:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1},`section1${c}`)}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(ae,{options:Array.isArray(Q)?Q:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Exam",name:"exam_id",onChange:Re=>{te(Re,"exam_id"),O(Re.value),Y(!1),$(xe=>({...xe,exam_id:Re.value}))},allowSelectAll:!1},`exam1${g}`)}),e.jsx(s.Grid,{item:!0,xs:12,md:1.5,children:e.jsx(s.Grid,{container:!0,justifyContent:"flex-end",children:e.jsx(s.Grid,{item:!0,children:e.jsx(w,{children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})})})})]})})}),E&&e.jsx(s.Grid,{item:!0,xs:12,style:{marginTop:16},children:e.jsx(s.Table,{size:"small",bordered:!0,columns:[{title:"SL",dataIndex:"Sl_no",align:"center"},{title:"Student Name",dataIndex:"firstname",align:"center"},{title:"Roll No",dataIndex:"roll_no",align:"center"},{title:"Full Marks",dataIndex:"full_marks",align:"center"},{title:"Marks Obtained",dataIndex:"marks_obtained",align:"center"},{title:"Percentage",dataIndex:"percentage",align:"center",render:(Re,xe)=>xe?.marks_obtained?`${xe.percentage||U1(xe.marks_obtained)}%`:Re},{title:"Attendance",dataIndex:"attendance",align:"center"},{title:"Action",key:"action",align:"center",render:(Re,xe)=>e.jsx(s.Space,{size:"middle",children:e.jsx(s.Button,{type:"text",icon:e.jsx(re.EyeOutlined,{}),size:"small",onClick:()=>Le(xe)})})}],rowKey:"id",dataSource:I,pagination:{current:m.pagination.current,pageSize:m.pagination.pageSize,total:Z?.pagination?.total_rows??I.length,showSizeChanger:!0,onChange:(Re,xe)=>{v(De=>({...De,pagination:{current:Re,pageSize:xe}}))},onShowSizeChange:(Re,xe)=>{v(De=>({...De,pagination:{current:1,pageSize:xe}}))},showTotal:(Re,xe)=>`${xe[0]}-${xe[1]} of ${Re} items`},loading:J})})]})})]}),e.jsx(s.Modal,{title:"Student Result Detail",open:z,onCancel:()=>k(!1),footer:null,width:800,destroyOnClose:!0,children:F&&e.jsxs("div",{children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Name:"})," ",F.firstname]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Roll No:"})," ",F.roll_no]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Class:"})," ",F.class]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Section:"})," ",F.section]})]})})]})}function z1({token:t}){return e.jsx(N1,{token:t})}const q1=t=>t?.is_theory==="yes"&&t?.is_practical==="yes",Y1=t=>t?.is_theory==="yes"?"Theory":t?.is_practical==="yes"?"Practical":"",W1=t=>(Array.isArray(t)?t:[]).map(a=>({subject_id:a.subject_id,subject_name:a.subject_name,is_theory:a.is_theory,is_practical:a.is_practical,isBoth:q1(a),start_time:ne().format("HH:mm"),end_time:ne().format("HH:mm"),date:ne().format("YYYY-MM-DD"),full_marks:"",weightage:""})),V1=["h:mm a","h:mm A","HH:mm","HH:mm:ss"],lc=t=>{if(!t)return null;const a=ne(t,V1,!0);return a.isValid()?a:null},H1=t=>{const a=new Map,n=/^schedule\[(\d+)\]\[(theory|practical)\]\[(\w+)\]$/;for(const[r,o]of t.entries()){const l=r.match(n);if(!l)continue;const[,d,c,h]=l,f=`${d}-${c}`;a.has(f)||a.set(f,{index:d,type:c}),a.get(f)[h]=o}return Array.from(a.values())};function K1({token:t}){const a=i.useRef(),n=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))||{}}catch{return{}}},[]),[r,o]=i.useState(ne().format("YYYY-MM-DD")),[l,d]=i.useState(ne().format("YYYY-MM-DD")),[c,h]=i.useState(""),[f,p]=i.useState(!0),[m,v]=i.useState(!1),[S,y]=i.useState(""),[g,b]=i.useState([]),[D,R]=i.useState([]),[I,A]=i.useState(!1),[_,u]=i.useState([]),[x,j]=i.useState([]),[P,O]=i.useState(""),[z,k]=i.useState(!1),{data:F}=q(t!=null?[We.examType.dropdown,t]:null,([ee,pe])=>W(ee,pe)),{isLoading:C,error:E,data:M}=q(t!=null&&n?[`${We.examSetting.assignMarksheetClass}?branch_id=${n?.fk_branchID}`,t]:null,([ee,pe])=>W(ee,pe),{onSuccess:ee=>{const pe=Array.isArray(ee?.data)?ee.data:[];b(pe);const te=pe.map(se=>({value:se.id,label:se.class}));R(te)},onError:()=>{b([]),R([])}}),{isLoading:U,data:Y}=q(m,W),{trigger:V}=it(We.examSchedule.add,(ee,{arg:pe})=>ip(ee,pe,t)),[L,B]=i.useState({class_id:"",exam_name:"",session_id:"",start_date:ne().format("YYYY-MM-DD"),end_date:ne().format("YYYY-MM-DD"),schedule:[]}),$=()=>!(a?.current?.exam_name?.value&&a?.current?.start_date?.value&&a?.current?.end_date?.value&&a?.current?.class_id?.value),N=ee=>{const pe=H1(ee);if(pe.length===0)return"No subjects configured for this class. Select a class with subjects before saving.";for(const te of pe){const se=x.find(Re=>String(Re.subject_id)===String(te.subject_id))?.subject_name||`Row ${Number(te.index)+1}`;if(!te.date)return`Please select an exam date for ${se}.`;if(te.date<r||te.date>l)return`Exam date for ${se} must be between the exam start and end dates.`;if(!te.start_time||!te.end_time)return`Please enter start and end time for ${se}.`;const le=lc(te.start_time),Ce=lc(te.end_time);if(le&&Ce&&!le.isBefore(Ce))return`End time must be after start time for ${se}.`;const Le=Number(te.full_marks);if(te.full_marks===void 0||te.full_marks===""||Number.isNaN(Le)||Le<=0)return`Full marks must be greater than 0 for ${se}.`;if(te.weightage!==void 0&&te.weightage!==""){const Re=Number(te.weightage);if(Number.isNaN(Re)||Re<0)return`Weightage cannot be negative for ${se}.`}}return null},H=()=>{u([]),j([])},Q=async ee=>{if(ee.preventDefault(),!ee.target.start_date.value){alert("Select required dates");return}if(!ee.target.end_date.value){alert("Select required dates");return}if(ee.target.end_date.value<ee.target.start_date.value){alert("End date cannot be earlier than start date.");return}const pe=new FormData(ee.target);pe.append("session_id",n.session_id),pe.append("exam_type_id",ee.target.exam_type.value);const te=N(pe);if(te){alert(te);return}try{const se=await V(pe);se?.Status==="Success"?(B({class_id:"",exam_name:"",session_id:"",start_date:ne().format("YYYY-MM-DD"),end_date:ne().format("YYYY-MM-DD"),schedule:[]}),O(""),H(),alert("Exam Successfully Created!")):alert(se?.message||"Failed to create exam")}catch(se){alert(se?.message||"Failed to create exam")}ee.target.reset()},X=(ee,pe)=>{k(ee?.value!=="Annual")},J=()=>{P&&u(W1(x))};function K(ee){if(_.length===1)return;const pe=[..._];pe.splice(ee,1),u(pe)}const Z=()=>{p($())};return e.jsx(w,{pt:5,pb:1,children:e.jsx(s.Grid,{container:!0,spacing:4,children:e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Add Exam"})}),e.jsx(w,{p:3,children:e.jsxs("form",{onChange:Z,ref:a,onSubmit:Q,children:[e.jsxs(s.Grid,{container:!0,spacing:2,children:[e.jsx(s.Grid,{item:!0,xs:12,md:2.5,children:e.jsx(w,{children:e.jsx(G,{type:"text",label:"Exam Name *",name:"exam_name",required:"required"})})}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(ae,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Exam Type *",name:"exam_type",required:!0,onChange:ee=>X(ee),allowSelectAll:!1})}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(Ge,{defaultValue:ne(),label:"Start Date *",name:"start_date",format:"YYYY-MM-DD",style:{display:"block"},status:c===""?"":"error",setDate:o,onChange:ee=>{h(""),o(ne(ee).format("YYYY-MM-DD"))}})}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(Ge,{defaultValue:ne(),label:"End Date *",name:"end_date",format:"YYYY-MM-DD",style:{display:"block"},status:S===""?"":"error",setDate:d,onChange:ee=>{y(""),d(ne(ee).format("YYYY-MM-DD"))}})}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,style:{display:"none"},children:e.jsx(ae,{mode:"multiple",isMulti:!0,options:Array.isArray(Y)?Y:[],value:Y||[],closeMenuOnSelect:!0,label:"Section",name:"section_id[]",allowSelectAll:!1},`section1${I}`)}),e.jsx(s.Grid,{item:!0,xs:12,md:2.5,children:e.jsx(w,{children:e.jsx(G,{type:"text",label:"Promoted To",name:"promoted_to"})})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.5,children:e.jsx(s.Grid,{container:!0,justifyContent:"flex-end",children:e.jsx(s.Grid,{item:!0,children:e.jsx(w,{children:e.jsx(s.Button,{size:"small",onClick:J,type:"primary",disabled:f||C||x.length===0,children:"Add Subjects"})})})})})]}),e.jsx(s.Grid,{container:!0,spacing:3,style:{marginTop:8},children:e.jsx(s.Grid,{item:!0,xs:12,style:{overflowX:"auto"},children:P&&x.length===0?e.jsx(s.Typography.Text,{children:"No subjects configured for this class."}):_.length>0?e.jsxs("table",{className:"table borderless",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Subject"}),e.jsx("th",{style:{width:"80px",textAlign:"center"},children:"Type"}),e.jsx("th",{children:"Date *"}),e.jsx("th",{children:"Start Time *"}),e.jsx("th",{children:"End Time *"}),e.jsx("th",{children:"Full Marks *"}),e.jsx("th",{children:"Weightage"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:_.map((ee,pe)=>e.jsxs(i.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{minWidth:"150px"},rowSpan:ee.isBoth?2:1,children:ee.subject_name}),e.jsx("td",{style:{textAlign:"center"},children:ee.isBoth?"Theory":Y1(ee)}),e.jsx("td",{children:e.jsx(Ge,{format:"YYYY-MM-DD",label:"",defaultValue:ne(r),minDate:ne(r),maxDate:ne(l),name:`schedule[${pe}][theory][date]`})}),e.jsx("td",{children:e.jsx(s.TimePicker,{format:"h:mm a",defaultValue:ne(),name:`schedule[${pe}][theory][start_time]`})}),e.jsx("td",{children:e.jsx(s.TimePicker,{format:"h:mm a",defaultValue:ne(),name:`schedule[${pe}][theory][end_time]`})}),e.jsx("td",{children:e.jsx(G,{type:"number",min:"1",label:"",name:`schedule[${pe}][theory][full_marks]`,required:"required"})}),e.jsx("td",{children:e.jsx(G,{type:"number",min:"0",label:"",name:`schedule[${pe}][theory][weightage]`})}),e.jsxs("td",{children:[e.jsx("input",{type:"hidden",name:`schedule[${pe}][theory][subject_id]`,value:ee.subject_id||""}),_.length>1&&e.jsx(s.Button,{type:"text",icon:e.jsx(re.CloseCircleOutlined,{style:{color:"red"}}),size:"small",onClick:()=>K(pe)})]})]}),ee.isBoth&&e.jsxs("tr",{children:[e.jsx("td",{style:{textAlign:"center"},children:"Practical"}),e.jsx("td",{children:e.jsx(Ge,{format:"YYYY-MM-DD",label:"",defaultValue:ne(r),minDate:ne(r),maxDate:ne(l),name:`schedule[${pe}][practical][date]`})}),e.jsx("td",{children:e.jsx(s.TimePicker,{format:"h:mm a",defaultValue:ne(),name:`schedule[${pe}][practical][start_time]`})}),e.jsx("td",{children:e.jsx(s.TimePicker,{format:"h:mm a",defaultValue:ne(),name:`schedule[${pe}][practical][end_time]`})}),e.jsx("td",{children:e.jsx(G,{type:"number",min:"1",label:"",name:`schedule[${pe}][practical][full_marks]`,required:"required"})}),e.jsx("td",{children:e.jsx(G,{type:"number",min:"0",label:"",name:`schedule[${pe}][practical][weightage]`})}),e.jsxs("td",{children:[e.jsx("input",{type:"hidden",name:`schedule[${pe}][practical][subject_id]`,value:ee.subject_id||""}),_.length>1&&e.jsx("span",{style:{opacity:0},children:"-"})]})]})]},ee.subject_id+"-"+pe+"frg"))})]}):e.jsx(s.Typography.Text,{children:"Select a class to load its subjects."})})}),e.jsx(s.Grid,{container:!0,justifyContent:"flex-end",style:{marginTop:16},children:e.jsx(s.Grid,{item:!0,children:e.jsx(de,{disabled:_.length===0,type:"submit",value:"Save",color:"primary"})})})]})})]})})})})}function G1({token:t}){return e.jsx(K1,{token:t})}function J1({token:t}){const a=Ss(),[n,r]=i.useState({page:0,rowsPerPage:1e3}),[o,l]=i.useState(""),[d,c]=i.useState(""),[h,f]=i.useState({}),[p,m]=i.useState({}),[v,S]=i.useState({}),[y,g]=i.useState({}),b=Q=>{if(typeof Q=="boolean")return Q;if(Q===1||Q==="1")return!0;if(Q===0||Q==="0"||Q==null)return!1;const X=String(Q).trim().toLowerCase();return X==="true"||X==="yes"},{isLoading:D,data:R,mutate:I}=q(t?[`${We.examSchedule.list}?page=${n.page+1}&per_page=${n.rowsPerPage}`,t]:null,([Q,X])=>W(Q,X)),{trigger:A,isMutating:_}=it(We.examSchedule.slUpdate,(Q,{arg:X})=>Bi(Q,X,t)),{trigger:u,isMutating:x}=it(We.examSchedule.subjectGroup,(Q,{arg:X})=>Bi(Q,X,t)),{trigger:j,isMutating:P}=it(We.examSchedule.mainAdditional,(Q,{arg:X})=>Bi(Q,X,t)),O=async(Q,X,J)=>{const K=J?"True":"False";S(Z=>({...Z,[Q]:J})),g(Z=>({...Z,[Q]:!0}));try{await j({id:Q,main_additional:K}),await I(),S(Z=>{const ee={...Z};return delete ee[Q],ee})}catch{S(ee=>({...ee,[Q]:X}))}finally{g(Z=>({...Z,[Q]:!1}))}},z=async Q=>{try{await A({slno:h.sl_no,id:Q}),l(""),f({}),await I()}catch{}},k=async Q=>{try{await u({group_id:p.group_id,id:Q}),c(""),m({}),await I()}catch{}},F=(Q,X)=>{f(J=>({...J,[X]:Q}))},C=(Q,X)=>{m(J=>({...J,[X]:Q}))},E=Q=>Q.id===o,M=Q=>Q.id===d,U=Q=>{l(Q.id),f({...Q})},Y=Q=>{c(Q.id),m({...Q})},V=()=>{l(""),f({})},L=()=>{c(""),m({})},B=Q=>{a(`/Exam/ExamEdit?id=${Q}`)},$=async Q=>{try{await I(st(We.examSchedule.list,Q),ot(Q))}catch{}},N=i.useMemo(()=>[{title:"Exam Name",dataIndex:"name",align:"center"},{title:"Exam Type",dataIndex:"exam_type",align:"center"},{title:"Start Date",dataIndex:"start_date",align:"center",render:(Q,X)=>e.jsx(e.Fragment,{children:X.start_date})},{title:"End Date",dataIndex:"end_date",align:"center",render:(Q,X)=>e.jsx(e.Fragment,{children:X.end_date})},{title:"Class",dataIndex:"class",align:"center"},{title:"Section",key:"Section",align:"center",render:Q=>e.jsx(e.Fragment,{children:Q.section?.toString()})},{title:"Action",key:"action",align:"center",render:(Q,X)=>e.jsxs(s.Space,{size:"middle",children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),size:"small",onClick:()=>B(X?.id)}),e.jsx(At,{id:X?.id,funcName:$})]})}],[]),H=Q=>{const{children:X=[]}=Q||{},J=[{title:"Serial No",dataIndex:"sl_no",align:"center",render:(K,Z)=>E(Z)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(s.Input,{defaultValue:Z.sl_no||K,onChange:pe=>F(pe.target.value,"sl_no"),onPressEnter:()=>z(Z.id),style:{width:"80px"}}),e.jsx("a",{onClick:()=>z(Z.id),style:{marginRight:8},children:"Save"}),e.jsx("a",{onClick:V,children:"Cancel"})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:K}),e.jsx("a",{onClick:()=>U(Z),children:"Edit"})]})},{title:"Subject",dataIndex:"Subject",align:"center",render:(K,Z)=>e.jsx(e.Fragment,{children:Z.subject})},{title:"Date",dataIndex:"date_of_exam",align:"center",render:(K,Z)=>e.jsx(e.Fragment,{children:Z.date_of_exam})},{title:"Start Time",dataIndex:"start_to",align:"center"},{title:"End Time",dataIndex:"end_from",align:"center"},{title:"Marks",dataIndex:"full_marks",align:"center"},{title:"Is Main Additional",dataIndex:"is_main_additional",align:"center",render:(K,Z)=>{const ee=Object.prototype.hasOwnProperty.call(v,Z.id)?v[Z.id]:Z.is_main_additional??K,pe=b(ee),te=!!y[Z.id];return e.jsx(s.Switch,{checked:pe,loading:te,onChange:se=>O(Z.id,pe,se)})}},{title:"Group",dataIndex:"group_id",align:"center",render:(K,Z)=>M(Z)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(s.Input,{defaultValue:Z.group_id||K,onChange:pe=>C(pe.target.value,"group_id"),onPressEnter:()=>k(Z.id),style:{width:"80px"}}),e.jsx("a",{onClick:()=>k(Z.id),style:{marginRight:8},children:"Save"}),e.jsx("a",{onClick:L,children:"Cancel"})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:K}),e.jsx("a",{onClick:()=>Y(Z),children:"Edit"})]})}];return e.jsxs(e.Fragment,{children:[e.jsx(s.Typography.Text,{style:{marginLeft:20},children:"Subject"}),e.jsx(w,{style:{width:"95%"},m:1,children:e.jsx(s.Table,{size:"small",bordered:!0,columns:J,rowKey:"id",dataSource:X,pagination:!1})})]})};return e.jsxs(w,{pt:5,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx("div",{style:{display:"grid",gap:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Exam List"})}),e.jsx(w,{pt:3,pb:5,children:D?e.jsx(s.Typography.Text,{children:"Loading..."}):e.jsx(s.Table,{size:"small",expandable:{expandedRowRender:H,childrenColumnName:"changed"},bordered:!0,columns:N,rowKey:"id",dataSource:R?.data??[],pagination:!1})})]})})]})}function Q1({token:t}){return e.jsx(J1,{token:t})}function X1({token:t}){Ss();const[a,n]=i.useState({page:0,rowsPerPage:10}),r=i.useMemo(()=>[{title:"Exam Name",dataIndex:"type_name",align:"center"},{title:"Remark",dataIndex:"remark",align:"center"},{title:"Action",key:"action",align:"center",render:(f,p)=>e.jsxs(s.Space,{size:"middle",children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),size:"small"}),e.jsx(At,{id:p?.id,funcName:h})]})}],[]),{isLoading:o,error:l,data:d,mutate:c}=q(t!=null?[`${We.examType.table}?page=${a.page+1}&per_page=10`,t]:null,([f,p])=>W(f,p)),h=async f=>{try{await c(st(We.examType.remove,f),ot(f))}catch{}};return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx("div",{style:{display:"grid",gap:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Exam Type List"})}),e.jsx(w,{pt:3,pb:5,children:e.jsx(s.Table,{size:"small",bordered:!0,columns:r,rowKey:"id",dataSource:d?.data??[],pagination:!1,loading:o})})]})})]})}function Z1({token:t}){return e.jsx(X1,{token:t})}function eC({token:t}){const[a,n]=i.useState({pagination:{current:1,pageSize:50}}),{data:r}=q(t!=null?[We.examType.dropdown,t]:null,([y,g])=>W(y,g)),{trigger:o}=it(We.examSetting.add,(y,{arg:g})=>Kr(y,g,t)),{data:l}=q(t!=null&&We.examSetting.assignMarksheetClass?[We.examSetting.assignMarksheetClass,t]:null,([y,g])=>W(y,g)),{isLoading:d,data:c,mutate:h}=q(t!=null?[`${We.examSetting.table}?page=${a.pagination.current}&per_page=${a.pagination.pageSize}`,t]:null,([y,g])=>W(y,g)),f=i.useMemo(()=>{const y=c?.data;return Array.isArray(y)?y:y&&Array.isArray(y?.data)?y.data:[]},[c]),p=async y=>{try{(await o(y))?.Status==="Success"&&h()}catch{}},m=y=>{n(g=>({...g,pagination:{current:y,pageSize:g.pagination.pageSize}}))},v=i.useMemo(()=>[{title:"Exam Name",dataIndex:"name",align:"center"},{title:"Exam Type",dataIndex:"exam_type",align:"center"},{title:"Start Date",dataIndex:"start_date",align:"center",render:(y,g)=>e.jsx(e.Fragment,{children:g.start_date})},{title:"End Date",dataIndex:"end_date",align:"center",render:(y,g)=>e.jsx(e.Fragment,{children:g.end_date})},{title:"Class",dataIndex:"class",align:"center"}],[]),S=y=>{const g=y.children?.[0]||{},b=y.sections||[];return e.jsx(s.Form,{layout:"inline",onFinish:p,children:e.jsx(s.Grid,{container:!0,style:{padding:"10px"},children:e.jsx(s.Grid,{item:!0,xs:12,style:{display:"flex",justifyContent:"center"},children:e.jsxs(s.Grid,{container:!0,spacing:3,alignItems:"center",children:[e.jsxs(s.Grid,{item:!0,children:[e.jsx("input",{type:"hidden",name:"class_id",value:y.class_id}),e.jsx("input",{type:"hidden",name:"exam_name_id",value:y.id})]}),b.map((D,R)=>e.jsx(s.Grid,{item:!0,children:e.jsxs(s.Grid,{container:!0,alignItems:"center",children:[e.jsx(s.Grid,{item:!0,children:e.jsx("input",{type:"file",name:`classteachersign_${D.value}`,accept:"image/*"})}),e.jsx(s.Grid,{item:!0,style:{marginLeft:10},children:g?.[`classteachersign_${D.value}`]&&e.jsx("img",{src:`${g?.[`classteachersign_${D.value}`]}`,alt:"sign",style:{width:50,height:50,objectFit:"cover"}})})]})},R)),e.jsxs(s.Grid,{item:!0,style:{marginLeft:"10px"},children:[e.jsx("input",{type:"file",name:"exam_ic_sign",accept:"image/*"}),g?.exam_ic_sign&&e.jsx("img",{src:g?.exam_ic_sign,alt:"ic sign",style:{width:50,height:50,objectFit:"cover"}})]}),e.jsx(s.Grid,{item:!0,style:{marginLeft:"10px"},children:e.jsx(s.Input,{defaultValue:g?.reportCardTitle,placeholder:"Report Card Title",name:"reportCardTitle",style:{width:200}})}),e.jsx(s.Grid,{item:!0,style:{marginLeft:"10px"},children:e.jsx("input",{type:"date",name:"marksheet_issue"})}),e.jsx(s.Grid,{item:!0,style:{marginLeft:"10px"},children:e.jsx(s.Input,{defaultValue:g?.promoted_to,placeholder:"Promoted To",name:"promoted_to",style:{width:200}})}),e.jsx(s.Grid,{item:!0,style:{marginLeft:"10px"},children:e.jsx(s.Input.TextArea,{defaultValue:g?.codes,placeholder:"Abbreviations",name:"codes",style:{minWidth:250}})}),e.jsx(s.Grid,{item:!0,style:{marginLeft:"10px",display:"flex",alignItems:"center"},children:e.jsx(de,{type:"submit",value:"Submit",color:"primary"})})]})})})})};return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx("div",{style:{display:"grid",gap:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Exam Setting"})}),e.jsx(w,{pt:3,pb:5,children:e.jsx(s.Table,{size:"small",expandable:{expandedRowRender:S,childrenColumnName:"changed"},bordered:!0,columns:v,rowKey:y=>y.id,dataSource:f,loading:d,pagination:{current:a.pagination.current,pageSize:a.pagination.pageSize,total:c?.pagination?.total_rows??f.length,showSizeChanger:!0,onChange:m,onShowSizeChange:(y,g)=>{n(b=>({...b,pagination:{current:1,pageSize:g}}))},showTotal:(y,g)=>`${g[0]}-${g[1]} of ${y} items`}})})]})})]})}function tC({token:t}){return e.jsx(eC,{token:t})}function aC({token:t}){const a=Ss(),{isLoading:n,error:r,data:o,mutate:l}=q(t!=null?[We.assessment.table,t]:null,([p,m])=>W(p,m)),d=p=>{a(`/ExamDashboard/EditAssessment?id=${p}`)},c=async p=>{try{await l(st(We.assessment.delete,p),ot(p))}catch{}},h=i.useMemo(()=>[{title:"Assessment Name",dataIndex:"name",align:"center"},{title:"Class",dataIndex:"class",align:"center"},{title:"Exam Type",dataIndex:"type_name",align:"center"},{title:"Action",key:"action",align:"center",render:(p,m)=>e.jsxs(s.Space,{size:"middle",children:[e.jsx(s.Button,{type:"text",icon:e.jsx(re.EditOutlined,{}),size:"small",onClick:()=>d(m?.id)}),e.jsx(At,{id:m?.id,funcName:c})]})}],[]),f=p=>{const{children:m=[]}=p||{},v=[{title:"Skill",dataIndex:"title",align:"center"},{title:"Marks",dataIndex:"max_marks",align:"center"}],S=[{title:"Subject",dataIndex:"subject_name",align:"center"},{title:"Skill",dataIndex:"subject_assessment_skill",align:"center",render:(y,g)=>e.jsx("div",{style:{fontSize:"11px"},children:g?.subject_assessment_skill?.map((b,D)=>e.jsx("div",{children:b?.skill},D))})},{title:"Number",dataIndex:"subject_assessment_skill",align:"center",render:(y,g)=>e.jsx("div",{style:{fontSize:"11px"},children:g?.subject_assessment_skill?.map((b,D)=>e.jsx("div",{children:b?.full_marks},D))})},{title:"Type",dataIndex:"subject_assessment_skill",align:"center",render:(y,g)=>e.jsx("div",{style:{fontSize:"11px"},children:g?.subject_assessment_skill?.map((b,D)=>e.jsx("div",{children:b?.type},D))})}];return e.jsxs(e.Fragment,{children:[e.jsx(s.Typography.Text,{style:{marginLeft:20},children:"Subject"}),e.jsx(w,{style:{width:"95%"},m:1,children:e.jsx(s.Table,{size:"small",expandable:{childrenColumnName:"changed"},bordered:!0,columns:m[0]?.type!=="subject_wise"?v:S,rowKey:m[0]?.type!=="subject_wise"?"id":"fk_subject_assessment_id",dataSource:m,pagination:!1})})]})};return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx("div",{style:{display:"grid",gap:24},children:e.jsxs("div",{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Assessment List"})}),e.jsx(w,{pt:3,pb:5,children:e.jsx(s.Table,{size:"small",expandable:{expandedRowRender:f,childrenColumnName:"changed"},bordered:!0,columns:h,rowKey:"id",dataSource:o?.data??[],pagination:!1,loading:n})})]})})]})}function nC({token:t}){return e.jsx(aC,{token:t})}function sC({token:t}){const[a,n]=i.useState(null),[r,o]=i.useState(null),{isLoading:l,data:d}=q(r!=null&&t!=null?[r,t]:null,([S,y])=>W(S,y),{onSuccess:S=>{}}),{isLoading:c,data:h}=q(t!=null?[We.examInstruction.dropdown,t]:null,([S,y])=>W(S,y)),{trigger:f}=it(We.examInstruction.update,(S,{arg:y})=>ip(S,y,t)),p=async S=>{try{(await f({exam_id:a,instruction:S.instruction}))?.Status==="Success"&&toast.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{}},m=S=>{n(S),o(`${We.examInstruction.get}?exam_id=${S}`)},v=i.useMemo(()=>{const S=h?.data;return Array.isArray(S)?S.map(y=>({value:y.value??y.id,label:y.label??y.name})):[]},[h]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Grid,{container:!0,spacing:3,children:e.jsxs(s.Grid,{item:!0,xs:12,children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Instruction"})}),e.jsx(w,{pl:2,pr:2,pb:2,children:e.jsxs(s.Form,{layout:"vertical",onFinish:p,children:[e.jsx(s.Form.Item,{name:"exam_name",label:"Exam Name",rules:[{required:!0,message:"Please select exam name"}],children:e.jsx(s.Select,{style:{width:"100%"},options:v,onChange:S=>m(S),placeholder:"Select exam name"})}),e.jsx(s.Form.Item,{name:"instruction",children:e.jsx(s.Input.TextArea,{rows:10,defaultValue:d?.data?.[0]?.instruction??""})}),e.jsx("div",{style:{marginTop:10},children:e.jsx(de,{type:"submit",value:"Update",color:"primary"})})]})})]})})]})}function rC({token:t}){return e.jsx(sC,{token:t})}function iC({token:t}){const[a,n]=i.useState({page:1,rowsPerPage:25}),r=j=>{n(P=>({...P,page:j}))},[o,l]=i.useState(!1),[d,c]=i.useState(!1),{isLoading:h,error:f,data:p,mutate:m}=q(t!=null?[`${We.roomManagement.list}?page=${a.page}&per_page=${a.rowsPerPage}`,t]:null,([j,P])=>W(j,P)),{isLoading:v,error:S,data:y,mutate:g}=q(t!=null?[`${We.roomManagement.list}?page=${a.page}&per_page=${a.rowsPerPage}`,t]:null,([j,P])=>W(j,P)),b=async j=>{j.preventDefault();const P=new FormData(j.target);try{await g(Wc(We.roomManagement.add,P)),j.target.reset(),R(O=>!O)}catch{}},[D,R]=i.useState(!1),I=(j,P)=>{l(!0),c(P)},A=async(j,P)=>{j.preventDefault();const O=new FormData(j.target);O.append("data",JSON.stringify(P));try{await m(addData(We.roomManagement.assign,O)),l(!1)}catch{}},_=j=>{l(j)},u=[{title:"Room",dataIndex:"class_room",key:"class_room"}],x=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",align:"center"},{title:"Section",dataIndex:"section",key:"section",align:"center"},{title:"Assigned Room",dataIndex:"class_room",key:"class_room",align:"center",render:j=>e.jsx("span",{style:{color:"blue",fontWeight:"bold"},children:j?.map((P,O)=>e.jsxs(i.Fragment,{children:[P.class_room,O<j.length-1&&e.jsx("br",{})]},O))})},{title:"Roll No",dataIndex:"class_room",key:"class_room",align:"center",render:j=>e.jsx("span",{style:{color:"blue",fontWeight:"bold"},children:j?.map((P,O)=>e.jsxs(i.Fragment,{children:[P.rollno_from," - ",P.rollno_to,O<j.length-1&&e.jsx("br",{})]},O))})},{title:"Action",align:"center",render:(j,P)=>e.jsx(s.Space,{children:e.jsx(s.Button,{icon:e.jsx(re.EditOutlined,{}),size:"small",onClick:()=>I(P,j)})}),width:"5%"}],[]);return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Grid,{container:!0,spacing:3,children:[e.jsxs(s.Grid,{item:!0,xs:12,md:6,children:[e.jsxs(w,{children:[e.jsx(he,{variant:"h6",color:"white",bgColor:"info",p:2,borderRadius:"lg",children:"Add Room"}),e.jsx(w,{p:2,children:e.jsxs(s.Form,{layout:"vertical",onFinish:b,children:[e.jsx(s.Form.Item,{name:"class_room",label:"Room Name",rules:[{required:!0,message:"Please enter room name"}],children:e.jsx(s.Input,{type:"text",required:!0})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(w,{pt:3,children:e.jsx(s.Table,{size:"small",bordered:!0,columns:u,rowKey:"id",dataSource:y?.data??[],pagination:!1,loading:v})})]}),e.jsx(s.Grid,{item:!0,xs:12,md:6,children:e.jsxs(w,{children:[e.jsx(he,{variant:"h6",color:"white",bgColor:"info",p:2,borderRadius:"lg",children:"Assigned Room"}),e.jsx(w,{pt:2,style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(s.Button,{type:"primary",onClick:()=>oC(),children:"+Add"})}),e.jsxs(w,{pt:3,children:[o&&e.jsx(s.Modal,{title:"Assign Room",open:o,onCancel:()=>_(!1),footer:null,destroyOnClose:!0,children:o&&e.jsx(AssignClassRoomEdit,{data:{handleUpdate:A,rowData:d}})}),e.jsx(s.Table,{size:"small",bordered:!0,columns:x,rowKey:"id",dataSource:p?.data??[],pagination:{current:a.page,pageSize:a.rowsPerPage,showSizeChanger:!0,onChange:r},loading:h})]})]})})]})]})}const oC=t=>{};function lC({token:t}){return e.jsx(iC,{token:t})}function dC({token:t}){const[a,n]=i.useState(!1),r=i.useRef(null),[o,l]=i.useState([]),[d,c]=i.useState(!1),[h,f]=i.useState(null),[p,m]=i.useState(!1),[v,S]=i.useState(null),[y,g]=i.useState(!1),[b,D]=i.useState(!1),[R,I]=i.useState(null),[A,_]=i.useState(!1),[u,x]=i.useState(null),[j,P]=i.useState(!1),O=i.useRef(null),[z,k]=i.useState([]),F=async(ee,pe)=>{pe==="class_id"?(_(ee.value),c(`${la}?class_id=${ee.value}`),I(`${We.examDropdownUrl}?class_id=${ee.value}`),g(te=>!te)):pe==="exam_id"&&(S(`${Fr}?class_id=${A}&exam_id=${ee.value}`),(await C({exam_id:ee.value}))[0].exam_type==="periodic_test"?P(!1):P(!0),D(se=>!se))},{trigger:C,isLoading:E,data:M}=it(We.examSetting.typeByExamId,(ee,{arg:pe})=>Kr(ee,pe,t)),{isLoading:U,errorSubject:Y,data:V}=q(v,W),{isLoading:L,errorExam:B,data:$}=q(R,W),{isLoading:N,errorClass:H,data:Q}=q(t!=null?[oa,t]:null,([ee,pe])=>W(ee,pe)),{isLoading:X,data:J}=q(d,W),K=i.useMemo(()=>j?[{title:"SL",dataIndex:"Sl_no",align:"center"},{title:"Student Name",dataIndex:"firstname",align:"center"},{title:"Full Marks",dataIndex:"full_marks",align:"center"},{title:"Marks Obtained",dataIndex:"marks_obtained",align:"center"},{title:"Percentage",dataIndex:"percentage",align:"center"},{title:"Attendance",dataIndex:"attendance",align:"center"}]:[{title:"SL",dataIndex:"Sl_no",align:"center"},{title:"Student Name",dataIndex:"firstname",align:"center"},{title:"Full Marks",dataIndex:"full_marks",align:"center"},{title:"Periodic Test",dataIndex:"PeriodicTest",align:"center"},{title:"Portfolio(CW/HW)",dataIndex:"Portfolio",align:"center"},{title:"Subject Enrichment",dataIndex:"Enrichment",align:"center"},{title:"Multiple Assessment",dataIndex:"Assessment",align:"center"},{title:"Attendance",dataIndex:"attendance",align:"center"}],[j]),Z=ee=>{ee.preventDefault();const pe=new FormData(ee.target),te={};pe.forEach((se,le)=>te[le]=se),l(te),f(`exam/exam/getstudentlistforExam?class_id=${ee.target.class_id.value}§ion_id=${ee.target.section_id.value}&subject_id=${ee.target.subject_id.value}&exam_id=${ee.target.exam_id.value}&`),r.current&&r.current.click(),n(!1),m(se=>!se)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Grid,{container:!0,spacing:6,children:e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Assign Marks Exam"})}),e.jsxs(w,{p:3,children:[e.jsx(s.Form,{layout:"vertical",onFinish:Z,children:e.jsxs(s.Grid,{container:!0,spacing:3,justifyContent:"center",children:[e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(ae,{options:Array.isArray(Q)?Q:[],closeMenuOnSelect:!0,label:"Class",name:"class_id",onChange:ee=>F(ee,"class_id"),allowSelectAll:!1,required:!0})}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(ae,{options:Array.isArray(J)?J:[],closeMenuOnSelect:!0,label:"Section",name:"section_id",allowSelectAll:!1},`section1${y}`)}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(ae,{options:Array.isArray($)?$:[],closeMenuOnSelect:!0,label:"Exam",name:"exam_id",onChange:ee=>F(ee,"exam_id"),allowSelectAll:!1,required:!0})}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(ae,{options:Array.isArray(V)?V:[],closeMenuOnSelect:!0,label:"Subject",name:"subject_id",allowSelectAll:!1,onChange:ee=>{x(ee.subject_type),n(!0)}},`sub${b}`)}),e.jsx(s.Grid,{item:!0,xs:12,md:1.5,className:"buttonCoustom",children:e.jsx(s.Grid,{container:!0,justifyContent:"flex-end",children:e.jsx(s.Grid,{item:!0,children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})})})]})}),e.jsx(s.Grid,{container:!0,spacing:3,style:{marginTop:16},children:e.jsx(s.Grid,{item:!0,xs:12,style:{borderTop:"1px solid #ececec",borderTopWidth:"2px"},children:h&&!a&&e.jsx(s.Table,{ref:O,columns:K,dataSource:z,rowKey:"id",pagination:!1,bordered:!0,size:"small",loading:E})})})]})]})})})]})}function cC({token:t}){return e.jsx(dC,{token:t})}function op(t,a,n){if(typeof t=="function"?t===a:t.has(a))return arguments.length<3?a:n;throw new TypeError("Private element is not present on this object")}function uC(t,a){if(a.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function dc(t,a){return t.get(op(t,a))}function pC(t,a,n){uC(t,a),a.set(t,n)}function mC(t,a,n){return t.set(op(t,a),n),n}const hC=100,Ee={},fC=()=>{Ee.previousActiveElement instanceof HTMLElement?(Ee.previousActiveElement.focus(),Ee.previousActiveElement=null):document.body&&document.body.focus()},gC=t=>new Promise(a=>{if(!t)return a();const n=window.scrollX,r=window.scrollY;Ee.restoreFocusTimeout=setTimeout(()=>{fC(),a()},hC),window.scrollTo(n,r)}),lp="swal2-",yC=["container","shown","height-auto","iosfix","popup","modal","no-backdrop","no-transition","toast","toast-shown","show","hide","close","title","html-container","actions","confirm","deny","cancel","footer","icon","icon-content","image","input","file","range","select","radio","checkbox","label","textarea","inputerror","input-label","validation-message","progress-steps","active-progress-step","progress-step","progress-step-line","loader","loading","styled","top","top-start","top-end","top-left","top-right","center","center-start","center-end","center-left","center-right","bottom","bottom-start","bottom-end","bottom-left","bottom-right","grow-row","grow-column","grow-fullscreen","rtl","timer-progress-bar","timer-progress-bar-container","scrollbar-measure","icon-success","icon-warning","icon-info","icon-question","icon-error","draggable","dragging"],ue=yC.reduce((t,a)=>(t[a]=lp+a,t),{}),xC=["success","warning","info","question","error"],wr=xC.reduce((t,a)=>(t[a]=lp+a,t),{}),dp="SweetAlert2:",Po=t=>t.charAt(0).toUpperCase()+t.slice(1),Pt=t=>{console.warn(`${dp} ${typeof t=="object"?t.join(" "):t}`)},Xa=t=>{console.error(`${dp} ${t}`)},cc=[],bC=t=>{cc.includes(t)||(cc.push(t),Pt(t))},cp=(t,a=null)=>{bC(`"${t}" is deprecated and will be removed in the next major release.${a?` Use "${a}" instead.`:""}`)},Gr=t=>typeof t=="function"?t():t,Mo=t=>t&&typeof t.toPromise=="function",vs=t=>Mo(t)?t.toPromise():Promise.resolve(t),Eo=t=>t&&Promise.resolve(t)===t,jC=()=>navigator.userAgent.includes("Firefox"),Mt=()=>document.body.querySelector(`.${ue.container}`),Cs=t=>{const a=Mt();return a?a.querySelector(t):null},Yt=t=>Cs(`.${t}`),Xe=()=>Yt(ue.popup),Rn=()=>Yt(ue.icon),SC=()=>Yt(ue["icon-content"]),up=()=>Yt(ue.title),Oo=()=>Yt(ue["html-container"]),pp=()=>Yt(ue.image),$o=()=>Yt(ue["progress-steps"]),Jr=()=>Yt(ue["validation-message"]),ia=()=>Cs(`.${ue.actions} .${ue.confirm}`),In=()=>Cs(`.${ue.actions} .${ue.cancel}`),Za=()=>Cs(`.${ue.actions} .${ue.deny}`),wC=()=>Yt(ue["input-label"]),Pn=()=>Cs(`.${ue.loader}`),_s=()=>Yt(ue.actions),mp=()=>Yt(ue.footer),Qr=()=>Yt(ue["timer-progress-bar"]),Fo=()=>Yt(ue.close),vC=`
|
|
65
|
+
a[href],
|
|
66
|
+
area[href],
|
|
67
|
+
input:not([disabled]),
|
|
68
|
+
select:not([disabled]),
|
|
69
|
+
textarea:not([disabled]),
|
|
70
|
+
button:not([disabled]),
|
|
71
|
+
iframe,
|
|
72
|
+
object,
|
|
73
|
+
embed,
|
|
74
|
+
[tabindex="0"],
|
|
75
|
+
[contenteditable],
|
|
76
|
+
audio[controls],
|
|
77
|
+
video[controls],
|
|
78
|
+
summary
|
|
79
|
+
`,Bo=()=>{const t=Xe();if(!t)return[];const a=t.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'),n=Array.from(a).sort((l,d)=>{const c=parseInt(l.getAttribute("tabindex")||"0"),h=parseInt(d.getAttribute("tabindex")||"0");return c>h?1:c<h?-1:0}),r=t.querySelectorAll(vC),o=Array.from(r).filter(l=>l.getAttribute("tabindex")!=="-1");return[...new Set(n.concat(o))].filter(l=>Bt(l))},Lo=()=>ha(document.body,ue.shown)&&!ha(document.body,ue["toast-shown"])&&!ha(document.body,ue["no-backdrop"]),Xr=()=>{const t=Xe();return t?ha(t,ue.toast):!1},CC=()=>{const t=Xe();return t?t.hasAttribute("data-loading"):!1},Wt=(t,a)=>{if(t.textContent="",a){const r=new DOMParser().parseFromString(a,"text/html"),o=r.querySelector("head");o&&Array.from(o.childNodes).forEach(d=>{t.appendChild(d)});const l=r.querySelector("body");l&&Array.from(l.childNodes).forEach(d=>{d instanceof HTMLVideoElement||d instanceof HTMLAudioElement?t.appendChild(d.cloneNode(!0)):t.appendChild(d)})}},ha=(t,a)=>a?a.split(/\s+/).every(n=>t.classList.contains(n)):!1,_C=(t,a)=>{Array.from(t.classList).forEach(n=>{!Object.values(ue).includes(n)&&!Object.values(wr).includes(n)&&!Object.values(a.showClass||{}).includes(n)&&t.classList.remove(n)})},zt=(t,a,n)=>{if(_C(t,a),!a.customClass)return;const r=a.customClass[n];if(r){if(typeof r!="string"&&!r.forEach){Pt(`Invalid type of customClass.${n}! Expected string or iterable object, got "${typeof r}"`);return}Qe(t,r)}},Zr=(t,a)=>{if(!a)return null;switch(a){case"select":case"textarea":case"file":return t.querySelector(`.${ue.popup} > .${ue[a]}`);case"checkbox":return t.querySelector(`.${ue.popup} > .${ue.checkbox} input`);case"radio":return t.querySelector(`.${ue.popup} > .${ue.radio} input:checked`)||t.querySelector(`.${ue.popup} > .${ue.radio} input:first-child`);case"range":return t.querySelector(`.${ue.popup} > .${ue.range} input`);default:return t.querySelector(`.${ue.popup} > .${ue.input}`)}},hp=t=>{if(t.focus(),t.type!=="file"){const a=t.value;t.value="",t.value=a}},fp=(t,a,n)=>{if(!t||!a)return;const r=typeof a=="string"?a.split(/\s+/).filter(Boolean):a;(Array.isArray(t)?t:[t]).forEach(l=>{r.forEach(d=>{n?l.classList.add(d):l.classList.remove(d)})})},Qe=(t,a)=>{fp(t,a,!0)},Gt=(t,a)=>{fp(t,a,!1)},Ca=(t,a)=>Array.from(t.children).find(n=>n instanceof HTMLElement&&ha(n,a)),Wa=(t,a,n)=>{n===`${parseInt(`${n}`)}`&&(n=parseInt(n)),n||n===0?t.style.setProperty(a,typeof n=="number"?`${n}px`:n):t.style.removeProperty(a)},wt=(t,a="flex")=>{t&&(t.style.display=a)},Rt=t=>{t&&(t.style.display="none")},Uo=(t,a="block")=>{t&&new MutationObserver(()=>{As(t,t.innerHTML,a)}).observe(t,{childList:!0,subtree:!0})},uc=(t,a,n,r)=>{const o=t.querySelector(a);o&&o.style.setProperty(n,r)},As=(t,a,n="flex")=>{a?wt(t,n):Rt(t)},Bt=t=>!!(t&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)),AC=()=>!Bt(ia())&&!Bt(Za())&&!Bt(In()),eo=t=>t.scrollHeight>t.clientHeight,TC=(t,a)=>{let n=t;for(;n&&n!==a;){if(eo(n))return!0;n=n.parentElement}return!1},gp=t=>{const a=window.getComputedStyle(t),n=parseFloat(a.getPropertyValue("animation-duration")||"0"),r=parseFloat(a.getPropertyValue("transition-duration")||"0");return n>0||r>0},No=(t,a=!1)=>{const n=Qr();n&&Bt(n)&&(a&&(n.style.transition="none",n.style.width="100%"),setTimeout(()=>{n.style.transition=`width ${t/1e3}s linear`,n.style.width="0%"},10))},DC=()=>{const t=Qr();if(!t)return;const a=parseInt(window.getComputedStyle(t).width);t.style.removeProperty("transition"),t.style.width="100%";const n=parseInt(window.getComputedStyle(t).width),r=a/n*100;t.style.width=`${r}%`},kC=()=>typeof window>"u"||typeof document>"u",RC=`
|
|
80
|
+
<div aria-labelledby="${ue.title}" aria-describedby="${ue["html-container"]}" class="${ue.popup}" tabindex="-1">
|
|
81
|
+
<button type="button" class="${ue.close}"></button>
|
|
82
|
+
<ul class="${ue["progress-steps"]}"></ul>
|
|
83
|
+
<div class="${ue.icon}"></div>
|
|
84
|
+
<img class="${ue.image}" />
|
|
85
|
+
<h2 class="${ue.title}" id="${ue.title}"></h2>
|
|
86
|
+
<div class="${ue["html-container"]}" id="${ue["html-container"]}"></div>
|
|
87
|
+
<input class="${ue.input}" id="${ue.input}" />
|
|
88
|
+
<input type="file" class="${ue.file}" />
|
|
89
|
+
<div class="${ue.range}">
|
|
90
|
+
<input type="range" />
|
|
91
|
+
<output></output>
|
|
92
|
+
</div>
|
|
93
|
+
<select class="${ue.select}" id="${ue.select}"></select>
|
|
94
|
+
<div class="${ue.radio}"></div>
|
|
95
|
+
<label class="${ue.checkbox}">
|
|
96
|
+
<input type="checkbox" id="${ue.checkbox}" />
|
|
97
|
+
<span class="${ue.label}"></span>
|
|
98
|
+
</label>
|
|
99
|
+
<textarea class="${ue.textarea}" id="${ue.textarea}"></textarea>
|
|
100
|
+
<div class="${ue["validation-message"]}" id="${ue["validation-message"]}"></div>
|
|
101
|
+
<div class="${ue.actions}">
|
|
102
|
+
<div class="${ue.loader}"></div>
|
|
103
|
+
<button type="button" class="${ue.confirm}"></button>
|
|
104
|
+
<button type="button" class="${ue.deny}"></button>
|
|
105
|
+
<button type="button" class="${ue.cancel}"></button>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="${ue.footer}"></div>
|
|
108
|
+
<div class="${ue["timer-progress-bar-container"]}">
|
|
109
|
+
<div class="${ue["timer-progress-bar"]}"></div>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
`.replace(/(^|\n)\s*/g,""),IC=()=>{const t=Mt();return t?(t.remove(),Gt([document.documentElement,document.body],[ue["no-backdrop"],ue["toast-shown"],ue["has-column"]]),!0):!1},Ua=()=>{Ee.currentInstance&&Ee.currentInstance.resetValidationMessage()},PC=()=>{const t=Xe();if(!t)return;const a=Ca(t,ue.input),n=Ca(t,ue.file),r=t.querySelector(`.${ue.range} input`),o=t.querySelector(`.${ue.range} output`),l=Ca(t,ue.select),d=t.querySelector(`.${ue.checkbox} input`),c=Ca(t,ue.textarea);a&&(a.oninput=Ua),n&&(n.onchange=Ua),l&&(l.onchange=Ua),d&&(d.onchange=Ua),c&&(c.oninput=Ua),r&&o&&(r.oninput=()=>{Ua(),o.value=r.value},r.onchange=()=>{Ua(),o.value=r.value})},MC=t=>{if(typeof t=="string"){const a=document.querySelector(t);if(!a)throw new Error(`Target element "${t}" not found`);return a}return t},EC=t=>{const a=Xe();a&&(a.setAttribute("role",t.toast?"alert":"dialog"),a.setAttribute("aria-live",t.toast?"polite":"assertive"),t.toast||a.setAttribute("aria-modal","true"))},OC=t=>{window.getComputedStyle(t).direction==="rtl"&&(Qe(Mt(),ue.rtl),Ee.isRTL=!0)},$C=t=>{const a=IC();if(kC()){Xa("SweetAlert2 requires document to initialize");return}const n=document.createElement("div");n.className=ue.container,a&&Qe(n,ue["no-transition"]),Wt(n,RC),n.dataset.swal2Theme=t.theme;const r=MC(t.target||"body");r.appendChild(n),t.topLayer&&(n.setAttribute("popover",""),n.showPopover()),EC(t),OC(r),PC()},zo=(t,a)=>{t instanceof HTMLElement?a.appendChild(t):typeof t=="object"?FC(t,a):t&&Wt(a,t)},FC=(t,a)=>{"jquery"in t?BC(a,t):Wt(a,t.toString())},BC=(t,a)=>{if(t.textContent="",0 in a)for(let n=0;n in a;n++)t.appendChild(a[n].cloneNode(!0));else t.appendChild(a.cloneNode(!0))},LC=(t,a)=>{const n=_s(),r=Pn();!n||!r||(!a.showConfirmButton&&!a.showDenyButton&&!a.showCancelButton?Rt(n):wt(n),zt(n,a,"actions"),UC(n,r,a),Wt(r,a.loaderHtml||""),zt(r,a,"loader"))};function UC(t,a,n){const r=ia(),o=Za(),l=In();!r||!o||!l||(Li(r,"confirm",n),Li(o,"deny",n),Li(l,"cancel",n),NC(r,o,l,n),n.reverseButtons&&(n.toast?(t.insertBefore(l,r),t.insertBefore(o,r)):(t.insertBefore(l,a),t.insertBefore(o,a),t.insertBefore(r,a))))}function NC(t,a,n,r){if(!r.buttonsStyling){Gt([t,a,n],ue.styled);return}Qe([t,a,n],ue.styled),[[t,"confirm",r.confirmButtonColor],[a,"deny",r.denyButtonColor],[n,"cancel",r.cancelButtonColor]].forEach(([l,d,c])=>{c&&l.style.setProperty(`--swal2-${d}-button-background-color`,c),zC(l)})}function zC(t){const a=window.getComputedStyle(t);if(a.getPropertyValue("--swal2-action-button-focus-box-shadow"))return;const n=a.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/,"rgba($1, $2, $3, 0.5)");t.style.setProperty("--swal2-action-button-focus-box-shadow",a.getPropertyValue("--swal2-outline").replace(/ rgba\(.*/,` ${n}`))}function Li(t,a,n){const r=Po(a);As(t,n[`show${r}Button`],"inline-block"),Wt(t,n[`${a}ButtonText`]||""),t.setAttribute("aria-label",n[`${a}ButtonAriaLabel`]||""),t.className=ue[a],zt(t,n,`${a}Button`)}const qC=(t,a)=>{const n=Fo();n&&(Wt(n,a.closeButtonHtml||""),zt(n,a,"closeButton"),As(n,a.showCloseButton),n.setAttribute("aria-label",a.closeButtonAriaLabel||""))},YC=(t,a)=>{const n=Mt();n&&(WC(n,a.backdrop),VC(n,a.position),HC(n,a.grow),zt(n,a,"container"))};function WC(t,a){typeof a=="string"?t.style.background=a:a||Qe([document.documentElement,document.body],ue["no-backdrop"])}function VC(t,a){a&&(a in ue?Qe(t,ue[a]):(Pt('The "position" parameter is not valid, defaulting to "center"'),Qe(t,ue.center)))}function HC(t,a){a&&Qe(t,ue[`grow-${a}`])}var nt={innerParams:new WeakMap,domCache:new WeakMap,focusedElement:new WeakMap};const KC=["input","file","range","select","radio","checkbox","textarea"],GC=(t,a)=>{const n=Xe();if(!n)return;const r=nt.innerParams.get(t),o=!r||a.input!==r.input;KC.forEach(l=>{const d=Ca(n,ue[l]);d&&(XC(l,a.inputAttributes),d.className=ue[l],o&&Rt(d))}),a.input&&(o&&JC(a),ZC(a))},JC=t=>{if(!t.input)return;if(!ft[t.input]){Xa(`Unexpected type of input! Expected ${Object.keys(ft).join(" | ")}, got "${t.input}"`);return}const a=yp(t.input);if(!a)return;const n=ft[t.input](a,t);wt(a),t.inputAutoFocus&&setTimeout(()=>{hp(n)})},QC=t=>{for(const{name:a}of Array.from(t.attributes))["id","type","value","style"].includes(a)||t.removeAttribute(a)},XC=(t,a)=>{const n=Xe();if(!n)return;const r=Zr(n,t);if(r){QC(r);for(const o in a)r.setAttribute(o,a[o])}},ZC=t=>{if(!t.input)return;const a=yp(t.input);a&&zt(a,t,"input")},qo=(t,a)=>{!t.placeholder&&a.inputPlaceholder&&(t.placeholder=a.inputPlaceholder)},Ts=(t,a,n)=>{if(n.inputLabel){const r=document.createElement("label"),o=ue["input-label"];r.setAttribute("for",t.id),r.className=o,typeof n.customClass=="object"&&Qe(r,n.customClass.inputLabel),r.innerText=n.inputLabel,a.insertAdjacentElement("beforebegin",r)}},yp=t=>{const a=Xe();if(a)return Ca(a,ue[t]||ue.input)},vr=(t,a)=>{["string","number"].includes(typeof a)?t.value=`${a}`:Eo(a)||Pt(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof a}"`)},ft={};ft.text=ft.email=ft.password=ft.number=ft.tel=ft.url=ft.search=ft.date=ft["datetime-local"]=ft.time=ft.week=ft.month=(t,a)=>{const n=t;return vr(n,a.inputValue),Ts(n,n,a),qo(n,a),n.type=a.input,n};ft.file=(t,a)=>{const n=t;return Ts(n,n,a),qo(n,a),n};ft.range=(t,a)=>{const n=t,r=n.querySelector("input"),o=n.querySelector("output");return r&&(vr(r,a.inputValue),r.type=a.input,Ts(r,t,a)),o&&vr(o,a.inputValue),t};ft.select=(t,a)=>{const n=t;if(n.textContent="",a.inputPlaceholder){const r=document.createElement("option");Wt(r,a.inputPlaceholder),r.value="",r.disabled=!0,r.selected=!0,n.appendChild(r)}return Ts(n,n,a),n};ft.radio=t=>{const a=t;return a.textContent="",t};ft.checkbox=(t,a)=>{const n=Xe();if(!n)throw new Error("Popup not found");const r=Zr(n,"checkbox");if(!r)throw new Error("Checkbox input not found");r.value="1",r.checked=!!a.inputValue;const l=t.querySelector("span");if(l){const d=a.inputPlaceholder||a.inputLabel;d&&Wt(l,d)}return r};ft.textarea=(t,a)=>{const n=t;vr(n,a.inputValue),qo(n,a),Ts(n,n,a);const r=o=>parseInt(window.getComputedStyle(o).marginLeft)+parseInt(window.getComputedStyle(o).marginRight);return setTimeout(()=>{if("MutationObserver"in window){const o=Xe();if(!o)return;const l=parseInt(window.getComputedStyle(o).width),d=()=>{if(!document.body.contains(n))return;const c=n.offsetWidth+r(n),h=Xe();h&&(c>l?h.style.width=`${c}px`:Wa(h,"width",a.width))};new MutationObserver(d).observe(n,{attributes:!0,attributeFilter:["style"]})}}),n};const e_=(t,a)=>{const n=Oo();n&&(Uo(n),zt(n,a,"htmlContainer"),a.html?(zo(a.html,n),wt(n,"block")):a.text?(n.textContent=a.text,wt(n,"block")):Rt(n),GC(t,a))},t_=(t,a)=>{const n=mp();n&&(Uo(n),As(n,!!a.footer,"block"),a.footer&&zo(a.footer,n),zt(n,a,"footer"))},a_=(t,a)=>{const n=nt.innerParams.get(t),r=Rn();if(!r)return;if(n&&a.icon===n.icon){mc(r,a),pc(r,a);return}if(!a.icon&&!a.iconHtml){Rt(r);return}if(a.icon&&Object.keys(wr).indexOf(a.icon)===-1){Xa(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${a.icon}"`),Rt(r);return}wt(r),mc(r,a),pc(r,a),Qe(r,a.showClass&&a.showClass.icon),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",xp)},pc=(t,a)=>{for(const[n,r]of Object.entries(wr))a.icon!==n&&Gt(t,r);Qe(t,a.icon&&wr[a.icon]),r_(t,a),xp(),zt(t,a,"icon")},xp=()=>{const t=Xe();if(!t)return;const a=window.getComputedStyle(t).getPropertyValue("background-color");t.querySelectorAll("[class^=swal2-success-circular-line], .swal2-success-fix").forEach(r=>{r.style.backgroundColor=a})},n_=t=>`
|
|
113
|
+
${t.animation?'<div class="swal2-success-circular-line-left"></div>':""}
|
|
114
|
+
<span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
|
|
115
|
+
<div class="swal2-success-ring"></div>
|
|
116
|
+
${t.animation?'<div class="swal2-success-fix"></div>':""}
|
|
117
|
+
${t.animation?'<div class="swal2-success-circular-line-right"></div>':""}
|
|
118
|
+
`,s_=`
|
|
119
|
+
<span class="swal2-x-mark">
|
|
120
|
+
<span class="swal2-x-mark-line-left"></span>
|
|
121
|
+
<span class="swal2-x-mark-line-right"></span>
|
|
122
|
+
</span>
|
|
123
|
+
`,mc=(t,a)=>{if(!a.icon&&!a.iconHtml)return;let n=t.innerHTML,r="";a.iconHtml?r=hc(a.iconHtml):a.icon==="success"?(r=n_(a),n=n.replace(/ style=".*?"/g,"")):a.icon==="error"?r=s_:a.icon&&(r=hc({question:"?",warning:"!",info:"i"}[a.icon])),n.trim()!==r.trim()&&Wt(t,r)},r_=(t,a)=>{if(a.iconColor){t.style.color=a.iconColor,t.style.borderColor=a.iconColor;for(const n of[".swal2-success-line-tip",".swal2-success-line-long",".swal2-x-mark-line-left",".swal2-x-mark-line-right"])uc(t,n,"background-color",a.iconColor);uc(t,".swal2-success-ring","border-color",a.iconColor)}},hc=t=>`<div class="${ue["icon-content"]}">${t}</div>`,i_=(t,a)=>{const n=pp();if(n){if(!a.imageUrl){Rt(n);return}wt(n,""),n.setAttribute("src",a.imageUrl),n.setAttribute("alt",a.imageAlt||""),Wa(n,"width",a.imageWidth),Wa(n,"height",a.imageHeight),n.className=ue.image,zt(n,a,"image")}};let Yo=!1,bp=0,jp=0,Sp=0,wp=0;const o_=t=>{t.addEventListener("mousedown",Cr),document.body.addEventListener("mousemove",_r),t.addEventListener("mouseup",Ar),t.addEventListener("touchstart",Cr),document.body.addEventListener("touchmove",_r),t.addEventListener("touchend",Ar)},l_=t=>{t.removeEventListener("mousedown",Cr),document.body.removeEventListener("mousemove",_r),t.removeEventListener("mouseup",Ar),t.removeEventListener("touchstart",Cr),document.body.removeEventListener("touchmove",_r),t.removeEventListener("touchend",Ar)},Cr=t=>{const a=Xe();if(!a)return;const n=Rn();if(t.target===a||n&&n.contains(t.target)){Yo=!0;const r=vp(t);bp=r.clientX,jp=r.clientY,Sp=parseInt(a.style.insetInlineStart)||0,wp=parseInt(a.style.insetBlockStart)||0,Qe(a,"swal2-dragging")}},_r=t=>{const a=Xe();if(a&&Yo){let{clientX:n,clientY:r}=vp(t);const o=n-bp;a.style.insetInlineStart=`${Sp+(Ee.isRTL?-o:o)}px`,a.style.insetBlockStart=`${wp+(r-jp)}px`}},Ar=()=>{const t=Xe();Yo=!1,Gt(t,"swal2-dragging")},vp=t=>{const a=t.type.startsWith("touch")?t.touches[0]:t;return{clientX:a.clientX,clientY:a.clientY}},d_=(t,a)=>{const n=Mt(),r=Xe();if(!(!n||!r)){if(a.toast){Wa(n,"width",a.width),r.style.width="100%";const o=Pn();o&&r.insertBefore(o,Rn())}else Wa(r,"width",a.width);Wa(r,"padding",a.padding),a.color&&(r.style.color=a.color),a.background&&(r.style.background=a.background),Rt(Jr()),c_(r,a),a.draggable&&!a.toast?(Qe(r,ue.draggable),o_(r)):(Gt(r,ue.draggable),l_(r))}},c_=(t,a)=>{const n=a.showClass||{};t.className=`${ue.popup} ${Bt(t)?n.popup:""}`,a.toast?(Qe([document.documentElement,document.body],ue["toast-shown"]),Qe(t,ue.toast)):Qe(t,ue.modal),zt(t,a,"popup"),typeof a.customClass=="string"&&Qe(t,a.customClass),a.icon&&Qe(t,ue[`icon-${a.icon}`])},u_=(t,a)=>{const n=$o();if(!n)return;const{progressSteps:r,currentProgressStep:o}=a;if(!r||r.length===0||o===void 0){Rt(n);return}wt(n),n.textContent="",o>=r.length&&Pt("Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),r.forEach((l,d)=>{const c=p_(l);if(n.appendChild(c),d===o&&Qe(c,ue["active-progress-step"]),d!==r.length-1){const h=m_(a);n.appendChild(h)}})},p_=t=>{const a=document.createElement("li");return Qe(a,ue["progress-step"]),Wt(a,t),a},m_=t=>{const a=document.createElement("li");return Qe(a,ue["progress-step-line"]),t.progressStepsDistance&&Wa(a,"width",t.progressStepsDistance),a},h_=(t,a)=>{const n=up();n&&(Uo(n),As(n,!!(a.title||a.titleText),"block"),a.title&&zo(a.title,n),a.titleText&&(n.innerText=a.titleText),zt(n,a,"title"))},Cp=(t,a)=>{var n;d_(t,a),YC(t,a),u_(t,a),a_(t,a),i_(t,a),h_(t,a),qC(t,a),e_(t,a),LC(t,a),t_(t,a);const r=Xe();typeof a.didRender=="function"&&r&&a.didRender(r),(n=Ee.eventEmitter)===null||n===void 0||n.emit("didRender",r)},f_=()=>Bt(Xe()),_p=()=>{var t;return(t=ia())===null||t===void 0?void 0:t.click()},g_=()=>{var t;return(t=Za())===null||t===void 0?void 0:t.click()},y_=()=>{var t;return(t=In())===null||t===void 0?void 0:t.click()},Mn=Object.freeze({cancel:"cancel",backdrop:"backdrop",close:"close",esc:"esc",timer:"timer"}),Ap=t=>{if(t.keydownTarget&&t.keydownHandlerAdded&&t.keydownHandler){const a=t.keydownHandler;t.keydownTarget.removeEventListener("keydown",a,{capture:t.keydownListenerCapture}),t.keydownHandlerAdded=!1}},x_=(t,a,n)=>{if(Ap(t),!a.toast){const r=l=>j_(a,l,n);t.keydownHandler=r;const o=a.keydownListenerCapture?window:Xe();if(o){t.keydownTarget=o,t.keydownListenerCapture=a.keydownListenerCapture;const l=r;t.keydownTarget.addEventListener("keydown",l,{capture:t.keydownListenerCapture}),t.keydownHandlerAdded=!0}}},to=(t,a)=>{var n;const r=Bo();return r.length?(t=t+a,t===-2&&(t=r.length-1),t===r.length?t=0:t===-1&&(t=r.length-1),r[t].focus(),!(jC()&&r[t]instanceof HTMLIFrameElement)):((n=Xe())===null||n===void 0||n.focus(),!0)},Tp=["ArrowRight","ArrowDown"],b_=["ArrowLeft","ArrowUp"],j_=(t,a,n)=>{t&&(a.isComposing||a.keyCode===229||(t.stopKeydownPropagation&&a.stopPropagation(),a.key==="Enter"?S_(a,t):a.key==="Tab"?w_(a):[...Tp,...b_].includes(a.key)?v_(a.key):a.key==="Escape"&&C_(a,t,n)))},S_=(t,a)=>{if(!Gr(a.allowEnterKey))return;const n=Xe();if(!n||!a.input)return;const r=Zr(n,a.input);if(t.target&&r&&t.target instanceof HTMLElement&&t.target.outerHTML===r.outerHTML){if(["textarea","file"].includes(a.input))return;_p(),t.preventDefault()}},w_=t=>{const a=t.target,r=Bo().findIndex(l=>l===a);let o=!0;t.shiftKey?o=to(r,-1):o=to(r,1),t.stopPropagation(),o&&t.preventDefault()},v_=t=>{const a=_s(),n=ia(),r=Za(),o=In();if(!a||!n||!r||!o)return;const l=[n,r,o];if(document.activeElement instanceof HTMLElement&&!l.includes(document.activeElement))return;const d=Tp.includes(t)?"nextElementSibling":"previousElementSibling";let c=document.activeElement;if(c){for(let h=0;h<a.children.length;h++){if(c=c[d],!c)return;if(c instanceof HTMLButtonElement&&Bt(c))break}c instanceof HTMLButtonElement&&c.focus()}},C_=(t,a,n)=>{t.preventDefault(),Gr(a.allowEscapeKey)&&n(Mn.esc)};var vn={swalPromiseResolve:new WeakMap,swalPromiseReject:new WeakMap};const __=()=>{const t=Mt();Array.from(document.body.children).forEach(n=>{n.contains(t)||(n.hasAttribute("aria-hidden")&&n.setAttribute("data-previous-aria-hidden",n.getAttribute("aria-hidden")||""),n.setAttribute("aria-hidden","true"))})},Dp=()=>{Array.from(document.body.children).forEach(a=>{a.hasAttribute("data-previous-aria-hidden")?(a.setAttribute("aria-hidden",a.getAttribute("data-previous-aria-hidden")||""),a.removeAttribute("data-previous-aria-hidden")):a.removeAttribute("aria-hidden")})},Wo=typeof window<"u"&&!!window.GestureEvent,A_=Wo&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,T_=()=>{if(Wo&&!ha(document.body,ue.iosfix)){const t=document.body.scrollTop;document.body.style.top=`${t*-1}px`,Qe(document.body,ue.iosfix),D_()}},D_=()=>{const t=Mt();if(!t)return;let a;t.ontouchstart=n=>{a=k_(n)},t.ontouchmove=n=>{a&&(n.preventDefault(),n.stopPropagation())}},k_=t=>{const a=t.target,n=Mt(),r=Oo();return!n||!r||R_(t)||I_(t)?!1:a===n||!eo(n)&&a instanceof HTMLElement&&!TC(a,r)&&a.tagName!=="INPUT"&&a.tagName!=="TEXTAREA"&&!(eo(r)&&r.contains(a))},R_=t=>!!(t.touches&&t.touches.length&&t.touches[0].touchType==="stylus"),I_=t=>t.touches&&t.touches.length>1,P_=()=>{if(ha(document.body,ue.iosfix)){const t=parseInt(document.body.style.top,10);Gt(document.body,ue.iosfix),document.body.style.top="",document.body.scrollTop=t*-1}},M_=()=>{const t=document.createElement("div");t.className=ue["scrollbar-measure"],document.body.appendChild(t);const a=t.getBoundingClientRect().width-t.clientWidth;return document.body.removeChild(t),a};let yn=null;const E_=t=>{yn===null&&(document.body.scrollHeight>window.innerHeight||t==="scroll")&&(yn=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right")),document.body.style.paddingRight=`${yn+M_()}px`)},O_=()=>{yn!==null&&(document.body.style.paddingRight=`${yn}px`,yn=null)};function kp(t,a,n,r){Xr()?fc(t,r):(gC(n).then(()=>fc(t,r)),Ap(Ee)),Wo?(a.setAttribute("style","display:none !important"),a.removeAttribute("class"),a.innerHTML=""):a.remove(),Lo()&&(O_(),P_(),Dp()),$_()}function $_(){Gt([document.documentElement,document.body],[ue.shown,ue["height-auto"],ue["no-backdrop"],ue["toast-shown"]])}function _a(t){t=B_(t);const a=vn.swalPromiseResolve.get(this),n=F_(this);this.isAwaitingPromise?t.isDismissed||(Ds(this),a(t)):n&&a(t)}const F_=t=>{const a=Xe();if(!a)return!1;const n=nt.innerParams.get(t);if(!n||ha(a,n.hideClass.popup))return!1;Gt(a,n.showClass.popup),Qe(a,n.hideClass.popup);const r=Mt();return Gt(r,n.showClass.backdrop),Qe(r,n.hideClass.backdrop),L_(t,a,n),!0};function Rp(t){const a=vn.swalPromiseReject.get(this);Ds(this),a&&a(t)}const Ds=t=>{t.isAwaitingPromise&&(delete t.isAwaitingPromise,nt.innerParams.get(t)||t._destroy())},B_=t=>typeof t>"u"?{isConfirmed:!1,isDenied:!1,isDismissed:!0}:Object.assign({isConfirmed:!1,isDenied:!1,isDismissed:!1},t),L_=(t,a,n)=>{var r;const o=Mt(),l=gp(a);typeof n.willClose=="function"&&n.willClose(a),(r=Ee.eventEmitter)===null||r===void 0||r.emit("willClose",a),l&&o?U_(t,a,o,!!n.returnFocus,n.didClose):o&&kp(t,o,!!n.returnFocus,n.didClose)},U_=(t,a,n,r,o)=>{Ee.swalCloseEventFinishedCallback=kp.bind(null,t,n,r,o);const l=function(d){if(d.target===a){var c;(c=Ee.swalCloseEventFinishedCallback)===null||c===void 0||c.call(Ee),delete Ee.swalCloseEventFinishedCallback,a.removeEventListener("animationend",l),a.removeEventListener("transitionend",l)}};a.addEventListener("animationend",l),a.addEventListener("transitionend",l)},fc=(t,a)=>{setTimeout(()=>{var n;typeof a=="function"&&a.bind(t.params)(),(n=Ee.eventEmitter)===null||n===void 0||n.emit("didClose"),t._destroy&&t._destroy()})},Cn=t=>{let a=Xe();if(a||new Rr,a=Xe(),!a)return;const n=Pn();Xr()?Rt(Rn()):N_(a,t),wt(n),a.setAttribute("data-loading","true"),a.setAttribute("aria-busy","true"),a.focus()},N_=(t,a)=>{const n=_s(),r=Pn();!n||!r||(!a&&Bt(ia())&&(a=ia()),wt(n),a&&(Rt(a),r.setAttribute("data-button-to-replace",a.className),n.insertBefore(r,a)),Qe([t,n],ue.loading))},z_=(t,a)=>{a.input==="select"||a.input==="radio"?H_(t,a):["text","email","number","tel","textarea"].some(n=>n===a.input)&&(Mo(a.inputValue)||Eo(a.inputValue))&&(Cn(ia()),K_(t,a))},q_=(t,a)=>{const n=t.getInput();if(!n)return null;switch(a.input){case"checkbox":return Y_(n);case"radio":return W_(n);case"file":return V_(n);default:return a.inputAutoTrim?n.value.trim():n.value}},Y_=t=>t.checked?1:0,W_=t=>t.checked?t.value:null,V_=t=>t.files&&t.files.length?t.getAttribute("multiple")!==null?t.files:t.files[0]:null,H_=(t,a)=>{const n=Xe();if(!n)return;const r=o=>{a.input==="select"?G_(n,ao(o),a):a.input==="radio"&&J_(n,ao(o),a)};Mo(a.inputOptions)||Eo(a.inputOptions)?(Cn(ia()),vs(a.inputOptions).then(o=>{t.hideLoading(),r(o)})):typeof a.inputOptions=="object"?r(a.inputOptions):Xa(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof a.inputOptions}`)},K_=(t,a)=>{const n=t.getInput();n&&(Rt(n),vs(a.inputValue).then(r=>{n.value=a.input==="number"?`${parseFloat(r)||0}`:`${r}`,wt(n),n.focus(),t.hideLoading()}).catch(r=>{Xa(`Error in inputValue promise: ${r}`),n.value="",wt(n),n.focus(),t.hideLoading()}))};function G_(t,a,n){const r=Ca(t,ue.select);if(!r)return;const o=(l,d,c)=>{const h=document.createElement("option");h.value=c,Wt(h,d),h.selected=Ip(c,n.inputValue),l.appendChild(h)};a.forEach(l=>{const d=l[0],c=l[1];if(Array.isArray(c)){const h=document.createElement("optgroup");h.label=d,h.disabled=!1,r.appendChild(h),c.forEach(f=>o(h,f[1],f[0]))}else o(r,c,d)}),r.focus()}function J_(t,a,n){const r=Ca(t,ue.radio);if(!r)return;a.forEach(l=>{const d=l[0],c=l[1],h=document.createElement("input"),f=document.createElement("label");h.type="radio",h.name=ue.radio,h.value=d,Ip(d,n.inputValue)&&(h.checked=!0);const p=document.createElement("span");Wt(p,c),p.className=ue.label,f.appendChild(h),f.appendChild(p),r.appendChild(f)});const o=r.querySelectorAll("input");o.length&&o[0].focus()}const ao=t=>(t instanceof Map?Array.from(t):Object.entries(t)).map(([n,r])=>[n,typeof r=="object"?ao(r):r]),Ip=(t,a)=>!!a&&a!=null&&a.toString()===t.toString(),Q_=t=>{const a=nt.innerParams.get(t);t.disableButtons(),a.input?Pp(t,"confirm"):Ho(t,!0)},X_=t=>{const a=nt.innerParams.get(t);t.disableButtons(),a.returnInputValueOnDeny?Pp(t,"deny"):Vo(t,!1)},Z_=(t,a)=>{t.disableButtons(),a(Mn.cancel)},Pp=(t,a)=>{const n=nt.innerParams.get(t);if(!n.input){Xa(`The "input" parameter is needed to be set when using returnInputValueOn${Po(a)}`);return}const r=t.getInput(),o=q_(t,n);n.inputValidator?e2(t,o,a):r&&!r.checkValidity()?(t.enableButtons(),t.showValidationMessage(n.validationMessage||r.validationMessage)):a==="deny"?Vo(t,o):Ho(t,o)},e2=(t,a,n)=>{const r=nt.innerParams.get(t);t.disableInput(),Promise.resolve().then(()=>vs(r.inputValidator(a,r.validationMessage))).then(l=>{t.enableButtons(),t.enableInput(),l?t.showValidationMessage(l):n==="deny"?Vo(t,a):Ho(t,a)})},Vo=(t,a)=>{const n=nt.innerParams.get(t);n.showLoaderOnDeny&&Cn(Za()),n.preDeny?(t.isAwaitingPromise=!0,Promise.resolve().then(()=>vs(n.preDeny(a,n.validationMessage))).then(o=>{o===!1?(t.hideLoading(),Ds(t)):t.close({isDenied:!0,value:typeof o>"u"?a:o})}).catch(o=>Mp(t,o))):t.close({isDenied:!0,value:a})},gc=(t,a)=>{t.close({isConfirmed:!0,value:a})},Mp=(t,a)=>{t.rejectPromise(a)},Ho=(t,a)=>{const n=nt.innerParams.get(t);n.showLoaderOnConfirm&&Cn(),n.preConfirm?(t.resetValidationMessage(),t.isAwaitingPromise=!0,Promise.resolve().then(()=>vs(n.preConfirm(a,n.validationMessage))).then(o=>{Bt(Jr())||o===!1?(t.hideLoading(),Ds(t)):gc(t,typeof o>"u"?a:o)}).catch(o=>Mp(t,o))):gc(t,a)};function Tr(){const t=nt.innerParams.get(this);if(!t)return;const a=nt.domCache.get(this);Rt(a.loader),Xr()?t.icon&&wt(Rn()):t2(a),Gt([a.popup,a.actions],ue.loading),a.popup.removeAttribute("aria-busy"),a.popup.removeAttribute("data-loading"),this.enableButtons()}const t2=t=>{const a=t.loader.getAttribute("data-button-to-replace"),n=a?t.popup.getElementsByClassName(a):[];n.length?wt(n[0],"inline-block"):AC()&&Rt(t.actions)};function Ep(){const t=nt.innerParams.get(this),a=nt.domCache.get(this);return a?Zr(a.popup,t.input):null}function Op(t,a,n){const r=nt.domCache.get(t);a.forEach(o=>{r[o].disabled=n})}function $p(t,a){const n=Xe();!n||!t||(t.type==="radio"?n.querySelectorAll(`[name="${ue.radio}"]`).forEach(o=>{o.disabled=a}):t.disabled=a)}function Fp(){Op(this,["confirmButton","denyButton","cancelButton"],!1);const t=nt.focusedElement.get(this);t instanceof HTMLElement&&document.activeElement===document.body&&t.focus(),nt.focusedElement.delete(this)}function Bp(){nt.focusedElement.set(this,document.activeElement),Op(this,["confirmButton","denyButton","cancelButton"],!0)}function Lp(){$p(this.getInput(),!1)}function Up(){$p(this.getInput(),!0)}function Np(t){const a=nt.domCache.get(this),n=nt.innerParams.get(this);Wt(a.validationMessage,t),a.validationMessage.className=ue["validation-message"],n.customClass&&n.customClass.validationMessage&&Qe(a.validationMessage,n.customClass.validationMessage),wt(a.validationMessage);const r=this.getInput();r&&(r.setAttribute("aria-invalid","true"),r.setAttribute("aria-describedby",ue["validation-message"]),hp(r),Qe(r,ue.inputerror))}function zp(){const t=nt.domCache.get(this);t.validationMessage&&Rt(t.validationMessage);const a=this.getInput();a&&(a.removeAttribute("aria-invalid"),a.removeAttribute("aria-describedby"),Gt(a,ue.inputerror))}const Aa={title:"",titleText:"",text:"",html:"",footer:"",icon:void 0,iconColor:void 0,iconHtml:void 0,template:void 0,toast:!1,draggable:!1,animation:!0,theme:"light",showClass:{popup:"swal2-show",backdrop:"swal2-backdrop-show",icon:"swal2-icon-show"},hideClass:{popup:"swal2-hide",backdrop:"swal2-backdrop-hide",icon:"swal2-icon-hide"},customClass:{},target:"body",color:void 0,backdrop:!0,heightAuto:!0,allowOutsideClick:!0,allowEscapeKey:!0,allowEnterKey:!0,stopKeydownPropagation:!0,keydownListenerCapture:!1,showConfirmButton:!0,showDenyButton:!1,showCancelButton:!1,preConfirm:void 0,preDeny:void 0,confirmButtonText:"OK",confirmButtonAriaLabel:"",confirmButtonColor:void 0,denyButtonText:"No",denyButtonAriaLabel:"",denyButtonColor:void 0,cancelButtonText:"Cancel",cancelButtonAriaLabel:"",cancelButtonColor:void 0,buttonsStyling:!0,reverseButtons:!1,focusConfirm:!0,focusDeny:!1,focusCancel:!1,returnFocus:!0,showCloseButton:!1,closeButtonHtml:"×",closeButtonAriaLabel:"Close this dialog",loaderHtml:"",showLoaderOnConfirm:!1,showLoaderOnDeny:!1,imageUrl:void 0,imageWidth:void 0,imageHeight:void 0,imageAlt:"",timer:void 0,timerProgressBar:!1,width:void 0,padding:void 0,background:void 0,input:void 0,inputPlaceholder:"",inputLabel:"",inputValue:"",inputOptions:{},inputAutoFocus:!0,inputAutoTrim:!0,inputAttributes:{},inputValidator:void 0,returnInputValueOnDeny:!1,validationMessage:void 0,grow:!1,position:"center",progressSteps:[],currentProgressStep:void 0,progressStepsDistance:void 0,willOpen:void 0,didOpen:void 0,didRender:void 0,willClose:void 0,didClose:void 0,didDestroy:void 0,scrollbarPadding:!0,topLayer:!1},a2=["allowEscapeKey","allowOutsideClick","background","buttonsStyling","cancelButtonAriaLabel","cancelButtonColor","cancelButtonText","closeButtonAriaLabel","closeButtonHtml","color","confirmButtonAriaLabel","confirmButtonColor","confirmButtonText","currentProgressStep","customClass","denyButtonAriaLabel","denyButtonColor","denyButtonText","didClose","didDestroy","draggable","footer","hideClass","html","icon","iconColor","iconHtml","imageAlt","imageHeight","imageUrl","imageWidth","preConfirm","preDeny","progressSteps","returnFocus","reverseButtons","showCancelButton","showCloseButton","showConfirmButton","showDenyButton","text","title","titleText","theme","willClose"],n2={allowEnterKey:void 0},s2=["allowOutsideClick","allowEnterKey","backdrop","draggable","focusConfirm","focusDeny","focusCancel","returnFocus","heightAuto","keydownListenerCapture"],qp=t=>Object.prototype.hasOwnProperty.call(Aa,t),Yp=t=>a2.indexOf(t)!==-1,Wp=t=>n2[t],r2=t=>{qp(t)||Pt(`Unknown parameter "${t}"`)},i2=t=>{s2.includes(t)&&Pt(`The parameter "${t}" is incompatible with toasts`)},o2=t=>{const a=Wp(t);a&&cp(t,a)},Vp=t=>{t.backdrop===!1&&t.allowOutsideClick&&Pt('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`'),t.theme&&!["light","dark","auto","minimal","borderless","bootstrap-4","bootstrap-4-light","bootstrap-4-dark","bootstrap-5","bootstrap-5-light","bootstrap-5-dark","material-ui","material-ui-light","material-ui-dark","embed-iframe","bulma","bulma-light","bulma-dark"].includes(t.theme)&&Pt(`Invalid theme "${t.theme}"`);for(const a in t)r2(a),t.toast&&i2(a),o2(a)};function Hp(t){const a=Mt(),n=Xe(),r=nt.innerParams.get(this);if(!n||ha(n,r.hideClass.popup)){Pt("You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.");return}const o=l2(t),l=Object.assign({},r,o);Vp(l),a&&(a.dataset.swal2Theme=l.theme),Cp(this,l),nt.innerParams.set(this,l),Object.defineProperties(this,{params:{value:Object.assign({},this.params,t),writable:!1,enumerable:!0}})}const l2=t=>{const a={};return Object.keys(t).forEach(n=>{if(Yp(n)){const r=t;a[n]=r[n]}else Pt(`Invalid parameter to update: ${n}`)}),a};function Kp(){var t;const a=nt.domCache.get(this),n=nt.innerParams.get(this);if(!n){Gp(this);return}a.popup&&Ee.swalCloseEventFinishedCallback&&(Ee.swalCloseEventFinishedCallback(),delete Ee.swalCloseEventFinishedCallback),typeof n.didDestroy=="function"&&n.didDestroy(),(t=Ee.eventEmitter)===null||t===void 0||t.emit("didDestroy"),d2(this)}const d2=t=>{Gp(t),delete t.params,delete Ee.keydownHandler,delete Ee.keydownTarget,delete Ee.currentInstance},Gp=t=>{t.isAwaitingPromise?(Ui(nt,t),t.isAwaitingPromise=!0):(Ui(vn,t),Ui(nt,t),delete t.isAwaitingPromise,delete t.disableButtons,delete t.enableButtons,delete t.getInput,delete t.disableInput,delete t.enableInput,delete t.hideLoading,delete t.disableLoading,delete t.showValidationMessage,delete t.resetValidationMessage,delete t.close,delete t.closePopup,delete t.closeModal,delete t.closeToast,delete t.rejectPromise,delete t.update,delete t._destroy)},Ui=(t,a)=>{for(const n in t)t[n].delete(a)};var c2=Object.freeze({__proto__:null,_destroy:Kp,close:_a,closeModal:_a,closePopup:_a,closeToast:_a,disableButtons:Bp,disableInput:Up,disableLoading:Tr,enableButtons:Fp,enableInput:Lp,getInput:Ep,handleAwaitingPromise:Ds,hideLoading:Tr,rejectPromise:Rp,resetValidationMessage:zp,showValidationMessage:Np,update:Hp});const u2=(t,a,n)=>{t.toast?p2(t,a,n):(h2(a),f2(a),g2(t,a,n))},p2=(t,a,n)=>{a.popup.onclick=()=>{t&&(m2(t)||t.timer||t.input)||n(Mn.close)}},m2=t=>!!(t.showConfirmButton||t.showDenyButton||t.showCancelButton||t.showCloseButton);let Dr=!1;const h2=t=>{t.popup.onmousedown=()=>{t.container.onmouseup=function(a){t.container.onmouseup=()=>{},a.target===t.container&&(Dr=!0)}}},f2=t=>{t.container.onmousedown=a=>{a.target===t.container&&a.preventDefault(),t.popup.onmouseup=function(n){t.popup.onmouseup=()=>{},(n.target===t.popup||n.target instanceof HTMLElement&&t.popup.contains(n.target))&&(Dr=!0)}}},g2=(t,a,n)=>{a.container.onclick=r=>{if(Dr){Dr=!1;return}r.target===a.container&&Gr(t.allowOutsideClick)&&n(Mn.backdrop)}},y2=t=>typeof t=="object"&&t!==null&&"jquery"in t,yc=t=>t instanceof Element||y2(t),x2=t=>{const a={};return typeof t[0]=="object"&&!yc(t[0])?Object.assign(a,t[0]):["title","html","icon"].forEach((n,r)=>{const o=t[r];typeof o=="string"||yc(o)?a[n]=o:o!==void 0&&Xa(`Unexpected type of ${n}! Expected "string" or "Element", got ${typeof o}`)}),a};function b2(...t){return new this(...t)}function j2(t){class a extends this{_main(r,o){return super._main(r,Object.assign({},t,o))}}return a}const S2=()=>Ee.timeout&&Ee.timeout.getTimerLeft(),Jp=()=>{if(Ee.timeout)return DC(),Ee.timeout.stop()},Qp=()=>{if(Ee.timeout){const t=Ee.timeout.start();return No(t),t}},w2=()=>{const t=Ee.timeout;return t&&(t.running?Jp():Qp())},v2=t=>{if(Ee.timeout){const a=Ee.timeout.increase(t);return No(a,!0),a}},C2=()=>!!(Ee.timeout&&Ee.timeout.isRunning());let xc=!1;const no={};function _2(t="data-swal-template"){no[t]=this,xc||(document.body.addEventListener("click",A2),xc=!0)}const A2=t=>{for(let a=t.target;a&&a!==document;a=a.parentNode)for(const n in no){const r=a.getAttribute&&a.getAttribute(n);if(r){no[n].fire({template:r});return}}};class T2{constructor(){this.events={}}_getHandlersByEventName(a){return typeof this.events[a]>"u"&&(this.events[a]=[]),this.events[a]}on(a,n){const r=this._getHandlersByEventName(a);r.includes(n)||r.push(n)}once(a,n){const r=(...o)=>{this.removeListener(a,r),n.apply(this,o)};this.on(a,r)}emit(a,...n){this._getHandlersByEventName(a).forEach(r=>{try{r.apply(this,n)}catch(o){console.error(o)}})}removeListener(a,n){const r=this._getHandlersByEventName(a),o=r.indexOf(n);o>-1&&r.splice(o,1)}removeAllListeners(a){this.events[a]!==void 0&&(this.events[a].length=0)}reset(){this.events={}}}Ee.eventEmitter=new T2;const D2=(t,a)=>{Ee.eventEmitter&&Ee.eventEmitter.on(t,a)},k2=(t,a)=>{Ee.eventEmitter&&Ee.eventEmitter.once(t,a)},R2=(t,a)=>{if(Ee.eventEmitter){if(!t){Ee.eventEmitter.reset();return}a?Ee.eventEmitter.removeListener(t,a):Ee.eventEmitter.removeAllListeners(t)}};var I2=Object.freeze({__proto__:null,argsToParams:x2,bindClickHandler:_2,clickCancel:y_,clickConfirm:_p,clickDeny:g_,enableLoading:Cn,fire:b2,getActions:_s,getCancelButton:In,getCloseButton:Fo,getConfirmButton:ia,getContainer:Mt,getDenyButton:Za,getFocusableElements:Bo,getFooter:mp,getHtmlContainer:Oo,getIcon:Rn,getIconContent:SC,getImage:pp,getInputLabel:wC,getLoader:Pn,getPopup:Xe,getProgressSteps:$o,getTimerLeft:S2,getTimerProgressBar:Qr,getTitle:up,getValidationMessage:Jr,increaseTimer:v2,isDeprecatedParameter:Wp,isLoading:CC,isTimerRunning:C2,isUpdatableParameter:Yp,isValidParameter:qp,isVisible:f_,mixin:j2,off:R2,on:D2,once:k2,resumeTimer:Qp,showLoading:Cn,stopTimer:Jp,toggleTimer:w2});class P2{constructor(a,n){this.callback=a,this.remaining=n,this.running=!1,this.start()}start(){return this.running||(this.running=!0,this.started=new Date,this.id=setTimeout(this.callback,this.remaining)),this.remaining}stop(){return this.started&&this.running&&(this.running=!1,clearTimeout(this.id),this.remaining-=new Date().getTime()-this.started.getTime()),this.remaining}increase(a){const n=this.running;return n&&this.stop(),this.remaining+=a,n&&this.start(),this.remaining}getTimerLeft(){return this.running&&(this.stop(),this.start()),this.remaining}isRunning(){return this.running}}const Xp=["swal-title","swal-html","swal-footer"],M2=t=>{const a=typeof t.template=="string"?document.querySelector(t.template):t.template;if(!a)return{};const n=a.content;return N2(n),Object.assign(E2(n),O2(n),$2(n),F2(n),B2(n),L2(n),U2(n,Xp))},E2=t=>{const a={};return Array.from(t.querySelectorAll("swal-param")).forEach(r=>{Ha(r,["name","value"]);const o=r.getAttribute("name"),l=r.getAttribute("value");!o||!l||(o in Aa&&typeof Aa[o]=="boolean"?a[o]=l!=="false":o in Aa&&typeof Aa[o]=="object"?a[o]=JSON.parse(l):a[o]=l)}),a},O2=t=>{const a={};return Array.from(t.querySelectorAll("swal-function-param")).forEach(r=>{const o=r.getAttribute("name"),l=r.getAttribute("value");!o||!l||(a[o]=new Function(`return ${l}`)())}),a},$2=t=>{const a={};return Array.from(t.querySelectorAll("swal-button")).forEach(r=>{Ha(r,["type","color","aria-label"]);const o=r.getAttribute("type");if(!o||!["confirm","cancel","deny"].includes(o))return;a[`${o}ButtonText`]=r.innerHTML,a[`show${Po(o)}Button`]=!0;const l=r.getAttribute("color");l!==null&&(a[`${o}ButtonColor`]=l);const d=r.getAttribute("aria-label");d!==null&&(a[`${o}ButtonAriaLabel`]=d)}),a},F2=t=>{const a={},n=t.querySelector("swal-image");if(n){Ha(n,["src","width","height","alt"]);const r=n.getAttribute("src");r!==null&&(a.imageUrl=r||void 0);const o=n.getAttribute("width");o!==null&&(a.imageWidth=o||void 0);const l=n.getAttribute("height");l!==null&&(a.imageHeight=l||void 0);const d=n.getAttribute("alt");d!==null&&(a.imageAlt=d||void 0)}return a},B2=t=>{const a={},n=t.querySelector("swal-icon");return n&&(Ha(n,["type","color"]),n.hasAttribute("type")&&(a.icon=n.getAttribute("type")),n.hasAttribute("color")&&(a.iconColor=n.getAttribute("color")),a.iconHtml=n.innerHTML),a},L2=t=>{const a={},n=t.querySelector("swal-input");n&&(Ha(n,["type","label","placeholder","value"]),a.input=n.getAttribute("type")||"text",n.hasAttribute("label")&&(a.inputLabel=n.getAttribute("label")),n.hasAttribute("placeholder")&&(a.inputPlaceholder=n.getAttribute("placeholder")),n.hasAttribute("value")&&(a.inputValue=n.getAttribute("value")));const r=Array.from(t.querySelectorAll("swal-input-option"));return r.length&&(a.inputOptions={},r.forEach(o=>{Ha(o,["value"]);const l=o.getAttribute("value");if(!l)return;const d=o.innerHTML;a.inputOptions[l]=d})),a},U2=(t,a)=>{const n={};for(const r in a){const o=a[r],l=t.querySelector(o);l&&(Ha(l,[]),n[o.replace(/^swal-/,"")]=l.innerHTML.trim())}return n},N2=t=>{const a=Xp.concat(["swal-param","swal-function-param","swal-button","swal-image","swal-icon","swal-input","swal-input-option"]);Array.from(t.children).forEach(n=>{const r=n.tagName.toLowerCase();a.includes(r)||Pt(`Unrecognized element <${r}>`)})},Ha=(t,a)=>{Array.from(t.attributes).forEach(n=>{a.indexOf(n.name)===-1&&Pt([`Unrecognized attribute "${n.name}" on <${t.tagName.toLowerCase()}>.`,`${a.length?`Allowed attributes are: ${a.join(", ")}`:"To set the value, use HTML within the element."}`])})},Zp=10,z2=t=>{var a,n;const r=Mt(),o=Xe();if(!r||!o)return;typeof t.willOpen=="function"&&t.willOpen(o),(a=Ee.eventEmitter)===null||a===void 0||a.emit("willOpen",o);const d=window.getComputedStyle(document.body).overflowY;if(W2(r,o,t),setTimeout(()=>{q2(r,o)},Zp),Lo()&&(Y2(r,t.scrollbarPadding!==void 0?t.scrollbarPadding:!1,d),__()),A_&&t.backdrop===!1&&o.scrollHeight>r.clientHeight&&(r.style.pointerEvents="auto"),!Xr()&&!Ee.previousActiveElement&&(Ee.previousActiveElement=document.activeElement),typeof t.didOpen=="function"){const c=t.didOpen;setTimeout(()=>c(o))}(n=Ee.eventEmitter)===null||n===void 0||n.emit("didOpen",o)},kr=t=>{const a=Xe();if(!a||t.target!==a)return;const n=Mt();n&&(a.removeEventListener("animationend",kr),a.removeEventListener("transitionend",kr),n.style.overflowY="auto",Gt(n,ue["no-transition"]))},q2=(t,a)=>{gp(a)?(t.style.overflowY="hidden",a.addEventListener("animationend",kr),a.addEventListener("transitionend",kr)):t.style.overflowY="auto"},Y2=(t,a,n)=>{T_(),a&&n!=="hidden"&&E_(n),setTimeout(()=>{t.scrollTop=0})},W2=(t,a,n)=>{var r;(r=n.showClass)!==null&&r!==void 0&&r.backdrop&&Qe(t,n.showClass.backdrop),n.animation?(a.style.setProperty("opacity","0","important"),wt(a,"grid"),setTimeout(()=>{var o;(o=n.showClass)!==null&&o!==void 0&&o.popup&&Qe(a,n.showClass.popup),a.style.removeProperty("opacity")},Zp)):wt(a,"grid"),Qe([document.documentElement,document.body],ue.shown),n.heightAuto&&n.backdrop&&!n.toast&&Qe([document.documentElement,document.body],ue["height-auto"])};var bc={email:(t,a)=>/^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(t)?Promise.resolve():Promise.resolve(a||"Invalid email address"),url:(t,a)=>/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(t)?Promise.resolve():Promise.resolve(a||"Invalid URL")};function V2(t){t.inputValidator||(t.input==="email"&&(t.inputValidator=bc.email),t.input==="url"&&(t.inputValidator=bc.url))}function H2(t){(!t.target||typeof t.target=="string"&&!document.querySelector(t.target)||typeof t.target!="string"&&!t.target.appendChild)&&(Pt('Target parameter is not valid, defaulting to "body"'),t.target="body")}function K2(t){V2(t),t.showLoaderOnConfirm&&!t.preConfirm&&Pt(`showLoaderOnConfirm is set to true, but preConfirm is not defined.
|
|
124
|
+
showLoaderOnConfirm should be used together with preConfirm, see usage example:
|
|
125
|
+
https://sweetalert2.github.io/#ajax-request`),H2(t),typeof t.title=="string"&&(t.title=t.title.split(`
|
|
126
|
+
`).join("<br />")),$C(t)}let sa;var Js=new WeakMap;class gt{constructor(...a){if(pC(this,Js,Promise.resolve({isConfirmed:!1,isDenied:!1,isDismissed:!0})),typeof window>"u")return;sa=this;const n=Object.freeze(this.constructor.argsToParams(a));this.params=n,this.isAwaitingPromise=!1,mC(Js,this,this._main(sa.params))}_main(a,n={}){if(Vp(Object.assign({},n,a)),Ee.currentInstance){const l=vn.swalPromiseResolve.get(Ee.currentInstance),{isAwaitingPromise:d}=Ee.currentInstance;Ee.currentInstance._destroy(),d||l({isDismissed:!0}),Lo()&&Dp()}Ee.currentInstance=sa;const r=J2(a,n);K2(r),Object.freeze(r),Ee.timeout&&(Ee.timeout.stop(),delete Ee.timeout),clearTimeout(Ee.restoreFocusTimeout);const o=Q2(sa);return Cp(sa,r),nt.innerParams.set(sa,r),G2(sa,o,r)}then(a){return dc(Js,this).then(a)}finally(a){return dc(Js,this).finally(a)}}const G2=(t,a,n)=>new Promise((r,o)=>{const l=d=>{t.close({isDismissed:!0,dismiss:d,isConfirmed:!1,isDenied:!1})};vn.swalPromiseResolve.set(t,r),vn.swalPromiseReject.set(t,o),a.confirmButton.onclick=()=>{Q_(t)},a.denyButton.onclick=()=>{X_(t)},a.cancelButton.onclick=()=>{Z_(t,l)},a.closeButton.onclick=()=>{l(Mn.close)},u2(n,a,l),x_(Ee,n,l),z_(t,n),z2(n),X2(Ee,n,l),Z2(a,n),setTimeout(()=>{a.container.scrollTop=0})}),J2=(t,a)=>{const n=M2(t),r=Object.assign({},Aa,a,n,t);return r.showClass=Object.assign({},Aa.showClass,r.showClass),r.hideClass=Object.assign({},Aa.hideClass,r.hideClass),r.animation===!1&&(r.showClass={backdrop:"swal2-noanimation"},r.hideClass={}),r},Q2=t=>{const a={popup:Xe(),container:Mt(),actions:_s(),confirmButton:ia(),denyButton:Za(),cancelButton:In(),loader:Pn(),closeButton:Fo(),validationMessage:Jr(),progressSteps:$o()};return nt.domCache.set(t,a),a},X2=(t,a,n)=>{const r=Qr();Rt(r),a.timer&&(t.timeout=new P2(()=>{n("timer"),delete t.timeout},a.timer),a.timerProgressBar&&r&&(wt(r),zt(r,a,"timerProgressBar"),setTimeout(()=>{t.timeout&&t.timeout.running&&No(a.timer)})))},Z2=(t,a)=>{if(!a.toast){if(!Gr(a.allowEnterKey)){cp("allowEnterKey","preConfirm: () => false"),t.popup.focus();return}eA(t)||tA(t,a)||to(-1,1)}},eA=t=>{const a=Array.from(t.popup.querySelectorAll("[autofocus]"));for(const n of a)if(n instanceof HTMLElement&&Bt(n))return n.focus(),!0;return!1},tA=(t,a)=>a.focusDeny&&Bt(t.denyButton)?(t.denyButton.focus(),!0):a.focusCancel&&Bt(t.cancelButton)?(t.cancelButton.focus(),!0):a.focusConfirm&&Bt(t.confirmButton)?(t.confirmButton.focus(),!0):!1;gt.prototype.disableButtons=Bp;gt.prototype.enableButtons=Fp;gt.prototype.getInput=Ep;gt.prototype.disableInput=Up;gt.prototype.enableInput=Lp;gt.prototype.hideLoading=Tr;gt.prototype.disableLoading=Tr;gt.prototype.showValidationMessage=Np;gt.prototype.resetValidationMessage=zp;gt.prototype.close=_a;gt.prototype.closePopup=_a;gt.prototype.closeModal=_a;gt.prototype.closeToast=_a;gt.prototype.rejectPromise=Rp;gt.prototype.update=Hp;gt.prototype._destroy=Kp;Object.assign(gt,I2);Object.keys(c2).forEach(t=>{gt[t]=function(...a){if(sa&&sa[t])return sa[t](...a)}});gt.DismissReason=Mn;gt.version="11.26.25";const Rr=gt;Rr.default=Rr;typeof document<"u"&&(function(t,a){var n=t.createElement("style");if(t.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=a);else try{n.innerHTML=a}catch{n.innerText=a}})(document,':root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:auto}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:"top-start top top-end" "center-start center center-end" "bottom-start bottom-center bottom-end";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:"!";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:auto}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}');function aA({token:t}){const[a,n]=i.useState(!0),{data:r,isLoading:o}=q(t!=null?[We.admitCardSetting.get,t]:null,([h,f])=>W(h,f)),l=r?.data?.[0],d=async h=>{h.preventDefault();const f=new FormData(h.target);["subject_show","room_no","roll_no_convert","student_photo","student_address","ic_signature","invigilator_signature"].forEach(m=>{f.get(m)?f.set(m,1):f.append(m,0)});try{(await Ze(We.admitCardSetting.update,f,t))?.data?.Status==="Success"&&c()}catch{}},c=()=>{Rr.fire({icon:"success",title:"Successfully Updated",showConfirmButton:!1,timer:2e3})};return o?e.jsx(s.Spin,{}):e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Grid,{container:!0,spacing:6,children:e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Admit Card Setting"})}),e.jsx(w,{p:3,children:e.jsx(s.Form,{layout:"vertical",onFinish:d,children:e.jsxs(s.Grid,{container:!0,spacing:2,style:{marginTop:8},children:[e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Grid,{container:!0,spacing:2,children:[e.jsx(s.Grid,{item:!0,md:4,children:e.jsx(s.Typography.Text,{style:{fontSize:"14px",fontWeight:"bold",display:"block"},children:"Subject Show"})}),e.jsx(s.Grid,{item:!0,md:8,children:e.jsxs(s.Form.Item,{name:"subject_show",valuePropName:"checked",rules:[{required:!1}],children:[e.jsx(s.Switch,{defaultChecked:l?.subject_show==1}),e.jsx("label",{style:{marginLeft:"5px"},children:"Show Subject List in Admit Card"})]})})]})}),e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Grid,{container:!0,spacing:2,children:[e.jsx(s.Grid,{item:!0,md:4,children:e.jsx(s.Typography.Text,{style:{fontSize:"14px",fontWeight:"bold",display:"block"},children:"Room No"})}),e.jsx(s.Grid,{item:!0,md:8,children:e.jsxs(s.Form.Item,{name:"room_no",valuePropName:"checked",children:[e.jsx(s.Switch,{defaultChecked:l?.room_no==1}),e.jsx("label",{style:{marginLeft:"5px"},children:"Show Room No in Admit Card"})]})})]})}),e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Grid,{container:!0,spacing:2,children:[e.jsx(s.Grid,{item:!0,md:4,children:e.jsx(s.Typography.Text,{style:{fontSize:"14px",fontWeight:"bold",display:"block"},children:"Roll No"})}),e.jsx(s.Grid,{item:!0,md:8,children:e.jsxs(s.Form.Item,{name:"roll_no_convert",valuePropName:"checked",children:[e.jsx(s.Switch,{defaultChecked:l?.roll_no_convert==1}),e.jsx("label",{style:{marginLeft:"5px"},children:"Show Roll No in Admit Card"})]})})]})}),e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Grid,{container:!0,spacing:2,children:[e.jsx(s.Grid,{item:!0,md:4,children:e.jsx(s.Typography.Text,{style:{fontSize:"14px",fontWeight:"bold",display:"block"},children:"Student Photo"})}),e.jsx(s.Grid,{item:!0,md:8,children:e.jsxs(s.Form.Item,{name:"student_photo",valuePropName:"checked",children:[e.jsx(s.Switch,{defaultChecked:l?.student_photo==1}),e.jsx("label",{style:{marginLeft:"5px"},children:"Show Student Photo in Admit Card"})]})})]})}),e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Grid,{container:!0,spacing:2,children:[e.jsx(s.Grid,{item:!0,md:4,children:e.jsx(s.Typography.Text,{style:{fontSize:"14px",fontWeight:"bold",display:"block"},children:"Student Address"})}),e.jsx(s.Grid,{item:!0,md:8,children:e.jsxs(s.Form.Item,{name:"student_address",valuePropName:"checked",children:[e.jsx(s.Switch,{defaultChecked:l?.student_address==1}),e.jsx("label",{style:{marginLeft:"5px"},children:"Show Student Address in Admit Card"})]})})]})}),e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Grid,{container:!0,spacing:2,children:[e.jsx(s.Grid,{item:!0,md:4,children:e.jsx(s.Typography.Text,{style:{fontSize:"14px",fontWeight:"bold",display:"block"},children:"IC Signature"})}),e.jsx(s.Grid,{item:!0,md:8,children:e.jsxs(s.Form.Item,{name:"ic_signature",valuePropName:"checked",children:[e.jsx(s.Switch,{defaultChecked:l?.ic_signature==1}),e.jsx("label",{style:{marginLeft:"5px"},children:"Show IC Signature in Admit Card"})]})})]})}),e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Grid,{container:!0,spacing:2,children:[e.jsx(s.Grid,{item:!0,md:4,children:e.jsx(s.Typography.Text,{style:{fontSize:"14px",fontWeight:"bold",display:"block"},children:"Invigilator Signature"})}),e.jsx(s.Grid,{item:!0,md:8,children:e.jsxs(s.Form.Item,{name:"invigilator_signature",valuePropName:"checked",children:[e.jsx(s.Switch,{defaultChecked:l?.invigilator_signature==1}),e.jsx("label",{style:{marginLeft:"5px"},children:"Show Invigilator Signature in Admit Card"})]})})]})}),e.jsx(s.Grid,{item:!0,xs:12,children:e.jsx(de,{type:"submit",value:"Update",color:"primary"})})]})})})]})})})]})}function nA({token:t}){return e.jsx(aA,{token:t})}function sA({token:t}){const[a,n]=i.useState(!1),[r,o]=i.useState(null),[l,d]=i.useState(1),[c,h]=i.useState(!1),[f,p]=i.useState(!1),[m,v]=i.useState({pagination:{current:1,pageSize:2}}),[S,y]=i.useState(null),[g,b]=i.useState(!1),[D,R]=i.useState(null),[I,A]=i.useState([]),{fetchAllPagesWithProgress:_,isMutating:u}=usePaginatedFetcher(),[x,j]=i.useState(!1),[P,O]=i.useState({current:0,total:1}),[z,k]=i.useState(""),{isLoading:F,data:C}=q(t!=null?[oa,t]:null,([te,se])=>W(te,se)),[E,M]=i.useState({exam_id:""}),{isLoading:U,errorExam:Y,data:V}=q(r,W),{TextArea:L}=s.Input,{isLoading:B,error:$,data:N,mutate:H}=q(S!=null&&t!=null?[`${S}&page=${m.pagination.current}&per_page=${m.pagination.pageSize}`,t]:null,([te,se])=>W(te,se),{onSuccess:te=>{const se=Array.isArray(te?.data)?te.data:[];A(se)}}),{data:Q}=q(t!=null?["/branchapi/GeneralSettings/getassign_templete",t]:null,([te,se])=>W(te,se)),X=(te,se)=>{if(se==="class_id"){n(`${la}?class_id=${te.value}`),o(`${We.examDropdownUrl}?class_id=${te.value}`),h(Ce=>!Ce),b(Ce=>!Ce);const le=Q?.data?.find(Ce=>Ce.class_id===te.value);d(le?.ui_id||1)}},{isLoading:J,data:K}=q(a,W),Z=async te=>{te.preventDefault(),y(`${We.studentMarklistBulk}?class_id=${te.target.class_id.value}§ion_id=${te.target.section_id.value}&exam_id=${te.target.exam_id.value}`),d(te.target.template.value),k(te.target.exam_id.value),M(se=>({...se,exam_id:te.target.exam_id.value})),f||p(!0),te.target.reset()};i.useRef(null);const ee=Math.round(P.current/P.total*100),pe=async()=>{j(!0),R(null),O({current:0,total:Number(I.length)});const te=await _(I,z,(se,le)=>{O({current:se,total:le})});R(te),j(!1)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Grid,{container:!0,spacing:4,children:e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Student Result"})}),e.jsx(w,{p:3,children:e.jsxs(s.Grid,{container:!0,spacing:3,children:[e.jsx(s.Grid,{item:!0,xs:12,children:e.jsx("form",{onSubmit:Z,children:e.jsxs(s.Grid,{container:!0,spacing:3,children:[e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(ae,{required:!0,options:Array.isArray(C)?C:[],closeMenuOnSelect:!0,label:"Class",name:"class_id",onChange:te=>X(te,"class_id"),allowSelectAll:!1})}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(ae,{options:Array.isArray(K)?K:[],closeMenuOnSelect:!0,label:"Section",name:"section_id",allowSelectAll:!1},`section1${c}`)}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(ae,{options:Array.isArray(V)?V:[],closeMenuOnSelect:!0,label:"Exam",name:"exam_id",onChange:te=>{X(te,"exam_id"),k(te.value)},allowSelectAll:!1},`exam1${g}`)}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(s.Select,{defaultValue:l,style:{width:"100%"},onChange:te=>d(te),options:[{value:1,label:"Template 1"},{value:2,label:"Template 2"},{value:3,label:"Template 3"},{value:4,label:"Template 4"},{value:5,label:"Template 5"},{value:6,label:"Template 6"},{value:7,label:"Template 7"},{value:8,label:"Template 8"},{value:9,label:"Template 9"},{value:10,label:"Template 10"},{value:11,label:"Template 11"},{value:12,label:"Template 12"},{value:13,label:"Template 13"},{value:14,label:"Template 14"},{value:15,label:"Template 15"}]})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.5,children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),f&&e.jsxs(s.Grid,{item:!0,xs:12,style:{marginTop:16},children:[e.jsx(s.Button,{type:"primary",onClick:pe,loading:x,children:"Generate Report Cards"}),x&&e.jsx(s.Spin,{tip:`Generating... ${ee}%`,style:{marginLeft:16}})]}),f&&e.jsx(s.Grid,{item:!0,xs:12,style:{borderTop:"1px solid #ececec",borderTopWidth:"2px",marginTop:16},children:e.jsx(s.Table,{columns:[{title:"SL",dataIndex:"Sl_no",align:"center"},{title:"Student Name",dataIndex:"firstname",align:"center"},{title:"Full Marks",dataIndex:"full_marks",align:"center"},{title:"Marks Obtained",dataIndex:"marks_obtained",align:"center"},{title:"Percentage",dataIndex:"percentage",align:"center"},{title:"Attendance",dataIndex:"attendance",align:"center"}],dataSource:I,rowKey:"id",pagination:!1,bordered:!0,size:"small",loading:B})})]})})]})})})]})}function rA({token:t}){return e.jsx(sA,{token:t})}function iA({token:t}){const[a,n]=i.useState({page:0,rowsPerPage:1e3}),{isLoading:r,error:o,data:l,mutate:d}=q(t!=null?[We.examDropdown,t]:null,([c,h])=>W(c,h));return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Grid,{container:!0,spacing:6,children:e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Exam Dashboard"})}),e.jsx(w,{p:3,children:e.jsx(s.Table,{size:"small",bordered:!0,rowKey:"id",dataSource:l?.data??[],pagination:!1,loading:r})})]})})})]})}function oA({token:t}){return e.jsx(iA,{token:t})}function lA({token:t}){const n=new URLSearchParams(window.location.search).get("id"),r=i.useRef(!1),[o,l]=i.useState(null),[d,c]=i.useState([]),[h,f]=i.useState(!1),{data:p,isLoading:m,mutate:v}=q(t!=null&&n?[`${We.examSchedule.getById}?id=${n}`,t]:null,([u,x])=>W(u,x)),{data:S}=q(t!=null?[We.examType.dropdown,t]:null,([u,x])=>W(u,x)),{data:y}=q(t!=null&&o?[o,t]:null,([u,x])=>W(u,x)),[g,b]=i.useState({exam_name:"",classes_id:"",section_id:"",exam_type:"",start_date:"",end_date:"",class_name:"",schedule:[]});i.useEffect(()=>{if(!p?.data?.length||r.current)return;r.current=!0;const u=p.data,x=u.map(j=>({subject:j.subjects_id??"",classes_id:j.classes_id??"",fk_section_id:j.fk_section_id??"",date:j.date_of_exam??"",start_time:j.start_to??"09:00",end_time:j.end_from??"10:00",full_marks:j.paper_type==="Theory"?j.full_marks:j.practical_full_marks??"",passing_marks:j.paper_type==="Theory"?j.passing_marks:j.practical_pass_marks??"",paper_type:j.paper_type??"",row_type:"old"}));b({exam_name:u[0].name,classes_id:u[0].classes_id,section_id:u[0].fk_section_id,exam_type:u[0].exam_type_id,start_date:u[0].start_date,end_date:u[0].end_date,class_name:u[0].class,schedule:x}),u[0].classes_id&&l(`${Fr}?class_id=${u[0].classes_id}`),f(!0)},[p]);const D=(u,x,j)=>{b(P=>{const O=[...P.schedule];return O[u][x]=j,{...P,schedule:O}})},R=(u,x)=>{if(g.schedule.some((P,O)=>P.subject===x.value&&O!==u)){s.notification.error({message:"Error",description:"Subject already exists in schedule!"});return}c(P=>P.filter(O=>O!==x.value)),x.is_theory==="yes"&&x.is_practical==="yes"&&b(P=>({...P,schedule:[...P.schedule,{subject:x.value,date:P.start_date,start_time:"09:00",end_time:"10:00",full_marks:"",passing_marks:"",paper_type:"Practical",row_type:"new"}]})),D(u,"subject",x.value),D(u,"paper_type",x.is_theory==="yes"?"Theory":"Practical")},I=()=>{b(u=>({...u,schedule:[...u.schedule,{subject:"",date:u.start_date,start_time:"09:00",end_time:"10:00",full_marks:"",passing_marks:"",paper_type:"",row_type:"new"}]}))},A=u=>{const x=g.schedule[u].subject;g.schedule[u].row_type==="old"&&c(j=>[...j,x]),b(j=>{const P=j.schedule.filter(O=>O.subject!==x);return{...j,schedule:P}})},_=async u=>{u.preventDefault();const x={id:n,exam_name:g.exam_name,exam_type:g.exam_type,start_date:g.start_date,end_date:g.end_date,class_name:g.class_name,classes_id:g.classes_id,section_id:g.section_id,schedule:g.schedule.map(j=>({subjects_id:j.subject,date_of_exam:j.date,start_to:j.start_time,end_from:j.end_time,full_marks:j.full_marks,passing_marks:j.passing_marks,paper_type:j.paper_type})),deleted_subjects:d};try{const j=await Ze("exam/exam/editExamSchedule",x,t);v(),j?s.notification.success({message:"Success",description:"Updated Successfully"}):s.notification.error({message:"Error",description:"Failed"})}catch{s.notification.error({message:"Error",description:"Failed"})}};return m||!S||!h?e.jsx("p",{children:"Loading..."}):e.jsx(w,{pt:6,children:e.jsxs(s.Card,{children:[e.jsx(w,{p:2,bgcolor:"info",borderRadius:2,children:e.jsx(he,{color:"white",variant:"h6",children:"Edit Exam"})}),e.jsx(w,{p:3,children:e.jsxs("form",{onSubmit:_,children:[e.jsxs(s.Grid,{container:!0,spacing:2,children:[e.jsx(s.Grid,{item:!0,xs:12,md:3,children:e.jsx(G,{label:"Exam Name",value:g.exam_name,onChange:u=>b({...g,exam_name:u.target.value})})}),e.jsx(s.Grid,{item:!0,xs:12,md:3,children:e.jsx(ae,{label:"Exam Type",options:S,isDisabled:!0,value:S.find(u=>u.value===g.exam_type),onChange:u=>b({...g,exam_type:u?.value})})}),e.jsx(s.Grid,{item:!0,xs:12,md:3,children:e.jsx(Ge,{label:"Start Date",defaultValue:ne(g?.start_date,"YYYY-MM-DD"),onChange:u=>b({...g,start_date:ne(u).format("YYYY-MM-DD")})})}),e.jsx(s.Grid,{item:!0,xs:12,md:3,children:e.jsx(Ge,{label:"End Date",defaultValue:ne(g?.end_date,"YYYY-MM-DD"),onChange:u=>b({...g,end_date:ne(u).format("YYYY-MM-DD")})})}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(s.Button,{fullWidth:!0,type:"primary",onClick:I,children:"Add Row"})})]}),e.jsx(w,{mt:3,children:g.schedule.map((u,x)=>{const j=g.schedule.findIndex(O=>O.subject===u.subject),P=x===g.schedule.length-1||g.schedule[x+1].subject!==u.subject;return e.jsxs(i.Fragment,{children:[e.jsxs(s.Grid,{container:!0,spacing:1,alignItems:"center",style:{padding:"8px"},children:[e.jsx(s.Grid,{item:!0,xs:12,md:2,children:u.subject&&j!==x?e.jsx("span",{style:{visibility:"hidden"},children:"-"}):u.subject?e.jsx("strong",{children:(y||[]).find(O=>O.value===u.subject)?.label}):e.jsx(ae,{label:"Subject",options:y||[],value:(y||[]).find(O=>O.value===u.subject)||null,onChange:O=>R(x,O)})}),e.jsx(s.Grid,{item:!0,xs:12,md:1,children:u.paper_type}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(Ge,{label:"Date",defaultValue:ne(u.date),onChange:O=>D(x,"date",ne(O).format("YYYY-MM-DD"))})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.5,children:e.jsx(s.TimePicker,{format:"h:mm a",defaultValue:ne(u.start_time,"HH:mm"),onChange:O=>D(x,"start_time",O?ne(O).format("HH:mm"):"")})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.5,children:e.jsx(s.TimePicker,{format:"h:mm a",defaultValue:ne(u.end_time,"HH:mm"),onChange:O=>D(x,"end_time",O?ne(O).format("HH:mm"):"")})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.5,children:e.jsx(G,{label:"Full Marks",type:"number",value:u.full_marks,onChange:O=>D(x,"full_marks",O.target.value)})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.5,children:e.jsx(G,{label:"Passing Marks",type:"number",value:u.passing_marks,onChange:O=>D(x,"passing_marks",O.target.value)})}),e.jsx(s.Grid,{item:!0,xs:12,md:1,children:j===x?e.jsx(s.Button,{type:"text",icon:e.jsx(re.CloseCircleOutlined,{style:{color:"red"}}),size:"small",onClick:()=>A(x)}):e.jsx("span",{style:{opacity:0},children:"-"})})]}),P&&e.jsx(s.Divider,{style:{margin:"16px 0",borderWidth:2}})]},x)})}),e.jsx(w,{mt:3,display:"flex",justifyContent:"flex-end",children:e.jsx(de,{type:"submit",value:"Save"})})]})})]})})}function dA({token:t}){return e.jsx(lA,{token:t})}const Qt=({label:t,data:a})=>e.jsxs("div",{style:{marginBottom:8},children:[e.jsx(s.Typography.Text,{type:"secondary",style:{display:"block",fontSize:12},children:t}),e.jsx(s.Typography.Text,{children:a})]});function cA({token:t}){const a=window.location.search,r=new URLSearchParams(a).get("id"),{isLoading:o,error:l,data:d}=q(t!=null&&r?[`${We.examSchedule.getById}?id=${r}`,t]:null,([c,h])=>W(c,h));return o?e.jsx("p",{children:"Loading..."}):e.jsx(w,{pt:8,pb:1,children:e.jsx(s.Grid,{container:!0,spacing:6,children:e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Exam Details"})}),e.jsx(w,{p:3,children:d&&e.jsxs("form",{children:[e.jsxs(s.Grid,{container:!0,spacing:3,children:[e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(w,{children:e.jsx(Qt,{label:"Exam Name",data:d?.data[0]?.name})})}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(Qt,{label:"Start Date",data:d?.data[0]?.start_date})}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(Qt,{label:"End Date",data:d?.data[0]?.end_date})}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(Qt,{label:"Class",data:d?.data[0]?.schedule[0]?.class})})]}),e.jsx(s.Grid,{container:!0,spacing:3,mt:2,children:e.jsx(s.Grid,{item:!0,xs:12,children:Array.isArray(d?.data[0]?.schedule)&&d?.data[0]?.schedule.map((c,h)=>e.jsxs(s.Grid,{container:!0,spacing:3,pt:1,children:[e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(Qt,{label:"Subject",data:c.subject})}),e.jsx(s.Grid,{item:!0,xs:12,md:2,children:e.jsx(Qt,{label:"Date",data:c.date_of_exam})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.3,children:e.jsx(Qt,{label:"Start Time",data:c.start_to})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.3,children:e.jsx(Qt,{label:"End Time",data:c.end_from})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.3,children:e.jsx(Qt,{label:"Room No",data:c.room_no})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.3,children:e.jsx(Qt,{label:"Full Marks",data:c.full_marks})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.3,children:e.jsx(Qt,{label:"Passing Marks",data:c.passing_marks})})]},h+"exam"))})})]})})]})})})})}function uA({token:t}){return e.jsx(cA,{token:t})}function pA({token:t}){i.useRef(null);const[a,n]=i.useState(!1),[r,o]=i.useState(null),[l,d]=i.useState(!1),[c,h]=i.useState(!1),[f,p]=i.useState(null),[m,v]=i.useState(!1),[S,y]=i.useState([]),[g,b]=i.useState(null),[D,R]=i.useState(null),{SHOW_PARENT:I}=s.TreeSelect,A=async(Q,X)=>{if(X==="class_id"){const J=Q?.value;v(J),n(`${la}?class_id=${J}`),p(`${We.examSchedule.dropdown}?class_id=${J}`),d(K=>!K)}else X==="exam_id"&&(o(`${Fr}?class_id=${m}&exam_id=${Q.value}`),await _({exam_id:Q.value,class_id:m}),h(J=>!J))},{trigger:_,data:u}=it(We.examSchedule.groupList,(Q,{arg:X})=>Kr(Q,X,t)),{isLoading:x,error:j,data:P,mutate:O}=q(t!=null?["/exam/exam/getExamGrouplist?page=1&per_page=100",t]:null,([Q,X])=>W(Q,X)),{isLoading:z,errorSubject:k,data:F}=q(r,W),{isLoading:C,errorExam:E,data:M}=q(f,W),{isLoading:U,errorSection:Y,data:V}=q(a,W),{isLoading:L,errorClass:B,data:$}=q(t!=null?[oa,t]:null,([Q,X])=>W(Q,X)),N=[{title:"Class name",dataIndex:"class",key:"class"},{title:"Exam Name",dataIndex:"parent_exam_title",key:"parent_exam_title"}],H=async Q=>{try{await _(Q),O()}catch{}};return e.jsx(w,{pt:5,pb:1,children:e.jsx(s.Grid,{container:!0,spacing:3,children:e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Exam Link"})}),e.jsxs(w,{p:3,children:[e.jsx(s.Form,{layout:"vertical",onFinish:H,children:e.jsxs(s.Grid,{container:!0,spacing:3,children:[e.jsx(s.Grid,{item:!0,xs:12,md:3,children:e.jsx(ae,{options:Array.isArray($)?$:[],closeMenuOnSelect:!0,label:"Class",name:"class_id",required:!0,onChange:Q=>A(Q,"class_id"),allowSelectAll:!1})}),e.jsx(s.Grid,{item:!0,xs:12,md:3,children:e.jsx(ae,{options:Array.isArray(V)?V:[],closeMenuOnSelect:!0,label:"Section",name:"section_id",allowSelectAll:!1},`section1${l}`)}),e.jsx(s.Grid,{item:!0,xs:12,md:3,children:e.jsx(ae,{options:Array.isArray(M)?M:[],closeMenuOnSelect:!0,label:"Exam",name:"exam_id",required:!0,onChange:Q=>A(Q,"exam_id"),allowSelectAll:!1})}),e.jsx(s.Grid,{item:!0,xs:12,md:3,children:e.jsx(ae,{options:Array.isArray(F)?F:[],closeMenuOnSelect:!0,label:"Subject",name:"subject_id",allowSelectAll:!1},`sub${c}`)}),e.jsx(s.Grid,{item:!0,xs:12,children:e.jsx(s.Form.Item,{children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})})]})}),e.jsx(w,{pt:3,children:e.jsx(s.Table,{columns:N,dataSource:P?.data??[],rowKey:"id",pagination:!1,loading:x,bordered:!0,size:"small"})})]})]})})})})}function mA({token:t}){return e.jsx(pA,{token:t})}function hA({token:t}){const[a,n]=i.useState(!1),r=i.useRef(null),[o,l]=i.useState([]),[d,c]=i.useState(!1),[h,f]=i.useState(null),[p,m]=i.useState(!1),[v,S]=i.useState(null),[y,g]=i.useState(!1),[b,D]=i.useState(!1),[R,I]=i.useState(null),[A,_]=i.useState(!1),[u,x]=i.useState(null),[j,P]=i.useState(null),[O,z]=i.useState(!1),k=i.useRef(),F=async(se,le)=>{le==="class_id"?(_(se.value),c(`${la}?class_id=${se.value}`),I(`${We.examSchedule.dropdown}?class_id=${se.value}`),P(`${We.coscholasticCategoryDropdown}?class_id=${se.value}`),g(Ce=>!Ce)):le==="exam_id"&&(S(`${Fr}?class_id=${A}&exam_id=${se.value}`),(await C({exam_id:se.value,class_id:A}))[0].exam_type==="periodic_test"?z(!1):z(!0),D(Le=>!Le))},{trigger:C,isLoading:E,data:M}=it(We.examSetting.typeByExamId,(se,{arg:le})=>Kr(se,le,t)),{isLoading:U,errorSubject:Y,data:V}=q(v,W),{isLoading:L,errorExam:B,data:$}=q(R,W),{isLoading:N,errorClass:H,data:Q}=q(t!=null?[oa,t]:null,([se,le])=>W(se,le)),{isLoading:X,data:J,mutate:K}=q(j,W),{isLoading:Z,data:ee}=q(d,W),pe=i.useMemo(()=>O?[{title:"SL",dataIndex:"Sl_no",align:"center"},{title:"Student Name",dataIndex:"firstname",align:"center"},{title:"Full Marks",dataIndex:"full_marks",align:"center"},{title:"Marks Obtained",dataIndex:"marks_obtained",align:"center"},{title:"Percentage",dataIndex:"percentage",align:"center"},{title:"Attendance",dataIndex:"attendance",align:"center"}]:[{title:"SL",dataIndex:"Sl_no",align:"center"},{title:"Student Name",dataIndex:"firstname",align:"center"},{title:"Full Marks",dataIndex:"full_marks",align:"center"},{title:"Periodic Test",dataIndex:"PeriodicTest",align:"center"},{title:"Portfolio(CW/HW)",dataIndex:"Portfolio",align:"center"},{title:"Subject Enrichment",dataIndex:"Enrichment",align:"center"},{title:"Multiple Assessment",dataIndex:"Assessment",align:"center"},{title:"Attendance",dataIndex:"attendance",align:"center"}],[O]),te=se=>{se.preventDefault();const le=new FormData(se.target),Ce={};le.forEach((Le,Re)=>Ce[Re]=Le),l(Ce),f(`exam/exam/getstudentlistforCoscholastic?class_id=${se.target.class_id.value}§ion_id=${se.target.section_id.value}&CoScholastic_category_id=${se.target.CoScholastic_category_id.value}&exam_id=${se.target.exam_id.value}&`),r.current&&r.current.click(),n(!1),m(Le=>!Le)};return e.jsxs(w,{pt:5,pb:1,children:[e.jsx(T.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Grid,{container:!0,spacing:6,children:e.jsx(s.Grid,{item:!0,xs:12,children:e.jsxs(s.Card,{children:[e.jsx(w,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(he,{variant:"h6",color:"white",children:"Co-Scholastic Area Marks"})}),e.jsxs(w,{p:3,children:[e.jsx(s.Form,{layout:"vertical",onFinish:te,children:e.jsxs(s.Grid,{container:!0,spacing:3,justifyContent:"center",children:[e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(ae,{options:Array.isArray(Q)?Q:[],closeMenuOnSelect:!0,label:"Class",name:"class_id",required:!0,onChange:se=>F(se,"class_id"),allowSelectAll:!1})}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(ae,{options:Array.isArray(ee)?ee:[],closeMenuOnSelect:!0,label:"Section",name:"section_id",allowSelectAll:!1},`section1${y}`)}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(ae,{options:Array.isArray(J?.data)?J.data:[],closeMenuOnSelect:!0,label:"Co-Scholastic Category",name:"CoScholastic_category_id",allowSelectAll:!1})}),e.jsx(s.Grid,{item:!0,xs:12,md:2.625,children:e.jsx(ae,{options:Array.isArray($)?$:[],closeMenuOnSelect:!0,label:"Exam",name:"exam_id",required:!0,onChange:se=>F(se,"exam_id"),allowSelectAll:!1})}),e.jsx(s.Grid,{item:!0,xs:12,md:1.5,children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})}),e.jsx(s.Grid,{container:!0,spacing:3,style:{marginTop:16},children:e.jsx(s.Grid,{item:!0,xs:12,style:{borderTop:"1px solid #ececec",borderTopWidth:"2px"},children:h&&!a&&e.jsx(s.Table,{ref:k,columns:pe,dataSource:[],pagination:!1,bordered:!0,size:"small"})})})]})]})})})]})}function fA({token:t}){return e.jsx(hA,{token:t})}const gA=({routes:t=[],onNavigate:a})=>e.jsx(s.Row,{gutter:[16,16],children:t.map((n,r)=>e.jsx(s.Col,{xs:24,md:8,lg:8,children:e.jsx(w,{children:e.jsx(wc,{icon:n?.icon??"",title:n?.title??"",path:n?.path??"",onClick:a})})},`${r}route001`))});exports.About=Bv;exports.AcademicYear=jv;exports.Academics=DS;exports.AddBook=Gy;exports.AddDriver=Uy;exports.AddExpense=mS;exports.AddHomework=Vy;exports.AddIncome=sS;exports.AddStaff=bb;exports.AdmissionEnquiry=xg;exports.AdmitCardSetting=nA;exports.ApplyLeave=nj;exports.AprroveLeaveRequest=Jb;exports.Assessment=nC;exports.AssignByClass=tw;exports.AssignMarks=cC;exports.AssignStudentSubject=_S;exports.AssignStudentToTransport=Ly;exports.AssignSubjects=XS;exports.AssignTimeGroup=dw;exports.AssignVehicles=Ry;exports.AttendanceDashboard=Uj;exports.BookList=Jy;exports.BulkUpload=TS;exports.BuySellProduct=Mx;exports.Category=wx;exports.Chat=g0;exports.ChatBar=Uu;exports.Class=US;exports.CoScholasticArea=yw;exports.CoScholasticAreaMarks=fA;exports.Complain=gy;exports.CreateTimeGroup=sw;exports.DailyAttendance=Wj;exports.Department=dj;exports.Designation=pj;exports.DownloadExpense=xS;exports.ErpDashboard=sm;exports.Exam=G1;exports.ExamDashboard=oA;exports.ExamDetails=uA;exports.ExamEdit=dA;exports.ExamInstruction=rC;exports.ExamLink=mA;exports.ExamList=Q1;exports.ExamSetting=tC;exports.ExamType=Z1;exports.ExpenseHead=SS;exports.FeeReceiptSetting=Cv;exports.FeesInfo=Vv;exports.GatePass=Ay;exports.GeneralSetting=qw;exports.Holidays=KS;exports.IncomeHead=oS;exports.IssueReturn=Xy;exports.LeaveType=ij;exports.LibraryAssignStudent=Zy;exports.LibraryCategory=ex;exports.LibraryRenewalReport=ax;exports.LibraryReport=tx;exports.ManageStock=Vx;exports.MarksReport=rA;exports.MarksheetSetting=Pv;exports.MedicalReport=vS;exports.MenuSubmenu=Wf;exports.MonthlyReport=Kj;exports.Notes=ww;exports.NpmReport=Xx;exports.Organization=hv;exports.PaymentGateway=a0;exports.Payroll=Wb;exports.PayrollReceiptDetails=Cj;exports.PayrollSettings=Xv;exports.PhoneCallLog=Kg;exports.PostalDispatch=ey;exports.PostalReceive=iy;exports.Privacy=$v;exports.Products=xx;exports.PromoteStudents=mw;exports.RoomManagment=lC;exports.RoutePage=gA;exports.RouteTimeTable=Ny;exports.SearchExpense=bS;exports.SearchIncome=rS;exports.Sections=OS;exports.SellReports=qx;exports.SetupFrontOffice=vy;exports.Shift=fj;exports.Sms=s0;exports.SmsAlertSetting=o0;exports.SmsSetting=l0;exports.StaffAttendance=$b;exports.StaffAttendanceReport=Ub;exports.StaffDailyAttendance=Sj;exports.StaffDirectory=Cb;exports.StockReport=Qx;exports.Stoppage=qy;exports.StudentAttendance=zj;exports.StudentLoginCredential=wS;exports.StudentResult=z1;exports.SubCategory=Dx;exports.Subjects=YS;exports.SubmissionDetails=Hy;exports.Syllabus=Iw;exports.Terms=Ev;exports.TimeTable=zw;exports.TransferCertificate=Tw;exports.TransportBulkUpload=Yy;exports.TransportRoutes=Ty;exports.TransportVehicles=Dy;exports.Unit=Fx;exports.Vendor=cx;exports.VisitorBook=Lg;exports.YearlyReport=Xj;exports.getImageBaseUrl=ut;exports.setBaseUrl=Nh;exports.setImageBaseUrl=zh;
|