{"version":3,"file":"index.cjs","names":["ZVerticalAnchor","ZHorizontalAnchor","ZAssert","claim","msg","_messages","push","assert","fail","length","isEnum","enumeration","candidate","Object","values","includes","isEnum","castEnum","enumeration","candidate","fallback","castExtension","candidate","trimmed","trim","normalized","replace","castNumber","candidate","fallback","casted","Number","isNaN","castSupplier","value","ZCookieBuilder","MillisecondsOneDay","_cookie","name","value","val","domain","expires","toJSON","expiresTomorrow","Date","now","immortal","bind","undefined","secure","sameSite","lax","strict","allowCrossSite","httpOnly","authentication","token","builder","build","countBuckets","weight","items","min","max","Infinity","Math","Number","isNaN","NaN","boxes","ceil","createError","problem","schema","Error","i","length","key","Object","prototype","hasOwnProperty","call","String","v4","createGuid","v4","enAU","enCA","enGB","enIE","enIN","enNZ","enUS","enZA","ja","LocaleLookup","code","enAU","enCA","enGB","enIE","enIN","enNZ","enUS","enZA","ja","LocaleLookup","culture","locale","Intl","DateTimeFormat","resolvedOptions","cultures","Object","keys","userTimeZone","Intl","DateTimeFormat","resolvedOptions","timeZone","timeZones","supportedValuesOf","TZDate","parse","startOfToday","culture","culture$","LocaleLookup","ZDateFormats","userTimeZone","parseDateTime","value","options","fallback","candidate","Date","Number","isNaN","getTime","format","Iso","timeZone","locale","reference","withTimeZone","result","culture$","culture","TZDate","startOfToday","parse","ZDateFormats","parseDateTime","guessDateTime","value","options","fallback","supportedFormats","Object","values","fmt","inner","format","result","TZDate","formatDate","culture","culture$","LocaleLookup","guessDateTime","userTimeZone","ZDateFormats","formatDateTime","value","options","format","timeZone","fallback","date","Date","Number","isNaN","getTime","withTz","locale","culture$","TZDate","formatDate","culture","detokenize","tokenized","tokens","replace","_","tokenName","value","undefined","ZEmailEnvelopeBuilder","_envelope","from","val","to","push","tos","cc","ccs","bcc","bccs","assign","other","Object","JSON","parse","stringify","copy","build","ZEmailEnvelopeBuilder","ZEmailBuilder","_email","envelope","build","val","subject","message","assign","other","Object","JSON","parse","stringify","copy","ZEmailContactBuilder","_contact","address","val","type","display","assign","other","Object","JSON","parse","stringify","copy","build","ZEmailContactAddressBuilder","_addresses","_delimiter","address","val","push","addresses","slice","delimiter","build","addr","ct","undefined","truthy","map","filter","join","isEmptyObject","candidate","candidateType","Object","keys","length","ZEnumInfoBuilder","_metadata","value","name","description","avatar","build","BYTES_PER_KIBIBYTE","BYTES_PER_MEBIBYTE","BYTES_PER_GIBIBYTE","BYTES_PER_TEBIBYTE","BYTES_PER_PEBIBYTE","bytes","bytesPerUnit","amount","Math","ceil","kibibytes","bind","kib","mebibytes","mib","gibibytes","gib","tebibytes","tib","pebibytes","pib","firstWhere","predicate","fallback","first","remaining","i","length","val","firstDefined","v","firstTruthy","isEmptyObject","firstDefined","ZQuadrilateralBuilder","_quad","start","bottom","left","right","top","x","y","from","other","isPoint2d","candidate","Object","prototype","hasOwnProperty","call","isQuadrilateral","copy","build","structuredClone","isEmptyObject","firstDefined","ZQuadrilateralCornersBuilder","_corners","start","bottomLeft","bottomRight","topLeft","topRight","value","bottom","left","right","top","from","other","isVerticals","candidate","Object","prototype","hasOwnProperty","call","isHorizontals","isCorners","copy","structuredClone","build","ZHorizontalAnchor","ZVerticalAnchor","ZQuadrilateralBuilder","ZRectangle","sides","width","left","right","height","top","bottom","area","attach","anchor","candidate","candidateAnchor","_candidate","x","ax","y","ay","point","ox","oy","build","offsetToFit","candidateRectangle","cx","middleCenter","tx","copy","cy","ty","vertical","horizontal","v","Top","Middle","Bottom","h","Left","Center","Right","topLeft","bind","topCenter","topRight","middleLeft","middleRight","bottomLeft","bottomCenter","bottomRight","$global","globalThis","joinDefined","delimiter","items","map","item","Array","filter","join","spaceJoinDefined","bind","cssJoinDefined","commaJoinDefined","semiColonJoinDefined","pipeJoinDefined","ZLazy","_value","_factory","initialized","get","required","val","Error","_val","optional","fallback","ZOrientation","peel","str","candidates","check","startsWith","substring","length","peelBetween","open","close","stack","_str","i","pickBy","predicate","target","keys","Object","reduced","forEach","key","value","pickDefined","_","v","pickDataAttributes","k","String","startsWith","pickEvents","purge","obj","property","undefined","ZDeserializeJson","_schema","deserialize","candidate","parsed","JSON","parse","Error","ZDeserializeTry","_children","deserialize","candidate","errors","child","e","push","message","msg","JSON","stringify","splice","Error","join","ZSerializeJson","serialize","candidate","JSON","stringify","undefined","ZServerBuilder","_server","address","val","port","username","password","assign","other","Object","copy","JSON","parse","stringify","build","setFirst","setValue","fallback","value","_value","length","sleep","ms","val","undefined","Promise","resolve","setTimeout","tag","strings","expressions","result","i","l","length","String","html","css","js","javascript","md","markdown","ts","typescript","sh","bash","zsh","tryFallback","candidate","fallback","tryFallbackAsync","tryFallback","tryJsonParse","buffer","fallback","firstChar","JSON","parse"],"sources":["../src/anchor/anchor.mts","../src/assert/assert.mts","../src/enum/is-enum.mts","../src/cast/cast-enum.mts","../src/cast/cast-extension.mts","../src/cast/cast-number.mts","../src/cast/cast-supplier.mts","../src/cookie/cookie.mts","../src/count-buckets/count-buckets.mts","../src/create-error/create-error.mts","../src/create-guid/create-guid.mts","../src/culture/locale-lookup.mts","../src/culture/culture.mts","../src/date/timezone.mts","../src/date/parse-date.mts","../src/date/guess-date.mts","../src/date/format-date.mts","../src/detokenize/detokenize.mts","../src/email/email-envelope.mts","../src/email/email.mts","../src/email/email-contact.mts","../src/email/email-contact-address.mts","../src/empty/is-empty-object.mts","../src/enum/enum-info.mts","../src/file-size/file-size.mts","../src/first-where/first-where.mts","../src/geometry/quadrilateral.mts","../src/geometry/quadrilateral-corners.mts","../src/geometry/rectangle.mts","../src/global/global.mts","../src/join-defined/join-defined.mts","../src/lazy/lazy.mts","../src/obligation/obligation.mts","../src/orientation/orientation.mts","../src/peel/peel.mts","../src/pick/pick.mts","../src/purge/purge.mts","../src/serialize/deserialize-json.mts","../src/serialize/deserialize-try.mts","../src/serialize/serialize-json.mts","../src/server/server.mts","../src/set-first/set-first.mts","../src/sleep/sleep.mts","../src/tag/tag.mts","../src/try/try-fallback.mts","../src/try/try-json-parse.mts"],"sourcesContent":["/**\n * Represents a targeted point along a y axis.\n */\nexport enum ZVerticalAnchor {\n  /**\n   * Top boundary.\n   *\n   * In vertical device space, this would equate to y = 0.\n   */\n  Top = \"top\",\n  /**\n   * Centerpoint between the top and bottom.\n   */\n  Middle = \"middle\",\n  /**\n   * Bottom boundary.\n   *\n   * In vertical device space, this would equate to y = Infinity.\n   */\n  Bottom = \"bottom\",\n}\n\n/**\n * Represents a targeted point along an x axis.\n */\nexport enum ZHorizontalAnchor {\n  /**\n   * Left boundary.\n   *\n   * In horizontal device space, this would equate to x = 0.\n   */\n  Left = \"left\",\n  /**\n   * Centerpoint between the left and right boundary.\n   */\n  Center = \"center\",\n  /**\n   * Right boundary.\n   *\n   * In horizontal device space, this would equate to x = Infinity.\n   */\n  Right = \"right\",\n}\n\n/**\n * Represents an anchor point in 2d space.\n *\n * An anchor array is defined by [vertical, horizontal]\n * and is read as such.\n *\n * @example\n *\n * ```ts\n * const topCenter = [ZVerticalAnchor.Top, ZHorizontalAnchor.Center];\n * const bottomRight = [ZVerticalAnchor.Bottom, ZHorizontalAnchor.Right];\n * ```\n *\n * @see {@link ZVerticalAnchor} For more information.\n * @see {@link ZHorizontalAnchor} For more information.\n */\nexport type ZAnchor = [ZVerticalAnchor, ZHorizontalAnchor];\n\n/**\n * Represents a special type of anchor that excludes the center points.\n */\nexport type ZSideAnchor =\n  | ZVerticalAnchor.Top\n  | ZVerticalAnchor.Bottom\n  | ZHorizontalAnchor.Left\n  | ZHorizontalAnchor.Right;\n","/**\n * Represents an object that can be used to build a list of assertions.\n *\n * @example\n *\n * ```ts\n * import { ZAssert, createError } from '@zthun/helpful-fn';\n *\n * const user = readUser();\n *\n * ZAssert\n *  .claim(user.name != null, 'User name is required')\n *  .claim(user.email != null, 'User email is required')\n *  .assert((m) => createError(m));\n * ```\n */\nexport class ZAssert {\n  /**\n   * Initializes a new instance of a ZAssert with one claim.\n   *\n   * @param claim -\n   *        The claim to make.\n   * @param msg -\n   *        The message to throw if the claim is false.\n   *\n   * @returns\n   *        A new ZAssert object with an initial claim.\n   */\n  public static claim(claim: boolean, msg: any): ZAssert {\n    return new ZAssert().claim(claim, msg);\n  }\n\n  private _messages: any[] = [];\n\n  /**\n   * Initializes a new instance of this object.\n   */\n  private constructor() {}\n\n  /**\n   * Adds a claim.\n   *\n   * @param claim -\n   *        The claim predicate.\n   * @param msg -\n   *        The message to add if the claim fails.\n   *\n   * @returns This object.\n   */\n  public claim(claim: boolean, msg: any): this {\n    if (!claim) {\n      this._messages.push(msg);\n    }\n    return this;\n  }\n\n  /**\n   * Runs the assertion.\n   *\n   * @param fail -\n   *        The factory that is responsible for returning the specified error to throw.\n   */\n  public assert<E extends Error>(fail: (message: any) => E): void {\n    if (this._messages.length === 1) {\n      throw fail(this._messages[0]);\n    }\n\n    if (this._messages.length) {\n      throw fail(this._messages);\n    }\n  }\n}\n","/**\n * Gets whether the candidate can represent an enumeration object of type TEnum.\n *\n * This is mostly helpful for type guarding value options in a type.\n *\n * @param enumeration -\n *        The enumeration object that contains the values.\n * @param candidate -\n *        The candidate to check.\n *\n * @returns\n *        True if candidate can represents one of the white listed\n *        object values in enumeration.\n */\nexport function isEnum<TEnum extends Record<string, string | number>>(\n  enumeration: TEnum,\n  candidate: unknown,\n): candidate is TEnum[keyof TEnum] {\n  return (\n    candidate != null &&\n    (typeof candidate === \"string\" || typeof candidate === \"number\") &&\n    Object.values(enumeration).includes(candidate)\n  );\n}\n","import { isEnum } from \"../enum/is-enum.mjs\";\n\n/**\n * Attempts to cast the candidate to an enumeration value.\n *\n * @param enumeration -\n *        The enumeration type.\n * @param candidate -\n *        The candidate to cast to the enum type.\n *\n * @returns\n *        The candidate if candidate represents the enumeration type,\n *        or undefined in the case that it does not.\n */\nexport function castEnum<TEnum extends Record<string, string | number>>(\n  enumeration: TEnum,\n  candidate: unknown,\n): TEnum[keyof TEnum] | undefined;\n\n/**\n * Attempts to cast the candidate to an enumeration value.\n *\n * @param enumeration -\n *        The enumeration type.\n * @param candidate -\n *        The candidate to cast to the enum type.\n * @param fallback -\n *        The fallback to use in the case that candidate\n *        cannot represent the enumeration type.\n *\n * @returns\n *        The candidate if candidate represents the enumeration type,\n *        or fallback in the case that it does not.\n */\nexport function castEnum<TEnum extends Record<string, string | number>>(\n  enumeration: TEnum,\n  candidate: unknown,\n  fallback: TEnum[keyof TEnum],\n): TEnum[keyof TEnum];\n\n/**\n * Attempts to cast the candidate to an enumeration value.\n *\n * @param enumeration -\n *        The enumeration type.\n * @param candidate -\n *        The candidate to cast to the enum type.\n * @param fallback -\n *        The fallback to use in the case that candidate\n *        cannot represent the enumeration type.\n *\n * @returns\n *        The candidate if candidate represents the enumeration type,\n *        or fallback in the case that it does not.\n */\nexport function castEnum<TEnum extends Record<string, string | number>>(\n  enumeration: TEnum,\n  candidate: unknown,\n  fallback?: TEnum[keyof TEnum],\n): TEnum[keyof TEnum] | undefined {\n  return isEnum(enumeration, candidate) ? candidate : fallback;\n}\n","import type { ZOptional } from \"../optional/optional.mjs\";\n\n/**\n * Puts a . in front of name if one is not already there.\n *\n * If there are multiple dots in front of name, then\n * all dots but one is removed.\n *\n * @example\n *\n * ```ts\n * // Outputs .zip\n * castExtension('zip');\n *\n * // Outputs .zip\n * castExtension('.zip');\n *\n * // Outputs .zip\n * castExtension('...zip');\n * ```\n *\n * @param candidate -\n *        The candidate extension\n *\n * @returns\n *        The candidate prepended by a single dot.\n *        If candidate is undefined, null, the empty\n *        string, white space, or nothing but dots,\n *        then the empty string is returned.\n */\nexport function castExtension(candidate: ZOptional<string>): string {\n  if (candidate == null) {\n    return \"\";\n  }\n\n  const trimmed = candidate.trim();\n\n  if (!trimmed) {\n    return \"\";\n  }\n\n  const normalized = trimmed.replace(/^\\.+/, \"\");\n\n  if (!normalized) {\n    return \"\";\n  }\n\n  return `.${normalized}`;\n}\n","/**\n * Attempts to cast candidate to a number.\n *\n * This method assumes you want an actual number and\n * not NaN.  In the case that candidate results in\n * NaN, then the fallback condition applies.\n *\n * @param candidate -\n *        The candidate to cast.\n *\n * @returns\n *        The casted number or undefined in the cast\n *        that casting candidate would result in NaN.\n */\nexport function castNumber(candidate: unknown): number | undefined;\n\n/**\n * Attempts to cast candidate to a number.\n *\n * This method assumes you want an actual number and\n * not NaN.  In the case that candidate results in\n * NaN, then the fallback condition applies.\n *\n * @param candidate -\n *        The candidate to cast.\n * @param fallback -\n *        The fallback value in the case that the result\n *        of casting candidate would result in NaN\n *\n * @returns\n *        The casted number or fallback in the cast\n *        that casting candidate would result in NaN.\n */\nexport function castNumber(candidate: unknown, fallback: number): number;\n\n/**\n * Attempts to cast candidate to a number.\n *\n * This method assumes you want an actual number and\n * not NaN.  In the case that candidate results in\n * NaN, then the fallback condition applies.\n *\n * @param candidate -\n *        The candidate to cast.\n * @param fallback -\n *        The fallback value in the case that the result\n *        of casting candidate would result in NaN\n *\n * @returns\n *        The casted number or fallback in the cast\n *        that casting candidate would result in NaN.\n */\nexport function castNumber(\n  candidate: unknown,\n  fallback?: number,\n): number | undefined {\n  try {\n    const casted = Number(candidate);\n    return Number.isNaN(casted) ? fallback : casted;\n  } catch {\n    return fallback;\n  }\n}\n","import type { ZSupplier, ZSupplierMaybe } from \"../function/supplier.mjs\";\n\n/**\n * Casts a value to a callback supplier function.\n *\n * Please note that if you force pass a function with arguments, the\n * same function is returned, even though that would not be a valid\n * supplier function.  This is mostly for named as castSupplier\n * for semantics and typescript checking.\n *\n * @param value -\n *        The value to cast to a supplier function.\n *\n * @returns\n *        The value as a guaranteed supplier.\n */\nexport function castSupplier<T>(value: ZSupplierMaybe<T>): ZSupplier<T> {\n  return typeof value === \"function\" ? (value as ZSupplier<T>) : () => value;\n}\n","/**\n * Represents a generic cookie.\n */\nexport interface IZCookie {\n  /**\n   * The cookie name.\n   */\n  name: string;\n  /**\n   * The cookie value.\n   */\n  value: string;\n  /**\n   * The scope domain attached to the cookie.\n   */\n  domain?: string;\n  /**\n   * The utc formatted date at which the cookie expires\n   */\n  expires?: string;\n  /**\n   * A flag that determines if this is a secure cookie.\n   */\n  secure?: boolean;\n  /**\n   * A flag that determines if this cookie can be ready by javascript.\n   */\n  httpOnly?: boolean;\n  /**\n   * A value that determines how the cookie is sent by the browser.\n   */\n  sameSite?: \"lax\" | \"strict\" | \"none\";\n}\n\n/**\n * Represents a builder for an IZCookie object.\n */\nexport class ZCookieBuilder {\n  public static readonly MillisecondsOneDay = 86400000;\n\n  private _cookie: IZCookie;\n\n  /**\n   * Initializes a new instance of this object.\n   */\n  public constructor() {\n    this._cookie = {\n      name: \"\",\n      value: \"\",\n    };\n  }\n\n  /**\n   * Sets the cookie name.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public name(val: string): this {\n    this._cookie.name = val;\n    return this;\n  }\n\n  /**\n   * Sets the cookie value.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public value(val: string): this {\n    this._cookie.value = val;\n    return this;\n  }\n\n  /**\n   * Sets the cookie domain.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public domain(val: string | undefined): this {\n    this._cookie.domain = val;\n    return this;\n  }\n\n  /**\n   * Sets the cookie expiration date.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public expires(val: Date | string | undefined): this {\n    if (val == null) {\n      delete this._cookie.expires;\n      return this;\n    }\n\n    this._cookie.expires = typeof val === \"string\" ? val : val.toJSON();\n    return this;\n  }\n\n  /**\n   * Sets the cookie expiration date to one day from the moment this is invoked.\n   *\n   * @returns\n   *        This object.\n   */\n  public expiresTomorrow(): this {\n    return this.expires(\n      new Date(Date.now() + ZCookieBuilder.MillisecondsOneDay),\n    );\n  }\n\n  /**\n   * Removes the cookie expiration.\n   *\n   * @returns\n   *        This object.\n   */\n  public immortal: () => this = this.expires.bind(this, undefined);\n\n  /**\n   * Sets the cookie secure flag.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public secure(val = true): this {\n    this._cookie.secure = val;\n    return this;\n  }\n\n  /**\n   * Sets the cookie same site policy.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public sameSite(val: \"lax\" | \"strict\" | \"none\"): this {\n    this._cookie.sameSite = val;\n    return this;\n  }\n\n  /**\n   * Sets the same site policy to 'lax'\n   *\n   * @returns\n   *        This object.\n   */\n  public lax = this.sameSite.bind(this, \"lax\");\n\n  /**\n   * Sets the same site polity to 'strict'\n   *\n   * @returns\n   *        This object.\n   */\n  public strict = this.sameSite.bind(this, \"strict\");\n\n  /**\n   * Sets the same site policy to 'none' and turns on the secure flag.\n   *\n   * @returns\n   *        This object.\n   */\n  public allowCrossSite(): this {\n    return this.secure().sameSite(\"none\");\n  }\n\n  /**\n   * Sets the cookie http only flag.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public httpOnly(val = true): this {\n    this._cookie.httpOnly = val;\n    return this;\n  }\n\n  /**\n   * Creates a token based authentication cookie.\n   *\n   * @param token -\n   *        The token value for the cookie.  You\n   *        can leave this as undefined to set it\n   *        later.\n   *\n   * @returns\n   *        This object.\n   */\n  public authentication(token?: string): this {\n    const builder = this.name(\"Authentication\")\n      .expiresTomorrow()\n      .secure()\n      .httpOnly();\n    return token == null ? builder : builder.value(token);\n  }\n\n  /**\n   * Returns a copy of the built instance of the cookie.\n   *\n   * @returns\n   *        A shallow copy of the current cookie object.\n   */\n  public build(): IZCookie {\n    return { ...this._cookie };\n  }\n}\n","/**\n * Calculates the total number of buckets you need to\n * store a number of items where each bucket can hold a\n * maximum weight of items.\n *\n * You can use this function to calculate groupings of\n * items based on total counts and sizes.  A good example\n * usage would be to calculate the total number of pages\n * on a paginated list of items given a page size and item\n * count.\n *\n * @param weight -\n *        The maximum weight a bucket can store.  If this value receives\n *        Infinity, then it will result in 1 or min buckets being returned,\n *        whichever is larger.  If this receives NaN, then this method will\n *        result in NaN.  Finally, if this receives a negative value, then\n *        the result will be max.\n * @param items -\n *        The total number of items you need to store where each item\n *        counts as 1 towards the weight.  If the total number of items\n *        is Infinity, then this method will result in max buckets.\n *        If this receives NaN, then this method will result in NaN. Finally,\n *        if you pass 0, or a negative number of items, then result will be min.\n * @param min -\n *        The bounded minimum value.  If the total number of buckets\n *        evaluates to less than this value, then this value is returned.\n *        The default is 0.\n * @param max -\n *        The bounded maximum value.  If the total number of buckets\n *        evaluates to more than this value, then this value is returned.\n *        The default is Infinity.\n *\n * @returns\n *        The number of buckets you need to store the total number\n *        of items given that a single bucket can hold a max weight of items.\n *        If either weight or items is NaN, then NaN will be returned regardless\n *        of the opposite value.  Passing a negative number is the same as\n *        passing 0.\n *\n * @example\n *\n * ```ts\n * // The following will return 5 for numberOfPages since you need 5 buckets\n * // to store 101 number of items where each bucket can hold a max of 25\n * // items.  The 5th page would be a page of 1 item, since 1 is the remainder.\n * const numberOfPages = countBuckets(25, 101);\n *\n * // In this case, the numberOfPages would be 1 here since our minimum buckets\n * // is 1.  By default, this would be 0.\n * const numberOfPages = countBuckets(10, 0, 1);\n *\n * // In this case, we have more items that can be held in the number of buckets\n * // available, so only 4 is returned instead of the 5.\n * const numberOfPages = countBuckets(25, 101, undefined, 4);\n * ```\n */\nexport function countBuckets(\n  weight: number,\n  items: number,\n  min = 0,\n  max = Infinity,\n) {\n  weight = Math.max(0, weight);\n  items = Math.max(0, items);\n\n  if (Number.isNaN(weight) || Number.isNaN(items)) {\n    return NaN;\n  }\n\n  if (items === 0) {\n    return min;\n  }\n\n  const boxes = weight === Infinity ? 1 : Math.ceil(items / weight);\n  return Math.min(max, Math.max(min, boxes));\n}\n","/**\n * A helper method to construct a JavaScript error object given a list of acceptable schema keys.\n *\n * @param problem -\n *        A generic representation of the problem that occurred.  This can be an Error object,\n *        another object representing some kind of error, or some message representing the error.\n *        If this is null or undefined, then a generic error is returned.\n * @param schema -\n *        The list of acceptable object keys to look into problem.  These will be recursively\n *        evaluated to strip out the real error message.  Note that this is in order of\n *        priority.  If schema[0] and schema[1] are both keys on problem, then schema[0] takes\n *        a higher precedence than schema[1].  By default, the schema will look for properties\n *        named, message, error, exception, and data, in that order.\n *\n * @returns\n *        An error object that is the best evaluation of what the problem actually is.\n *\n * @example\n *\n * ```ts\n * // All of these result an Error with the message, 'Something went wrong'\n * const errorWithStringProblem = createError('Something went wrong');\n * const errorWithObjectProblemInSchema = createError({ error: 'Something went wrong'});\n * const errorWithCustomSchema = createError({ issue: 'Something went wrong'}, ['issue']);\n * const errorRecursive = createError({ error: { message: 'Something went wrong' }});\n *\n * // This would result in '[Object object]' as there is no way to figure out how to deconstruct this problem.\n * const errorCannotBeFound = createError({ wut: 'Something went wrong' });\n * ```\n */\nexport function createError(\n  problem: any,\n  schema = [\"message\", \"error\", \"exception\", \"data\"],\n): Error {\n  if (problem instanceof Error) {\n    return problem;\n  }\n\n  if (problem == null) {\n    return new Error();\n  }\n\n  for (let i = 0; i < schema.length; ++i) {\n    const key = schema[i];\n\n    if (Object.prototype.hasOwnProperty.call(problem, key)) {\n      return createError(problem[key]);\n    }\n  }\n\n  return new Error(String(problem));\n}\n","import { v4 } from \"uuid\";\n\n/**\n * Creates a globally unique identifier.\n *\n * The identifier holds to v4 of the UUID specification.  A summary\n * of the specification can be found at\n * {@link https://commons.apache.org/sandbox/commons-id/uuid.html | Apache Commons UUID Documentation}.\n *\n * The official documentation of the UUID specification is under\n * {@link https://www.rfc-editor.org/info/rfc4122 | RFC 4122}\n *\n * @returns\n *        A new generated globally unique identifier based on random bytes.\n *\n * @example\n *\n * ```ts\n * // Will get a value similar to 53e33fb6-d05a-4fa9-8dc0-b78e4feaa702\n * const guidA = createGuid();\n * // Will most likely not ever be equal to guidA\n * const guidB = createGuid();\n * ```\n */\nexport const createGuid: () => string = v4;\n","import {\n  enAU,\n  enCA,\n  enGB,\n  enIE,\n  enIN,\n  enNZ,\n  enUS,\n  enZA,\n  ja,\n} from \"date-fns/locale\";\n\n/**\n * Supported locales from date-fns.\n *\n * This should not be exported.  This is an internal helper.\n */\nexport const LocaleLookup = {\n  [enAU.code]: enAU,\n  [enCA.code]: enCA,\n  [enGB.code]: enGB,\n  [enIE.code]: enIE,\n  [enIN.code]: enIN,\n  [enNZ.code]: enNZ,\n  [enUS.code]: enUS,\n  [enZA.code]: enZA,\n  [ja.code]: ja,\n};\n","import { LocaleLookup } from \"./locale-lookup.mjs\";\n\n/**\n * Returns the users current culture (locale).\n *\n * @returns\n *        The current locale.\n */\nexport function culture() {\n  const locale = Intl.DateTimeFormat().resolvedOptions().locale;\n  return locale;\n}\n\n/**\n * Returns all supported cultures.\n *\n * @returns\n *        A list of currently supported culture codes.\n */\nexport function cultures() {\n  return Object.keys(LocaleLookup);\n}\n","/**\n * Returns the user's current timezone.\n *\n * @returns\n *        The users current timezone.\n */\nexport function userTimeZone(): string {\n  return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\n/**\n * Returns the list of all supported timezones.\n *\n * @returns\n *        A list of all timezone values.\n */\nexport function timeZones(): string[] {\n  return Intl.supportedValuesOf(\"timeZone\");\n}\n","import { TZDate } from \"@date-fns/tz\";\nimport { parse, startOfToday } from \"date-fns\";\n\nimport { culture as culture$ } from \"../culture/culture.mjs\";\nimport { LocaleLookup } from \"../culture/locale-lookup.mjs\";\nimport type { ZDateTime, ZDateTimeOptions } from \"../date/date-time.mjs\";\nimport { ZDateFormats } from \"./format-date.mjs\";\nimport { userTimeZone } from \"./timezone.mjs\";\n\n/**\n * Parses a string value back to a date format.\n *\n *\n * @param value -\n *        The value to parse\n * @param options -\n *        The options to parse with.  The most important option here is format.\n *        If the format is not specified, then the standard zoned ISO 8601\n *        format is used.  The timezone is also used in the case the date\n *        does not supply it for string values.  If the timezone is not specified\n *        then the users timezone is assumed.  Finally, the cultural local will\n *        default to the users current culture if not specified.\n *\n * @returns\n *        The date object parsed from the value.  Returns null\n *        if the value parsed with the given options results in an\n *        invalid date.\n */\nexport function parseDateTime(\n  value: ZDateTime,\n  options: ZDateTimeOptions<Date | null> = {},\n): Date | null {\n  const { fallback = null } = options;\n\n  if (value == null) {\n    return fallback;\n  }\n\n  if (typeof value === \"number\") {\n    const candidate = new Date(value);\n    return Number.isNaN(candidate.getTime()) ? fallback : candidate;\n  }\n\n  if (value instanceof Date) {\n    return Number.isNaN(value.getTime()) ? fallback : value;\n  }\n\n  const {\n    format = ZDateFormats.Iso,\n    culture = culture$(),\n    timeZone = userTimeZone(),\n  } = options;\n\n  const locale = LocaleLookup[culture];\n  const reference = new TZDate(startOfToday()).withTimeZone(timeZone);\n  const result = parse(value, format, reference, { locale });\n\n  return Number.isNaN(result.getTime()) ? fallback : result;\n}\n","import type { ZDateTime, ZDateTimeOptions } from \"../date/date-time.mjs\";\nimport { ZDateFormats } from \"./format-date.mjs\";\nimport { parseDateTime } from \"./parse-date.mjs\";\n\n/**\n * Similar to {@link parseDateTime} but tries multiple supported formats.\n *\n * @param value -\n *        The value to parse that may result in a date.\n * @param options -\n *        The options for guessing the date.  These will be forwarded to parse\n *        for processing.\n */\nexport function guessDateTime(\n  value: ZDateTime,\n  options: ZDateTimeOptions<Date | null> = {},\n): Date | null {\n  const { fallback = null } = options;\n\n  if (value == null) {\n    return fallback;\n  }\n\n  const { supportedFormats = Object.values(ZDateFormats) } = options;\n\n  for (const fmt of supportedFormats) {\n    const inner = { ...options };\n    inner.format = fmt;\n    const result = parseDateTime(value, inner);\n\n    if (result != null) {\n      return result;\n    }\n  }\n\n  return fallback;\n}\n","import { TZDate } from \"@date-fns/tz\";\nimport { formatDate } from \"date-fns\";\n\nimport { culture as culture$ } from \"../culture/culture.mjs\";\nimport { LocaleLookup } from \"../culture/locale-lookup.mjs\";\nimport type { ZDateTime, ZDateTimeOptions } from \"../date/date-time.mjs\";\nimport { guessDateTime } from \"./guess-date.mjs\";\nimport { userTimeZone } from \"./timezone.mjs\";\n\n/**\n * Basic date formats that are common for storage and usage.\n */\nexport enum ZDateFormats {\n  /**\n   * Standard {@link https://en.wikipedia.org/wiki/ISO_8601 | ISO-8601} format with date only.\n   *\n   * Using this should imply midnight user timezone.\n   */\n  IsoDateOnly = `yyyy-MM-dd`,\n  /**\n   * Standard {@link https://en.wikipedia.org/wiki/ISO_8601 | ISO-8601} format with time only.\n   */\n  IsoTimeOnly = `HH:mm:ss.SSS`,\n  /**\n   * Standard {@link https://en.wikipedia.org/wiki/ISO_8601 | ISO-8601} format without timezone specifier.\n   */\n  IsoNoTimeZone = `${IsoDateOnly}'T'${IsoTimeOnly}`,\n  /**\n   * Standard {@link https://en.wikipedia.org/wiki/ISO_8601 | ISO-8601} format.\n   */\n  Iso = `${IsoNoTimeZone}XX`,\n  /**\n   * Users local date (locale specific).\n   */\n  LocalDate = \"P\",\n  /**\n   * User local time (locale specific).\n   */\n  LocalTime = \"p\",\n  /**\n   * Date and time formatted with user specific locale.\n   */\n  LocalDateTime = \"Pp\",\n}\n\n/**\n * Formats a given value.\n *\n * @param value -\n *        The value to format.\n * @param options -\n *        The given options for the format.\n *\n * @returns\n *        If value is null or undefined, then the empty string is returned.\n *        If value is a string, then the date is guessed from the string and\n *        reformatted to the format specified by options.  Otherwise,\n *        the date or number specified by value is formatted to the culture,\n *        timezone, and format specified in the options.\n */\nexport function formatDateTime(\n  value: ZDateTime,\n  options: ZDateTimeOptions<string> = {},\n): string {\n  const {\n    format = ZDateFormats.LocalDateTime,\n    culture = culture$(),\n    timeZone = userTimeZone(),\n    fallback = \"\",\n  } = options;\n\n  let date: Date | null;\n\n  if (value == null) {\n    date = null;\n  } else if (typeof value === \"string\") {\n    date = guessDateTime(value, { ...options, fallback: null });\n  } else {\n    date = new Date(value);\n  }\n\n  if (date == null || Number.isNaN(date.getTime())) {\n    return fallback;\n  }\n\n  const withTz = new TZDate(date, timeZone);\n\n  return formatDate(withTz, format, {\n    locale: LocaleLookup[culture],\n  });\n}\n","import type { ZOptional } from \"../optional/optional.mjs\";\n\n/**\n * Does replacement of interpolation, ${}, tokens in a string.\n *\n * @param tokenized -\n *        The string that can contain interpolation tokens.\n * @param tokens -\n *         The tokens to replace.\n *\n * @returns\n *         A detokenized string that replaces the tokens with the values\n *         in the token dictionary.  If a value is missing in the token dictionary,\n *         then the tokens are preserved.  If the value of a token is null or\n *         undefined explicitly, then any tokens in the tokenized string are\n *         removed for that value.\n */\nexport function detokenize(\n  tokenized: ZOptional<string>,\n  tokens: Record<string, ZOptional<string>>,\n) {\n  if (tokenized == null) return \"\";\n\n  return tokenized.replace(/\\$\\{([^}]+)\\}/g, (_, tokenName) => {\n    if (tokenName in tokens) {\n      const value = tokens[tokenName];\n      if (value === null || value === undefined) {\n        return \"\";\n      }\n      return value;\n    }\n    return `\\${${tokenName}}`; // leave token intact if not present in tokens\n  });\n}\n","import type { IZEmailContact } from \"./email-contact.mjs\";\n\n/**\n * Represents an email envelope of information about who the email is from and where it's going to.\n */\nexport interface IZEmailEnvelope {\n  /**\n   * Who the email is from.\n   *\n   * This can be the full contact or just the address.\n   */\n  from: IZEmailContact | string;\n\n  /**\n   * Where the email is going.\n   *\n   * This can be falsy if cc is filled out.\n   */\n  to?: Array<IZEmailContact | string>;\n\n  /**\n   * Who is receiving a carbon copy of the email.\n   *\n   * This can be falsy if to is filled out.\n   */\n  cc?: Array<IZEmailContact | string>;\n\n  /**\n   * Who is receiving a blind carbon copy of an email.\n   */\n  bcc?: Array<IZEmailContact | string>;\n}\n\n/**\n * Represents a builder for an email envelope.\n */\nexport class ZEmailEnvelopeBuilder {\n  private _envelope: IZEmailEnvelope;\n\n  /**\n   * Initializes a new instance of this object.\n   */\n  public constructor() {\n    this._envelope = {\n      from: \"\",\n    };\n  }\n\n  /**\n   * Sets the from field.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public from(val: IZEmailContact | string): this {\n    this._envelope.from = val;\n    return this;\n  }\n\n  /**\n   * Adds a value to the 'to' field.\n   *\n   * @param val -\n   *        The value to add.\n   *\n   * @returns\n   *        This object.\n   */\n  public to(val: IZEmailContact | string): this {\n    this._envelope.to = this._envelope.to || [];\n    this._envelope.to.push(val);\n    return this;\n  }\n\n  /**\n   * Sets the to field.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public tos(val: Array<IZEmailContact | string>): this {\n    this._envelope.to = val;\n    return this;\n  }\n\n  /**\n   * Adds a value to the cc field.\n   *\n   * @param val -\n   *        The value to add.\n   *\n   * @returns\n   *        This object.\n   */\n  public cc(val: IZEmailContact | string): this {\n    this._envelope.cc = this._envelope.cc || [];\n    this._envelope.cc.push(val);\n    return this;\n  }\n\n  /**\n   * Sets the cc field.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public ccs(val: Array<IZEmailContact | string>): this {\n    this._envelope.cc = val;\n    return this;\n  }\n\n  /**\n   * Adds a value to the bcc field.\n   *\n   * @param val -\n   *        The value to add.\n   *\n   * @returns\n   *        This object.\n   */\n  public bcc(val: IZEmailContact | string): this {\n    this._envelope.bcc = this._envelope.bcc || [];\n    this._envelope.bcc.push(val);\n    return this;\n  }\n\n  /**\n   * Sets the bcc field.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public bccs(val: Array<IZEmailContact | string>): this {\n    this._envelope.bcc = val;\n    return this;\n  }\n\n  /**\n   * Assigns another partial email envelope to this object.\n   *\n   * @param other -\n   *        The value to partial copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public assign(other: Partial<IZEmailEnvelope>): this {\n    this._envelope = Object.assign({}, this._envelope, other);\n    this._envelope = JSON.parse(JSON.stringify(this._envelope));\n    return this;\n  }\n\n  /**\n   * Copies another email envelope to this object.\n   *\n   * @param other -\n   *        The value to copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public copy(other: IZEmailEnvelope): this {\n    this._envelope = JSON.parse(JSON.stringify(other));\n    return this;\n  }\n\n  /**\n   * Returns a copy of the built envelope.\n   *\n   * @returns\n   *        A copy of the currently built up envelope object.\n   */\n  public build(): IZEmailEnvelope {\n    return JSON.parse(JSON.stringify(this._envelope));\n  }\n}\n","import type { IZEmailEnvelope } from \"./email-envelope.mjs\";\nimport { ZEmailEnvelopeBuilder } from \"./email-envelope.mjs\";\n\n/**\n * Represents an email message.\n */\nexport interface IZEmail {\n  /**\n   * The email envelope of where the email is going to.\n   */\n  envelope: IZEmailEnvelope;\n\n  /**\n   * The subject (title) of the email.\n   */\n  subject?: string;\n\n  /**\n   * The message to send.\n   */\n  message?: string;\n}\n\n/**\n * Represents a builder for an email.\n */\nexport class ZEmailBuilder {\n  private _email: IZEmail;\n\n  /**\n   * Initializes a new instance of this object.\n   */\n  public constructor() {\n    this._email = {\n      envelope: new ZEmailEnvelopeBuilder().build(),\n    };\n  }\n\n  /**\n   * Sets the envelope of where the email is going.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public envelope(val: IZEmailEnvelope): this {\n    this._email.envelope = val;\n    return this;\n  }\n\n  /**\n   * Sets the subject line of the email.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public subject(val: string): this {\n    this._email.subject = val;\n    return this;\n  }\n\n  /**\n   * Sets the message of the email.\n   *\n   * The message can be raw text or html.\n   *\n   * @param val -\n   *        A html enabled formatted message to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public message(val: string): this {\n    this._email.message = val;\n    return this;\n  }\n\n  /**\n   * Assigns the other object to the current email object.\n   *\n   * @param other -\n   *        The object to copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public assign(other: Partial<IZEmail>): this {\n    this._email = Object.assign(this._email, other);\n    this._email = JSON.parse(JSON.stringify(this._email));\n    return this;\n  }\n\n  /**\n   * Copies another email into the builder.\n   *\n   * @param other -\n   *        The object to copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public copy(other: IZEmail) {\n    this._email = JSON.parse(JSON.stringify(other));\n    return this;\n  }\n\n  /**\n   * Returns a copy of the built object.\n   *\n   * @returns\n   *        A copy of the built object.\n   */\n  public build(): IZEmail {\n    return JSON.parse(JSON.stringify(this._email));\n  }\n}\n","/**\n * Represents an email contact.\n */\nexport interface IZEmailContact {\n  /**\n   * The email address of the contact.\n   */\n  address: string;\n\n  /**\n   * The type of contact.\n   *\n   * This can be anything you want.  In the end, this has no bearing\n   * on the final sent message.  It's just a descriptor to determine what this contact\n   * represents if needed.\n   */\n  type?: string;\n\n  /**\n   * The display name of the contact.\n   *\n   * If this is falsy, then you can consider the\n   * address as the display.\n   */\n  display?: string;\n}\n\n/**\n * Represents a builder for an email contact.\n */\nexport class ZEmailContactBuilder {\n  private _contact: IZEmailContact;\n\n  /**\n   * Initializes a new instance of this object.\n   */\n  public constructor() {\n    this._contact = {\n      address: \"\",\n    };\n  }\n\n  /**\n   * Sets the address of the contact.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public address(val: string): this {\n    this._contact.address = val;\n    return this;\n  }\n\n  /**\n   * Sets the type of the contact.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public type(val: string): this {\n    this._contact.type = val;\n    return this;\n  }\n\n  /**\n   * Sets the display of the contact.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public display(val: string) {\n    this._contact.display = val;\n    return this;\n  }\n\n  /**\n   * Assigns the values in other to this object.\n   *\n   * @param other -\n   *        The value to partial copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public assign(other: Partial<IZEmailContact>): this {\n    this._contact = Object.assign({}, this._contact, other);\n    this._contact = JSON.parse(JSON.stringify(this._contact));\n    return this;\n  }\n\n  /**\n   * Copies another object.\n   *\n   * @param other -\n   *        The value to copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public copy(other: IZEmailContact): this {\n    this._contact = JSON.parse(JSON.stringify(other));\n    return this;\n  }\n\n  /**\n   * Returns a copy of the built object.\n   *\n   * @returns\n   *        A copy of the built email contact.\n   */\n  public build(): IZEmailContact {\n    return JSON.parse(JSON.stringify(this._contact));\n  }\n}\n","import type { IZEmailContact } from \"./email-contact.mjs\";\n\n/**\n * Represents a builder that will build a comma separated\n * list of addresses for an email message.\n */\nexport class ZEmailContactAddressBuilder {\n  private _addresses: Array<string | IZEmailContact> = [];\n  private _delimiter = \", \";\n\n  /**\n   * Adds an address to the list to builder.\n   *\n   * @param val -\n   *        The address to add. This can be the empty string,\n   *        null, or undefined.\n   *\n   * @returns\n   *        This object.\n   */\n  public address(val: string | IZEmailContact): this {\n    this._addresses.push(val);\n    return this;\n  }\n\n  /**\n   * Sets the addresses to build from.\n   *\n   * @param val -\n   *        The address to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public addresses(val: Array<string | IZEmailContact>) {\n    this._addresses = val.slice();\n    return this;\n  }\n\n  /**\n   * Sets the delimiter to split the addresses with.\n   *\n   * The default is a comma with a space.\n   *\n   * @param val -\n   *        The delimiter to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public delimiter(val: string): this {\n    this._delimiter = val;\n    return this;\n  }\n\n  /**\n   * Builds the delimiters separated list of addresses.\n   *\n   * @returns\n   *        The delimited separated list of addresses.\n   */\n  public build(): string {\n    const addr = (ct: string | IZEmailContact) => {\n      if (!ct) {\n        return undefined;\n      }\n\n      return typeof ct === \"string\" ? ct : ct.address;\n    };\n\n    const truthy = (ct: string) => {\n      return !!ct;\n    };\n\n    return this._addresses.map(addr).filter(truthy).join(this._delimiter);\n  }\n}\n","/**\n * Returns true if an object is empty, null, or undefined.\n *\n * Note that this is different than lodash's isEmpty method.\n * Checking an empty array or empty string will result\n * in false.\n *\n * @param candidate -\n *        The object to test.\n *\n * @returns\n *        True if candidate is the empty object or\n *        null.  False otherwise.\n */\nexport function isEmptyObject(candidate: any): candidate is {} {\n  const candidateType = typeof candidate;\n\n  return (\n    candidate == null ||\n    (candidateType === \"object\" && Object.keys(candidate).length === 0)\n  );\n}\n","/**\n * Information for an enum value.\n *\n * This is useful for front end development when\n * you want to map an enumeration like value to\n * things like a display name, description, and\n * avatar.  ECMAScript does not support decorators\n * for literal fields so this is an alternative\n * to describe that kind of information.\n *\n * This is similar to Metadata from helpful-query,\n * but it's much more specific and specialized\n * to enumerations.\n */\nexport interface IZEnumInfo<TEnum extends string | number> {\n  /**\n   * The display name of the enum value.\n   */\n  name?: string;\n\n  /**\n   * The avatar representation of the enum.\n   *\n   * This can be anything and is contextual of how\n   * this object is used.\n   */\n  avatar?: any;\n\n  /**\n   * The description of the enum value.\n   */\n  description?: string;\n\n  /**\n   * The value being described.\n   */\n  value: TEnum;\n}\n\n/**\n * Builds information for an enum.\n */\nexport class ZEnumInfoBuilder<TEnum extends string | number> {\n  private _metadata: IZEnumInfo<TEnum>;\n\n  /**\n   * Initializes a new instance of this object.\n   *\n   * @param value -\n   *        The value to initialize with.\n   */\n  public constructor(value: TEnum) {\n    this._metadata = { value };\n  }\n\n  /**\n   * The display name of the enum.\n   *\n   * @param name -\n   *        The display name of the enum.\n   *\n   * @returns\n   *        This object.\n   */\n  public name(name: string) {\n    this._metadata.name = name;\n    return this;\n  }\n\n  /**\n   * Text description of the enum.\n   *\n   * @param description -\n   *        Text description of what the value means.\n   *\n   * @returns\n   *        This object.\n   */\n  public description(description: string) {\n    this._metadata.description = description;\n    return this;\n  }\n\n  /**\n   * The avatar representation of the enum.\n   *\n   * @param avatar -\n   *        The avatar representation of what the value\n   *        is.  This can be anything but should be related\n   *        to the framework it is being developed for.\n   *\n   * @returns\n   *        This object.\n   */\n  public avatar(avatar: any) {\n    this._metadata.avatar = avatar;\n    return this;\n  }\n\n  /**\n   * Returns a shallow copy of the metadata.\n   *\n   * @returns\n   *        A shallow copy of the metadata.\n   */\n  public build(): IZEnumInfo<TEnum> {\n    return { ...this._metadata };\n  }\n}\n","const BYTES_PER_KIBIBYTE = 1024;\nconst BYTES_PER_MEBIBYTE = 1048576; // 1024 ^ 2\nconst BYTES_PER_GIBIBYTE = 1073741824; // 1024 ^ 3\nconst BYTES_PER_TEBIBYTE = 1099511627776; // 1024 ^ 4\nconst BYTES_PER_PEBIBYTE = 1125899906842624; // 1024 ^ 5\n\nfunction bytes(bytesPerUnit: number, amount: number) {\n  return Math.ceil(bytesPerUnit * amount);\n}\n\n/**\n * Returns the total number of bytes for the wanted amount of kibibytes.\n *\n * A kibibyte is 1024 bytes.\n *\n * @param amount -\n *        The total number of kibibytes to convert to bytes.\n *\n * @returns\n *        The total number of bytes in the given amount of kibibytes.\n */\nexport const kibibytes: (amount: number) => number = bytes.bind(\n  null,\n  BYTES_PER_KIBIBYTE,\n);\n/**\n * @see {@link kibibytes}\n */\nexport const kib = kibibytes;\n\n/**\n * Returns the total number of bytes for the wanted number of mebibytes.\n *\n * A mebibyte is 1024 kibibytes.\n *\n * @param amount -\n *        The total amount of mebibytes to convert to bytes.\n *\n * @returns\n *        The total number of bytes in the given amount of mebibytes.\n */\nexport const mebibytes: (amount: number) => number = bytes.bind(\n  null,\n  BYTES_PER_MEBIBYTE,\n);\n/**\n * @see {@link mebibytes}\n */\nexport const mib = mebibytes;\n\n/**\n * Returns the total number of bytes for the wanted number of gibibytes.\n *\n * A gibibyte is 1024 mebibytes.\n *\n * @param amount -\n *        The total amount of gibibytes to convert to bytes.\n *\n * @returns\n *        The total number of bytes in the given amount of gibibytes.\n */\nexport const gibibytes: (amount: number) => number = bytes.bind(\n  null,\n  BYTES_PER_GIBIBYTE,\n);\n/**\n * @see {@link gibibytes}\n */\nexport const gib = gibibytes;\n\n/**\n * Returns the total number of bytes for the wanted number of tebibytes.\n *\n * A tebibyte is 1024 gibibytes.\n *\n * @param amount -\n *        The total amount of tebibytes to convert to bytes.\n *\n * @returns\n *        The total number of bytes in the given amount of tebibytes.\n */\nexport const tebibytes: (amount: number) => number = bytes.bind(\n  null,\n  BYTES_PER_TEBIBYTE,\n);\n/**\n * @see {@link tebibytes}\n */\nexport const tib = tebibytes;\n\n/**\n * Returns the total number of bytes for the wanted number of pebibytes.\n *\n * A pebibytes is 1024 tebibytes.\n *\n * @param amount -\n *        The total amount of pebibytes to convert to bytes.\n *\n * @returns\n *        The total number of bytes in the given amount of pebibytes.\n */\nexport const pebibytes: (amount: number) => number = bytes.bind(\n  null,\n  BYTES_PER_PEBIBYTE,\n);\n/**\n * @see {@link pebibytes}\n */\nexport const pib = pebibytes;\n","/**\n * Returns the first value in an argument list that matches a predicate.\n *\n * @param predicate -\n *        The match method against each value argument.\n * @param fallback -\n *        The fallback value in the case that all arguments fail\n *        the predicate.\n * @param first -\n *        The first value to check.\n * @param remaining -\n *        The remaining values beyond the first to check.\n * @param T -\n *        The type of data that will be enumerated.\n *\n * @returns\n *        The first value for where predicate returns true for the given argument value.\n *        If first and all values of remaining fail the predicate then fallback is returned.\n */\nexport function firstWhere<T = any>(\n  predicate: (v: T | null | undefined) => boolean,\n  fallback: T,\n  first: T,\n  ...remaining: T[]\n): T {\n  if (predicate(first)) {\n    return first;\n  }\n\n  for (let i = 0; i < remaining.length; ++i) {\n    const val = remaining[i];\n\n    if (predicate(val)) {\n      return val;\n    }\n  }\n\n  return fallback;\n}\n\n/**\n * Returns the first value in args such that args is not null or undefined.\n *\n * @param fallback -\n *        The fallback value in the case that all values in args are null/undefined.\n * @param first -\n *        The first value to check.\n * @param remaining -\n *        The remaining values beyond the first to check.\n * @param T -\n *        The type of data that will be enumerated.\n *\n * @returns\n *        The first value if it is not null or undefined.  If first is undefined or null, then the first item\n *        in remaining such that remaining[i] is not null or undefined is returned.  If first and all values of\n *        remaining are null or undefined, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstDefined('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstDefined('Fallback', null, undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', undefined);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, 'Third');\n * ```\n */\nexport function firstDefined<T = any>(\n  fallback: T,\n  first: T | null | undefined,\n  ...remaining: (T | null | undefined)[]\n): T {\n  return firstWhere<T | null | undefined>(\n    (v) => v != null,\n    fallback,\n    first,\n    ...remaining,\n  ) as T;\n}\n\n/**\n * Returns the first value in args such that args is truthy\n *\n * @param fallback -\n *        The fallback value in the case that all values in args are falsy.\n * @param first -\n *        The first value to check.\n * @param remaining -\n *        The remaining values beyond the first to check.\n * @param T -\n *        The type of data that will be enumerated.\n *\n * @returns\n *        The first value if it is truthy.  If first is falsy, then the first item\n *        in remaining such that remaining[i] is truthy is returned.  If first and\n *        all values of remaining are falsy, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstTruthy('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstTruthy('Fallback', '', undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', 0, false);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, false, 0, NaN);\n * ```\n */\nexport function firstTruthy<T = any>(\n  fallback: T,\n  first: T | null | undefined,\n  ...remaining: (T | null | undefined)[]\n): T {\n  return firstWhere<T | null | undefined>(\n    (v) => !!v,\n    fallback,\n    first,\n    ...remaining,\n  ) as T;\n}\n","import { isEmptyObject } from \"../empty/is-empty-object.mjs\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\nimport type { IZPoint2d } from \"./point.mjs\";\n\n/**\n * Represents a object of 4 side values.\n *\n * @param T -\n *        Value type.  Typically number.\n */\nexport interface IZQuadrilateral<T = number> {\n  /**\n   * Bottom value.\n   */\n  bottom: T;\n  /**\n   * Left value.\n   */\n  left: T;\n  /**\n   * Right value.\n   */\n  right: T;\n  /**\n   * Top value.\n   */\n  top: T;\n}\n\n/**\n * Represents an object that can describe a quadrilateral.\n *\n * Note that there will be limitations on what you can describe\n * when building Quadrilaterals of Quadrilaterals, or Quadrilaterals\n * of Point2d's which is not supported and has undefined behavior.\n */\nexport type ZQuadrilateralLike<T = number> =\n  T | Partial<IZPoint2d<T>> | Partial<IZQuadrilateral<T>> | null | undefined;\n\n/**\n * Represents a builder for a quadrilateral object.\n */\nexport class ZQuadrilateralBuilder<T = number> {\n  private _quad: IZQuadrilateral<T>;\n\n  /**\n   * Initializes a new instance of this object.\n   *\n   * @param start -\n   *        The starting value.\n   */\n  public constructor(start: T) {\n    this._quad = {\n      bottom: start,\n      left: start,\n      right: start,\n      top: start,\n    };\n  }\n\n  /**\n   * Sets the bottom value.\n   *\n   * @param bottom -\n   *        The bottom value.\n   *\n   * @returns\n   *        This object.\n   */\n  public bottom(bottom: T): this {\n    this._quad.bottom = bottom;\n    return this;\n  }\n\n  /**\n   * Sets the left value.\n   *\n   * @param left -\n   *        The left value.\n   *\n   * @returns\n   *        This object.\n   */\n  public left(left: T): this {\n    this._quad.left = left;\n    return this;\n  }\n\n  /**\n   * Sets the right value.\n   *\n   * @param right -\n   *        The right value.\n   *\n   * @returns\n   *        This object.\n   */\n  public right(right: T): this {\n    this._quad.right = right;\n    return this;\n  }\n\n  /**\n   * Sets the top value.\n   *\n   * @param top -\n   *        The top value.\n   *\n   * @returns\n   *        This object.\n   */\n  public top(top: T): this {\n    this._quad.top = top;\n    return this;\n  }\n\n  /**\n   * Sets the left and right value.\n   *\n   * @param x -\n   *        The left and right value.\n   *\n   * @returns\n   *        This object.\n   */\n  public x(x: T): this {\n    return this.left(x).right(x);\n  }\n\n  /**\n   * Sets the top and bottom value.\n   *\n   * @param y -\n   *        The top and bottom value.\n   *\n   * @returns\n   *        This object.\n   */\n  public y(y: T): this {\n    return this.bottom(y).top(y);\n  }\n\n  /**\n   * Constructs a full quadrilateral from an object that describes a quadrilateral.\n   *\n   * Note the limitations of this method.  If T is of type Quadrilateral or Point2d,\n   * then this method's behavior is undefined and it will most likely build a\n   * corrupt object.\n   *\n   * @param other -\n   *        The object to build from.\n   *\n   * @returns\n   *        This object.\n   */\n  public from(other: ZQuadrilateralLike<T>): this {\n    function isPoint2d<T>(\n      candidate: ZQuadrilateralLike<T>,\n    ): candidate is Partial<IZPoint2d<T>> {\n      return (\n        candidate != null &&\n        (Object.prototype.hasOwnProperty.call(candidate, \"x\") ||\n          Object.prototype.hasOwnProperty.call(candidate, \"y\"))\n      );\n    }\n\n    function isQuadrilateral<T>(\n      candidate: ZQuadrilateralLike<T>,\n    ): candidate is Partial<IZQuadrilateral<T>> {\n      return (\n        candidate != null &&\n        (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n          Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n          Object.prototype.hasOwnProperty.call(candidate, \"right\") ||\n          Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n      );\n    }\n\n    if (isQuadrilateral(other)) {\n      this._quad.bottom = firstDefined(this._quad.bottom, other.bottom);\n      this._quad.left = firstDefined(this._quad.left, other.left);\n      this._quad.right = firstDefined(this._quad.right, other.right);\n      this._quad.top = firstDefined(this._quad.top, other.top);\n      return this;\n    }\n\n    if (isPoint2d(other)) {\n      this._quad.bottom = firstDefined(this._quad.bottom, other.y);\n      this._quad.left = firstDefined(this._quad.left, other.x);\n      this._quad.right = firstDefined(this._quad.right, other.x);\n      this._quad.top = firstDefined(this._quad.top, other.y);\n      return this;\n    }\n\n    if (!isEmptyObject(other)) {\n      this._quad.bottom = firstDefined(this._quad.bottom, other);\n      this._quad.left = firstDefined(this._quad.left, other);\n      this._quad.right = firstDefined(this._quad.right, other);\n      this._quad.top = firstDefined(this._quad.top, other);\n    }\n\n    return this;\n  }\n\n  /**\n   * Copies another quadrilateral object into the current instance.\n   *\n   * @param other -\n   *        The quadrilateral object to copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public copy(other: IZQuadrilateral<T>): this {\n    // The copy is done this way instead of a structured\n    // copy because we want to support things like\n    // copy(other.getBoundingClientRect()) which\n    // is immutable when working on the client.\n    this._quad.left = other.left;\n    this._quad.right = other.right;\n    this._quad.top = other.top;\n    this._quad.bottom = other.bottom;\n    return this;\n  }\n\n  /**\n   * Returns the built quadrilateral object.\n   *\n   * @returns\n   *        The built quadrilateral.\n   */\n  public build(): IZQuadrilateral<T> {\n    return structuredClone(this._quad);\n  }\n}\n","import { isEmptyObject } from \"../empty/is-empty-object.mjs\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\n\n/**\n * An object that describes 4 corner values of a quadrilateral.\n *\n * This object is almost identical in functionality to a quadrilateral,\n * but is mostly useful for semantics.\n *\n * @param T -\n *        The type of data to associate to each corner.\n */\nexport interface IZQuadrilateralCorners<T = number> {\n  bottomLeft: T;\n  bottomRight: T;\n  topLeft: T;\n  topRight: T;\n}\n\n/**\n * A type that describes quadrilateral corners on the vertical axis.\n */\nexport type ZCornersVertical<T> = {\n  bottom?: T;\n  top?: T;\n};\n\n/**\n * A type that describes quadrilateral corners on the horizontal axis.\n */\nexport type ZCornersHorizontal<T> = {\n  left?: T;\n  right?: T;\n};\n\n/**\n * An value that a corners object can be built upon.\n */\nexport type ZQuadrilateralCornersLike<T = number> =\n  | T\n  | ZCornersVertical<T>\n  | ZCornersHorizontal<T>\n  | Partial<IZQuadrilateralCorners<T>>\n  | null\n  | undefined;\n\n/**\n * An object that can be used to build an {@link IZQuadrilateralCorners} object.\n *\n * @param T -\n *        The type of data to associate to each corner.\n */\nexport class ZQuadrilateralCornersBuilder<T = number> {\n  private _corners: IZQuadrilateralCorners<T>;\n\n  public constructor(start: T) {\n    this._corners = {\n      bottomLeft: start,\n      bottomRight: start,\n      topLeft: start,\n      topRight: start,\n    };\n  }\n\n  /**\n   * Sets the bottom left corner value.\n   *\n   * @param value -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public bottomLeft(value: T): this {\n    this._corners.bottomLeft = value;\n    return this;\n  }\n\n  /**\n   * Sets the bottom right corner value.\n   *\n   * @param value -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public bottomRight(value: T): this {\n    this._corners.bottomRight = value;\n    return this;\n  }\n\n  /**\n   * Sets the top left corner value.\n   *\n   * @param value -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public topLeft(value: T): this {\n    this._corners.topLeft = value;\n    return this;\n  }\n\n  /**\n   * Sets the top right corner value.\n   *\n   * @param value -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public topRight(value: T): this {\n    this._corners.topRight = value;\n    return this;\n  }\n\n  /**\n   * Sets the bottom left and bottom right values.\n   *\n   * @param value -\n   *        The value for bottom left and bottom right.\n   *\n   * @returns\n   *        This object.\n   */\n  public bottom(value: T): this {\n    return this.bottomLeft(value).bottomRight(value);\n  }\n\n  /**\n   * Sets the bottom left and top left values.\n   *\n   * @param value -\n   *        The value for bottom left and top left.\n   *\n   * @returns\n   *        This object.\n   */\n  public left(value: T): this {\n    return this.topLeft(value).bottomLeft(value);\n  }\n\n  /**\n   * Sets the bottom right and top right values.\n   *\n   * @param value -\n   *        The value for bottom right and top right.\n   *\n   * @returns\n   *        This object.\n   */\n  public right(value: T): this {\n    return this.bottomRight(value).topRight(value);\n  }\n\n  /**\n   * Sets the top left and top right  values.\n   *\n   * @param value -\n   *        The value for top left and top right.\n   *\n   * @returns\n   *        This object.\n   */\n  public top(value: T): this {\n    return this.topLeft(value).topRight(value);\n  }\n\n  /**\n   * Sets the corner values based on an object that\n   * describes a set of quadrilateral corners.\n   *\n   * @param other -\n   *        The object that describes the corners.\n   *\n   * @returns\n   *        This object.\n   */\n  public from(other: ZQuadrilateralCornersLike<T>): this {\n    function isVerticals<T>(\n      candidate: ZQuadrilateralCornersLike<T>,\n    ): candidate is ZCornersVertical<T> {\n      return (\n        candidate != null &&\n        (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n          Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n      );\n    }\n\n    function isHorizontals<T>(\n      candidate: ZQuadrilateralCornersLike<T>,\n    ): candidate is ZCornersHorizontal<T> {\n      return (\n        candidate != null &&\n        (Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n          Object.prototype.hasOwnProperty.call(candidate, \"right\"))\n      );\n    }\n\n    function isCorners<T>(\n      candidate: ZQuadrilateralCornersLike<T>,\n    ): candidate is Partial<IZQuadrilateralCorners<T>> {\n      return (\n        candidate != null &&\n        (Object.prototype.hasOwnProperty.call(candidate, \"bottomLeft\") ||\n          Object.prototype.hasOwnProperty.call(candidate, \"bottomRight\") ||\n          Object.prototype.hasOwnProperty.call(candidate, \"topLeft\") ||\n          Object.prototype.hasOwnProperty.call(candidate, \"topRight\"))\n      );\n    }\n\n    const { bottomLeft, bottomRight, topLeft, topRight } = this._corners;\n\n    if (isCorners(other)) {\n      this._corners.bottomLeft = firstDefined(bottomLeft, other.bottomLeft);\n      this._corners.bottomRight = firstDefined(bottomRight, other.bottomRight);\n      this._corners.topLeft = firstDefined(topLeft, other.topLeft);\n      this._corners.topRight = firstDefined(topRight, other.topRight);\n      return this;\n    }\n\n    if (isVerticals(other)) {\n      this._corners.bottomLeft = firstDefined(bottomLeft, other.bottom);\n      this._corners.bottomRight = firstDefined(bottomRight, other.bottom);\n      this._corners.topLeft = firstDefined(topLeft, other.top);\n      this._corners.topRight = firstDefined(topRight, other.top);\n      return this;\n    }\n\n    if (isHorizontals(other)) {\n      this._corners.bottomLeft = firstDefined(bottomLeft, other.left);\n      this._corners.bottomRight = firstDefined(bottomRight, other.right);\n      this._corners.topLeft = firstDefined(topLeft, other.left);\n      this._corners.topRight = firstDefined(topRight, other.right);\n      return this;\n    }\n\n    if (!isEmptyObject(other)) {\n      this._corners.bottomLeft = firstDefined(bottomLeft, other);\n      this._corners.bottomRight = firstDefined(bottomRight, other);\n      this._corners.topLeft = firstDefined(topLeft, other);\n      this._corners.topRight = firstDefined(topRight, other);\n    }\n\n    return this;\n  }\n\n  /**\n   * Copies another corners object into this builder.\n   *\n   * @param other -\n   *        The corners object to copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public copy(other: IZQuadrilateralCorners<T>): this {\n    this._corners = structuredClone(other);\n    return this;\n  }\n\n  /**\n   * Builds the corners.\n   *\n   * @returns\n   *        The built corners.\n   */\n  public build(): IZQuadrilateralCorners<T> {\n    return structuredClone(this._corners);\n  }\n}\n","import type { ZAnchor } from \"../anchor/anchor.mjs\";\nimport { ZHorizontalAnchor, ZVerticalAnchor } from \"../anchor/anchor.mjs\";\nimport type { IZPoint2d } from \"./point.mjs\";\nimport type { IZQuadrilateral } from \"./quadrilateral.mjs\";\nimport { ZQuadrilateralBuilder } from \"./quadrilateral.mjs\";\n\n/**\n * Represents a helper object that can run calculations on a numeric quadrilateral.\n */\nexport class ZRectangle {\n  /**\n   * Initializes a new instance of this object.\n   *\n   * @param sides -\n   *        The numeric sides of a quadrilateral.\n   */\n  public constructor(public readonly sides: IZQuadrilateral) {}\n\n  /**\n   * Calculates the width of the rectangle.\n   *\n   * @returns\n   *        The numeric width of the rectangle.\n   */\n  public width(): number {\n    const { left, right } = this.sides;\n    return right - left;\n  }\n\n  /**\n   * Calculates the height of the rectangle.\n   *\n   * @returns\n   *        The numeric height of the rectangle.\n   */\n  public height(): number {\n    const { top, bottom } = this.sides;\n    return bottom - top;\n  }\n\n  /**\n   * Calculates the area of the rectangle.\n   *\n   * @returns\n   *        The numeric area of the rectangle.\n   */\n  public area(): number {\n    return this.width() * this.height();\n  }\n\n  /**\n   * Takes a candidate and attaches it to this rectangle that matches the anchor points.\n   *\n   * @param anchor -\n   *        The anchor point of this rectangle.\n   * @param candidate -\n   *        The candidate rectangle to move\n   * @param candidateAnchor -\n   *        The anchor point of the candidate rectangle.\n   *\n   * @returns\n   *        A new quadrilateral that has it's placement such that if candidate was moved\n   *        to this resulting position, would have its candidateAnchor be in the same\n   *        place as this rectangles specified anchor.\n   */\n  public attach(\n    anchor: ZAnchor,\n    candidate: IZQuadrilateral,\n    candidateAnchor: ZAnchor,\n  ): IZQuadrilateral {\n    const _candidate = new ZRectangle(candidate);\n    const { x: ax, y: ay } = this.point(anchor);\n    const { x: ox, y: oy } = new ZRectangle(candidate).point(candidateAnchor);\n\n    const left: number = candidate.left + (ax - ox);\n    const top: number = candidate.top + (ay - oy);\n    const bottom: number = top + _candidate.height();\n    const right = left + _candidate.width();\n\n    return new ZQuadrilateralBuilder(0)\n      .left(left)\n      .right(right)\n      .top(top)\n      .bottom(bottom)\n      .build();\n  }\n\n  /**\n   * Takes the candidate quadrilateral and adjusts it's coordinates to fit inside this rectangle.\n   *\n   * This is done by shifting the rectangle left, right, up, and down to make sure it is bounded\n   * inside.\n   *\n   * If the candidate width or height is larger than this rectangle, thus it cannot fit, then\n   * the candidate will be centered on the dimension where it is too big to fit.\n   *\n   * @param candidate -\n   *        The candidate quadrilateral to fit.\n   *\n   * @returns\n   *        A new quadrilateral that offsets candidate so that it can fit inside this\n   *        rectangle.\n   */\n  public offsetToFit(candidate: IZQuadrilateral): IZQuadrilateral {\n    let _candidate = candidate;\n    const candidateRectangle = new ZRectangle(candidate);\n\n    if (candidateRectangle.width() > this.width()) {\n      // Center the horizontal\n      const { x: cx } = candidateRectangle.middleCenter();\n      const { x: tx } = this.middleCenter();\n\n      _candidate = new ZQuadrilateralBuilder(0)\n        .copy(_candidate)\n        .left(_candidate.left - (cx - tx))\n        .right(_candidate.right - (cx - tx))\n        .build();\n    } else {\n      if (_candidate.left < this.sides.left) {\n        // Move the candidate to the right.\n        _candidate = new ZQuadrilateralBuilder(0)\n          .copy(_candidate)\n          .left(this.sides.left)\n          .right(_candidate.right + (this.sides.left - _candidate.left))\n          .build();\n      }\n\n      if (_candidate.right > this.sides.right) {\n        // Move the candidate to the left.\n        _candidate = new ZQuadrilateralBuilder(0)\n          .copy(_candidate)\n          .right(this.sides.right)\n          .left(_candidate.left - (_candidate.right - this.sides.right))\n          .build();\n      }\n    }\n\n    if (candidateRectangle.height() > this.height()) {\n      // Center the vertical\n      const { y: cy } = candidateRectangle.middleCenter();\n      const { y: ty } = this.middleCenter();\n\n      _candidate = new ZQuadrilateralBuilder(0)\n        .copy(_candidate)\n        .top(_candidate.top - (cy - ty))\n        .bottom(_candidate.bottom - (cy - ty))\n        .build();\n    } else {\n      if (_candidate.bottom > this.sides.bottom) {\n        // Move the candidate up.\n        _candidate = new ZQuadrilateralBuilder(0)\n          .copy(_candidate)\n          .bottom(this.sides.bottom)\n          .top(_candidate.top - (_candidate.bottom - this.sides.bottom))\n          .build();\n      }\n\n      if (_candidate.top < this.sides.top) {\n        // Move the candidate down\n        _candidate = new ZQuadrilateralBuilder(0)\n          .copy(_candidate)\n          .top(this.sides.top)\n          .bottom(_candidate.bottom + (this.sides.top - _candidate.top))\n          .build();\n      }\n    }\n\n    return _candidate;\n  }\n\n  /**\n   * Calculates the (x, y) point given an anchor target.\n   *\n   * @param anchor -\n   *        The anchor target to calculate the point for.\n   *\n   * @returns\n   *        The numeric width of the rectangle.\n   */\n  public point(anchor: ZAnchor): IZPoint2d {\n    const { bottom, left, right, top } = this.sides;\n    const [vertical, horizontal] = anchor;\n\n    const v: Record<ZVerticalAnchor, number> = {\n      [ZVerticalAnchor.Top]: top,\n      [ZVerticalAnchor.Middle]: (bottom + top) / 2,\n      [ZVerticalAnchor.Bottom]: bottom,\n    };\n\n    const h: Record<ZHorizontalAnchor, number> = {\n      [ZHorizontalAnchor.Left]: left,\n      [ZHorizontalAnchor.Center]: (right + left) / 2,\n      [ZHorizontalAnchor.Right]: right,\n    };\n\n    return { x: h[horizontal], y: v[vertical] };\n  }\n\n  /**\n   * Calculates the top left point of the rectangle.\n   *\n   * @returns\n   *        The top left point of the rectangle.\n   */\n  public topLeft = this.point.bind(this, [\n    ZVerticalAnchor.Top,\n    ZHorizontalAnchor.Left,\n  ]);\n\n  /**\n   * Calculates the top center point of the rectangle.\n   *\n   * @returns\n   *        The top center point of the rectangle.\n   */\n  public topCenter = this.point.bind(this, [\n    ZVerticalAnchor.Top,\n    ZHorizontalAnchor.Center,\n  ]);\n\n  /**\n   * Calculates the top right point of the rectangle.\n   *\n   * @returns\n   *        The top right point of the rectangle.\n   */\n  public topRight = this.point.bind(this, [\n    ZVerticalAnchor.Top,\n    ZHorizontalAnchor.Right,\n  ]);\n\n  /**\n   * Calculates the middle left point of the rectangle.\n   *\n   * @returns\n   *        The middle left point of the rectangle.\n   */\n  public middleLeft = this.point.bind(this, [\n    ZVerticalAnchor.Middle,\n    ZHorizontalAnchor.Left,\n  ]);\n\n  /**\n   * Calculates the middle center point of the rectangle.\n   *\n   * @returns\n   *        The middle center point of the rectangle.\n   */\n  public middleCenter = this.point.bind(this, [\n    ZVerticalAnchor.Middle,\n    ZHorizontalAnchor.Center,\n  ]);\n\n  /**\n   * Calculates the middle right point of the rectangle.\n   *\n   * @returns\n   *        The middle right point of the rectangle.\n   */\n  public middleRight = this.point.bind(this, [\n    ZVerticalAnchor.Middle,\n    ZHorizontalAnchor.Right,\n  ]);\n\n  /**\n   * Calculates the bottom left point of the rectangle.\n   *\n   * @returns\n   *        The bottom left point of the rectangle.\n   */\n  public bottomLeft = this.point.bind(this, [\n    ZVerticalAnchor.Bottom,\n    ZHorizontalAnchor.Left,\n  ]);\n\n  /**\n   * Calculates the bottom center point of the rectangle.\n   *\n   * @returns\n   *        The bottom center point of the rectangle.\n   */\n  public bottomCenter = this.point.bind(this, [\n    ZVerticalAnchor.Bottom,\n    ZHorizontalAnchor.Center,\n  ]);\n\n  /**\n   * Calculates the bottom right point of the rectangle.\n   *\n   * @returns\n   *        The bottom right point of the rectangle.\n   */\n  public bottomRight = this.point.bind(this, [\n    ZVerticalAnchor.Bottom,\n    ZHorizontalAnchor.Right,\n  ]);\n}\n","/* v8 ignore start -- @preserve */\n/* istanbul ignore file -- @preserve */\n/**\n * Resolves the global object without referencing DOM globals so this can be\n * consumed in Node builds that do not include the `dom` lib.\n */\nexport const $global = globalThis;\n/* v8 ignore end -- @preserve */\n","/**\n * A set of parameters that can be used for a string join.\n *\n * Join lists can be a regular object, null, undefined, or a tuple where the\n * first item is the object to join, and the second item is a boolean that specifies\n * whether to include it if the value is truthy.\n *\n * @param T -\n *        The type of data to join.\n */\nexport type JoinListInputParameter<T> = T | [T, boolean] | null | undefined;\n\n/**\n * Similar to Array.join but filters out null and undefined items.\n *\n * @param delimiter -\n *        The delimiter that separates the items.\n * @param items -\n *        The items to join.\n * @param T -\n *        The type of data to join.\n *\n * @returns\n *        A string that joins the items that are defined, separated by delimiter.\n *\n * @example\n *\n * ```ts\n * // 'a b d'\n * const joinBySpace = joinDefined(' ', 'a', 'b', ['c', false], null, undefined, ['d', true]);\n * // (Empty String)\n * const joinEmpty = joinDefined('?');\n * ```\n */\nexport function joinDefined<T>(\n  delimiter: string,\n  ...items: JoinListInputParameter<T>[]\n) {\n  return items\n    .map((item) => (item instanceof Array ? (item[1] ? item[0] : null) : item))\n    .filter((item) => item != null)\n    .join(delimiter);\n}\n\n/**\n * Alias to joinList with a space delimiter.\n *\n * @param items -\n *        The items to join.\n *\n * @returns\n *        A string that joins the items that are defined, separated by space delimiter.\n *\n * @see\n *        {@link joinDefined} for more information and examples.\n */\nexport const spaceJoinDefined: <T>(\n  ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \" \");\n\n/**\n * Alias of spaceJoinList.\n *\n * @param items -\n *        The items to join.\n *\n * @returns\n *        A string that joins the items that are defined, separated by a space delimiter.\n *\n * @see\n *        {@link joinDefined} for more information and examples.\n */\nexport const cssJoinDefined: <T>(\n  ...items: JoinListInputParameter<T>[]\n) => string = spaceJoinDefined;\n\n/**\n * Alias of joinList with a comma delimiter.\n *\n * @param items -\n *        The items to join.\n *\n * @returns\n *        A string that joins the items that are defined, separated by a comma delimiter.\n *\n * @see\n *        {@link joinDefined} for more information and examples.\n */\nexport const commaJoinDefined: <T>(\n  ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \",\");\n\n/**\n * Alias of joinList with a semi-colon delimiter.\n *\n * @param items -\n *        The items to join.\n *\n * @returns\n *        A string that joins the items that are defined, separated by a semi-colon delimiter.\n *\n * @see\n *        {@link joinDefined} for more information and examples.\n */\nexport const semiColonJoinDefined: <T>(\n  ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \";\");\n\n/**\n * Alias of joinList with a pipe delimiter.\n *\n * @param items -\n *        The items to join.\n *\n * @returns\n *        A string that joins the items that are defined, separated by a pipe delimiter.\n *\n * @see\n *        {@link joinDefined} for more information and examples.\n */\nexport const pipeJoinDefined: <T>(\n  ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \"|\");\n","import type { ZSupplierAsync } from \"../function/supplier.mjs\";\n\nexport class ZLazy<T> {\n  private _value: Promise<T>;\n\n  public constructor(private _factory: ZSupplierAsync<T>) {}\n\n  public initialized() {\n    return this._value != null;\n  }\n\n  public async get() {\n    if (this._value == null) {\n      this._value = this._factory();\n    }\n\n    return this._value;\n  }\n}\n","/**\n * A specific set of possible values that need to be checked for requirements.\n *\n * @param T -\n *        The type of value that is being checked.\n */\nexport type ZObligatedValue<T> =\n  T | null | undefined | Promise<T | null | undefined>;\n\n/**\n * Requires a value to be non null.\n *\n * @param val -\n *        The value to require.  This can be a promise\n *        that can return null or undefined in addition to the\n *        value.\n * @param T -\n *        The type of value that is being checked.\n *\n * @returns\n *        This method returns val if it is not null\n *        or undefined, otherwise, an error is thrown.\n *\n * @throws\n *        An error if the value is null or undefined.\n */\nexport async function required<T>(val: ZObligatedValue<T>): Promise<T> {\n  if (val == null) {\n    throw new Error(\"A required value was not provided\");\n  }\n\n  const _val = await val;\n\n  if (_val == null) {\n    throw new Error(\"A required value was not provided\");\n  }\n\n  return _val;\n}\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n *        The value to check.  This can be a promise\n *        that can return null or undefined in addition to the\n *        value.\n * @param fallback -\n *        The fallback value in the case that val is\n *        null or undefined.\n * @param T -\n *        The type of value that is being checked.\n *\n * @returns\n *        This method returns val if it is not null\n *        or undefined, otherwise, the fallback is returned.\n *        If val is a promise and rejects, then fallback is\n *        also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>, fallback: T): Promise<T>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n *        The value to check.  This can be a promise\n *        that can return null or undefined in addition to the\n *        value.\n * @param T -\n *        The type of value that is being checked.\n *\n * @returns\n *        This method returns val if it is not null\n *        or undefined, otherwise, null is returned.\n *        If val is a promise and rejects, then null is\n *        also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>): Promise<T | null>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n *        The value to check.  This can be a promise\n *        that can return null or undefined in addition to the\n *        value.\n * @param fallback -\n *        The fallback value in the case that val is\n *        null or undefined.\n * @param T -\n *        The type of value that is being checked.\n *\n * @returns\n *        This method returns val if it is not null\n *        or undefined, otherwise, the fallback is returned.\n *        If val is a promise and rejects, then fallback is\n *        also returned.\n */\nexport async function optional<T>(\n  val: ZObligatedValue<T>,\n  fallback: T | null = null,\n): Promise<T | null> {\n  if (val == null) {\n    return fallback;\n  }\n\n  try {\n    const _val = await val;\n    return _val == null ? fallback : _val;\n  } catch {\n    return fallback;\n  }\n}\n","/**\n * Represents a direction orientation.\n */\nexport enum ZOrientation {\n  /**\n   * Horizontal orientation.\n   *\n   * This type of orientation is a row\n   * style orientation or flex-row orientation.\n   */\n  Horizontal = \"horizontal\",\n\n  /**\n   * Vertical orientation.\n   *\n   * This type of orientation is a column\n   * style orientation or block orientation.\n   */\n  Vertical = \"vertical\",\n}\n","/**\n * Peels a candidate string from the start of a string and splits it into two segments.\n *\n * @param str -\n *        The string to peel from.\n * @param candidates -\n *        The candidate list of values to peel from str.\n *\n * @returns\n *        A tuple where the first item is the peeled string and\n *        the second item is the remainder of the string.  If the string\n *        does not start with any given candidates, then the first\n *        item will be null and the second item will be str.\n */\nexport function peel<T extends string = string>(\n  str: string,\n  candidates: T[],\n): [T | null, string] {\n  for (const check of candidates) {\n    if (str.startsWith(check)) {\n      return [str.substring(0, check.length) as T, str.substring(check.length)];\n    }\n  }\n\n  return [null, str];\n}\n\n/**\n * Peels the values between an opening string set and a closing string set.\n *\n * The actual value will handle issues with internal opening and closing brackets\n *\n * @example\n *\n * ```ts\n * const [peeled, rest] = peelBetween('[a, b, [c1, c2],[d]] other', '[' ']');\n *\n * // Outputs 'a, b, [c1, c2], [d]'\n * console.log(peeled);\n *\n * // Outputs ' other' - white space is included'\n * console.log(rest);\n * ```\n *\n * @param str -\n *        The string to peel between.\n * @param open -\n *        The opening string.  This will test\n *        at the start of str.\n * @param close -\n *        The closing string.  This can be anywhere\n *        in the str.  If this is equal to open, then\n *        the open string is removed from the start of the\n *        string and the rest of the string would be returned.\n *\n * @returns\n *        A tuple where the first argument is string that was found between\n *        the opening and closing bracket. Returns null if no string could\n *        be found between an open and close pair.  The second argument will\n *        be the remaining text of the string, including whitespace.\n */\nexport function peelBetween(\n  str: string,\n  open: string,\n  close: string,\n): [string | null, string] {\n  if (!str.startsWith(open)) {\n    return [null, str];\n  }\n\n  let stack = 1;\n\n  const _str = str.substring(open.length);\n\n  for (let i = 0; i < _str.length; ++i) {\n    if (_str.startsWith(open, i)) {\n      stack += 1;\n      i += open.length - 1;\n      continue;\n    }\n\n    if (_str.startsWith(close, i)) {\n      stack -= 1;\n\n      if (stack === 0) {\n        return [_str.substring(0, i), _str.substring(i + close.length)];\n      }\n\n      i += close.length - 1;\n    }\n  }\n\n  return [null, str];\n}\n","export type PickPredicate = (\n  key: number | string | symbol,\n  value: any,\n) => boolean;\n\nexport type PickResult<T> = Partial<T> | null | undefined;\n\n/**\n * A function that reduces an object to keys and values that match a predicate.\n *\n * @param predicate -\n *        The predicate to match the key and value against.\n * @param target -\n *        The object to reduce.\n *\n * @returns\n *        A reduced object that only contains key-value pairs that match\n *        the predicate.\n */\nexport function pickBy<T = unknown>(\n  predicate: PickPredicate,\n  target: object,\n): PickResult<T> {\n  const keys = Object.keys(target);\n  const reduced = {};\n\n  keys.forEach((key) => {\n    const value = target[key];\n    if (predicate(key, value)) {\n      reduced[key] = value;\n    }\n  });\n\n  return reduced;\n}\n\n/**\n * An alias to pickBy with a predicate of (_, v) =&gt; v != null.\n *\n * @param target -\n *        The target object to reduce.\n *\n * @returns\n *        The reduced object.\n */\nexport function pickDefined<T = unknown>(target: object): PickResult<T> {\n  return pickBy((_, v) => v != null, target);\n}\n\n/**\n * An alias to pickBy((k) =&gt; k.startsWith('data-')).\n *\n * @param target -\n *        The target object to reduce.\n *\n * @returns\n *        The reduced object.\n */\nexport function pickDataAttributes<T = unknown>(target: object): PickResult<T> {\n  return pickBy((k) => String(k).startsWith(\"data-\"), target);\n}\n\n/**\n * An alias to pickBy((k) =&gt; k.startsWith('on')).\n *\n * @param target -\n *        The target object to reduce.\n *\n * @returns\n *        The reduced object.\n */\nexport function pickEvents<T = unknown>(target: object): PickResult<T> {\n  return pickBy((k) => String(k).startsWith(\"on\"), target);\n}\n","export function purge<T>(obj: T, property: keyof T) {\n  if (obj[property] === undefined) {\n    delete obj[property];\n  }\n}\n","import type { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that deserializes a JSON string.\n */\nexport class ZDeserializeJson<T> implements IZDeserialize<T> {\n  public constructor(private _schema?: (k: any) => k is T) {}\n\n  public deserialize(candidate: string): T {\n    const parsed = JSON.parse(candidate);\n\n    if (this._schema && !this._schema(parsed)) {\n      throw new Error(\n        \"The parsed JSON does not conform to the given schema requirement\",\n      );\n    }\n\n    return parsed;\n  }\n}\n","import type { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that attempts to deserialize multiple times through a series of supported languages.\n *\n * @param T -\n *        The type of data to deserialize.\n * @param S -\n *        The input type\n */\nexport class ZDeserializeTry<T, S = string> implements IZDeserialize<T, S> {\n  /**\n   * Initializes a new instance of this object.\n   *\n   * @param _children -\n   *        The list of deserializer objects to try on a specific candidate.\n   *        The first deserializer to succeed will return the target object.\n   *        If no deserializer is able to deserialize the candidate, then an\n   *        error is throw with a mapping of serialization errors between each\n   *        deserializer.\n   */\n  public constructor(private _children: IZDeserialize<T, S>[]) {}\n\n  public deserialize(candidate: S): T {\n    const errors: string[] = [];\n\n    for (const child of this._children) {\n      try {\n        return child.deserialize(candidate);\n      } catch (e) {\n        errors.push(e.message);\n      }\n    }\n\n    const msg = `Unable to deserialize candidate, ${JSON.stringify(candidate)}.`;\n    errors.splice(0, 0, msg);\n    throw new Error(errors.join(\"\\n\\n\"));\n  }\n}\n","import type { IZSerialize } from \"./serialize.mjs\";\n\n/**\n * Represents a serializer that serializes anything to a JSON string.\n */\nexport class ZSerializeJson implements IZSerialize<any> {\n  public serialize(candidate: any): string | undefined {\n    return JSON.stringify(candidate, undefined, 2);\n  }\n}\n","/**\n * Represents an abstract server connection.\n */\nexport interface IZServer {\n  /**\n   * The host or ip address to connect to.\n   *\n   * Does not distinguish between the protocol and hostname.\n   */\n  address: string;\n\n  /**\n   * The optional port to connect on.\n   *\n   * If this is falsy, then it is up to the implementation\n   * taking this object to properly default the value.\n   */\n  port?: number;\n\n  /**\n   * The optional username.\n   *\n   * Falsy usually implies guest access.\n   */\n  username?: string;\n\n  /**\n   * The user's password to connect with.\n   *\n   * If username is not supplied, then this generally has no meaning.\n   */\n  password?: string;\n}\n\n/**\n * Represents a builder for a server object.\n */\nexport class ZServerBuilder {\n  private _server: IZServer;\n\n  /**\n   * Initializes a new instance of this object.\n   */\n  public constructor() {\n    this._server = {\n      address: \"\",\n    };\n  }\n\n  /**\n   * The server ip address or hostname.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public address(val: string): this {\n    this._server.address = val;\n    return this;\n  }\n\n  /**\n   * Sets the optional port to connect on.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public port(val: number): this {\n    this._server.port = val;\n    return this;\n  }\n\n  /**\n   * Sets the optional username to connect on.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public username(val: string): this {\n    this._server.username = val;\n    return this;\n  }\n\n  /**\n   * Sets the password to connect on.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public password(val: string): this {\n    this._server.password = val;\n    return this;\n  }\n\n  /**\n   * Assigns all truthy properties in other to this object.\n   *\n   * @param other -\n   *        The server object to copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public assign(other: Partial<IZServer>): this {\n    this._server = Object.assign({}, this._server, other);\n    return this;\n  }\n\n  /**\n   * Copies all properties in other to this object.\n   *\n   * @param other -\n   *        The server object to copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public copy(other: IZServer): this {\n    this._server = JSON.parse(JSON.stringify(other));\n    return this;\n  }\n\n  /**\n   * Returns a copy of the built object.\n   *\n   * @returns\n   *        A copy of the built object.\n   */\n  public build(): IZServer {\n    return JSON.parse(JSON.stringify(this._server));\n  }\n}\n","/**\n * Represents a setter function for when you want to set a single value,\n * but you have an array instead.\n *\n * This is useful when you want to support lists of items, but you need\n * backwards compatibility for setting a single item. This is primarily meant\n * to be use with bind to construct a new method setter that takes an array\n * and forwards it to a setter method which will accept a single value of the\n * first item in the target value.\n *\n * @param setValue -\n *        The setter function that takes a single value.  This will receive\n *        the first item of the value list.\n * @param fallback -\n *        The fallback value in the case that there are no values.\n * @param value -\n *        The value list to retrieve the first item from.\n * @param T -\n *        The type of data that the array holds.\n *\n * @example\n *\n * ```ts\n * // An example of a react component that needs a value of an array, but you only care about a single selection.\n * const [value, setValue] = useState<TypesOfPie>();\n * const _values = useMemo(() => value ? [value] : [], [value]);\n * const _setValues = setFirst.bind(null, setValue, undefined);\n *\n * return <ComponentWithMultiSelectSupport values={_values} onValuesChange={_setValues} />\n * ```\n */\nexport function setFirst<T>(\n  setValue: (val: T) => any,\n  fallback: T,\n  value: T[] | null | undefined,\n) {\n  const _value = value?.length ? value[0] : fallback;\n  setValue(_value);\n}\n","/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n *        The total number of milliseconds to sleep.\n *\n * @returns\n *        A promise that resolves after ms milliseconds.\n */\nexport function sleep(ms?: number): Promise<void>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n *        The total number of milliseconds to sleep.\n * @param val -\n *        The value to resolve with.\n * @param T -\n *        The type of value that will be resolved.\n *\n * @returns\n *        A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(ms: number, val: T): Promise<T>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n *        The total number of milliseconds to sleep.\n * @param T -\n *        The type of value that will be resolved.\n *\n * @returns\n *        A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(\n  ms = 0,\n  val: T | undefined = undefined,\n): Promise<T | undefined> {\n  return new Promise<T | undefined>((resolve) =>\n    setTimeout(() => resolve(val), ms),\n  );\n}\n","/**\n * This is just a method that allows you to tag an interpolation\n * string as a syntax language.\n *\n * This is useful with IDE extensions that can detect the language\n * and do the syntax highlighting for you.\n *\n * @param strings -\n *        The string breaks for interpolation.\n * @param expressions -\n *        The equivalent expressions that break apart\n *        the single string literal.\n *\n * @returns\n *        The compiled string literal.  This is no different\n *        than letting native JavaScript do it for you.\n *\n * @example\n *\n * ```ts\n * const html = tag;\n * const css = tag;\n *\n * const $html = html`\n *  <div>Some IDE extensions will highlight this as html</div>\n * `\n *\n * const $css = css`\n *   button {\n *     display: grid;\n *   }\n * `\n * ```\n */\nexport function tag(\n  strings: TemplateStringsArray,\n  ...expressions: unknown[]\n): string {\n  let [result] = strings;\n\n  for (let i = 1, l = strings.length; i < l; i++) {\n    result += String(expressions[i - 1]);\n    result += strings[i];\n  }\n\n  return result;\n}\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html | IDE extensions will detect the string}\n * interpolation as html when using this tag.\n */\nexport const html = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=bashmish.es6-string-css | IDE extensions will detect the string}\n * interpolation as css when using this tag.\n */\nexport const css = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=zjcompt.es6-string-javascript | IDE extensions will detect the string}\n * interpolation as javascript when using this tag.\n */\nexport const js = tag;\n\n/**\n * See {@link js}\n */\nexport const javascript = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=jeoht.es6-string-markdown | IDE extensions will detect the string}\n * interpolation as markdown when using this tag.\n */\nexport const md = tag;\n\n/**\n * See {@link md}\n */\nexport const markdown = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=HoodieCollin.es6-string-typescript | IDE extensions will detect the string}\n * interpolation as typescript when using this tag.\n */\nexport const ts = tag;\n\n/**\n * See {@link ts}\n */\nexport const typescript = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const sh = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const bash = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const zsh = tag;\n","/**\n * Invokes the candidate function and returns undefined if an error is thrown from it.\n *\n * @param candidate -\n *        The candidate function to run.\n *\n * @returns\n *        The result from candidate.  Returns undefined if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T): T | undefined;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n *        The candidate function to run.\n * @param fallback -\n *        The fallback value to return if candidate throws an error.\n *\n * @returns\n *        The result from candidate.  Returns fallback if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T, fallback: T): T;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n *        The candidate function to run.\n * @param fallback -\n *        The fallback value to return if candidate throws an error.\n *\n * @returns\n *        The result from candidate.  Returns fallback if candidate throws an Error.\n *        If no fallback value is provided, then undefined is returned.\n */\nexport function tryFallback<T>(\n  candidate: () => T,\n  fallback?: T,\n): T | undefined {\n  try {\n    return candidate();\n  } catch {\n    return fallback;\n  }\n}\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n *        The candidate function to run.\n *\n * @returns\n *        A promise that resolves with the result from candidate.  Returns undefined\n *        if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n  candidate: () => Promise<T>,\n): Promise<T | undefined>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n *        The candidate function to run.\n * @param fallback -\n *        The fallback value that will be returned if candidate returns a rejected promise.\n *\n * @returns\n *        A promise that resolves with the result from candidate.  Returns fallback\n *        if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n  candidate: () => Promise<T>,\n  fallback: T,\n): Promise<T>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n *        The candidate function to run.\n * @param fallback -\n *        The optional fallback value to return if the candidate throws an Error.\n *\n * @returns\n *        A promise that resolves with the result from candidate or fallback\n *        if candidate returns a rejected promise.  Resolves with undefined\n *        if no fallback is provided.\n */\nexport async function tryFallbackAsync<T>(\n  candidate: () => Promise<T>,\n  fallback?: T,\n): Promise<T | undefined> {\n  try {\n    return await candidate();\n  } catch {\n    return fallback;\n  }\n}\n","import type { ZNullable, ZOptional } from \"../optional/optional.mjs\";\nimport { tryFallback } from \"./try-fallback.mjs\";\n\n/**\n * Attempts to parse the string buffer as json.\n *\n * This is similar to JSON.parse, but instead of throwing\n * an error, it returns null.\n *\n * @param buffer\n *        The string buffer that may be json.\n *\n * @returns\n *        The parsed value of the buffer when parsed as JSON. If\n *        buffer is null, undefined, or does not represent valid\n *        JSON, then null is returned.\n */\nexport function tryJsonParse<T = unknown>(\n  buffer: ZOptional<string>,\n): ZNullable<T>;\n\n/**\n * Attempts to parse the string buffer as json.\n *\n * This is similar to JSON.parse, but instead of throwing\n * an error, it returns a fallback value.\n *\n * @param buffer -\n *        The string buffer that may be json.\n * @param fallback -\n *        The fallback value in the case that buffer\n *        cannot be parsed.  Note that parsing the text\n *        \"null\" will return null instead of the fallback.\n *\n * @returns\n *        The parsed value of the buffer when parsed as JSON. If\n *        buffer is null, undefined, or does not represent valid\n *        JSON, then fallback is returned.\n */\nexport function tryJsonParse<T>(buffer: ZOptional<string>, fallback: T): T;\n\n/**\n * Attempts to parse the string buffer as json.\n *\n * This is similar to JSON.parse, but instead of throwing\n * an error, it returns the fallback.\n *\n * @param buffer -\n *        The string buffer that may be json.\n * @param fallback -\n *        The fallback value in the case that buffer\n *        cannot be parsed.  Note that parsing the text\n *        \"null\" will return null instead of the fallback.\n *        The default value for this is null.\n *\n * @returns\n *        The parsed value of the buffer when parsed as JSON. If\n *        buffer is null, undefined, or does not represent valid\n *        JSON, then the fallback is returned.\n */\nexport function tryJsonParse<T = unknown>(\n  buffer: ZOptional<string>,\n  fallback: ZNullable<T> = null,\n): ZNullable<T> {\n  if (buffer == null) {\n    return fallback;\n  }\n\n  // This is not really necessary because it is handled in the\n  // JSON.parse method, but this avoids parsing random binary data.\n  // If someone tries to read a buffer that's 300MB, there's no point\n  // trying to parse it if it's just random binary data.  This can\n  // still happen if the first binary character is { or [, but\n  // most situations won't have this happen.\n  const [firstChar] = buffer;\n\n  if (firstChar !== \"{\" && firstChar !== \"[\") {\n    return fallback;\n  }\n\n  return tryFallback(() => JSON.parse(buffer), fallback);\n}\n"],"mappings":";;;;;;;;GAGA,IAAO,kBAAKA,uBAAAA,iBAAAA;;;;;IAKT,gBAAA,SAAA;;;IAIA,gBAAA,YAAA;;;;;IAMA,gBAAA,YAAA;CAfSA,OAAAA;AAiBX,EAAA,CAAA,CAAA;;;GAKD,IAAO,oBAAKC,uBAAAA,mBAAAA;;;;;IAKT,kBAAA,UAAA;;;IAIA,kBAAA,YAAA;;;;;IAMA,kBAAA,WAAA;CAfSA,OAAAA;AAiBX,EAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;GC1BD,IAAaC,UAAb,MAAaA,QAAAA;;;;;;;;;;;IAYX,OAAcC,MAAMA,OAAgBC,KAAmB;EACrD,OAAO,IAAIF,QAAAA,CAAAA,CAAUC,MAAMA,OAAOC,GAAAA;CACpC;CAEQC,YAAmB,CAAA;;;IAK3B,cAAsB,CAAC;;;;;;;;;;IAYvB,MAAaF,OAAgBC,KAAgB;EAC3C,IAA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