entity-client 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +362 -362
- package/dist/EntityAppServerApi.d.ts +96 -96
- package/dist/EntityAppServerApi.js.map +1 -1
- package/dist/EntityServerApi.d.ts +81 -48
- package/dist/EntityServerApi.js.map +1 -1
- package/dist/client/base.d.ts +7 -7
- package/dist/client/base.js +1 -1
- package/dist/client/base.js.map +3 -3
- package/dist/client/hmac.js.map +1 -1
- package/dist/client/packet.js.map +1 -1
- package/dist/client/request.d.ts +1 -0
- package/dist/client/request.js +1 -1
- package/dist/client/request.js.map +3 -3
- package/dist/client/utils.js.map +1 -1
- package/dist/hooks/useEntityAppServer.js.map +1 -1
- package/dist/hooks/useEntityClient.js.map +1 -1
- package/dist/hooks/useEntityServer.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/mixins/app/index.js.map +1 -1
- package/dist/mixins/app/plugins/alimtalk.d.ts +6 -6
- package/dist/mixins/app/plugins/alimtalk.js.map +1 -1
- package/dist/mixins/app/plugins/friendtalk.d.ts +6 -6
- package/dist/mixins/app/plugins/friendtalk.js.map +1 -1
- package/dist/mixins/app/plugins/holidays.d.ts +6 -6
- package/dist/mixins/app/plugins/holidays.js.map +1 -1
- package/dist/mixins/app/plugins/identity.d.ts +6 -6
- package/dist/mixins/app/plugins/identity.js.map +1 -1
- package/dist/mixins/app/plugins/index.js.map +1 -1
- package/dist/mixins/app/plugins/llm.d.ts +6 -6
- package/dist/mixins/app/plugins/llm.js.map +1 -1
- package/dist/mixins/app/plugins/ocr.d.ts +6 -6
- package/dist/mixins/app/plugins/ocr.js.map +1 -1
- package/dist/mixins/app/plugins/pg.d.ts +6 -6
- package/dist/mixins/app/plugins/pg.js.map +1 -1
- package/dist/mixins/app/plugins/push.d.ts +6 -6
- package/dist/mixins/app/plugins/push.js.map +1 -1
- package/dist/mixins/app/plugins/sms.d.ts +6 -6
- package/dist/mixins/app/plugins/sms.js.map +1 -1
- package/dist/mixins/app/plugins/taxinvoice.d.ts +6 -6
- package/dist/mixins/app/plugins/taxinvoice.js.map +1 -1
- package/dist/mixins/app/routes/account.d.ts +6 -6
- package/dist/mixins/app/routes/account.js.map +1 -1
- package/dist/mixins/app/routes/board.d.ts +6 -6
- package/dist/mixins/app/routes/board.js.map +1 -1
- package/dist/mixins/app/routes/email-verify.d.ts +6 -6
- package/dist/mixins/app/routes/email-verify.js.map +1 -1
- package/dist/mixins/app/routes/oauth.d.ts +6 -6
- package/dist/mixins/app/routes/oauth.js.map +1 -1
- package/dist/mixins/app/routes/password-reset.d.ts +6 -6
- package/dist/mixins/app/routes/password-reset.js.map +1 -1
- package/dist/mixins/app/routes/two-factor.d.ts +6 -6
- package/dist/mixins/app/routes/two-factor.js.map +1 -1
- package/dist/mixins/server/admin.d.ts +6 -6
- package/dist/mixins/server/admin.js.map +1 -1
- package/dist/mixins/server/auth.d.ts +6 -6
- package/dist/mixins/server/auth.js.map +1 -1
- package/dist/mixins/server/entity.d.ts +6 -6
- package/dist/mixins/server/entity.js.map +1 -1
- package/dist/mixins/server/file.d.ts +49 -7
- package/dist/mixins/server/file.js +1 -1
- package/dist/mixins/server/file.js.map +2 -2
- package/dist/mixins/server/index.js.map +1 -1
- package/dist/mixins/server/push.d.ts +6 -6
- package/dist/mixins/server/push.js.map +1 -1
- package/dist/mixins/server/smtp.d.ts +6 -6
- package/dist/mixins/server/smtp.js.map +1 -1
- package/dist/mixins/server/transaction.d.ts +6 -6
- package/dist/mixins/server/transaction.js.map +1 -1
- package/dist/mixins/server/utils.d.ts +6 -6
- package/dist/mixins/server/utils.js.map +1 -1
- package/dist/packet.js.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +3 -3
- package/dist/types.d.ts +5 -0
- package/package.json +57 -57
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/useEntityClient.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n type EntityQueryRequest,\n type EntityServerClientOptions,\n} from \"../index.js\";\n\nexport interface UseEntityServerOptions extends EntityServerClientOptions {\n singleton?: boolean;\n tokenResolver?: () => string | undefined | null;\n /**\n * \uD398\uC774\uC9C0 \uC0C8\uB85C\uACE0\uCE68 \uD6C4 \uB85C\uADF8\uC778 \uC0C1\uD0DC\uB97C \uBCF5\uC6D0\uD560 \uB54C \uC0AC\uC6A9\uD569\uB2C8\uB2E4.\n * \uAC12 \uC790\uCCB4\uB294 \uB354 \uC774\uC0C1 \uC0AC\uC6A9\uD558\uC9C0 \uC54A\uACE0, \uAC12\uC774 \uC788\uC73C\uBA74 \uB9C8\uC6B4\uD2B8 \uC2DC `client.checkHealth(true)`\uB85C\n * refresh \uCFE0\uD0A4 \uAE30\uBC18 \uC138\uC158 \uBD80\uD2B8\uC2A4\uD2B8\uB7A9\uC744 \uC2DC\uB3C4\uD569\uB2C8\uB2E4.\n */\n resumeSession?: string;\n}\n\n/** useEntityClient\uAC00 \uC694\uAD6C\uD558\uB294 \uCD5C\uC18C \uD074\uB77C\uC774\uC5B8\uD2B8 \uC778\uD130\uD398\uC774\uC2A4 */\nexport interface EntityClientShape {\n configure(options: Partial<EntityServerClientOptions>): void;\n setToken(token: string): void;\n checkHealth?: (bootstrapAuth?: boolean) => Promise<unknown>;\n refreshToken(refreshToken?: string): Promise<unknown>;\n submit(\n entity: string,\n data: Record<string, unknown>,\n opts?: { transactionId?: string; skipHooks?: boolean },\n ): Promise<{ ok: boolean; seq: number }>;\n delete(\n entity: string,\n seq: number,\n opts?: { transactionId?: string; hard?: boolean; skipHooks?: boolean },\n ): Promise<{ ok: boolean; deleted: number }>;\n query<T = unknown>(\n entity: string,\n req: EntityQueryRequest,\n ): Promise<{ ok: boolean; data: { items: T[]; count: number } }>;\n}\n\ntype ClientConstructor<TClient extends EntityClientShape> = new (\n options?: EntityServerClientOptions,\n) => TClient;\n\nexport interface UseEntityClientResult<TClient extends EntityClientShape> {\n client: TClient;\n isPending: boolean;\n error: Error | null;\n reset: () => void;\n submit: (\n entity: string,\n data: Record<string, unknown>,\n opts?: { transactionId?: string; skipHooks?: boolean },\n ) => Promise<{ ok: boolean; seq: number }>;\n del: (\n entity: string,\n seq: number,\n opts?: { transactionId?: string; hard?: boolean; skipHooks?: boolean },\n ) => Promise<{ ok: boolean; deleted: number }>;\n query: <T = unknown>(\n entity: string,\n req: EntityQueryRequest,\n ) => Promise<{ ok: boolean; data: { items: T[]; count: number } }>;\n}\n\nexport function useEntityClient<TClient extends EntityClientShape>(\n options: UseEntityServerOptions,\n config: {\n singletonInstance: TClient;\n ClientClass: ClientConstructor<TClient>;\n },\n): UseEntityClientResult<TClient> {\n const {\n singleton = true,\n tokenResolver,\n baseUrl,\n token,\n resumeSession,\n } = options;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n const client = useMemo(() => {\n const instance = singleton\n ? config.singletonInstance\n : new config.ClientClass({ baseUrl, token });\n\n if (singleton) {\n instance.configure({ baseUrl, token });\n }\n\n const resolvedToken = tokenResolver?.();\n if (typeof resolvedToken === \"string\") {\n instance.setToken(resolvedToken);\n }\n\n return instance;\n }, [\n singleton,\n tokenResolver,\n baseUrl,\n token,\n config.ClientClass,\n config.singletonInstance,\n ]);\n\n const resumeTokenRef = useRef(resumeSession);\n useEffect(() => {\n if (!resumeTokenRef.current) return;\n if (client.checkHealth) {\n client.checkHealth(true).catch(() => {\n // refresh cookie \uB9CC\uB8CC \uB4F1 \u2014 onSessionExpired \uCF5C\uBC31\uC5D0\uC11C \uCC98\uB9AC \uAC00\uB2A5\n });\n return;\n }\n\n client.refreshToken(resumeTokenRef.current).catch(() => {\n // \uD558\uC704 \uD638\uD658 fallback\n });\n }, [client]);\n\n const run = useCallback(async <T>(fn: () => Promise<T>): Promise<T> => {\n if (mountedRef.current) {\n setIsPending(true);\n setError(null);\n }\n try {\n const result = await fn();\n return result;\n } catch (err) {\n const wrapped = err instanceof Error ? err : new Error(String(err));\n if (mountedRef.current) setError(wrapped);\n throw wrapped;\n } finally {\n if (mountedRef.current) setIsPending(false);\n }\n }, []);\n\n const submit = useCallback<UseEntityClientResult<TClient>[\"submit\"]>(\n (entity, data, opts) => run(() => client.submit(entity, data, opts)),\n [client, run],\n );\n\n const del = useCallback<UseEntityClientResult<TClient>[\"del\"]>(\n (entity, seq, opts) => run(() => client.delete(entity, seq, opts)),\n [client, run],\n );\n\n const query = useCallback<UseEntityClientResult<TClient>[\"query\"]>(\n (entity, req) => run(() => client.query(entity, req)),\n [client, run],\n );\n\n const reset = useCallback(() => {\n setIsPending(false);\n setError(null);\n }, []);\n\n return { client, isPending, error, reset, submit, del, query };\n}\n"],
|
|
5
5
|
"mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,WAAAC,EAAS,UAAAC,EAAQ,YAAAC,MAAgB,QAgE3D,SAASC,EACZC,EACAC,EAI8B,CAC9B,KAAM,CACF,UAAAC,EAAY,GACZ,cAAAC,EACA,QAAAC,EACA,MAAAC,EACA,cAAAC,CACJ,EAAIN,EAEE,CAACO,EAAWC,CAAY,EAAIV,EAAS,EAAK,EAC1C,CAACW,EAAOC,CAAQ,EAAIZ,EAAuB,IAAI,EAE/Ca,EAAad,EAAO,EAAI,EAC9BF,EAAU,KACNgB,EAAW,QAAU,GACd,IAAM,CACTA,EAAW,QAAU,EACzB,GACD,CAAC,CAAC,EAEL,MAAMC,EAAShB,EAAQ,IAAM,CACzB,MAAMiB,EAAWX,EACXD,EAAO,kBACP,IAAIA,EAAO,YAAY,CAAE,QAAAG,EAAS,MAAAC,CAAM,CAAC,EAE3CH,GACAW,EAAS,UAAU,CAAE,QAAAT,EAAS,MAAAC,CAAM,CAAC,EAGzC,MAAMS,EAAgBX,IAAgB,EACtC,OAAI,OAAOW,GAAkB,UACzBD,EAAS,SAASC,CAAa,EAG5BD,CACX,EAAG,CACCX,EACAC,EACAC,EACAC,EACAJ,EAAO,YACPA,EAAO,iBACX,CAAC,EAEKc,EAAiBlB,EAAOS,CAAa,EAC3CX,EAAU,IAAM,CACZ,GAAKoB,EAAe,QACpB,IAAIH,EAAO,YAAa,CACpBA,EAAO,YAAY,EAAI,EAAE,MAAM,IAAM,CAErC,CAAC,EACD,MACJ,CAEAA,EAAO,aAAaG,EAAe,OAAO,EAAE,MAAM,IAAM,CAExD,CAAC,EACL,EAAG,CAACH,CAAM,CAAC,EAEX,MAAMI,EAAMtB,EAAY,MAAUuB,GAAqC,CAC/DN,EAAW,UACXH,EAAa,EAAI,EACjBE,EAAS,IAAI,GAEjB,GAAI,CAEA,OADe,MAAMO,EAAG,CAE5B,OAASC,EAAK,CACV,MAAMC,EAAUD,aAAe,MAAQA,EAAM,IAAI,MAAM,OAAOA,CAAG,CAAC,EAClE,MAAIP,EAAW,SAASD,EAASS,CAAO,EAClCA,CACV,QAAE,CACMR,EAAW,SAASH,EAAa,EAAK,CAC9C,CACJ,EAAG,CAAC,CAAC,EAECY,EAAS1B,EACX,CAAC2B,EAAQC,EAAMC,IAASP,EAAI,IAAMJ,EAAO,OAAOS,EAAQC,EAAMC,CAAI,CAAC,EACnE,CAACX,EAAQI,CAAG,CAChB,EAEMQ,EAAM9B,EACR,CAAC2B,EAAQI,EAAKF,IAASP,EAAI,IAAMJ,EAAO,OAAOS,EAAQI,EAAKF,CAAI,CAAC,EACjE,CAACX,EAAQI,CAAG,CAChB,EAEMU,EAAQhC,EACV,CAAC2B,EAAQM,IAAQX,EAAI,IAAMJ,EAAO,MAAMS,EAAQM,CAAG,CAAC,EACpD,CAACf,EAAQI,CAAG,CAChB,EAEMY,EAAQlC,EAAY,IAAM,CAC5Bc,EAAa,EAAK,EAClBE,EAAS,IAAI,CACjB,EAAG,CAAC,CAAC,EAEL,MAAO,CAAE,OAAAE,EAAQ,UAAAL,EAAW,MAAAE,EAAO,MAAAmB,EAAO,OAAAR,EAAQ,IAAAI,EAAK,MAAAE,CAAM,CACjE",
|
|
6
6
|
"names": ["useCallback", "useEffect", "useMemo", "useRef", "useState", "useEntityClient", "options", "config", "singleton", "tokenResolver", "baseUrl", "token", "resumeSession", "isPending", "setIsPending", "error", "setError", "mountedRef", "client", "instance", "resolvedToken", "resumeTokenRef", "run", "fn", "err", "wrapped", "submit", "entity", "data", "opts", "del", "seq", "query", "req", "reset"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/useEntityServer.ts"],
|
|
4
|
-
"sourcesContent": ["import { EntityServerApi, entityServer } from \"../index.js\";\
|
|
4
|
+
"sourcesContent": ["import { EntityServerApi, entityServer } from \"../index.js\";\nimport {\n useEntityClient,\n type UseEntityClientResult,\n type UseEntityServerOptions,\n} from \"./useEntityClient.js\";\n\nexport type { UseEntityServerOptions };\n\nexport interface UseEntityServerResult extends UseEntityClientResult<EntityServerApi> {}\n\n/**\n * React \uD658\uACBD\uC5D0\uC11C EntityServerApi \uC778\uC2A4\uD134\uC2A4\uC640 mutation \uC0C1\uD0DC\uB97C \uBC18\uD658\uD569\uB2C8\uB2E4.\n *\n * - `singleton=true`(\uAE30\uBCF8): \uD328\uD0A4\uC9C0 \uC804\uC5ED `entityServer` \uC778\uC2A4\uD134\uC2A4\uB97C \uC0AC\uC6A9\uD569\uB2C8\uB2E4.\n * - `singleton=false`: \uCEF4\uD3EC\uB10C\uD2B8 \uC2A4\uCF54\uD504\uC758 \uC0C8 \uC778\uC2A4\uD134\uC2A4\uB97C \uC0DD\uC131\uD569\uB2C8\uB2E4.\n *\n * @example\n * ```tsx\n * const { submit, del, isPending, error, reset } = useEntityServer();\n *\n * const handleSave = async () => {\n * await submit(\"account\", { name: \"\uD64D\uAE38\uB3D9\" });\n * };\n * ```\n */\nexport function useEntityServer(\n options: UseEntityServerOptions = {},\n): UseEntityServerResult {\n return useEntityClient(options, {\n singletonInstance: entityServer,\n ClientClass: EntityServerApi,\n });\n}\n"],
|
|
5
5
|
"mappings": "AAAA,OAAS,mBAAAA,EAAiB,gBAAAC,MAAoB,cAC9C,OACI,mBAAAC,MAGG,uBAqBA,SAASC,EACZC,EAAkC,CAAC,EACd,CACrB,OAAOF,EAAgBE,EAAS,CAC5B,kBAAmBH,EACnB,YAAaD,CACjB,CAAC,CACL",
|
|
6
6
|
"names": ["EntityServerApi", "entityServer", "useEntityClient", "useEntityServer", "options"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function I(r){let n=import.meta;if(n?.env?.[r]!=null)return n.env[r];let e=globalThis.process;if(e?.env?.[r]!=null)return e.env[r]}function c(r){return Object.entries(r).filter(([,n])=>n!=null).map(([n,e])=>`${encodeURIComponent(n==="orderBy"?"order_by":n)}=${encodeURIComponent(String(e))}`).join("&")}import{xchacha20poly1305 as ge}from"@noble/ciphers/chacha";import{sha256 as Oe}from"@noble/hashes/sha2";import{hkdf as Le}from"@noble/hashes/hkdf";var G=32,H=2,F=14,y=24,_e=16,Ue="entity-server:hkdf:v1",Ie="entity-server:packet-encryption";function R(r){return r instanceof Uint8Array?r:new Uint8Array(r)}function ye(r,n=Ie){return Le(Oe,new TextEncoder().encode(r),new TextEncoder().encode(Ue),new TextEncoder().encode(n),G)}function Pe(r,n=H,e=F){let t=R(r);return t.length<G?n:n+t[G-1]%e}function we(r,n,e=H,t=F){let s=R(r),i=R(n),o=Pe(i,e,t),a=crypto.getRandomValues(new Uint8Array(o)),u=crypto.getRandomValues(new Uint8Array(y)),k=ge(i,u).encrypt(s),p=new Uint8Array(o+y+k.length);return p.set(a,0),p.set(u,o),p.set(k,o+y),p}function be(r,n,e=H,t=F){let s=R(r),i=R(n),o=Pe(i,e,t);if(s.length<o+y+_e)throw new Error("Encrypted packet too short");let a=s.slice(o,o+y),u=s.slice(o+y);return ge(i,a).decrypt(u)}function S(r,n){return ye(r||n)}function ve(r,n){return we(r,n)}function $(r,n){let e=be(r,n);return JSON.parse(new TextDecoder().decode(e))}function Re(r,n,e,t){let s=n.toLowerCase().includes("application/octet-stream");if(e&&!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 $(r,t);if(r instanceof Uint8Array){let i=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return $(i,t)}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 Ge}from"@noble/hashes/sha2";import{hmac as He}from"@noble/hashes/hmac";function Se(r,n,e,t,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+e.length);u.set(a,0),u.set(e,a.length);let k=[...He(Ge,new TextEncoder().encode(s),u)].map(p=>p.toString(16).padStart(2,"0")).join("");return{"X-API-Key":t,"X-Timestamp":i,"X-Nonce":o,"X-Signature":k}}function Fe(r){return r.hmacSecret||r.token||r.anonymousPacketToken}function je(r,n,e){return r.hmacSecret?r.hmacSecret:n&&r.token||e}function De(r){return r?r.length<=8?`${r.slice(0,2)}...${r.slice(-2)}`:`${r.slice(0,4)}...${r.slice(-4)}`:""}function Ke(r){typeof console>"u"||typeof console.error!="function"||console.error("[entity-client] packet decrypt failed",{method:r.method,path:r.path,withAuth:r.withAuth,status:r.status,contentType:r.contentType,responsePacketSource:De(r.responsePacketSource),tokenPresent:r.tokenPresent,anonymousPacketTokenPresent:r.anonymousPacketTokenPresent,hmacEnabled:r.hmacEnabled,error:r.error instanceof Error?{name:r.error.name,message:r.error.message,stack:r.error.stack}:r.error})}function Ne(r){return r!=="GET"&&r!=="HEAD"&&r!=="OPTIONS"}function q(r){if(typeof document>"u")return"";for(let n of document.cookie.split(";")){let e=n.indexOf("=");if(!(e<0)&&n.substring(0,e).trim()===r)return decodeURIComponent(n.substring(e+1).trim())}return""}function Ve(r,n){return r===403&&/csrf/i.test(n)?!0:/csrf/i.test(n)&&/expired|token validation failed/i.test(n)}async function xe(r){if((r.headers.get("Content-Type")??"").includes("application/json")){let t=await r.json().catch(()=>null);if(t?.error)return t.error;if(t?.message)return t.message}return await r.text().catch(()=>"")||`HTTP ${r.status}`}async function T(r,n,e,t,s=!0,i={},o=!0){let a=typeof o=="boolean"?{requireOkShape:o}:o,u=a.requireOkShape??!0,m=new Set(a.allowStatuses??[]),{baseUrl:k,token:p,apiKey:de,hmacSecret:w,encryptRequests:Ee,csrfEnabled:Be,csrfHeaderName:Ae,csrfCookieName:L,refreshCsrfCookie:x,onAccessToken:pe}=r,b=r.anonymousPacketToken||q("anon_token"),C=s&&!!(de&&w),$e=Fe(r),fe=je(r,s,b),E=Be&&Ne(n)&&!C,v=E?q(L):"",Te="application/json",qe=!C&&!!b,f=null;if(t!=null)if(Ee&&!!$e&&s&&n!=="GET"&&n!=="HEAD"){let d=S(w,p||b);f=ve(new TextEncoder().encode(JSON.stringify(t)),d),Te="application/octet-stream"}else f=JSON.stringify(t);let Me=h=>{let d={...i},A=Object.keys(d).some(g=>g.toLowerCase()==="content-type");if(f!=null&&!A&&(d["Content-Type"]=Te),!C&&s&&p&&(d.Authorization=`Bearer ${p}`),qe&&(d["X-Packet-Token"]=b),E&&h&&(d[Ae]=h),C){let g=f instanceof Uint8Array?f:typeof f=="string"?new TextEncoder().encode(f):new Uint8Array(0);Object.assign(d,Se(n,e,g,de,w))}return d};E&&!v&&x&&(await x(),v=q(L));let ke=h=>fetch(k+e,{method:n,headers:Me(h),...f!=null?{body:f}:{},credentials:"include"}),l=await ke(v);if(!l.ok){let h=await xe(l.clone());if(E&&x&&Ve(l.status,h))await x(),v=q(L),l=await ke(v);else if(!m.has(l.status)){let d=new Error(h);throw d.status=l.status,d}}if(!l.ok&&!m.has(l.status)){let h=new Error(await xe(l));throw h.status=l.status,h}let B=l.headers.get("X-Access-Token")?.trim()??"",_=l.headers.get("Content-Type")??"";if(_.includes("application/octet-stream")){let h=S(w,fe),d=await l.arrayBuffer(),A;try{A=$(d,h)}catch(g){throw Ke({method:n,path:e,withAuth:s,status:l.status,contentType:_,responsePacketSource:fe,tokenPresent:!!p,anonymousPacketTokenPresent:!!b,hmacEnabled:!!w,error:g}),g}return B&&pe?.(B),A}if(B&&pe?.(B),!_.includes("application/json"))return await l.text();let U=await l.json();if(u&&!U.ok&&!m.has(l.status)){let h=new Error(U.message??`EntityServer error (HTTP ${l.status})`);throw h.status=l.status,h}return U}var j="/v1/realtime",M=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;realtimeEnabled;realtimePath;realtimeAutoConnect;realtimeAutoReconnect;realtimeReconnectDelayMs;realtimeStatus;realtimeSocket=null;realtimeConnectPromise=null;realtimeReconnectTimer=null;realtimeShouldReconnect=!1;realtimeMessageListeners=new Set;realtimeStatusListeners=new Set;realtimeEventListeners=new Map;constructor(n={}){let e=I("VITE_ENTITY_SERVER_URL");this.baseUrl=(n.baseUrl??e??"").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,this.realtimeEnabled=!1,this.realtimePath=j,this.realtimeAutoConnect=!0,this.realtimeAutoReconnect=!0,this.realtimeReconnectDelayMs=3e3,this.realtimeStatus="idle",this.applyRealtimeOptions(n.realtime),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.realtime<"u"&&this.applyRealtimeOptions(n.realtime),typeof n.healthTickInterval=="number"&&n.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(n.healthTickInterval))}setToken(n){if(this.token=n,!n){this.disconnectRealtime("token_cleared");return}this.realtimeEnabled&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})}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}addRealtimeListener(n){this.realtimeMessageListeners.add(n)}removeRealtimeListener(n){this.realtimeMessageListeners.delete(n)}addRealtimeStatusListener(n){this.realtimeStatusListeners.add(n)}removeRealtimeStatusListener(n){this.realtimeStatusListeners.delete(n)}addRealtimeEventListener(n,e){let t=String(n).trim();t&&(this.realtimeEventListeners.has(t)||this.realtimeEventListeners.set(t,new Set),this.realtimeEventListeners.get(t).add(e))}removeRealtimeEventListener(n,e){let t=String(n).trim();if(!t)return;let s=this.realtimeEventListeners.get(t);s&&(s.delete(e),s.size===0&&this.realtimeEventListeners.delete(t))}async connectRealtime(){if(!this.realtimeEnabled){this.setRealtimeStatus("disabled","realtime_disabled");return}if(!this.token)throw new Error("Cannot open realtime connection without access token.");if(typeof WebSocket>"u")throw new Error("WebSocket is not available in this environment.");if(this.realtimeSocket&&this.realtimeSocket.readyState===WebSocket.OPEN)return;if(this.realtimeSocket&&this.realtimeSocket.readyState===WebSocket.CONNECTING&&this.realtimeConnectPromise)return this.realtimeConnectPromise;this.clearRealtimeReconnectTimer(),this.realtimeShouldReconnect=this.realtimeAutoReconnect,this.setRealtimeStatus("connecting","connect_requested");let n=new WebSocket(this.buildRealtimeUrl());return this.realtimeSocket=n,this.realtimeConnectPromise=new Promise((e,t)=>{let s=!1,i=()=>{s||(s=!0,this.realtimeConnectPromise=null,e())},o=a=>{s||(s=!0,this.realtimeConnectPromise=null,t(a))};n.addEventListener("open",()=>{this.setRealtimeStatus("open","socket_open"),i()}),n.addEventListener("message",a=>{this.handleRealtimeMessage(a.data)}),n.addEventListener("error",()=>{this.setRealtimeStatus("closed","socket_error",new Error("Realtime socket error."))}),n.addEventListener("close",a=>{this.realtimeSocket===n&&(this.realtimeSocket=null);let u=a.reason||"socket_closed",m=new Error(`Realtime socket closed (${a.code}${a.reason?`: ${a.reason}`:""}).`);this.setRealtimeStatus("closed",u,m),s||o(m),this.realtimeShouldReconnect&&this.realtimeEnabled&&this.realtimeAutoReconnect&&this.token&&this.scheduleRealtimeReconnect(u)})}),this.realtimeConnectPromise}disconnectRealtime(n="client_disconnect"){if(this.realtimeShouldReconnect=!1,this.clearRealtimeReconnectTimer(),this.realtimeSocket){let e=this.realtimeSocket;this.realtimeSocket=null;try{(e.readyState===WebSocket.OPEN||e.readyState===WebSocket.CONNECTING)&&e.close(1e3,n)}catch{}}this.realtimeConnectPromise=null,this.setRealtimeStatus(this.realtimeEnabled?"idle":"disabled",n)}sendRealtime(n){return!this.realtimeSocket||this.realtimeSocket.readyState!==WebSocket.OPEN?!1:(this.realtimeSocket.send(JSON.stringify(n)),!0)}subscribeRealtime(n){return this.sendRealtime({type:"subscribe",channel:"session",event:"session.subscribe",data:{subscriptions:n}})}unsubscribeRealtime(n){return this.sendRealtime({type:"unsubscribe",channel:"session",event:"session.unsubscribe",data:{subscriptions:n}})}startHealthTick(n=300*1e3){this.stopHealthTick();let e=()=>{this.healthTickPromise||(this.healthTickPromise=(this.csrfRefresher?this.csrfRefresher():Promise.resolve()).then(()=>{this.onHealthChange?.(!0)}).catch(()=>{this.onHealthChange?.(!1)}).finally(()=>{this.healthTickPromise=null}))};e(),this.healthTickTimer=setInterval(e,n)}stopHealthTick(){this.healthTickTimer!==null&&(clearInterval(this.healthTickTimer),this.healthTickTimer=null),this.healthTickPromise=null}scheduleKeepSession(n,e,t){this.clearRefreshTimer(),this.sessionRefreshToken=n;let s=Math.max((e-this.refreshBuffer)*1e3,0);this.refreshTimer=setTimeout(async()=>{if(this.sessionRefreshToken)try{let i=await t(this.sessionRefreshToken);this.onTokenRefreshed?.(i.access_token,i.expires_in),this.scheduleKeepSession(this.sessionRefreshToken,i.expires_in,t)}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}applyRealtimeOptions(n){let e=typeof n=="boolean"?{enabled:n}:n??{};if(this.realtimeEnabled=e.enabled??!1,this.realtimePath=String(e.path??j).trim()||j,this.realtimeAutoConnect=e.autoConnect??!0,this.realtimeAutoReconnect=e.autoReconnect??!0,this.realtimeReconnectDelayMs=Math.max(250,e.reconnectDelayMs??3e3),!this.realtimeEnabled){this.disconnectRealtime("realtime_disabled");return}this.setRealtimeStatus("idle","realtime_enabled"),this.token&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})}buildRealtimeUrl(){let e=this.baseUrl||I("VITE_ENTITY_SERVER_URL")||""||(typeof window<"u"?window.location.origin:"");if(!e)throw new Error("Realtime connection requires baseUrl.");let t=new URL(this.realtimePath,e);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.searchParams.set("access_token",this.token),t.toString()}handleRealtimeMessage(n){if(typeof n!="string")return;let e;try{e=JSON.parse(n)}catch{return}for(let s of this.realtimeMessageListeners)s(e);let t=this.realtimeEventListeners.get(e.event);if(t)for(let s of t)s(e)}scheduleRealtimeReconnect(n){this.clearRealtimeReconnectTimer(),this.realtimeReconnectTimer=setTimeout(()=>{this.realtimeReconnectTimer=null,!(!this.realtimeEnabled||!this.token)&&(this.setRealtimeStatus("connecting",`${n}:reconnect`),this.connectRealtime().catch(()=>{}))},this.realtimeReconnectDelayMs)}clearRealtimeReconnectTimer(){this.realtimeReconnectTimer!==null&&(clearTimeout(this.realtimeReconnectTimer),this.realtimeReconnectTimer=null)}setRealtimeStatus(n,e,t){let s=this.realtimeStatus;if(!(s===n&&typeof e>"u"&&typeof t>"u")){this.realtimeStatus=n;for(let i of this.realtimeStatusListeners)i({status:n,previousStatus:s,...e?{reason:e}:{},...t?{error:t}:{}})}}applyCsrfHealth(){if(!(typeof document>"u")){for(let n of document.cookie.split(";")){let e=n.indexOf("=");if(!(e<0)&&n.substring(0,e).trim()===this.csrfCookieName){this.csrfEnabled=!!n.substring(e+1).trim();return}}this.csrfEnabled=!1}}readRequestBody(n,e="application/json",t=!1){let s=S(this.hmacSecret,this.token||this.anonymousPacketToken);return Re(n,e,t,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,onAccessToken:n=>{this.token=n}}}prepareRequest(n){return Promise.resolve()}get http(){let n=this;return{get(e,t=!0,s){return n.prepareRequest(t).then(()=>T(n.reqOpts,"GET",e,void 0,t,s,!0))},post(e,t,s=!0,i){return n.prepareRequest(s).then(()=>T(n.reqOpts,"POST",e,t,s,i,!0))},put(e,t,s=!0,i){return n.prepareRequest(s).then(()=>T(n.reqOpts,"PUT",e,t,s,i,!0))},patch(e,t,s=!0,i){return n.prepareRequest(s).then(()=>T(n.reqOpts,"PATCH",e,t,s,i,!0))},delete(e,t,s=!0,i){return n.prepareRequest(s).then(()=>T(n.reqOpts,"DELETE",e,t,s,i,!0))}}}request(n,e,t,s=!0,i){return this.prepareRequest(s).then(()=>T(this.reqOpts,n,e,t,s,i,!0))}async requestBinary(n,e,t,s=!0){await this.prepareRequest(s);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+e,{method:n,headers:i,...t!=null?{body:JSON.stringify(t)}:{},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,e,t,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+e,{method:n,headers:i,body:t,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,e,t,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+e,{method:n,headers:i,body:t,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 Ce(r){return r.ok===!0&&r.requires_2fa!==!0&&typeof r.data=="object"&&r.data!==null&&"access_token"in r.data}function D(r){return class extends r{authBootstrapPromise=null;authBootstrapToken="";authBootstrapAnonymousCompleted=!1;csrfRefresher=()=>this.checkHealth(this.keepSession).then(()=>{});async checkHealth(e=!1){try{let t=this.token,s={};e&&(s["X-Session-Bootstrap"]="1");let i=await fetch(`${this.baseUrl}/v1/health`,{signal:AbortSignal.timeout(3e3),credentials:"include",headers:s}),o=await i.json(),a=i.headers.get("X-Access-Token");a&&(this.token=a,e&&a!==t&&this.onTokenRefreshed?.(a,0),e&&o.authenticated===!0&&this.realtimeEnabled&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{}));let u=this.readCookie("anon_token");return o.packet_encryption===!0&&u&&(this.anonymousPacketToken=u,this.encryptRequests=!0),this.applyCsrfHealth(),this.onHealthChange?.(!0),e&&o.authenticated===!1&&t&&(this.disconnectRealtime("session_expired"),this.onSessionExpired?.(new Error("Session expired"))),o}catch(t){throw this.onHealthChange?.(!1),t}}readCookie(e){if(typeof document>"u")return null;let t=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith(`${e}=`));if(!t)return null;try{return decodeURIComponent(t.slice(e.length+1))}catch{return t.slice(e.length+1)}}async ensurePublicAuthBootstrap(){if(typeof document>"u"||this.apiKey&&this.hmacSecret)return;let e=!!this.anonymousPacketToken||!!this.readCookie("anon_token"),t=!!this.readCookie(this.csrfCookieName);e&&t&&this.csrfEnabled||await this.checkHealth(!1)}async ensureAuthenticatedRequestBootstrap(){if(!(typeof document>"u")&&!(this.apiKey&&this.hmacSecret)){if(this.token){if(this.authBootstrapToken===this.token)return}else if(this.authBootstrapAnonymousCompleted)return;return this.authBootstrapPromise?this.authBootstrapPromise:(this.authBootstrapPromise=this.checkHealth(!0).then(()=>{this.token?this.authBootstrapToken=this.token:this.authBootstrapAnonymousCompleted=!0}).finally(()=>{this.authBootstrapPromise=null}),this.authBootstrapPromise)}}async prepareRequest(e){await super.prepareRequest(e),e&&await this.ensureAuthenticatedRequestBootstrap()}async login(e,t){await this.ensurePublicAuthBootstrap();let s=await T(this.reqOpts,"POST","/v1/auth/login",{email:e,passwd:t},!1,{},{requireOkShape:!1,allowStatuses:[403]});return Ce(s)&&(this.token=s.data.access_token,this.applyCsrfHealth(),this.keepSession&&this.healthTickTimer===null&&this.startHealthTick(),this.realtimeEnabled&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})),s}async tokenRefresh(){let e=await this.request("POST","/v1/auth/token_refresh",void 0,!1);return this.token=e.data.access_token,this.applyCsrfHealth(),e.data}async refreshToken(e){if(!e)return this.tokenRefresh();let t=await this.request("POST","/v1/auth/refresh",{refresh_token:e},!1);return this.token=t.data.access_token,this.applyCsrfHealth(),t.data}async logout(e){this.stopKeepSession(),this.stopHealthTick(),this.disconnectRealtime("logout");let t=await this.request("POST","/v1/auth/logout",e?{refresh_token:e}:void 0,!1);return this.token="",this.applyCsrfHealth(),t}me(){return this.request("GET","/v1/auth/me")}withdraw(e){return this.request("POST","/v1/auth/withdraw",e?{passwd:e}:{})}}}function K(r){return class extends r{async transStart(){let e=await this.request("POST","/v1/transaction/start",void 0,!1);return this.activeTxId=e.transaction_id,this.activeTxId}transRollback(e){let t=e??this.activeTxId;return t?(this.activeTxId=null,this.request("POST",`/v1/transaction/rollback/${t}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}transCommit(e){let t=e??this.activeTxId;return t?(this.activeTxId=null,this.request("POST",`/v1/transaction/commit/${t}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}meta(e){return this.request("POST",`/v1/entity/${e}/meta`,{})}validate(e,t){return this.http.post(`/v1/entity/${e}/validate`,t)}get(e,t,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this.request("GET",`/v1/entity/${e}/${t}${i}`)}find(e,t,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this.request("POST",`/v1/entity/${e}/find${i}`,t??{})}list(e,t={}){let{conditions:s,fields:i,orderDir:o,orderBy:a,...u}=t,m={page:1,limit:20,...u};return a&&(m.orderBy=o==="DESC"?`-${a}`:a),i?.length&&(m.fields=i.join(",")),this.request("POST",`/v1/entity/${e}/list?${c(m)}`,s??{})}count(e,t){return this.request("POST",`/v1/entity/${e}/count`,t??{})}query(e,t){return this.request("POST",`/v1/entity/${e}/query`,t)}submit(e,t,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/${e}/submit${a}`,t,!0,o)}delete(e,t,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/${e}/delete/${t}${o}`,void 0,!0,u)}history(e,t,s={}){return this.request("GET",`/v1/entity/${e}/history/${t}?${c({page:1,limit:50,...s})}`)}rollback(e,t){return this.request("POST",`/v1/entity/${e}/rollback/${t}`)}}}function N(r){return class extends r{async fileUpload(e,t,s={}){let i=new FormData;return i.append("file",t,t instanceof File?t.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/${e}/upload`,i)}fileDownload(e,t){return this.requestBinary("POST",`/v1/files/${e}/download/${t}`,{})}fileDelete(e,t){return this.request("POST",`/v1/files/${e}/delete/${t}`,{})}fileList(e,t={}){return this.request("POST",`/v1/files/${e}/list`,t.refSeq?{ref_seq:t.refSeq}:{})}fileMeta(e,t){return this.request("POST",`/v1/files/${e}/meta/${t}`,{})}fileToken(e){return this.request("POST",`/v1/files/token/${e}`,{})}fileViewUrl(e,t={}){let s=t.download?"?download=true":"";return`${this.baseUrl}/v1/files/${e}${s}`}fileUrl(e){return`${this.baseUrl}/v1/files/${e}`}}}function V(r){return class extends r{push(e,t,s={}){return this.submit(e,t,s)}pushLogList(e={}){return this.list("push_log",e)}registerPushDevice(e,t,s,i={}){let{platform:o,deviceType:a,browser:u,browserVersion:m,pushEnabled:k=!0,transactionId:p}=i;return this.submit("account_device",{id:t,account_seq:e,push_token:s,push_enabled:k,...o?{platform:o}:{},...a?{device_type:a}:{},...u?{browser:u}:{},...m?{browser_version:m}:{}},{transactionId:p})}updatePushDeviceToken(e,t,s={}){let{pushEnabled:i=!0,transactionId:o}=s;return this.submit("account_device",{seq:e,push_token:t,push_enabled:i},{transactionId:o})}disablePushDevice(e,t={}){return this.submit("account_device",{seq:e,push_enabled:!1},{transactionId:t.transactionId})}}}function z(r){return class extends r{smtpSend(e){return this.request("POST","/v1/smtp/send",e)}smtpStatus(e){return this.request("POST",`/v1/smtp/status/${e}`,{})}smtpTemplatePreview(e){let t=e.split("/").map(encodeURIComponent).join("/");return fetch(`${this.baseUrl}/v1/smtp/template/${t}`,{credentials:"include"}).then(s=>s.text())}}}function Q(r){return class extends r{transactionStart(e){return this.request("POST","/v1/transaction/start",e??{})}transactionCommit(e){return this.request("POST",`/v1/transaction/commit/${encodeURIComponent(e)}`,{})}transactionRollback(e){return this.request("POST",`/v1/transaction/rollback/${encodeURIComponent(e)}`,{})}}}function W(r){return class extends r{addressSido(){return this.http.get("/v1/utils/address/sido",!1)}addressSigungu(e){let t=new URLSearchParams({sido:e.sido}).toString();return this.http.get(`/v1/utils/address/sigungu?${t}`,!1)}addressDong(e){let t=new URLSearchParams({sido:e.sido,sigungu:e.sigungu}).toString();return this.http.get(`/v1/utils/address/dong?${t}`,!1)}addressClean(e){let t=new URLSearchParams({q:e.q}).toString();return this.http.get(`/v1/utils/address/clean?${t}`,!1)}qrcode(e,t={}){return this.requestBinary("POST","/v1/utils/qrcode",{content:e,...t})}qrcodeBase64(e,t={}){return this.request("POST","/v1/utils/qrcode/base64",{content:e,...t})}qrcodeText(e,t={}){return this.request("POST","/v1/utils/qrcode/text",{content:e,...t})}barcode(e,t={}){return this.requestBinary("POST","/v1/utils/barcode",{content:e,...t})}pdf2png(e,t={}){let s=new FormData;s.append("file",new Blob([e],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;t.dpi!=null&&i.set("dpi",String(t.dpi)),t.firstPage!=null&&i.set("first_page",String(t.firstPage)),t.lastPage!=null&&i.set("last_page",String(t.lastPage));let o=i.toString(),a="/v1/utils/pdf2png"+(o?`?${o}`:"");return this.requestFormBinary("POST",a,s)}pdf2pngByFileSeq(e,t={}){return this.requestBinary("POST",`/v1/utils/pdf2png/${e}`,t)}pdf2jpg(e,t={}){let s=new FormData;s.append("file",new Blob([e],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;t.dpi!=null&&i.set("dpi",String(t.dpi)),t.firstPage!=null&&i.set("first_page",String(t.firstPage)),t.lastPage!=null&&i.set("last_page",String(t.lastPage));let o=i.toString(),a="/v1/utils/pdf2jpg"+(o?`?${o}`:"");return this.requestFormBinary("POST",a,s)}pdf2jpgByFileSeq(e,t={}){return this.requestBinary("POST",`/v1/utils/pdf2jpg/${e}`,t)}}}function X(r){return class extends r{adminPath(e){return`/v1/admin${e}`}adminGet(e){return this.http.get(this.adminPath(e))}adminPost(e,t){return this.http.post(this.adminPath(e),t)}adminPut(e,t){return this.http.put(this.adminPath(e),t)}adminPatch(e,t){return this.http.patch(this.adminPath(e),t)}adminDelete(e,t){return this.http.delete(this.adminPath(e),t)}listAdminEntities(){return this.adminGet("/entities")}getAdminErdSchema(){return this.adminGet("/erd/schema")}batchEnsureAdminEntities(e){return this.adminPost("/entities/batch-ensure",e)}createAdminEntityConfig(e,t){return this.adminPost(`/${e}/create`,t)}getAdminEntityConfig(e){return this.adminGet(`/${e}/config`)}updateAdminEntityConfig(e,t){return this.adminPut(`/${e}/config`,t)}validateAdminEntityConfig(e,t){return this.adminPost(t?`/${t}/validate`:"/entity/validate",e)}normalizeAdminEntityConfig(e,t){return this.adminPost(t?`/${t}/normalize`:"/entity/normalize",e)}getAdminEntityStats(e,t){return this.adminPost(`/${e}/stats`,t)}reindexAdminEntity(e){return this.adminPost(`/${e}/reindex`)}syncAdminEntitySchema(e){return this.adminPost(`/${e}/sync-schema`)}resetAdminEntity(e){return this.adminPost(`/${e}/reset`)}truncateAdminEntity(e){return this.adminPost(`/${e}/truncate`)}dropAdminEntity(e){return this.adminPost(`/${e}/drop`)}resetAllAdmin(e){return this.adminPost("/reset-all",e)}listAdminConfigs(){return this.adminGet("/configs")}getAdminConfig(e){return this.adminGet(`/configs/${e}`)}updateAdminConfig(e,t){return this.adminPatch(`/configs/${e}`,t)}listAdminRoles(){return this.adminGet("/roles")}createAdminRole(e){return this.adminPost("/roles",e)}getAdminRole(e){return this.adminGet(`/roles/${e}`)}updateAdminRole(e,t){return this.adminPatch(`/roles/${e}`,t)}deleteAdminRole(e){return this.adminDelete(`/roles/${e}`)}listAdminApiKeys(){return this.adminGet("/api-keys")}createAdminApiKey(e){return this.adminPost("/api-keys",e)}getAdminApiKey(e){return this.adminGet(`/api-keys/${e}`)}updateAdminApiKey(e,t){return this.adminPatch(`/api-keys/${e}`,t)}deleteAdminApiKey(e){return this.adminDelete(`/api-keys/${e}`)}regenerateAdminApiKeySecret(e){return this.adminPost(`/api-keys/${e}/regenerate-secret`)}listAdminAccounts(){return this.adminGet("/accounts")}createAdminAccount(e){return this.adminPost("/accounts",e)}getAdminAccount(e){return this.adminGet(`/accounts/${e}`)}updateAdminAccount(e,t){return this.adminPatch(`/accounts/${e}`,t)}deleteAdminAccount(e){return this.adminDelete(`/accounts/${e}`)}listAdminLicenses(){return this.adminGet("/licenses")}createAdminLicense(e){return this.adminPost("/licenses",e)}getAdminLicense(e){return this.adminGet(`/licenses/${e}`)}updateAdminLicense(e,t){return this.adminPatch(`/licenses/${e}`,t)}deleteAdminLicense(e){return this.adminDelete(`/licenses/${e}`)}runAdminBackup(e){return this.adminPost("/backup/run",e)}getAdminBackupStatus(e){return this.adminPost("/backup/status",e)}listAdminBackups(e){return this.adminPost("/backup/list",e)}restoreAdminBackup(e){return this.adminPost("/backup/restore",e)}deleteAdminBackup(e){return this.adminPost("/backup/delete",e)}disableAdminAccountTwoFactor(e){return this.adminDelete(`/accounts/${e}/2fa`)}}}var P=class extends W(Q(N(z(V(X(K(D(M)))))))){};function J(r){return class extends r{accountRegister(e){return this.http.post("/v1/account/register",e,!1)}accountWithdraw(e){return this.http.post("/v1/account/withdraw",e)}accountChangePassword(e){return this.http.post("/v1/account/change-password",e)}accountReactivate(e){return this.http.post("/v1/account/reactivate",e,!1)}listAccountBiometrics(){return this.http.get("/v1/account/biometric")}registerAccountBiometric(e){return this.http.post("/v1/account/biometric",e)}deleteAccountBiometric(e){return this.http.delete(`/v1/account/biometric/${e}`)}}}function Y(r){return class extends r{listBoardCategories(e={}){let t=c(e);return this.http.get(`/v1/board/categories${t?`?${t}`:""}`,!1)}getBoardCategory(e){return this.http.get(`/v1/board/categories/${e}`,!1)}createBoardCategory(e){return this.http.post("/v1/board/categories",e)}updateBoardCategory(e,t){return this.http.put(`/v1/board/categories/${e}`,t)}deleteBoardCategory(e){return this.http.delete(`/v1/board/categories/${e}`)}listBoardPosts(e,t={}){let s=c(t);return this.http.get(`/v1/board/${e}/list${s?`?${s}`:""}`)}getBoardPost(e){return this.http.get(`/v1/board/posts/${e}`)}createBoardPost(e,t){return this.http.post(`/v1/board/${e}/submit`,t)}updateBoardPost(e,t){return this.http.put(`/v1/board/posts/${e}`,t)}deleteBoardPost(e){return this.http.delete(`/v1/board/posts/${e}`)}listBoardComments(e,t={}){let s=c(t);return this.http.get(`/v1/board/posts/${e}/comments${s?`?${s}`:""}`,!1)}createBoardComment(e,t){return this.http.post(`/v1/board/posts/${e}/comments/submit`,t)}updateBoardComment(e,t){return this.http.put(`/v1/board/comments/${e}`,t)}deleteBoardComment(e){return this.http.delete(`/v1/board/comments/${e}`)}listBoardFiles(e){return this.http.get(`/v1/board/posts/${e}/files`,!1)}async uploadBoardFile(e,t){let s=new FormData;return s.append("file",t,t instanceof File?t.name:"upload"),this.requestForm("POST",`/v1/board/posts/${e}/files`,s)}boardFileUrl(e){return`${this.baseUrl}/v1/board/files/${e}`}deleteBoardFile(e){return this.http.delete(`/v1/board/files/${e}`)}createBoardGuestPost(e,t){return this.http.post(`/v1/board/${e}/guest-submit`,t,!1)}authenticateBoardGuestPost(e,t){return this.http.post(`/v1/board/posts/${e}/guest-auth`,t,!1)}toggleBoardPostLike(e){return this.http.post(`/v1/board/posts/${e}/like`,{})}acceptBoardPost(e){return this.http.post(`/v1/board/posts/${e}/accept`,{})}rateBoardPost(e,t){return this.http.post(`/v1/board/posts/${e}/rating`,t)}rateBoardComment(e,t){return this.http.post(`/v1/board/comments/${e}/rating`,t)}listBoardTags(e={}){let t=c(e);return this.http.get(`/v1/board/tags${t?`?${t}`:""}`,!1)}setBoardPostTags(e,t){return this.http.put(`/v1/board/posts/${e}/tags`,t)}reportBoardPost(e,t){return this.http.post(`/v1/board/posts/${e}/report`,t)}reportBoardComment(e,t){return this.http.post(`/v1/board/comments/${e}/report`,t)}listBoardReports(e={}){let t=c(e);return this.http.get(`/v1/board/admin/reports${t?`?${t}`:""}`)}updateBoardReport(e,t){return this.http.patch(`/v1/board/admin/reports/${e}`,t)}markBoardPostRead(e){return this.http.post(`/v1/board/posts/${e}/read`,{})}listBoardMentions(e={}){let t=c(e);return this.http.get(`/v1/board/mentions${t?`?${t}`:""}`)}markBoardMentionRead(e){return this.http.patch(`/v1/board/mentions/${e}/read`,{})}}}function Z(r){return class extends r{sendEmailVerification(e){return this.http.post("/v1/email-verify/send",e,!1)}confirmEmailVerification(e){return this.http.post("/v1/email-verify/confirm",e,!1)}activateEmailVerification(e){let t=c(e);return this.http.get(`/v1/email-verify/activate${t?`?${t}`:""}`,!1)}getEmailVerificationStatus(){return this.http.get("/v1/email-verify/status")}changeVerifiedEmail(e){return this.http.post("/v1/email-verify/change",e)}}}function ee(r){return class extends r{oauthAuthorizeUrl(e,t={}){let s=c(t);return`${this.baseUrl}/v1/oauth/${e}${s?`?${s}`:""}`}oauthCallback(e,t,s="POST"){if(s==="GET"){let i=c(t??{});return this.http.get(`/v1/oauth/${e}/callback${i?`?${i}`:""}`,!1)}return this.http.post(`/v1/oauth/${e}/callback`,t,!1)}linkOAuthAccount(e){return this.http.post("/v1/account/oauth/link",e)}unlinkOAuthAccount(e){return this.http.delete(`/v1/account/oauth/link/${e}`)}listOAuthProviders(){return this.http.get("/v1/account/oauth/providers")}refreshOAuthProviderToken(e,t){return this.http.post(`/v1/account/oauth/refresh/${e}`,t)}}}function te(r){return class extends r{requestPasswordReset(e){return this.http.post("/v1/password-reset/request",e,!1)}validatePasswordResetToken(e){return this.http.get(`/v1/password-reset/validate/${encodeURIComponent(e)}`,!1)}verifyPasswordReset(e){return this.http.post("/v1/password-reset/verify",e,!1)}}}function ne(r){return class extends r{setupTwoFactor(e){return this.http.post("/v1/account/2fa/setup",e)}verifyTwoFactorSetup(e){return this.http.post("/v1/account/2fa/setup/verify",e,!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(e){return this.http.post("/v1/account/2fa/verify",e,!1)}recoverTwoFactorAccess(e){return this.http.post("/v1/account/2fa/recovery",e,!1)}}}function re(r){return class extends r{alimtalkSend(e){return this.http.post("/v1/alimtalk/send",e)}alimtalkStatus(e){return this.http.get(`/v1/alimtalk/status/${e}`,!1)}listAlimtalkTemplates(){return this.http.get("/v1/alimtalk/templates",!1)}alimtalkWebhook(e,t){return this.http.post(`/v1/alimtalk/webhook/${encodeURIComponent(e)}`,t,!1)}}}function se(r){return class extends r{friendtalkSend(e){return this.http.post("/v1/friendtalk/send",e)}}}function ie(r){return class extends r{listHolidays(e={}){let t=c(e);return this.http.get(`/v1/holidays${t?`?${t}`:""}`,!1)}getHolidayByDate(e){return this.http.get(`/v1/holidays/${encodeURIComponent(e)}`,!1)}syncHolidays(e){return this.http.post("/v1/holidays/sync",e)}}}function oe(r){return class extends r{identityRequest(e){return this.http.post("/v1/identity/request",e,!1)}identityCallback(e){return this.http.post("/v1/identity/callback",e,!1)}identityResult(e){return this.http.get(`/v1/identity/result/${encodeURIComponent(e)}`,!1)}identityVerifyCI(e){return this.http.post("/v1/identity/verify-ci",e)}}}function ae(r){return class extends r{llmChat(e){return this.http.post("/v1/llm/chat",e)}llmChatStream(e){return this.http.post("/v1/llm/chat/stream",e)}createLlmConversation(e){return this.http.post("/v1/llm/conversations",e)}sendLlmMessage(e,t){return this.http.post(`/v1/llm/conversations/${e}/messages`,t)}listLlmConversations(e={}){let t=c(e);return this.http.get(`/v1/llm/conversations${t?`?${t}`:""}`)}getLlmConversation(e){return this.http.get(`/v1/llm/conversations/${e}`)}updateLlmConversation(e,t){return this.http.patch(`/v1/llm/conversations/${e}`,t)}deleteLlmConversation(e){return this.http.delete(`/v1/llm/conversations/${e}`)}ragUploadDocument(e){return this.requestForm("POST","/v1/llm/rag/documents",e)}ragListDocuments(e={}){let t=c(e);return this.http.get(`/v1/llm/rag/documents${t?`?${t}`:""}`)}ragDeleteDocument(e){return this.http.delete(`/v1/llm/rag/documents/${encodeURIComponent(e)}`)}ragSearch(e){return this.http.post("/v1/llm/rag/search",e)}ragChat(e){return this.http.post("/v1/llm/rag/chat",e)}ragChatStream(e){return this.http.post("/v1/llm/rag/chat/stream",e)}ragRebuildIndex(e){return this.http.post("/v1/llm/rag/rebuild-index",e)}listLlmProviders(){return this.http.get("/v1/llm/providers")}getLlmUsage(e={}){let t=c(e);return this.http.get(`/v1/llm/usage${t?`?${t}`:""}`)}getLlmUsageSummary(e={}){let t=c(e);return this.http.get(`/v1/llm/usage/summary${t?`?${t}`:""}`)}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(e,t){return this.http.post(`/v1/llm/${encodeURIComponent(e)}/chat`,t)}llmTemplateChatStream(e,t){return this.http.post(`/v1/llm/${encodeURIComponent(e)}/chat/stream`,t)}listLlmChatbots(e={}){let t=c(e);return this.http.get(`/v1/llm/chatbots${t?`?${t}`:""}`)}createLlmChatbot(e){return this.http.post("/v1/llm/chatbots",e)}getLlmChatbot(e){return this.http.get(`/v1/llm/chatbots/${e}`)}updateLlmChatbot(e,t){return this.http.patch(`/v1/llm/chatbots/${e}`,t)}deleteLlmChatbot(e){return this.http.delete(`/v1/llm/chatbots/${e}`)}llmChatbotChat(e,t){return this.http.post(`/v1/llm/chatbots/${e}/chat`,t)}llmChatbotChatStream(e,t){return this.http.post(`/v1/llm/chatbots/${e}/chat/stream`,t)}listLlmChatbotSessions(e,t={}){let s=c(t);return this.http.get(`/v1/llm/chatbots/${e}/sessions${s?`?${s}`:""}`)}deleteLlmChatbotSession(e,t){return this.http.delete(`/v1/llm/chatbots/${e}/sessions/${t}`)}listLlmProfiles(e={}){let t=c(e);return this.http.get(`/v1/llm/profiles${t?`?${t}`:""}`)}upsertLlmProfile(e){return this.http.post("/v1/llm/profiles",e)}deleteLlmProfile(e){return this.http.delete(`/v1/llm/profiles/${e}`)}}}function ue(r){return class extends r{ocrRecognize(e){return this.requestForm("POST","/v1/ocr/recognize",e)}ocrRecognizeAsync(e){return this.requestForm("POST","/v1/ocr/recognize/async",e)}ocrRecognizeByDocType(e,t){return this.requestForm("POST",`/v1/ocr/${encodeURIComponent(e)}`,t)}listOcrResults(e={}){let t=c(e);return this.http.get(`/v1/ocr/results${t?`?${t}`:""}`)}getOcrResult(e){return this.http.get(`/v1/ocr/results/${encodeURIComponent(e)}`)}getOcrResultText(e){return this.http.get(`/v1/ocr/results/${encodeURIComponent(e)}/text`)}deleteOcrResult(e){return this.http.delete(`/v1/ocr/results/${encodeURIComponent(e)}`)}getOcrQuota(){return this.http.get("/v1/ocr/quota")}}}function ce(r){return class extends r{pgCreateOrder(e){return this.http.post("/v1/pg/orders",e)}pgGetOrder(e){return this.http.get(`/v1/pg/orders/${encodeURIComponent(e)}`)}pgConfirmPayment(e){return this.http.post("/v1/pg/confirm",e)}pgCancelPayment(e,t){return this.http.post(`/v1/pg/orders/${encodeURIComponent(e)}/cancel`,t)}pgSyncPaymentStatus(e,t){return this.http.post(`/v1/pg/orders/${encodeURIComponent(e)}/sync`,t)}pgWebhook(e){return this.http.post("/v1/pg/webhook",e,!1)}pgGetClientConfig(){return this.http.get("/v1/pg/config",!1)}}}function le(r){return class extends r{appPushSend(e){return this.http.post("/v1/push/send",e)}appPushBroadcast(e){return this.http.post("/v1/push/broadcast",e)}appPushStatus(e){return this.http.get(`/v1/push/status/${e}`)}appPushRegisterDevice(e){return this.http.post("/v1/push/device",e)}appPushUnregisterDevice(e){return this.http.delete(`/v1/push/device/${e}`)}}}function me(r){return class extends r{smsSend(e){return this.http.post("/v1/sms/send",e)}smsStatus(e){return this.http.get(`/v1/sms/status/${e}`,!1)}smsVerificationSend(e){return this.http.post("/v1/sms/verification/send",e,!1)}smsVerificationVerify(e){return this.http.post("/v1/sms/verification/verify",e,!1)}}}function he(r){return class extends r{taxinvoiceRegistIssue(e){return this.http.post("/v1/taxinvoice",e)}taxinvoiceRegister(e){return this.http.post("/v1/taxinvoice/register",e)}taxinvoiceIssue(e){return this.http.post(`/v1/taxinvoice/${e}/issue`,{})}taxinvoiceCancelIssue(e,t){return this.http.post(`/v1/taxinvoice/${e}/cancel`,t)}taxinvoiceGetState(e){return this.http.get(`/v1/taxinvoice/${e}/state`)}taxinvoiceGetDetail(e){return this.http.get(`/v1/taxinvoice/${e}`)}}}var O=class extends re(se(me(le(ce(he(ue(ae(oe(ie(ee(ne(te(Z(Y(J(P)))))))))))))))){};var Wn=new P,Xn=new O;export{J as AccountAppMixin,X as AdminMixin,D as AuthMixin,Y as BoardMixin,Z as EmailVerifyMixin,O as EntityAppServerApi,K as EntityMixin,P as EntityServerApi,N as FileMixin,ee as OAuthMixin,Ue as PACKET_HKDF_SALT,Ie as PACKET_INFO_LABEL,G as PACKET_KEY_SIZE,H as PACKET_MAGIC_MIN,F as PACKET_MAGIC_RANGE,y as PACKET_NONCE_SIZE,_e as PACKET_TAG_SIZE,te as PasswordResetMixin,V as PushMixin,z as SmtpMixin,Q as TransactionMixin,ne as TwoFactorMixin,W as UtilsMixin,be as decryptPacket,ye as derivePacketKey,we as encryptPacket,Xn as entityAppServer,Wn as entityServer,Ce as isAuthLoginSuccessResponse,Pe as packetMagicLenFromKey};
|
|
1
|
+
function G(r){let n=import.meta;if(n?.env?.[r]!=null)return n.env[r];let e=globalThis.process;if(e?.env?.[r]!=null)return e.env[r]}function c(r){return Object.entries(r).filter(([,n])=>n!=null).map(([n,e])=>`${encodeURIComponent(n==="orderBy"?"order_by":n)}=${encodeURIComponent(String(e))}`).join("&")}import{xchacha20poly1305 as ye}from"@noble/ciphers/chacha";import{sha256 as Le}from"@noble/hashes/sha2";import{hkdf as Ue}from"@noble/hashes/hkdf";var H=32,F=2,D=14,y=24,_e=16,Ie="entity-server:hkdf:v1",Ge="entity-server:packet-encryption";function R(r){return r instanceof Uint8Array?r:new Uint8Array(r)}function Pe(r,n=Ge){return Ue(Le,new TextEncoder().encode(r),new TextEncoder().encode(Ie),new TextEncoder().encode(n),H)}function we(r,n=F,e=D){let t=R(r);return t.length<H?n:n+t[H-1]%e}function be(r,n,e=F,t=D){let s=R(r),i=R(n),o=we(i,e,t),a=crypto.getRandomValues(new Uint8Array(o)),u=crypto.getRandomValues(new Uint8Array(y)),k=ye(i,u).encrypt(s),p=new Uint8Array(o+y+k.length);return p.set(a,0),p.set(u,o),p.set(k,o+y),p}function ve(r,n,e=F,t=D){let s=R(r),i=R(n),o=we(i,e,t);if(s.length<o+y+_e)throw new Error("Encrypted packet too short");let a=s.slice(o,o+y),u=s.slice(o+y);return ye(i,a).decrypt(u)}function S(r,n){return Pe(r||n)}function Re(r,n){return be(r,n)}function q(r,n){let e=ve(r,n);return JSON.parse(new TextDecoder().decode(e))}function Se(r,n,e,t){let s=n.toLowerCase().includes("application/octet-stream");if(e&&!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 q(r,t);if(r instanceof Uint8Array){let i=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return q(i,t)}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 He}from"@noble/hashes/sha2";import{hmac as Fe}from"@noble/hashes/hmac";function xe(r,n,e,t,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+e.length);u.set(a,0),u.set(e,a.length);let k=[...Fe(He,new TextEncoder().encode(s),u)].map(p=>p.toString(16).padStart(2,"0")).join("");return{"X-API-Key":t,"X-Timestamp":i,"X-Nonce":o,"X-Signature":k}}function De(r){return r.hmacSecret||r.token||r.anonymousPacketToken}function je(r,n,e){return r.hmacSecret?r.hmacSecret:n&&r.token||e}function Ke(r){return r?r.length<=8?`${r.slice(0,2)}...${r.slice(-2)}`:`${r.slice(0,4)}...${r.slice(-4)}`:""}function Ne(r){typeof console>"u"||typeof console.error!="function"||console.error("[entity-client] packet decrypt failed",{method:r.method,path:r.path,withAuth:r.withAuth,status:r.status,contentType:r.contentType,responsePacketSource:Ke(r.responsePacketSource),tokenPresent:r.tokenPresent,anonymousPacketTokenPresent:r.anonymousPacketTokenPresent,hmacEnabled:r.hmacEnabled,error:r.error instanceof Error?{name:r.error.name,message:r.error.message,stack:r.error.stack}:r.error})}function Ve(r){return r!=="GET"&&r!=="HEAD"&&r!=="OPTIONS"}function M(r){if(typeof document>"u")return"";for(let n of document.cookie.split(";")){let e=n.indexOf("=");if(!(e<0)&&n.substring(0,e).trim()===r)return decodeURIComponent(n.substring(e+1).trim())}return""}function ze(r,n){return r===403&&/csrf/i.test(n)?!0:/csrf/i.test(n)&&/expired|token validation failed/i.test(n)}async function Ce(r){if((r.headers.get("Content-Type")??"").includes("application/json")){let t=await r.json().catch(()=>null);if(t?.error)return t.error;if(t?.message)return t.message}return await r.text().catch(()=>"")||`HTTP ${r.status}`}async function T(r,n,e,t,s=!0,i={},o=!0){let a=typeof o=="boolean"?{requireOkShape:o}:o,u=a.requireOkShape??!0,m=new Set(a.allowStatuses??[]),k=a.signal,{baseUrl:p,token:x,apiKey:pe,hmacSecret:w,encryptRequests:Be,csrfEnabled:Ae,csrfHeaderName:$e,csrfCookieName:U,refreshCsrfCookie:C,onAccessToken:fe}=r,b=r.anonymousPacketToken||M("anon_token"),E=s&&!!(pe&&w),qe=De(r),Te=je(r,s,b),B=Ae&&Ve(n)&&!E,v=B?M(U):"",ke="application/json",Me=!E&&!!b,f=null;if(t!=null)if(Be&&!!qe&&s&&n!=="GET"&&n!=="HEAD"){let d=S(w,x||b);f=Re(new TextEncoder().encode(JSON.stringify(t)),d),ke="application/octet-stream"}else f=JSON.stringify(t);let Oe=h=>{let d={...i},$=Object.keys(d).some(g=>g.toLowerCase()==="content-type");if(f!=null&&!$&&(d["Content-Type"]=ke),!E&&s&&x&&(d.Authorization=`Bearer ${x}`),Me&&(d["X-Packet-Token"]=b),B&&h&&(d[$e]=h),E){let g=f instanceof Uint8Array?f:typeof f=="string"?new TextEncoder().encode(f):new Uint8Array(0);Object.assign(d,xe(n,e,g,pe,w))}return d};B&&!v&&C&&(await C(),v=M(U));let ge=h=>fetch(p+e,{method:n,headers:Oe(h),...f!=null?{body:f}:{},credentials:"include",signal:k}),l=await ge(v);if(!l.ok){let h=await Ce(l.clone());if(B&&C&&ze(l.status,h))await C(),v=M(U),l=await ge(v);else if(!m.has(l.status)){let d=new Error(h);throw d.status=l.status,d}}if(!l.ok&&!m.has(l.status)){let h=new Error(await Ce(l));throw h.status=l.status,h}let A=l.headers.get("X-Access-Token")?.trim()??"",_=l.headers.get("Content-Type")??"";if(_.includes("application/octet-stream")){let h=S(w,Te),d=await l.arrayBuffer(),$;try{$=q(d,h)}catch(g){throw Ne({method:n,path:e,withAuth:s,status:l.status,contentType:_,responsePacketSource:Te,tokenPresent:!!x,anonymousPacketTokenPresent:!!b,hmacEnabled:!!w,error:g}),g}return A&&fe?.(A),$}if(A&&fe?.(A),!_.includes("application/json"))return await l.text();let I=await l.json();if(u&&!I.ok&&!m.has(l.status)){let h=new Error(I.message??`EntityServer error (HTTP ${l.status})`);throw h.status=l.status,h}return I}var j="/v1/realtime",O=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;realtimeEnabled;realtimePath;realtimeAutoConnect;realtimeAutoReconnect;realtimeReconnectDelayMs;realtimeStatus;realtimeSocket=null;realtimeConnectPromise=null;realtimeReconnectTimer=null;realtimeShouldReconnect=!1;realtimeMessageListeners=new Set;realtimeStatusListeners=new Set;realtimeEventListeners=new Map;constructor(n={}){let e=G("VITE_ENTITY_SERVER_URL");this.baseUrl=(n.baseUrl??e??"").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,this.realtimeEnabled=!1,this.realtimePath=j,this.realtimeAutoConnect=!0,this.realtimeAutoReconnect=!0,this.realtimeReconnectDelayMs=3e3,this.realtimeStatus="idle",this.applyRealtimeOptions(n.realtime),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.realtime<"u"&&this.applyRealtimeOptions(n.realtime),typeof n.healthTickInterval=="number"&&n.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(n.healthTickInterval))}setToken(n){if(this.token=n,!n){this.disconnectRealtime("token_cleared");return}this.realtimeEnabled&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})}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}addRealtimeListener(n){this.realtimeMessageListeners.add(n)}removeRealtimeListener(n){this.realtimeMessageListeners.delete(n)}addRealtimeStatusListener(n){this.realtimeStatusListeners.add(n)}removeRealtimeStatusListener(n){this.realtimeStatusListeners.delete(n)}addRealtimeEventListener(n,e){let t=String(n).trim();t&&(this.realtimeEventListeners.has(t)||this.realtimeEventListeners.set(t,new Set),this.realtimeEventListeners.get(t).add(e))}removeRealtimeEventListener(n,e){let t=String(n).trim();if(!t)return;let s=this.realtimeEventListeners.get(t);s&&(s.delete(e),s.size===0&&this.realtimeEventListeners.delete(t))}async connectRealtime(){if(!this.realtimeEnabled){this.setRealtimeStatus("disabled","realtime_disabled");return}if(!this.token)throw new Error("Cannot open realtime connection without access token.");if(typeof WebSocket>"u")throw new Error("WebSocket is not available in this environment.");if(this.realtimeSocket&&this.realtimeSocket.readyState===WebSocket.OPEN)return;if(this.realtimeSocket&&this.realtimeSocket.readyState===WebSocket.CONNECTING&&this.realtimeConnectPromise)return this.realtimeConnectPromise;this.clearRealtimeReconnectTimer(),this.realtimeShouldReconnect=this.realtimeAutoReconnect,this.setRealtimeStatus("connecting","connect_requested");let n=new WebSocket(this.buildRealtimeUrl());return this.realtimeSocket=n,this.realtimeConnectPromise=new Promise((e,t)=>{let s=!1,i=()=>{s||(s=!0,this.realtimeConnectPromise=null,e())},o=a=>{s||(s=!0,this.realtimeConnectPromise=null,t(a))};n.addEventListener("open",()=>{this.setRealtimeStatus("open","socket_open"),i()}),n.addEventListener("message",a=>{this.handleRealtimeMessage(a.data)}),n.addEventListener("error",()=>{this.setRealtimeStatus("closed","socket_error",new Error("Realtime socket error."))}),n.addEventListener("close",a=>{this.realtimeSocket===n&&(this.realtimeSocket=null);let u=a.reason||"socket_closed",m=new Error(`Realtime socket closed (${a.code}${a.reason?`: ${a.reason}`:""}).`);this.setRealtimeStatus("closed",u,m),s||o(m),this.realtimeShouldReconnect&&this.realtimeEnabled&&this.realtimeAutoReconnect&&this.token&&this.scheduleRealtimeReconnect(u)})}),this.realtimeConnectPromise}disconnectRealtime(n="client_disconnect"){if(this.realtimeShouldReconnect=!1,this.clearRealtimeReconnectTimer(),this.realtimeSocket){let e=this.realtimeSocket;this.realtimeSocket=null;try{(e.readyState===WebSocket.OPEN||e.readyState===WebSocket.CONNECTING)&&e.close(1e3,n)}catch{}}this.realtimeConnectPromise=null,this.setRealtimeStatus(this.realtimeEnabled?"idle":"disabled",n)}sendRealtime(n){return!this.realtimeSocket||this.realtimeSocket.readyState!==WebSocket.OPEN?!1:(this.realtimeSocket.send(JSON.stringify(n)),!0)}subscribeRealtime(n){return this.sendRealtime({type:"subscribe",channel:"session",event:"session.subscribe",data:{subscriptions:n}})}unsubscribeRealtime(n){return this.sendRealtime({type:"unsubscribe",channel:"session",event:"session.unsubscribe",data:{subscriptions:n}})}startHealthTick(n=300*1e3){this.stopHealthTick();let e=()=>{this.healthTickPromise||(this.healthTickPromise=(this.csrfRefresher?this.csrfRefresher():Promise.resolve()).then(()=>{this.onHealthChange?.(!0)}).catch(()=>{this.onHealthChange?.(!1)}).finally(()=>{this.healthTickPromise=null}))};e(),this.healthTickTimer=setInterval(e,n)}stopHealthTick(){this.healthTickTimer!==null&&(clearInterval(this.healthTickTimer),this.healthTickTimer=null),this.healthTickPromise=null}scheduleKeepSession(n,e,t){this.clearRefreshTimer(),this.sessionRefreshToken=n;let s=Math.max((e-this.refreshBuffer)*1e3,0);this.refreshTimer=setTimeout(async()=>{if(this.sessionRefreshToken)try{let i=await t(this.sessionRefreshToken);this.onTokenRefreshed?.(i.access_token,i.expires_in),this.scheduleKeepSession(this.sessionRefreshToken,i.expires_in,t)}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}applyRealtimeOptions(n){let e=typeof n=="boolean"?{enabled:n}:n??{};if(this.realtimeEnabled=e.enabled??!1,this.realtimePath=String(e.path??j).trim()||j,this.realtimeAutoConnect=e.autoConnect??!0,this.realtimeAutoReconnect=e.autoReconnect??!0,this.realtimeReconnectDelayMs=Math.max(250,e.reconnectDelayMs??3e3),!this.realtimeEnabled){this.disconnectRealtime("realtime_disabled");return}this.setRealtimeStatus("idle","realtime_enabled"),this.token&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})}buildRealtimeUrl(){let e=this.baseUrl||G("VITE_ENTITY_SERVER_URL")||""||(typeof window<"u"?window.location.origin:"");if(!e)throw new Error("Realtime connection requires baseUrl.");let t=new URL(this.realtimePath,e);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.searchParams.set("access_token",this.token),t.toString()}handleRealtimeMessage(n){if(typeof n!="string")return;let e;try{e=JSON.parse(n)}catch{return}for(let s of this.realtimeMessageListeners)s(e);let t=this.realtimeEventListeners.get(e.event);if(t)for(let s of t)s(e)}scheduleRealtimeReconnect(n){this.clearRealtimeReconnectTimer(),this.realtimeReconnectTimer=setTimeout(()=>{this.realtimeReconnectTimer=null,!(!this.realtimeEnabled||!this.token)&&(this.setRealtimeStatus("connecting",`${n}:reconnect`),this.connectRealtime().catch(()=>{}))},this.realtimeReconnectDelayMs)}clearRealtimeReconnectTimer(){this.realtimeReconnectTimer!==null&&(clearTimeout(this.realtimeReconnectTimer),this.realtimeReconnectTimer=null)}setRealtimeStatus(n,e,t){let s=this.realtimeStatus;if(!(s===n&&typeof e>"u"&&typeof t>"u")){this.realtimeStatus=n;for(let i of this.realtimeStatusListeners)i({status:n,previousStatus:s,...e?{reason:e}:{},...t?{error:t}:{}})}}applyCsrfHealth(){if(!(typeof document>"u")){for(let n of document.cookie.split(";")){let e=n.indexOf("=");if(!(e<0)&&n.substring(0,e).trim()===this.csrfCookieName){this.csrfEnabled=!!n.substring(e+1).trim();return}}this.csrfEnabled=!1}}readRequestBody(n,e="application/json",t=!1){let s=S(this.hmacSecret,this.token||this.anonymousPacketToken);return Se(n,e,t,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,onAccessToken:n=>{this.token=n}}}prepareRequest(n){return Promise.resolve()}get http(){let n=this;return{get(e,t=!0,s,i){return n.prepareRequest(t).then(()=>T(n.reqOpts,"GET",e,void 0,t,s,i??!0))},post(e,t,s=!0,i,o){return n.prepareRequest(s).then(()=>T(n.reqOpts,"POST",e,t,s,i,o??!0))},put(e,t,s=!0,i,o){return n.prepareRequest(s).then(()=>T(n.reqOpts,"PUT",e,t,s,i,o??!0))},patch(e,t,s=!0,i,o){return n.prepareRequest(s).then(()=>T(n.reqOpts,"PATCH",e,t,s,i,o??!0))},delete(e,t,s=!0,i,o){return n.prepareRequest(s).then(()=>T(n.reqOpts,"DELETE",e,t,s,i,o??!0))}}}request(n,e,t,s=!0,i,o){return this.prepareRequest(s).then(()=>T(this.reqOpts,n,e,t,s,i,o??!0))}async requestBinary(n,e,t,s=!0){await this.prepareRequest(s);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+e,{method:n,headers:i,...t!=null?{body:JSON.stringify(t)}:{},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,e,t,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+e,{method:n,headers:i,body:t,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,e,t,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+e,{method:n,headers:i,body:t,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 Ee(r){return r.ok===!0&&r.requires_2fa!==!0&&typeof r.data=="object"&&r.data!==null&&"access_token"in r.data}function K(r){return class extends r{authBootstrapPromise=null;authBootstrapToken="";authBootstrapAnonymousCompleted=!1;csrfRefresher=()=>this.checkHealth(this.keepSession).then(()=>{});async checkHealth(e=!1){try{let t=this.token,s={};e&&(s["X-Session-Bootstrap"]="1");let i=await fetch(`${this.baseUrl}/v1/health`,{signal:AbortSignal.timeout(3e3),credentials:"include",headers:s}),o=await i.json(),a=i.headers.get("X-Access-Token");a&&(this.token=a,e&&a!==t&&this.onTokenRefreshed?.(a,0),e&&o.authenticated===!0&&this.realtimeEnabled&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{}));let u=this.readCookie("anon_token");return o.packet_encryption===!0&&u&&(this.anonymousPacketToken=u,this.encryptRequests=!0),this.applyCsrfHealth(),this.onHealthChange?.(!0),e&&o.authenticated===!1&&t&&(this.disconnectRealtime("session_expired"),this.onSessionExpired?.(new Error("Session expired"))),o}catch(t){throw this.onHealthChange?.(!1),t}}readCookie(e){if(typeof document>"u")return null;let t=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith(`${e}=`));if(!t)return null;try{return decodeURIComponent(t.slice(e.length+1))}catch{return t.slice(e.length+1)}}async ensurePublicAuthBootstrap(){if(typeof document>"u"||this.apiKey&&this.hmacSecret)return;let e=!!this.anonymousPacketToken||!!this.readCookie("anon_token"),t=!!this.readCookie(this.csrfCookieName);e&&t&&this.csrfEnabled||await this.checkHealth(!1)}async ensureAuthenticatedRequestBootstrap(){if(!(typeof document>"u")&&!(this.apiKey&&this.hmacSecret)){if(this.token){if(this.authBootstrapToken===this.token)return}else if(this.authBootstrapAnonymousCompleted)return;return this.authBootstrapPromise?this.authBootstrapPromise:(this.authBootstrapPromise=this.checkHealth(!0).then(()=>{this.token?this.authBootstrapToken=this.token:this.authBootstrapAnonymousCompleted=!0}).finally(()=>{this.authBootstrapPromise=null}),this.authBootstrapPromise)}}async prepareRequest(e){await super.prepareRequest(e),e&&await this.ensureAuthenticatedRequestBootstrap()}async login(e,t){await this.ensurePublicAuthBootstrap();let s=await T(this.reqOpts,"POST","/v1/auth/login",{email:e,passwd:t},!1,{},{requireOkShape:!1,allowStatuses:[403]});return Ee(s)&&(this.token=s.data.access_token,this.applyCsrfHealth(),this.keepSession&&this.healthTickTimer===null&&this.startHealthTick(),this.realtimeEnabled&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})),s}async tokenRefresh(){let e=await this.request("POST","/v1/auth/token_refresh",void 0,!1);return this.token=e.data.access_token,this.applyCsrfHealth(),e.data}async refreshToken(e){if(!e)return this.tokenRefresh();let t=await this.request("POST","/v1/auth/refresh",{refresh_token:e},!1);return this.token=t.data.access_token,this.applyCsrfHealth(),t.data}async logout(e){this.stopKeepSession(),this.stopHealthTick(),this.disconnectRealtime("logout");let t=await this.request("POST","/v1/auth/logout",e?{refresh_token:e}:void 0,!1);return this.token="",this.applyCsrfHealth(),t}me(){return this.request("GET","/v1/auth/me")}withdraw(e){return this.request("POST","/v1/auth/withdraw",e?{passwd:e}:{})}}}function N(r){return class extends r{async transStart(){let e=await this.request("POST","/v1/transaction/start",void 0,!1);return this.activeTxId=e.transaction_id,this.activeTxId}transRollback(e){let t=e??this.activeTxId;return t?(this.activeTxId=null,this.request("POST",`/v1/transaction/rollback/${t}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}transCommit(e){let t=e??this.activeTxId;return t?(this.activeTxId=null,this.request("POST",`/v1/transaction/commit/${t}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}meta(e){return this.request("POST",`/v1/entity/${e}/meta`,{})}validate(e,t){return this.http.post(`/v1/entity/${e}/validate`,t)}get(e,t,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this.request("GET",`/v1/entity/${e}/${t}${i}`)}find(e,t,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this.request("POST",`/v1/entity/${e}/find${i}`,t??{})}list(e,t={}){let{conditions:s,fields:i,orderDir:o,orderBy:a,...u}=t,m={page:1,limit:20,...u};return a&&(m.orderBy=o==="DESC"?`-${a}`:a),i?.length&&(m.fields=i.join(",")),this.request("POST",`/v1/entity/${e}/list?${c(m)}`,s??{})}count(e,t){return this.request("POST",`/v1/entity/${e}/count`,t??{})}query(e,t){return this.request("POST",`/v1/entity/${e}/query`,t)}submit(e,t,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/${e}/submit${a}`,t,!0,o)}delete(e,t,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/${e}/delete/${t}${o}`,void 0,!0,u)}history(e,t,s={}){return this.request("GET",`/v1/entity/${e}/history/${t}?${c({page:1,limit:50,...s})}`)}rollback(e,t){return this.request("POST",`/v1/entity/${e}/rollback/${t}`)}}}function V(r){return class extends r{async fileUpload(e,t,s={}){let i=new FormData;return i.append("file",t,t instanceof File?t.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/${e}/upload`,i)}fileDownload(e,t){return this.requestBinary("POST",`/v1/files/${e}/download/${t}`,{})}fileDelete(e,t){return this.request("POST",`/v1/files/${e}/delete/${t}`,{})}fileList(e,t={}){return this.request("POST",`/v1/files/${e}/list`,t.refSeq?{ref_seq:t.refSeq}:{})}fileMeta(e,t){return this.request("POST",`/v1/files/${e}/meta/${t}`,{})}fileToken(e){return this.request("POST",`/v1/files/token/${e}`,{})}fileViewUrl(e,t={}){let s=t.download?"?download=true":"";return`${this.baseUrl}/v1/files/${e}${s}`}fileUrl(e){return`${this.baseUrl}/v1/files/${e}`}storageUpload(e,t,s={}){return this.fileUpload(e,t,s)}storageDownload(e,t){return this.fileDownload(e,t)}storageDelete(e,t){return this.fileDelete(e,t)}storageList(e,t={}){return this.fileList(e,t)}storageMeta(e,t){return this.fileMeta(e,t)}storageToken(e){return this.fileToken(e)}storageViewUrl(e,t={}){return this.fileViewUrl(e,t)}storageDownloadUrl(e){return this.fileViewUrl(e,{download:!0})}storageUrl(e){return this.fileUrl(e)}}}function z(r){return class extends r{push(e,t,s={}){return this.submit(e,t,s)}pushLogList(e={}){return this.list("push_log",e)}registerPushDevice(e,t,s,i={}){let{platform:o,deviceType:a,browser:u,browserVersion:m,pushEnabled:k=!0,transactionId:p}=i;return this.submit("account_device",{id:t,account_seq:e,push_token:s,push_enabled:k,...o?{platform:o}:{},...a?{device_type:a}:{},...u?{browser:u}:{},...m?{browser_version:m}:{}},{transactionId:p})}updatePushDeviceToken(e,t,s={}){let{pushEnabled:i=!0,transactionId:o}=s;return this.submit("account_device",{seq:e,push_token:t,push_enabled:i},{transactionId:o})}disablePushDevice(e,t={}){return this.submit("account_device",{seq:e,push_enabled:!1},{transactionId:t.transactionId})}}}function Q(r){return class extends r{smtpSend(e){return this.request("POST","/v1/smtp/send",e)}smtpStatus(e){return this.request("POST",`/v1/smtp/status/${e}`,{})}smtpTemplatePreview(e){let t=e.split("/").map(encodeURIComponent).join("/");return fetch(`${this.baseUrl}/v1/smtp/template/${t}`,{credentials:"include"}).then(s=>s.text())}}}function W(r){return class extends r{transactionStart(e){return this.request("POST","/v1/transaction/start",e??{})}transactionCommit(e){return this.request("POST",`/v1/transaction/commit/${encodeURIComponent(e)}`,{})}transactionRollback(e){return this.request("POST",`/v1/transaction/rollback/${encodeURIComponent(e)}`,{})}}}function X(r){return class extends r{addressSido(){return this.http.get("/v1/utils/address/sido",!1)}addressSigungu(e){let t=new URLSearchParams({sido:e.sido}).toString();return this.http.get(`/v1/utils/address/sigungu?${t}`,!1)}addressDong(e){let t=new URLSearchParams({sido:e.sido,sigungu:e.sigungu}).toString();return this.http.get(`/v1/utils/address/dong?${t}`,!1)}addressClean(e){let t=new URLSearchParams({q:e.q}).toString();return this.http.get(`/v1/utils/address/clean?${t}`,!1)}qrcode(e,t={}){return this.requestBinary("POST","/v1/utils/qrcode",{content:e,...t})}qrcodeBase64(e,t={}){return this.request("POST","/v1/utils/qrcode/base64",{content:e,...t})}qrcodeText(e,t={}){return this.request("POST","/v1/utils/qrcode/text",{content:e,...t})}barcode(e,t={}){return this.requestBinary("POST","/v1/utils/barcode",{content:e,...t})}pdf2png(e,t={}){let s=new FormData;s.append("file",new Blob([e],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;t.dpi!=null&&i.set("dpi",String(t.dpi)),t.firstPage!=null&&i.set("first_page",String(t.firstPage)),t.lastPage!=null&&i.set("last_page",String(t.lastPage));let o=i.toString(),a="/v1/utils/pdf2png"+(o?`?${o}`:"");return this.requestFormBinary("POST",a,s)}pdf2pngByFileSeq(e,t={}){return this.requestBinary("POST",`/v1/utils/pdf2png/${e}`,t)}pdf2jpg(e,t={}){let s=new FormData;s.append("file",new Blob([e],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;t.dpi!=null&&i.set("dpi",String(t.dpi)),t.firstPage!=null&&i.set("first_page",String(t.firstPage)),t.lastPage!=null&&i.set("last_page",String(t.lastPage));let o=i.toString(),a="/v1/utils/pdf2jpg"+(o?`?${o}`:"");return this.requestFormBinary("POST",a,s)}pdf2jpgByFileSeq(e,t={}){return this.requestBinary("POST",`/v1/utils/pdf2jpg/${e}`,t)}}}function J(r){return class extends r{adminPath(e){return`/v1/admin${e}`}adminGet(e){return this.http.get(this.adminPath(e))}adminPost(e,t){return this.http.post(this.adminPath(e),t)}adminPut(e,t){return this.http.put(this.adminPath(e),t)}adminPatch(e,t){return this.http.patch(this.adminPath(e),t)}adminDelete(e,t){return this.http.delete(this.adminPath(e),t)}listAdminEntities(){return this.adminGet("/entities")}getAdminErdSchema(){return this.adminGet("/erd/schema")}batchEnsureAdminEntities(e){return this.adminPost("/entities/batch-ensure",e)}createAdminEntityConfig(e,t){return this.adminPost(`/${e}/create`,t)}getAdminEntityConfig(e){return this.adminGet(`/${e}/config`)}updateAdminEntityConfig(e,t){return this.adminPut(`/${e}/config`,t)}validateAdminEntityConfig(e,t){return this.adminPost(t?`/${t}/validate`:"/entity/validate",e)}normalizeAdminEntityConfig(e,t){return this.adminPost(t?`/${t}/normalize`:"/entity/normalize",e)}getAdminEntityStats(e,t){return this.adminPost(`/${e}/stats`,t)}reindexAdminEntity(e){return this.adminPost(`/${e}/reindex`)}syncAdminEntitySchema(e){return this.adminPost(`/${e}/sync-schema`)}resetAdminEntity(e){return this.adminPost(`/${e}/reset`)}truncateAdminEntity(e){return this.adminPost(`/${e}/truncate`)}dropAdminEntity(e){return this.adminPost(`/${e}/drop`)}resetAllAdmin(e){return this.adminPost("/reset-all",e)}listAdminConfigs(){return this.adminGet("/configs")}getAdminConfig(e){return this.adminGet(`/configs/${e}`)}updateAdminConfig(e,t){return this.adminPatch(`/configs/${e}`,t)}listAdminRoles(){return this.adminGet("/roles")}createAdminRole(e){return this.adminPost("/roles",e)}getAdminRole(e){return this.adminGet(`/roles/${e}`)}updateAdminRole(e,t){return this.adminPatch(`/roles/${e}`,t)}deleteAdminRole(e){return this.adminDelete(`/roles/${e}`)}listAdminApiKeys(){return this.adminGet("/api-keys")}createAdminApiKey(e){return this.adminPost("/api-keys",e)}getAdminApiKey(e){return this.adminGet(`/api-keys/${e}`)}updateAdminApiKey(e,t){return this.adminPatch(`/api-keys/${e}`,t)}deleteAdminApiKey(e){return this.adminDelete(`/api-keys/${e}`)}regenerateAdminApiKeySecret(e){return this.adminPost(`/api-keys/${e}/regenerate-secret`)}listAdminAccounts(){return this.adminGet("/accounts")}createAdminAccount(e){return this.adminPost("/accounts",e)}getAdminAccount(e){return this.adminGet(`/accounts/${e}`)}updateAdminAccount(e,t){return this.adminPatch(`/accounts/${e}`,t)}deleteAdminAccount(e){return this.adminDelete(`/accounts/${e}`)}listAdminLicenses(){return this.adminGet("/licenses")}createAdminLicense(e){return this.adminPost("/licenses",e)}getAdminLicense(e){return this.adminGet(`/licenses/${e}`)}updateAdminLicense(e,t){return this.adminPatch(`/licenses/${e}`,t)}deleteAdminLicense(e){return this.adminDelete(`/licenses/${e}`)}runAdminBackup(e){return this.adminPost("/backup/run",e)}getAdminBackupStatus(e){return this.adminPost("/backup/status",e)}listAdminBackups(e){return this.adminPost("/backup/list",e)}restoreAdminBackup(e){return this.adminPost("/backup/restore",e)}deleteAdminBackup(e){return this.adminPost("/backup/delete",e)}disableAdminAccountTwoFactor(e){return this.adminDelete(`/accounts/${e}/2fa`)}}}var P=class extends X(W(V(Q(z(J(N(K(O)))))))){};function Y(r){return class extends r{accountRegister(e){return this.http.post("/v1/account/register",e,!1)}accountWithdraw(e){return this.http.post("/v1/account/withdraw",e)}accountChangePassword(e){return this.http.post("/v1/account/change-password",e)}accountReactivate(e){return this.http.post("/v1/account/reactivate",e,!1)}listAccountBiometrics(){return this.http.get("/v1/account/biometric")}registerAccountBiometric(e){return this.http.post("/v1/account/biometric",e)}deleteAccountBiometric(e){return this.http.delete(`/v1/account/biometric/${e}`)}}}function Z(r){return class extends r{listBoardCategories(e={}){let t=c(e);return this.http.get(`/v1/board/categories${t?`?${t}`:""}`,!1)}getBoardCategory(e){return this.http.get(`/v1/board/categories/${e}`,!1)}createBoardCategory(e){return this.http.post("/v1/board/categories",e)}updateBoardCategory(e,t){return this.http.put(`/v1/board/categories/${e}`,t)}deleteBoardCategory(e){return this.http.delete(`/v1/board/categories/${e}`)}listBoardPosts(e,t={}){let s=c(t);return this.http.get(`/v1/board/${e}/list${s?`?${s}`:""}`)}getBoardPost(e){return this.http.get(`/v1/board/posts/${e}`)}createBoardPost(e,t){return this.http.post(`/v1/board/${e}/submit`,t)}updateBoardPost(e,t){return this.http.put(`/v1/board/posts/${e}`,t)}deleteBoardPost(e){return this.http.delete(`/v1/board/posts/${e}`)}listBoardComments(e,t={}){let s=c(t);return this.http.get(`/v1/board/posts/${e}/comments${s?`?${s}`:""}`,!1)}createBoardComment(e,t){return this.http.post(`/v1/board/posts/${e}/comments/submit`,t)}updateBoardComment(e,t){return this.http.put(`/v1/board/comments/${e}`,t)}deleteBoardComment(e){return this.http.delete(`/v1/board/comments/${e}`)}listBoardFiles(e){return this.http.get(`/v1/board/posts/${e}/files`,!1)}async uploadBoardFile(e,t){let s=new FormData;return s.append("file",t,t instanceof File?t.name:"upload"),this.requestForm("POST",`/v1/board/posts/${e}/files`,s)}boardFileUrl(e){return`${this.baseUrl}/v1/board/files/${e}`}deleteBoardFile(e){return this.http.delete(`/v1/board/files/${e}`)}createBoardGuestPost(e,t){return this.http.post(`/v1/board/${e}/guest-submit`,t,!1)}authenticateBoardGuestPost(e,t){return this.http.post(`/v1/board/posts/${e}/guest-auth`,t,!1)}toggleBoardPostLike(e){return this.http.post(`/v1/board/posts/${e}/like`,{})}acceptBoardPost(e){return this.http.post(`/v1/board/posts/${e}/accept`,{})}rateBoardPost(e,t){return this.http.post(`/v1/board/posts/${e}/rating`,t)}rateBoardComment(e,t){return this.http.post(`/v1/board/comments/${e}/rating`,t)}listBoardTags(e={}){let t=c(e);return this.http.get(`/v1/board/tags${t?`?${t}`:""}`,!1)}setBoardPostTags(e,t){return this.http.put(`/v1/board/posts/${e}/tags`,t)}reportBoardPost(e,t){return this.http.post(`/v1/board/posts/${e}/report`,t)}reportBoardComment(e,t){return this.http.post(`/v1/board/comments/${e}/report`,t)}listBoardReports(e={}){let t=c(e);return this.http.get(`/v1/board/admin/reports${t?`?${t}`:""}`)}updateBoardReport(e,t){return this.http.patch(`/v1/board/admin/reports/${e}`,t)}markBoardPostRead(e){return this.http.post(`/v1/board/posts/${e}/read`,{})}listBoardMentions(e={}){let t=c(e);return this.http.get(`/v1/board/mentions${t?`?${t}`:""}`)}markBoardMentionRead(e){return this.http.patch(`/v1/board/mentions/${e}/read`,{})}}}function ee(r){return class extends r{sendEmailVerification(e){return this.http.post("/v1/email-verify/send",e,!1)}confirmEmailVerification(e){return this.http.post("/v1/email-verify/confirm",e,!1)}activateEmailVerification(e){let t=c(e);return this.http.get(`/v1/email-verify/activate${t?`?${t}`:""}`,!1)}getEmailVerificationStatus(){return this.http.get("/v1/email-verify/status")}changeVerifiedEmail(e){return this.http.post("/v1/email-verify/change",e)}}}function te(r){return class extends r{oauthAuthorizeUrl(e,t={}){let s=c(t);return`${this.baseUrl}/v1/oauth/${e}${s?`?${s}`:""}`}oauthCallback(e,t,s="POST"){if(s==="GET"){let i=c(t??{});return this.http.get(`/v1/oauth/${e}/callback${i?`?${i}`:""}`,!1)}return this.http.post(`/v1/oauth/${e}/callback`,t,!1)}linkOAuthAccount(e){return this.http.post("/v1/account/oauth/link",e)}unlinkOAuthAccount(e){return this.http.delete(`/v1/account/oauth/link/${e}`)}listOAuthProviders(){return this.http.get("/v1/account/oauth/providers")}refreshOAuthProviderToken(e,t){return this.http.post(`/v1/account/oauth/refresh/${e}`,t)}}}function ne(r){return class extends r{requestPasswordReset(e){return this.http.post("/v1/password-reset/request",e,!1)}validatePasswordResetToken(e){return this.http.get(`/v1/password-reset/validate/${encodeURIComponent(e)}`,!1)}verifyPasswordReset(e){return this.http.post("/v1/password-reset/verify",e,!1)}}}function re(r){return class extends r{setupTwoFactor(e){return this.http.post("/v1/account/2fa/setup",e)}verifyTwoFactorSetup(e){return this.http.post("/v1/account/2fa/setup/verify",e,!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(e){return this.http.post("/v1/account/2fa/verify",e,!1)}recoverTwoFactorAccess(e){return this.http.post("/v1/account/2fa/recovery",e,!1)}}}function se(r){return class extends r{alimtalkSend(e){return this.http.post("/v1/alimtalk/send",e)}alimtalkStatus(e){return this.http.get(`/v1/alimtalk/status/${e}`,!1)}listAlimtalkTemplates(){return this.http.get("/v1/alimtalk/templates",!1)}alimtalkWebhook(e,t){return this.http.post(`/v1/alimtalk/webhook/${encodeURIComponent(e)}`,t,!1)}}}function ie(r){return class extends r{friendtalkSend(e){return this.http.post("/v1/friendtalk/send",e)}}}function oe(r){return class extends r{listHolidays(e={}){let t=c(e);return this.http.get(`/v1/holidays${t?`?${t}`:""}`,!1)}getHolidayByDate(e){return this.http.get(`/v1/holidays/${encodeURIComponent(e)}`,!1)}syncHolidays(e){return this.http.post("/v1/holidays/sync",e)}}}function ae(r){return class extends r{identityRequest(e){return this.http.post("/v1/identity/request",e,!1)}identityCallback(e){return this.http.post("/v1/identity/callback",e,!1)}identityResult(e){return this.http.get(`/v1/identity/result/${encodeURIComponent(e)}`,!1)}identityVerifyCI(e){return this.http.post("/v1/identity/verify-ci",e)}}}function ue(r){return class extends r{llmChat(e){return this.http.post("/v1/llm/chat",e)}llmChatStream(e){return this.http.post("/v1/llm/chat/stream",e)}createLlmConversation(e){return this.http.post("/v1/llm/conversations",e)}sendLlmMessage(e,t){return this.http.post(`/v1/llm/conversations/${e}/messages`,t)}listLlmConversations(e={}){let t=c(e);return this.http.get(`/v1/llm/conversations${t?`?${t}`:""}`)}getLlmConversation(e){return this.http.get(`/v1/llm/conversations/${e}`)}updateLlmConversation(e,t){return this.http.patch(`/v1/llm/conversations/${e}`,t)}deleteLlmConversation(e){return this.http.delete(`/v1/llm/conversations/${e}`)}ragUploadDocument(e){return this.requestForm("POST","/v1/llm/rag/documents",e)}ragListDocuments(e={}){let t=c(e);return this.http.get(`/v1/llm/rag/documents${t?`?${t}`:""}`)}ragDeleteDocument(e){return this.http.delete(`/v1/llm/rag/documents/${encodeURIComponent(e)}`)}ragSearch(e){return this.http.post("/v1/llm/rag/search",e)}ragChat(e){return this.http.post("/v1/llm/rag/chat",e)}ragChatStream(e){return this.http.post("/v1/llm/rag/chat/stream",e)}ragRebuildIndex(e){return this.http.post("/v1/llm/rag/rebuild-index",e)}listLlmProviders(){return this.http.get("/v1/llm/providers")}getLlmUsage(e={}){let t=c(e);return this.http.get(`/v1/llm/usage${t?`?${t}`:""}`)}getLlmUsageSummary(e={}){let t=c(e);return this.http.get(`/v1/llm/usage/summary${t?`?${t}`:""}`)}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(e,t){return this.http.post(`/v1/llm/${encodeURIComponent(e)}/chat`,t)}llmTemplateChatStream(e,t){return this.http.post(`/v1/llm/${encodeURIComponent(e)}/chat/stream`,t)}listLlmChatbots(e={}){let t=c(e);return this.http.get(`/v1/llm/chatbots${t?`?${t}`:""}`)}createLlmChatbot(e){return this.http.post("/v1/llm/chatbots",e)}getLlmChatbot(e){return this.http.get(`/v1/llm/chatbots/${e}`)}updateLlmChatbot(e,t){return this.http.patch(`/v1/llm/chatbots/${e}`,t)}deleteLlmChatbot(e){return this.http.delete(`/v1/llm/chatbots/${e}`)}llmChatbotChat(e,t){return this.http.post(`/v1/llm/chatbots/${e}/chat`,t)}llmChatbotChatStream(e,t){return this.http.post(`/v1/llm/chatbots/${e}/chat/stream`,t)}listLlmChatbotSessions(e,t={}){let s=c(t);return this.http.get(`/v1/llm/chatbots/${e}/sessions${s?`?${s}`:""}`)}deleteLlmChatbotSession(e,t){return this.http.delete(`/v1/llm/chatbots/${e}/sessions/${t}`)}listLlmProfiles(e={}){let t=c(e);return this.http.get(`/v1/llm/profiles${t?`?${t}`:""}`)}upsertLlmProfile(e){return this.http.post("/v1/llm/profiles",e)}deleteLlmProfile(e){return this.http.delete(`/v1/llm/profiles/${e}`)}}}function ce(r){return class extends r{ocrRecognize(e){return this.requestForm("POST","/v1/ocr/recognize",e)}ocrRecognizeAsync(e){return this.requestForm("POST","/v1/ocr/recognize/async",e)}ocrRecognizeByDocType(e,t){return this.requestForm("POST",`/v1/ocr/${encodeURIComponent(e)}`,t)}listOcrResults(e={}){let t=c(e);return this.http.get(`/v1/ocr/results${t?`?${t}`:""}`)}getOcrResult(e){return this.http.get(`/v1/ocr/results/${encodeURIComponent(e)}`)}getOcrResultText(e){return this.http.get(`/v1/ocr/results/${encodeURIComponent(e)}/text`)}deleteOcrResult(e){return this.http.delete(`/v1/ocr/results/${encodeURIComponent(e)}`)}getOcrQuota(){return this.http.get("/v1/ocr/quota")}}}function le(r){return class extends r{pgCreateOrder(e){return this.http.post("/v1/pg/orders",e)}pgGetOrder(e){return this.http.get(`/v1/pg/orders/${encodeURIComponent(e)}`)}pgConfirmPayment(e){return this.http.post("/v1/pg/confirm",e)}pgCancelPayment(e,t){return this.http.post(`/v1/pg/orders/${encodeURIComponent(e)}/cancel`,t)}pgSyncPaymentStatus(e,t){return this.http.post(`/v1/pg/orders/${encodeURIComponent(e)}/sync`,t)}pgWebhook(e){return this.http.post("/v1/pg/webhook",e,!1)}pgGetClientConfig(){return this.http.get("/v1/pg/config",!1)}}}function me(r){return class extends r{appPushSend(e){return this.http.post("/v1/push/send",e)}appPushBroadcast(e){return this.http.post("/v1/push/broadcast",e)}appPushStatus(e){return this.http.get(`/v1/push/status/${e}`)}appPushRegisterDevice(e){return this.http.post("/v1/push/device",e)}appPushUnregisterDevice(e){return this.http.delete(`/v1/push/device/${e}`)}}}function he(r){return class extends r{smsSend(e){return this.http.post("/v1/sms/send",e)}smsStatus(e){return this.http.get(`/v1/sms/status/${e}`,!1)}smsVerificationSend(e){return this.http.post("/v1/sms/verification/send",e,!1)}smsVerificationVerify(e){return this.http.post("/v1/sms/verification/verify",e,!1)}}}function de(r){return class extends r{taxinvoiceRegistIssue(e){return this.http.post("/v1/taxinvoice",e)}taxinvoiceRegister(e){return this.http.post("/v1/taxinvoice/register",e)}taxinvoiceIssue(e){return this.http.post(`/v1/taxinvoice/${e}/issue`,{})}taxinvoiceCancelIssue(e,t){return this.http.post(`/v1/taxinvoice/${e}/cancel`,t)}taxinvoiceGetState(e){return this.http.get(`/v1/taxinvoice/${e}/state`)}taxinvoiceGetDetail(e){return this.http.get(`/v1/taxinvoice/${e}`)}}}var L=class extends se(ie(he(me(le(de(ce(ue(ae(oe(te(re(ne(ee(Z(Y(P)))))))))))))))){};var Xn=new P,Jn=new L;export{Y as AccountAppMixin,J as AdminMixin,K as AuthMixin,Z as BoardMixin,ee as EmailVerifyMixin,L as EntityAppServerApi,N as EntityMixin,P as EntityServerApi,V as FileMixin,te as OAuthMixin,Ie as PACKET_HKDF_SALT,Ge as PACKET_INFO_LABEL,H as PACKET_KEY_SIZE,F as PACKET_MAGIC_MIN,D as PACKET_MAGIC_RANGE,y as PACKET_NONCE_SIZE,_e as PACKET_TAG_SIZE,ne as PasswordResetMixin,z as PushMixin,Q as SmtpMixin,W as TransactionMixin,re as TwoFactorMixin,X as UtilsMixin,ve as decryptPacket,Pe as derivePacketKey,be as encryptPacket,Jn as entityAppServer,Xn as entityServer,Ee as isAuthLoginSuccessResponse,we as packetMagicLenFromKey};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|