{"version":3,"file":"timestamp.mjs","names":[],"sources":["../../../../../src/grpc/proto/google/protobuf/timestamp.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// @generated by protobuf-ts 2.9.6 with parameter force_server_none,optimize_code_size,ts_nocheck\n// @generated from protobuf file \"google/protobuf/timestamp.proto\" (package \"google.protobuf\", syntax proto3)\n// tslint:disable\n// @ts-nocheck\n//\n// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\nimport { typeofJsonValue } from '@protobuf-ts/runtime';\nimport type { JsonValue } from '@protobuf-ts/runtime';\nimport type { JsonReadOptions } from '@protobuf-ts/runtime';\nimport type { JsonWriteOptions } from '@protobuf-ts/runtime';\nimport { PbLong } from '@protobuf-ts/runtime';\nimport { MessageType } from '@protobuf-ts/runtime';\n/**\n * A Timestamp represents a point in time independent of any time zone\n * or calendar, represented as seconds and fractions of seconds at\n * nanosecond resolution in UTC Epoch time. It is encoded using the\n * Proleptic Gregorian Calendar which extends the Gregorian calendar\n * backwards to year one. It is encoded assuming all minutes are 60\n * seconds long, i.e. leap seconds are \"smeared\" so that no leap second\n * table is needed for interpretation. Range is from\n * `0001-01-01T00:00:00Z` to `9999-12-31T23:59:59.999999999Z`.\n * Restricting to that range ensures that conversion to\n * and from RFC 3339 date strings is possible.\n * See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).\n *\n * # Examples\n *\n * Example 1: Compute Timestamp from POSIX `time()`.\n *\n * ```\n * Timestamp timestamp;\n * timestamp.set_seconds(time(NULL));\n * timestamp.set_nanos(0);\n * ```\n *\n * Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n *\n * ```\n * struct timeval tv;\n * gettimeofday(&tv, NULL);\n *\n * Timestamp timestamp;\n * timestamp.set_seconds(tv.tv_sec);\n * timestamp.set_nanos(tv.tv_usec * 1000);\n * ```\n *\n * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n *\n * ```\n * FILETIME ft;\n * GetSystemTimeAsFileTime(&ft);\n * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n *\n * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n * Timestamp timestamp;\n * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); //\n * ```\n *\n * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n *\n * ```\n * long millis = System.currentTimeMillis();\n *\n * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n *     .setNanos((int) ((millis % 1000) * 1000000)).build();\n *\n * ```\n *\n * Example 5: Compute Timestamp from current time in Python.\n *\n * ```\n * timestamp = Timestamp()\n * timestamp.GetCurrentTime()\n * ```\n *\n * # JSON Mapping\n *\n * In JSON format, the `Timestamp` type is encoded as a string in the\n * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n * format is `{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z`\n * where `{year}` is always expressed using four digits while `{month}`, `{day}`,\n * `{hour}`, `{min}`, and `{sec}` are zero-padded to two digits each. The fractional\n * seconds, which can go up to 9 digits (so up to 1 nanosecond resolution),\n * are optional. The \"Z\" suffix indicates the timezone (\"UTC\"); the timezone\n * is required, though only UTC (as indicated by \"Z\") is presently supported.\n *\n * For example, `2017-01-15T01:30:15.01Z` encodes 15.01 seconds past\n * 01:30 UTC on January 15, 2017.\n *\n * In JavaScript, you can convert a `Date` object to this format using the\n * standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n * method. In Python, you can convert a standard `datetime.datetime` object\n * to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)\n * with the time format spec `%Y-%m-%dT%H:%M:%S.%fZ`. Likewise, in Java, you\n * can use the Joda Time's [`ISODateTimeFormat.dateTime()`](\n * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--)\n * to obtain a formatter capable of generating timestamps in this format.\n *\n *\n *\n * @generated from protobuf message google.protobuf.Timestamp\n */\nexport interface Timestamp {\n\t/**\n\t * Represents seconds of UTC time since Unix epoch\n\t * `1970-01-01T00:00:00Z`. Must be from `0001-01-01T00:00:00Z` to\n\t * `9999-12-31T23:59:59Z` inclusive.\n\t *\n\t * @generated from protobuf field: int64 seconds = 1;\n\t */\n\tseconds: bigint;\n\t/**\n\t * Non-negative fractions of a second at nanosecond resolution. Negative\n\t * second values with fractions must still have non-negative nano values\n\t * that count forward in time. Must be from 0 to 999,999,999\n\t * inclusive.\n\t *\n\t * @generated from protobuf field: int32 nanos = 2;\n\t */\n\tnanos: number;\n}\n// @generated message type with reflection information, may provide speed optimized methods\nclass Timestamp$Type extends MessageType<Timestamp> {\n\tconstructor() {\n\t\tsuper('google.protobuf.Timestamp', [\n\t\t\t{\n\t\t\t\tno: 1,\n\t\t\t\tname: 'seconds',\n\t\t\t\tkind: 'scalar',\n\t\t\t\tT: 3 /*ScalarType.INT64*/,\n\t\t\t\tL: 0 /*LongType.BIGINT*/,\n\t\t\t},\n\t\t\t{ no: 2, name: 'nanos', kind: 'scalar', T: 5 /*ScalarType.INT32*/ },\n\t\t]);\n\t}\n\t/**\n\t * Creates a new `Timestamp` for the current time.\n\t */\n\tnow(): Timestamp {\n\t\tconst msg = this.create();\n\t\tconst ms = Date.now();\n\t\tmsg.seconds = PbLong.from(Math.floor(ms / 1000)).toBigInt();\n\t\tmsg.nanos = (ms % 1000) * 1000000;\n\t\treturn msg;\n\t}\n\t/**\n\t * Converts a `Timestamp` to a JavaScript Date.\n\t */\n\ttoDate(message: Timestamp): Date {\n\t\treturn new Date(\n\t\t\tPbLong.from(message.seconds).toNumber() * 1000 + Math.ceil(message.nanos / 1000000),\n\t\t);\n\t}\n\t/**\n\t * Converts a JavaScript Date to a `Timestamp`.\n\t */\n\tfromDate(date: Date): Timestamp {\n\t\tconst msg = this.create();\n\t\tconst ms = date.getTime();\n\t\tmsg.seconds = PbLong.from(Math.floor(ms / 1000)).toBigInt();\n\t\tmsg.nanos = ((ms % 1000) + (ms < 0 && ms % 1000 !== 0 ? 1000 : 0)) * 1000000;\n\t\treturn msg;\n\t}\n\t/**\n\t * In JSON format, the `Timestamp` type is encoded as a string\n\t * in the RFC 3339 format.\n\t */\n\tinternalJsonWrite(message: Timestamp, options: JsonWriteOptions): JsonValue {\n\t\tlet ms = PbLong.from(message.seconds).toNumber() * 1000;\n\t\tif (ms < Date.parse('0001-01-01T00:00:00Z') || ms > Date.parse('9999-12-31T23:59:59Z'))\n\t\t\tthrow new Error(\n\t\t\t\t'Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.',\n\t\t\t);\n\t\tif (message.nanos < 0)\n\t\t\tthrow new Error('Unable to encode invalid Timestamp to JSON. Nanos must not be negative.');\n\t\tlet z = 'Z';\n\t\tif (message.nanos > 0) {\n\t\t\tlet nanosStr = (message.nanos + 1000000000).toString().substring(1);\n\t\t\tif (nanosStr.substring(3) === '000000') z = '.' + nanosStr.substring(0, 3) + 'Z';\n\t\t\telse if (nanosStr.substring(6) === '000') z = '.' + nanosStr.substring(0, 6) + 'Z';\n\t\t\telse z = '.' + nanosStr + 'Z';\n\t\t}\n\t\treturn new Date(ms).toISOString().replace('.000Z', z);\n\t}\n\t/**\n\t * In JSON format, the `Timestamp` type is encoded as a string\n\t * in the RFC 3339 format.\n\t */\n\tinternalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Timestamp): Timestamp {\n\t\tif (typeof json !== 'string')\n\t\t\tthrow new Error('Unable to parse Timestamp from JSON ' + typeofJsonValue(json) + '.');\n\t\tlet matches = json.match(\n\t\t\t/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/,\n\t\t);\n\t\tif (!matches) throw new Error('Unable to parse Timestamp from JSON. Invalid format.');\n\t\tlet ms = Date.parse(\n\t\t\tmatches[1] +\n\t\t\t\t'-' +\n\t\t\t\tmatches[2] +\n\t\t\t\t'-' +\n\t\t\t\tmatches[3] +\n\t\t\t\t'T' +\n\t\t\t\tmatches[4] +\n\t\t\t\t':' +\n\t\t\t\tmatches[5] +\n\t\t\t\t':' +\n\t\t\t\tmatches[6] +\n\t\t\t\t(matches[8] ? matches[8] : 'Z'),\n\t\t);\n\t\tif (Number.isNaN(ms)) throw new Error('Unable to parse Timestamp from JSON. Invalid value.');\n\t\tif (ms < Date.parse('0001-01-01T00:00:00Z') || ms > Date.parse('9999-12-31T23:59:59Z'))\n\t\t\tthrow new globalThis.Error(\n\t\t\t\t'Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.',\n\t\t\t);\n\t\tif (!target) target = this.create();\n\t\ttarget.seconds = PbLong.from(ms / 1000).toBigInt();\n\t\ttarget.nanos = 0;\n\t\tif (matches[7])\n\t\t\ttarget.nanos = parseInt('1' + matches[7] + '0'.repeat(9 - matches[7].length)) - 1000000000;\n\t\treturn target;\n\t}\n}\n/**\n * @generated MessageType for protobuf message google.protobuf.Timestamp\n */\nexport const Timestamp = new Timestamp$Type();\n"],"mappings":";;;AA4JA,IAAM,iBAAN,cAA6B,YAAuB;CACnD,cAAc;AACb,QAAM,6BAA6B,CAClC;GACC,IAAI;GACJ,MAAM;GACN,MAAM;GACN,GAAG;GACH,GAAG;GACH,EACD;GAAE,IAAI;GAAG,MAAM;GAAS,MAAM;GAAU,GAAG;GAAwB,CACnE,CAAC;;;;;CAKH,MAAiB;EAChB,MAAM,MAAM,KAAK,QAAQ;EACzB,MAAM,KAAK,KAAK,KAAK;AACrB,MAAI,UAAU,OAAO,KAAK,KAAK,MAAM,KAAK,IAAK,CAAC,CAAC,UAAU;AAC3D,MAAI,QAAS,KAAK,MAAQ;AAC1B,SAAO;;;;;CAKR,OAAO,SAA0B;AAChC,SAAO,IAAI,KACV,OAAO,KAAK,QAAQ,QAAQ,CAAC,UAAU,GAAG,MAAO,KAAK,KAAK,QAAQ,QAAQ,IAAQ,CACnF;;;;;CAKF,SAAS,MAAuB;EAC/B,MAAM,MAAM,KAAK,QAAQ;E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