{"mappings":"AAEA,cAAc,qBAAqB,sBAA4B;AAG/D,OAAO,UAAU;;;;;;;AAUjB,cACM,aAAa,KAAK;;;;CAItB,AACA;;;;CAKA,AACA;;;;CAKA,AACA,MAAM;;;;CAKN,AACA;;;;CAKA,AACA;CAEA,UAAU;CAEV,UAAU,UAAU,eAAe;CAMnC,UAAU,QAAQ,mBAAmB;;AAavC,eAAe;AACf,SAAS","names":[],"sources":["../../../../src/web-components/time/component.ts"],"sourcesContent":["import { godown } from \"@godown/element\";\nimport fmtime from \"fmtime\";\nimport { type PropertyValues, type TemplateResult, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n\nimport Text from \"../text/component.js\";\n\nconst protoName = \"time\";\n\n/**\n * {@linkcode Time} renders a formatting time.\n *\n * @fires time - Fires when the time changes.\n * @category display\n */\n@godown(protoName)\nclass Time extends Text {\n  /**\n   * Escape symbol.\n   */\n  @property()\n  escape = \"%\";\n\n  /**\n   * Format strings.\n   */\n  @property()\n  format = \"YYYY-MM-DD hh:mm:ss\";\n\n  /**\n   * Time.\n   */\n  @property({ type: Object })\n  time: Date = new Date();\n\n  /**\n   * If there is a value, update every gap or timeout.\n   */\n  @property({ type: Number })\n  timeout: number;\n\n  /**\n   * The number of milliseconds that change with each update.\n   */\n  @property({ type: Number })\n  gap: number;\n\n  protected timeoutId: number;\n\n  protected render(): TemplateResult<1> {\n    return html`\n      <p part=\"root\">${fmtime(this.format, this.time, this.escape)}</p>\n    `;\n  }\n\n  protected updated(changedProperties: PropertyValues): void {\n    if (changedProperties.has(\"timeout\") && this.timeout) {\n      this.timeouts.remove(this.timeoutId);\n      this.timeoutId = this.timeouts.add(\n        setInterval(() => {\n          this.dispatchCustomEvent(\"time\", this.time);\n          this.time = new Date(this.time.getTime() + (this.gap || this.timeout));\n        }, Math.abs(this.timeout)),\n      );\n    }\n  }\n}\n\nexport default Time;\nexport { Time };\n"],"version":3,"file":"component.d.ts"}