@qwanyx/stack 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var wt=Object.defineProperty;var Et=(h,t,r)=>t in h?wt(h,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):h[t]=r;var fe=(h,t,r)=>Et(h,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react");class _t{constructor(t){fe(this,"config");fe(this,"defaultUploadOptions",{maxSizeMB:10,maxImageDimension:0,imageQuality:.9});if(!t.system_id)throw new Error("GraphClient: system_id is REQUIRED. No system_id → No start.");this.config=t}async callGraph(t,r={}){const n={coprocessor:"graph",method:t,system_id:this.config.system_id,params:r};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!i.ok){const o=await i.text();throw new Error(`API error (${i.status}): ${o}`)}const s=await i.json();if(!s.success&&s.error)throw new Error(s.error);return s}catch(i){throw console.error("Graph API call failed:",i),i}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getChildren(t){return(await this.callGraph("get_children",{parent_id:t})).result||[]}async getNode(t){return(await this.callGraph("get_node",{node_id:t})).result||null}async addNode(t){const r={...t,created:t.created||new Date().toISOString(),modified:new Date().toISOString()},n=await this.callGraph("add_node",r);if(!n.result)throw new Error("Failed to add node");return n.result}async updateNode(t,r){const n={node_id:t,updates:{...r,modified:new Date().toISOString()}},i=await this.callGraph("update_node",n);if(!i.result)throw new Error("Failed to update node");return i.result}async deleteNode(t,r=!1){return(await this.callGraph("delete_node",{node_id:t,cascade:r})).success===!0}async getChildrenWithEdges(t,r="children",n,i){return(await this.callGraph("get_children_with_edges",{node_id:t,display_mode:r,edge_type:n,node_type:i})).result||[]}async addEdge(t,r,n="link",i){return await this.callGraph("add_edge",{source_id:t,target_id:r,edge_type:n,data:i})}async deleteEdge(t,r,n){return await this.callGraph("delete_edge",{source_id:t,target_id:r,edge_type:n})}async getEdges(t,r,n){return(await this.callGraph("get_edges",{source_id:t,edge_type:r,target_id:n})).result||[]}async getAncestors(t){return(await this.callGraph("get_ancestors",{node_id:t})).ancestors||[]}async getTree(t,r=10){return(await this.callGraph("get_tree",{root_id:t,max_depth:r})).tree||[]}async moveNode(t,r){const n=await this.callGraph("move",{node_id:t,new_parent_id:r});if(!n.node)throw new Error("Failed to move node");return n.node}async searchNodes(t,r){return(await this.callGraph("search",{query:t,type:r})).nodes||[]}async getNodesByType(t){return(await this.callGraph("get_nodes_by_type",{type:t})).result||[]}fileToBase64(t){return new Promise((r,n)=>{const i=new FileReader;i.onload=()=>{const o=i.result.split(",")[1];r(o)},i.onerror=()=>n(new Error("Failed to read file")),i.readAsDataURL(t)})}async resizeImage(t,r,n){return t.type.startsWith("image/")?new Promise(i=>{const s=new Image,o=URL.createObjectURL(t);s.onload=()=>{if(URL.revokeObjectURL(o),s.width<=r&&s.height<=r){i(t);return}let p,d;s.width>s.height?(p=r,d=Math.round(s.height/s.width*r)):(d=r,p=Math.round(s.width/s.height*r));const g=document.createElement("canvas");g.width=p,g.height=d;const c=g.getContext("2d");if(!c){i(t);return}c.drawImage(s,0,0,p,d);const j=t.type==="image/png"?"image/png":"image/jpeg";g.toBlob(x=>{if(x){const m=new File([x],t.name,{type:j});i(m)}else i(t)},j,n)},s.onerror=()=>{URL.revokeObjectURL(o),i(t)},s.src=o}):t}async uploadFile(t,r,n,i={}){const s={...this.defaultUploadOptions,...i};try{let o=n;s.maxImageDimension>0&&n.type.startsWith("image/")&&(o=await this.resizeImage(n,s.maxImageDimension,s.imageQuality));const p=s.maxSizeMB*1024*1024;if(o.size>p)return{success:!1,error:`File too large (${(o.size/1024/1024).toFixed(1)} MB). Max: ${s.maxSizeMB} MB`};const d=await this.fileToBase64(o),g=await this.callGraph("upload_file",{node_id:t,filename:r,content:d});return g.success?{success:!0,path:g.path}:{success:!1,error:g.error||"Upload failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Upload failed"}}}async listFiles(t){var i;return(((i=(await this.callGraph("list_files",{node_id:t})).result)==null?void 0:i.files)||[]).map(s=>({filename:s.name,path:s.path}))}async deleteFile(t,r){return{success:(await this.callGraph("delete_file",{node_id:t,filename:r})).success||!1}}getFileUrl(t,r){return`${this.config.baseUrl}/files/${this.config.system_id}/${t}/${r}`}}class Ze{constructor(t){fe(this,"config");if(!t.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=t}async callCoprocessor(t,r,n={}){const i={coprocessor:t,method:r,system_id:this.config.system_id,params:{user_id:this.config.system_id,...n}};try{const s=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(i)});if(!s.ok){const p=await s.text();throw new Error(`API error (${s.status}): ${p}`)}const o=await s.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(s){throw console.error("API call failed:",s),s}}async callMail(t,r={}){return this.callCoprocessor("mail",t,r)}async callEmail(t,r={}){return this.callCoprocessor("email",t,r)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(t){await this.callMail("save_email_settings",{accounts:t})}async listEmails(t,r=20,n){return this.callMail("list_emails",{account_id:t,limit:r,folder:n})}async deleteEmails(t,r,n=!0){return this.callMail("delete_emails",{account_id:t,uids:r,expunge:n})}async imapExec(t,r){return this.callMail("imap_exec",{account_id:t,commands:r})}async trashEmails(t,r){const n=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const i of n){const s=["SELECT INBOX",...r.map(d=>`UID MOVE ${d} ${i}`)],p=(await this.imapExec(t,s)).responses.filter(d=>d.ok&&d.command==="UID MOVE").length;if(p>0)return{success:!0,moved:p}}return{success:!1,moved:0}}async archiveEmails(t,r){const n=["SELECT INBOX",...r.map(o=>`UID STORE ${o} +FLAGS (\\Deleted)`),"EXPUNGE"],s=(await this.imapExec(t,n)).responses.filter(o=>o.ok&&o.command==="UID STORE").length;return{success:s>0,archived:s}}async listFolders(t){const n=(await this.imapExec(t,['LIST "" *'])).responses.find(i=>i.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}async listEmailsSorted(t,r="INBOX",n=20){const i=await this.imapExec(t,[`SELECT ${r}`,"FETCH 1:* (UID INTERNALDATE)"]),s=i.responses.find(m=>m.command==="SELECT");if(!(s!=null&&s.ok))throw new Error(`Failed to select folder: ${(s==null?void 0:s.error)||"Unknown error"}`);const o=i.responses.find(m=>m.command==="FETCH");if(!(o!=null&&o.ok)||!o.messages)return{account:{id:t,label:"",email:""},mailbox:{name:r,total:s.exists||0},messages:[]};const d=[...o.messages].sort((m,k)=>{const C=m.internalDate?new Date(m.internalDate).getTime():0;return(k.internalDate?new Date(k.internalDate).getTime():0)-C}).slice(0,n).map(m=>m.uid).filter(Boolean);if(d.length===0)return{account:{id:t,label:"",email:""},mailbox:{name:r,total:s.exists||0},messages:[]};const c=(await this.imapExec(t,[`SELECT ${r}`,`UID FETCH ${d.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(m=>m.command==="UID FETCH");if(!(c!=null&&c.ok)||!c.messages)throw new Error(`Failed to fetch details: ${(c==null?void 0:c.error)||"Unknown error"}`);const j=new Map;for(const m of c.messages)m.uid&&j.set(m.uid,m);const x=d.map(m=>{var Y,E,M,y,N;const k=j.get(m);if(!k)return null;const C=((Y=k.flags)==null?void 0:Y.some(D=>D.includes("Seen")))||!1,V=((M=(E=k.envelope)==null?void 0:E.from)==null?void 0:M.email)||"Unknown",I=((y=k.envelope)==null?void 0:y.subject)||"(No subject)",F=((N=k.envelope)==null?void 0:N.date)||"";return{uid:m,from:V,subject:I,date:F,seen:C}}).filter(Boolean);return{account:{id:t,label:"",email:""},mailbox:{name:r,total:s.exists||0},messages:x}}async getEmail(t,r){return this.callMail("get_email",{account_id:t,uid:r})}async sendMail(t){const r={to:t.to,subject:t.subject,body:t.body};return t.html&&(r.html=t.html),t.from&&(r.from=t.from),t.smtpConfig&&(r.smtp_config=t.smtpConfig),this.callEmail("send",r)}}const De="qwanyx_auth_token",Me="qwanyx_refresh_token";class et{static setToken(t){typeof window<"u"&&localStorage.setItem(De,t)}static getToken(){return typeof window<"u"?localStorage.getItem(De):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(De),localStorage.removeItem(Me))}static setRefreshToken(t){typeof window<"u"&&localStorage.setItem(Me,t)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(Me):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const t=this.getToken();return t?{Authorization:`Bearer ${t}`}:{}}}class tt{constructor(t){fe(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...t}}buildQueryString(t){if(!t||Object.keys(t).length===0)return"";const r=new URLSearchParams;Object.entries(t).forEach(([i,s])=>{s!=null&&r.append(i,String(s))});const n=r.toString();return n?`?${n}`:""}async request(t,r={}){const{method:n="GET",headers:i={},body:s,params:o}=r,p=`${this.config.baseUrl}/${t}${this.buildQueryString(o)}`,d={...this.config.headers,...et.getAuthHeader(),...i},g={method:n,headers:d};s&&n!=="GET"&&(g.body=JSON.stringify(s));try{const c=new AbortController,j=setTimeout(()=>c.abort(),this.config.timeout),x=await fetch(p,{...g,signal:c.signal});if(clearTimeout(j),!x.ok){const m=await x.json().catch(()=>({message:x.statusText}));throw new Error(m.message||`HTTP ${x.status}`)}return await x.json()}catch(c){throw c instanceof Error?c:new Error("An unexpected error occurred")}}async get(t,r){return this.request(t,{method:"GET",params:r})}async post(t,r,n){return this.request(t,{method:"POST",body:r,params:n})}async put(t,r,n){return this.request(t,{method:"PUT",body:r,params:n})}async patch(t,r,n){return this.request(t,{method:"PATCH",body:r,params:n})}async delete(t,r){return this.request(t,{method:"DELETE",params:r})}setBaseUrl(t){this.config.baseUrl=t}getBaseUrl(){return this.config.baseUrl}}let Se=null;function jt(h){return Se=new tt(h),Se}function Be(){if(!Se)throw new Error("API client not initialized. Call initializeApiClient() first.");return Se}function rt(h,t,r={}){const{enabled:n=!0,refetchOnMount:i=!0,onSuccess:s,onError:o}=r,[p,d]=w.useState(null),[g,c]=w.useState(n),[j,x]=w.useState(null),m=w.useCallback(async()=>{if(n){c(!0),x(null);try{const C=await Be().get(h,t);d(C),s==null||s(C)}catch(k){const C=k instanceof Error?k:new Error("Unknown error");x(C),o==null||o(C)}finally{c(!1)}}},[h,JSON.stringify(t),n,s,o]);return w.useEffect(()=>{i&&m()},[m,i]),{data:p,loading:g,error:j,refetch:m}}function St(h,t="POST",r={}){const{onSuccess:n,onError:i}=r,[s,o]=w.useState(null),[p,d]=w.useState(!1),[g,c]=w.useState(null),j=w.useCallback(async m=>{d(!0),c(null);try{const k=Be();let C;switch(t){case"POST":C=await k.post(h,m);break;case"PUT":C=await k.put(h,m);break;case"PATCH":C=await k.patch(h,m);break;case"DELETE":C=await k.delete(h);break;default:throw new Error(`Unsupported method: ${t}`)}return o(C),n==null||n(C,m),C}catch(k){const C=k instanceof Error?k:new Error("Unknown error");return c(C),i==null||i(C,m),null}finally{d(!1)}},[h,t,n,i]),x=w.useCallback(()=>{o(null),c(null),d(!1)},[]);return{data:s,loading:p,error:g,mutate:j,reset:x}}var Ue={exports:{}},pe={};/**
1
+ "use strict";var wt=Object.defineProperty;var Et=(h,t,r)=>t in h?wt(h,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):h[t]=r;var fe=(h,t,r)=>Et(h,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react");class _t{constructor(t){fe(this,"config");fe(this,"defaultUploadOptions",{maxSizeMB:10,maxImageDimension:0,imageQuality:.9});if(!t.system_id)throw new Error("GraphClient: system_id is REQUIRED. No system_id → No start.");this.config=t}async callGraph(t,r={}){const s={coprocessor:"graph",method:t,system_id:this.config.system_id,params:r};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!i.ok){const o=await i.text();throw new Error(`API error (${i.status}): ${o}`)}const n=await i.json();if(!n.success&&n.error)throw new Error(n.error);return n}catch(i){throw console.error("Graph API call failed:",i),i}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getChildren(t){return(await this.callGraph("get_children",{parent_id:t})).result||[]}async getNode(t){return(await this.callGraph("get_node",{node_id:t})).result||null}async addNode(t){const r={...t,created:t.created||new Date().toISOString(),modified:new Date().toISOString()},s=await this.callGraph("add_node",r);if(!s.result)throw new Error("Failed to add node");return s.result}async updateNode(t,r){const s={node_id:t,updates:{...r,modified:new Date().toISOString()}},i=await this.callGraph("update_node",s);if(!i.result)throw new Error("Failed to update node");return i.result}async deleteNode(t,r=!1){return(await this.callGraph("delete_node",{node_id:t,cascade:r})).success===!0}async getChildrenWithEdges(t,r="children",s,i){return(await this.callGraph("get_children_with_edges",{node_id:t,display_mode:r,edge_type:s,node_type:i})).result||[]}async addEdge(t,r,s="link",i){return await this.callGraph("add_edge",{source_id:t,target_id:r,edge_type:s,data:i})}async deleteEdge(t,r,s){return await this.callGraph("delete_edge",{source_id:t,target_id:r,edge_type:s})}async getEdges(t,r,s){return(await this.callGraph("get_edges",{source_id:t,edge_type:r,target_id:s})).result||[]}async getAncestors(t){return(await this.callGraph("get_ancestors",{node_id:t})).ancestors||[]}async getTree(t,r=10){return(await this.callGraph("get_tree",{root_id:t,max_depth:r})).tree||[]}async moveNode(t,r){const s=await this.callGraph("move",{node_id:t,new_parent_id:r});if(!s.node)throw new Error("Failed to move node");return s.node}async searchNodes(t,r){return(await this.callGraph("search",{query:t,type:r})).nodes||[]}async getNodesByType(t){return(await this.callGraph("get_nodes_by_type",{type:t})).result||[]}fileToBase64(t){return new Promise((r,s)=>{const i=new FileReader;i.onload=()=>{const o=i.result.split(",")[1];r(o)},i.onerror=()=>s(new Error("Failed to read file")),i.readAsDataURL(t)})}async resizeImage(t,r,s){return t.type.startsWith("image/")?new Promise(i=>{const n=new Image,o=URL.createObjectURL(t);n.onload=()=>{if(URL.revokeObjectURL(o),n.width<=r&&n.height<=r){i(t);return}let p,d;n.width>n.height?(p=r,d=Math.round(n.height/n.width*r)):(d=r,p=Math.round(n.width/n.height*r));const g=document.createElement("canvas");g.width=p,g.height=d;const c=g.getContext("2d");if(!c){i(t);return}c.drawImage(n,0,0,p,d);const _=t.type==="image/png"?"image/png":"image/jpeg";g.toBlob(x=>{if(x){const m=new File([x],t.name,{type:_});i(m)}else i(t)},_,s)},n.onerror=()=>{URL.revokeObjectURL(o),i(t)},n.src=o}):t}async uploadFile(t,r,s,i={}){const n={...this.defaultUploadOptions,...i};try{let o=s;n.maxImageDimension>0&&s.type.startsWith("image/")&&(o=await this.resizeImage(s,n.maxImageDimension,n.imageQuality));const p=n.maxSizeMB*1024*1024;if(o.size>p)return{success:!1,error:`File too large (${(o.size/1024/1024).toFixed(1)} MB). Max: ${n.maxSizeMB} MB`};const d=await this.fileToBase64(o),g=await this.callGraph("upload_file",{node_id:t,filename:r,content:d});return g.success?{success:!0,path:g.path}:{success:!1,error:g.error||"Upload failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Upload failed"}}}async listFiles(t){var i;return(((i=(await this.callGraph("list_files",{node_id:t})).result)==null?void 0:i.files)||[]).map(n=>({filename:n.name,path:n.path}))}async deleteFile(t,r){return{success:(await this.callGraph("delete_file",{node_id:t,filename:r})).success||!1}}getFileUrl(t,r){return`${this.config.baseUrl}/files/${this.config.system_id}/${t}/${r}`}}class Ze{constructor(t){fe(this,"config");if(!t.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=t}async callCoprocessor(t,r,s={}){const i={coprocessor:t,method:r,system_id:this.config.system_id,params:{user_id:this.config.system_id,...s}};try{const n=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(i)});if(!n.ok){const p=await n.text();throw new Error(`API error (${n.status}): ${p}`)}const o=await n.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(n){throw console.error("API call failed:",n),n}}async callMail(t,r={}){return this.callCoprocessor("mail",t,r)}async callEmail(t,r={}){return this.callCoprocessor("email",t,r)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(t){await this.callMail("save_email_settings",{accounts:t})}async listEmails(t,r=20,s){return this.callMail("list_emails",{account_id:t,limit:r,folder:s})}async deleteEmails(t,r,s=!0){return this.callMail("delete_emails",{account_id:t,uids:r,expunge:s})}async imapExec(t,r){return this.callMail("imap_exec",{account_id:t,commands:r})}async trashEmails(t,r){const s=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const i of s){const n=["SELECT INBOX",...r.map(d=>`UID MOVE ${d} ${i}`)],p=(await this.imapExec(t,n)).responses.filter(d=>d.ok&&d.command==="UID MOVE").length;if(p>0)return{success:!0,moved:p}}return{success:!1,moved:0}}async archiveEmails(t,r){const s=["SELECT INBOX",...r.map(o=>`UID STORE ${o} +FLAGS (\\Deleted)`),"EXPUNGE"],n=(await this.imapExec(t,s)).responses.filter(o=>o.ok&&o.command==="UID STORE").length;return{success:n>0,archived:n}}async listFolders(t){const s=(await this.imapExec(t,['LIST "" *'])).responses.find(i=>i.command==="LIST");return s!=null&&s.ok&&s.folders?{success:!0,folders:s.folders}:{success:!1,folders:[]}}async listEmailsSorted(t,r="INBOX",s=20){const i=await this.imapExec(t,[`SELECT ${r}`,"FETCH 1:* (UID INTERNALDATE)"]),n=i.responses.find(m=>m.command==="SELECT");if(!(n!=null&&n.ok))throw new Error(`Failed to select folder: ${(n==null?void 0:n.error)||"Unknown error"}`);const o=i.responses.find(m=>m.command==="FETCH");if(!(o!=null&&o.ok)||!o.messages)return{account:{id:t,label:"",email:""},mailbox:{name:r,total:n.exists||0},messages:[]};const d=[...o.messages].sort((m,k)=>{const C=m.internalDate?new Date(m.internalDate).getTime():0;return(k.internalDate?new Date(k.internalDate).getTime():0)-C}).slice(0,s).map(m=>m.uid).filter(Boolean);if(d.length===0)return{account:{id:t,label:"",email:""},mailbox:{name:r,total:n.exists||0},messages:[]};const c=(await this.imapExec(t,[`SELECT ${r}`,`UID FETCH ${d.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(m=>m.command==="UID FETCH");if(!(c!=null&&c.ok)||!c.messages)throw new Error(`Failed to fetch details: ${(c==null?void 0:c.error)||"Unknown error"}`);const _=new Map;for(const m of c.messages)m.uid&&_.set(m.uid,m);const x=d.map(m=>{var Y,E,M,y,N;const k=_.get(m);if(!k)return null;const C=((Y=k.flags)==null?void 0:Y.some(D=>D.includes("Seen")))||!1,V=((M=(E=k.envelope)==null?void 0:E.from)==null?void 0:M.email)||"Unknown",I=((y=k.envelope)==null?void 0:y.subject)||"(No subject)",F=((N=k.envelope)==null?void 0:N.date)||"";return{uid:m,from:V,subject:I,date:F,seen:C}}).filter(Boolean);return{account:{id:t,label:"",email:""},mailbox:{name:r,total:n.exists||0},messages:x}}async getEmail(t,r){return this.callMail("get_email",{account_id:t,uid:r})}async sendMail(t){const r={to:t.to,subject:t.subject,body:t.body};return t.html&&(r.html=t.html),t.from&&(r.from=t.from),t.smtpConfig&&(r.smtp_config=t.smtpConfig),this.callEmail("send",r)}}const De="qwanyx_auth_token",Me="qwanyx_refresh_token";class et{static setToken(t){typeof window<"u"&&localStorage.setItem(De,t)}static getToken(){return typeof window<"u"?localStorage.getItem(De):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(De),localStorage.removeItem(Me))}static setRefreshToken(t){typeof window<"u"&&localStorage.setItem(Me,t)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(Me):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const t=this.getToken();return t?{Authorization:`Bearer ${t}`}:{}}}class tt{constructor(t){fe(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...t}}buildQueryString(t){if(!t||Object.keys(t).length===0)return"";const r=new URLSearchParams;Object.entries(t).forEach(([i,n])=>{n!=null&&r.append(i,String(n))});const s=r.toString();return s?`?${s}`:""}async request(t,r={}){const{method:s="GET",headers:i={},body:n,params:o}=r,p=`${this.config.baseUrl}/${t}${this.buildQueryString(o)}`,d={...this.config.headers,...et.getAuthHeader(),...i},g={method:s,headers:d};n&&s!=="GET"&&(g.body=JSON.stringify(n));try{const c=new AbortController,_=setTimeout(()=>c.abort(),this.config.timeout),x=await fetch(p,{...g,signal:c.signal});if(clearTimeout(_),!x.ok){const m=await x.json().catch(()=>({message:x.statusText}));throw new Error(m.message||`HTTP ${x.status}`)}return await x.json()}catch(c){throw c instanceof Error?c:new Error("An unexpected error occurred")}}async get(t,r){return this.request(t,{method:"GET",params:r})}async post(t,r,s){return this.request(t,{method:"POST",body:r,params:s})}async put(t,r,s){return this.request(t,{method:"PUT",body:r,params:s})}async patch(t,r,s){return this.request(t,{method:"PATCH",body:r,params:s})}async delete(t,r){return this.request(t,{method:"DELETE",params:r})}setBaseUrl(t){this.config.baseUrl=t}getBaseUrl(){return this.config.baseUrl}}let Se=null;function jt(h){return Se=new tt(h),Se}function Be(){if(!Se)throw new Error("API client not initialized. Call initializeApiClient() first.");return Se}function rt(h,t,r={}){const{enabled:s=!0,refetchOnMount:i=!0,onSuccess:n,onError:o}=r,[p,d]=w.useState(null),[g,c]=w.useState(s),[_,x]=w.useState(null),m=w.useCallback(async()=>{if(s){c(!0),x(null);try{const C=await Be().get(h,t);d(C),n==null||n(C)}catch(k){const C=k instanceof Error?k:new Error("Unknown error");x(C),o==null||o(C)}finally{c(!1)}}},[h,JSON.stringify(t),s,n,o]);return w.useEffect(()=>{i&&m()},[m,i]),{data:p,loading:g,error:_,refetch:m}}function St(h,t="POST",r={}){const{onSuccess:s,onError:i}=r,[n,o]=w.useState(null),[p,d]=w.useState(!1),[g,c]=w.useState(null),_=w.useCallback(async m=>{d(!0),c(null);try{const k=Be();let C;switch(t){case"POST":C=await k.post(h,m);break;case"PUT":C=await k.put(h,m);break;case"PATCH":C=await k.patch(h,m);break;case"DELETE":C=await k.delete(h);break;default:throw new Error(`Unsupported method: ${t}`)}return o(C),s==null||s(C,m),C}catch(k){const C=k instanceof Error?k:new Error("Unknown error");return c(C),i==null||i(C,m),null}finally{d(!1)}},[h,t,s,i]),x=w.useCallback(()=>{o(null),c(null),d(!1)},[]);return{data:n,loading:p,error:g,mutate:_,reset:x}}var Ue={exports:{}},pe={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Qe;function kt(){if(Qe)return pe;Qe=1;var h=w,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(p,d,g){var c,j={},x=null,m=null;g!==void 0&&(x=""+g),d.key!==void 0&&(x=""+d.key),d.ref!==void 0&&(m=d.ref);for(c in d)n.call(d,c)&&!s.hasOwnProperty(c)&&(j[c]=d[c]);if(p&&p.defaultProps)for(c in d=p.defaultProps,d)j[c]===void 0&&(j[c]=d[c]);return{$$typeof:t,type:p,key:x,ref:m,props:j,_owner:i.current}}return pe.Fragment=r,pe.jsx=o,pe.jsxs=o,pe}var he={};/**
9
+ */var Xe;function kt(){if(Xe)return pe;Xe=1;var h=w,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n={key:!0,ref:!0,__self:!0,__source:!0};function o(p,d,g){var c,_={},x=null,m=null;g!==void 0&&(x=""+g),d.key!==void 0&&(x=""+d.key),d.ref!==void 0&&(m=d.ref);for(c in d)s.call(d,c)&&!n.hasOwnProperty(c)&&(_[c]=d[c]);if(p&&p.defaultProps)for(c in d=p.defaultProps,d)_[c]===void 0&&(_[c]=d[c]);return{$$typeof:t,type:p,key:x,ref:m,props:_,_owner:i.current}}return pe.Fragment=r,pe.jsx=o,pe.jsxs=o,pe}var he={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,21 +14,21 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Xe;function Tt(){return Xe||(Xe=1,process.env.NODE_ENV!=="production"&&function(){var h=w,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),p=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),k=Symbol.iterator,C="@@iterator";function V(e){if(e===null||typeof e!="object")return null;var l=k&&e[k]||e[C];return typeof l=="function"?l:null}var I=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function F(e){{for(var l=arguments.length,u=new Array(l>1?l-1:0),b=1;b<l;b++)u[b-1]=arguments[b];Y("error",e,u)}}function Y(e,l,u){{var b=I.ReactDebugCurrentFrame,P=b.getStackAddendum();P!==""&&(l+="%s",u=u.concat([P]));var $=u.map(function(O){return String(O)});$.unshift("Warning: "+l),Function.prototype.apply.call(console[e],console,$)}}var E=!1,M=!1,y=!1,N=!1,D=!1,S;S=Symbol.for("react.module.reference");function A(e){return!!(typeof e=="string"||typeof e=="function"||e===n||e===s||D||e===i||e===g||e===c||N||e===m||E||M||y||typeof e=="object"&&e!==null&&(e.$$typeof===x||e.$$typeof===j||e.$$typeof===o||e.$$typeof===p||e.$$typeof===d||e.$$typeof===S||e.getModuleId!==void 0))}function v(e,l,u){var b=e.displayName;if(b)return b;var P=l.displayName||l.name||"";return P!==""?u+"("+P+")":u}function W(e){return e.displayName||"Context"}function L(e){if(e==null)return null;if(typeof e.tag=="number"&&F("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case n:return"Fragment";case r:return"Portal";case s:return"Profiler";case i:return"StrictMode";case g:return"Suspense";case c:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var l=e;return W(l)+".Consumer";case o:var u=e;return W(u._context)+".Provider";case d:return v(e,e.render,"ForwardRef");case j:var b=e.displayName||null;return b!==null?b:L(e.type)||"Memo";case x:{var P=e,$=P._payload,O=P._init;try{return L(O($))}catch{return null}}}return null}var R=Object.assign,z=0,J,Q,te,ge,me,ye,xe;function ve(){}ve.__reactDisabledLog=!0;function ke(){{if(z===0){J=console.log,Q=console.info,te=console.warn,ge=console.error,me=console.group,ye=console.groupCollapsed,xe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}z++}}function Te(){{if(z--,z===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},e,{value:J}),info:R({},e,{value:Q}),warn:R({},e,{value:te}),error:R({},e,{value:ge}),group:R({},e,{value:me}),groupCollapsed:R({},e,{value:ye}),groupEnd:R({},e,{value:xe})})}z<0&&F("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=I.ReactCurrentDispatcher,ue;function se(e,l,u){{if(ue===void 0)try{throw Error()}catch(P){var b=P.stack.trim().match(/\n( *(at )?)/);ue=b&&b[1]||""}return`
17
+ */var Qe;function Tt(){return Qe||(Qe=1,process.env.NODE_ENV!=="production"&&function(){var h=w,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),p=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),k=Symbol.iterator,C="@@iterator";function V(e){if(e===null||typeof e!="object")return null;var l=k&&e[k]||e[C];return typeof l=="function"?l:null}var I=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function F(e){{for(var l=arguments.length,u=new Array(l>1?l-1:0),b=1;b<l;b++)u[b-1]=arguments[b];Y("error",e,u)}}function Y(e,l,u){{var b=I.ReactDebugCurrentFrame,P=b.getStackAddendum();P!==""&&(l+="%s",u=u.concat([P]));var $=u.map(function(O){return String(O)});$.unshift("Warning: "+l),Function.prototype.apply.call(console[e],console,$)}}var E=!1,M=!1,y=!1,N=!1,D=!1,j;j=Symbol.for("react.module.reference");function A(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===n||D||e===i||e===g||e===c||N||e===m||E||M||y||typeof e=="object"&&e!==null&&(e.$$typeof===x||e.$$typeof===_||e.$$typeof===o||e.$$typeof===p||e.$$typeof===d||e.$$typeof===j||e.getModuleId!==void 0))}function v(e,l,u){var b=e.displayName;if(b)return b;var P=l.displayName||l.name||"";return P!==""?u+"("+P+")":u}function G(e){return e.displayName||"Context"}function L(e){if(e==null)return null;if(typeof e.tag=="number"&&F("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case s:return"Fragment";case r:return"Portal";case n:return"Profiler";case i:return"StrictMode";case g:return"Suspense";case c:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var l=e;return G(l)+".Consumer";case o:var u=e;return G(u._context)+".Provider";case d:return v(e,e.render,"ForwardRef");case _:var b=e.displayName||null;return b!==null?b:L(e.type)||"Memo";case x:{var P=e,$=P._payload,O=P._init;try{return L(O($))}catch{return null}}}return null}var R=Object.assign,z=0,J,K,te,ge,me,ye,xe;function ve(){}ve.__reactDisabledLog=!0;function ke(){{if(z===0){J=console.log,K=console.info,te=console.warn,ge=console.error,me=console.group,ye=console.groupCollapsed,xe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}z++}}function Te(){{if(z--,z===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},e,{value:J}),info:R({},e,{value:K}),warn:R({},e,{value:te}),error:R({},e,{value:ge}),group:R({},e,{value:me}),groupCollapsed:R({},e,{value:ye}),groupEnd:R({},e,{value:xe})})}z<0&&F("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=I.ReactCurrentDispatcher,ue;function ne(e,l,u){{if(ue===void 0)try{throw Error()}catch(P){var b=P.stack.trim().match(/\n( *(at )?)/);ue=b&&b[1]||""}return`
18
18
  `+ue+e}}var de=!1,ae;{var Re=typeof WeakMap=="function"?WeakMap:Map;ae=new Re}function be(e,l){if(!e||de)return"";{var u=ae.get(e);if(u!==void 0)return u}var b;de=!0;var P=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $;$=ce.current,ce.current=null,ke();try{if(l){var O=function(){throw Error()};if(Object.defineProperty(O.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(O,[])}catch(H){b=H}Reflect.construct(e,[],O)}else{try{O.call()}catch(H){b=H}e.call(O.prototype)}}else{try{throw Error()}catch(H){b=H}e()}}catch(H){if(H&&b&&typeof H.stack=="string"){for(var T=H.stack.split(`
19
19
  `),q=b.stack.split(`
20
- `),U=T.length-1,B=q.length-1;U>=1&&B>=0&&T[U]!==q[B];)B--;for(;U>=1&&B>=0;U--,B--)if(T[U]!==q[B]){if(U!==1||B!==1)do if(U--,B--,B<0||T[U]!==q[B]){var Z=`
21
- `+T[U].replace(" at new "," at ");return e.displayName&&Z.includes("<anonymous>")&&(Z=Z.replace("<anonymous>",e.displayName)),typeof e=="function"&&ae.set(e,Z),Z}while(U>=1&&B>=0);break}}}finally{de=!1,ce.current=$,Te(),Error.prepareStackTrace=P}var le=e?e.displayName||e.name:"",ne=le?se(le):"";return typeof e=="function"&&ae.set(e,ne),ne}function Ce(e,l,u){return be(e,!1)}function Oe(e){var l=e.prototype;return!!(l&&l.isReactComponent)}function ie(e,l,u){if(e==null)return"";if(typeof e=="function")return be(e,Oe(e));if(typeof e=="string")return se(e);switch(e){case g:return se("Suspense");case c:return se("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return Ce(e.render);case j:return ie(e.type,l,u);case x:{var b=e,P=b._payload,$=b._init;try{return ie($(P),l,u)}catch{}}}return""}var re=Object.prototype.hasOwnProperty,f={},_=I.ReactDebugCurrentFrame;function G(e){if(e){var l=e._owner,u=ie(e.type,e._source,l?l.type:null);_.setExtraStackFrame(u)}else _.setExtraStackFrame(null)}function K(e,l,u,b,P){{var $=Function.call.bind(re);for(var O in e)if($(e,O)){var T=void 0;try{if(typeof e[O]!="function"){var q=Error((b||"React class")+": "+u+" type `"+O+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[O]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw q.name="Invariant Violation",q}T=e[O](l,O,b,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(U){T=U}T&&!(T instanceof Error)&&(G(P),F("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",b||"React class",u,O,typeof T),G(null)),T instanceof Error&&!(T.message in f)&&(f[T.message]=!0,G(P),F("Failed %s type: %s",u,T.message),G(null))}}}var ee=Array.isArray;function X(e){return ee(e)}function Ne(e){{var l=typeof Symbol=="function"&&Symbol.toStringTag,u=l&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u}}function we(e){try{return Ee(e),!1}catch{return!0}}function Ee(e){return""+e}function Ie(e){if(we(e))return F("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ne(e)),Ee(e)}var Le=I.ReactCurrentOwner,nt={key:!0,ref:!0,__self:!0,__source:!0},ze,Ge;function st(e){if(re.call(e,"ref")){var l=Object.getOwnPropertyDescriptor(e,"ref").get;if(l&&l.isReactWarning)return!1}return e.ref!==void 0}function at(e){if(re.call(e,"key")){var l=Object.getOwnPropertyDescriptor(e,"key").get;if(l&&l.isReactWarning)return!1}return e.key!==void 0}function it(e,l){typeof e.ref=="string"&&Le.current}function ot(e,l){{var u=function(){ze||(ze=!0,F("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",l))};u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}}function lt(e,l){{var u=function(){Ge||(Ge=!0,F("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",l))};u.isReactWarning=!0,Object.defineProperty(e,"ref",{get:u,configurable:!0})}}var ct=function(e,l,u,b,P,$,O){var T={$$typeof:t,type:e,key:l,ref:u,props:O,_owner:$};return T._store={},Object.defineProperty(T._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(T,"_self",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.defineProperty(T,"_source",{configurable:!1,enumerable:!1,writable:!1,value:P}),Object.freeze&&(Object.freeze(T.props),Object.freeze(T)),T};function ut(e,l,u,b,P){{var $,O={},T=null,q=null;u!==void 0&&(Ie(u),T=""+u),at(l)&&(Ie(l.key),T=""+l.key),st(l)&&(q=l.ref,it(l,P));for($ in l)re.call(l,$)&&!nt.hasOwnProperty($)&&(O[$]=l[$]);if(e&&e.defaultProps){var U=e.defaultProps;for($ in U)O[$]===void 0&&(O[$]=U[$])}if(T||q){var B=typeof e=="function"?e.displayName||e.name||"Unknown":e;T&&ot(O,B),q&&lt(O,B)}return ct(e,T,q,P,b,Le.current,O)}}var Ae=I.ReactCurrentOwner,We=I.ReactDebugCurrentFrame;function oe(e){if(e){var l=e._owner,u=ie(e.type,e._source,l?l.type:null);We.setExtraStackFrame(u)}else We.setExtraStackFrame(null)}var Pe;Pe=!1;function $e(e){return typeof e=="object"&&e!==null&&e.$$typeof===t}function Ye(){{if(Ae.current){var e=L(Ae.current.type);if(e)return`
20
+ `),U=T.length-1,B=q.length-1;U>=1&&B>=0&&T[U]!==q[B];)B--;for(;U>=1&&B>=0;U--,B--)if(T[U]!==q[B]){if(U!==1||B!==1)do if(U--,B--,B<0||T[U]!==q[B]){var X=`
21
+ `+T[U].replace(" at new "," at ");return e.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",e.displayName)),typeof e=="function"&&ae.set(e,X),X}while(U>=1&&B>=0);break}}}finally{de=!1,ce.current=$,Te(),Error.prepareStackTrace=P}var le=e?e.displayName||e.name:"",se=le?ne(le):"";return typeof e=="function"&&ae.set(e,se),se}function Ce(e,l,u){return be(e,!1)}function Oe(e){var l=e.prototype;return!!(l&&l.isReactComponent)}function ie(e,l,u){if(e==null)return"";if(typeof e=="function")return be(e,Oe(e));if(typeof e=="string")return ne(e);switch(e){case g:return ne("Suspense");case c:return ne("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return Ce(e.render);case _:return ie(e.type,l,u);case x:{var b=e,P=b._payload,$=b._init;try{return ie($(P),l,u)}catch{}}}return""}var re=Object.prototype.hasOwnProperty,f={},S=I.ReactDebugCurrentFrame;function W(e){if(e){var l=e._owner,u=ie(e.type,e._source,l?l.type:null);S.setExtraStackFrame(u)}else S.setExtraStackFrame(null)}function Q(e,l,u,b,P){{var $=Function.call.bind(re);for(var O in e)if($(e,O)){var T=void 0;try{if(typeof e[O]!="function"){var q=Error((b||"React class")+": "+u+" type `"+O+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[O]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw q.name="Invariant Violation",q}T=e[O](l,O,b,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(U){T=U}T&&!(T instanceof Error)&&(W(P),F("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",b||"React class",u,O,typeof T),W(null)),T instanceof Error&&!(T.message in f)&&(f[T.message]=!0,W(P),F("Failed %s type: %s",u,T.message),W(null))}}}var ee=Array.isArray;function Z(e){return ee(e)}function Ne(e){{var l=typeof Symbol=="function"&&Symbol.toStringTag,u=l&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u}}function we(e){try{return Ee(e),!1}catch{return!0}}function Ee(e){return""+e}function Ie(e){if(we(e))return F("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ne(e)),Ee(e)}var Le=I.ReactCurrentOwner,st={key:!0,ref:!0,__self:!0,__source:!0},ze,Ge;function nt(e){if(re.call(e,"ref")){var l=Object.getOwnPropertyDescriptor(e,"ref").get;if(l&&l.isReactWarning)return!1}return e.ref!==void 0}function at(e){if(re.call(e,"key")){var l=Object.getOwnPropertyDescriptor(e,"key").get;if(l&&l.isReactWarning)return!1}return e.key!==void 0}function it(e,l){typeof e.ref=="string"&&Le.current}function ot(e,l){{var u=function(){ze||(ze=!0,F("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",l))};u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}}function lt(e,l){{var u=function(){Ge||(Ge=!0,F("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",l))};u.isReactWarning=!0,Object.defineProperty(e,"ref",{get:u,configurable:!0})}}var ct=function(e,l,u,b,P,$,O){var T={$$typeof:t,type:e,key:l,ref:u,props:O,_owner:$};return T._store={},Object.defineProperty(T._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(T,"_self",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.defineProperty(T,"_source",{configurable:!1,enumerable:!1,writable:!1,value:P}),Object.freeze&&(Object.freeze(T.props),Object.freeze(T)),T};function ut(e,l,u,b,P){{var $,O={},T=null,q=null;u!==void 0&&(Ie(u),T=""+u),at(l)&&(Ie(l.key),T=""+l.key),nt(l)&&(q=l.ref,it(l,P));for($ in l)re.call(l,$)&&!st.hasOwnProperty($)&&(O[$]=l[$]);if(e&&e.defaultProps){var U=e.defaultProps;for($ in U)O[$]===void 0&&(O[$]=U[$])}if(T||q){var B=typeof e=="function"?e.displayName||e.name||"Unknown":e;T&&ot(O,B),q&&lt(O,B)}return ct(e,T,q,P,b,Le.current,O)}}var Ae=I.ReactCurrentOwner,We=I.ReactDebugCurrentFrame;function oe(e){if(e){var l=e._owner,u=ie(e.type,e._source,l?l.type:null);We.setExtraStackFrame(u)}else We.setExtraStackFrame(null)}var Pe;Pe=!1;function $e(e){return typeof e=="object"&&e!==null&&e.$$typeof===t}function Ye(){{if(Ae.current){var e=L(Ae.current.type);if(e)return`
22
22
 
23
23
  Check the render method of \``+e+"`."}return""}}function dt(e){return""}var qe={};function ft(e){{var l=Ye();if(!l){var u=typeof e=="string"?e:e.displayName||e.name;u&&(l=`
24
24
 
25
- Check the top-level render call using <`+u+">.")}return l}}function Ve(e,l){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var u=ft(l);if(qe[u])return;qe[u]=!0;var b="";e&&e._owner&&e._owner!==Ae.current&&(b=" It was passed a child from "+L(e._owner.type)+"."),oe(e),F('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,b),oe(null)}}function He(e,l){{if(typeof e!="object")return;if(X(e))for(var u=0;u<e.length;u++){var b=e[u];$e(b)&&Ve(b,l)}else if($e(e))e._store&&(e._store.validated=!0);else if(e){var P=V(e);if(typeof P=="function"&&P!==e.entries)for(var $=P.call(e),O;!(O=$.next()).done;)$e(O.value)&&Ve(O.value,l)}}}function pt(e){{var l=e.type;if(l==null||typeof l=="string")return;var u;if(typeof l=="function")u=l.propTypes;else if(typeof l=="object"&&(l.$$typeof===d||l.$$typeof===j))u=l.propTypes;else return;if(u){var b=L(l);K(u,e.props,"prop",b,e)}else if(l.PropTypes!==void 0&&!Pe){Pe=!0;var P=L(l);F("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",P||"Unknown")}typeof l.getDefaultProps=="function"&&!l.getDefaultProps.isReactClassApproved&&F("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ht(e){{for(var l=Object.keys(e.props),u=0;u<l.length;u++){var b=l[u];if(b!=="children"&&b!=="key"){oe(e),F("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),oe(null);break}}e.ref!==null&&(oe(e),F("Invalid attribute `ref` supplied to `React.Fragment`."),oe(null))}}var Je={};function Ke(e,l,u,b,P,$){{var O=A(e);if(!O){var T="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(T+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var q=dt();q?T+=q:T+=Ye();var U;e===null?U="null":X(e)?U="array":e!==void 0&&e.$$typeof===t?(U="<"+(L(e.type)||"Unknown")+" />",T=" Did you accidentally export a JSX literal instead of a component?"):U=typeof e,F("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",U,T)}var B=ut(e,l,u,P,$);if(B==null)return B;if(O){var Z=l.children;if(Z!==void 0)if(b)if(X(Z)){for(var le=0;le<Z.length;le++)He(Z[le],e);Object.freeze&&Object.freeze(Z)}else F("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else He(Z,e)}if(re.call(l,"key")){var ne=L(e),H=Object.keys(l).filter(function(bt){return bt!=="key"}),Fe=H.length>0?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}";if(!Je[ne+Fe]){var vt=H.length>0?"{"+H.join(": ..., ")+": ...}":"{}";F(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+u+">.")}return l}}function Ve(e,l){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var u=ft(l);if(qe[u])return;qe[u]=!0;var b="";e&&e._owner&&e._owner!==Ae.current&&(b=" It was passed a child from "+L(e._owner.type)+"."),oe(e),F('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,b),oe(null)}}function He(e,l){{if(typeof e!="object")return;if(Z(e))for(var u=0;u<e.length;u++){var b=e[u];$e(b)&&Ve(b,l)}else if($e(e))e._store&&(e._store.validated=!0);else if(e){var P=V(e);if(typeof P=="function"&&P!==e.entries)for(var $=P.call(e),O;!(O=$.next()).done;)$e(O.value)&&Ve(O.value,l)}}}function pt(e){{var l=e.type;if(l==null||typeof l=="string")return;var u;if(typeof l=="function")u=l.propTypes;else if(typeof l=="object"&&(l.$$typeof===d||l.$$typeof===_))u=l.propTypes;else return;if(u){var b=L(l);Q(u,e.props,"prop",b,e)}else if(l.PropTypes!==void 0&&!Pe){Pe=!0;var P=L(l);F("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",P||"Unknown")}typeof l.getDefaultProps=="function"&&!l.getDefaultProps.isReactClassApproved&&F("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ht(e){{for(var l=Object.keys(e.props),u=0;u<l.length;u++){var b=l[u];if(b!=="children"&&b!=="key"){oe(e),F("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),oe(null);break}}e.ref!==null&&(oe(e),F("Invalid attribute `ref` supplied to `React.Fragment`."),oe(null))}}var Je={};function Ke(e,l,u,b,P,$){{var O=A(e);if(!O){var T="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(T+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var q=dt();q?T+=q:T+=Ye();var U;e===null?U="null":Z(e)?U="array":e!==void 0&&e.$$typeof===t?(U="<"+(L(e.type)||"Unknown")+" />",T=" Did you accidentally export a JSX literal instead of a component?"):U=typeof e,F("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",U,T)}var B=ut(e,l,u,P,$);if(B==null)return B;if(O){var X=l.children;if(X!==void 0)if(b)if(Z(X)){for(var le=0;le<X.length;le++)He(X[le],e);Object.freeze&&Object.freeze(X)}else F("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else He(X,e)}if(re.call(l,"key")){var se=L(e),H=Object.keys(l).filter(function(bt){return bt!=="key"}),Fe=H.length>0?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}";if(!Je[se+Fe]){var vt=H.length>0?"{"+H.join(": ..., ")+": ...}":"{}";F(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,Fe,ne,vt,ne),Je[ne+Fe]=!0}}return e===n?ht(B):pt(B),B}}function gt(e,l,u){return Ke(e,l,u,!0)}function mt(e,l,u){return Ke(e,l,u,!1)}var yt=mt,xt=gt;he.Fragment=n,he.jsx=yt,he.jsxs=xt}()),he}process.env.NODE_ENV==="production"?Ue.exports=kt():Ue.exports=Tt();var a=Ue.exports;class je{static filter(t,r){return t.filter(r)}static filterBy(t,r,n){return t.filter(i=>i[r]===n)}static filterByFields(t,r){return t.filter(n=>Object.entries(r).every(([i,s])=>n[i]===s))}static sort(t,r,n="asc"){return[...t].sort((i,s)=>{const o=i[r],p=s[r];if(o===p)return 0;let d=0;return o>p&&(d=1),o<p&&(d=-1),n==="asc"?d:-d})}static search(t,r,n){if(!r.trim())return t;const i=r.toLowerCase();return t.filter(s=>n.some(o=>{const p=s[o];return p==null?!1:String(p).toLowerCase().includes(i)}))}static paginate(t,r,n){const i=(r-1)*n,s=i+n;return{data:t.slice(i,s),total:t.length,page:r,totalPages:Math.ceil(t.length/n)}}static groupBy(t,r){return t.reduce((n,i)=>{const s=String(i[r]);return n[s]||(n[s]=[]),n[s].push(i),n},{})}static unique(t,r){const n=t.map(i=>i[r]);return[...new Set(n)]}static countBy(t,r){return t.reduce((n,i)=>{const s=String(i[r]);return n[s]=(n[s]||0)+1,n},{})}static pipe(t,r){return r.reduce((n,i)=>i(n),t)}}function Rt({endpoint:h,params:t,layout:r="list",title:n,emptyMessage:i="No items found",renderItem:s,keyExtractor:o=(C,V)=>C.id||C._id||String(V),searchable:p=!1,searchFields:d=[],searchPlaceholder:g="Search...",filters:c=[],pageSize:j=20,onItemClick:x,onRefresh:m,theme:k={}}){const{data:C,loading:V,error:I,refetch:F}=rt(h,t),[Y,E]=w.useState(""),[M,y]=w.useState({}),[N,D]=w.useState(1),S=w.useMemo(()=>{if(!C)return{data:[],total:0,totalPages:0};let R=C;return p&&Y&&d.length>0&&(R=je.search(R,Y,d)),Object.keys(M).length>0&&(R=je.filterByFields(R,M)),je.paginate(R,N,j)},[C,Y,M,N,j,p,d]);w.useEffect(()=>{D(1)},[Y,M]);const A=()=>{E(""),y({}),D(1),F(),m==null||m()},v={background:k.background||"#ffffff",cardBackground:k.cardBackground||"#f9fafb",text:k.text||"#111827",textSecondary:k.textSecondary||"#6b7280",border:k.border||"#e5e7eb",primary:k.primary||"#3b82f6"},L=s||(R=>a.jsxs("div",{style:{padding:"16px",cursor:x?"pointer":"default"},children:[a.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:v.text},children:R.title||R.name||R.label||"Untitled"}),R.description&&a.jsx("div",{style:{fontSize:"13px",color:v.textSecondary,marginTop:"4px"},children:R.description})]}));return V&&!C?a.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:v.textSecondary},children:"Loading..."}):I?a.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[a.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),a.jsx("div",{style:{fontSize:"14px"},children:I.message}),a.jsx("button",{onClick:A,style:{marginTop:"16px",padding:"8px 16px",background:v.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):a.jsxs("div",{style:{background:v.background,borderRadius:"12px",overflow:"hidden"},children:[(n||p||c.length>0)&&a.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${v.border}`},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:p||c.length>0?"12px":"0"},children:[n&&a.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:v.text},children:n}),a.jsx("button",{onClick:A,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",color:v.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),p&&a.jsx("input",{type:"text",placeholder:g,value:Y,onChange:R=>E(R.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${v.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),a.jsx("div",{style:{display:r==="grid"?"grid":"flex",flexDirection:r==="list"?"column":void 0,gridTemplateColumns:r==="grid"?"repeat(auto-fill, minmax(250px, 1fr))":void 0,gap:r==="list"?"0":"16px",padding:r==="list"?"0":"16px"},children:S.data.length===0?a.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:i}):S.data.map((R,z)=>a.jsx("div",{onClick:()=>x==null?void 0:x(R),style:{background:v.cardBackground,borderRadius:r==="list"?"0":"8px",borderBottom:r==="list"?`1px solid ${v.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:J=>{x&&(J.currentTarget.style.background=v.border)},onMouseLeave:J=>{J.currentTarget.style.background=v.cardBackground},children:L(R,z)},o(R,z)))}),S.totalPages>1&&a.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${v.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{fontSize:"13px",color:v.textSecondary},children:["Page ",N," of ",S.totalPages]}),a.jsxs("div",{style:{display:"flex",gap:"8px"},children:[a.jsx("button",{onClick:()=>D(R=>Math.max(1,R-1)),disabled:N===1,style:{padding:"6px 12px",border:`1px solid ${v.border}`,borderRadius:"6px",background:"white",cursor:N===1?"not-allowed":"pointer",opacity:N===1?.5:1},children:"Previous"}),a.jsx("button",{onClick:()=>D(R=>Math.min(S.totalPages,R+1)),disabled:N===S.totalPages,style:{padding:"6px 12px",border:`1px solid ${v.border}`,borderRadius:"6px",background:"white",cursor:N===S.totalPages?"not-allowed":"pointer",opacity:N===S.totalPages?.5:1},children:"Next"})]})]})]})}function Ct({item:h,onClick:t,title:r=o=>o.title||o.name||o.label||"Untitled",subtitle:n=o=>o.description||o.subtitle||"",image:i=o=>o.image||o.thumbnail||o.photo,badge:s=o=>o.badge||o.tag||o.type}){const o=r(h),p=n(h),d=i(h),g=s(h);return a.jsxs("div",{onClick:t,className:`
30
+ <%s key={someKey} {...props} />`,Fe,se,vt,se),Je[se+Fe]=!0}}return e===s?ht(B):pt(B),B}}function gt(e,l,u){return Ke(e,l,u,!0)}function mt(e,l,u){return Ke(e,l,u,!1)}var yt=mt,xt=gt;he.Fragment=s,he.jsx=yt,he.jsxs=xt}()),he}process.env.NODE_ENV==="production"?Ue.exports=kt():Ue.exports=Tt();var a=Ue.exports;class je{static filter(t,r){return t.filter(r)}static filterBy(t,r,s){return t.filter(i=>i[r]===s)}static filterByFields(t,r){return t.filter(s=>Object.entries(r).every(([i,n])=>s[i]===n))}static sort(t,r,s="asc"){return[...t].sort((i,n)=>{const o=i[r],p=n[r];if(o===p)return 0;let d=0;return o>p&&(d=1),o<p&&(d=-1),s==="asc"?d:-d})}static search(t,r,s){if(!r.trim())return t;const i=r.toLowerCase();return t.filter(n=>s.some(o=>{const p=n[o];return p==null?!1:String(p).toLowerCase().includes(i)}))}static paginate(t,r,s){const i=(r-1)*s,n=i+s;return{data:t.slice(i,n),total:t.length,page:r,totalPages:Math.ceil(t.length/s)}}static groupBy(t,r){return t.reduce((s,i)=>{const n=String(i[r]);return s[n]||(s[n]=[]),s[n].push(i),s},{})}static unique(t,r){const s=t.map(i=>i[r]);return[...new Set(s)]}static countBy(t,r){return t.reduce((s,i)=>{const n=String(i[r]);return s[n]=(s[n]||0)+1,s},{})}static pipe(t,r){return r.reduce((s,i)=>i(s),t)}}function Rt({endpoint:h,params:t,layout:r="list",title:s,emptyMessage:i="No items found",renderItem:n,keyExtractor:o=(C,V)=>C.id||C._id||String(V),searchable:p=!1,searchFields:d=[],searchPlaceholder:g="Search...",filters:c=[],pageSize:_=20,onItemClick:x,onRefresh:m,theme:k={}}){const{data:C,loading:V,error:I,refetch:F}=rt(h,t),[Y,E]=w.useState(""),[M,y]=w.useState({}),[N,D]=w.useState(1),j=w.useMemo(()=>{if(!C)return{data:[],total:0,totalPages:0};let R=C;return p&&Y&&d.length>0&&(R=je.search(R,Y,d)),Object.keys(M).length>0&&(R=je.filterByFields(R,M)),je.paginate(R,N,_)},[C,Y,M,N,_,p,d]);w.useEffect(()=>{D(1)},[Y,M]);const A=()=>{E(""),y({}),D(1),F(),m==null||m()},v={background:k.background||"#ffffff",cardBackground:k.cardBackground||"#f9fafb",text:k.text||"#111827",textSecondary:k.textSecondary||"#6b7280",border:k.border||"#e5e7eb",primary:k.primary||"#3b82f6"},L=n||(R=>a.jsxs("div",{style:{padding:"16px",cursor:x?"pointer":"default"},children:[a.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:v.text},children:R.title||R.name||R.label||"Untitled"}),R.description&&a.jsx("div",{style:{fontSize:"13px",color:v.textSecondary,marginTop:"4px"},children:R.description})]}));return V&&!C?a.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:v.textSecondary},children:"Loading..."}):I?a.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[a.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),a.jsx("div",{style:{fontSize:"14px"},children:I.message}),a.jsx("button",{onClick:A,style:{marginTop:"16px",padding:"8px 16px",background:v.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):a.jsxs("div",{style:{background:v.background,borderRadius:"12px",overflow:"hidden"},children:[(s||p||c.length>0)&&a.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${v.border}`},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:p||c.length>0?"12px":"0"},children:[s&&a.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:v.text},children:s}),a.jsx("button",{onClick:A,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",color:v.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),p&&a.jsx("input",{type:"text",placeholder:g,value:Y,onChange:R=>E(R.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${v.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),a.jsx("div",{style:{display:r==="grid"?"grid":"flex",flexDirection:r==="list"?"column":void 0,gridTemplateColumns:r==="grid"?"repeat(auto-fill, minmax(250px, 1fr))":void 0,gap:r==="list"?"0":"16px",padding:r==="list"?"0":"16px"},children:j.data.length===0?a.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:i}):j.data.map((R,z)=>a.jsx("div",{onClick:()=>x==null?void 0:x(R),style:{background:v.cardBackground,borderRadius:r==="list"?"0":"8px",borderBottom:r==="list"?`1px solid ${v.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:J=>{x&&(J.currentTarget.style.background=v.border)},onMouseLeave:J=>{J.currentTarget.style.background=v.cardBackground},children:L(R,z)},o(R,z)))}),j.totalPages>1&&a.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${v.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{fontSize:"13px",color:v.textSecondary},children:["Page ",N," of ",j.totalPages]}),a.jsxs("div",{style:{display:"flex",gap:"8px"},children:[a.jsx("button",{onClick:()=>D(R=>Math.max(1,R-1)),disabled:N===1,style:{padding:"6px 12px",border:`1px solid ${v.border}`,borderRadius:"6px",background:"white",cursor:N===1?"not-allowed":"pointer",opacity:N===1?.5:1},children:"Previous"}),a.jsx("button",{onClick:()=>D(R=>Math.min(j.totalPages,R+1)),disabled:N===j.totalPages,style:{padding:"6px 12px",border:`1px solid ${v.border}`,borderRadius:"6px",background:"white",cursor:N===j.totalPages?"not-allowed":"pointer",opacity:N===j.totalPages?.5:1},children:"Next"})]})]})]})}function Ct({item:h,onClick:t,title:r=o=>o.title||o.name||o.label||"Untitled",subtitle:s=o=>o.description||o.subtitle||"",image:i=o=>o.image||o.thumbnail||o.photo,badge:n=o=>o.badge||o.tag||o.type}){const o=r(h),p=s(h),d=i(h),g=n(h);return a.jsxs("div",{onClick:t,className:`
31
31
  flex items-center gap-4 p-4 border-b border-gray-200
32
32
  hover:bg-gray-50 transition-colors
33
33
  ${t?"cursor-pointer":""}
34
- `,children:[d&&a.jsx("div",{className:"flex-shrink-0",children:a.jsx("img",{src:d,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),g&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:g})]}),p&&a.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:p})]}),t&&a.jsx("div",{className:"flex-shrink-0 text-gray-400",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function Ot({item:h,onClose:t,title:r=s=>s.title||s.name||s.label||"Detail",image:n=s=>s.image||s.thumbnail||s.photo,fields:i=[]}){if(!h)return null;const s=r(h),o=n(h);return a.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:a.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[a.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:s}),t&&a.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"p-6",children:[o&&a.jsx("div",{className:"mb-6",children:a.jsx("img",{src:o,alt:s,className:"w-full h-64 object-cover rounded-lg"})}),i.length>0&&a.jsx("div",{className:"space-y-4",children:i.map((p,d)=>{const g=p.value(h);return g==null||g===""?null:a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:p.label}),a.jsx("div",{className:"text-base text-gray-900",children:typeof g=="object"?JSON.stringify(g,null,2):String(g)})]},d)})}),i.length===0&&a.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(h,null,2)})]}),t&&a.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:a.jsx("button",{onClick:t,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const Nt={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function At({nodes:h,cardCount:t=2,minInterval:r=1e3,maxInterval:n=3e3,onCardClick:i,cardSize:s="medium",className:o=""}){const p=Math.min(Math.max(t,1),5),[d,g]=w.useState([]),[c,j]=w.useState([]),[x,m]=w.useState(Array(p).fill(!1)),[k,C]=w.useState(Array(p).fill(!1)),V=w.useRef([]),I=w.useCallback(y=>{const N=h.filter(S=>!y.includes(S._id));if(N.length===0)return null;const D=Math.floor(Math.random()*N.length);return N[D]},[h]),F=w.useCallback(()=>Math.random()*(n-r)+r,[r,n]);w.useEffect(()=>{if(h.length===0){g([]),j([]);return}const y=[],N=[],D=[];for(let S=0;S<p&&S<h.length;S++){const A=I(D);A&&(y.push(A),D.push(A._id))}for(let S=0;S<y.length;S++){const A=[y[S]._id,...y.filter((W,L)=>L!==S).map(W=>W._id)],v=I(A);v?N.push(v):N.push(y[S])}g(y),j(N)},[h,p,I]);const Y=w.useCallback(y=>{const N=F(),D=setTimeout(()=>{m(S=>{const A=[...S];return A[y]=!A[y],A}),setTimeout(()=>{C(S=>{const A=[...S];return A[y]=!A[y],A}),setTimeout(()=>{const S=!k[y];S&&g(A=>{const v=[...A];return v[y]=c[y],v}),j(A=>{const v=[...A],L=[(S?c[y]:d[y])._id,...d.filter((z,J)=>J!==y).map(z=>z._id),...A.filter((z,J)=>J!==y).map(z=>z._id)],R=I(L);return R&&(v[y]=R),v}),setTimeout(()=>{Y(y)},150)},200)},150)},N);V.current[y]=D},[F,I,d,c,k]),E=w.useRef(!1);w.useEffect(()=>{if(!(d.length===0||h.length<=1)&&!E.current){E.current=!0;for(let y=0;y<d.length;y++)Y(y);return()=>{V.current.forEach(y=>clearTimeout(y)),V.current=[],E.current=!1}}},[d.length,h.length]);const M=y=>{i&&i(y)};return h.length===0?a.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:a.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):d.length===0?a.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:a.jsx("p",{className:"text-gray-500",children:"Loading..."})}):a.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${o}`,children:d.map((y,N)=>{const D=c[N],S=k[N];return a.jsx("div",{className:`relative ${Nt[s]}`,style:{perspective:"1000px"},onClick:()=>M(S?D:y),children:a.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${x[N]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[a.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:S?0:1},children:a.jsxs("div",{style:{transform:x[N]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[a.jsx("img",{src:y.data.image,alt:y.title,className:"w-full h-full object-cover"}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:a.jsx("p",{className:"text-white text-sm font-medium truncate",children:y.title})})]})}),D&&a.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:S?1:0},children:a.jsxs("div",{style:{transform:x[N]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[a.jsx("img",{src:D.data.image,alt:D.title,className:"w-full h-full object-cover"}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:a.jsx("p",{className:"text-white text-sm font-medium truncate",children:D.title})})]})})]})},`slot-${N}`)})})}function _e(h){if(!h)return"";const t=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return h.replace(t,(r,n,i,s)=>{try{if(i.toUpperCase()==="B"){const o=atob(s);return decodeURIComponent(escape(o))}else if(i.toUpperCase()==="Q"){const o=s.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(p,d)=>String.fromCharCode(parseInt(d,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return r}).replace(/\s+/g," ").trim()}const Pt={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function $t({baseUrl:h,systemId:t,accountId:r,limit:n=30,folder:i,selectable:s=!0,showDetail:o=!1,emptyMessage:p="No emails",autoLoad:d=!0,onSelect:g,onSelectionChange:c,onDelete:j,onError:x,onLoad:m,renderItem:k,renderDetail:C,renderActions:V,renderEmpty:I,renderLoading:F,theme:Y={}}){const E={...Pt,...Y},[M,y]=w.useState([]),[N,D]=w.useState(!1),[S,A]=w.useState(null),[v,W]=w.useState(new Set),[L,R]=w.useState(null),[z,J]=w.useState(null),Q=w.useMemo(()=>t?new Ze({baseUrl:h,system_id:t}):null,[h,t]),te=w.useCallback(async()=>{if(Q){D(!0),A(null);try{const f=await Q.listEmails(r,n,i);if(f!=null&&f.messages){const _=[...f.messages].sort((G,K)=>{const ee=new Date(G.date).getTime()||0;return(new Date(K.date).getTime()||0)-ee});y(_),m==null||m(_)}}catch(f){const _=f instanceof Error?f:new Error("Failed to fetch emails");A(_.message),x==null||x(_)}D(!1)}},[Q,r,n,i,x,m]);w.useEffect(()=>{d&&te()},[d,te]),w.useEffect(()=>{te()},[i]);const ge=w.useCallback(f=>{g==null||g(f),o&&J(f)},[g,o]),me=w.useCallback((f,_,G)=>{if(!s){g==null||g(f),o&&J(f);return}const K=f.uid;if(G.shiftKey&&L!==null){const ee=Math.min(L,_),X=Math.max(L,_),Ne=M.slice(ee,X+1).map(Ee=>Ee.uid),we=new Set(Ne);W(we),c==null||c(Array.from(we))}else if(G.ctrlKey||G.metaKey)W(ee=>{const X=new Set(ee);return X.has(K)?X.delete(K):X.add(K),c==null||c(Array.from(X)),X}),R(_);else{const ee=new Set([K]);W(ee),R(_),c==null||c(Array.from(ee))}},[s,L,M,v,g,c,o]),ye=w.useCallback(async()=>{if(!(!Q||v.size===0))try{const f=await Q.trashEmails(r,Array.from(v));if(console.log("Trash result:",f),f.success&&f.moved>0){y(G=>G.filter(K=>!v.has(K.uid)));const _=Array.from(v);W(new Set),j==null||j(_)}else A("Failed to move emails to trash")}catch(f){const _=f instanceof Error?f:new Error("Trash failed");console.error("Trash error:",_),A(_.message),x==null||x(_)}},[Q,r,v,j,x]),xe=w.useCallback(async()=>{if(!(!Q||v.size===0))try{const f=await Q.archiveEmails(r,Array.from(v));if(console.log("Archive result:",f),f.success&&f.archived>0){y(G=>G.filter(K=>!v.has(K.uid)));const _=Array.from(v);W(new Set),j==null||j(_)}else A("Failed to archive emails")}catch(f){const _=f instanceof Error?f:new Error("Archive failed");console.error("Archive error:",_),A(_.message),x==null||x(_)}},[Q,r,v,j,x]),ve=w.useCallback(()=>{if(v.size===M.length)W(new Set),c==null||c([]);else{const f=new Set(M.map(_=>_.uid));W(f),c==null||c(Array.from(f))}},[M,v.size,c]),ke=w.useCallback(()=>{W(new Set),c==null||c([])},[c]),Te={delete:ye,archive:xe,refresh:te,selectAll:ve,clearSelection:ke},ce=f=>{if(!f)return"";const _=new Date(f),G=new Date;return _.toDateString()===G.toDateString()?_.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):_.toLocaleDateString([],{month:"short",day:"numeric"})},ue=(f,_)=>a.jsx("div",{style:{padding:"12px 16px",background:_?E.selectedBackground:f.seen?E.cardBackground:E.unreadBackground,borderBottom:`1px solid ${E.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:"14px",fontWeight:f.seen?400:600,color:E.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_e(f.from).split("@")[0]}),a.jsx("div",{style:{fontSize:"14px",fontWeight:f.seen?400:500,color:f.seen?E.textSecondary:E.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_e(f.subject)||"(No subject)"})]}),a.jsx("div",{style:{fontSize:"12px",color:E.textSecondary,flexShrink:0},children:ce(f.date)})]})}),se=f=>a.jsxs("div",{style:{padding:"24px"},children:[a.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:E.text},children:_e(f.subject)||"(No subject)"}),a.jsxs("div",{style:{fontSize:"14px",color:E.textSecondary,marginBottom:"16px"},children:["From: ",_e(f.from)," • ",new Date(f.date).toLocaleString()]}),a.jsx("div",{style:{fontSize:"14px",color:E.text},children:"Email body not loaded. Implement getEmail(uid) to fetch full content."})]}),de=(f,_)=>a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:E.cardBackground,borderBottom:`1px solid ${E.border}`},children:[a.jsx("button",{onClick:_.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${E.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:E.text},children:f.length===M.length?"Deselect All":"Select All"}),f.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{style:{fontSize:"13px",color:E.textSecondary},children:[f.length," selected"]}),a.jsx("button",{onClick:_.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${E.border}`,borderRadius:"6px",cursor:"pointer",color:E.textSecondary},children:a.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),a.jsx("button",{onClick:_.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${E.border}`,borderRadius:"6px",cursor:"pointer",color:E.textSecondary},children:a.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),a.jsx("div",{style:{flex:1}}),a.jsx("button",{onClick:_.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${E.border}`,borderRadius:"6px",cursor:"pointer",color:E.textSecondary},children:a.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),ae=()=>a.jsx("div",{style:{padding:"48px",textAlign:"center",color:E.textSecondary},children:p}),Re=()=>a.jsx("div",{style:{padding:"48px",textAlign:"center",color:E.textSecondary},children:"Loading..."}),be=k||ue,Ce=C||se,Oe=V||de,ie=I||ae,re=F||Re;return N&&M.length===0?a.jsx("div",{style:{background:E.background,width:"100%",height:"100%"},children:re()}):a.jsxs("div",{style:{display:"flex",background:E.background,width:"100%",height:"100%"},children:[a.jsxs("div",{style:{flex:o&&z?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&z?`1px solid ${E.border}`:"none",overflow:"hidden"},children:[s&&Oe(Array.from(v),Te),S&&a.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:E.danger,fontSize:"14px",borderBottom:`1px solid ${E.border}`},children:S}),a.jsx("div",{style:{flex:1,overflowY:"auto"},children:M.length===0?ie():M.map((f,_)=>a.jsx("div",{onClick:G=>me(f,_,G),onDoubleClick:()=>ge(f),children:be(f,v.has(f.uid))},f.uid))})]}),o&&z&&a.jsx("div",{style:{flex:1,overflowY:"auto"},children:Ce(z)})]})}exports.AnimatedCardFlip=At;exports.ApiClient=tt;exports.AuthManager=et;exports.Card=Ct;exports.DataOperations=je;exports.Detail=Ot;exports.GraphClient=_t;exports.Mail=$t;exports.MailClient=Ze;exports.Stack=Rt;exports.getApiClient=Be;exports.initializeApiClient=jt;exports.useMutation=St;exports.useQuery=rt;
34
+ `,children:[d&&a.jsx("div",{className:"flex-shrink-0",children:a.jsx("img",{src:d,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),g&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:g})]}),p&&a.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:p})]}),t&&a.jsx("div",{className:"flex-shrink-0 text-gray-400",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function Ot({item:h,onClose:t,title:r=n=>n.title||n.name||n.label||"Detail",image:s=n=>n.image||n.thumbnail||n.photo,fields:i=[]}){if(!h)return null;const n=r(h),o=s(h);return a.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:a.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[a.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:n}),t&&a.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"p-6",children:[o&&a.jsx("div",{className:"mb-6",children:a.jsx("img",{src:o,alt:n,className:"w-full h-64 object-cover rounded-lg"})}),i.length>0&&a.jsx("div",{className:"space-y-4",children:i.map((p,d)=>{const g=p.value(h);return g==null||g===""?null:a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:p.label}),a.jsx("div",{className:"text-base text-gray-900",children:typeof g=="object"?JSON.stringify(g,null,2):String(g)})]},d)})}),i.length===0&&a.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(h,null,2)})]}),t&&a.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:a.jsx("button",{onClick:t,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const Nt={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function At({nodes:h,cardCount:t=2,minInterval:r=1e3,maxInterval:s=3e3,onCardClick:i,cardSize:n="medium",className:o=""}){const p=Math.min(Math.max(t,1),5),[d,g]=w.useState([]),[c,_]=w.useState([]),[x,m]=w.useState(Array(p).fill(!1)),[k,C]=w.useState(Array(p).fill(!1)),V=w.useRef([]),I=w.useCallback(y=>{const N=h.filter(j=>!y.includes(j._id));if(N.length===0)return null;const D=Math.floor(Math.random()*N.length);return N[D]},[h]),F=w.useCallback(()=>Math.random()*(s-r)+r,[r,s]);w.useEffect(()=>{if(h.length===0){g([]),_([]);return}const y=[],N=[],D=[];for(let j=0;j<p&&j<h.length;j++){const A=I(D);A&&(y.push(A),D.push(A._id))}for(let j=0;j<y.length;j++){const A=[y[j]._id,...y.filter((G,L)=>L!==j).map(G=>G._id)],v=I(A);v?N.push(v):N.push(y[j])}g(y),_(N)},[h,p,I]);const Y=w.useCallback(y=>{const N=F(),D=setTimeout(()=>{m(j=>{const A=[...j];return A[y]=!A[y],A}),setTimeout(()=>{C(j=>{const A=[...j];return A[y]=!A[y],A}),setTimeout(()=>{const j=!k[y];j&&g(A=>{const v=[...A];return v[y]=c[y],v}),_(A=>{const v=[...A],L=[(j?c[y]:d[y])._id,...d.filter((z,J)=>J!==y).map(z=>z._id),...A.filter((z,J)=>J!==y).map(z=>z._id)],R=I(L);return R&&(v[y]=R),v}),setTimeout(()=>{Y(y)},150)},200)},150)},N);V.current[y]=D},[F,I,d,c,k]),E=w.useRef(!1);w.useEffect(()=>{if(!(d.length===0||h.length<=1)&&!E.current){E.current=!0;for(let y=0;y<d.length;y++)Y(y);return()=>{V.current.forEach(y=>clearTimeout(y)),V.current=[],E.current=!1}}},[d.length,h.length]);const M=y=>{i&&i(y)};return h.length===0?a.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:a.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):d.length===0?a.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:a.jsx("p",{className:"text-gray-500",children:"Loading..."})}):a.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${o}`,children:d.map((y,N)=>{const D=c[N],j=k[N];return a.jsx("div",{className:`relative ${Nt[n]}`,style:{perspective:"1000px"},onClick:()=>M(j?D:y),children:a.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${x[N]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[a.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:j?0:1},children:a.jsxs("div",{style:{transform:x[N]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[a.jsx("img",{src:y.data.image,alt:y.title,className:"w-full h-full object-cover"}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:a.jsx("p",{className:"text-white text-sm font-medium truncate",children:y.title})})]})}),D&&a.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:j?1:0},children:a.jsxs("div",{style:{transform:x[N]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[a.jsx("img",{src:D.data.image,alt:D.title,className:"w-full h-full object-cover"}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:a.jsx("p",{className:"text-white text-sm font-medium truncate",children:D.title})})]})})]})},`slot-${N}`)})})}function _e(h){if(!h)return"";const t=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return h.replace(t,(r,s,i,n)=>{try{if(i.toUpperCase()==="B"){const o=atob(n);return decodeURIComponent(escape(o))}else if(i.toUpperCase()==="Q"){const o=n.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(p,d)=>String.fromCharCode(parseInt(d,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return r}).replace(/\s+/g," ").trim()}const Pt={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function $t({baseUrl:h,systemId:t,accountId:r,limit:s=30,folder:i,selectable:n=!0,showDetail:o=!1,emptyMessage:p="No emails",autoLoad:d=!0,onSelect:g,onSelectionChange:c,onDelete:_,onError:x,onLoad:m,renderItem:k,renderDetail:C,renderActions:V,renderEmpty:I,renderLoading:F,theme:Y={}}){const E={...Pt,...Y},[M,y]=w.useState([]),[N,D]=w.useState(!1),[j,A]=w.useState(null),[v,G]=w.useState(new Set),[L,R]=w.useState(null),[z,J]=w.useState(null),K=w.useMemo(()=>t?new Ze({baseUrl:h,system_id:t}):null,[h,t]),te=w.useCallback(async()=>{if(K){D(!0),A(null);try{const f=await K.listEmailsSorted(r,i||"INBOX",s);f!=null&&f.messages&&(y(f.messages),m==null||m(f.messages))}catch(f){const S=f instanceof Error?f:new Error("Failed to fetch emails");A(S.message),x==null||x(S)}D(!1)}},[K,r,s,i,x,m]);w.useEffect(()=>{d&&te()},[d,te]),w.useEffect(()=>{te()},[i]);const ge=w.useCallback(f=>{g==null||g(f),o&&J(f)},[g,o]),me=w.useCallback((f,S,W)=>{if(!n){g==null||g(f),o&&J(f);return}const Q=f.uid;if(W.shiftKey&&L!==null){const ee=Math.min(L,S),Z=Math.max(L,S),Ne=M.slice(ee,Z+1).map(Ee=>Ee.uid),we=new Set(Ne);G(we),c==null||c(Array.from(we))}else if(W.ctrlKey||W.metaKey)G(ee=>{const Z=new Set(ee);return Z.has(Q)?Z.delete(Q):Z.add(Q),c==null||c(Array.from(Z)),Z}),R(S);else{const ee=new Set([Q]);G(ee),R(S),c==null||c(Array.from(ee))}},[n,L,M,v,g,c,o]),ye=w.useCallback(async()=>{if(!(!K||v.size===0))try{const f=await K.trashEmails(r,Array.from(v));if(console.log("Trash result:",f),f.success&&f.moved>0){y(W=>W.filter(Q=>!v.has(Q.uid)));const S=Array.from(v);G(new Set),_==null||_(S)}else A("Failed to move emails to trash")}catch(f){const S=f instanceof Error?f:new Error("Trash failed");console.error("Trash error:",S),A(S.message),x==null||x(S)}},[K,r,v,_,x]),xe=w.useCallback(async()=>{if(!(!K||v.size===0))try{const f=await K.archiveEmails(r,Array.from(v));if(console.log("Archive result:",f),f.success&&f.archived>0){y(W=>W.filter(Q=>!v.has(Q.uid)));const S=Array.from(v);G(new Set),_==null||_(S)}else A("Failed to archive emails")}catch(f){const S=f instanceof Error?f:new Error("Archive failed");console.error("Archive error:",S),A(S.message),x==null||x(S)}},[K,r,v,_,x]),ve=w.useCallback(()=>{if(v.size===M.length)G(new Set),c==null||c([]);else{const f=new Set(M.map(S=>S.uid));G(f),c==null||c(Array.from(f))}},[M,v.size,c]),ke=w.useCallback(()=>{G(new Set),c==null||c([])},[c]),Te={delete:ye,archive:xe,refresh:te,selectAll:ve,clearSelection:ke},ce=f=>{if(!f)return"";const S=new Date(f),W=new Date;return S.toDateString()===W.toDateString()?S.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):S.toLocaleDateString([],{month:"short",day:"numeric"})},ue=(f,S)=>a.jsx("div",{style:{padding:"12px 16px",background:S?E.selectedBackground:f.seen?E.cardBackground:E.unreadBackground,borderBottom:`1px solid ${E.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:"14px",fontWeight:f.seen?400:600,color:E.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_e(f.from).split("@")[0]}),a.jsx("div",{style:{fontSize:"14px",fontWeight:f.seen?400:500,color:f.seen?E.textSecondary:E.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_e(f.subject)||"(No subject)"})]}),a.jsx("div",{style:{fontSize:"12px",color:E.textSecondary,flexShrink:0},children:ce(f.date)})]})}),ne=f=>a.jsxs("div",{style:{padding:"24px"},children:[a.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:E.text},children:_e(f.subject)||"(No subject)"}),a.jsxs("div",{style:{fontSize:"14px",color:E.textSecondary,marginBottom:"16px"},children:["From: ",_e(f.from)," • ",new Date(f.date).toLocaleString()]}),a.jsx("div",{style:{fontSize:"14px",color:E.text},children:"Email body not loaded. Implement getEmail(uid) to fetch full content."})]}),de=(f,S)=>a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:E.cardBackground,borderBottom:`1px solid ${E.border}`},children:[a.jsx("button",{onClick:S.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${E.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:E.text},children:f.length===M.length?"Deselect All":"Select All"}),f.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{style:{fontSize:"13px",color:E.textSecondary},children:[f.length," selected"]}),a.jsx("button",{onClick:S.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${E.border}`,borderRadius:"6px",cursor:"pointer",color:E.textSecondary},children:a.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),a.jsx("button",{onClick:S.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${E.border}`,borderRadius:"6px",cursor:"pointer",color:E.textSecondary},children:a.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),a.jsx("div",{style:{flex:1}}),a.jsx("button",{onClick:S.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${E.border}`,borderRadius:"6px",cursor:"pointer",color:E.textSecondary},children:a.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),ae=()=>a.jsx("div",{style:{padding:"48px",textAlign:"center",color:E.textSecondary},children:p}),Re=()=>a.jsx("div",{style:{padding:"48px",textAlign:"center",color:E.textSecondary},children:"Loading..."}),be=k||ue,Ce=C||ne,Oe=V||de,ie=I||ae,re=F||Re;return N&&M.length===0?a.jsx("div",{style:{background:E.background,width:"100%",height:"100%"},children:re()}):a.jsxs("div",{style:{display:"flex",background:E.background,width:"100%",height:"100%"},children:[a.jsxs("div",{style:{flex:o&&z?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&z?`1px solid ${E.border}`:"none",overflow:"hidden"},children:[n&&Oe(Array.from(v),Te),j&&a.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:E.danger,fontSize:"14px",borderBottom:`1px solid ${E.border}`},children:j}),a.jsx("div",{style:{flex:1,overflowY:"auto"},children:M.length===0?ie():M.map((f,S)=>a.jsx("div",{onClick:W=>me(f,S,W),onDoubleClick:()=>ge(f),children:be(f,v.has(f.uid))},f.uid))})]}),o&&z&&a.jsx("div",{style:{flex:1,overflowY:"auto"},children:Ce(z)})]})}exports.AnimatedCardFlip=At;exports.ApiClient=tt;exports.AuthManager=et;exports.Card=Ct;exports.DataOperations=je;exports.Detail=Ot;exports.GraphClient=_t;exports.Mail=$t;exports.MailClient=Ze;exports.Stack=Rt;exports.getApiClient=Be;exports.initializeApiClient=jt;exports.useMutation=St;exports.useQuery=rt;
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var Et = Object.defineProperty;
2
2
  var _t = (h, t, r) => t in h ? Et(h, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : h[t] = r;
3
3
  var he = (h, t, r) => _t(h, typeof t != "symbol" ? t + "" : t, r);
4
- import tt, { useState as z, useCallback as X, useEffect as de, useMemo as rt, useRef as Qe } from "react";
4
+ import tt, { useState as z, useCallback as K, useEffect as de, useMemo as rt, useRef as Qe } from "react";
5
5
  class $t {
6
6
  constructor(t) {
7
7
  he(this, "config");
@@ -238,16 +238,16 @@ class $t {
238
238
  return;
239
239
  }
240
240
  c.drawImage(s, 0, 0, p, u);
241
- const _ = t.type === "image/png" ? "image/png" : "image/jpeg";
241
+ const E = t.type === "image/png" ? "image/png" : "image/jpeg";
242
242
  g.toBlob(
243
243
  (x) => {
244
244
  if (x) {
245
- const m = new File([x], t.name, { type: _ });
245
+ const m = new File([x], t.name, { type: E });
246
246
  i(m);
247
247
  } else
248
248
  i(t);
249
249
  },
250
- _,
250
+ E,
251
251
  n
252
252
  );
253
253
  }, s.onerror = () => {
@@ -498,14 +498,14 @@ class jt {
498
498
  ])).responses.find((m) => m.command === "UID FETCH");
499
499
  if (!(c != null && c.ok) || !c.messages)
500
500
  throw new Error(`Failed to fetch details: ${(c == null ? void 0 : c.error) || "Unknown error"}`);
501
- const _ = /* @__PURE__ */ new Map();
501
+ const E = /* @__PURE__ */ new Map();
502
502
  for (const m of c.messages)
503
- m.uid && _.set(m.uid, m);
503
+ m.uid && E.set(m.uid, m);
504
504
  const x = u.map((m) => {
505
- var Y, w, D, y, N;
506
- const T = _.get(m);
505
+ var Y, w, U, y, N;
506
+ const T = E.get(m);
507
507
  if (!T) return null;
508
- const S = ((Y = T.flags) == null ? void 0 : Y.some((F) => F.includes("Seen"))) || !1, V = ((D = (w = T.envelope) == null ? void 0 : w.from) == null ? void 0 : D.email) || "Unknown", B = ((y = T.envelope) == null ? void 0 : y.subject) || "(No subject)", $ = ((N = T.envelope) == null ? void 0 : N.date) || "";
508
+ const S = ((Y = T.flags) == null ? void 0 : Y.some((F) => F.includes("Seen"))) || !1, V = ((U = (w = T.envelope) == null ? void 0 : w.from) == null ? void 0 : U.email) || "Unknown", B = ((y = T.envelope) == null ? void 0 : y.subject) || "(No subject)", $ = ((N = T.envelope) == null ? void 0 : N.date) || "";
509
509
  return { uid: m, from: V, subject: B, date: $, seen: S };
510
510
  }).filter(Boolean);
511
511
  return {
@@ -537,25 +537,25 @@ class jt {
537
537
  return t.html && (r.html = t.html), t.from && (r.from = t.from), t.smtpConfig && (r.smtp_config = t.smtpConfig), this.callEmail("send", r);
538
538
  }
539
539
  }
540
- const Ue = "qwanyx_auth_token", Me = "qwanyx_refresh_token";
540
+ const De = "qwanyx_auth_token", Me = "qwanyx_refresh_token";
541
541
  class Tt {
542
542
  /**
543
543
  * Store authentication token
544
544
  */
545
545
  static setToken(t) {
546
- typeof window < "u" && localStorage.setItem(Ue, t);
546
+ typeof window < "u" && localStorage.setItem(De, t);
547
547
  }
548
548
  /**
549
549
  * Get authentication token
550
550
  */
551
551
  static getToken() {
552
- return typeof window < "u" ? localStorage.getItem(Ue) : null;
552
+ return typeof window < "u" ? localStorage.getItem(De) : null;
553
553
  }
554
554
  /**
555
555
  * Remove authentication token
556
556
  */
557
557
  static clearToken() {
558
- typeof window < "u" && (localStorage.removeItem(Ue), localStorage.removeItem(Me));
558
+ typeof window < "u" && (localStorage.removeItem(De), localStorage.removeItem(Me));
559
559
  }
560
560
  /**
561
561
  * Store refresh token
@@ -626,11 +626,11 @@ class kt {
626
626
  };
627
627
  s && n !== "GET" && (g.body = JSON.stringify(s));
628
628
  try {
629
- const c = new AbortController(), _ = setTimeout(() => c.abort(), this.config.timeout), x = await fetch(p, {
629
+ const c = new AbortController(), E = setTimeout(() => c.abort(), this.config.timeout), x = await fetch(p, {
630
630
  ...g,
631
631
  signal: c.signal
632
632
  });
633
- if (clearTimeout(_), !x.ok) {
633
+ if (clearTimeout(E), !x.ok) {
634
634
  const m = await x.json().catch(() => ({
635
635
  message: x.statusText
636
636
  }));
@@ -699,7 +699,7 @@ function Rt(h, t, r = {}) {
699
699
  refetchOnMount: i = !0,
700
700
  onSuccess: s,
701
701
  onError: o
702
- } = r, [p, u] = z(null), [g, c] = z(n), [_, x] = z(null), m = X(async () => {
702
+ } = r, [p, u] = z(null), [g, c] = z(n), [E, x] = z(null), m = K(async () => {
703
703
  if (n) {
704
704
  c(!0), x(null);
705
705
  try {
@@ -718,12 +718,12 @@ function Rt(h, t, r = {}) {
718
718
  }, [m, i]), {
719
719
  data: p,
720
720
  loading: g,
721
- error: _,
721
+ error: E,
722
722
  refetch: m
723
723
  };
724
724
  }
725
- function Dt(h, t = "POST", r = {}) {
726
- const { onSuccess: n, onError: i } = r, [s, o] = z(null), [p, u] = z(!1), [g, c] = z(null), _ = X(
725
+ function Ut(h, t = "POST", r = {}) {
726
+ const { onSuccess: n, onError: i } = r, [s, o] = z(null), [p, u] = z(!1), [g, c] = z(null), E = K(
727
727
  async (m) => {
728
728
  u(!0), c(null);
729
729
  try {
@@ -754,14 +754,14 @@ function Dt(h, t = "POST", r = {}) {
754
754
  }
755
755
  },
756
756
  [h, t, n, i]
757
- ), x = X(() => {
757
+ ), x = K(() => {
758
758
  o(null), c(null), u(!1);
759
759
  }, []);
760
760
  return {
761
761
  data: s,
762
762
  loading: p,
763
763
  error: g,
764
- mutate: _,
764
+ mutate: E,
765
765
  reset: x
766
766
  };
767
767
  }
@@ -781,11 +781,11 @@ function St() {
781
781
  Ze = 1;
782
782
  var h = tt, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, i = h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
783
783
  function o(p, u, g) {
784
- var c, _ = {}, x = null, m = null;
784
+ var c, E = {}, x = null, m = null;
785
785
  g !== void 0 && (x = "" + g), u.key !== void 0 && (x = "" + u.key), u.ref !== void 0 && (m = u.ref);
786
- for (c in u) n.call(u, c) && !s.hasOwnProperty(c) && (_[c] = u[c]);
787
- if (p && p.defaultProps) for (c in u = p.defaultProps, u) _[c] === void 0 && (_[c] = u[c]);
788
- return { $$typeof: t, type: p, key: x, ref: m, props: _, _owner: i.current };
786
+ for (c in u) n.call(u, c) && !s.hasOwnProperty(c) && (E[c] = u[c]);
787
+ if (p && p.defaultProps) for (c in u = p.defaultProps, u) E[c] === void 0 && (E[c] = u[c]);
788
+ return { $$typeof: t, type: p, key: x, ref: m, props: E, _owner: i.current };
789
789
  }
790
790
  return ge.Fragment = r, ge.jsx = o, ge.jsxs = o, ge;
791
791
  }
@@ -802,7 +802,7 @@ var me = {};
802
802
  var et;
803
803
  function Ot() {
804
804
  return et || (et = 1, process.env.NODE_ENV !== "production" && function() {
805
- var h = tt, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), o = Symbol.for("react.provider"), p = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), c = Symbol.for("react.suspense_list"), _ = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), m = Symbol.for("react.offscreen"), T = Symbol.iterator, S = "@@iterator";
805
+ var h = tt, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), o = Symbol.for("react.provider"), p = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), c = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), m = Symbol.for("react.offscreen"), T = Symbol.iterator, S = "@@iterator";
806
806
  function V(e) {
807
807
  if (e === null || typeof e != "object")
808
808
  return null;
@@ -827,14 +827,14 @@ function Ot() {
827
827
  A.unshift("Warning: " + l), Function.prototype.apply.call(console[e], console, A);
828
828
  }
829
829
  }
830
- var w = !1, D = !1, y = !1, N = !1, F = !1, j;
831
- j = Symbol.for("react.module.reference");
830
+ var w = !1, U = !1, y = !1, N = !1, F = !1, _;
831
+ _ = Symbol.for("react.module.reference");
832
832
  function C(e) {
833
- return !!(typeof e == "string" || typeof e == "function" || e === n || e === s || F || e === i || e === g || e === c || N || e === m || w || D || y || typeof e == "object" && e !== null && (e.$$typeof === x || e.$$typeof === _ || e.$$typeof === o || e.$$typeof === p || e.$$typeof === u || // This needs to include all possible module reference object
833
+ return !!(typeof e == "string" || typeof e == "function" || e === n || e === s || F || e === i || e === g || e === c || N || e === m || w || U || y || typeof e == "object" && e !== null && (e.$$typeof === x || e.$$typeof === E || e.$$typeof === o || e.$$typeof === p || e.$$typeof === u || // This needs to include all possible module reference object
834
834
  // types supported by any Flight configuration anywhere since
835
835
  // we don't know which Flight build this will end up being used
836
836
  // with.
837
- e.$$typeof === j || e.getModuleId !== void 0));
837
+ e.$$typeof === _ || e.getModuleId !== void 0));
838
838
  }
839
839
  function v(e, l, d) {
840
840
  var b = e.displayName;
@@ -843,7 +843,7 @@ function Ot() {
843
843
  var P = l.displayName || l.name || "";
844
844
  return P !== "" ? d + "(" + P + ")" : d;
845
845
  }
846
- function W(e) {
846
+ function G(e) {
847
847
  return e.displayName || "Context";
848
848
  }
849
849
  function I(e) {
@@ -871,13 +871,13 @@ function Ot() {
871
871
  switch (e.$$typeof) {
872
872
  case p:
873
873
  var l = e;
874
- return W(l) + ".Consumer";
874
+ return G(l) + ".Consumer";
875
875
  case o:
876
876
  var d = e;
877
- return W(d._context) + ".Provider";
877
+ return G(d._context) + ".Provider";
878
878
  case u:
879
879
  return v(e, e.render, "ForwardRef");
880
- case _:
880
+ case E:
881
881
  var b = e.displayName || null;
882
882
  return b !== null ? b : I(e.type) || "Memo";
883
883
  case x: {
@@ -891,14 +891,14 @@ function Ot() {
891
891
  }
892
892
  return null;
893
893
  }
894
- var R = Object.assign, L = 0, J, Q, re, ye, xe, ve, be;
894
+ var R = Object.assign, L = 0, J, X, re, ye, xe, ve, be;
895
895
  function we() {
896
896
  }
897
897
  we.__reactDisabledLog = !0;
898
898
  function Re() {
899
899
  {
900
900
  if (L === 0) {
901
- J = console.log, Q = console.info, re = console.warn, ye = console.error, xe = console.group, ve = console.groupCollapsed, be = console.groupEnd;
901
+ J = console.log, X = console.info, re = console.warn, ye = console.error, xe = console.group, ve = console.groupCollapsed, be = console.groupEnd;
902
902
  var e = {
903
903
  configurable: !0,
904
904
  enumerable: !0,
@@ -931,7 +931,7 @@ function Ot() {
931
931
  value: J
932
932
  }),
933
933
  info: R({}, e, {
934
- value: Q
934
+ value: X
935
935
  }),
936
936
  warn: R({}, e, {
937
937
  value: re
@@ -1022,18 +1022,18 @@ function Ot() {
1022
1022
  if (H && b && typeof H.stack == "string") {
1023
1023
  for (var k = H.stack.split(`
1024
1024
  `), q = b.stack.split(`
1025
- `), U = k.length - 1, M = q.length - 1; U >= 1 && M >= 0 && k[U] !== q[M]; )
1025
+ `), D = k.length - 1, M = q.length - 1; D >= 1 && M >= 0 && k[D] !== q[M]; )
1026
1026
  M--;
1027
- for (; U >= 1 && M >= 0; U--, M--)
1028
- if (k[U] !== q[M]) {
1029
- if (U !== 1 || M !== 1)
1027
+ for (; D >= 1 && M >= 0; D--, M--)
1028
+ if (k[D] !== q[M]) {
1029
+ if (D !== 1 || M !== 1)
1030
1030
  do
1031
- if (U--, M--, M < 0 || k[U] !== q[M]) {
1032
- var ee = `
1033
- ` + k[U].replace(" at new ", " at ");
1034
- return e.displayName && ee.includes("<anonymous>") && (ee = ee.replace("<anonymous>", e.displayName)), typeof e == "function" && ie.set(e, ee), ee;
1031
+ if (D--, M--, M < 0 || k[D] !== q[M]) {
1032
+ var Q = `
1033
+ ` + k[D].replace(" at new ", " at ");
1034
+ return e.displayName && Q.includes("<anonymous>") && (Q = Q.replace("<anonymous>", e.displayName)), typeof e == "function" && ie.set(e, Q), Q;
1035
1035
  }
1036
- while (U >= 1 && M >= 0);
1036
+ while (D >= 1 && M >= 0);
1037
1037
  break;
1038
1038
  }
1039
1039
  }
@@ -1067,7 +1067,7 @@ function Ot() {
1067
1067
  switch (e.$$typeof) {
1068
1068
  case u:
1069
1069
  return Ne(e.render);
1070
- case _:
1070
+ case E:
1071
1071
  return oe(e.type, l, d);
1072
1072
  case x: {
1073
1073
  var b = e, P = b._payload, A = b._init;
@@ -1079,15 +1079,15 @@ function Ot() {
1079
1079
  }
1080
1080
  return "";
1081
1081
  }
1082
- var ne = Object.prototype.hasOwnProperty, f = {}, E = B.ReactDebugCurrentFrame;
1083
- function G(e) {
1082
+ var ne = Object.prototype.hasOwnProperty, f = {}, j = B.ReactDebugCurrentFrame;
1083
+ function W(e) {
1084
1084
  if (e) {
1085
1085
  var l = e._owner, d = oe(e.type, e._source, l ? l.type : null);
1086
- E.setExtraStackFrame(d);
1086
+ j.setExtraStackFrame(d);
1087
1087
  } else
1088
- E.setExtraStackFrame(null);
1088
+ j.setExtraStackFrame(null);
1089
1089
  }
1090
- function K(e, l, d, b, P) {
1090
+ function Z(e, l, d, b, P) {
1091
1091
  {
1092
1092
  var A = Function.call.bind(ne);
1093
1093
  for (var O in e)
@@ -1099,15 +1099,15 @@ function Ot() {
1099
1099
  throw q.name = "Invariant Violation", q;
1100
1100
  }
1101
1101
  k = e[O](l, O, b, d, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
1102
- } catch (U) {
1103
- k = U;
1102
+ } catch (D) {
1103
+ k = D;
1104
1104
  }
1105
- k && !(k instanceof Error) && (G(P), $("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", b || "React class", d, O, typeof k), G(null)), k instanceof Error && !(k.message in f) && (f[k.message] = !0, G(P), $("Failed %s type: %s", d, k.message), G(null));
1105
+ k && !(k instanceof Error) && (W(P), $("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", b || "React class", d, O, typeof k), W(null)), k instanceof Error && !(k.message in f) && (f[k.message] = !0, W(P), $("Failed %s type: %s", d, k.message), W(null));
1106
1106
  }
1107
1107
  }
1108
1108
  }
1109
1109
  var te = Array.isArray;
1110
- function Z(e) {
1110
+ function ee(e) {
1111
1111
  return te(e);
1112
1112
  }
1113
1113
  function Pe(e) {
@@ -1213,9 +1213,9 @@ function Ot() {
1213
1213
  for (A in l)
1214
1214
  ne.call(l, A) && !st.hasOwnProperty(A) && (O[A] = l[A]);
1215
1215
  if (e && e.defaultProps) {
1216
- var U = e.defaultProps;
1217
- for (A in U)
1218
- O[A] === void 0 && (O[A] = U[A]);
1216
+ var D = e.defaultProps;
1217
+ for (A in D)
1218
+ O[A] === void 0 && (O[A] = D[A]);
1219
1219
  }
1220
1220
  if (k || q) {
1221
1221
  var M = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
@@ -1282,7 +1282,7 @@ Check the top-level render call using <` + d + ">.");
1282
1282
  {
1283
1283
  if (typeof e != "object")
1284
1284
  return;
1285
- if (Z(e))
1285
+ if (ee(e))
1286
1286
  for (var d = 0; d < e.length; d++) {
1287
1287
  var b = e[d];
1288
1288
  Fe(b) && He(b, l);
@@ -1307,13 +1307,13 @@ Check the top-level render call using <` + d + ">.");
1307
1307
  d = l.propTypes;
1308
1308
  else if (typeof l == "object" && (l.$$typeof === u || // Note: Memo only checks outer props here.
1309
1309
  // Inner props are checked in the reconciler.
1310
- l.$$typeof === _))
1310
+ l.$$typeof === E))
1311
1311
  d = l.propTypes;
1312
1312
  else
1313
1313
  return;
1314
1314
  if (d) {
1315
1315
  var b = I(l);
1316
- K(d, e.props, "prop", b, e);
1316
+ Z(d, e.props, "prop", b, e);
1317
1317
  } else if (l.PropTypes !== void 0 && !$e) {
1318
1318
  $e = !0;
1319
1319
  var P = I(l);
@@ -1343,37 +1343,37 @@ Check the top-level render call using <` + d + ">.");
1343
1343
  (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (k += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
1344
1344
  var q = ft();
1345
1345
  q ? k += q : k += qe();
1346
- var U;
1347
- e === null ? U = "null" : Z(e) ? U = "array" : e !== void 0 && e.$$typeof === t ? (U = "<" + (I(e.type) || "Unknown") + " />", k = " Did you accidentally export a JSX literal instead of a component?") : U = typeof e, $("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", U, k);
1346
+ var D;
1347
+ e === null ? D = "null" : ee(e) ? D = "array" : e !== void 0 && e.$$typeof === t ? (D = "<" + (I(e.type) || "Unknown") + " />", k = " Did you accidentally export a JSX literal instead of a component?") : D = typeof e, $("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", D, k);
1348
1348
  }
1349
1349
  var M = ut(e, l, d, P, A);
1350
1350
  if (M == null)
1351
1351
  return M;
1352
1352
  if (O) {
1353
- var ee = l.children;
1354
- if (ee !== void 0)
1353
+ var Q = l.children;
1354
+ if (Q !== void 0)
1355
1355
  if (b)
1356
- if (Z(ee)) {
1357
- for (var ce = 0; ce < ee.length; ce++)
1358
- Je(ee[ce], e);
1359
- Object.freeze && Object.freeze(ee);
1356
+ if (ee(Q)) {
1357
+ for (var ce = 0; ce < Q.length; ce++)
1358
+ Je(Q[ce], e);
1359
+ Object.freeze && Object.freeze(Q);
1360
1360
  } else
1361
1361
  $("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
1362
1362
  else
1363
- Je(ee, e);
1363
+ Je(Q, e);
1364
1364
  }
1365
1365
  if (ne.call(l, "key")) {
1366
1366
  var se = I(e), H = Object.keys(l).filter(function(wt) {
1367
1367
  return wt !== "key";
1368
- }), De = H.length > 0 ? "{key: someKey, " + H.join(": ..., ") + ": ...}" : "{key: someKey}";
1369
- if (!Ke[se + De]) {
1368
+ }), Ue = H.length > 0 ? "{key: someKey, " + H.join(": ..., ") + ": ...}" : "{key: someKey}";
1369
+ if (!Ke[se + Ue]) {
1370
1370
  var bt = H.length > 0 ? "{" + H.join(": ..., ") + ": ...}" : "{}";
1371
1371
  $(`A props object containing a "key" prop is being spread into JSX:
1372
1372
  let props = %s;
1373
1373
  <%s {...props} />
1374
1374
  React keys must be passed directly to JSX without using spread:
1375
1375
  let props = %s;
1376
- <%s key={someKey} {...props} />`, De, se, bt, se), Ke[se + De] = !0;
1376
+ <%s key={someKey} {...props} />`, Ue, se, bt, se), Ke[se + Ue] = !0;
1377
1377
  }
1378
1378
  }
1379
1379
  return e === n ? gt(M) : ht(M), M;
@@ -1476,7 +1476,7 @@ class Be {
1476
1476
  return r.reduce((n, i) => i(n), t);
1477
1477
  }
1478
1478
  }
1479
- function Ut({
1479
+ function Dt({
1480
1480
  endpoint: h,
1481
1481
  params: t,
1482
1482
  layout: r = "list",
@@ -1488,19 +1488,19 @@ function Ut({
1488
1488
  searchFields: u = [],
1489
1489
  searchPlaceholder: g = "Search...",
1490
1490
  filters: c = [],
1491
- pageSize: _ = 20,
1491
+ pageSize: E = 20,
1492
1492
  onItemClick: x,
1493
1493
  onRefresh: m,
1494
1494
  theme: T = {}
1495
1495
  }) {
1496
- const { data: S, loading: V, error: B, refetch: $ } = Rt(h, t), [Y, w] = z(""), [D, y] = z({}), [N, F] = z(1), j = rt(() => {
1496
+ const { data: S, loading: V, error: B, refetch: $ } = Rt(h, t), [Y, w] = z(""), [U, y] = z({}), [N, F] = z(1), _ = rt(() => {
1497
1497
  if (!S) return { data: [], total: 0, totalPages: 0 };
1498
1498
  let R = S;
1499
- return p && Y && u.length > 0 && (R = Be.search(R, Y, u)), Object.keys(D).length > 0 && (R = Be.filterByFields(R, D)), Be.paginate(R, N, _);
1500
- }, [S, Y, D, N, _, p, u]);
1499
+ return p && Y && u.length > 0 && (R = Be.search(R, Y, u)), Object.keys(U).length > 0 && (R = Be.filterByFields(R, U)), Be.paginate(R, N, E);
1500
+ }, [S, Y, U, N, E, p, u]);
1501
1501
  de(() => {
1502
1502
  F(1);
1503
- }, [Y, D]);
1503
+ }, [Y, U]);
1504
1504
  const C = () => {
1505
1505
  w(""), y({}), F(1), $(), m == null || m();
1506
1506
  }, v = {
@@ -1608,11 +1608,11 @@ function Ut({
1608
1608
  gridTemplateColumns: r === "grid" ? "repeat(auto-fill, minmax(250px, 1fr))" : void 0,
1609
1609
  gap: r === "list" ? "0" : "16px",
1610
1610
  padding: r === "list" ? "0" : "16px"
1611
- }, children: j.data.length === 0 ? /* @__PURE__ */ a.jsx("div", { style: {
1611
+ }, children: _.data.length === 0 ? /* @__PURE__ */ a.jsx("div", { style: {
1612
1612
  padding: "48px",
1613
1613
  textAlign: "center",
1614
1614
  color: v.textSecondary
1615
- }, children: i }) : j.data.map((R, L) => /* @__PURE__ */ a.jsx(
1615
+ }, children: i }) : _.data.map((R, L) => /* @__PURE__ */ a.jsx(
1616
1616
  "div",
1617
1617
  {
1618
1618
  onClick: () => x == null ? void 0 : x(R),
@@ -1632,7 +1632,7 @@ function Ut({
1632
1632
  },
1633
1633
  o(R, L)
1634
1634
  )) }),
1635
- j.totalPages > 1 && /* @__PURE__ */ a.jsxs("div", { style: {
1635
+ _.totalPages > 1 && /* @__PURE__ */ a.jsxs("div", { style: {
1636
1636
  padding: "16px",
1637
1637
  borderTop: `1px solid ${v.border}`,
1638
1638
  display: "flex",
@@ -1643,7 +1643,7 @@ function Ut({
1643
1643
  "Page ",
1644
1644
  N,
1645
1645
  " of ",
1646
- j.totalPages
1646
+ _.totalPages
1647
1647
  ] }),
1648
1648
  /* @__PURE__ */ a.jsxs("div", { style: { display: "flex", gap: "8px" }, children: [
1649
1649
  /* @__PURE__ */ a.jsx(
@@ -1665,15 +1665,15 @@ function Ut({
1665
1665
  /* @__PURE__ */ a.jsx(
1666
1666
  "button",
1667
1667
  {
1668
- onClick: () => F((R) => Math.min(j.totalPages, R + 1)),
1669
- disabled: N === j.totalPages,
1668
+ onClick: () => F((R) => Math.min(_.totalPages, R + 1)),
1669
+ disabled: N === _.totalPages,
1670
1670
  style: {
1671
1671
  padding: "6px 12px",
1672
1672
  border: `1px solid ${v.border}`,
1673
1673
  borderRadius: "6px",
1674
1674
  background: "white",
1675
- cursor: N === j.totalPages ? "not-allowed" : "pointer",
1676
- opacity: N === j.totalPages ? 0.5 : 1
1675
+ cursor: N === _.totalPages ? "not-allowed" : "pointer",
1676
+ opacity: N === _.totalPages ? 0.5 : 1
1677
1677
  },
1678
1678
  children: "Next"
1679
1679
  }
@@ -1784,48 +1784,48 @@ function It({
1784
1784
  cardSize: s = "medium",
1785
1785
  className: o = ""
1786
1786
  }) {
1787
- const p = Math.min(Math.max(t, 1), 5), [u, g] = z([]), [c, _] = z([]), [x, m] = z(Array(p).fill(!1)), [T, S] = z(Array(p).fill(!1)), V = Qe([]), B = X((y) => {
1788
- const N = h.filter((j) => !y.includes(j._id));
1787
+ const p = Math.min(Math.max(t, 1), 5), [u, g] = z([]), [c, E] = z([]), [x, m] = z(Array(p).fill(!1)), [T, S] = z(Array(p).fill(!1)), V = Qe([]), B = K((y) => {
1788
+ const N = h.filter((_) => !y.includes(_._id));
1789
1789
  if (N.length === 0) return null;
1790
1790
  const F = Math.floor(Math.random() * N.length);
1791
1791
  return N[F];
1792
- }, [h]), $ = X(() => Math.random() * (n - r) + r, [r, n]);
1792
+ }, [h]), $ = K(() => Math.random() * (n - r) + r, [r, n]);
1793
1793
  de(() => {
1794
1794
  if (h.length === 0) {
1795
- g([]), _([]);
1795
+ g([]), E([]);
1796
1796
  return;
1797
1797
  }
1798
1798
  const y = [], N = [], F = [];
1799
- for (let j = 0; j < p && j < h.length; j++) {
1799
+ for (let _ = 0; _ < p && _ < h.length; _++) {
1800
1800
  const C = B(F);
1801
1801
  C && (y.push(C), F.push(C._id));
1802
1802
  }
1803
- for (let j = 0; j < y.length; j++) {
1803
+ for (let _ = 0; _ < y.length; _++) {
1804
1804
  const C = [
1805
- y[j]._id,
1806
- ...y.filter((W, I) => I !== j).map((W) => W._id)
1805
+ y[_]._id,
1806
+ ...y.filter((G, I) => I !== _).map((G) => G._id)
1807
1807
  ], v = B(C);
1808
- v ? N.push(v) : N.push(y[j]);
1808
+ v ? N.push(v) : N.push(y[_]);
1809
1809
  }
1810
- g(y), _(N);
1810
+ g(y), E(N);
1811
1811
  }, [h, p, B]);
1812
- const Y = X((y) => {
1812
+ const Y = K((y) => {
1813
1813
  const N = $(), F = setTimeout(() => {
1814
- m((j) => {
1815
- const C = [...j];
1814
+ m((_) => {
1815
+ const C = [..._];
1816
1816
  return C[y] = !C[y], C;
1817
1817
  }), setTimeout(() => {
1818
- S((j) => {
1819
- const C = [...j];
1818
+ S((_) => {
1819
+ const C = [..._];
1820
1820
  return C[y] = !C[y], C;
1821
1821
  }), setTimeout(() => {
1822
- const j = !T[y];
1823
- j && g((C) => {
1822
+ const _ = !T[y];
1823
+ _ && g((C) => {
1824
1824
  const v = [...C];
1825
1825
  return v[y] = c[y], v;
1826
- }), _((C) => {
1826
+ }), E((C) => {
1827
1827
  const v = [...C], I = [
1828
- (j ? c[y] : u[y])._id,
1828
+ (_ ? c[y] : u[y])._id,
1829
1829
  ...u.filter((L, J) => J !== y).map((L) => L._id),
1830
1830
  ...C.filter((L, J) => J !== y).map((L) => L._id)
1831
1831
  ], R = B(I);
@@ -1848,17 +1848,17 @@ function It({
1848
1848
  };
1849
1849
  }
1850
1850
  }, [u.length, h.length]);
1851
- const D = (y) => {
1851
+ const U = (y) => {
1852
1852
  i && i(y);
1853
1853
  };
1854
1854
  return h.length === 0 ? /* @__PURE__ */ a.jsx("div", { className: `flex items-center justify-center p-8 ${o}`, children: /* @__PURE__ */ a.jsx("p", { className: "text-gray-500", children: "No nodes available" }) }) : u.length === 0 ? /* @__PURE__ */ a.jsx("div", { className: `flex items-center justify-center p-8 ${o}`, children: /* @__PURE__ */ a.jsx("p", { className: "text-gray-500", children: "Loading..." }) }) : /* @__PURE__ */ a.jsx("div", { className: `flex gap-4 justify-center items-center flex-wrap ${o}`, children: u.map((y, N) => {
1855
- const F = c[N], j = T[N];
1855
+ const F = c[N], _ = T[N];
1856
1856
  return /* @__PURE__ */ a.jsx(
1857
1857
  "div",
1858
1858
  {
1859
1859
  className: `relative ${Nt[s]}`,
1860
1860
  style: { perspective: "1000px" },
1861
- onClick: () => D(j ? F : y),
1861
+ onClick: () => U(_ ? F : y),
1862
1862
  children: /* @__PURE__ */ a.jsxs(
1863
1863
  "div",
1864
1864
  {
@@ -1874,7 +1874,7 @@ function It({
1874
1874
  {
1875
1875
  className: "absolute inset-0 transition-opacity duration-200",
1876
1876
  style: {
1877
- opacity: j ? 0 : 1
1877
+ opacity: _ ? 0 : 1
1878
1878
  },
1879
1879
  children: /* @__PURE__ */ a.jsxs(
1880
1880
  "div",
@@ -1904,7 +1904,7 @@ function It({
1904
1904
  {
1905
1905
  className: "absolute inset-0 transition-opacity duration-200",
1906
1906
  style: {
1907
- opacity: j ? 1 : 0
1907
+ opacity: _ ? 1 : 0
1908
1908
  },
1909
1909
  children: /* @__PURE__ */ a.jsxs(
1910
1910
  "div",
@@ -1981,7 +1981,7 @@ function Lt({
1981
1981
  autoLoad: u = !0,
1982
1982
  onSelect: g,
1983
1983
  onSelectionChange: c,
1984
- onDelete: _,
1984
+ onDelete: E,
1985
1985
  onError: x,
1986
1986
  onLoad: m,
1987
1987
  renderItem: T,
@@ -1991,87 +1991,81 @@ function Lt({
1991
1991
  renderLoading: $,
1992
1992
  theme: Y = {}
1993
1993
  }) {
1994
- const w = { ...Ct, ...Y }, [D, y] = z([]), [N, F] = z(!1), [j, C] = z(null), [v, W] = z(/* @__PURE__ */ new Set()), [I, R] = z(null), [L, J] = z(null), Q = rt(() => t ? new jt({ baseUrl: h, system_id: t }) : null, [h, t]), re = X(async () => {
1995
- if (Q) {
1994
+ const w = { ...Ct, ...Y }, [U, y] = z([]), [N, F] = z(!1), [_, C] = z(null), [v, G] = z(/* @__PURE__ */ new Set()), [I, R] = z(null), [L, J] = z(null), X = rt(() => t ? new jt({ baseUrl: h, system_id: t }) : null, [h, t]), re = K(async () => {
1995
+ if (X) {
1996
1996
  F(!0), C(null);
1997
1997
  try {
1998
- const f = await Q.listEmails(r, n, i);
1999
- if (f != null && f.messages) {
2000
- const E = [...f.messages].sort((G, K) => {
2001
- const te = new Date(G.date).getTime() || 0;
2002
- return (new Date(K.date).getTime() || 0) - te;
2003
- });
2004
- y(E), m == null || m(E);
2005
- }
1998
+ const f = await X.listEmailsSorted(r, i || "INBOX", n);
1999
+ f != null && f.messages && (y(f.messages), m == null || m(f.messages));
2006
2000
  } catch (f) {
2007
- const E = f instanceof Error ? f : new Error("Failed to fetch emails");
2008
- C(E.message), x == null || x(E);
2001
+ const j = f instanceof Error ? f : new Error("Failed to fetch emails");
2002
+ C(j.message), x == null || x(j);
2009
2003
  }
2010
2004
  F(!1);
2011
2005
  }
2012
- }, [Q, r, n, i, x, m]);
2006
+ }, [X, r, n, i, x, m]);
2013
2007
  de(() => {
2014
2008
  u && re();
2015
2009
  }, [u, re]), de(() => {
2016
2010
  re();
2017
2011
  }, [i]);
2018
- const ye = X((f) => {
2012
+ const ye = K((f) => {
2019
2013
  g == null || g(f), o && J(f);
2020
- }, [g, o]), xe = X((f, E, G) => {
2014
+ }, [g, o]), xe = K((f, j, W) => {
2021
2015
  if (!s) {
2022
2016
  g == null || g(f), o && J(f);
2023
2017
  return;
2024
2018
  }
2025
- const K = f.uid;
2026
- if (G.shiftKey && I !== null) {
2027
- const te = Math.min(I, E), Z = Math.max(I, E), Pe = D.slice(te, Z + 1).map((je) => je.uid), _e = new Set(Pe);
2028
- W(_e), c == null || c(Array.from(_e));
2029
- } else if (G.ctrlKey || G.metaKey)
2030
- W((te) => {
2031
- const Z = new Set(te);
2032
- return Z.has(K) ? Z.delete(K) : Z.add(K), c == null || c(Array.from(Z)), Z;
2033
- }), R(E);
2019
+ const Z = f.uid;
2020
+ if (W.shiftKey && I !== null) {
2021
+ const te = Math.min(I, j), ee = Math.max(I, j), Pe = U.slice(te, ee + 1).map((je) => je.uid), _e = new Set(Pe);
2022
+ G(_e), c == null || c(Array.from(_e));
2023
+ } else if (W.ctrlKey || W.metaKey)
2024
+ G((te) => {
2025
+ const ee = new Set(te);
2026
+ return ee.has(Z) ? ee.delete(Z) : ee.add(Z), c == null || c(Array.from(ee)), ee;
2027
+ }), R(j);
2034
2028
  else {
2035
- const te = /* @__PURE__ */ new Set([K]);
2036
- W(te), R(E), c == null || c(Array.from(te));
2029
+ const te = /* @__PURE__ */ new Set([Z]);
2030
+ G(te), R(j), c == null || c(Array.from(te));
2037
2031
  }
2038
- }, [s, I, D, v, g, c, o]), ve = X(async () => {
2039
- if (!(!Q || v.size === 0))
2032
+ }, [s, I, U, v, g, c, o]), ve = K(async () => {
2033
+ if (!(!X || v.size === 0))
2040
2034
  try {
2041
- const f = await Q.trashEmails(r, Array.from(v));
2035
+ const f = await X.trashEmails(r, Array.from(v));
2042
2036
  if (console.log("Trash result:", f), f.success && f.moved > 0) {
2043
- y((G) => G.filter((K) => !v.has(K.uid)));
2044
- const E = Array.from(v);
2045
- W(/* @__PURE__ */ new Set()), _ == null || _(E);
2037
+ y((W) => W.filter((Z) => !v.has(Z.uid)));
2038
+ const j = Array.from(v);
2039
+ G(/* @__PURE__ */ new Set()), E == null || E(j);
2046
2040
  } else
2047
2041
  C("Failed to move emails to trash");
2048
2042
  } catch (f) {
2049
- const E = f instanceof Error ? f : new Error("Trash failed");
2050
- console.error("Trash error:", E), C(E.message), x == null || x(E);
2043
+ const j = f instanceof Error ? f : new Error("Trash failed");
2044
+ console.error("Trash error:", j), C(j.message), x == null || x(j);
2051
2045
  }
2052
- }, [Q, r, v, _, x]), be = X(async () => {
2053
- if (!(!Q || v.size === 0))
2046
+ }, [X, r, v, E, x]), be = K(async () => {
2047
+ if (!(!X || v.size === 0))
2054
2048
  try {
2055
- const f = await Q.archiveEmails(r, Array.from(v));
2049
+ const f = await X.archiveEmails(r, Array.from(v));
2056
2050
  if (console.log("Archive result:", f), f.success && f.archived > 0) {
2057
- y((G) => G.filter((K) => !v.has(K.uid)));
2058
- const E = Array.from(v);
2059
- W(/* @__PURE__ */ new Set()), _ == null || _(E);
2051
+ y((W) => W.filter((Z) => !v.has(Z.uid)));
2052
+ const j = Array.from(v);
2053
+ G(/* @__PURE__ */ new Set()), E == null || E(j);
2060
2054
  } else
2061
2055
  C("Failed to archive emails");
2062
2056
  } catch (f) {
2063
- const E = f instanceof Error ? f : new Error("Archive failed");
2064
- console.error("Archive error:", E), C(E.message), x == null || x(E);
2057
+ const j = f instanceof Error ? f : new Error("Archive failed");
2058
+ console.error("Archive error:", j), C(j.message), x == null || x(j);
2065
2059
  }
2066
- }, [Q, r, v, _, x]), we = X(() => {
2067
- if (v.size === D.length)
2068
- W(/* @__PURE__ */ new Set()), c == null || c([]);
2060
+ }, [X, r, v, E, x]), we = K(() => {
2061
+ if (v.size === U.length)
2062
+ G(/* @__PURE__ */ new Set()), c == null || c([]);
2069
2063
  else {
2070
- const f = new Set(D.map((E) => E.uid));
2071
- W(f), c == null || c(Array.from(f));
2064
+ const f = new Set(U.map((j) => j.uid));
2065
+ G(f), c == null || c(Array.from(f));
2072
2066
  }
2073
- }, [D, v.size, c]), Re = X(() => {
2074
- W(/* @__PURE__ */ new Set()), c == null || c([]);
2067
+ }, [U, v.size, c]), Re = K(() => {
2068
+ G(/* @__PURE__ */ new Set()), c == null || c([]);
2075
2069
  }, [c]), Se = {
2076
2070
  delete: ve,
2077
2071
  archive: be,
@@ -2080,11 +2074,11 @@ function Lt({
2080
2074
  clearSelection: Re
2081
2075
  }, ue = (f) => {
2082
2076
  if (!f) return "";
2083
- const E = new Date(f), G = /* @__PURE__ */ new Date();
2084
- return E.toDateString() === G.toDateString() ? E.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : E.toLocaleDateString([], { month: "short", day: "numeric" });
2085
- }, fe = (f, E) => /* @__PURE__ */ a.jsx("div", { style: {
2077
+ const j = new Date(f), W = /* @__PURE__ */ new Date();
2078
+ return j.toDateString() === W.toDateString() ? j.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : j.toLocaleDateString([], { month: "short", day: "numeric" });
2079
+ }, fe = (f, j) => /* @__PURE__ */ a.jsx("div", { style: {
2086
2080
  padding: "12px 16px",
2087
- background: E ? w.selectedBackground : f.seen ? w.cardBackground : w.unreadBackground,
2081
+ background: j ? w.selectedBackground : f.seen ? w.cardBackground : w.unreadBackground,
2088
2082
  borderBottom: `1px solid ${w.border}`,
2089
2083
  cursor: "pointer",
2090
2084
  transition: "background 0.15s ease"
@@ -2122,7 +2116,7 @@ function Lt({
2122
2116
  new Date(f.date).toLocaleString()
2123
2117
  ] }),
2124
2118
  /* @__PURE__ */ a.jsx("div", { style: { fontSize: "14px", color: w.text }, children: "Email body not loaded. Implement getEmail(uid) to fetch full content." })
2125
- ] }), pe = (f, E) => /* @__PURE__ */ a.jsxs("div", { style: {
2119
+ ] }), pe = (f, j) => /* @__PURE__ */ a.jsxs("div", { style: {
2126
2120
  display: "flex",
2127
2121
  alignItems: "center",
2128
2122
  gap: "8px",
@@ -2133,7 +2127,7 @@ function Lt({
2133
2127
  /* @__PURE__ */ a.jsx(
2134
2128
  "button",
2135
2129
  {
2136
- onClick: E.selectAll,
2130
+ onClick: j.selectAll,
2137
2131
  style: {
2138
2132
  padding: "6px 12px",
2139
2133
  background: "transparent",
@@ -2143,7 +2137,7 @@ function Lt({
2143
2137
  cursor: "pointer",
2144
2138
  color: w.text
2145
2139
  },
2146
- children: f.length === D.length ? "Deselect All" : "Select All"
2140
+ children: f.length === U.length ? "Deselect All" : "Select All"
2147
2141
  }
2148
2142
  ),
2149
2143
  f.length > 0 && /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
@@ -2154,7 +2148,7 @@ function Lt({
2154
2148
  /* @__PURE__ */ a.jsx(
2155
2149
  "button",
2156
2150
  {
2157
- onClick: E.archive,
2151
+ onClick: j.archive,
2158
2152
  title: "Archive",
2159
2153
  style: {
2160
2154
  display: "flex",
@@ -2174,7 +2168,7 @@ function Lt({
2174
2168
  /* @__PURE__ */ a.jsx(
2175
2169
  "button",
2176
2170
  {
2177
- onClick: E.delete,
2171
+ onClick: j.delete,
2178
2172
  title: "Delete",
2179
2173
  style: {
2180
2174
  display: "flex",
@@ -2196,7 +2190,7 @@ function Lt({
2196
2190
  /* @__PURE__ */ a.jsx(
2197
2191
  "button",
2198
2192
  {
2199
- onClick: E.refresh,
2193
+ onClick: j.refresh,
2200
2194
  title: "Refresh",
2201
2195
  style: {
2202
2196
  display: "flex",
@@ -2222,7 +2216,7 @@ function Lt({
2222
2216
  textAlign: "center",
2223
2217
  color: w.textSecondary
2224
2218
  }, children: "Loading..." }), Ee = T || fe, Ne = S || ae, Ce = V || pe, oe = B || ie, ne = $ || Oe;
2225
- return N && D.length === 0 ? /* @__PURE__ */ a.jsx("div", { style: { background: w.background, width: "100%", height: "100%" }, children: ne() }) : /* @__PURE__ */ a.jsxs("div", { style: { display: "flex", background: w.background, width: "100%", height: "100%" }, children: [
2219
+ return N && U.length === 0 ? /* @__PURE__ */ a.jsx("div", { style: { background: w.background, width: "100%", height: "100%" }, children: ne() }) : /* @__PURE__ */ a.jsxs("div", { style: { display: "flex", background: w.background, width: "100%", height: "100%" }, children: [
2226
2220
  /* @__PURE__ */ a.jsxs("div", { style: {
2227
2221
  flex: o && L ? "0 0 50%" : "1",
2228
2222
  display: "flex",
@@ -2231,17 +2225,17 @@ function Lt({
2231
2225
  overflow: "hidden"
2232
2226
  }, children: [
2233
2227
  s && Ce(Array.from(v), Se),
2234
- j && /* @__PURE__ */ a.jsx("div", { style: {
2228
+ _ && /* @__PURE__ */ a.jsx("div", { style: {
2235
2229
  padding: "12px 16px",
2236
2230
  background: "#fef2f2",
2237
2231
  color: w.danger,
2238
2232
  fontSize: "14px",
2239
2233
  borderBottom: `1px solid ${w.border}`
2240
- }, children: j }),
2241
- /* @__PURE__ */ a.jsx("div", { style: { flex: 1, overflowY: "auto" }, children: D.length === 0 ? oe() : D.map((f, E) => /* @__PURE__ */ a.jsx(
2234
+ }, children: _ }),
2235
+ /* @__PURE__ */ a.jsx("div", { style: { flex: 1, overflowY: "auto" }, children: U.length === 0 ? oe() : U.map((f, j) => /* @__PURE__ */ a.jsx(
2242
2236
  "div",
2243
2237
  {
2244
- onClick: (G) => xe(f, E, G),
2238
+ onClick: (W) => xe(f, j, W),
2245
2239
  onDoubleClick: () => ye(f),
2246
2240
  children: Ee(f, v.has(f.uid))
2247
2241
  },
@@ -2261,9 +2255,9 @@ export {
2261
2255
  $t as GraphClient,
2262
2256
  Lt as Mail,
2263
2257
  jt as MailClient,
2264
- Ut as Stack,
2258
+ Dt as Stack,
2265
2259
  nt as getApiClient,
2266
2260
  Ft as initializeApiClient,
2267
- Dt as useMutation,
2261
+ Ut as useMutation,
2268
2262
  Rt as useQuery
2269
2263
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwanyx/stack",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "Modern HyperCard for React - All-in-one data management (REST + Graph API + Auth + Hooks + UI)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",