{"version":3,"file":"sntp-client-A8iBOjlE.mjs","names":[],"sources":["../src/sntp/sntp-client.ts"],"sourcesContent":["/* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD */\n/* SPDX-License-Identifier: Apache-2.0 */\n\nimport {\n  callServiceFunction,\n  closeService,\n  isServiceAvailable,\n  openService,\n  resolveHost,\n  type ServiceClientOptions,\n  type ServiceHandle,\n} from '../common/service-rpc.ts';\nimport type { SntpState } from './sntp-types.ts';\n\n/** Registered name (`helper::SNTP::get_name()`). */\nexport const SNTP_SERVICE_NAME = 'SNTP';\n\n/** RPC function names (`helper::SNTP::FunctionId`). */\nexport const SNTP_FUNCTIONS = {\n  SetServers: 'SetServers',\n  SetTimezone: 'SetTimezone',\n  Start: 'Start',\n  Stop: 'Stop',\n  GetServers: 'GetServers',\n  GetTimezone: 'GetTimezone',\n  GetState: 'GetState',\n  IsTimeSynced: 'IsTimeSynced',\n  LoadData: 'LoadData',\n  ResetData: 'ResetData',\n} as const;\n\nexport type SntpClientOptions = ServiceClientOptions;\n\nexport { type ServiceHandle as SntpHandle };\n\nexport function isSntpAvailable(options?: SntpClientOptions): boolean {\n  return isServiceAvailable(SNTP_SERVICE_NAME, options);\n}\n\nexport function openSntp(options?: SntpClientOptions): ServiceHandle {\n  return openService(SNTP_SERVICE_NAME, options);\n}\n\nexport function closeSntp(handle: ServiceHandle, options?: SntpClientOptions): void {\n  closeService(handle, options);\n}\n\nfunction callSntp<T>(\n  handle: ServiceHandle,\n  functionName: string,\n  params: Record<string, unknown>,\n  options?: SntpClientOptions,\n): T {\n  return callServiceFunction<T>(resolveHost(options), handle, functionName, params);\n}\n\nexport function setServers(\n  handle: ServiceHandle,\n  servers: string[],\n  options?: SntpClientOptions,\n): void {\n  callSntp<void>(handle, SNTP_FUNCTIONS.SetServers, { Servers: servers }, options);\n}\n\nexport function setTimezone(\n  handle: ServiceHandle,\n  timezone: string,\n  options?: SntpClientOptions,\n): void {\n  callSntp<void>(handle, SNTP_FUNCTIONS.SetTimezone, { Timezone: timezone }, options);\n}\n\nexport function startSntp(handle: ServiceHandle, options?: SntpClientOptions): void {\n  callSntp<void>(handle, SNTP_FUNCTIONS.Start, {}, options);\n}\n\nexport function stopSntp(handle: ServiceHandle, options?: SntpClientOptions): void {\n  callSntp<void>(handle, SNTP_FUNCTIONS.Stop, {}, options);\n}\n\nexport function getServers(handle: ServiceHandle, options?: SntpClientOptions): string[] {\n  return callSntp<string[]>(handle, SNTP_FUNCTIONS.GetServers, {}, options);\n}\n\nexport function getTimezone(handle: ServiceHandle, options?: SntpClientOptions): string {\n  return callSntp<string>(handle, SNTP_FUNCTIONS.GetTimezone, {}, options);\n}\n\nexport function getSntpState(handle: ServiceHandle, options?: SntpClientOptions): SntpState {\n  return callSntp<SntpState>(handle, SNTP_FUNCTIONS.GetState, {}, options);\n}\n\nexport function isTimeSynced(handle: ServiceHandle, options?: SntpClientOptions): boolean {\n  return callSntp<boolean>(handle, SNTP_FUNCTIONS.IsTimeSynced, {}, options);\n}\n\nexport function loadSntpData(handle: ServiceHandle, options?: SntpClientOptions): void {\n  callSntp<void>(handle, SNTP_FUNCTIONS.LoadData, {}, options);\n}\n\nexport function resetSntpData(handle: ServiceHandle, options?: SntpClientOptions): void {\n  callSntp<void>(handle, SNTP_FUNCTIONS.ResetData, {}, options);\n}\n"],"mappings":";;;AAeA,MAAa,oBAAoB;;AAGjC,MAAa,iBAAiB;CAC5B,YAAY;CACZ,aAAa;CACb,OAAO;CACP,MAAM;CACN,YAAY;CACZ,aAAa;CACb,UAAU;CACV,cAAc;CACd,UAAU;CACV,WAAW;AACb;AAMA,SAAgB,gBAAgB,SAAsC;CACpE,OAAO,mBAAmB,mBAAmB,OAAO;AACtD;AAEA,SAAgB,SAAS,SAA4C;CACnE,OAAO,YAAY,mBAAmB,OAAO;AAC/C;AAEA,SAAgB,UAAU,QAAuB,SAAmC;CAClF,aAAa,QAAQ,OAAO;AAC9B;AAEA,SAAS,SACP,QACA,cACA,QACA,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