import { type ContentTypeMimeType, type Maybe } from '@dereekb/util'; import { type ICalendarIcsString, type ICalendarMethod } from './icalendar'; import { type ICalendarComponent, type ICalendarContentLine } from './icalendar.component'; import { type ICalendar, type ICalendarSerializeConfig } from './icalendar.model'; /** * Returns the number of octets the given string occupies when encoded as UTF-8. * * Computed from the code points directly rather than through a platform encoder, so the serializer stays * free of any Node or browser API. * * @param input - The string to measure. * @returns The UTF-8 octet length. * * @__NO_SIDE_EFFECTS__ */ export declare function utf8OctetLength(input: string): number; /** * Splits a line into the smallest units a fold is allowed to fall between. * * An atom is a single code point, except that a backslash and the character it escapes form one atom. * Iterating by code point (rather than by UTF-16 index) is what keeps a surrogate pair — an emoji — intact; * keeping escape pairs together is defensive, since unfolding restores the octet stream and a split escape is * technically legal, but real-world parsers choke on it. * * @param line - The assembled, already-escaped content line. * @returns The atoms of the line, in order. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarLineAtoms(line: string): readonly string[]; /** * Folds a single assembled content line into physical lines of at most 75 octets each. * * The returned values carry no fold prefix and no line break; see {@link iCalendarFoldedLineString}. * * A continuation line's leading space counts toward the 75-octet limit, so every line after the first has a * payload budget of 74 octets. * * @param line - The assembled, already-escaped content line. * @returns The physical line payloads, in order. Always at least one. * * @__NO_SIDE_EFFECTS__ */ export declare function foldICalendarLine(line: string): readonly string[]; /** * Folds a single assembled content line and joins the result with CRLF-prefixed continuations. * * The result does NOT carry a trailing line break. * * @param line - The assembled, already-escaped content line. * @returns The folded line. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarFoldedLineString(line: string): string; /** * Assembles a content line into its unfolded ICS representation. * * I.E. `DTSTART;TZID=America/Denver:20260315T090000`. Both the parameters and the value are expected to have * been encoded already; this only joins them with the structural delimiters. * * @param line - The content line to assemble. * @returns The unfolded line. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarContentLineToUnfoldedString(line: ICalendarContentLine): string; /** * Serializes a component tree as an RFC 5545 ICS document. * * THE ONLY ICS-AWARE STEP. Everything specific to the text serialization — BEGIN/END wrappers, the `:` and * `;` delimiters, 75-octet folding and CRLF line endings — lives here and nowhere else, so an alternate * serialization of the same data model (jCal, xCal) replaces this function alone. * * @param component - The component tree to serialize. * @returns The ICS document, CRLF-terminated including after the final line. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarComponentToIcsString(component: ICalendarComponent): ICalendarIcsString; /** * Serializes a calendar as an RFC 5545 ICS document. * * @param calendar - The calendar to serialize. * @param config - Optional serialization config, notably the DTSTAMP source. * @returns The ICS document, CRLF-terminated including after the final line. * * @example * ```ts * iCalendarToIcsString({ name: 'My Feed', events: [] }, { now: new Date('2026-03-15T14:00:00Z') }); * ``` * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarToIcsString(calendar: ICalendar, config?: Maybe): ICalendarIcsString; /** * Reverses the 75-octet folding of an ICS document, yielding the logical content lines. * * Useful for validating or re-parsing emitted output. * * @param ics - The ICS document to unfold. * @returns The logical content lines, with the trailing empty line removed. * * @__NO_SIDE_EFFECTS__ */ export declare function unfoldIcsString(ics: ICalendarIcsString): readonly string[]; /** * Builds the Content-Type value an iTIP payload's MIME part must carry. * * The METHOD is duplicated here deliberately: RFC 6047 2.4 requires the `method` parameter to agree with * the METHOD property in the body, and a receiving client decides whether to treat the part as an * invitation from the PART TYPE, before it parses anything. The same bytes typed * `application/octet-stream` are a paperclip. * * @param method - The iTIP method the payload carries. * @returns The full Content-Type value, e.g. `text/calendar; method=REQUEST; charset=utf-8`. * * @example * ```ts * iCalendarITipContentType('REQUEST'); // 'text/calendar; method=REQUEST; charset=utf-8' * ``` * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarITipContentType(method: ICalendarMethod): ContentTypeMimeType;