{"version":3,"file":"_breakpoints-observer-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/layout/media-matcher.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/layout/breakpoints-observer.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {Service, CSP_NONCE, inject} from '@angular/core';\nimport {Platform} from '../platform';\n\n/** Global registry for all dynamically-created, injected media queries. */\nconst mediaQueriesForWebkitCompatibility: Set<string> = new Set<string>();\n\n/** Style tag that holds all of the dynamically-created media queries. */\nlet mediaQueryStyleNode: HTMLStyleElement | undefined;\n\n/** A utility for calling matchMedia queries. */\n@Service()\nexport class MediaMatcher {\n  private _platform = inject(Platform);\n  private _nonce = inject(CSP_NONCE, {optional: true});\n\n  /** The internal matchMedia method to return back a MediaQueryList like object. */\n  private _matchMedia: (query: string) => MediaQueryList;\n\n  constructor() {\n    this._matchMedia =\n      this._platform.isBrowser && window.matchMedia\n        ? // matchMedia is bound to the window scope intentionally as it is an illegal invocation to\n          // call it from a different scope.\n          window.matchMedia.bind(window)\n        : noopMatchMedia;\n  }\n\n  /**\n   * Evaluates the given media query and returns the native MediaQueryList from which results\n   * can be retrieved.\n   * Confirms the layout engine will trigger for the selector query provided and returns the\n   * MediaQueryList for the query provided.\n   */\n  matchMedia(query: string): MediaQueryList {\n    if (this._platform.WEBKIT || this._platform.BLINK) {\n      createEmptyStyleRule(query, this._nonce);\n    }\n    return this._matchMedia(query);\n  }\n}\n\n/**\n * Creates an empty stylesheet that is used to work around browser inconsistencies related to\n * `matchMedia`. At the time of writing, it handles the following cases:\n * 1. On WebKit browsers, a media query has to have at least one rule in order for `matchMedia`\n * to fire. We work around it by declaring a dummy stylesheet with a `@media` declaration.\n * 2. In some cases Blink browsers will stop firing the `matchMedia` listener if none of the rules\n * inside the `@media` match existing elements on the page. We work around it by having one rule\n * targeting the `body`. See https://github.com/angular/components/issues/23546.\n */\nfunction createEmptyStyleRule(query: string, nonce: string | undefined | null) {\n  if (mediaQueriesForWebkitCompatibility.has(query)) {\n    return;\n  }\n\n  try {\n    if (!mediaQueryStyleNode) {\n      mediaQueryStyleNode = document.createElement('style');\n\n      if (nonce) {\n        mediaQueryStyleNode.setAttribute('nonce', nonce);\n      }\n\n      mediaQueryStyleNode.setAttribute('type', 'text/css');\n      document.head!.appendChild(mediaQueryStyleNode);\n    }\n\n    if (mediaQueryStyleNode.sheet) {\n      mediaQueryStyleNode.sheet.insertRule(\n        // Drop the curly braces to avoid injection attacks. Curly braces aren't\n        // valid media query syntax so this should be a no-op in valid cases.\n        `@media ${query.replace(/[{}]/g, '')} {body{ }}`,\n        0,\n      );\n      mediaQueriesForWebkitCompatibility.add(query);\n    }\n  } catch (e) {\n    console.error(e);\n  }\n}\n\n/** No-op matchMedia replacement for non-browser platforms. */\nfunction noopMatchMedia(query: string): MediaQueryList {\n  // Use `as any` here to avoid adding additional necessary properties for\n  // the noop matcher.\n  return {\n    matches: query === 'all' || query === '',\n    media: query,\n    addListener: () => {},\n    removeListener: () => {},\n  } as any;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {coerceArray} from '../coercion';\nimport {Service, NgZone, OnDestroy, inject} from '@angular/core';\nimport {combineLatest, concat, Observable, Observer, Subject} from 'rxjs';\nimport {debounceTime, map, skip, startWith, take, takeUntil} from 'rxjs/operators';\nimport {MediaMatcher} from './media-matcher';\n\n/** The current state of a layout breakpoint. */\nexport interface BreakpointState {\n  /** Whether the breakpoint is currently matching. */\n  matches: boolean;\n  /**\n   * A key boolean pair for each query provided to the observe method,\n   * with its current matched state.\n   */\n  breakpoints: {\n    [key: string]: boolean;\n  };\n}\n\n/** The current state of a layout breakpoint. */\ninterface InternalBreakpointState {\n  /** Whether the breakpoint is currently matching. */\n  matches: boolean;\n  /** The media query being to be matched */\n  query: string;\n}\n\ninterface Query {\n  observable: Observable<InternalBreakpointState>;\n  mql: MediaQueryList;\n}\n\n/** Utility for checking the matching state of `@media` queries. */\n@Service()\nexport class BreakpointObserver implements OnDestroy {\n  private _mediaMatcher = inject(MediaMatcher);\n  private _zone = inject(NgZone);\n\n  /**  A map of all media queries currently being listened for. */\n  private _queries = new Map<string, Query>();\n  /** A subject for all other observables to takeUntil based on. */\n  private readonly _destroySubject = new Subject<void>();\n\n  /** Completes the active subject, signalling to all other observables to complete. */\n  ngOnDestroy() {\n    this._destroySubject.next();\n    this._destroySubject.complete();\n  }\n\n  /**\n   * Whether one or more media queries match the current viewport size.\n   * @param value One or more media queries to check.\n   * @returns Whether any of the media queries match.\n   */\n  isMatched(value: string | readonly string[]): boolean {\n    const queries = splitQueries(coerceArray(value));\n    return queries.some(mediaQuery => this._registerQuery(mediaQuery).mql.matches);\n  }\n\n  /**\n   * Gets an observable of results for the given queries that will emit new results for any changes\n   * in matching of the given queries.\n   * @param value One or more media queries to check.\n   * @returns A stream of matches for the given queries.\n   */\n  observe(value: string | readonly string[]): Observable<BreakpointState> {\n    const queries = splitQueries(coerceArray(value));\n    const observables = queries.map(query => this._registerQuery(query).observable);\n\n    let stateObservable = combineLatest(observables);\n    // Emit the first state immediately, and then debounce the subsequent emissions.\n    stateObservable = concat(\n      stateObservable.pipe(take(1)),\n      stateObservable.pipe(skip(1), debounceTime(0)),\n    );\n    return stateObservable.pipe(\n      map(breakpointStates => {\n        const response: BreakpointState = {\n          matches: false,\n          breakpoints: {},\n        };\n        breakpointStates.forEach(({matches, query}) => {\n          response.matches = response.matches || matches;\n          response.breakpoints[query] = matches;\n        });\n        return response;\n      }),\n    );\n  }\n\n  /** Registers a specific query to be listened for. */\n  private _registerQuery(query: string): Query {\n    // Only set up a new MediaQueryList if it is not already being listened for.\n    if (this._queries.has(query)) {\n      return this._queries.get(query)!;\n    }\n\n    const mql = this._mediaMatcher.matchMedia(query);\n\n    // Create callback for match changes and add it is as a listener.\n    const queryObservable = new Observable((observer: Observer<MediaQueryListEvent>) => {\n      // Listener callback methods are wrapped to be placed back in ngZone. Callbacks must be placed\n      // back into the zone because matchMedia is only included in Zone.js by loading the\n      // webapis-media-query.js file alongside the zone.js file.  Additionally, some browsers do not\n      // have MediaQueryList inherit from EventTarget, which causes inconsistencies in how Zone.js\n      // patches it.\n      const handler = (e: MediaQueryListEvent): void => this._zone.run(() => observer.next(e));\n      mql.addListener(handler);\n\n      return () => {\n        mql.removeListener(handler);\n      };\n    }).pipe(\n      startWith(mql),\n      map(({matches}) => ({query, matches})),\n      takeUntil(this._destroySubject),\n    );\n\n    // Add the MediaQueryList to the set of queries.\n    const output = {observable: queryObservable, mql};\n    this._queries.set(query, output);\n    return output;\n  }\n}\n\n/**\n * Split each query string into separate query strings if two queries are provided as comma\n * separated.\n */\nfunction splitQueries(queries: readonly string[]): readonly string[] {\n  return queries\n    .map(query => query.split(','))\n    .reduce((a1, a2) => a1.concat(a2))\n    .map(query => query.trim());\n}\n"],"names":[],"mappings":";;;;;;;AAWA,MAAM,kCAAkC,GAAgB,IAAI,GAAG,EAAU;AAGzE,IAAI,mBAAiD;MAIxC,YAAY,CAAA;AACf,EAAA,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC5B,EAAA,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE;AAAC,IAAA,QAAQ,EAAE;AAAI,GAAC,CAAC;EAG5C,WAAW;AAEnB,EAAA,WAAA,GAAA;IACE,IAAI,CAAC,WAAW,GACd,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI,MAAM,CAAC,UAAA,GAG/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAA,GAC7B,cAAc;AACtB,EAAA;EAQA,UAAU,CAAC,KAAa,EAAA;IACtB,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,KAA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