var h=Object.defineProperty;var t=(e,n)=>h(e,"name",{value:n,configurable:!0});var y=(e,n)=>{for(var i in n)h(e,i,{get:n[i],enumerable:!0})};var c={};y(c,{$decorators:()=>l,$lib:()=>o,$onValidate:()=>p,isTerminalEvent:()=>u});import{createTypeSpecLibrary as v}from"@typespec/compiler";var o=v({name:"@typespec/sse",diagnostics:{"terminal-event-not-in-events":{severity:"error",messages:{default:"A field marked as '@terminalEvent' must be a member of a type decorated with '@TypeSpec.Events.events'."}},"sse-stream-union-not-events":{severity:"error",messages:{default:"SSEStream type parameter must be a union decorated with '@TypeSpec.Events.events'."}}},state:{terminalEvent:{description:"State for the @terminalEvent decorator."}}}),{reportDiagnostic:r,createDiagnostic:L,stateKeys:s}=o;import{useStateSet as T}from"@typespec/compiler/utils";var[u,x]=T(s.terminalEvent),f=t((e,n)=>{x(e.program,n)},"$terminalEventDecorator");var d={};y(d,{$decorators:()=>l,$lib:()=>o,$onValidate:()=>p});import{navigateProgram as w}from"@typespec/compiler";import{isEvents as g}from"@typespec/events";import{getContentTypes as P}from"@typespec/http";import{getStreamOf as S}from"@typespec/streams";function p(e){k(e),O(e)}t(p,"$onValidate");function k(e){e.stateSet(s.terminalEvent).forEach(n=>{"union"in n&&M(e,n)})}t(k,"checkForIncorrectlyAssignedTerminalEvents");function M(e,n){g(e,n.union)||r(e,{code:"terminal-event-not-in-events",target:n})}t(M,"validateTerminalEvent");function O(e){w(e,{model:t(n=>{A(e,n)},"model")})}t(O,"checkForSSEStreamWithoutEventsDecorator");function A(e,n){let i=S(e,n);if(!i)return;let m=n.properties.get("contentType");if(!m)return;let[b]=P(m);if(b.includes("text/event-stream")){if(i.kind!=="Union"){r(e,{code:"sse-stream-union-not-events",target:n});return}g(e,i)||r(e,{code:"sse-stream-union-not-events",target:n})}}t(A,"validateSSEStream");var l={"TypeSpec.SSE":{terminalEvent:f}};var C={"dist/src/index.js":c,"dist/src/tsp-index.js":d},D={"package.json":'{"name":"@typespec/sse","version":"0.83.0","author":"Microsoft Corporation","description":"TypeSpec library providing server sent events bindings","homepage":"https://typespec.io","readme":"https://github.com/microsoft/typespec/blob/main/README.md","license":"MIT","repository":{"type":"git","url":"git+https://github.com/microsoft/typespec.git"},"bugs":{"url":"https://github.com/microsoft/typespec/issues"},"keywords":["typespec"],"type":"module","main":"dist/src/index.js","tspMain":"lib/main.tsp","exports":{".":{"typespec":"./lib/main.tsp","default":"./dist/src/index.js"},"./testing":"./dist/src/testing/index.js"},"engines":{"node":">=22.0.0"},"scripts":{"clean":"rimraf ./dist ./temp","build":"pnpm gen-extern-signature && tsc -p tsconfig.build.json && pnpm lint-typespec-library","watch":"tsc -p tsconfig.build.json --watch","gen-extern-signature":"tspd --enable-experimental gen-extern-signature .","lint-typespec-library":"tsp compile . --warn-as-error --import @typespec/library-linter --no-emit","test":"vitest run","test:watch":"vitest -w","test:ui":"vitest --ui","test-official":"vitest run --coverage --reporter=junit --reporter=default --no-file-parallelism","lint":"eslint . --ext .ts --max-warnings=0","lint:fix":"eslint . --fix --ext .ts","regen-docs":"tspd doc .  --enable-experimental  --output-dir ../../website/src/content/docs/docs/libraries/sse/reference"},"files":["lib/*.tsp","dist/**","!dist/test/**"],"peerDependencies":{"@typespec/compiler":"workspace:^","@typespec/events":"workspace:^","@typespec/http":"workspace:^","@typespec/streams":"workspace:^"},"devDependencies":{"@types/node":"catalog:","@typespec/compiler":"workspace:^","@typespec/events":"workspace:^","@typespec/http":"workspace:^","@typespec/library-linter":"workspace:^","@typespec/streams":"workspace:^","@typespec/tspd":"workspace:^","@vitest/coverage-v8":"catalog:","@vitest/ui":"catalog:","rimraf":"catalog:","typescript":"catalog:","vitest":"catalog:"}}',"../compiler/lib/intrinsics.tsp":`import "../dist/src/lib/intrinsic/tsp-index.js";
import "./prototypes.tsp";

// This file contains all the intrinsic types of typespec. Everything here will always be loaded
namespace TypeSpec;

/**
 * Represent a byte array
 */
scalar bytes;

/**
 * A numeric type
 */
scalar numeric;

/**
 * A whole number. This represent any \`integer\` value possible.
 * It is commonly represented as \`BigInteger\` in some languages.
 */
scalar integer extends numeric;

/**
 * A number with decimal value
 */
scalar float extends numeric;

/**
 * A 64-bit integer. (\`-9,223,372,036,854,775,808\` to \`9,223,372,036,854,775,807\`)
 */
scalar int64 extends integer;

/**
 * A 32-bit integer. (\`-2,147,483,648\` to \`2,147,483,647\`)
 */
scalar int32 extends int64;

/**
 * A 16-bit integer. (\`-32,768\` to \`32,767\`)
 */
scalar int16 extends int32;

/**
 * A 8-bit integer. (\`-128\` to \`127\`)
 */
scalar int8 extends int16;

/**
 * A 64-bit unsigned integer (\`0\` to \`18,446,744,073,709,551,615\`)
 */
scalar uint64 extends integer;

/**
 * A 32-bit unsigned integer (\`0\` to \`4,294,967,295\`)
 */
scalar uint32 extends uint64;

/**
 * A 16-bit unsigned integer (\`0\` to \`65,535\`)
 */
scalar uint16 extends uint32;

/**
 * A 8-bit unsigned integer (\`0\` to \`255\`)
 */
scalar uint8 extends uint16;

/**
 * An integer that can be serialized to JSON (\`\u22129007199254740991 (\u2212(2^53 \u2212 1))\` to \`9007199254740991 (2^53 \u2212 1)\` )
 */
scalar safeint extends int64;

/**
 * A 64 bit floating point number. (\`\xB15.0 \xD7 10^\u2212324\` to \`\xB11.7 \xD7 10^308\`)
 */
scalar float64 extends float;

/**
 * A 32 bit floating point number. (\`\xB11.5 x 10^\u221245\` to \`\xB13.4 x 10^38\`)
 */
scalar float32 extends float64;

/**
 * A decimal number with any length and precision. This represent any \`decimal\` value possible.
 * It is commonly represented as \`BigDecimal\` in some languages.
 */
scalar decimal extends numeric;

/**
 * A 128-bit decimal number.
 */
scalar decimal128 extends decimal;

/**
 * A sequence of textual characters.
 */
scalar string;

/**
 * A date on a calendar without a time zone, e.g. "April 10th"
 */
scalar plainDate {
  /**
   * Create a plain date from an ISO 8601 string.
   * @example
   *
   * \`\`\`tsp
   * const date = plainDate.fromISO("2024-05-06");
   * \`\`\`
   */
  init fromISO(value: string);

  /**
   * Create a plain date representing the current date.
   * @example
   *
   * \`\`\`tsp
   * const date = plainDate.now();
   * \`\`\`
   */
  init now();
}

/**
 * A time on a clock without a time zone, e.g. "3:00 am"
 */
scalar plainTime {
  /**
   * Create a plain time from an ISO 8601 string.
   * @example
   *
   * \`\`\`tsp
   * const time = plainTime.fromISO("12:34");
   * \`\`\`
   */
  init fromISO(value: string);

  /**
   * Create a plain time representing the current time.
   * @example
   *
   * \`\`\`tsp
   * const time = plainTime.now();
   * \`\`\`
   */
  init now();
}

/**
 * An instant in coordinated universal time (UTC)"
 */
scalar utcDateTime {
  /**
   * Create a date from an ISO 8601 string.
   * @example
   *
   * \`\`\`tsp
   * const time = utcDateTime.fromISO("2024-05-06T12:20-12Z");
   * \`\`\`
   */
  init fromISO(value: string);

  /**
   * Create a date representing the current date and time in UTC.
   * @example
   *
   * \`\`\`tsp
   * const time = utcDateTime.now();
   * \`\`\`
   */
  init now();
}

/**
 * A date and time in a particular time zone, e.g. "April 10th at 3:00am in PST"
 */
scalar offsetDateTime {
  /**
   * Create a date from an ISO 8601 string.
   * @example
   *
   * \`\`\`tsp
   * const time = offsetDateTime.fromISO("2024-05-06T12:20-12-0700");
   * \`\`\`
   */
  init fromISO(value: string);

  /**
   * Create a date representing the current date and time with offset.
   * @example
   *
   * \`\`\`tsp
   * const time = offsetDateTime.now();
   * \`\`\`
   */
  init now();
}

/**
 * A duration/time period. e.g 5s, 10h
 */
scalar duration {
  /**
   * Create a duration from an ISO 8601 string.
   * @example
   *
   * \`\`\`tsp
   * const time = duration.fromISO("P1Y1D");
   * \`\`\`
   */
  init fromISO(value: string);
}

/**
 * Boolean with \`true\` and \`false\` values.
 */
scalar boolean;

/**
 * @dev Array model type, equivalent to \`Element[]\`
 * @template Element The type of the array elements
 */
@indexer(integer, Element)
model Array<Element> {}

/**
 * @dev Model with string properties where all the properties have type \`Property\`
 * @template Element The type of the properties
 */
@indexer(string, Element)
model Record<Element> {}
`,"../compiler/lib/prototypes.tsp":`namespace TypeSpec.Prototypes;

internal extern dec getter(target: unknown);

namespace Types {
  interface ModelProperty {
    @getter type(): unknown;
  }

  interface Operation {
    @getter returnType(): unknown;
    @getter parameters(): unknown;
  }

  interface Array<TElementType> {
    @getter elementType(): TElementType;
  }
}
`,"../compiler/lib/std/main.tsp":`// TypeSpec standard library. Everything in here can be omitted by using \`--nostdlib\` cli flag or \`nostdlib\` in the config.
import "./types.tsp";
import "./decorators.tsp";
import "./reflection.tsp";
import "./visibility.tsp";
`,"../compiler/lib/std/types.tsp":`namespace TypeSpec;

/**
 * Represent a 32-bit unix timestamp datetime with 1s of granularity.
 * It measures time by the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970.
 */
@encode("unixTimestamp", int32)
scalar unixTimestamp32 extends utcDateTime;

/**
 * Represent a URL string as described by https://url.spec.whatwg.org/
 */
scalar url extends string;

/**
 * Represents a collection of optional properties.
 *
 * @template Source An object whose spread properties are all optional.
 */
@doc("The template for adding optional properties.")
@withOptionalProperties
model OptionalProperties<Source> {
  ...Source;
}

/**
 * Represents a collection of updateable properties.
 *
 * @template Source An object whose spread properties are all updateable.
 */
@doc("The template for adding updateable properties.")
@withUpdateableProperties
model UpdateableProperties<Source> {
  ...Source;
}

/**
 * Represents a collection of omitted properties.
 *
 * @template Source An object whose properties are spread.
 * @template Keys The property keys to omit.
 */
@doc("The template for omitting properties.")
@withoutOmittedProperties(Keys)
model OmitProperties<Source, Keys extends string> {
  ...Source;
}

/**
 * Represents a collection of properties with only the specified keys included.
 *
 * @template Source An object whose properties are spread.
 * @template Keys The property keys to include.
 */
@doc("The template for picking properties.")
@withPickedProperties(Keys)
model PickProperties<Source, Keys extends string> {
  ...Source;
}

/**
 * Represents a collection of properties with default values omitted.
 *
 * @template Source An object whose spread property defaults are all omitted.
 */
@withoutDefaultValues
model OmitDefaults<Source> {
  ...Source;
}

/**
 * Applies a visibility setting to a collection of properties.
 *
 * @template Source An object whose properties are spread.
 * @template Visibility The visibility to apply to all properties.
 */
@doc("The template for setting the default visibility of key properties.")
@withDefaultKeyVisibility(Visibility)
model DefaultKeyVisibility<Source, Visibility extends valueof Reflection.EnumMember> {
  ...Source;
}
`,"../compiler/lib/std/decorators.tsp":`import "../../dist/src/lib/tsp-index.js";

using TypeSpec.Reflection;

namespace TypeSpec;

/**
 * Typically a short, single-line description.
 * @param summary Summary string.
 *
 * @example
 * \`\`\`typespec
 * @summary("This is a pet")
 * model Pet {}
 * \`\`\`
 */
extern dec summary(target: unknown, summary: valueof string);

/**
 * Attach a documentation string. Content support CommonMark markdown formatting.
 * @param doc Documentation string
 * @param formatArgs Record with key value pair that can be interpolated in the doc.
 *
 * @example
 * \`\`\`typespec
 * @doc("Represent a Pet available in the PetStore")
 * model Pet {}
 * \`\`\`
 */
extern dec doc(target: unknown, doc: valueof string, formatArgs?: {});

/**
 * Attach a documentation string to describe the successful return types of an operation.
 * If an operation returns a union of success and errors it only describes the success. See \`@errorsDoc\` for error documentation.
 * @param doc Documentation string
 *
 * @example
 * \`\`\`typespec
 * @returnsDoc("Returns doc")
 * op get(): Pet | NotFound;
 * \`\`\`
 */
extern dec returnsDoc(target: Operation, doc: valueof string);

/**
 * Attach a documentation string to describe the error return types of an operation.
 * If an operation returns a union of success and errors it only describes the errors. See \`@returnsDoc\` for success documentation.
 * @param doc Documentation string
 *
 * @example
 * \`\`\`typespec
 * @errorsDoc("Errors doc")
 * op get(): Pet | NotFound;
 * \`\`\`
 */
extern dec errorsDoc(target: Operation, doc: valueof string);

/**
 * Service options.
 */
model ServiceOptions {
  /**
   * Title of the service.
   */
  title?: string;
}

/**
 * Mark this namespace as describing a service and configure service properties.
 * @param options Optional configuration for the service.
 *
 * @example
 * \`\`\`typespec
 * @service
 * namespace PetStore;
 * \`\`\`
 *
 * @example Setting service title
 * \`\`\`typespec
 * @service(#{title: "Pet store"})
 * namespace PetStore;
 * \`\`\`
 */
extern dec service(target: Namespace, options?: valueof ServiceOptions);

/**
 * Specify that this model is an error type. Operations return error types when the operation has failed.
 *
 * @example
 * \`\`\`typespec
 * @error
 * model PetStoreError {
 *   code: string;
 *   message: string;
 * }
 * \`\`\`
 */
extern dec error(target: Model);

/**
 * Applies a media type hint to a TypeSpec type. Emitters and libraries may choose to use this hint to determine how a
 * type should be serialized. For example, the \`@typespec/http\` library will use the media type hint of the response
 * body type as a default \`Content-Type\` if one is not explicitly specified in the operation.
 *
 * Media types (also known as MIME types) are defined by RFC 6838. The media type hint should be a valid media type
 * string as defined by the RFC, but the decorator does not enforce or validate this constraint.
 *
 * Notes: the applied media type is _only_ a hint. It may be overridden or not used at all. Media type hints are
 * inherited by subtypes. If a media type hint is applied to a model, it will be inherited by all other models that
 * \`extend\` it unless they delcare their own media type hint.
 *
 * @param mediaType The media type hint to apply to the target type.
 *
 * @example create a model that serializes as XML by default
 *
 * \`\`\`tsp
 * @mediaTypeHint("application/xml")
 * model Example {
 *   @visibility(Lifecycle.Read)
 *   id: string;
 *
 *   name: string;
 * }
 * \`\`\`
 */
extern dec mediaTypeHint(target: Model | Scalar | Enum | Union, mediaType: valueof string);

// Cannot apply this to the scalar itself. Needs to be applied here so that we don't crash nostdlib scenarios
@@mediaTypeHint(TypeSpec.bytes, "application/octet-stream");

// @@mediaTypeHint(TypeSpec.string "text/plain") -- This is hardcoded in the compiler to avoid circularity
// between the initialization of the string scalar and the \`valueof string\` required to call the
// \`mediaTypeHint\` decorator.

/**
 * Specify a known data format hint for this string type. For example \`uuid\`, \`uri\`, etc.
 * This differs from the \`@pattern\` decorator which is meant to specify a regular expression while \`@format\` accepts a known format name.
 * The format names are open ended and are left to emitter to interpret.
 *
 * @param format format name.
 *
 * @example
 * \`\`\`typespec
 * @format("uuid")
 * scalar uuid extends string;
 * \`\`\`
 */
extern dec format(target: string | ModelProperty, format: valueof string);

/**
 * Specify the the pattern this string should respect using simple regular expression syntax.
 * The following syntax is allowed: alternations (\`|\`), quantifiers (\`?\`, \`*\`, \`+\`, and \`{ }\`), wildcard (\`.\`), and grouping parentheses.
 * Advanced features like look-around, capture groups, and references are not supported.
 *
 * This decorator may optionally provide a custom validation _message_. Emitters may choose to use the message to provide
 * context when pattern validation fails. For the sake of consistency, the message should be a phrase that describes in
 * plain language what sort of content the pattern attempts to validate. For example, a complex regular expression that
 * validates a GUID string might have a message like "Must be a valid GUID."
 *
 * @param pattern Regular expression.
 * @param validationMessage Optional validation message that may provide context when validation fails.
 *
 * @example
 * \`\`\`typespec
 * @pattern("[a-z]+", "Must be a string consisting of only lower case letters and of at least one character.")
 * scalar LowerAlpha extends string;
 * \`\`\`
 */
extern dec pattern(
  target: string | bytes | ModelProperty,
  pattern: valueof string,
  validationMessage?: valueof string
);

/**
 * Specify the minimum length this string type should be.
 * @param value Minimum length
 *
 * @example
 * \`\`\`typespec
 * @minLength(2)
 * scalar Username extends string;
 * \`\`\`
 */
extern dec minLength(target: string | ModelProperty, value: valueof integer);

/**
 * Specify the maximum length this string type should be.
 * @param value Maximum length
 *
 * @example
 * \`\`\`typespec
 * @maxLength(20)
 * scalar Username extends string;
 * \`\`\`
 */
extern dec maxLength(target: string | ModelProperty, value: valueof integer);

/** Types that can have range limits */
alias RangeLimitableTypes =
  | numeric
  | utcDateTime
  | offsetDateTime
  | plainDate
  | plainTime
  | duration;

/**
 * Specify the minimum number of items this array should have.
 * @param value Minimum number
 *
 * @example
 * \`\`\`typespec
 * @minItems(1)
 * model Endpoints is string[];
 * \`\`\`
 */
extern dec minItems(target: unknown[] | ModelProperty, value: valueof integer);

/**
 * Specify the maximum number of items this array should have.
 * @param value Maximum number
 *
 * @example
 * \`\`\`typespec
 * @maxItems(5)
 * model Endpoints is string[];
 * \`\`\`
 */
extern dec maxItems(target: unknown[] | ModelProperty, value: valueof integer);

/**
 * Specify the minimum value this numeric type should be.
 * @param value Minimum value
 *
 * @example
 * \`\`\`typespec
 * @minValue(18)
 * scalar Age is int32;
 * \`\`\`
 */
extern dec minValue(
  target: RangeLimitableTypes | ModelProperty,
  value: valueof RangeLimitableTypes
);

/**
 * Specify the maximum value this numeric type should be.
 * @param value Maximum value
 *
 * @example
 * \`\`\`typespec
 * @maxValue(200)
 * scalar Age is int32;
 * \`\`\`
 */
extern dec maxValue(
  target: RangeLimitableTypes | ModelProperty,
  value: valueof RangeLimitableTypes
);

/**
 * Specify the minimum value this numeric type should be, exclusive of the given
 * value.
 * @param value Minimum value
 *
 * @example
 * \`\`\`typespec
 * @minValueExclusive(0)
 * scalar distance is float64;
 * \`\`\`
 */
extern dec minValueExclusive(
  target: RangeLimitableTypes | ModelProperty,
  value: valueof RangeLimitableTypes
);

/**
 * Specify the maximum value this numeric type should be, exclusive of the given
 * value.
 * @param value Maximum value
 *
 * @example
 * \`\`\`typespec
 * @maxValueExclusive(50)
 * scalar distance is float64;
 * \`\`\`
 */
extern dec maxValueExclusive(
  target: RangeLimitableTypes | ModelProperty,
  value: valueof RangeLimitableTypes
);

/**
 * Mark this value as a secret value that should be treated carefully to avoid exposure
 *
 * @example
 * \`\`\`typespec
 * @secret
 * scalar Password is string;
 * \`\`\`
 */
extern dec secret(target: Scalar | ModelProperty | Model | Union | Enum);

/**
 * Attaches a tag to an operation, interface, or namespace. Multiple \`@tag\` decorators can be specified to attach multiple tags to a TypeSpec element.
 * @param tag Tag value
 */
extern dec tag(target: Namespace | Interface | Operation, tag: valueof string);

/**
 * Specifies how a templated type should name their instances.
 * @param name name the template instance should take
 * @param formatArgs Model with key value used to interpolate the name
 *
 * @example
 * \`\`\`typespec
 * @friendlyName("{name}List", T)
 * model List<Item> {
 *   value: Item[];
 *   nextLink: string;
 * }
 * \`\`\`
 */
extern dec friendlyName(target: unknown, name: valueof string, formatArgs?: unknown);

/**
 * Mark a model property as the key to identify instances of that type
 * @param altName Name of the property. If not specified, the decorated property name is used.
 *
 * @example
 * \`\`\`typespec
 * model Pet {
 *   @key id: string;
 * }
 * \`\`\`
 */
extern dec key(target: ModelProperty, altName?: valueof string);

/**
 * Specify this operation is an overload of the given operation.
 * @param overloadbase Base operation that should be a union of all overloads
 *
 * @example
 * \`\`\`typespec
 * op upload(data: string | bytes, @header contentType: "text/plain" | "application/octet-stream"): void;
 * @overload(upload)
 * op uploadString(data: string, @header contentType: "text/plain" ): void;
 * @overload(upload)
 * op uploadBytes(data: bytes, @header contentType: "application/octet-stream"): void;
 * \`\`\`
 */
extern dec overload(target: Operation, overloadbase: Operation);

/**
 * Provide an alternative name for this type when serialized to the given mime type.
 * @param mimeType Mime type this should apply to. The mime type should be a known mime type as described here https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types without any suffix (e.g. \`+json\`)
 * @param name Alternative name
 *
 * @example
 *
 * \`\`\`typespec
 * model Certificate {
 *   @encodedName("application/json", "exp")
 *   @encodedName("application/xml", "expiry")
 *   expireAt: int32;
 * }
 * \`\`\`
 *
 * @example Invalid values
 *
 * \`\`\`typespec
 * @encodedName("application/merge-patch+json", "exp")
 *              ^ error cannot use subtype
 * \`\`\`
 */
extern dec encodedName(target: unknown, mimeType: valueof string, name: valueof string);

/**
 * Options for \`@discriminated\` decorator.
 */
model DiscriminatedOptions {
  /**
   * How is the discriminated union serialized.
   * @default object
   */
  envelope?: "object" | "none";

  /** Name of the discriminator property */
  discriminatorPropertyName?: string;

  /** Name of the property envelopping the data */
  envelopePropertyName?: string;
}

/**
 * Specify that this union is discriminated.
 * @param options Options to configure the serialization of the discriminated union.
 *
 * @example
 *
 * \`\`\`typespec
 * @discriminated
 * union Pet{ cat: Cat, dog: Dog }
 *
 * model Cat { name: string, meow: boolean }
 * model Dog { name: string, bark: boolean }
 * \`\`\`
 * Serialized as:
 * \`\`\`json
 * {
 *   "kind": "cat",
 *   "value": {
 *     "name": "Whiskers",
 *     "meow": true
 *   }
 * },
 * {
 *   "kind": "dog",
 *   "value": {
 *     "name": "Rex",
 *     "bark": false
 *   }
 * }
 * \`\`\`
 *
 * @example Custom property names
 *
 * \`\`\`typespec
 * @discriminated(#{discriminatorPropertyName: "dataKind", envelopePropertyName: "data"})
 * union Pet{ cat: Cat, dog: Dog }
 *
 * model Cat { name: string, meow: boolean }
 * model Dog { name: string, bark: boolean }
 * \`\`\`
 * Serialized as:
 * \`\`\`json
 * {
 *   "dataKind": "cat",
 *   "data": {
 *     "name": "Whiskers",
 *     "meow": true
 *   }
 * },
 * {
 *   "dataKind": "dog",
 *   "data": {
 *     "name": "Rex",
 *     "bark": false
 *   }
 * }
 * \`\`\`
 */
extern dec discriminated(target: Union, options?: valueof DiscriminatedOptions);

/**
 * Specify the property to be used to discriminate this type.
 * @param propertyName The property name to use for discrimination
 *
 * @example
 *
 * \`\`\`typespec
 * @discriminator("kind")
 * model Pet{ kind: string }
 *
 * model Cat extends Pet {kind: "cat", meow: boolean}
 * model Dog extends Pet  {kind: "dog", bark: boolean}
 * \`\`\`
 */
extern dec discriminator(target: Model, propertyName: valueof string);

/**
 * Known encoding to use on utcDateTime or offsetDateTime
 */
enum DateTimeKnownEncoding {
  /**
   * RFC 3339 standard. https://www.ietf.org/rfc/rfc3339.txt
   * Encode to string.
   */
  rfc3339: "rfc3339",

  /**
   * RFC 7231 standard. https://www.ietf.org/rfc/rfc7231.txt
   * Encode to string.
   */
  rfc7231: "rfc7231",

  /**
   * Encode a datetime to a unix timestamp.
   * Unix timestamps are represented as an integer number of seconds since the Unix epoch and usually encoded as an int32.
   */
  unixTimestamp: "unixTimestamp",
}

/**
 * Known encoding to use on duration
 */
enum DurationKnownEncoding {
  /**
   * ISO8601 duration
   */
  ISO8601: "ISO8601",

  /**
   * Encode to integer or float as seconds
   */
  seconds: "seconds",

  /**
   * Encode to integer or float as milliseconds
   */
  milliseconds: "milliseconds",
}

/**
 * Known encoding to use on bytes
 */
enum BytesKnownEncoding {
  /**
   * Encode to Base64
   */
  base64: "base64",

  /**
   * Encode to Base64 Url
   */
  base64url: "base64url",
}

/**
 * Encoding for serializing arrays
 */
enum ArrayEncoding {
  /**
   * Each value of the array is separated by a pipe character (|).
   * Values can only contain | if the underlying protocol supports encoding them.
   * - json -> error
   * - http -> %7C
   */
  pipeDelimited,

  /**
   * Each value of the array is separated by a space character.
   * Values can only contain spaces if the underlying protocol supports encoding them.
   * - json -> error
   * - http -> %20
   */
  spaceDelimited,

  /**
   * Each value of the array is separated by a comma (,).
   * Values can only contain commas if the underlying protocol supports encoding them.
   * - json -> error
   * - http -> %2C
   */
  commaDelimited,

  /**
   * Each value of the array is separated by a newline character (\\n).
   * Values can only contain newlines if the underlying protocol supports encoding them.
   * - json -> error
   * - http -> %0A
   */
  newlineDelimited,
}

/**
 * Specify how to encode the target type.
 * @param encodingOrEncodeAs Known name of an encoding or a scalar type to encode as(Only for numeric types to encode as string).
 * @param encodedAs What target type is this being encoded as. Default to string.
 *
 * @example offsetDateTime encoded with rfc7231
 *
 * \`\`\`tsp
 * @encode("rfc7231")
 * scalar myDateTime extends offsetDateTime;
 * \`\`\`
 *
 * @example utcDateTime encoded with unixTimestamp
 *
 * \`\`\`tsp
 * @encode("unixTimestamp", int32)
 * scalar myDateTime extends unixTimestamp;
 * \`\`\`
 *
 * @example encode numeric type to string
 *
 * \`\`\`tsp
 * model Pet {
 *   @encode(string) id: int64;
 * }
 * \`\`\`
 */
extern dec encode(
  target: Scalar | ModelProperty,
  encodingOrEncodeAs: (valueof string | EnumMember) | Scalar,
  encodedAs?: Scalar
);

/** Options for example decorators */
model ExampleOptions {
  /** The title of the example */
  title?: string;

  /** Description of the example */
  description?: string;
}

/**
 * Provide an example value for a data type.
 *
 * @param example Example value.
 * @param options Optional metadata for the example.
 *
 * @example
 *
 * \`\`\`tsp
 * @example(#{name: "Fluffy", age: 2})
 * model Pet {
 *  name: string;
 *  age: int32;
 * }
 * \`\`\`
 */
extern dec example(
  target: Model | Enum | Scalar | Union | ModelProperty | UnionVariant,
  example: valueof unknown,
  options?: valueof ExampleOptions
);

/**
 * Operation example configuration.
 */
model OperationExample {
  /** Example request body. */
  parameters?: unknown;

  /** Example response body. */
  returnType?: unknown;
}

/**
 * Provide example values for an operation's parameters and corresponding return type.
 *
 * @param example Example value.
 * @param options Optional metadata for the example.
 *
 * @example
 *
 * \`\`\`tsp
 * @opExample(#{parameters: #{name: "Fluffy", age: 2}, returnType: #{name: "Fluffy", age: 2, id: "abc"})
 * op createPet(pet: Pet): Pet;
 * \`\`\`
 */
extern dec opExample(
  target: Operation,
  example: valueof OperationExample,
  options?: valueof ExampleOptions
);

/**
 * Returns the model with required properties removed.
 */
extern dec withOptionalProperties(target: Model);

/**
 * Returns the model with any default values removed.
 */
extern dec withoutDefaultValues(target: Model);

/**
 * Returns the model with the given properties omitted.
 * @param omit List of properties to omit
 */
extern dec withoutOmittedProperties(target: Model, omit: string | Union);

/**
 * Returns the model with only the given properties included.
 * @param pick List of properties to include
 */
extern dec withPickedProperties(target: Model, pick: string | Union);

//---------------------------------------------------------------------------
// Paging
//---------------------------------------------------------------------------

/**
 * Mark this operation as a \`list\` operation that returns a paginated list of items.
 */
extern dec list(target: Operation);

/**
 * Pagination property defining the number of items to skip.
 * @example
 * \`\`\`tsp
 * model Page<T> {
 *   @pageItems items: T[];
 * }
 * @list op listPets(@offset skip: int32, @pageSize pageSize: int8): Page<Pet>;
 * \`\`\`
 */
extern dec offset(target: ModelProperty);

/**
 * Pagination property defining the page index.
 *
 * @example
 * \`\`\`tsp
 * model Page<T> {
 *   @pageItems items: T[];
 * }
 * @list op listPets(@pageIndex page: int32, @pageSize pageSize: int8): Page<Pet>;
 * \`\`\`
 */
extern dec pageIndex(target: ModelProperty);

/**
 * Specify the pagination parameter that controls the maximum number of items to include in a page.
 *
 * @example
 * \`\`\`tsp
 * model Page<T> {
 *   @pageItems items: T[];
 * }
 * @list op listPets(@pageIndex page: int32, @pageSize pageSize: int8): Page<Pet>;
 * \`\`\`
 */
extern dec pageSize(target: ModelProperty);

/**
 * Specify the the property that contains the array of page items.
 *
 * @example
 * \`\`\`tsp
 * model Page<T> {
 *   @pageItems items: T[];
 * }
 * @list op listPets(@pageIndex page: int32, @pageSize pageSize: int8): Page<Pet>;
 * \`\`\`
 */
extern dec pageItems(target: ModelProperty);

/**
 * Pagination property defining the token to get to the next page.
 * It MUST be specified both on the request parameter and the response.
 *
 * @example
 * \`\`\`tsp
 * model Page<T> {
 *   @pageItems items: T[];
 *   @continuationToken continuationToken: string;
 * }
 * @list op listPets(@continuationToken continuationToken: string): Page<Pet>;
 * \`\`\`
 */
extern dec continuationToken(target: ModelProperty);

/**
 * Pagination property defining a link to the next page.
 *
 * It is expected that navigating to the link will return the same set of responses as the operation that returned the current page.
 *
 * @example
 * \`\`\`tsp
 * model Page<T> {
 *   @pageItems items: T[];
 *   @nextLink next: url;
 *   @prevLink prev: url;
 *   @firstLink first: url;
 *   @lastLink last: url;
 * }
 * @list op listPets(): Page<Pet>;
 * \`\`\`
 */
extern dec nextLink(target: ModelProperty);

/**
 * Pagination property defining a link to the previous page.
 *
 * It is expected that navigating to the link will return the same set of responses as the operation that returned the current page.
 *
 * @example
 * \`\`\`tsp
 * model Page<T> {
 *   @pageItems items: T[];
 *   @nextLink next: url;
 *   @prevLink prev: url;
 *   @firstLink first: url;
 *   @lastLink last: url;
 * }
 * @list op listPets(): Page<Pet>;
 * \`\`\`
 */
extern dec prevLink(target: ModelProperty);

/**
 * Pagination property defining a link to the first page.
 *
 * It is expected that navigating to the link will return the same set of responses as the operation that returned the current page.
 *
 * @example
 * \`\`\`tsp
 * model Page<T> {
 *   @pageItems items: T[];
 *   @nextLink next: url;
 *   @prevLink prev: url;
 *   @firstLink first: url;
 *   @lastLink last: url;
 * }
 * @list op listPets(): Page<Pet>;
 * \`\`\`
 */
extern dec firstLink(target: ModelProperty);

/**
 * Pagination property defining a link to the last page.
 *
 * It is expected that navigating to the link will return the same set of responses as the operation that returned the current page.
 *
 * @example
 * \`\`\`tsp
 * model Page<T> {
 *   @pageItems items: T[];
 *   @nextLink next: url;
 *   @prevLink prev: url;
 *   @firstLink first: url;
 *   @lastLink last: url;
 * }
 * @list op listPets(): Page<Pet>;
 * \`\`\`
 */
extern dec lastLink(target: ModelProperty);

//---------------------------------------------------------------------------
// Debugging
//---------------------------------------------------------------------------

/**
 * A debugging decorator used to inspect a type.
 * @param text Custom text to log
 */
extern dec inspectType(target: unknown, text: valueof string);

/**
 * A debugging decorator used to inspect a type name.
 * @param text Custom text to log
 */
extern dec inspectTypeName(target: unknown, text: valueof string);
`,"../compiler/lib/std/reflection.tsp":`namespace TypeSpec.Reflection;

model Enum {}
model EnumMember {}
model Interface {}
model Model {}
model ModelProperty {}
model Namespace {}
model Operation {}
model Scalar {}
model Union {}
model UnionVariant {}
model StringTemplate {}
`,"../compiler/lib/std/visibility.tsp":`// Copyright (c) Microsoft Corporation
// Licensed under the MIT license.

import "../../dist/src/lib/tsp-index.js";

using TypeSpec.Reflection;

namespace TypeSpec;

/**
 * Sets the visibility modifiers that are active on a property, indicating that it is only considered to be present
 * (or "visible") in contexts that select for the given modifiers.
 *
 * A property without any visibility settings applied for any visibility class (e.g. \`Lifecycle\`) is considered to have
 * the default visibility settings for that class.
 *
 * If visibility for the property has already been set for a visibility class (for example, using \`@invisible\` or
 * \`@removeVisibility\`), this decorator will **add** the specified visibility modifiers to the property.
 *
 * See: [Visibility](https://typespec.io/docs/language-basics/visibility)
 *
 * The \`@typespec/http\` library uses \`Lifecycle\` visibility to determine which properties are included in the request or
 * response bodies of HTTP operations. By default, it uses the following visibility settings:
 *
 * - For the return type of operations, properties are included if they have \`Lifecycle.Read\` visibility.
 * - For POST operation parameters, properties are included if they have \`Lifecycle.Create\` visibility.
 * - For PUT operation parameters, properties are included if they have \`Lifecycle.Create\` or \`Lifecycle.Update\` visibility.
 * - For PATCH operation parameters, properties are included if they have \`Lifecycle.Update\` visibility.
 * - For DELETE operation parameters, properties are included if they have \`Lifecycle.Delete\` visibility.
 * - For GET or HEAD operation parameters, properties are included if they have \`Lifecycle.Query\` visibility.
 *
 * By default, properties have all five Lifecycle visibility modifiers enabled, so a property is visible in all contexts
 * by default.
 *
 * The default settings may be overridden using the \`@returnTypeVisibility\` and \`@parameterVisibility\` decorators.
 *
 * See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
 *
 * @param visibilities List of visibilities which apply to this property.
 *
 * @example
 *
 * \`\`\`typespec
 * model Dog {
 *   // The service will generate an ID, so you don't need to send it.
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   // The service will store this secret name, but won't ever return it.
 *   @visibility(Lifecycle.Create, Lifecycle.Update)
 *   secretName: string;
 *
 *   // The regular name has all vi
 *   name: string;
 * }
 * \`\`\`
 */
extern dec visibility(target: ModelProperty, ...visibilities: valueof EnumMember[]);

/**
 * Indicates that a property is not visible in the given visibility class.
 *
 * This decorator removes all active visibility modifiers from the property within
 * the given visibility class, making it invisible to any context that selects for
 * visibility modifiers within that class.
 *
 * @param visibilityClass The visibility class to make the property invisible within.
 *
 * @example
 * \`\`\`typespec
 * model Example {
 *   @invisible(Lifecycle)
 *   hidden_property: string;
 * }
 * \`\`\`
 */
extern dec invisible(target: ModelProperty, visibilityClass: Enum);

/**
 * Removes visibility modifiers from a property.
 *
 * If the visibility modifiers for a visibility class have not been initialized,
 * this decorator will use the default visibility modifiers for the visibility
 * class as the default modifier set.
 *
 * @param target The property to remove visibility from.
 * @param visibilities The visibility modifiers to remove from the target property.
 *
 * @example
 * \`\`\`typespec
 * model Example {
 *   // This property will have all Lifecycle visibilities except the Read
 *   // visibility, since it is removed.
 *   @removeVisibility(Lifecycle.Read)
 *   secret_property: string;
 * }
 * \`\`\`
 */
extern dec removeVisibility(target: ModelProperty, ...visibilities: valueof EnumMember[]);

/**
 * Removes properties that do not have at least one of the given visibility modifiers
 * active.
 *
 * If no visibility modifiers are supplied, this decorator has no effect.
 *
 * See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
 *
 * When using an emitter that applies visibility automatically, it is generally
 * not necessary to use this decorator.
 *
 * @param visibilities List of visibilities that apply to this property.
 *
 * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   @visibility(Lifecycle.Create, Lifecycle.Update)
 *   secretName: string;
 *
 *   name: string;
 * }
 *
 * // The spread operator will copy all the properties of Dog into DogRead,
 * // and @withVisibility will then remove those that are not visible with
 * // create or update visibility.
 * //
 * // In this case, the id property is removed, and the name and secretName
 * // properties are kept.
 * @withVisibility(Lifecycle.Create, Lifecycle.Update)
 * model DogCreateOrUpdate {
 *   ...Dog;
 * }
 *
 * // In this case the id and name properties are kept and the secretName property
 * // is removed.
 * @withVisibility(Lifecycle.Read)
 * model DogRead {
 *   ...Dog;
 * }
 * \`\`\`
 */
extern dec withVisibility(target: Model, ...visibilities: valueof EnumMember[]);

/**
 * Set the visibility of key properties in a model if not already set.
 *
 * This will set the visibility modifiers of all key properties in the model if the visibility is not already _explicitly_ set,
 * but will not change the visibility of any properties that have visibility set _explicitly_, even if the visibility
 * is the same as the default visibility.
 *
 * Visibility may be set explicitly using any of the following decorators:
 *
 * - \`@visibility\`
 * - \`@removeVisibility\`
 * - \`@invisible\`
 *
 * @param visibility The desired default visibility value. If a key property already has visibility set, it will not be changed.
 */
extern dec withDefaultKeyVisibility(target: Model, visibility: valueof EnumMember);

/**
 * Declares the visibility constraint of the parameters of a given operation.
 *
 * A parameter or property nested within a parameter will be visible if it has _any_ of the visibilities
 * in the list.
 *
 * It is invalid to call this decorator with no visibility modifiers.
 *
 * @param visibilities List of visibility modifiers that apply to the parameters of this operation.
 */
extern dec parameterVisibility(target: Operation, ...visibilities: valueof EnumMember[]);

/**
 * Declares the visibility constraint of the return type of a given operation.
 *
 * A property within the return type of the operation will be visible if it has _any_ of the visibilities
 * in the list.
 *
 * It is invalid to call this decorator with no visibility modifiers.
 *
 * @param visibilities List of visibility modifiers that apply to the return type of this operation.
 */
extern dec returnTypeVisibility(target: Operation, ...visibilities: valueof EnumMember[]);

/**
 * Returns the model with non-updateable properties removed.
 */
extern dec withUpdateableProperties(target: Model);

/**
 * Declares the default visibility modifiers for a visibility class.
 *
 * The default modifiers are used when a property does not have any visibility decorators
 * applied to it.
 *
 * The modifiers passed to this decorator _MUST_ be members of the target Enum.
 *
 * @param visibilities the list of modifiers to use as the default visibility modifiers.
 */
extern dec defaultVisibility(target: Enum, ...visibilities: valueof EnumMember[]);

/**
 * A visibility class for resource lifecycle phases.
 *
 * These visibilities control whether a property is visible during the various phases of a resource's lifecycle.
 *
 * @example
 * \`\`\`typespec
 * model Dog {
 *  @visibility(Lifecycle.Read)
 *  id: int32;
 *
 *  @visibility(Lifecycle.Create, Lifecycle.Update)
 *  secretName: string;
 *
 *  name: string;
 * }
 * \`\`\`
 *
 * In this example, the \`id\` property is only visible during the read phase, and the \`secretName\` property is only visible
 * during the create and update phases. This means that the server will return the \`id\` property when returning a \`Dog\`,
 * but the client will not be able to set or update it. In contrast, the \`secretName\` property can be set when creating
 * or updating a \`Dog\`, but the server will never return it. The \`name\` property has no visibility modifiers and is
 * therefore visible in all phases.
 */
enum Lifecycle {
  /**
   * The property is visible when a resource is being created.
   */
  Create,

  /**
   * The property is visible when a resource is being read.
   */
  Read,

  /**
   * The property is visible when a resource is being updated.
   */
  Update,

  /**
   * The property is visible when a resource is being deleted.
   */
  Delete,

  /**
   * The property is visible when a resource is being queried.
   *
   * In HTTP APIs, this visibility applies to parameters of GET or HEAD operations.
   */
  Query,
}

/**
 * A visibility filter, used to specify which properties should be included when
 * using the \`withVisibilityFilter\` decorator.
 *
 * The filter matches any property with ALL of the following:
 * - If the \`any\` key is present, the property must have at least one of the specified visibilities.
 * - If the \`all\` key is present, the property must have all of the specified visibilities.
 * - If the \`none\` key is present, the property must have none of the specified visibilities.
 */
model VisibilityFilter {
  any?: EnumMember[];
  all?: EnumMember[];
  none?: EnumMember[];
}

/**
 * Applies the given visibility filter to the properties of the target model.
 *
 * This transformation is recursive, so it will also apply the filter to any nested
 * or referenced models that are the types of any properties in the \`target\`.
 *
 * If a \`nameTemplate\` is provided, newly-created type instances will be named according
 * to the template. See the \`@friendlyName\` decorator for more information on the template
 * syntax. The transformed type is provided as the argument to the template.
 *
 * @param target The model to apply the visibility filter to.
 * @param filter The visibility filter to apply to the properties of the target model.
 * @param nameTemplate The name template to use when renaming new model instances.
 *
 * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   name: string;
 * }
 *
 * @withVisibilityFilter(#{ all: #[Lifecycle.Read] })
 * model DogRead {
 *  ...Dog
 * }
 * \`\`\`
 */
#deprecated "withVisibilityFilter is deprecated and will be removed in a future release. Use the \`FilterVisibility\` template or Lifecycle specific templates (e.g. \`Read\`, \`Create\`, \`Update\`, etc.) instead."
extern dec withVisibilityFilter(
  target: Model,
  filter: valueof VisibilityFilter,
  nameTemplate?: valueof string
);

/**
 * A copy of the input model \`M\` with only the properties that match the given visibility filter.
 *
 * This transformation is recursive, so it will also apply the filter to any nested
 * or referenced models that are the types of any properties in the \`target\`.
 *
 * If a \`nameTemplate\` is provided, newly-created type instances will be named according
 * to the template. See the \`@friendlyName\` decorator for more information on the template
 * syntax. The transformed type is provided as the argument to the template.
 *
 * @template M the model to apply the visibility filter to.
 * @template Filter the visibility filter to apply to the properties of the target model.
 * @template NameTemplate the name template to use when renaming new type instances.
 *
 * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(CustomVisibility.A)
 *   id: int32;
 *   @removeVisibility(CustomVisibility.A)
 *   name: string;
 * }
 *
 * enum CustomVisibility {
 *   A,
 *   B,
 * }
 *
 * const customFilter: VisibilityFilter = #{ all: #[CustomVisibility.A] };
 *
 * // This model will have the \`id\` property but not the \`name\` property, since \`id\` has the CustomVisibility.A visibility and \`name\` does not.
 * model DogRead is FilterVisibility<Dog, customFilter, "Read{name}">;
 * \`\`\`
 */
alias FilterVisibility<
  M extends Model,
  Filter extends valueof VisibilityFilter,
  NameTemplate extends valueof string
> = applyVisibilityFilter(M, Filter, NameTemplate);

#suppress "experimental-feature"
internal extern fn applyVisibilityFilter(
  input: Model,
  filter: valueof VisibilityFilter,
  nameTemplate?: valueof string
): Model;

/**
 * Transforms the \`target\` model to include only properties that are visible during the
 * "Update" lifecycle phase.
 *
 * Any nested models of optional properties will be transformed into the "CreateOrUpdate"
 * lifecycle phase instead of the "Update" lifecycle phase, so that nested models may be
 * fully updated.
 *
 * If a \`nameTemplate\` is provided, newly-created type instances will be named according
 * to the template. See the \`@friendlyName\` decorator for more information on the template
 * syntax. The transformed type is provided as the argument to the template.
 *
 * @param target The model to apply the transformation to.
 * @param nameTemplate The name template to use when renaming new model instances.
 *
 * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   @visibility(Lifecycle.Create, Lifecycle.Update)
 *   secretName: string;
 *
 *   name: string;
 * }
 *
 * @withLifecycleUpdate
 * model DogUpdate {
 *   ...Dog
 * }
 * \`\`\`
 */
#deprecated "withLifecycleUpdate is deprecated and will be removed in a future release. Use the \`Update\` template instead."
extern dec withLifecycleUpdate(target: Model, nameTemplate?: valueof string);

#suppress "experimental-feature"
internal extern fn applyLifecycleUpdate(input: Model, nameTemplate?: valueof string): Model;

/**
 * A copy of the input model \`T\` with only the properties that are visible during the
 * "Create" resource lifecycle phase.
 *
 * This transformation is recursive, and will include only properties that have the
 * \`Lifecycle.Create\` visibility modifier.
 *
 * If a \`NameTemplate\` is provided, the new model will be named according to the template.
 * The template uses the same syntax as the \`@friendlyName\` decorator.
 *
 * @template T The model to transform.
 * @template NameTemplate The name template to use for the new model.
 *
 *  * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   name: string;
 * }
 *
 * // This model has only the \`name\` field.
 * model CreateDog is Create<Dog>;
 * \`\`\`
 */
alias Create<
  T extends Model,
  NameTemplate extends valueof string = "Create{name}"
> = applyVisibilityFilter(T, #{ all: #[Lifecycle.Create] }, NameTemplate);

/**
 * A copy of the input model \`T\` with only the properties that are visible during the
 * "Read" resource lifecycle phase.
 *
 * The "Read" lifecycle phase is used for properties returned by operations that read data, like
 * HTTP GET operations.
 *
 * This transformation is recursive, and will include only properties that have the
 * \`Lifecycle.Read\` visibility modifier.
 *
 * If a \`NameTemplate\` is provided, the new model will be named according to the template.
 * The template uses the same syntax as the \`@friendlyName\` decorator.
 *
 * @template T The model to transform.
 * @template NameTemplate The name template to use for the new model.
 *
 *  * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   @visibility(Lifecycle.Create, Lifecycle.Update)
 *   secretName: string;
 *
 *   name: string;
 * }
 *
 * // This model has the \`id\` and \`name\` fields, but not \`secretName\`.
 * model ReadDog is Read<Dog>;
 * \`\`\`
 */
alias Read<
  T extends Model,
  NameTemplate extends valueof string = "Read{name}"
> = applyVisibilityFilter(T, #{ all: #[Lifecycle.Read] }, NameTemplate);

/**
 * A copy of the input model \`T\` with only the properties that are visible during the
 * "Update" resource lifecycle phase.
 *
 * The "Update" lifecycle phase is used for properties passed as parameters to operations
 * that update data, like HTTP PATCH operations.
 *
 * This transformation will include only the properties that have the \`Lifecycle.Update\`
 * visibility modifier, and the types of all properties will be replaced with the
 * equivalent \`CreateOrUpdate\` transformation.
 *
 * If a \`NameTemplate\` is provided, the new model will be named according to the template.
 * The template uses the same syntax as the \`@friendlyName\` decorator.
 *
 * @template T The model to transform.
 * @template NameTemplate The name template to use for the new model.
 *
 *  * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   @visibility(Lifecycle.Create, Lifecycle.Update)
 *   secretName: string;
 *
 *   name: string;
 * }
 *
 * // This model will have the \`secretName\` and \`name\` fields, but not the \`id\` field.
 * model UpdateDog is Update<Dog>;
 * \`\`\`
 */
alias Update<
  T extends Model,
  NameTemplate extends valueof string = "Update{name}"
> = applyLifecycleUpdate(T, NameTemplate);

/**
 * A copy of the input model \`T\` with only the properties that are visible during the
 * "Create" or "Update" resource lifecycle phases.
 *
 * The "CreateOrUpdate" lifecycle phase is used by default for properties passed as parameters to operations
 * that can create _or_ update data, like HTTP PUT operations.
 *
 * This transformation is recursive, and will include only properties that have the
 * \`Lifecycle.Create\` or \`Lifecycle.Update\` visibility modifier.
 *
 * If a \`NameTemplate\` is provided, the new model will be named according to the template.
 * The template uses the same syntax as the \`@friendlyName\` decorator.
 *
 * @template T The model to transform.
 * @template NameTemplate The name template to use for the new model.
 *
 *  * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   @visibility(Lifecycle.Create)
 *   immutableSecret: string;
 *
 *   @visibility(Lifecycle.Create, Lifecycle.Update)
 *   secretName: string;
 *
 *   name: string;
 * }
 *
 * // This model will have the \`immutableSecret\`, \`secretName\`, and \`name\` fields, but not the \`id\` field.
 * model CreateOrUpdateDog is CreateOrUpdate<Dog>;
 * \`\`\`
 */
alias CreateOrUpdate<
  T extends Model,
  NameTemplate extends valueof string = "CreateOrUpdate{name}"
> = applyVisibilityFilter(T, #{ any: #[Lifecycle.Create, Lifecycle.Update] }, NameTemplate);

/**
 * A copy of the input model \`T\` with only the properties that are visible during the
 * "Delete" resource lifecycle phase.
 *
 * The "Delete" lifecycle phase is used for properties passed as parameters to operations
 * that delete data, like HTTP DELETE operations.
 *
 * This transformation is recursive, and will include only properties that have the
 * \`Lifecycle.Delete\` visibility modifier.
 *
 * If a \`NameTemplate\` is provided, the new model will be named according to the template.
 * The template uses the same syntax as the \`@friendlyName\` decorator.
 *
 * @template T The model to transform.
 * @template NameTemplate The name template to use for the new model.
 *
 *  * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   // Set when the Dog is removed from our data store. This happens when the
 *   // Dog is re-homed to a new owner.
 *   @visibility(Lifecycle.Delete)
 *   nextOwner: string;
 *
 *   name: string;
 * }
 *
 * // This model will have the \`nextOwner\` and \`name\` fields, but not the \`id\` field.
 * model DeleteDog is Delete<Dog>;
 * \`\`\`
 */
alias Delete<
  T extends Model,
  NameTemplate extends valueof string = "Delete{name}"
> = applyVisibilityFilter(T, #{ all: #[Lifecycle.Delete] }, NameTemplate);

/**
 * A copy of the input model \`T\` with only the properties that are visible during the
 * "Query" resource lifecycle phase.
 *
 * The "Query" lifecycle phase is used for properties passed as parameters to operations
 * that read data, like HTTP GET or HEAD operations. This should not be confused for
 * the \`@query\` decorator, which specifies that the property is transmitted in the
 * query string of an HTTP request.
 *
 * This transformation is recursive, and will include only properties that have the
 * \`Lifecycle.Query\` visibility modifier.
 *
 * If a \`NameTemplate\` is provided, the new model will be named according to the template.
 * The template uses the same syntax as the \`@friendlyName\` decorator.
 *
 * @template T The model to transform.
 * @template NameTemplate The name template to use for the new model.
 *
 *  * @example
 * \`\`\`typespec
 * model Dog {
 *   @visibility(Lifecycle.Read)
 *   id: int32;
 *
 *   // When getting information for a Dog, you can set this field to true to include
 *   // some extra information about the Dog's pedigree that is normally not returned.
 *   // Alternatively, you could just use a separate option parameter to get this
 *   // information.
 *   @visibility(Lifecycle.Query)
 *   includePedigree?: boolean;
 *
 *   name: string;
 *
 *   // Only included if \`includePedigree\` is set to true in the request.
 *   @visibility(Lifecycle.Read)
 *   pedigree?: string;
 * }
 *
 * // This model will have the \`includePedigree\` and \`name\` fields, but not \`id\` or \`pedigree\`.
 * model QueryDog is Query<Dog>;
 * \`\`\`
 */
alias Query<
  T extends Model,
  NameTemplate extends valueof string = "Query{name}"
> = applyVisibilityFilter(T, #{ all: #[Lifecycle.Query] }, NameTemplate);
`,"lib/main.tsp":`import "../dist/src/tsp-index.js";
import "./decorators.tsp";
import "./types.tsp";
`,"lib/decorators.tsp":`using TypeSpec.Reflection;

namespace TypeSpec.SSE;

/**
 * Indicates that the presence of this event is a terminal event,
 * and the client should disconnect from the server.
 */
extern dec terminalEvent(target: UnionVariant);
`,"lib/types.tsp":`import "@typespec/http/streams";

using Http.Streams;

namespace TypeSpec.SSE;

/**
 * Describes a stream of server-sent events.
 *
 * The content-type is set to \`text/event-stream\`.
 *
 * The server-sent events are described by \`Type\`.
 * The event type for any event can be defined by using named union variants.
 * When a union variant is not named, it is considered a 'message' event.
 *
 * @template Type The set of models describing the server-sent events.
 *
 * @example Mix of named union variants and terminal event
 *
 * \`\`\`typespec
 * model UserConnect {
 *   username: string;
 *   time: string;
 * }
 *
 * model UserMessage {
 *   username: string;
 *   time: string;
 *   text: string;
 * }
 *
 * model UserDisconnect {
 *   username: string;
 *   time: string;
 * }
 *
 * @TypeSpec.Events.events
 * union ChannelEvents {
 *   userconnect: UserConnect,
 *   usermessage: UserMessage,
 *   userdisconnect: UserDisconnect,
 *
 *   @Events.contentType("text/plain")
 *   @terminalEvent
 *   "[unsubscribe]",
 * }
 *
 * op subscribeToChannel(): SSEStream<ChannelEvents>;
 * \`\`\`
 */
@doc("")
model SSEStream<Type extends TypeSpec.Reflection.Union> is HttpStream<Type, "text/event-stream">;
`,"../http/lib/streams/main.tsp":`import "@typespec/streams";
import "../main.tsp";

using TypeSpec.Streams;

namespace TypeSpec.Http.Streams;

/**
 * Defines a model that represents a stream protocol type whose data is described
 * by \`Type\`.
 *
 * The \`ContentType\` and \`BodyType\` describe how the stream is encoded over the wire,
 * while \`Type\` describes the data that the stream contains.
 *
 * @template Type The type of the stream's data.
 * @template ContentType The content type of the stream.
 * @template BodyType The underlying wire type of the stream.
 */
@doc("")
model HttpStream<Type, ContentType extends valueof string, BodyType extends bytes | string = string>
  is Stream<Type> {
  @header contentType: typeof ContentType;
  @body body: BodyType;
}

/**
 * Describes a stream of JSON data with one JSON object per line and sets
 * the content type to \`application/jsonl\`.
 *
 * The JSON data is described by \`Type\`.
 *
 * @template Type The set of models describing the JSON data in the stream.
 *
 * @example
 *
 * \`\`\`typespec
 * model Message {
 *   id: string;
 *   text: string;
 * }
 *
 * @TypeSpec.Events.events
 * union Events {
 *   Message,
 * }
 *
 * op subscribe(): JsonlStream<Events>;
 * \`\`\`
 */
@doc("")
model JsonlStream<Type> is HttpStream<Type, "application/jsonl">;
`,"../streams/lib/main.tsp":`import "../dist/src/tsp-index.js";
import "./decorators.tsp";
import "./types.tsp";
`,"../streams/lib/decorators.tsp":`using TypeSpec.Reflection;

namespace TypeSpec.Streams;

/**
 * Specify that a model represents a stream protocol type whose data is described
 * by \`Type\`.
 *
 * @param type The type that models the underlying data of the stream.
 *
 * @example
 *
 * \`\`\`typespec
 * model Message {
 *   id: string;
 *   text: string;
 * }
 *
 * @streamOf(Message)
 * model Response {
 *   @body body: string;
 * }
 * \`\`\`
 */
extern dec streamOf(target: Model, type: unknown);
`,"../streams/lib/types.tsp":`namespace TypeSpec.Streams;

/**
 * Defines a model that represents a stream protocol type whose data is described
 * by \`Type\`.
 *
 * This can be useful when the underlying data type is not relevant, or to serve as
 * a base type for custom streams.
 *
 * @template Type The type of the stream's data.
 */
@doc("")
@streamOf(Type)
model Stream<Type> {}
`,"../http/lib/main.tsp":`import "../dist/src/tsp-index.js";
import "./decorators.tsp";
import "./private.decorators.tsp";
import "./auth.tsp";

namespace TypeSpec.Http;

using Private;

/**
 * Describes an HTTP response.
 *
 * @template Status The status code of the response.
 */
@doc("")
model Response<Status> {
  @doc("The status code.")
  @statusCode
  statusCode: Status;
}

/**
 * Defines a model with a single property of the given type, marked with \`@body\`.
 *
 * This can be useful in situations where you cannot use a bare type as the body
 * and it is awkward to add a property.
 *
 * @template Type The type of the model's \`body\` property.
 */
@doc("")
model Body<Type> {
  @body
  @doc("The body type of the operation request or response.")
  body: Type;
}

/**
 * The Location header contains the URL where the status of the long running operation can be checked.
 */
model LocationHeader {
  @doc("The Location header contains the URL where the status of the long running operation can be checked.")
  @header
  location: string;
}

// Don't put @doc on these, change \`getStatusCodeDescription\` implementation
// to update the default descriptions for these status codes. This ensures
// that we get consistent emit between different ways to spell the same
// responses in TypeSpec.

/**
 * The request has succeeded.
 */
model OkResponse is Response<200>;
/**
 * The request has succeeded and a new resource has been created as a result.
 */
model CreatedResponse is Response<201>;
/**
 * The request has been accepted for processing, but processing has not yet completed.
 */
model AcceptedResponse is Response<202>;
/**
 * There is no content to send for this request, but the headers may be useful.
 */
model NoContentResponse is Response<204>;
/**
 * The URL of the requested resource has been changed permanently. The new URL is given in the response.
 */
model MovedResponse is Response<301> {
  ...LocationHeader;
}
/**
 * The client has made a conditional request and the resource has not been modified.
 */
model NotModifiedResponse is Response<304>;
/**
 * The server could not understand the request due to invalid syntax.
 */
model BadRequestResponse is Response<400>;
/**
 * Access is unauthorized.
 */
model UnauthorizedResponse is Response<401>;
/**
 * Access is forbidden.
 */
model ForbiddenResponse is Response<403>;
/**
 * The server cannot find the requested resource.
 */
model NotFoundResponse is Response<404>;
/**
 * The request conflicts with the current state of the server.
 */
model ConflictResponse is Response<409>;

/**
 * Produces a new model with the same properties as T, but with \`@query\`,
 * \`@header\`, \`@body\`, and \`@path\` decorators removed from all properties.
 *
 * @template Data The model to spread as the plain data.
 */
@plainData
model PlainData<Data> {
  ...Data;
}

/**
 * A file in an HTTP request, response, or multipart payload.
 *
 * Files have a special meaning that the HTTP library understands. When the body of an HTTP request, response,
 * or multipart payload is _effectively_ an instance of \`TypeSpec.Http.File\` or any type that extends it, the
 * operation is treated as a file upload or download.
 *
 * When using file bodies, the fields of the file model are defined to come from particular locations by default:
 *
 * - \`contentType\`: The \`Content-Type\` header of the request, response, or multipart payload (CANNOT be overridden or changed).
 * - \`contents\`: The body of the request, response, or multipart payload (CANNOT be overridden or changed).
 * - \`filename\`: The \`filename\` parameter value of the \`Content-Disposition\` header of the response or multipart payload
 *   (MAY be overridden or changed).
 *
 * A File may be used as a normal structured JSON object in a request or response, if the request specifies an explicit
 * \`Content-Type\` header. In this case, the entire File model is serialized as if it were any other model. In a JSON payload,
 * it will have a structure like:
 *
 * \`\`\`
 * {
 *   "contentType": <string?>,
 *   "filename": <string?>,
 *   "contents": <string, base64>
 * }
 * \`\`\`
 *
 * The \`contentType\` _within_ the file defines what media types the data inside the file can be, but if the specification
 * defines a \`Content-Type\` for the payload as HTTP metadata, that \`Content-Type\` metadata defines _how the file is
 * serialized_. See the examples below for more information.
 *
 * NOTE: The \`filename\` and \`contentType\` fields are optional. Furthermore, the default location of \`filename\`
 * (\`Content-Disposition: <disposition>; filename=<filename>\`) is only valid in HTTP responses and multipart payloads. If
 * you wish to send the \`filename\` in a request, you must use HTTP metadata decorators to describe the location of the
 * \`filename\` field. You can combine the metadata decorators with \`@visibility\` to control when the \`filename\` location
 * is overridden, as shown in the examples below.
 *
 * @template ContentType The allowed media (MIME) types of the file contents.
 * @template Contents The type of the file contents. This can be \`string\`, \`bytes\`, or any scalar that extends them.
 *
 * @example
 * \`\`\`tsp
 * // Download a file
 * @get op download(): File;
 *
 * // Upload a file
 * @post op upload(@bodyRoot file: File): void;
 * \`\`\`
 *
 * @example
 * \`\`\`tsp
 * // Upload and download files in a multipart payload
 * op multipartFormDataUpload(
 *   @multipartBody fields: {
 *     files: HttpPart<File>[];
 *   },
 * ): void;
 *
 * op multipartFormDataDownload(): {
 *   @multipartBody formFields: {
 *     files: HttpPart<File>[];
 *   }
 * };
 * \`\`\`
 *
 * @example
 * \`\`\`tsp
 * // Declare a custom type of text file, where the filename goes in the path
 * // in requests.
 * model SpecFile extends File<"application/json" | "application/yaml", string> {
 *   // Provide a header that contains the name of the file when created or updated
 *   @header("x-filename")
 *   @path filename: string;
 * }
 *
 * @get op downloadSpec(@path name: string): SpecFile;
 *
 * @post op uploadSpec(@bodyRoot spec: SpecFile): void;
 * \`\`\`
 *
 * @example
 * \`\`\`tsp
 * // Declare a custom type of binary file
 * model ImageFile extends File {
 *   contentType: "image/png" | "image/jpeg";
 *   @path filename: string;
 * }
 *
 * @get op downloadImage(@path name: string): ImageFile;
 *
 * @post op uploadImage(@bodyRoot image: ImageFile): void;
 * \`\`\`
 *
 * @example
 * \`\`\`tsp
 * // Use a File as a structured JSON object. The HTTP library will warn you that the File will be serialized as JSON,
 * // so you should suppress the warning if it's really what you want instead of a binary file upload/download.
 *
 * // The response body is a JSON object like \`{"contentType":<string?>,"filename":<string?>,"contents":<string>}\`
 * @get op downloadTextFileJson(): {
 *   @header contentType: "application/json",
 *   @body file: File<"text/plain", string>,
 * };
 *
 * // The request body is a JSON object like \`{"contentType":<string?>,"filename":<string?>,"contents":<base64>}\`
 * @post op uploadBinaryFileJson(
 *   @header contentType: "application/json",
 *   @body file: File<"image/png", bytes>,
 * ): void;
 *
 */
@summary("A file in an HTTP request, response, or multipart payload.")
@Private.httpFile
model File<ContentType extends string = string, Contents extends bytes | string = bytes> {
  /**
   * The allowed media (MIME) types of the file contents.
   *
   * In file bodies, this value comes from the \`Content-Type\` header of the request or response. In JSON bodies,
   * this value is serialized as a field in the response.
   *
   * NOTE: this is not _necessarily_ the same as the \`Content-Type\` header of the request or response, but
   * it will be for file bodies. It may be different if the file is serialized as a JSON object. It always refers to the
   * _contents_ of the file, and not necessarily the way the file itself is transmitted or serialized.
   */
  @summary("The allowed media (MIME) types of the file contents.")
  contentType?: ContentType;

  /**
   * The name of the file, if any.
   *
   * In file bodies, this value comes from the \`filename\` parameter of the \`Content-Disposition\` header of the response
   * or multipart payload. In JSON bodies, this value is serialized as a field in the response.
   *
   * NOTE: By default, \`filename\` cannot be sent in request payloads and can only be sent in responses and multipart
   * payloads, as the \`Content-Disposition\` header is not valid in requests. If you want to send the \`filename\` in a request,
   * you must extend the \`File\` model and override the \`filename\` property with a different location defined by HTTP metadata
   * decorators.
   */
  @summary("The name of the file, if any.")
  filename?: string;

  /**
   * The contents of the file.
   *
   * In file bodies, this value comes from the body of the request, response, or multipart payload. In JSON bodies,
   * this value is serialized as a field in the response.
   */
  @summary("The contents of the file.")
  contents: Contents;
}

model HttpPartOptions {
  /** Name of the part when using the array form. */
  name?: string;
}

@Private.httpPart(Type, Options)
model HttpPart<Type, Options extends valueof HttpPartOptions = #{}> {}

model Link {
  target: url;
  rel: string;
  attributes?: Record<unknown>;
}

scalar LinkHeader<T extends Record<url> | Link[]> extends string;

/**
 * Create a MergePatch Request body for updating the given resource Model.
 * The MergePatch request created by this template provides a TypeSpec description of a
 * JSON MergePatch request that can successfully update the given resource.
 * The transformation follows the definition of JSON MergePatch requests in
 * rfc 7396: https://www.rfc-editor.org/rfc/rfc7396,
 * applying the merge-patch transform recursively to keyed types in the resource Model.
 *
 * Using this template in a PATCH request body overrides the \`implicitOptionality\`
 * setting for PATCH operations and sets \`application/merge-patch+json\` as the request
 * content-type.
 *
 * @template T The type of the resource to create a MergePatch update request body for.
 * @template NameTemplate A StringTemplate used to name any models created by applying
 * the merge-patch transform to the resource. The default name template is \`{name}MergePatchUpdate\`,
 * for example, the merge patch transform of model \`Widget\` is named \`WidgetMergePatchUpdate\`.
 *
 * @example
 * \`\`\`tsp
 * // An operation updating a 'Widget' using merge-patch
 * @patch op update(@body request: MergePatchUpdate<Widget>): Widget;
 * \`\`\`
 *
 * @example
 * \`\`\`tsp
 * // An operation updating a 'Widget' using merge-patch
 * @patch op update(@bodyRoot request: MergePatchUpdate<Widget>): Widget;
 * \`\`\`
 *
 * @example
 * \`\`\`tsp
 * // An operation updating a 'Widget' using merge-patch
 * @patch op update(...MergePatchUpdate<Widget>): Widget;
 * \`\`\`
 */
alias MergePatchUpdate<
  T extends Reflection.Model,
  NameTemplate extends valueof string = "{name}MergePatchUpdate"
> = applyMergePatchTransform(
  T,
  NameTemplate,
  #{ visibilityMode: Private.MergePatchVisibilityMode.Update }
);

/**
 * Create a MergePatch Request body for creating or updating the given resource Model.
 * The MergePatch request created by this template provides a TypeSpec description of a
 * JSON MergePatch request that can successfully create or update the given resource.
 * The transformation follows the definition of JSON MergePatch requests in
 * rfc 7396: https://www.rfc-editor.org/rfc/rfc7396,
 * applying the merge-patch transform recursively to keyed types in the resource Model.
 *
 * Using this template in a PATCH request body overrides the \`implicitOptionality\`
 * setting for PATCH operations and sets \`application/merge-patch+json\` as the request
 * content-type.
 *
 * @template T The type of the resource to create a MergePatch update request body for.
 * @template NameTemplate A StringTemplate used to name any models created by applying
 * the merge-patch transform to the resource. The default name template is \`{name}MergePatchCreateOrUpdate\`,
 * for example, the merge patch transform of model \`Widget\` is named \`WidgetMergePatchCreateOrUpdate\`.
 *
 * @example
 * \`\`\`tsp
 * // An operation updating a 'Widget' using merge-patch
 * @patch op update(@body request: MergePatchCreateOrUpdate<Widget>): Widget;
 * \`\`\`
 *
 * @example
 * \`\`\`tsp
 * // An operation updating a 'Widget' using merge-patch
 * @patch op update(@bodyRoot request: MergePatchCreateOrUpdate<Widget>): Widget;
 * \`\`\`
 *
 * @example
 * \`\`\`tsp
 * // An operation updating a 'Widget' using merge-patch
 * @patch op update(...MergePatchCreateOrUpdate<Widget>): Widget;
 * \`\`\`
 */
alias MergePatchCreateOrUpdate<
  T extends Reflection.Model,
  NameTemplate extends valueof string = "{name}MergePatchCreateOrUpdate"
> = applyMergePatchTransform(
  T,
  NameTemplate,
  #{ visibilityMode: Private.MergePatchVisibilityMode.CreateOrUpdate }
);
`,"../http/lib/decorators.tsp":`namespace TypeSpec.Http;

using TypeSpec.Reflection;

/**
 * Header options.
 */
model HeaderOptions {
  /**
   * Name of the header when sent over HTTP.
   */
  name?: string;

  /**
   * Equivalent of adding \`*\` in the path parameter as per [RFC-6570](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.3)
   *
   *  | Style  | Explode | Primitive value = 5 | Array = [3, 4, 5] | Object = {"role": "admin", "firstName": "Alex"} |
   *  | ------ | ------- | ------------------- | ----------------- | ----------------------------------------------- |
   *  | simple | false   | \`5   \`              | \`3,4,5\`           | \`role,admin,firstName,Alex\`                     |
   *  | simple | true    | \`5\`                 | \`3,4,5\`           | \`role=admin,firstName=Alex\`                     |
   *
   */
  explode?: boolean;
}

/**
 * Specify this property is to be sent or received as an HTTP header.
 *
 * @param headerNameOrOptions Optional name of the header when sent over HTTP or header options.
 *  By default the header name will be the property name converted from camelCase to kebab-case. (e.g. \`contentType\` -> \`content-type\`)
 *
 * @example
 *
 * \`\`\`typespec
 * op read(@header accept: string): {@header("ETag") eTag: string};
 * op create(@header({name: "X-Color", format: "csv"}) colors: string[]): void;
 * \`\`\`
 *
 * @example Implicit header name
 *
 * \`\`\`typespec
 * op read(): {@header contentType: string}; // headerName: content-type
 * op update(@header ifMatch: string): void; // headerName: if-match
 * \`\`\`
 */
extern dec header(target: ModelProperty, headerNameOrOptions?: valueof string | HeaderOptions);

/**
 * Cookie Options.
 */
model CookieOptions {
  /**
   * Name in the cookie.
   */
  name?: string;
}

/**
 * Specify this property is to be sent or received in the cookie.
 *
 * @param cookieNameOrOptions Optional name of the cookie in the cookie or cookie options.
 *  By default the cookie name will be the property name converted from camelCase to snake_case. (e.g. \`authToken\` -> \`auth_token\`)
 *
 * @example
 *
 * \`\`\`typespec
 * op read(@cookie token: string): {data: string[]};
 * op create(@cookie({name: "auth_token"}) data: string[]): void;
 * \`\`\`
 *
 * @example Implicit header name
 *
 * \`\`\`typespec
 * op read(): {@cookie authToken: string}; // headerName: auth_token
 * op update(@cookie AuthToken: string): void; // headerName: auth_token
 * \`\`\`
 */
extern dec cookie(target: ModelProperty, cookieNameOrOptions?: valueof string | CookieOptions);

/**
 * Query parameter options.
 */
model QueryOptions {
  /**
   * Name of the query when included in the url.
   */
  name?: string;

  /**
   * If true send each value in the array/object as a separate query parameter.
   * Equivalent of adding \`*\` in the path parameter as per [RFC-6570](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.3)
   *
   *  | Style  | Explode | Uri Template   | Primitive value id = 5 | Array id = [3, 4, 5]    | Object id = {"role": "admin", "firstName": "Alex"} |
   *  | ------ | ------- | -------------- | ---------------------- | ----------------------- | -------------------------------------------------- |
   *  | simple | false   | \`/users{?id}\`  | \`/users?id=5\`          | \`/users?id=3,4,5\`       | \`/users?id=role,admin,firstName,Alex\`              |
   *  | simple | true    | \`/users{?id*}\` | \`/users?id=5\`          | \`/users?id=3&id=4&id=5\` | \`/users?role=admin&firstName=Alex\`                 |
   *
   */
  explode?: boolean;
}

/**
 * Specify this property is to be sent as a query parameter.
 *
 * @param queryNameOrOptions Optional name of the query when included in the url or query parameter options.
 *
 * @example
 *
 * \`\`\`typespec
 * op read(@query select: string, @query("order-by") orderBy: string): void;
 * op list(@query(#{name: "id", explode: true}) ids: string[]): void;
 * \`\`\`
 */
extern dec query(target: ModelProperty, queryNameOrOptions?: valueof string | QueryOptions);

model PathOptions {
  /** Name of the parameter in the uri template. */
  name?: string;

  /**
   * When interpolating this parameter in the case of array or object expand each value using the given style.
   * Equivalent of adding \`*\` in the path parameter as per [RFC-6570](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.3)
   */
  explode?: boolean;

  /**
   * Different interpolating styles for the path parameter.
   * - \`simple\`: No special encoding.
   * - \`label\`: Using \`.\` separator.
   * - \`matrix\`: \`;\` as separator.
   * - \`fragment\`: \`#\` as separator.
   * - \`path\`: \`/\` as separator.
   */
  style?: "simple" | "label" | "matrix" | "fragment" | "path";

  /**
   * When interpolating this parameter do not encode reserved characters.
   * Equivalent of adding \`+\` in the path parameter as per [RFC-6570](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.3)
   */
  allowReserved?: boolean;
}

/**
 * Explicitly specify that this property is to be interpolated as a path parameter.
 *
 * @param paramNameOrOptions Optional name of the parameter in the uri template or options.
 *
 * @example
 *
 * \`\`\`typespec
 * @route("/read/{explicit}/things/{implicit}")
 * op read(@path explicit: string, implicit: string): void;
 * \`\`\`
 */
extern dec path(target: ModelProperty, paramNameOrOptions?: valueof string | PathOptions);

/**
 * Explicitly specify that this property type will be exactly the HTTP body.
 *
 * This means that any properties under \`@body\` cannot be marked as headers, query parameters, or path parameters.
 * If wanting to change the resolution of the body but still mix parameters, use \`@bodyRoot\`.
 *
 * @example
 *
 * \`\`\`typespec
 * op upload(@body image: bytes): void;
 * op download(): {@body image: bytes};
 * \`\`\`
 */
extern dec body(target: ModelProperty);

/**
 * Specify that the body resolution should be resolved from that property.
 * By default the body is resolved by including all properties in the operation request/response that are not metadata.
 * This allows to nest the body in a property while still allowing to use headers, query parameters, and path parameters in the same model.
 *
 * @example
 *
 * \`\`\`typespec
 * op upload(@bodyRoot user: {name: string, @header id: string}): void;
 * op download(): {@bodyRoot user: {name: string, @header id: string}};
 * \`\`\`
 */
extern dec bodyRoot(target: ModelProperty);
/**
 * Specify that this property shouldn't be included in the HTTP body.
 * This can be useful when bundling metadata together that would result in an empty property to be included in the body.
 *
 * @example
 *
 * \`\`\`typespec
 * op upload(name: string, @bodyIgnore headers: {@header id: string}): void;
 * \`\`\`
 */
extern dec bodyIgnore(target: ModelProperty);

/**
 * @example
 *
 * \`\`\`tsp
 * op upload(
 *   @header \`content-type\`: "multipart/form-data",
 *   @multipartBody body: {
 *     fullName: HttpPart<string>,
 *     headShots: HttpPart<Image>[]
 *   }
 * ): void;
 * \`\`\`
 */
extern dec multipartBody(target: ModelProperty);

/**
 * Specify the status code for this response. Property type must be a status code integer or a union of status code integer.
 *
 * @example
 *
 * \`\`\`typespec
 * op read(): {
 *   @statusCode _: 200;
 *   @body pet: Pet;
 * };
 * op create(): {
 *   @statusCode _: 201 | 202;
 * };
 * \`\`\`
 */
extern dec statusCode(target: ModelProperty);

/**
 * Specify the HTTP verb for the target operation to be \`GET\`.
 *
 * @example
 *
 * \`\`\`typespec
 * @get op read(): string
 * \`\`\`
 */
extern dec get(target: Operation);

/**
 * Specify the HTTP verb for the target operation to be \`PUT\`.
 *
 * @example
 *
 * \`\`\`typespec
 * @put op set(pet: Pet): void
 * \`\`\`
 */
extern dec put(target: Operation);

/**
 * Specify the HTTP verb for the target operation to be \`POST\`.
 *
 * @example
 *
 * \`\`\`typespec
 * @post op create(pet: Pet): void
 * \`\`\`
 */
extern dec post(target: Operation);

/**
 * Options for PATCH operations.
 */
model PatchOptions {
  /**
   * If set to \`false\`, disables the implicit transform that makes the body of a
   * PATCH operation deeply optional.
   *
   * @deprecated \`implicitOptionality\` is deprecated and will be removed.
   *   To preserve the previous behavior, define and use an explicit patch model
   *   with optional properties for your \`@body\` parameter.
   *   For actual JSON Merge Patch behavior, use \`MergePatchUpdate<T>\` as the
   *   \`@body\` type (for example: \`@patch op update(@body pet: MergePatchUpdate<Pet>): void;\`).
   */
  implicitOptionality?: boolean;
}

/**
 * Specify the HTTP verb for the target operation to be \`PATCH\`.
 *
 * @param options Options for the PATCH operation.
 *
 * @example
 *
 * \`\`\`typespec
 * @patch op update(pet: Pet): void;
 * \`\`\`
 *
 * @example Using MergePatch template for proper merge-patch semantics
 * \`\`\`typespec
 * @patch op update(@body pet: MergePatchUpdate<Pet>): void;
 * \`\`\`
 */
extern dec patch(target: Operation, options?: valueof PatchOptions);

/**
 * Specify the HTTP verb for the target operation to be \`DELETE\`.
 *
 * @example
 *
 * \`\`\`typespec
 * @delete op set(petId: string): void
 * \`\`\`
 */
extern dec delete(target: Operation);

/**
 * Specify the HTTP verb for the target operation to be \`HEAD\`.
 * @example
 *
 * \`\`\`typespec
 * @head op ping(petId: string): void
 * \`\`\`
 */
extern dec head(target: Operation);

/**
 * Specify an endpoint for this service. Multiple \`@server\` decorators can be used to specify multiple endpoints.
 *
 *  @param url Server endpoint
 *  @param description Description of the endpoint
 *  @param parameters Optional set of parameters used to interpolate the url.
 *
 * @example
 *
 * \`\`\`typespec
 * @service
 * @server("https://example.com")
 * namespace PetStore;
 * \`\`\`
 *
 * @example With a description
 *
 * \`\`\`typespec
 * @service
 * @server("https://example.com", "Single server endpoint")
 * namespace PetStore;
 * \`\`\`
 *
 * @example Parameterized
 *
 * \`\`\`typespec
 * @server("https://{region}.foo.com", "Regional endpoint", {
 *   @doc("Region name")
 *   region?: string = "westus",
 * })
 * \`\`\`
 *
 * @example Multiple
 * \`\`\`typespec
 * @service
 * @server("https://example.com", "Standard endpoint")
 * @server("https://{project}.private.example.com", "Private project endpoint", {
 *   project: string;
 * })
 * namespace PetStore;
 * \`\`\`
 *
 */
extern dec server(
  target: Namespace,
  url: valueof string,
  description?: valueof string,
  parameters?: Record<unknown>
);

/**
 * Specify authentication for a whole service or specific methods. See the [documentation in the Http library](https://typespec.io/docs/libraries/http/authentication) for full details.
 *
 * @param auth Authentication configuration. Can be a single security scheme, a union(either option is valid authentication) or a tuple (must use all authentication together)
 * @example
 *
 * \`\`\`typespec
 * @service
 * @useAuth(BasicAuth)
 * namespace PetStore;
 * \`\`\`
 */
extern dec useAuth(target: Namespace | Interface | Operation, auth: {} | Union | {}[]);

/**
 * Defines the relative route URI template for the target operation as defined by [RFC 6570](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.3)
 *
 * \`@route\` can only be applied to operations, namespaces, and interfaces.
 *
 * @param uriTemplate Uri template for this operation.
 *
 * @example Simple path parameter
 *
 * \`\`\`typespec
 * @route("/widgets/{id}") op getWidget(@path id: string): Widget;
 * \`\`\`
 *
 * @example Reserved characters
 * \`\`\`typespec
 * @route("/files{+path}") op getFile(@path path: string): bytes;
 * \`\`\`
 *
 * @example Query parameter
 * \`\`\`typespec
 * @route("/files") op list(select?: string, filter?: string): Files[];
 * @route("/files{?select,filter}") op listFullUriTemplate(select?: string, filter?: string): Files[];
 * \`\`\`
 */
extern dec route(target: Namespace | Interface | Operation, path: valueof string);

/**
 * \`@sharedRoute\` marks the operation as sharing a route path with other operations.
 *
 * When an operation is marked with \`@sharedRoute\`, it enables other operations to share the same
 * route path as long as those operations are also marked with \`@sharedRoute\`.
 *
 * \`@sharedRoute\` can only be applied directly to operations.
 *
 * \`\`\`typespec
 * @sharedRoute
 * @route("/widgets")
 * op getWidget(@path id: string): Widget;
 * \`\`\`
 */
extern dec sharedRoute(target: Operation);
`,"../http/lib/private.decorators.tsp":`/**
 * Private decorators. Those are meant for internal use inside Http types only.
 */
namespace TypeSpec.Http.Private;

extern dec plainData(target: TypeSpec.Reflection.Model);
extern dec httpFile(target: TypeSpec.Reflection.Model);
extern dec httpPart(
  target: TypeSpec.Reflection.Model,
  type: unknown,
  options: valueof HttpPartOptions
);

/**
 * Specify if inapplicable metadata should be included in the payload for the given entity.
 * @param value If true, inapplicable metadata will be included in the payload.
 */
extern dec includeInapplicableMetadataInPayload(target: unknown, value: valueof boolean);

/**
 * The visibility mode for the merge patch transform.
 */
enum MergePatchVisibilityMode {
  /**
   * The Update mode. This is used when a resource can be updated but must already exist.
   */
  Update,

  /**
   * The Create or Update mode. This is used when a resource can be created OR updated in a single operation.
   */
  CreateOrUpdate,
}

/**
 * Options for the \`@applyMergePatch\` decorator.
 */
model ApplyMergePatchOptions {
  /**
   * The visibility mode to use.
   */
  visibilityMode: MergePatchVisibilityMode;
}

/**
 * Performs the canonical merge-patch transformation on the given model and injects its
 * transformed properties into the target.
 */
#deprecated "applyMergePatch is deprecated and will be removed in a future release. This decorator is not intended for public use."
extern dec applyMergePatch(
  target: Reflection.Model,
  source: Reflection.Model,
  nameTemplate: valueof string,
  options: valueof ApplyMergePatchOptions
);

#suppress "experimental-feature"
internal extern fn applyMergePatchTransform(
  input: Reflection.Model,
  nameTemplate: valueof string,
  options: valueof ApplyMergePatchOptions
): Reflection.Model;

/**
 * Marks a model that was generated by applying the MergePatch
 * transform and links to its source model
 */
extern dec mergePatchModel(target: Reflection.Model, source: Reflection.Model);

/**
 * Links a modelProperty mutated as part of a mergePatch transform to
 * its source property;
 */
extern dec mergePatchProperty(target: Reflection.ModelProperty, source: Reflection.ModelProperty);
`,"../http/lib/auth.tsp":`namespace TypeSpec.Http;

@doc("Authentication type")
enum AuthType {
  @doc("HTTP")
  http,

  @doc("API key")
  apiKey,

  @doc("OAuth2")
  oauth2,

  @doc("OpenID connect")
  openIdConnect,

  @doc("Empty auth")
  noAuth,
}

/**
 * Basic authentication is a simple authentication scheme built into the HTTP protocol.
 * The client sends HTTP requests with the Authorization header that contains the word Basic word followed by a space and a base64-encoded string username:password.
 * For example, to authorize as demo / \`p@55w0rd\` the client would send
 * \`\`\`
 * Authorization: Basic ZGVtbzpwQDU1dzByZA==
 * \`\`\`
 */
@doc("")
model BasicAuth {
  @doc("Http authentication")
  type: AuthType.http;

  @doc("basic auth scheme")
  scheme: "Basic";
}

/**
 * Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens.
 * The name \u201CBearer authentication\u201D can be understood as \u201Cgive access to the bearer of this token.\u201D The bearer token is a cryptic string, usually generated by the server in response to a login request.
 * The client must send this token in the Authorization header when making requests to protected resources:
 * \`\`\`
 * Authorization: Bearer <token>
 * \`\`\`
 */
@doc("")
model BearerAuth {
  @doc("Http authentication")
  type: AuthType.http;

  @doc("bearer auth scheme")
  scheme: "Bearer";
}

@doc("Describes the location of the API key")
enum ApiKeyLocation {
  @doc("API key is a header value")
  header,

  @doc("API key is a query parameter")
  query,

  @doc("API key is found in a cookie")
  cookie,
}

/**
 * An API key is a token that a client provides when making API calls. The key can be sent in the query string:
 *
 * \`\`\`
 * GET /something?api_key=abcdef12345
 * \`\`\`
 *
 * or as a request header
 *
 * \`\`\`
 * GET /something HTTP/1.1
 * X-API-Key: abcdef12345
 * \`\`\`
 *
 * or as a cookie
 *
 * \`\`\`
 * GET /something HTTP/1.1
 * Cookie: X-API-KEY=abcdef12345
 * \`\`\`
 *
 * @template Location The location of the API key
 * @template Name The name of the API key
 */
@doc("")
model ApiKeyAuth<Location extends ApiKeyLocation, Name extends string> {
  @doc("API key authentication")
  type: AuthType.apiKey;

  @doc("location of the API key")
  in: Location;

  @doc("name of the API key")
  name: Name;
}

/**
 * OAuth 2.0 is an authorization protocol that gives an API client limited access to user data on a web server.
 *
 * OAuth relies on authentication scenarios called flows, which allow the resource owner (user) to share the protected content from the resource server without sharing their credentials.
 * For that purpose, an OAuth 2.0 server issues access tokens that the client applications can use to access protected resources on behalf of the resource owner.
 * For more information about OAuth 2.0, see oauth.net and RFC 6749.
 *
 * @template Flows The list of supported OAuth2 flows
 * @template Scopes The list of OAuth2 scopes, which are common for every flow from \`Flows\`. This list is combined with the scopes defined in specific OAuth2 flows.
 */
@doc("")
model OAuth2Auth<Flows extends OAuth2Flow[], Scopes extends string[] = []> {
  @doc("OAuth2 authentication")
  type: AuthType.oauth2;

  @doc("Supported OAuth2 flows")
  flows: Flows;

  @doc("Oauth2 scopes of every flow. Overridden by scope definitions in specific flows")
  defaultScopes: Scopes;
}

@doc("Describes the OAuth2 flow type")
enum OAuth2FlowType {
  @doc("authorization code flow")
  authorizationCode,

  @doc("implicit flow")
  implicit,

  @doc("password flow")
  password,

  @doc("client credential flow")
  clientCredentials,
}

alias OAuth2Flow = AuthorizationCodeFlow | ImplicitFlow | PasswordFlow | ClientCredentialsFlow;

@doc("Authorization Code flow")
model AuthorizationCodeFlow {
  @doc("authorization code flow")
  type: OAuth2FlowType.authorizationCode;

  @doc("the authorization URL")
  authorizationUrl: string;

  @doc("the token URL")
  tokenUrl: string;

  @doc("the refresh URL")
  refreshUrl?: string;

  @doc("list of scopes for the credential")
  scopes?: string[];
}

@doc("Implicit flow")
model ImplicitFlow {
  @doc("implicit flow")
  type: OAuth2FlowType.implicit;

  @doc("the authorization URL")
  authorizationUrl: string;

  @doc("the refresh URL")
  refreshUrl?: string;

  @doc("list of scopes for the credential")
  scopes?: string[];
}

@doc("Resource Owner Password flow")
model PasswordFlow {
  @doc("password flow")
  type: OAuth2FlowType.password;

  @doc("the token URL")
  tokenUrl: string;

  @doc("the refresh URL")
  refreshUrl?: string;

  @doc("list of scopes for the credential")
  scopes?: string[];
}

@doc("Client credentials flow")
model ClientCredentialsFlow {
  @doc("client credential flow")
  type: OAuth2FlowType.clientCredentials;

  @doc("the token URL")
  tokenUrl: string;

  @doc("the refresh URL")
  refreshUrl?: string;

  @doc("list of scopes for the credential")
  scopes?: string[];
}

/**
 * OpenID Connect (OIDC) is an identity layer built on top of the OAuth 2.0 protocol and supported by some OAuth 2.0 providers, such as Google and Azure Active Directory.
 * It defines a sign-in flow that enables a client application to authenticate a user, and to obtain information (or "claims") about that user, such as the user name, email, and so on.
 * User identity information is encoded in a secure JSON Web Token (JWT), called ID token.
 * OpenID Connect defines a discovery mechanism, called OpenID Connect Discovery, where an OpenID server publishes its metadata at a well-known URL, typically
 *
 * \`\`\`http
 * https://server.com/.well-known/openid-configuration
 * \`\`\`
 */
model OpenIdConnectAuth<ConnectUrl extends string> {
  /** Auth type */
  type: AuthType.openIdConnect;

  /** Connect url. It can be specified relative to the server URL */
  openIdConnectUrl: ConnectUrl;
}

/**
 * This authentication option signifies that API is not secured at all.
 * It might be useful when overriding authentication on interface of operation level.
 */
@doc("")
model NoAuth {
  type: AuthType.noAuth;
}
`},ae={jsSourceFiles:C,typespecSourceFiles:D};export{l as $decorators,o as $lib,p as $onValidate,ae as _TypeSpecLibrary_,u as isTerminalEvent};
