const r="";class i{constructor(e=r){this.baseUrl=e}async request(e,t={}){const o=typeof sessionStorage<"u"?sessionStorage.getItem("auth_token"):null,a=await fetch(`${this.baseUrl}${e}`,{...t,headers:{"Content-Type":"application/json",...o?{Authorization:`Bearer ${o}`}:{},...t.headers}});if(!a.ok){const s=await a.text();throw new Error(`API Error: ${a.status} - ${s}`)}return a.json()}async uploadFiles(e){const t=new FormData;e.forEach(a=>t.append("files",a));const o=await fetch(`${this.baseUrl}/api/v1/upload/upload`,{method:"POST",body:t,headers:{...typeof sessionStorage<"u"&&sessionStorage.getItem("auth_token")?{Authorization:`Bearer ${sessionStorage.getItem("auth_token")}`}:{}}});if(!o.ok){const a=await o.text();throw new Error(`Upload Error: ${o.status} - ${a}`)}return o.json()}async clean(e){return this.request("/api/v1/cleaning/clean",{method:"POST",body:JSON.stringify(e)})}async getCleanResult(e){return this.request(`/api/v1/cleaning/clean/${e}`)}async downloadCleanedData(e){const t=typeof sessionStorage<"u"?sessionStorage.getItem("auth_token"):null,o=await fetch(`${this.baseUrl}/api/v1/cleaning/clean/${e}/download`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}});if(!o.ok)throw new Error("Download failed");const a=await o.blob(),s=window.URL.createObjectURL(a),n=document.createElement("a");n.href=s,n.download=`cleaned_data_${e.slice(0,8)}.csv`,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(s),document.body.removeChild(n)}async downloadReport(e){const t=typeof sessionStorage<"u"?sessionStorage.getItem("auth_token"):null,o=await fetch(`${this.baseUrl}/api/v1/cleaning/clean/${e}/report`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}});if(!o.ok)throw new Error("Report download failed");const a=await o.blob(),s=window.URL.createObjectURL(a),n=document.createElement("a");n.href=s,n.download=`report_${e.slice(0,8)}.html`,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(s),document.body.removeChild(n)}async downloadSchema(e){const t=typeof sessionStorage<"u"?sessionStorage.getItem("auth_token"):null,o=await fetch(`${this.baseUrl}/api/v1/cleaning/clean/${e}/schema`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}});if(!o.ok)throw new Error("Schema download failed");const a=await o.blob(),s=window.URL.createObjectURL(a),n=document.createElement("a");n.href=s,n.download=`schema_${e.slice(0,8)}.json`,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(s),document.body.removeChild(n)}async reconcileSchemas(e){return this.request("/api/v1/schema/reconcile",{method:"POST",body:JSON.stringify(e)})}async diffSchemas(e,t){return this.request("/api/v1/schema/diff",{method:"POST",body:JSON.stringify({schema1:e,schema2:t})})}async validateSchema(e,t){return this.request("/api/v1/schema/validate",{method:"POST",body:JSON.stringify({file_path:e,schema_dict:t})})}async healthCheck(){return this.request("/health")}async login(e,t){return this.request("/api/v1/auth/login",{method:"POST",body:JSON.stringify({license_key:e,email:t})})}async createCheckoutSession(e){return this.request("/api/v1/payments/checkout",{method:"POST",body:JSON.stringify(e)})}async activateLicense(e,t,o,a){return this.request("/api/v1/licensing/activate",{method:"POST",body:JSON.stringify({license_key:e,email:t,hardware_id:o,device_name:a})})}async getLicenseStatus(){return this.request("/api/v1/licensing/status")}async getUsageStats(){return this.request("/api/v1/licensing/usage")}}const d=new i;export{d as a};
