entity-client 1.0.12 → 1.0.13

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.js CHANGED
@@ -1,2 +1,2 @@
1
- function ct(r){let n=import.meta;if(n?.env?.[r]!=null)return n.env[r];let t=globalThis.process;if(t?.env?.[r]!=null)return t.env[r]}function c(r){return Object.entries(r).filter(([,n])=>n!=null).map(([n,t])=>`${encodeURIComponent(n==="orderBy"?"order_by":n)}=${encodeURIComponent(String(t))}`).join("&")}import{xchacha20poly1305 as mt}from"@noble/ciphers/chacha";import{sha256 as Rt}from"@noble/hashes/sha2";import{hkdf as Ct}from"@noble/hashes/hkdf";var q=32,M=2,O=14,k=24,St=16,_t="entity-server:hkdf:v1",Bt="entity-server:packet-encryption";function w(r){return r instanceof Uint8Array?r:new Uint8Array(r)}function lt(r,n=Bt){return Ct(Rt,new TextEncoder().encode(r),new TextEncoder().encode(_t),new TextEncoder().encode(n),q)}function dt(r,n=M,t=O){let e=w(r);return e.length<q?n:n+e[q-1]%t}function ht(r,n,t=M,e=O){let s=w(r),i=w(n),o=dt(i,t,e),a=crypto.getRandomValues(new Uint8Array(o)),u=crypto.getRandomValues(new Uint8Array(k)),h=mt(i,u).encrypt(s),p=new Uint8Array(o+k+h.length);return p.set(a,0),p.set(u,o),p.set(h,o+k),p}function pt(r,n,t=M,e=O){let s=w(r),i=w(n),o=dt(i,t,e);if(s.length<o+k+St)throw new Error("Encrypted packet too short");let a=s.slice(o,o+k),u=s.slice(o+k);return mt(i,a).decrypt(u)}function v(r,n){return lt(r||n)}function Tt(r,n){return ht(r,n)}function S(r,n){let t=pt(r,n);return JSON.parse(new TextDecoder().decode(t))}function ft(r,n,t,e){let s=n.toLowerCase().includes("application/octet-stream");if(t&&!s)throw new Error("Encrypted request required: Content-Type must be application/octet-stream");if(s){if(r==null)throw new Error("Encrypted request body is empty");if(r instanceof ArrayBuffer)return S(r,e);if(r instanceof Uint8Array){let i=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return S(i,e)}throw new Error("Encrypted request body must be ArrayBuffer or Uint8Array")}return r==null||r===""?{}:typeof r=="string"?JSON.parse(r):r}import{sha256 as $t}from"@noble/hashes/sha2";import{hmac as At}from"@noble/hashes/hmac";function gt(r,n,t,e,s){let i=String(Math.floor(Date.now()/1e3)),o=crypto.randomUUID(),a=new TextEncoder().encode(`${r}|${n}|${i}|${o}|`),u=new Uint8Array(a.length+t.length);u.set(a,0),u.set(t,a.length);let h=[...At($t,new TextEncoder().encode(s),u)].map(p=>p.toString(16).padStart(2,"0")).join("");return{"X-API-Key":e,"X-Timestamp":i,"X-Nonce":o,"X-Signature":h}}function Et(r){return r.hmacSecret||r.token||r.anonymousPacketToken}function qt(r){return r!=="GET"&&r!=="HEAD"&&r!=="OPTIONS"}function _(r){if(typeof document>"u")return"";for(let n of document.cookie.split(";")){let t=n.indexOf("=");if(!(t<0)&&n.substring(0,t).trim()===r)return decodeURIComponent(n.substring(t+1).trim())}return""}function Mt(r,n){return r===403&&/csrf/i.test(n)?!0:/csrf/i.test(n)&&/expired|token validation failed/i.test(n)}async function kt(r){if((r.headers.get("Content-Type")??"").includes("application/json")){let e=await r.json().catch(()=>null);if(e?.error)return e.error;if(e?.message)return e.message}return await r.text().catch(()=>"")||`HTTP ${r.status}`}async function g(r,n,t,e,s=!0,i={},o=!0){let{baseUrl:a,token:u,apiKey:d,hmacSecret:h,encryptRequests:p,csrfEnabled:Pt,csrfHeaderName:yt,csrfCookieName:A,refreshCsrfCookie:b}=r,x=r.anonymousPacketToken||_("anon_token"),R=s&&!!(d&&h),wt=Et(r),C=Pt&&qt(n)&&!R,y=C?_(A):"",ot="application/json",vt=!u&&!R&&!!x,f=null;if(e!=null)if(p&&!!wt&&n!=="GET"&&n!=="HEAD"){let T=v(h,u||x);f=Tt(new TextEncoder().encode(JSON.stringify(e)),T),ot="application/octet-stream"}else f=JSON.stringify(e);let bt=m=>{let T={"Content-Type":ot,...i};if(!R&&s&&u&&(T.Authorization=`Bearer ${u}`),vt&&(T["X-Packet-Token"]=x),C&&m&&(T[yt]=m),R){let xt=f instanceof Uint8Array?f:typeof f=="string"?new TextEncoder().encode(f):new Uint8Array(0);Object.assign(T,gt(n,t,xt,d,h))}return T};C&&!y&&b&&(await b(),y=_(A));let at=m=>fetch(a+t,{method:n,headers:bt(m),...f!=null?{body:f}:{},credentials:"include"}),l=await at(y);if(!l.ok){let m=await kt(l.clone());if(C&&b&&Mt(l.status,m))await b(),y=_(A),l=await at(y);else{let T=new Error(m);throw T.status=l.status,T}}if(!l.ok){let m=new Error(await kt(l));throw m.status=l.status,m}let ut=l.headers.get("Content-Type")??"";if(ut.includes("application/octet-stream")){let m=v(h,u||x);return S(await l.arrayBuffer(),m)}if(!ut.includes("application/json"))return await l.text();let E=await l.json();if(o&&!E.ok){let m=new Error(E.message??`EntityServer error (HTTP ${l.status})`);throw m.status=l.status,m}return E}var B=class{baseUrl;token;anonymousPacketToken;apiKey;hmacSecret;encryptRequests;csrfEnabled;csrfHeaderName;csrfCookieName;_csrfRefresher=null;activeTxId=null;keepSession;refreshBuffer;onTokenRefreshed;onSessionExpired;onHealthChange;_sessionRefreshToken=null;_refreshTimer=null;_healthTickTimer=null;_healthTickPromise=null;constructor(n={}){let t=ct("VITE_ENTITY_SERVER_URL");this.baseUrl=(n.baseUrl??t??"").replace(/\/$/,""),this.token=n.token??"",this.anonymousPacketToken=n.anonymousPacketToken??"",this.apiKey=n.apiKey??"",this.hmacSecret=n.hmacSecret??"",this.encryptRequests=n.encryptRequests??!1,this.csrfEnabled=n.csrfEnabled??!1,this.csrfHeaderName=n.csrfHeaderName??"x-csrf-token",this.csrfCookieName=n.csrfCookieName??"_csrf",this.keepSession=n.keepSession??!1,this.refreshBuffer=n.refreshBuffer??60,this.onTokenRefreshed=n.onTokenRefreshed,this.onSessionExpired=n.onSessionExpired,this.onHealthChange=n.onHealthChange,typeof n.healthTickInterval=="number"&&n.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(n.healthTickInterval))}configure(n){typeof n.baseUrl=="string"&&(this.baseUrl=n.baseUrl.replace(/\/$/,"")),typeof n.token=="string"&&(this.token=n.token),typeof n.anonymousPacketToken=="string"&&(this.anonymousPacketToken=n.anonymousPacketToken),typeof n.encryptRequests=="boolean"&&(this.encryptRequests=n.encryptRequests),typeof n.csrfEnabled=="boolean"&&(this.csrfEnabled=n.csrfEnabled),typeof n.csrfHeaderName=="string"&&(this.csrfHeaderName=n.csrfHeaderName),typeof n.csrfCookieName=="string"&&(this.csrfCookieName=n.csrfCookieName),typeof n.apiKey=="string"&&(this.apiKey=n.apiKey),typeof n.hmacSecret=="string"&&(this.hmacSecret=n.hmacSecret),typeof n.keepSession=="boolean"&&(this.keepSession=n.keepSession),typeof n.refreshBuffer=="number"&&(this.refreshBuffer=n.refreshBuffer),n.onTokenRefreshed&&(this.onTokenRefreshed=n.onTokenRefreshed),n.onSessionExpired&&(this.onSessionExpired=n.onSessionExpired),n.onHealthChange&&(this.onHealthChange=n.onHealthChange),typeof n.healthTickInterval=="number"&&n.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(n.healthTickInterval))}setToken(n){this.token=n}setAnonymousPacketToken(n){this.anonymousPacketToken=n}setApiKey(n){this.apiKey=n}setHmacSecret(n){this.hmacSecret=n}setEncryptRequests(n){this.encryptRequests=n}setCsrfEnabled(n){this.csrfEnabled=n}startHealthTick(n=300*1e3){this.stopHealthTick();let t=()=>{this._healthTickPromise||(this._healthTickPromise=(this._csrfRefresher?this._csrfRefresher():Promise.resolve()).then(()=>{this.onHealthChange?.(!0)}).catch(()=>{this.onHealthChange?.(!1)}).finally(()=>{this._healthTickPromise=null}))};t(),this._healthTickTimer=setInterval(t,n)}stopHealthTick(){this._healthTickTimer!==null&&(clearInterval(this._healthTickTimer),this._healthTickTimer=null),this._healthTickPromise=null}_scheduleKeepSession(n,t,e){this._clearRefreshTimer(),this._sessionRefreshToken=n;let s=Math.max((t-this.refreshBuffer)*1e3,0);this._refreshTimer=setTimeout(async()=>{if(this._sessionRefreshToken)try{let i=await e(this._sessionRefreshToken);this.onTokenRefreshed?.(i.access_token,i.expires_in),this._scheduleKeepSession(this._sessionRefreshToken,i.expires_in,e)}catch(i){this._clearRefreshTimer(),this.onSessionExpired?.(i instanceof Error?i:new Error(String(i)))}},s)}_clearRefreshTimer(){this._refreshTimer!==null&&(clearTimeout(this._refreshTimer),this._refreshTimer=null)}stopKeepSession(){this._clearRefreshTimer(),this._sessionRefreshToken=null}_applyCsrfHealth(){if(!(typeof document>"u")){for(let n of document.cookie.split(";")){let t=n.indexOf("=");if(!(t<0)&&n.substring(0,t).trim()===this.csrfCookieName){this.csrfEnabled=!!n.substring(t+1).trim();return}}this.csrfEnabled=!1}}readRequestBody(n,t="application/json",e=!1){let s=v(this.hmacSecret,this.token||this.anonymousPacketToken);return ft(n,t,e,s)}get _reqOpts(){return{baseUrl:this.baseUrl,token:this.token,anonymousPacketToken:this.anonymousPacketToken,apiKey:this.apiKey,hmacSecret:this.hmacSecret,encryptRequests:this.encryptRequests,csrfEnabled:this.csrfEnabled,csrfHeaderName:this.csrfHeaderName,csrfCookieName:this.csrfCookieName,refreshCsrfCookie:this.csrfEnabled?this._csrfRefresher:null}}get http(){let n=this;return{get(t,e=!0,s){return g(n._reqOpts,"GET",t,void 0,e,s,!1)},post(t,e,s=!0,i){return g(n._reqOpts,"POST",t,e,s,i,!1)},put(t,e,s=!0,i){return g(n._reqOpts,"PUT",t,e,s,i,!1)},patch(t,e,s=!0,i){return g(n._reqOpts,"PATCH",t,e,s,i,!1)},delete(t,e,s=!0,i){return g(n._reqOpts,"DELETE",t,e,s,i,!1)}}}requestBinary(n,t,e,s=!0){return this._requestBinary(n,t,e,s)}requestForm(n,t,e,s=!0){return this._requestForm(n,t,e,s)}requestFormBinary(n,t,e,s=!0){return this._requestFormBinary(n,t,e,s)}_request(n,t,e,s=!0,i){return g(this._reqOpts,n,t,e,s,i,!0)}async _requestBinary(n,t,e,s=!0){let i={"Content-Type":"application/json"};s&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+t,{method:n,headers:i,...e!=null?{body:JSON.stringify(e)}:{},credentials:"include"});if(!o.ok){let a=await o.text(),u=new Error(`HTTP ${o.status}: ${a}`);throw u.status=o.status,u}return o.arrayBuffer()}async _requestForm(n,t,e,s=!0){let i={};s&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+t,{method:n,headers:i,body:e,credentials:"include"}),a=await o.json();if(!a.ok){let u=new Error(a.message??`EntityServer error (HTTP ${o.status})`);throw u.status=o.status,u}return a}async _requestFormBinary(n,t,e,s=!0){let i={};s&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+t,{method:n,headers:i,body:e,credentials:"include"});if(!o.ok){let a=await o.text(),u=new Error(`HTTP ${o.status}: ${a}`);throw u.status=o.status,u}return o.arrayBuffer()}};function U(r){return class extends r{_csrfRefresher=()=>this.checkHealth().then(()=>{});async checkHealth(){let e=await(await fetch(`${this.baseUrl}/v1/health`,{signal:AbortSignal.timeout(3e3),credentials:"include"})).json(),s=this._readCookie("anon_token");return s&&(this.anonymousPacketToken=s),this._applyCsrfHealth(),e}_readCookie(t){if(typeof document>"u")return null;let e=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith(`${t}=`));if(!e)return null;try{return decodeURIComponent(e.slice(t.length+1))}catch{return e.slice(t.length+1)}}async login(t,e){let s=await this._request("POST","/v1/auth/login",{email:t,passwd:e},!1);return this.token=s.data.access_token,this.keepSession&&this._scheduleKeepSession(s.data.refresh_token,s.data.expires_in,i=>this.refreshToken(i)),s.data}async refreshToken(t){let e=await this._request("POST","/v1/auth/refresh",{refresh_token:t},!1);return this.token=e.data.access_token,this.keepSession&&this._scheduleKeepSession(t,e.data.expires_in,s=>this.refreshToken(s)),e.data}async logout(t){this.stopKeepSession();let e=await this._request("POST","/v1/auth/logout",{refresh_token:t},!1);return this.token="",e}me(){return this._request("GET","/v1/auth/me")}withdraw(t){return this._request("POST","/v1/auth/withdraw",t?{passwd:t}:{})}}}function I(r){return class extends r{async transStart(){let t=await this._request("POST","/v1/transaction/start",void 0,!1);return this.activeTxId=t.transaction_id,this.activeTxId}transRollback(t){let e=t??this.activeTxId;return e?(this.activeTxId=null,this._request("POST",`/v1/transaction/rollback/${e}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}transCommit(t){let e=t??this.activeTxId;return e?(this.activeTxId=null,this._request("POST",`/v1/transaction/commit/${e}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}meta(t){return this._request("POST",`/v1/entity/${t}/meta`,{})}validate(t,e){return this.http.post(`/v1/entity/${t}/validate`,e)}get(t,e,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this._request("GET",`/v1/entity/${t}/${e}${i}`)}find(t,e,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this._request("POST",`/v1/entity/${t}/find${i}`,e??{})}list(t,e={}){let{conditions:s,fields:i,orderDir:o,orderBy:a,...u}=e,d={page:1,limit:20,...u};return a&&(d.orderBy=o==="DESC"?`-${a}`:a),i?.length&&(d.fields=i.join(",")),this._request("POST",`/v1/entity/${t}/list?${c(d)}`,s??{})}count(t,e){return this._request("POST",`/v1/entity/${t}/count`,e??{})}query(t,e){return this._request("POST",`/v1/entity/${t}/query`,e)}submit(t,e,s={}){let i=s.transactionId??this.activeTxId,o=i?{"X-Transaction-ID":i}:void 0,a=s.skipHooks?"?skipHooks=true":"";return this._request("POST",`/v1/entity/${t}/submit${a}`,e,!0,o)}delete(t,e,s={}){let i=new URLSearchParams;s.hard&&i.set("hard","true"),s.skipHooks&&i.set("skipHooks","true");let o=i.size?`?${i}`:"",a=s.transactionId??this.activeTxId,u=a?{"X-Transaction-ID":a}:void 0;return this._request("POST",`/v1/entity/${t}/delete/${e}${o}`,void 0,!0,u)}history(t,e,s={}){return this._request("GET",`/v1/entity/${t}/history/${e}?${c({page:1,limit:50,...s})}`)}rollback(t,e){return this._request("POST",`/v1/entity/${t}/rollback/${e}`)}}}function G(r){return class extends r{async fileUpload(t,e,s={}){let i=new FormData;return i.append("file",e,e instanceof File?e.name:"upload"),s.refSeq!=null&&i.append("ref_seq",String(s.refSeq)),s.isPublic!=null&&i.append("is_public",s.isPublic?"true":"false"),this._requestForm("POST",`/v1/files/${t}/upload`,i)}fileDownload(t,e){return this._requestBinary("POST",`/v1/files/${t}/download/${e}`,{})}fileDelete(t,e){return this._request("POST",`/v1/files/${t}/delete/${e}`,{})}fileList(t,e={}){return this._request("POST",`/v1/files/${t}/list`,e.refSeq?{ref_seq:e.refSeq}:{})}fileMeta(t,e){return this._request("POST",`/v1/files/${t}/meta/${e}`,{})}fileToken(t){return this._request("POST",`/v1/files/token/${t}`,{})}fileViewUrl(t,e={}){let s=e.download?"?download=true":"";return`${this.baseUrl}/v1/files/${t}${s}`}fileUrl(t){return`${this.baseUrl}/v1/files/${t}`}}}function H(r){return class extends r{push(t,e,s={}){return this.submit(t,e,s)}pushLogList(t={}){return this.list("push_log",t)}registerPushDevice(t,e,s,i={}){let{platform:o,deviceType:a,browser:u,browserVersion:d,pushEnabled:h=!0,transactionId:p}=i;return this.submit("account_device",{id:e,account_seq:t,push_token:s,push_enabled:h,...o?{platform:o}:{},...a?{device_type:a}:{},...u?{browser:u}:{},...d?{browser_version:d}:{}},{transactionId:p})}updatePushDeviceToken(t,e,s={}){let{pushEnabled:i=!0,transactionId:o}=s;return this.submit("account_device",{seq:t,push_token:e,push_enabled:i},{transactionId:o})}disablePushDevice(t,e={}){return this.submit("account_device",{seq:t,push_enabled:!1},{transactionId:e.transactionId})}}}function F(r){return class extends r{smtpSend(t){return this._request("POST","/v1/smtp/send",t)}smtpStatus(t){return this._request("POST",`/v1/smtp/status/${t}`,{})}smtpTemplatePreview(t){let e=t.split("/").map(encodeURIComponent).join("/");return fetch(`${this.baseUrl}/v1/smtp/template/${e}`,{credentials:"include"}).then(s=>s.text())}}}function L(r){return class extends r{transactionStart(t){return this._request("POST","/v1/transaction/start",t??{})}transactionCommit(t){return this._request("POST",`/v1/transaction/commit/${encodeURIComponent(t)}`,{})}transactionRollback(t){return this._request("POST",`/v1/transaction/rollback/${encodeURIComponent(t)}`,{})}}}function j(r){return class extends r{addressSido(){return this.http.get("/v1/utils/address/sido",!1)}addressSigungu(t){let e=new URLSearchParams({sido:t.sido}).toString();return this.http.get(`/v1/utils/address/sigungu?${e}`,!1)}addressDong(t){let e=new URLSearchParams({sido:t.sido,sigungu:t.sigungu}).toString();return this.http.get(`/v1/utils/address/dong?${e}`,!1)}addressClean(t){let e=new URLSearchParams({q:t.q}).toString();return this.http.get(`/v1/utils/address/clean?${e}`,!1)}qrcode(t,e={}){return this._requestBinary("POST","/v1/utils/qrcode",{content:t,...e})}qrcodeBase64(t,e={}){return this._request("POST","/v1/utils/qrcode/base64",{content:t,...e})}qrcodeText(t,e={}){return this._request("POST","/v1/utils/qrcode/text",{content:t,...e})}barcode(t,e={}){return this._requestBinary("POST","/v1/utils/barcode",{content:t,...e})}pdf2png(t,e={}){let s=new FormData;s.append("file",new Blob([t],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;e.dpi!=null&&i.set("dpi",String(e.dpi)),e.firstPage!=null&&i.set("first_page",String(e.firstPage)),e.lastPage!=null&&i.set("last_page",String(e.lastPage));let o=i.toString(),a="/v1/utils/pdf2png"+(o?`?${o}`:"");return this._requestFormBinary("POST",a,s)}pdf2pngByFileSeq(t,e={}){return this.requestBinary("POST",`/v1/utils/pdf2png/${t}`,e)}pdf2jpg(t,e={}){let s=new FormData;s.append("file",new Blob([t],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;e.dpi!=null&&i.set("dpi",String(e.dpi)),e.firstPage!=null&&i.set("first_page",String(e.firstPage)),e.lastPage!=null&&i.set("last_page",String(e.lastPage));let o=i.toString(),a="/v1/utils/pdf2jpg"+(o?`?${o}`:"");return this._requestFormBinary("POST",a,s)}pdf2jpgByFileSeq(t,e={}){return this.requestBinary("POST",`/v1/utils/pdf2jpg/${t}`,e)}}}function K(r){return class extends r{_adminPath(t){return`/v1/admin${t}`}_adminGet(t){return this.http.get(this._adminPath(t))}_adminPost(t,e){return this.http.post(this._adminPath(t),e)}_adminPut(t,e){return this.http.put(this._adminPath(t),e)}_adminPatch(t,e){return this.http.patch(this._adminPath(t),e)}_adminDelete(t,e){return this.http.delete(this._adminPath(t),e)}listAdminEntities(){return this._adminGet("/entities")}getAdminErdSchema(){return this._adminGet("/erd/schema")}batchEnsureAdminEntities(t){return this._adminPost("/entities/batch-ensure",t)}createAdminEntityConfig(t,e){return this._adminPost(`/${t}/create`,e)}getAdminEntityConfig(t){return this._adminGet(`/${t}/config`)}updateAdminEntityConfig(t,e){return this._adminPut(`/${t}/config`,e)}validateAdminEntityConfig(t,e){return this._adminPost(e?`/${e}/validate`:"/entity/validate",t)}normalizeAdminEntityConfig(t,e){return this._adminPost(e?`/${e}/normalize`:"/entity/normalize",t)}getAdminEntityStats(t,e){return this._adminPost(`/${t}/stats`,e)}reindexAdminEntity(t){return this._adminPost(`/${t}/reindex`)}syncAdminEntitySchema(t){return this._adminPost(`/${t}/sync-schema`)}resetAdminEntity(t){return this._adminPost(`/${t}/reset`)}truncateAdminEntity(t){return this._adminPost(`/${t}/truncate`)}dropAdminEntity(t){return this._adminPost(`/${t}/drop`)}resetAllAdmin(t){return this._adminPost("/reset-all",t)}listAdminConfigs(){return this._adminGet("/configs")}getAdminConfig(t){return this._adminGet(`/configs/${t}`)}updateAdminConfig(t,e){return this._adminPatch(`/configs/${t}`,e)}listAdminRoles(){return this._adminGet("/roles")}createAdminRole(t){return this._adminPost("/roles",t)}getAdminRole(t){return this._adminGet(`/roles/${t}`)}updateAdminRole(t,e){return this._adminPatch(`/roles/${t}`,e)}deleteAdminRole(t){return this._adminDelete(`/roles/${t}`)}listAdminApiKeys(){return this._adminGet("/api-keys")}createAdminApiKey(t){return this._adminPost("/api-keys",t)}getAdminApiKey(t){return this._adminGet(`/api-keys/${t}`)}updateAdminApiKey(t,e){return this._adminPatch(`/api-keys/${t}`,e)}deleteAdminApiKey(t){return this._adminDelete(`/api-keys/${t}`)}regenerateAdminApiKeySecret(t){return this._adminPost(`/api-keys/${t}/regenerate-secret`)}listAdminAccounts(){return this._adminGet("/accounts")}createAdminAccount(t){return this._adminPost("/accounts",t)}getAdminAccount(t){return this._adminGet(`/accounts/${t}`)}updateAdminAccount(t,e){return this._adminPatch(`/accounts/${t}`,e)}deleteAdminAccount(t){return this._adminDelete(`/accounts/${t}`)}listAdminLicenses(){return this._adminGet("/licenses")}createAdminLicense(t){return this._adminPost("/licenses",t)}getAdminLicense(t){return this._adminGet(`/licenses/${t}`)}updateAdminLicense(t,e){return this._adminPatch(`/licenses/${t}`,e)}deleteAdminLicense(t){return this._adminDelete(`/licenses/${t}`)}runAdminBackup(t){return this._adminPost("/backup/run",t)}getAdminBackupStatus(t){return this._adminPost("/backup/status",t)}listAdminBackups(t){return this._adminPost("/backup/list",t)}restoreAdminBackup(t){return this._adminPost("/backup/restore",t)}deleteAdminBackup(t){return this._adminPost("/backup/delete",t)}disableAdminAccountTwoFactor(t){return this._adminDelete(`/accounts/${t}/2fa`)}}}var P=class extends j(L(G(F(H(K(I(U(B)))))))){};function D(r){return class extends r{accountRegister(t){return this.http.post("/v1/account/register",t,!1)}accountWithdraw(t){return this.http.post("/v1/account/withdraw",t)}accountChangePassword(t){return this.http.post("/v1/account/change-password",t)}accountReactivate(t){return this.http.post("/v1/account/reactivate",t,!1)}listAccountBiometrics(){return this.http.get("/v1/account/biometric")}registerAccountBiometric(t){return this.http.post("/v1/account/biometric",t)}deleteAccountBiometric(t){return this.http.delete(`/v1/account/biometric/${t}`)}}}function N(r){return class extends r{listBoardCategories(t={}){let e=c(t);return this.http.get(`/v1/board/categories${e?`?${e}`:""}`,!1)}getBoardCategory(t){return this.http.get(`/v1/board/categories/${t}`,!1)}createBoardCategory(t){return this.http.post("/v1/board/categories",t)}updateBoardCategory(t,e){return this.http.put(`/v1/board/categories/${t}`,e)}deleteBoardCategory(t){return this.http.delete(`/v1/board/categories/${t}`)}listBoardPosts(t,e={}){let s=c(e);return this.http.get(`/v1/board/${t}/list${s?`?${s}`:""}`,!1)}getBoardPost(t){return this.http.get(`/v1/board/posts/${t}`,!1)}createBoardPost(t,e){return this.http.post(`/v1/board/${t}/submit`,e)}updateBoardPost(t,e){return this.http.put(`/v1/board/posts/${t}`,e)}deleteBoardPost(t){return this.http.delete(`/v1/board/posts/${t}`)}listBoardComments(t,e={}){let s=c(e);return this.http.get(`/v1/board/posts/${t}/comments${s?`?${s}`:""}`,!1)}createBoardComment(t,e){return this.http.post(`/v1/board/posts/${t}/comments/submit`,e)}updateBoardComment(t,e){return this.http.put(`/v1/board/comments/${t}`,e)}deleteBoardComment(t){return this.http.delete(`/v1/board/comments/${t}`)}listBoardFiles(t){return this.http.get(`/v1/board/posts/${t}/files`,!1)}async uploadBoardFile(t,e){let s=new FormData;return s.append("file",e,e instanceof File?e.name:"upload"),this.requestForm("POST",`/v1/board/posts/${t}/files`,s)}boardFileUrl(t){return`${this.baseUrl}/v1/board/files/${t}`}deleteBoardFile(t){return this.http.delete(`/v1/board/files/${t}`)}createBoardGuestPost(t,e){return this.http.post(`/v1/board/${t}/guest-submit`,e,!1)}authenticateBoardGuestPost(t,e){return this.http.post(`/v1/board/posts/${t}/guest-auth`,e,!1)}toggleBoardPostLike(t){return this.http.post(`/v1/board/posts/${t}/like`,{})}acceptBoardPost(t){return this.http.post(`/v1/board/posts/${t}/accept`,{})}rateBoardPost(t,e){return this.http.post(`/v1/board/posts/${t}/rating`,e)}rateBoardComment(t,e){return this.http.post(`/v1/board/comments/${t}/rating`,e)}listBoardTags(t={}){let e=c(t);return this.http.get(`/v1/board/tags${e?`?${e}`:""}`,!1)}setBoardPostTags(t,e){return this.http.put(`/v1/board/posts/${t}/tags`,e)}reportBoardPost(t,e){return this.http.post(`/v1/board/posts/${t}/report`,e)}reportBoardComment(t,e){return this.http.post(`/v1/board/comments/${t}/report`,e)}listBoardReports(t={}){let e=c(t);return this.http.get(`/v1/board/admin/reports${e?`?${e}`:""}`)}updateBoardReport(t,e){return this.http.patch(`/v1/board/admin/reports/${t}`,e)}markBoardPostRead(t){return this.http.post(`/v1/board/posts/${t}/read`,{})}listBoardMentions(t={}){let e=c(t);return this.http.get(`/v1/board/mentions${e?`?${e}`:""}`)}markBoardMentionRead(t){return this.http.patch(`/v1/board/mentions/${t}/read`,{})}}}function V(r){return class extends r{sendEmailVerification(t){return this.http.post("/v1/email-verify/send",t,!1)}confirmEmailVerification(t){return this.http.post("/v1/email-verify/confirm",t,!1)}activateEmailVerification(t){let e=c(t);return this.http.get(`/v1/email-verify/activate${e?`?${e}`:""}`,!1)}getEmailVerificationStatus(){return this.http.get("/v1/email-verify/status")}changeVerifiedEmail(t){return this.http.post("/v1/email-verify/change",t)}}}function Q(r){return class extends r{oauthAuthorizeUrl(t,e={}){let s=c(e);return`${this.baseUrl}/v1/oauth/${t}${s?`?${s}`:""}`}oauthCallback(t,e,s="POST"){if(s==="GET"){let i=c(e??{});return this.http.get(`/v1/oauth/${t}/callback${i?`?${i}`:""}`,!1)}return this.http.post(`/v1/oauth/${t}/callback`,e,!1)}linkOAuthAccount(t){return this.http.post("/v1/account/oauth/link",t)}unlinkOAuthAccount(t){return this.http.delete(`/v1/account/oauth/link/${t}`)}listOAuthProviders(){return this.http.get("/v1/account/oauth/providers")}refreshOAuthProviderToken(t,e){return this.http.post(`/v1/account/oauth/refresh/${t}`,e)}}}function z(r){return class extends r{requestPasswordReset(t){return this.http.post("/v1/password-reset/request",t,!1)}validatePasswordResetToken(t){return this.http.get(`/v1/password-reset/validate/${encodeURIComponent(t)}`,!1)}verifyPasswordReset(t){return this.http.post("/v1/password-reset/verify",t,!1)}}}function X(r){return class extends r{setupTwoFactor(t){return this.http.post("/v1/account/2fa/setup",t)}verifyTwoFactorSetup(t){return this.http.post("/v1/account/2fa/setup/verify",t,!1)}disableTwoFactor(){return this.http.delete("/v1/account/2fa")}getTwoFactorStatus(){return this.http.get("/v1/account/2fa/status")}regenerateTwoFactorRecoveryCodes(){return this.http.post("/v1/account/2fa/recovery/regenerate")}verifyTwoFactor(t){return this.http.post("/v1/account/2fa/verify",t,!1)}recoverTwoFactorAccess(t){return this.http.post("/v1/account/2fa/recovery",t,!1)}}}function W(r){return class extends r{alimtalkSend(t){return this.http.post("/v1/alimtalk/send",t)}alimtalkStatus(t){return this.http.get(`/v1/alimtalk/status/${t}`,!1)}listAlimtalkTemplates(){return this.http.get("/v1/alimtalk/templates",!1)}alimtalkWebhook(t,e){return this.http.post(`/v1/alimtalk/webhook/${encodeURIComponent(t)}`,e,!1)}}}function J(r){return class extends r{friendtalkSend(t){return this.http.post("/v1/friendtalk/send",t)}}}function Y(r){return class extends r{listHolidays(t={}){let e=c(t);return this.http.get(`/v1/holidays${e?`?${e}`:""}`,!1)}getHolidayByDate(t){return this.http.get(`/v1/holidays/${encodeURIComponent(t)}`,!1)}syncHolidays(t){return this.http.post("/v1/holidays/sync",t)}}}function Z(r){return class extends r{identityRequest(t){return this.http.post("/v1/identity/request",t,!1)}identityCallback(t){return this.http.post("/v1/identity/callback",t,!1)}identityResult(t){return this.http.get(`/v1/identity/result/${encodeURIComponent(t)}`,!1)}identityVerifyCI(t){return this.http.post("/v1/identity/verify-ci",t)}}}function tt(r){return class extends r{llmChat(t){return this.http.post("/v1/llm/chat",t)}llmChatStream(t){return this.http.post("/v1/llm/chat/stream",t)}createLlmConversation(t){return this.http.post("/v1/llm/conversations",t)}sendLlmMessage(t,e){return this.http.post(`/v1/llm/conversations/${t}/messages`,e)}listLlmConversations(t={}){let e=c(t);return this.http.get(`/v1/llm/conversations${e?`?${e}`:""}`)}getLlmConversation(t){return this.http.get(`/v1/llm/conversations/${t}`)}updateLlmConversation(t,e){return this.http.patch(`/v1/llm/conversations/${t}`,e)}deleteLlmConversation(t){return this.http.delete(`/v1/llm/conversations/${t}`)}ragUploadDocument(t){return this.requestForm("POST","/v1/llm/rag/documents",t)}ragListDocuments(t={}){let e=c(t);return this.http.get(`/v1/llm/rag/documents${e?`?${e}`:""}`)}ragDeleteDocument(t){return this.http.delete(`/v1/llm/rag/documents/${encodeURIComponent(t)}`)}ragSearch(t){return this.http.post("/v1/llm/rag/search",t)}ragChat(t){return this.http.post("/v1/llm/rag/chat",t)}ragChatStream(t){return this.http.post("/v1/llm/rag/chat/stream",t)}ragRebuildIndex(t){return this.http.post("/v1/llm/rag/rebuild-index",t)}listLlmProviders(){return this.http.get("/v1/llm/providers")}getLlmUsage(t={}){let e=c(t);return this.http.get(`/v1/llm/usage${e?`?${e}`:""}`)}getLlmUsageSummary(t={}){let e=c(t);return this.http.get(`/v1/llm/usage/summary${e?`?${e}`:""}`)}getLlmCacheStats(){return this.http.get("/v1/llm/cache/stats")}clearLlmCache(){return this.http.delete("/v1/llm/cache")}listLlmTemplates(){return this.http.get("/v1/llm/templates")}llmTemplateChat(t,e){return this.http.post(`/v1/llm/${encodeURIComponent(t)}/chat`,e)}llmTemplateChatStream(t,e){return this.http.post(`/v1/llm/${encodeURIComponent(t)}/chat/stream`,e)}listLlmChatbots(t={}){let e=c(t);return this.http.get(`/v1/llm/chatbots${e?`?${e}`:""}`)}createLlmChatbot(t){return this.http.post("/v1/llm/chatbots",t)}getLlmChatbot(t){return this.http.get(`/v1/llm/chatbots/${t}`)}updateLlmChatbot(t,e){return this.http.patch(`/v1/llm/chatbots/${t}`,e)}deleteLlmChatbot(t){return this.http.delete(`/v1/llm/chatbots/${t}`)}llmChatbotChat(t,e){return this.http.post(`/v1/llm/chatbots/${t}/chat`,e)}llmChatbotChatStream(t,e){return this.http.post(`/v1/llm/chatbots/${t}/chat/stream`,e)}listLlmChatbotSessions(t,e={}){let s=c(e);return this.http.get(`/v1/llm/chatbots/${t}/sessions${s?`?${s}`:""}`)}deleteLlmChatbotSession(t,e){return this.http.delete(`/v1/llm/chatbots/${t}/sessions/${e}`)}listLlmProfiles(t={}){let e=c(t);return this.http.get(`/v1/llm/profiles${e?`?${e}`:""}`)}upsertLlmProfile(t){return this.http.post("/v1/llm/profiles",t)}deleteLlmProfile(t){return this.http.delete(`/v1/llm/profiles/${t}`)}}}function et(r){return class extends r{ocrRecognize(t){return this.requestForm("POST","/v1/ocr/recognize",t)}ocrRecognizeAsync(t){return this.requestForm("POST","/v1/ocr/recognize/async",t)}ocrRecognizeByDocType(t,e){return this.requestForm("POST",`/v1/ocr/${encodeURIComponent(t)}`,e)}listOcrResults(t={}){let e=c(t);return this.http.get(`/v1/ocr/results${e?`?${e}`:""}`)}getOcrResult(t){return this.http.get(`/v1/ocr/results/${encodeURIComponent(t)}`)}getOcrResultText(t){return this.http.get(`/v1/ocr/results/${encodeURIComponent(t)}/text`)}deleteOcrResult(t){return this.http.delete(`/v1/ocr/results/${encodeURIComponent(t)}`)}getOcrQuota(){return this.http.get("/v1/ocr/quota")}}}function nt(r){return class extends r{pgCreateOrder(t){return this.http.post("/v1/pg/orders",t)}pgGetOrder(t){return this.http.get(`/v1/pg/orders/${encodeURIComponent(t)}`)}pgConfirmPayment(t){return this.http.post("/v1/pg/confirm",t)}pgCancelPayment(t,e){return this.http.post(`/v1/pg/orders/${encodeURIComponent(t)}/cancel`,e)}pgSyncPaymentStatus(t,e){return this.http.post(`/v1/pg/orders/${encodeURIComponent(t)}/sync`,e)}pgWebhook(t){return this.http.post("/v1/pg/webhook",t,!1)}pgGetClientConfig(){return this.http.get("/v1/pg/config",!1)}}}function rt(r){return class extends r{appPushSend(t){return this.http.post("/v1/push/send",t)}appPushBroadcast(t){return this.http.post("/v1/push/broadcast",t)}appPushStatus(t){return this.http.get(`/v1/push/status/${t}`)}appPushRegisterDevice(t){return this.http.post("/v1/push/device",t)}appPushUnregisterDevice(t){return this.http.delete(`/v1/push/device/${t}`)}}}function st(r){return class extends r{smsSend(t){return this.http.post("/v1/sms/send",t)}smsStatus(t){return this.http.get(`/v1/sms/status/${t}`,!1)}smsVerificationSend(t){return this.http.post("/v1/sms/verification/send",t,!1)}smsVerificationVerify(t){return this.http.post("/v1/sms/verification/verify",t,!1)}}}function it(r){return class extends r{taxinvoiceRegistIssue(t){return this.http.post("/v1/taxinvoice",t)}taxinvoiceRegister(t){return this.http.post("/v1/taxinvoice/register",t)}taxinvoiceIssue(t){return this.http.post(`/v1/taxinvoice/${t}/issue`,{})}taxinvoiceCancelIssue(t,e){return this.http.post(`/v1/taxinvoice/${t}/cancel`,e)}taxinvoiceGetState(t){return this.http.get(`/v1/taxinvoice/${t}/state`)}taxinvoiceGetDetail(t){return this.http.get(`/v1/taxinvoice/${t}`)}}}var $=class extends W(J(st(rt(nt(it(et(tt(Z(Y(Q(X(z(V(N(D(P)))))))))))))))){};var Un=new P,In=new $;export{D as AccountAppMixin,K as AdminMixin,U as AuthMixin,N as BoardMixin,V as EmailVerifyMixin,$ as EntityAppServerApi,I as EntityMixin,P as EntityServerApi,G as FileMixin,Q as OAuthMixin,_t as PACKET_HKDF_SALT,Bt as PACKET_INFO_LABEL,q as PACKET_KEY_SIZE,M as PACKET_MAGIC_MIN,O as PACKET_MAGIC_RANGE,k as PACKET_NONCE_SIZE,St as PACKET_TAG_SIZE,z as PasswordResetMixin,H as PushMixin,F as SmtpMixin,L as TransactionMixin,X as TwoFactorMixin,j as UtilsMixin,pt as decryptPacket,lt as derivePacketKey,ht as encryptPacket,In as entityAppServer,Un as entityServer,dt as packetMagicLenFromKey};
1
+ function ct(r){let n=import.meta;if(n?.env?.[r]!=null)return n.env[r];let t=globalThis.process;if(t?.env?.[r]!=null)return t.env[r]}function c(r){return Object.entries(r).filter(([,n])=>n!=null).map(([n,t])=>`${encodeURIComponent(n==="orderBy"?"order_by":n)}=${encodeURIComponent(String(t))}`).join("&")}import{xchacha20poly1305 as mt}from"@noble/ciphers/chacha";import{sha256 as Rt}from"@noble/hashes/sha2";import{hkdf as Ct}from"@noble/hashes/hkdf";var q=32,M=2,O=14,k=24,St=16,_t="entity-server:hkdf:v1",Bt="entity-server:packet-encryption";function w(r){return r instanceof Uint8Array?r:new Uint8Array(r)}function lt(r,n=Bt){return Ct(Rt,new TextEncoder().encode(r),new TextEncoder().encode(_t),new TextEncoder().encode(n),q)}function dt(r,n=M,t=O){let e=w(r);return e.length<q?n:n+e[q-1]%t}function ht(r,n,t=M,e=O){let s=w(r),i=w(n),o=dt(i,t,e),a=crypto.getRandomValues(new Uint8Array(o)),u=crypto.getRandomValues(new Uint8Array(k)),h=mt(i,u).encrypt(s),p=new Uint8Array(o+k+h.length);return p.set(a,0),p.set(u,o),p.set(h,o+k),p}function pt(r,n,t=M,e=O){let s=w(r),i=w(n),o=dt(i,t,e);if(s.length<o+k+St)throw new Error("Encrypted packet too short");let a=s.slice(o,o+k),u=s.slice(o+k);return mt(i,a).decrypt(u)}function v(r,n){return lt(r||n)}function Tt(r,n){return ht(r,n)}function S(r,n){let t=pt(r,n);return JSON.parse(new TextDecoder().decode(t))}function ft(r,n,t,e){let s=n.toLowerCase().includes("application/octet-stream");if(t&&!s)throw new Error("Encrypted request required: Content-Type must be application/octet-stream");if(s){if(r==null)throw new Error("Encrypted request body is empty");if(r instanceof ArrayBuffer)return S(r,e);if(r instanceof Uint8Array){let i=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return S(i,e)}throw new Error("Encrypted request body must be ArrayBuffer or Uint8Array")}return r==null||r===""?{}:typeof r=="string"?JSON.parse(r):r}import{sha256 as $t}from"@noble/hashes/sha2";import{hmac as At}from"@noble/hashes/hmac";function gt(r,n,t,e,s){let i=String(Math.floor(Date.now()/1e3)),o=crypto.randomUUID(),a=new TextEncoder().encode(`${r}|${n}|${i}|${o}|`),u=new Uint8Array(a.length+t.length);u.set(a,0),u.set(t,a.length);let h=[...At($t,new TextEncoder().encode(s),u)].map(p=>p.toString(16).padStart(2,"0")).join("");return{"X-API-Key":e,"X-Timestamp":i,"X-Nonce":o,"X-Signature":h}}function Et(r){return r.hmacSecret||r.token||r.anonymousPacketToken}function qt(r){return r!=="GET"&&r!=="HEAD"&&r!=="OPTIONS"}function _(r){if(typeof document>"u")return"";for(let n of document.cookie.split(";")){let t=n.indexOf("=");if(!(t<0)&&n.substring(0,t).trim()===r)return decodeURIComponent(n.substring(t+1).trim())}return""}function Mt(r,n){return r===403&&/csrf/i.test(n)?!0:/csrf/i.test(n)&&/expired|token validation failed/i.test(n)}async function kt(r){if((r.headers.get("Content-Type")??"").includes("application/json")){let e=await r.json().catch(()=>null);if(e?.error)return e.error;if(e?.message)return e.message}return await r.text().catch(()=>"")||`HTTP ${r.status}`}async function g(r,n,t,e,s=!0,i={},o=!0){let{baseUrl:a,token:u,apiKey:d,hmacSecret:h,encryptRequests:p,csrfEnabled:Pt,csrfHeaderName:yt,csrfCookieName:A,refreshCsrfCookie:b}=r,x=r.anonymousPacketToken||_("anon_token"),R=s&&!!(d&&h),wt=Et(r),C=Pt&&qt(n)&&!R,y=C?_(A):"",ot="application/json",vt=!u&&!R&&!!x,f=null;if(e!=null)if(p&&!!wt&&n!=="GET"&&n!=="HEAD"){let T=v(h,u||x);f=Tt(new TextEncoder().encode(JSON.stringify(e)),T),ot="application/octet-stream"}else f=JSON.stringify(e);let bt=m=>{let T={"Content-Type":ot,...i};if(!R&&s&&u&&(T.Authorization=`Bearer ${u}`),vt&&(T["X-Packet-Token"]=x),C&&m&&(T[yt]=m),R){let xt=f instanceof Uint8Array?f:typeof f=="string"?new TextEncoder().encode(f):new Uint8Array(0);Object.assign(T,gt(n,t,xt,d,h))}return T};C&&!y&&b&&(await b(),y=_(A));let at=m=>fetch(a+t,{method:n,headers:bt(m),...f!=null?{body:f}:{},credentials:"include"}),l=await at(y);if(!l.ok){let m=await kt(l.clone());if(C&&b&&Mt(l.status,m))await b(),y=_(A),l=await at(y);else{let T=new Error(m);throw T.status=l.status,T}}if(!l.ok){let m=new Error(await kt(l));throw m.status=l.status,m}let ut=l.headers.get("Content-Type")??"";if(ut.includes("application/octet-stream")){let m=v(h,u||x);return S(await l.arrayBuffer(),m)}if(!ut.includes("application/json"))return await l.text();let E=await l.json();if(o&&!E.ok){let m=new Error(E.message??`EntityServer error (HTTP ${l.status})`);throw m.status=l.status,m}return E}var B=class{baseUrl;token;anonymousPacketToken;apiKey;hmacSecret;encryptRequests;csrfEnabled;csrfHeaderName;csrfCookieName;_csrfRefresher=null;activeTxId=null;keepSession;refreshBuffer;onTokenRefreshed;onSessionExpired;onHealthChange;_sessionRefreshToken=null;_refreshTimer=null;_healthTickTimer=null;_healthTickPromise=null;constructor(n={}){let t=ct("VITE_ENTITY_SERVER_URL");this.baseUrl=(n.baseUrl??t??"").replace(/\/$/,""),this.token=n.token??"",this.anonymousPacketToken=n.anonymousPacketToken??"",this.apiKey=n.apiKey??"",this.hmacSecret=n.hmacSecret??"",this.encryptRequests=n.encryptRequests??!1,this.csrfEnabled=n.csrfEnabled??!1,this.csrfHeaderName=n.csrfHeaderName??"x-csrf-token",this.csrfCookieName=n.csrfCookieName??"_csrf",this.keepSession=n.keepSession??!1,this.refreshBuffer=n.refreshBuffer??60,this.onTokenRefreshed=n.onTokenRefreshed,this.onSessionExpired=n.onSessionExpired,this.onHealthChange=n.onHealthChange,typeof n.healthTickInterval=="number"&&n.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(n.healthTickInterval))}configure(n){typeof n.baseUrl=="string"&&(this.baseUrl=n.baseUrl.replace(/\/$/,"")),typeof n.token=="string"&&(this.token=n.token),typeof n.anonymousPacketToken=="string"&&(this.anonymousPacketToken=n.anonymousPacketToken),typeof n.encryptRequests=="boolean"&&(this.encryptRequests=n.encryptRequests),typeof n.csrfEnabled=="boolean"&&(this.csrfEnabled=n.csrfEnabled),typeof n.csrfHeaderName=="string"&&(this.csrfHeaderName=n.csrfHeaderName),typeof n.csrfCookieName=="string"&&(this.csrfCookieName=n.csrfCookieName),typeof n.apiKey=="string"&&(this.apiKey=n.apiKey),typeof n.hmacSecret=="string"&&(this.hmacSecret=n.hmacSecret),typeof n.keepSession=="boolean"&&(this.keepSession=n.keepSession),typeof n.refreshBuffer=="number"&&(this.refreshBuffer=n.refreshBuffer),n.onTokenRefreshed&&(this.onTokenRefreshed=n.onTokenRefreshed),n.onSessionExpired&&(this.onSessionExpired=n.onSessionExpired),n.onHealthChange&&(this.onHealthChange=n.onHealthChange),typeof n.healthTickInterval=="number"&&n.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(n.healthTickInterval))}setToken(n){this.token=n}setAnonymousPacketToken(n){this.anonymousPacketToken=n}setApiKey(n){this.apiKey=n}setHmacSecret(n){this.hmacSecret=n}setEncryptRequests(n){this.encryptRequests=n}setCsrfEnabled(n){this.csrfEnabled=n}startHealthTick(n=300*1e3){this.stopHealthTick();let t=()=>{this._healthTickPromise||(this._healthTickPromise=(this._csrfRefresher?this._csrfRefresher():Promise.resolve()).then(()=>{this.onHealthChange?.(!0)}).catch(()=>{this.onHealthChange?.(!1)}).finally(()=>{this._healthTickPromise=null}))};t(),this._healthTickTimer=setInterval(t,n)}stopHealthTick(){this._healthTickTimer!==null&&(clearInterval(this._healthTickTimer),this._healthTickTimer=null),this._healthTickPromise=null}_scheduleKeepSession(n,t,e){this._clearRefreshTimer(),this._sessionRefreshToken=n;let s=Math.max((t-this.refreshBuffer)*1e3,0);this._refreshTimer=setTimeout(async()=>{if(this._sessionRefreshToken)try{let i=await e(this._sessionRefreshToken);this.onTokenRefreshed?.(i.access_token,i.expires_in),this._scheduleKeepSession(this._sessionRefreshToken,i.expires_in,e)}catch(i){this._clearRefreshTimer(),this.onSessionExpired?.(i instanceof Error?i:new Error(String(i)))}},s)}_clearRefreshTimer(){this._refreshTimer!==null&&(clearTimeout(this._refreshTimer),this._refreshTimer=null)}stopKeepSession(){this._clearRefreshTimer(),this._sessionRefreshToken=null}_applyCsrfHealth(){if(!(typeof document>"u")){for(let n of document.cookie.split(";")){let t=n.indexOf("=");if(!(t<0)&&n.substring(0,t).trim()===this.csrfCookieName){this.csrfEnabled=!!n.substring(t+1).trim();return}}this.csrfEnabled=!1}}readRequestBody(n,t="application/json",e=!1){let s=v(this.hmacSecret,this.token||this.anonymousPacketToken);return ft(n,t,e,s)}get _reqOpts(){return{baseUrl:this.baseUrl,token:this.token,anonymousPacketToken:this.anonymousPacketToken,apiKey:this.apiKey,hmacSecret:this.hmacSecret,encryptRequests:this.encryptRequests,csrfEnabled:this.csrfEnabled,csrfHeaderName:this.csrfHeaderName,csrfCookieName:this.csrfCookieName,refreshCsrfCookie:this.csrfEnabled?this._csrfRefresher:null}}get http(){let n=this;return{get(t,e=!0,s){return g(n._reqOpts,"GET",t,void 0,e,s,!1)},post(t,e,s=!0,i){return g(n._reqOpts,"POST",t,e,s,i,!1)},put(t,e,s=!0,i){return g(n._reqOpts,"PUT",t,e,s,i,!1)},patch(t,e,s=!0,i){return g(n._reqOpts,"PATCH",t,e,s,i,!1)},delete(t,e,s=!0,i){return g(n._reqOpts,"DELETE",t,e,s,i,!1)}}}requestBinary(n,t,e,s=!0){return this._requestBinary(n,t,e,s)}requestForm(n,t,e,s=!0){return this._requestForm(n,t,e,s)}requestFormBinary(n,t,e,s=!0){return this._requestFormBinary(n,t,e,s)}_request(n,t,e,s=!0,i){return g(this._reqOpts,n,t,e,s,i,!0)}async _requestBinary(n,t,e,s=!0){let i={"Content-Type":"application/json"};s&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+t,{method:n,headers:i,...e!=null?{body:JSON.stringify(e)}:{},credentials:"include"});if(!o.ok){let a=await o.text(),u=new Error(`HTTP ${o.status}: ${a}`);throw u.status=o.status,u}return o.arrayBuffer()}async _requestForm(n,t,e,s=!0){let i={};s&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+t,{method:n,headers:i,body:e,credentials:"include"}),a=await o.json();if(!a.ok){let u=new Error(a.message??`EntityServer error (HTTP ${o.status})`);throw u.status=o.status,u}return a}async _requestFormBinary(n,t,e,s=!0){let i={};s&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+t,{method:n,headers:i,body:e,credentials:"include"});if(!o.ok){let a=await o.text(),u=new Error(`HTTP ${o.status}: ${a}`);throw u.status=o.status,u}return o.arrayBuffer()}};function U(r){return class extends r{_csrfRefresher=()=>this.checkHealth().then(()=>{});async checkHealth(){let e=await(await fetch(`${this.baseUrl}/v1/health`,{signal:AbortSignal.timeout(3e3),credentials:"include"})).json(),s=this._readCookie("anon_token");return s&&(this.anonymousPacketToken=s,this.encryptRequests=!0),this._applyCsrfHealth(),e}_readCookie(t){if(typeof document>"u")return null;let e=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith(`${t}=`));if(!e)return null;try{return decodeURIComponent(e.slice(t.length+1))}catch{return e.slice(t.length+1)}}async login(t,e){let s=await this._request("POST","/v1/auth/login",{email:t,passwd:e},!1);return this.token=s.data.access_token,this.keepSession&&this._scheduleKeepSession(s.data.refresh_token,s.data.expires_in,i=>this.refreshToken(i)),s.data}async refreshToken(t){let e=await this._request("POST","/v1/auth/refresh",{refresh_token:t},!1);return this.token=e.data.access_token,this.keepSession&&this._scheduleKeepSession(t,e.data.expires_in,s=>this.refreshToken(s)),e.data}async logout(t){this.stopKeepSession();let e=await this._request("POST","/v1/auth/logout",{refresh_token:t},!1);return this.token="",e}me(){return this._request("GET","/v1/auth/me")}withdraw(t){return this._request("POST","/v1/auth/withdraw",t?{passwd:t}:{})}}}function I(r){return class extends r{async transStart(){let t=await this._request("POST","/v1/transaction/start",void 0,!1);return this.activeTxId=t.transaction_id,this.activeTxId}transRollback(t){let e=t??this.activeTxId;return e?(this.activeTxId=null,this._request("POST",`/v1/transaction/rollback/${e}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}transCommit(t){let e=t??this.activeTxId;return e?(this.activeTxId=null,this._request("POST",`/v1/transaction/commit/${e}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}meta(t){return this._request("POST",`/v1/entity/${t}/meta`,{})}validate(t,e){return this.http.post(`/v1/entity/${t}/validate`,e)}get(t,e,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this._request("GET",`/v1/entity/${t}/${e}${i}`)}find(t,e,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this._request("POST",`/v1/entity/${t}/find${i}`,e??{})}list(t,e={}){let{conditions:s,fields:i,orderDir:o,orderBy:a,...u}=e,d={page:1,limit:20,...u};return a&&(d.orderBy=o==="DESC"?`-${a}`:a),i?.length&&(d.fields=i.join(",")),this._request("POST",`/v1/entity/${t}/list?${c(d)}`,s??{})}count(t,e){return this._request("POST",`/v1/entity/${t}/count`,e??{})}query(t,e){return this._request("POST",`/v1/entity/${t}/query`,e)}submit(t,e,s={}){let i=s.transactionId??this.activeTxId,o=i?{"X-Transaction-ID":i}:void 0,a=s.skipHooks?"?skipHooks=true":"";return this._request("POST",`/v1/entity/${t}/submit${a}`,e,!0,o)}delete(t,e,s={}){let i=new URLSearchParams;s.hard&&i.set("hard","true"),s.skipHooks&&i.set("skipHooks","true");let o=i.size?`?${i}`:"",a=s.transactionId??this.activeTxId,u=a?{"X-Transaction-ID":a}:void 0;return this._request("POST",`/v1/entity/${t}/delete/${e}${o}`,void 0,!0,u)}history(t,e,s={}){return this._request("GET",`/v1/entity/${t}/history/${e}?${c({page:1,limit:50,...s})}`)}rollback(t,e){return this._request("POST",`/v1/entity/${t}/rollback/${e}`)}}}function G(r){return class extends r{async fileUpload(t,e,s={}){let i=new FormData;return i.append("file",e,e instanceof File?e.name:"upload"),s.refSeq!=null&&i.append("ref_seq",String(s.refSeq)),s.isPublic!=null&&i.append("is_public",s.isPublic?"true":"false"),this._requestForm("POST",`/v1/files/${t}/upload`,i)}fileDownload(t,e){return this._requestBinary("POST",`/v1/files/${t}/download/${e}`,{})}fileDelete(t,e){return this._request("POST",`/v1/files/${t}/delete/${e}`,{})}fileList(t,e={}){return this._request("POST",`/v1/files/${t}/list`,e.refSeq?{ref_seq:e.refSeq}:{})}fileMeta(t,e){return this._request("POST",`/v1/files/${t}/meta/${e}`,{})}fileToken(t){return this._request("POST",`/v1/files/token/${t}`,{})}fileViewUrl(t,e={}){let s=e.download?"?download=true":"";return`${this.baseUrl}/v1/files/${t}${s}`}fileUrl(t){return`${this.baseUrl}/v1/files/${t}`}}}function H(r){return class extends r{push(t,e,s={}){return this.submit(t,e,s)}pushLogList(t={}){return this.list("push_log",t)}registerPushDevice(t,e,s,i={}){let{platform:o,deviceType:a,browser:u,browserVersion:d,pushEnabled:h=!0,transactionId:p}=i;return this.submit("account_device",{id:e,account_seq:t,push_token:s,push_enabled:h,...o?{platform:o}:{},...a?{device_type:a}:{},...u?{browser:u}:{},...d?{browser_version:d}:{}},{transactionId:p})}updatePushDeviceToken(t,e,s={}){let{pushEnabled:i=!0,transactionId:o}=s;return this.submit("account_device",{seq:t,push_token:e,push_enabled:i},{transactionId:o})}disablePushDevice(t,e={}){return this.submit("account_device",{seq:t,push_enabled:!1},{transactionId:e.transactionId})}}}function F(r){return class extends r{smtpSend(t){return this._request("POST","/v1/smtp/send",t)}smtpStatus(t){return this._request("POST",`/v1/smtp/status/${t}`,{})}smtpTemplatePreview(t){let e=t.split("/").map(encodeURIComponent).join("/");return fetch(`${this.baseUrl}/v1/smtp/template/${e}`,{credentials:"include"}).then(s=>s.text())}}}function L(r){return class extends r{transactionStart(t){return this._request("POST","/v1/transaction/start",t??{})}transactionCommit(t){return this._request("POST",`/v1/transaction/commit/${encodeURIComponent(t)}`,{})}transactionRollback(t){return this._request("POST",`/v1/transaction/rollback/${encodeURIComponent(t)}`,{})}}}function j(r){return class extends r{addressSido(){return this.http.get("/v1/utils/address/sido",!1)}addressSigungu(t){let e=new URLSearchParams({sido:t.sido}).toString();return this.http.get(`/v1/utils/address/sigungu?${e}`,!1)}addressDong(t){let e=new URLSearchParams({sido:t.sido,sigungu:t.sigungu}).toString();return this.http.get(`/v1/utils/address/dong?${e}`,!1)}addressClean(t){let e=new URLSearchParams({q:t.q}).toString();return this.http.get(`/v1/utils/address/clean?${e}`,!1)}qrcode(t,e={}){return this._requestBinary("POST","/v1/utils/qrcode",{content:t,...e})}qrcodeBase64(t,e={}){return this._request("POST","/v1/utils/qrcode/base64",{content:t,...e})}qrcodeText(t,e={}){return this._request("POST","/v1/utils/qrcode/text",{content:t,...e})}barcode(t,e={}){return this._requestBinary("POST","/v1/utils/barcode",{content:t,...e})}pdf2png(t,e={}){let s=new FormData;s.append("file",new Blob([t],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;e.dpi!=null&&i.set("dpi",String(e.dpi)),e.firstPage!=null&&i.set("first_page",String(e.firstPage)),e.lastPage!=null&&i.set("last_page",String(e.lastPage));let o=i.toString(),a="/v1/utils/pdf2png"+(o?`?${o}`:"");return this._requestFormBinary("POST",a,s)}pdf2pngByFileSeq(t,e={}){return this.requestBinary("POST",`/v1/utils/pdf2png/${t}`,e)}pdf2jpg(t,e={}){let s=new FormData;s.append("file",new Blob([t],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;e.dpi!=null&&i.set("dpi",String(e.dpi)),e.firstPage!=null&&i.set("first_page",String(e.firstPage)),e.lastPage!=null&&i.set("last_page",String(e.lastPage));let o=i.toString(),a="/v1/utils/pdf2jpg"+(o?`?${o}`:"");return this._requestFormBinary("POST",a,s)}pdf2jpgByFileSeq(t,e={}){return this.requestBinary("POST",`/v1/utils/pdf2jpg/${t}`,e)}}}function K(r){return class extends r{_adminPath(t){return`/v1/admin${t}`}_adminGet(t){return this.http.get(this._adminPath(t))}_adminPost(t,e){return this.http.post(this._adminPath(t),e)}_adminPut(t,e){return this.http.put(this._adminPath(t),e)}_adminPatch(t,e){return this.http.patch(this._adminPath(t),e)}_adminDelete(t,e){return this.http.delete(this._adminPath(t),e)}listAdminEntities(){return this._adminGet("/entities")}getAdminErdSchema(){return this._adminGet("/erd/schema")}batchEnsureAdminEntities(t){return this._adminPost("/entities/batch-ensure",t)}createAdminEntityConfig(t,e){return this._adminPost(`/${t}/create`,e)}getAdminEntityConfig(t){return this._adminGet(`/${t}/config`)}updateAdminEntityConfig(t,e){return this._adminPut(`/${t}/config`,e)}validateAdminEntityConfig(t,e){return this._adminPost(e?`/${e}/validate`:"/entity/validate",t)}normalizeAdminEntityConfig(t,e){return this._adminPost(e?`/${e}/normalize`:"/entity/normalize",t)}getAdminEntityStats(t,e){return this._adminPost(`/${t}/stats`,e)}reindexAdminEntity(t){return this._adminPost(`/${t}/reindex`)}syncAdminEntitySchema(t){return this._adminPost(`/${t}/sync-schema`)}resetAdminEntity(t){return this._adminPost(`/${t}/reset`)}truncateAdminEntity(t){return this._adminPost(`/${t}/truncate`)}dropAdminEntity(t){return this._adminPost(`/${t}/drop`)}resetAllAdmin(t){return this._adminPost("/reset-all",t)}listAdminConfigs(){return this._adminGet("/configs")}getAdminConfig(t){return this._adminGet(`/configs/${t}`)}updateAdminConfig(t,e){return this._adminPatch(`/configs/${t}`,e)}listAdminRoles(){return this._adminGet("/roles")}createAdminRole(t){return this._adminPost("/roles",t)}getAdminRole(t){return this._adminGet(`/roles/${t}`)}updateAdminRole(t,e){return this._adminPatch(`/roles/${t}`,e)}deleteAdminRole(t){return this._adminDelete(`/roles/${t}`)}listAdminApiKeys(){return this._adminGet("/api-keys")}createAdminApiKey(t){return this._adminPost("/api-keys",t)}getAdminApiKey(t){return this._adminGet(`/api-keys/${t}`)}updateAdminApiKey(t,e){return this._adminPatch(`/api-keys/${t}`,e)}deleteAdminApiKey(t){return this._adminDelete(`/api-keys/${t}`)}regenerateAdminApiKeySecret(t){return this._adminPost(`/api-keys/${t}/regenerate-secret`)}listAdminAccounts(){return this._adminGet("/accounts")}createAdminAccount(t){return this._adminPost("/accounts",t)}getAdminAccount(t){return this._adminGet(`/accounts/${t}`)}updateAdminAccount(t,e){return this._adminPatch(`/accounts/${t}`,e)}deleteAdminAccount(t){return this._adminDelete(`/accounts/${t}`)}listAdminLicenses(){return this._adminGet("/licenses")}createAdminLicense(t){return this._adminPost("/licenses",t)}getAdminLicense(t){return this._adminGet(`/licenses/${t}`)}updateAdminLicense(t,e){return this._adminPatch(`/licenses/${t}`,e)}deleteAdminLicense(t){return this._adminDelete(`/licenses/${t}`)}runAdminBackup(t){return this._adminPost("/backup/run",t)}getAdminBackupStatus(t){return this._adminPost("/backup/status",t)}listAdminBackups(t){return this._adminPost("/backup/list",t)}restoreAdminBackup(t){return this._adminPost("/backup/restore",t)}deleteAdminBackup(t){return this._adminPost("/backup/delete",t)}disableAdminAccountTwoFactor(t){return this._adminDelete(`/accounts/${t}/2fa`)}}}var P=class extends j(L(G(F(H(K(I(U(B)))))))){};function D(r){return class extends r{accountRegister(t){return this.http.post("/v1/account/register",t,!1)}accountWithdraw(t){return this.http.post("/v1/account/withdraw",t)}accountChangePassword(t){return this.http.post("/v1/account/change-password",t)}accountReactivate(t){return this.http.post("/v1/account/reactivate",t,!1)}listAccountBiometrics(){return this.http.get("/v1/account/biometric")}registerAccountBiometric(t){return this.http.post("/v1/account/biometric",t)}deleteAccountBiometric(t){return this.http.delete(`/v1/account/biometric/${t}`)}}}function N(r){return class extends r{listBoardCategories(t={}){let e=c(t);return this.http.get(`/v1/board/categories${e?`?${e}`:""}`,!1)}getBoardCategory(t){return this.http.get(`/v1/board/categories/${t}`,!1)}createBoardCategory(t){return this.http.post("/v1/board/categories",t)}updateBoardCategory(t,e){return this.http.put(`/v1/board/categories/${t}`,e)}deleteBoardCategory(t){return this.http.delete(`/v1/board/categories/${t}`)}listBoardPosts(t,e={}){let s=c(e);return this.http.get(`/v1/board/${t}/list${s?`?${s}`:""}`,!1)}getBoardPost(t){return this.http.get(`/v1/board/posts/${t}`,!1)}createBoardPost(t,e){return this.http.post(`/v1/board/${t}/submit`,e)}updateBoardPost(t,e){return this.http.put(`/v1/board/posts/${t}`,e)}deleteBoardPost(t){return this.http.delete(`/v1/board/posts/${t}`)}listBoardComments(t,e={}){let s=c(e);return this.http.get(`/v1/board/posts/${t}/comments${s?`?${s}`:""}`,!1)}createBoardComment(t,e){return this.http.post(`/v1/board/posts/${t}/comments/submit`,e)}updateBoardComment(t,e){return this.http.put(`/v1/board/comments/${t}`,e)}deleteBoardComment(t){return this.http.delete(`/v1/board/comments/${t}`)}listBoardFiles(t){return this.http.get(`/v1/board/posts/${t}/files`,!1)}async uploadBoardFile(t,e){let s=new FormData;return s.append("file",e,e instanceof File?e.name:"upload"),this.requestForm("POST",`/v1/board/posts/${t}/files`,s)}boardFileUrl(t){return`${this.baseUrl}/v1/board/files/${t}`}deleteBoardFile(t){return this.http.delete(`/v1/board/files/${t}`)}createBoardGuestPost(t,e){return this.http.post(`/v1/board/${t}/guest-submit`,e,!1)}authenticateBoardGuestPost(t,e){return this.http.post(`/v1/board/posts/${t}/guest-auth`,e,!1)}toggleBoardPostLike(t){return this.http.post(`/v1/board/posts/${t}/like`,{})}acceptBoardPost(t){return this.http.post(`/v1/board/posts/${t}/accept`,{})}rateBoardPost(t,e){return this.http.post(`/v1/board/posts/${t}/rating`,e)}rateBoardComment(t,e){return this.http.post(`/v1/board/comments/${t}/rating`,e)}listBoardTags(t={}){let e=c(t);return this.http.get(`/v1/board/tags${e?`?${e}`:""}`,!1)}setBoardPostTags(t,e){return this.http.put(`/v1/board/posts/${t}/tags`,e)}reportBoardPost(t,e){return this.http.post(`/v1/board/posts/${t}/report`,e)}reportBoardComment(t,e){return this.http.post(`/v1/board/comments/${t}/report`,e)}listBoardReports(t={}){let e=c(t);return this.http.get(`/v1/board/admin/reports${e?`?${e}`:""}`)}updateBoardReport(t,e){return this.http.patch(`/v1/board/admin/reports/${t}`,e)}markBoardPostRead(t){return this.http.post(`/v1/board/posts/${t}/read`,{})}listBoardMentions(t={}){let e=c(t);return this.http.get(`/v1/board/mentions${e?`?${e}`:""}`)}markBoardMentionRead(t){return this.http.patch(`/v1/board/mentions/${t}/read`,{})}}}function V(r){return class extends r{sendEmailVerification(t){return this.http.post("/v1/email-verify/send",t,!1)}confirmEmailVerification(t){return this.http.post("/v1/email-verify/confirm",t,!1)}activateEmailVerification(t){let e=c(t);return this.http.get(`/v1/email-verify/activate${e?`?${e}`:""}`,!1)}getEmailVerificationStatus(){return this.http.get("/v1/email-verify/status")}changeVerifiedEmail(t){return this.http.post("/v1/email-verify/change",t)}}}function Q(r){return class extends r{oauthAuthorizeUrl(t,e={}){let s=c(e);return`${this.baseUrl}/v1/oauth/${t}${s?`?${s}`:""}`}oauthCallback(t,e,s="POST"){if(s==="GET"){let i=c(e??{});return this.http.get(`/v1/oauth/${t}/callback${i?`?${i}`:""}`,!1)}return this.http.post(`/v1/oauth/${t}/callback`,e,!1)}linkOAuthAccount(t){return this.http.post("/v1/account/oauth/link",t)}unlinkOAuthAccount(t){return this.http.delete(`/v1/account/oauth/link/${t}`)}listOAuthProviders(){return this.http.get("/v1/account/oauth/providers")}refreshOAuthProviderToken(t,e){return this.http.post(`/v1/account/oauth/refresh/${t}`,e)}}}function z(r){return class extends r{requestPasswordReset(t){return this.http.post("/v1/password-reset/request",t,!1)}validatePasswordResetToken(t){return this.http.get(`/v1/password-reset/validate/${encodeURIComponent(t)}`,!1)}verifyPasswordReset(t){return this.http.post("/v1/password-reset/verify",t,!1)}}}function X(r){return class extends r{setupTwoFactor(t){return this.http.post("/v1/account/2fa/setup",t)}verifyTwoFactorSetup(t){return this.http.post("/v1/account/2fa/setup/verify",t,!1)}disableTwoFactor(){return this.http.delete("/v1/account/2fa")}getTwoFactorStatus(){return this.http.get("/v1/account/2fa/status")}regenerateTwoFactorRecoveryCodes(){return this.http.post("/v1/account/2fa/recovery/regenerate")}verifyTwoFactor(t){return this.http.post("/v1/account/2fa/verify",t,!1)}recoverTwoFactorAccess(t){return this.http.post("/v1/account/2fa/recovery",t,!1)}}}function W(r){return class extends r{alimtalkSend(t){return this.http.post("/v1/alimtalk/send",t)}alimtalkStatus(t){return this.http.get(`/v1/alimtalk/status/${t}`,!1)}listAlimtalkTemplates(){return this.http.get("/v1/alimtalk/templates",!1)}alimtalkWebhook(t,e){return this.http.post(`/v1/alimtalk/webhook/${encodeURIComponent(t)}`,e,!1)}}}function J(r){return class extends r{friendtalkSend(t){return this.http.post("/v1/friendtalk/send",t)}}}function Y(r){return class extends r{listHolidays(t={}){let e=c(t);return this.http.get(`/v1/holidays${e?`?${e}`:""}`,!1)}getHolidayByDate(t){return this.http.get(`/v1/holidays/${encodeURIComponent(t)}`,!1)}syncHolidays(t){return this.http.post("/v1/holidays/sync",t)}}}function Z(r){return class extends r{identityRequest(t){return this.http.post("/v1/identity/request",t,!1)}identityCallback(t){return this.http.post("/v1/identity/callback",t,!1)}identityResult(t){return this.http.get(`/v1/identity/result/${encodeURIComponent(t)}`,!1)}identityVerifyCI(t){return this.http.post("/v1/identity/verify-ci",t)}}}function tt(r){return class extends r{llmChat(t){return this.http.post("/v1/llm/chat",t)}llmChatStream(t){return this.http.post("/v1/llm/chat/stream",t)}createLlmConversation(t){return this.http.post("/v1/llm/conversations",t)}sendLlmMessage(t,e){return this.http.post(`/v1/llm/conversations/${t}/messages`,e)}listLlmConversations(t={}){let e=c(t);return this.http.get(`/v1/llm/conversations${e?`?${e}`:""}`)}getLlmConversation(t){return this.http.get(`/v1/llm/conversations/${t}`)}updateLlmConversation(t,e){return this.http.patch(`/v1/llm/conversations/${t}`,e)}deleteLlmConversation(t){return this.http.delete(`/v1/llm/conversations/${t}`)}ragUploadDocument(t){return this.requestForm("POST","/v1/llm/rag/documents",t)}ragListDocuments(t={}){let e=c(t);return this.http.get(`/v1/llm/rag/documents${e?`?${e}`:""}`)}ragDeleteDocument(t){return this.http.delete(`/v1/llm/rag/documents/${encodeURIComponent(t)}`)}ragSearch(t){return this.http.post("/v1/llm/rag/search",t)}ragChat(t){return this.http.post("/v1/llm/rag/chat",t)}ragChatStream(t){return this.http.post("/v1/llm/rag/chat/stream",t)}ragRebuildIndex(t){return this.http.post("/v1/llm/rag/rebuild-index",t)}listLlmProviders(){return this.http.get("/v1/llm/providers")}getLlmUsage(t={}){let e=c(t);return this.http.get(`/v1/llm/usage${e?`?${e}`:""}`)}getLlmUsageSummary(t={}){let e=c(t);return this.http.get(`/v1/llm/usage/summary${e?`?${e}`:""}`)}getLlmCacheStats(){return this.http.get("/v1/llm/cache/stats")}clearLlmCache(){return this.http.delete("/v1/llm/cache")}listLlmTemplates(){return this.http.get("/v1/llm/templates")}llmTemplateChat(t,e){return this.http.post(`/v1/llm/${encodeURIComponent(t)}/chat`,e)}llmTemplateChatStream(t,e){return this.http.post(`/v1/llm/${encodeURIComponent(t)}/chat/stream`,e)}listLlmChatbots(t={}){let e=c(t);return this.http.get(`/v1/llm/chatbots${e?`?${e}`:""}`)}createLlmChatbot(t){return this.http.post("/v1/llm/chatbots",t)}getLlmChatbot(t){return this.http.get(`/v1/llm/chatbots/${t}`)}updateLlmChatbot(t,e){return this.http.patch(`/v1/llm/chatbots/${t}`,e)}deleteLlmChatbot(t){return this.http.delete(`/v1/llm/chatbots/${t}`)}llmChatbotChat(t,e){return this.http.post(`/v1/llm/chatbots/${t}/chat`,e)}llmChatbotChatStream(t,e){return this.http.post(`/v1/llm/chatbots/${t}/chat/stream`,e)}listLlmChatbotSessions(t,e={}){let s=c(e);return this.http.get(`/v1/llm/chatbots/${t}/sessions${s?`?${s}`:""}`)}deleteLlmChatbotSession(t,e){return this.http.delete(`/v1/llm/chatbots/${t}/sessions/${e}`)}listLlmProfiles(t={}){let e=c(t);return this.http.get(`/v1/llm/profiles${e?`?${e}`:""}`)}upsertLlmProfile(t){return this.http.post("/v1/llm/profiles",t)}deleteLlmProfile(t){return this.http.delete(`/v1/llm/profiles/${t}`)}}}function et(r){return class extends r{ocrRecognize(t){return this.requestForm("POST","/v1/ocr/recognize",t)}ocrRecognizeAsync(t){return this.requestForm("POST","/v1/ocr/recognize/async",t)}ocrRecognizeByDocType(t,e){return this.requestForm("POST",`/v1/ocr/${encodeURIComponent(t)}`,e)}listOcrResults(t={}){let e=c(t);return this.http.get(`/v1/ocr/results${e?`?${e}`:""}`)}getOcrResult(t){return this.http.get(`/v1/ocr/results/${encodeURIComponent(t)}`)}getOcrResultText(t){return this.http.get(`/v1/ocr/results/${encodeURIComponent(t)}/text`)}deleteOcrResult(t){return this.http.delete(`/v1/ocr/results/${encodeURIComponent(t)}`)}getOcrQuota(){return this.http.get("/v1/ocr/quota")}}}function nt(r){return class extends r{pgCreateOrder(t){return this.http.post("/v1/pg/orders",t)}pgGetOrder(t){return this.http.get(`/v1/pg/orders/${encodeURIComponent(t)}`)}pgConfirmPayment(t){return this.http.post("/v1/pg/confirm",t)}pgCancelPayment(t,e){return this.http.post(`/v1/pg/orders/${encodeURIComponent(t)}/cancel`,e)}pgSyncPaymentStatus(t,e){return this.http.post(`/v1/pg/orders/${encodeURIComponent(t)}/sync`,e)}pgWebhook(t){return this.http.post("/v1/pg/webhook",t,!1)}pgGetClientConfig(){return this.http.get("/v1/pg/config",!1)}}}function rt(r){return class extends r{appPushSend(t){return this.http.post("/v1/push/send",t)}appPushBroadcast(t){return this.http.post("/v1/push/broadcast",t)}appPushStatus(t){return this.http.get(`/v1/push/status/${t}`)}appPushRegisterDevice(t){return this.http.post("/v1/push/device",t)}appPushUnregisterDevice(t){return this.http.delete(`/v1/push/device/${t}`)}}}function st(r){return class extends r{smsSend(t){return this.http.post("/v1/sms/send",t)}smsStatus(t){return this.http.get(`/v1/sms/status/${t}`,!1)}smsVerificationSend(t){return this.http.post("/v1/sms/verification/send",t,!1)}smsVerificationVerify(t){return this.http.post("/v1/sms/verification/verify",t,!1)}}}function it(r){return class extends r{taxinvoiceRegistIssue(t){return this.http.post("/v1/taxinvoice",t)}taxinvoiceRegister(t){return this.http.post("/v1/taxinvoice/register",t)}taxinvoiceIssue(t){return this.http.post(`/v1/taxinvoice/${t}/issue`,{})}taxinvoiceCancelIssue(t,e){return this.http.post(`/v1/taxinvoice/${t}/cancel`,e)}taxinvoiceGetState(t){return this.http.get(`/v1/taxinvoice/${t}/state`)}taxinvoiceGetDetail(t){return this.http.get(`/v1/taxinvoice/${t}`)}}}var $=class extends W(J(st(rt(nt(it(et(tt(Z(Y(Q(X(z(V(N(D(P)))))))))))))))){};var Un=new P,In=new $;export{D as AccountAppMixin,K as AdminMixin,U as AuthMixin,N as BoardMixin,V as EmailVerifyMixin,$ as EntityAppServerApi,I as EntityMixin,P as EntityServerApi,G as FileMixin,Q as OAuthMixin,_t as PACKET_HKDF_SALT,Bt as PACKET_INFO_LABEL,q as PACKET_KEY_SIZE,M as PACKET_MAGIC_MIN,O as PACKET_MAGIC_RANGE,k as PACKET_NONCE_SIZE,St as PACKET_TAG_SIZE,z as PasswordResetMixin,H as PushMixin,F as SmtpMixin,L as TransactionMixin,X as TwoFactorMixin,j as UtilsMixin,pt as decryptPacket,lt as derivePacketKey,ht as encryptPacket,In as entityAppServer,Un as entityServer,dt as packetMagicLenFromKey};
2
2
  //# sourceMappingURL=index.js.map