{"version":3,"file":"toolstik-ngx-sub-form.mjs","sources":["../../../projects/ngx-sub-form/src/lib/shared/ngx-sub-form-utils.ts","../../../projects/ngx-sub-form/src/lib/deprecated/ngx-sub-form.component.ts","../../../projects/ngx-sub-form/src/lib/deprecated/ngx-root-form.component.ts","../../../projects/ngx-sub-form/src/lib/deprecated/ngx-automatic-root-form.component.ts","../../../projects/ngx-sub-form/src/lib/deprecated/ngx-sub-form.decorators.ts","../../../projects/ngx-sub-form/src/lib/helpers.ts","../../../projects/ngx-sub-form/src/lib/ngx-sub-form.types.ts","../../../projects/ngx-sub-form/src/lib/ngx-sub-form.ts","../../../projects/ngx-sub-form/src/public_api.ts","../../../projects/ngx-sub-form/src/toolstik-ngx-sub-form.ts"],"sourcesContent":["import { InjectionToken, Type } from '@angular/core';\nimport {\n  AbstractControl,\n  AbstractControlOptions,\n  ControlValueAccessor,\n  FormArray,\n  FormControl,\n  FormGroup,\n  NG_VALIDATORS,\n  NG_VALUE_ACCESSOR,\n  ValidationErrors,\n} from '@angular/forms';\nimport { getObservableLifecycle } from 'ngx-observable-lifecycle';\nimport { Observable, Subject, timer } from 'rxjs';\nimport { debounce, takeUntil } from 'rxjs/operators';\nimport { NgxSubFormComponent } from '../deprecated/ngx-sub-form.component';\n\nexport type Controls<T> = { [K in keyof T]-?: AbstractControl };\n\nexport type ControlsNames<T> = { [K in keyof T]-?: K };\n\nexport type ControlMap<T, V> = { [K in keyof T]-?: V };\n\nexport type ControlForType<T> =\n  | TypedFormControl<T>\n  | (T extends any[] ? TypedFormArray<T> : T extends object ? TypedFormGroup<T> : never);\n\nexport type ControlsType<T> = {\n  [K in keyof T]-?: ControlForType<T[K]>;\n};\n\nexport type OneOfControlsTypes<T = any> = ControlsType<T>[keyof ControlsType<T>];\n\n/**\n * @deprecated\n */\nexport type FormErrorsType<T> = {\n  [K in keyof T]-?: T[K] extends any[] ? (null | ValidationErrors)[] : ValidationErrors;\n};\n\n/**\n * @deprecated\n */\nexport type FormUpdate<FormInterface> = { [FormControlInterface in keyof FormInterface]?: true };\n\n/**\n * @deprecated\n */\nexport type FormErrors<FormInterface> = null | Partial<\n  FormErrorsType<FormInterface> & {\n    formGroup?: ValidationErrors;\n  }\n>;\n\n// @todo rename to `FormErrorsType` once the deprecated one is removed\nexport type NewFormErrorsType<T> = {\n  [K in keyof T]-?: T[K] extends any[] ? Record<number, ValidationErrors> : ValidationErrors;\n};\n\n// @todo rename to `FormErrors` once the deprecated one is removed\nexport type NewFormErrors<FormInterface> = null | Partial<\n  NewFormErrorsType<FormInterface> & {\n    formGroup?: ValidationErrors;\n  }\n>;\n\n// using set/patch value options signature from form controls to allow typing without additional casting\nexport interface TypedAbstractControl<TValue> extends AbstractControl {\n  value: TValue;\n  valueChanges: Observable<TValue>;\n  setValue(value: TValue, options?: Parameters<AbstractControl['setValue']>[1]): void;\n  patchValue(value: Partial<TValue>, options?: Parameters<AbstractControl['patchValue']>[1]): void;\n}\n\nexport interface TypedFormGroup<TValue, FormControlsType extends ControlsType<TValue> = ControlsType<TValue>>\n  extends FormGroup {\n  value: TValue;\n  valueChanges: Observable<TValue>;\n  controls: FormControlsType;\n  setValue(value: TValue, options?: Parameters<FormGroup['setValue']>[1]): void;\n  patchValue(value: Partial<TValue>, options?: Parameters<FormGroup['patchValue']>[1]): void;\n  getRawValue(): TValue;\n}\n\nexport interface TypedFormArray<\n  TValue extends any[],\n  TControl extends ControlForType<TValue[0]> = ControlForType<TValue[0]>\n> extends FormArray {\n  value: TValue;\n  valueChanges: Observable<TValue>;\n  controls: TControl[];\n  setValue(value: TValue, options?: Parameters<FormArray['setValue']>[1]): void;\n  patchValue(value: TValue, options?: Parameters<FormArray['patchValue']>[1]): void;\n  getRawValue(): TValue;\n  push(control: TControl): void;\n}\n\nexport interface TypedFormControl<TValue> extends FormControl {\n  value: TValue;\n  valueChanges: Observable<TValue>;\n  setValue(value: TValue, options?: Parameters<FormControl['setValue']>[1]): void;\n  patchValue(value: Partial<TValue>, options?: Parameters<FormControl['patchValue']>[1]): void;\n}\n\nexport type KeysWithType<T, V> = { [K in keyof T]: T[K] extends V ? K : never }[keyof T];\n\nexport type ArrayPropertyKey<T> = KeysWithType<T, Array<any>>;\n\nexport type ArrayPropertyValue<T, K extends ArrayPropertyKey<T> = ArrayPropertyKey<T>> = T[K] extends Array<infer U>\n  ? U\n  : never;\n\nexport function subformComponentProviders(\n  component: any,\n): {\n  provide: InjectionToken<ControlValueAccessor>;\n  useExisting: Type<any>;\n  multi?: boolean;\n}[] {\n  return [\n    {\n      provide: NG_VALUE_ACCESSOR,\n      useExisting: component,\n      multi: true,\n    },\n    {\n      provide: NG_VALIDATORS,\n      useExisting: component,\n      multi: true,\n    },\n  ];\n}\n\nconst wrapAsQuote = (str: string): string => `\"${str}\"`;\n\nexport class MissingFormControlsError<T extends string> extends Error {\n  constructor(missingFormControls: T[]) {\n    super(\n      `Attempt to update the form value with an object that doesn't contains some of the required form control keys.\\nMissing: ${missingFormControls\n        .map(wrapAsQuote)\n        .join(`, `)}`,\n    );\n  }\n}\n\nexport const NGX_SUB_FORM_HANDLE_VALUE_CHANGES_RATE_STRATEGIES = {\n  debounce: <T, U>(time: number): ReturnType<NgxSubFormComponent<T, U>['handleEmissionRate']> => obs =>\n    obs.pipe(debounce(() => timer(time))),\n};\n\n/**\n * Easily unsubscribe from an observable stream by appending `takeUntilDestroyed(this)` to the observable pipe.\n * If the component already has a `ngOnDestroy` method defined, it will call this first.\n */\nexport function takeUntilDestroyed<T>(component: any): (source: Observable<T>) => Observable<T> {\n  const { ngOnDestroy } = getObservableLifecycle(component);\n  return (source: Observable<T>): Observable<T> => source.pipe(takeUntil(ngOnDestroy));\n}\n\n/** @internal */\nexport function isNullOrUndefined(obj: any): obj is null | undefined {\n  return obj === null || obj === undefined;\n}\n\nexport function createFormControl<T>(formState?: T, options?: AbstractControlOptions) {\n  return new FormControl(formState, options) as TypedFormControl<T>;\n}\n\nexport function createFormGroup<T extends object, TControls extends ControlsType<T> = ControlsType<T>>(\n  formState: TControls,\n  options?: AbstractControlOptions,\n) {\n  return new FormGroup(formState, options) as TypedFormGroup<T, TControls>;\n}\n\nexport function createFormArray<T extends any[], TControl extends ControlForType<T[0]> = ControlForType<T[0]>>(\n  formState: TControl[],\n  options?: AbstractControlOptions,\n) {\n  return new FormArray(formState, options) as TypedFormArray<T, TControl>;\n}\n","import { Directive, OnDestroy } from '@angular/core';\nimport {\n  AbstractControl,\n  AbstractControlOptions,\n  ControlValueAccessor,\n  FormArray,\n  FormControl,\n  FormGroup,\n  ValidationErrors,\n  Validator,\n} from '@angular/forms';\nimport { merge, Observable, Subscription } from 'rxjs';\nimport { delay, filter, map, startWith, withLatestFrom } from 'rxjs/operators';\nimport {\n  ArrayPropertyKey,\n  ControlMap,\n  Controls,\n  ControlsNames,\n  ControlsType,\n  FormErrors,\n  FormUpdate,\n  isNullOrUndefined,\n  MissingFormControlsError,\n  TypedAbstractControl,\n  TypedFormGroup,\n} from '../shared/ngx-sub-form-utils';\nimport { NgxFormWithArrayControls, OnFormUpdate, TypedAbstractControlOptions } from '../shared/ngx-sub-form.types';\n\ntype MapControlFunction<FormInterface, MapValue> = (\n  ctrl: TypedAbstractControl<any>,\n  key: keyof FormInterface,\n) => MapValue;\ntype FilterControlFunction<FormInterface> = (\n  ctrl: TypedAbstractControl<any>,\n  key: keyof FormInterface,\n  isCtrlWithinFormArray: boolean,\n) => boolean;\n\n/* eslint-disable @angular-eslint/directive-class-suffix */\n@Directive()\n/**\n * @deprecated\n */\nexport abstract class NgxSubFormComponent<ControlInterface, FormInterface = ControlInterface>\n  implements ControlValueAccessor, Validator, OnDestroy, OnFormUpdate<FormInterface> {\n  public get formGroupControls(): ControlsType<FormInterface> {\n    // @note form-group-undefined we need the return null here because we do not want to expose the fact that\n    // the form can be undefined, it's handled internally to contain an Angular bug\n    if (!this.formGroup) {\n      return null as any;\n    }\n\n    return (this.formGroup.controls as unknown) as ControlsType<FormInterface>;\n  }\n\n  public get formGroupValues(): Required<FormInterface> {\n    // see @note form-group-undefined for non-null assertion reason\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    return this.mapControls(ctrl => ctrl.value)!;\n  }\n\n  public get formGroupErrors(): FormErrors<FormInterface> {\n    const errors: FormErrors<FormInterface> = this.mapControls<ValidationErrors | ValidationErrors[] | null>(\n      ctrl => ctrl.errors,\n      (ctrl, _, isCtrlWithinFormArray) => (isCtrlWithinFormArray ? true : ctrl.invalid),\n      true,\n    ) as FormErrors<FormInterface>;\n\n    if (!this.formGroup.errors && (!errors || !Object.keys(errors).length)) {\n      return null;\n    }\n\n    return Object.assign({}, this.formGroup.errors ? { formGroup: this.formGroup.errors } : {}, errors);\n  }\n\n  public get formControlNames(): ControlsNames<FormInterface> {\n    // see @note form-group-undefined for as syntax\n    return this.mapControls(\n      (_, key) => key,\n      () => true,\n      false,\n    ) as ControlsNames<FormInterface>;\n  }\n\n  private controlKeys: (keyof FormInterface)[] = [];\n\n  // when developing the lib it's a good idea to set the formGroup type\n  // to current + `| undefined` to catch a bunch of possible issues\n  // see @note form-group-undefined\n  public formGroup: TypedFormGroup<FormInterface> = (new FormGroup(\n    this._getFormControls(),\n    this.getFormGroupControlOptions() as AbstractControlOptions,\n  ) as unknown) as TypedFormGroup<FormInterface>;\n\n  protected onChange: Function | undefined = undefined;\n  protected onTouched: Function | undefined = undefined;\n  protected emitNullOnDestroy = true;\n  protected emitInitialValueOnInit = true;\n\n  private subscription: Subscription | undefined = undefined;\n\n  // a RootFormComponent with the disabled property set initially to `false`\n  // will call `setDisabledState` *before* the form is actually available\n  // and it wouldn't be disabled once available, therefore we use this flag\n  // to check when the FormGroup is created if we should disable it\n  private controlDisabled = false;\n\n  constructor() {\n    // if the form has default values, they should be applied straight away\n    const defaultValues: Partial<FormInterface> | null = this.getDefaultValues();\n    if (!!defaultValues) {\n      this.formGroup.reset(defaultValues, { emitEvent: false });\n    }\n\n    // `setTimeout` and `updateValueAndValidity` are both required here\n    // indeed, if you check the demo you'll notice that without it, if\n    // you select `Droid` and `Assassin` for example the displayed errors\n    // are not yet defined for the field `assassinDroid`\n    // (until you change one of the value in that form)\n    setTimeout(() => {\n      if (this.formGroup) {\n        this.formGroup.updateValueAndValidity({ emitEvent: false });\n\n        if (this.controlDisabled) {\n          this.formGroup.disable();\n        }\n      }\n    }, 0);\n  }\n\n  // can't define them directly\n  protected abstract getFormControls(): Controls<FormInterface>;\n  private _getFormControls(): Controls<FormInterface> {\n    const controls: Controls<FormInterface> = this.getFormControls();\n\n    this.controlKeys = (Object.keys(controls) as unknown) as (keyof FormInterface)[];\n\n    return controls;\n  }\n\n  private mapControls<MapValue>(\n    mapControl: MapControlFunction<FormInterface, MapValue>,\n    filterControl: FilterControlFunction<FormInterface>,\n    recursiveIfArray: boolean,\n  ): Partial<ControlMap<FormInterface, MapValue | MapValue[]>> | null;\n  private mapControls<MapValue>(\n    mapControl: MapControlFunction<FormInterface, MapValue>,\n  ): ControlMap<FormInterface, MapValue | MapValue[]> | null;\n  private mapControls<MapValue>(\n    mapControl: MapControlFunction<FormInterface, MapValue>,\n    filterControl: FilterControlFunction<FormInterface> = () => true,\n    recursiveIfArray: boolean = true,\n  ): Partial<ControlMap<FormInterface, MapValue | MapValue[]>> | null {\n    if (!this.formGroup) {\n      return null;\n    }\n\n    const formControls: ControlsType<FormInterface> = this.formGroup.controls;\n\n    const controls: Partial<ControlMap<FormInterface, MapValue | MapValue[]>> = {};\n\n    for (const key in formControls) {\n      if (this.formGroup.controls.hasOwnProperty(key)) {\n        const control = formControls[key];\n\n        if (recursiveIfArray && control instanceof FormArray) {\n          const values: MapValue[] = [];\n\n          for (let i = 0; i < control.length; i++) {\n            if (filterControl(control.at(i), key, true)) {\n              values.push(mapControl(control.at(i), key));\n            }\n          }\n\n          if (values.length > 0 && values.some(x => !isNullOrUndefined(x))) {\n            controls[key] = values;\n          }\n        } else if (control && filterControl(control, key, false)) {\n          controls[key] = mapControl(control, key);\n        }\n      }\n    }\n\n    return controls;\n  }\n\n  public onFormUpdate(formUpdate: FormUpdate<FormInterface>): void {}\n\n  /**\n   * Extend this method to provide custom local FormGroup level validation\n   */\n  protected getFormGroupControlOptions(): TypedAbstractControlOptions<FormInterface> {\n    return {};\n  }\n\n  public validate(): ValidationErrors | null {\n    if (\n      // @hack see where defining this.formGroup to undefined\n      !this.formGroup ||\n      this.formGroup.valid\n    ) {\n      return null;\n    }\n\n    return this.formGroupErrors;\n  }\n\n  // @todo could this be removed to avoid an override and just use `takeUntilDestroyed`?\n  public ngOnDestroy(): void {\n    // @hack there's a memory leak within Angular and those components\n    // are not correctly cleaned up which leads to error if a form is defined\n    // with validators and then it's been removed, the validator would still fail\n    // `as any` if because we do not want to define the formGroup as FormGroup | undefined\n    // everything related to undefined is handled internally and shouldn't be exposed to end user\n    (this.formGroup as any) = undefined;\n\n    if (this.subscription) {\n      this.subscription.unsubscribe();\n    }\n\n    if (this.emitNullOnDestroy && this.onChange) {\n      this.onChange(null);\n    }\n\n    this.onChange = undefined;\n  }\n\n  // when getDefaultValues is defined, you do not need to specify the default values\n  // in your form (the ones defined within the `getFormControls` method)\n  protected getDefaultValues(): Partial<FormInterface> | null {\n    return null;\n  }\n\n  public writeValue(obj: Required<ControlInterface> | null): void {\n    // @hack see where defining this.formGroup to undefined\n    if (!this.formGroup) {\n      return;\n    }\n\n    const defaultValues: Partial<FormInterface> | null = this.getDefaultValues();\n\n    const transformedValue: FormInterface | null = this.transformToFormGroup(\n      obj === undefined ? null : obj,\n      defaultValues,\n    );\n\n    if (isNullOrUndefined(transformedValue)) {\n      this.formGroup.reset(\n        // calling `reset` on a form with `null` throws an error but if nothing is passed\n        // (undefined) it will reset all the form values to null (as expected)\n        defaultValues === null ? undefined : defaultValues,\n        { emitEvent: false },\n      );\n    } else {\n      const missingKeys: (keyof FormInterface)[] = this.getMissingKeys(transformedValue);\n      if (missingKeys.length > 0) {\n        throw new MissingFormControlsError(missingKeys as string[]);\n      }\n\n      this.handleFormArrayControls(transformedValue);\n\n      // The next few lines are weird but it's as workaround.\n      // There are some shady behavior with the disabled state\n      // of a form. Apparently, using `setValue` on a disabled\n      // form does re-enable it *sometimes*, not always.\n      // related issues:\n      // https://github.com/angular/angular/issues/31506\n      // https://github.com/angular/angular/issues/22556\n      // but if you display `this.formGroup.disabled`\n      // before and after the `setValue` is called, it's the same\n      // result which is even weirder\n      const fgDisabled: boolean = this.formGroup.disabled;\n\n      this.formGroup.setValue(transformedValue, {\n        emitEvent: false,\n      });\n\n      if (fgDisabled) {\n        this.formGroup.disable();\n      }\n    }\n\n    this.formGroup.markAsPristine();\n    this.formGroup.markAsUntouched();\n  }\n\n  private handleFormArrayControls(obj: any) {\n    Object.entries(obj).forEach(([key, value]) => {\n      if (this.formGroup.get(key) instanceof FormArray && Array.isArray(value)) {\n        const formArray: FormArray = this.formGroup.get(key) as FormArray;\n\n        // instead of creating a new array every time and push a new FormControl\n        // we just remove or add what is necessary so that:\n        // - it is as efficient as possible and do not create unnecessary FormControl every time\n        // - validators are not destroyed/created again and eventually fire again for no reason\n        while (formArray.length > value.length) {\n          formArray.removeAt(formArray.length - 1);\n        }\n\n        for (let i = formArray.length; i < value.length; i++) {\n          if (this.formIsFormWithArrayControls()) {\n            formArray.insert(i, this.createFormArrayControl(key as ArrayPropertyKey<FormInterface>, value[i]));\n          } else {\n            formArray.insert(i, new FormControl(value[i]));\n          }\n        }\n      }\n    });\n  }\n\n  private formIsFormWithArrayControls(): this is NgxFormWithArrayControls<FormInterface> {\n    return typeof ((this as unknown) as NgxFormWithArrayControls<FormInterface>).createFormArrayControl === 'function';\n  }\n\n  private getMissingKeys(transformedValue: FormInterface | null) {\n    // `controlKeys` can be an empty array, empty forms are allowed\n    const missingKeys: (keyof FormInterface)[] = this.controlKeys.reduce((keys, key) => {\n      if (isNullOrUndefined(transformedValue) || transformedValue[key] === undefined) {\n        keys.push(key);\n      }\n\n      return keys;\n    }, [] as (keyof FormInterface)[]);\n\n    return missingKeys;\n  }\n\n  // when customizing the emission rate of your sub form component, remember not to **mutate** the stream\n  // it is safe to throttle, debounce, delay, etc but using skip, first, last or mutating data inside\n  // the stream will cause issues!\n  protected handleEmissionRate(): (obs$: Observable<FormInterface>) => Observable<FormInterface> {\n    return obs$ => obs$;\n  }\n\n  // that method can be overridden if the\n  // shape of the form needs to be modified\n  protected transformToFormGroup(\n    obj: ControlInterface | null,\n    defaultValues: Partial<FormInterface> | null,\n  ): FormInterface | null {\n    return (obj as any) as FormInterface;\n  }\n\n  // that method can be overridden if the\n  // shape of the form needs to be modified\n  protected transformFromFormGroup(formValue: FormInterface): ControlInterface | null {\n    return (formValue as any) as ControlInterface;\n  }\n\n  public registerOnChange(fn: (_: any) => void): void {\n    if (!this.formGroup) {\n      return;\n    }\n\n    this.onChange = fn;\n\n    interface KeyValueForm {\n      key: keyof FormInterface;\n      value: unknown;\n    }\n\n    const formControlNames: (keyof FormInterface)[] = Object.keys(this.formControlNames) as (keyof FormInterface)[];\n\n    const formValues: Observable<KeyValueForm>[] = formControlNames.map(key =>\n      ((this.formGroup.controls[key] as unknown) as AbstractControl).valueChanges.pipe(\n        startWith(this.formGroup.controls[key].value),\n        map(value => ({ key, value })),\n      ),\n    );\n\n    const lastKeyEmitted$: Observable<keyof FormInterface> = merge(...formValues.map(obs => obs.pipe(map(x => x.key))));\n\n    this.subscription = this.formGroup.valueChanges\n      .pipe(\n        // hook to give access to the observable for sub-classes\n        // this allow sub-classes (for example) to debounce, throttle, etc\n        this.handleEmissionRate(),\n        startWith(this.formGroup.value),\n        // this is required otherwise an `ExpressionChangedAfterItHasBeenCheckedError` will happen\n        // this is due to the fact that parent component will define a given state for the form that might\n        // be changed once the children are being initialized\n        delay(0),\n        filter(() => !!this.formGroup),\n        // detect which stream emitted last\n        withLatestFrom(lastKeyEmitted$),\n        map(([_, keyLastEmit], index) => {\n          if (index > 0 && this.onTouched) {\n            this.onTouched();\n          }\n\n          if (index > 0 || (index === 0 && this.emitInitialValueOnInit)) {\n            if (this.onChange) {\n              this.onChange(\n                this.transformFromFormGroup(\n                  // do not use the changes passed by `this.formGroup.valueChanges` here\n                  // as we've got a delay(0) above, on the next tick the form data might\n                  // be outdated and might result into an inconsistent state where a form\n                  // state is valid (base on latest value) but the previous value\n                  // (the one passed by `this.formGroup.valueChanges` would be the previous one)\n                  this.formGroup.value,\n                ),\n              );\n            }\n\n            const formUpdate: FormUpdate<FormInterface> = {};\n            formUpdate[keyLastEmit] = true;\n            this.onFormUpdate(formUpdate);\n          }\n        }),\n      )\n      .subscribe();\n  }\n\n  public registerOnTouched(fn: any): void {\n    this.onTouched = fn;\n  }\n\n  public setDisabledState(shouldDisable: boolean | undefined): void {\n    this.controlDisabled = !!shouldDisable;\n\n    if (!this.formGroup) {\n      return;\n    }\n\n    if (shouldDisable) {\n      this.formGroup.disable({ emitEvent: false });\n    } else {\n      this.formGroup.enable({ emitEvent: false });\n    }\n  }\n}\n\n@Directive()\n/**\n * @deprecated\n */\nexport abstract class NgxSubFormRemapComponent<ControlInterface, FormInterface> extends NgxSubFormComponent<\n  ControlInterface,\n  FormInterface\n> {\n  protected abstract transformToFormGroup(\n    obj: ControlInterface | null,\n    defaultValues: Partial<FormInterface> | null,\n  ): FormInterface | null;\n  protected abstract transformFromFormGroup(formValue: FormInterface): ControlInterface | null;\n}\n","import { Directive, EventEmitter, Input, OnInit } from '@angular/core';\nimport isEqual from 'fast-deep-equal';\nimport { BehaviorSubject, Subject } from 'rxjs';\nimport { filter, tap } from 'rxjs/operators';\nimport { isNullOrUndefined, takeUntilDestroyed } from '../shared/ngx-sub-form-utils';\nimport { NgxSubFormRemapComponent } from './ngx-sub-form.component';\n\n/* eslint-disable @angular-eslint/directive-class-suffix */\n@Directive()\n/**\n * @deprecated\n */\nexport abstract class NgxRootFormComponent<ControlInterface, FormInterface = ControlInterface>\n  extends NgxSubFormRemapComponent<ControlInterface, FormInterface>\n  implements OnInit {\n  public abstract dataInput: Required<ControlInterface> | null | undefined;\n  // `Input` values are set while the `ngOnChanges` hook is ran\n  // and it does happen before the `ngOnInit` where we start\n  // listening to `dataInput$`. Therefore, it cannot be a `Subject`\n  // or we will miss the first value\n  protected dataInput$: BehaviorSubject<Required<ControlInterface> | null | undefined> = new BehaviorSubject<\n    Required<ControlInterface> | null | undefined\n  >(null);\n\n  public abstract dataOutput: EventEmitter<ControlInterface>;\n  // using a private variable `_dataOutput$` to be able to control the\n  // emission rate with a debounce or throttle for ex\n  /** @internal */\n  protected _dataOutput$: Subject<ControlInterface> = new Subject();\n\n  @Input()\n  public set disabled(shouldDisable: boolean | undefined) {\n    this.setDisabledState(shouldDisable);\n  }\n\n  protected emitInitialValueOnInit = false;\n  protected emitNullOnDestroy = false;\n\n  protected dataValue: ControlInterface | null = null;\n\n  public ngOnInit(): void {\n    // we need to manually call registerOnChange because that function\n    // handles most of the logic from NgxSubForm and when it's called\n    // as a ControlValueAccessor that function is called by Angular itself\n    this.registerOnChange(data => this.onRegisterOnChangeHook(data));\n\n    this.dataInput$\n      .pipe(\n        filter(newValue => !isEqual(newValue, this.formGroup.value)),\n        tap(newValue => {\n          if (!isNullOrUndefined(newValue)) {\n            this.writeValue(newValue);\n          }\n        }),\n        takeUntilDestroyed(this),\n      )\n      .subscribe();\n\n    this._dataOutput$\n      .pipe(\n        filter(() => this.formGroup.valid),\n        tap(value => this.dataOutput.emit(value)),\n        takeUntilDestroyed(this),\n      )\n      .subscribe();\n  }\n\n  /** @internal */\n  protected onRegisterOnChangeHook(data: ControlInterface | null): boolean {\n    if (this.formGroup.invalid || isEqual(data, this.dataInput$.value)) {\n      return false;\n    }\n\n    this.dataValue = data;\n    return true;\n  }\n\n  // called by the DataInput decorator\n  /** @internal */\n  public dataInputUpdated(data: Required<ControlInterface> | null | undefined): void {\n    this.dataInput$.next(data);\n  }\n\n  public writeValue(obj: Required<ControlInterface> | null): void {\n    this.dataValue = obj;\n    super.writeValue(obj);\n  }\n\n  protected transformToFormGroup(\n    obj: ControlInterface | null,\n    defaultValues: Partial<FormInterface> | null,\n  ): FormInterface | null {\n    return (obj as unknown) as FormInterface;\n  }\n\n  protected transformFromFormGroup(formValue: FormInterface): ControlInterface | null {\n    return (formValue as unknown) as ControlInterface;\n  }\n\n  public manualSave(): void {\n    if (!isNullOrUndefined(this.dataValue) && this.formGroup.valid) {\n      this._dataOutput$.next(this.dataValue);\n    }\n  }\n}\n","import { Directive, OnInit } from '@angular/core';\nimport { NgxRootFormComponent } from './ngx-root-form.component';\n\n/* eslint-disable @angular-eslint/directive-class-suffix */\n@Directive()\n/**\n * @deprecated\n */\nexport abstract class NgxAutomaticRootFormComponent<ControlInterface, FormInterface = ControlInterface>\n  extends NgxRootFormComponent<ControlInterface, FormInterface>\n  implements OnInit {\n  /** @internal */\n  protected onRegisterOnChangeHook(data: ControlInterface | null) {\n    if (!super.onRegisterOnChangeHook(data)) {\n      return false;\n    }\n\n    if (this.formGroup) {\n      this.formGroup.markAsPristine();\n\n      if (this.formGroup.valid) {\n        this.manualSave();\n      }\n    }\n\n    return true;\n  }\n}\n","import { NgxRootFormComponent } from './ngx-root-form.component';\n\n/**\n * @deprecated\n */\nexport class DataInputUsedOnWrongPropertyError extends Error {\n  constructor(calledOnPropertyKey: string) {\n    super(\n      `You're trying to apply the \"DataInput\" decorator on a property called \"${calledOnPropertyKey}\". That decorator should only be used on a property called \"dataInput\"`,\n    );\n  }\n}\n\n/**\n * @deprecated\n */\nexport function DataInput() {\n  return function<ControlInterface, FormInterface = ControlInterface>(\n    target: NgxRootFormComponent<ControlInterface, FormInterface>,\n    propertyKey: string,\n  ) {\n    if (propertyKey !== 'dataInput') {\n      throw new DataInputUsedOnWrongPropertyError(propertyKey);\n    }\n\n    Object.defineProperty(target, propertyKey, {\n      set: function(dataInputValue) {\n        (this as NgxRootFormComponent<ControlInterface, FormInterface>).dataInputUpdated(dataInputValue);\n      },\n    });\n  };\n}\n","import { AbstractControlOptions, ControlValueAccessor, FormArray, FormGroup, ValidationErrors } from '@angular/forms';\nimport { ReplaySubject } from 'rxjs';\nimport {\n  ControlValueAccessorComponentInstance,\n  FormBindings,\n  NgxFormOptions,\n  NgxSubFormArrayOptions,\n} from './ngx-sub-form.types';\nimport {\n  ArrayPropertyKey,\n  ControlsNames,\n  ControlsType,\n  NewFormErrors,\n  OneOfControlsTypes,\n  TypedFormGroup,\n} from './shared/ngx-sub-form-utils';\n\nexport type Nilable<T> = T | null | undefined;\n\nexport const deepCopy = <T>(value: T): T => JSON.parse(JSON.stringify(value));\n\n/** @internal */\nexport const patchClassInstance = (componentInstance: any, obj: Object) => {\n  Object.entries(obj).forEach(([key, newMethod]) => {\n    componentInstance[key] = newMethod;\n  });\n};\n\n/** @internal */\nexport const getControlValueAccessorBindings = <ControlInterface>(\n  componentInstance: ControlValueAccessorComponentInstance,\n): FormBindings<ControlInterface> => {\n  const writeValue$$: ReplaySubject<Nilable<ControlInterface>> = new ReplaySubject(1);\n  const registerOnChange$$: ReplaySubject<(formValue: ControlInterface | null) => void> = new ReplaySubject(1);\n  const registerOnTouched$$: ReplaySubject<() => void> = new ReplaySubject(1);\n  const setDisabledState$$: ReplaySubject<boolean> = new ReplaySubject(1);\n\n  const controlValueAccessorPatch: Required<ControlValueAccessor> = {\n    writeValue: (obj: Nilable<any>): void => {\n      writeValue$$.next(obj);\n    },\n    registerOnChange: (fn: (formValue: ControlInterface | null) => void): void => {\n      registerOnChange$$.next(fn);\n    },\n    registerOnTouched: (fn: () => void): void => {\n      registerOnTouched$$.next(fn);\n    },\n    setDisabledState: (shouldDisable: boolean | undefined): void => {\n      setDisabledState$$.next(shouldDisable);\n    },\n  };\n\n  patchClassInstance(componentInstance, controlValueAccessorPatch);\n\n  return {\n    writeValue$: writeValue$$.asObservable(),\n    registerOnChange$: registerOnChange$$.asObservable(),\n    registerOnTouched$: registerOnTouched$$.asObservable(),\n    setDisabledState$: setDisabledState$$.asObservable(),\n  };\n};\n\nexport const getFormGroupErrors = <ControlInterface, FormInterface>(\n  formGroup: TypedFormGroup<FormInterface>,\n): NewFormErrors<FormInterface> => {\n  const formErrors: NewFormErrors<ControlInterface> = Object.entries<OneOfControlsTypes>(formGroup.controls).reduce<\n    Exclude<NewFormErrors<ControlInterface>, null>\n  >((acc, [key, control]) => {\n    if (control.errors) {\n      // all of FormControl, FormArray and FormGroup can have errors so we assign them first\n      const accumulatedGenericError = acc as Record<keyof ControlInterface, ValidationErrors>;\n      accumulatedGenericError[key as keyof ControlInterface] = control.errors;\n    }\n\n    if (control instanceof FormArray) {\n      // errors within an array are represented as a map\n      // with the index and the error\n      // this way, we avoid holding a lot of potential `null`\n      // values in the array for the valid form controls\n      const errorsInArray: Record<number, ValidationErrors> = {};\n\n      for (let i = 0; i < control.length; i++) {\n        const controlErrors = control.at(i).errors;\n        if (controlErrors) {\n          errorsInArray[i] = controlErrors;\n        }\n      }\n\n      if (Object.values(errorsInArray).length > 0) {\n        const accumulatedArrayErrors = acc as Record<keyof ControlInterface, Record<number, ValidationErrors>>;\n        if (!(key in accumulatedArrayErrors)) {\n          accumulatedArrayErrors[key as keyof ControlInterface] = {};\n      }\n        Object.assign(accumulatedArrayErrors[key as keyof ControlInterface], errorsInArray);\n    }\n    }\n\n    return acc;\n  }, {});\n\n  if (!formGroup.errors && !Object.values(formErrors).length) {\n    return null;\n  }\n\n  // todo remove any\n  return Object.assign<any, any, any>({}, formGroup.errors ? { formGroup: formGroup.errors } : {}, formErrors);\n};\n\ninterface FormArrayWrapper<FormInterface> {\n  key: keyof FormInterface;\n  control: FormArray;\n}\n\nexport function createFormDataFromOptions<\n  ControlInterface,\n  FormInterface,\n  FormControlsType extends ControlsType<FormInterface>\n>(options: NgxFormOptions<ControlInterface, FormInterface, FormControlsType>) {\n  const formGroup: TypedFormGroup<FormInterface, FormControlsType> = new FormGroup(\n    options.formControls,\n    options.formGroupOptions as AbstractControlOptions,\n  ) as TypedFormGroup<FormInterface, FormControlsType>;\n  const defaultValues: FormInterface = deepCopy(formGroup.value);\n  const formGroupKeys: (keyof FormInterface)[] = Object.keys(defaultValues) as (keyof FormInterface)[];\n  const formControlNames: ControlsNames<FormInterface> = formGroupKeys.reduce<ControlsNames<FormInterface>>(\n    (acc, curr) => {\n      acc[curr] = curr;\n      return acc;\n    },\n    {} as ControlsNames<FormInterface>,\n  );\n\n  const formArrays: FormArrayWrapper<FormInterface>[] = formGroupKeys.reduce<FormArrayWrapper<FormInterface>[]>(\n    (acc, key) => {\n      const control = formGroup.get(key as string);\n      if (control instanceof FormArray) {\n        acc.push({ key, control });\n      }\n      return acc;\n    },\n    [],\n  );\n  return { formGroup, defaultValues, formControlNames, formArrays };\n}\n\nexport const handleFormArrays = <FormInterface>(\n  formArrayWrappers: FormArrayWrapper<FormInterface>[],\n  obj: FormInterface,\n  createFormArrayControl: Required<NgxSubFormArrayOptions<FormInterface>>['createFormArrayControl'],\n) => {\n  if (!formArrayWrappers.length) {\n    return;\n  }\n\n  formArrayWrappers.forEach(({ key, control }) => {\n    const value = obj[key];\n\n    if (!Array.isArray(value)) {\n      return;\n    }\n\n    // instead of creating a new array every time and push a new FormControl\n    // we just remove or add what is necessary so that:\n    // - it is as efficient as possible and do not create unnecessary FormControl every time\n    // - validators are not destroyed/created again and eventually fire again for no reason\n    while (control.length > value.length) {\n      control.removeAt(control.length - 1);\n    }\n\n    for (let i = control.length; i < value.length; i++) {\n      control.insert(i, createFormArrayControl(key as ArrayPropertyKey<FormInterface>, value[i]));\n    }\n  });\n};\n","import { ControlValueAccessor, FormControl, Validator } from '@angular/forms';\nimport { Observable, Subject } from 'rxjs';\nimport { Nilable } from './helpers';\nimport {\n  ArrayPropertyKey,\n  ArrayPropertyValue,\n  ControlsNames,\n  ControlsType,\n  NewFormErrors,\n  TypedFormGroup,\n} from './shared/ngx-sub-form-utils';\nimport { TypedAbstractControlOptions } from './shared/ngx-sub-form.types';\n\nexport interface ComponentHooks {\n  onDestroy: Observable<void>;\n  afterViewInit: Observable<void>;\n}\n\nexport interface FormBindings<ControlInterface> {\n  readonly writeValue$: Observable<Nilable<ControlInterface>>;\n  readonly registerOnChange$: Observable<(formValue: ControlInterface | null) => void>;\n  readonly registerOnTouched$: Observable<() => void>;\n  readonly setDisabledState$: Observable<boolean>;\n}\n\nexport type ControlValueAccessorComponentInstance = Object &\n  // ControlValueAccessor methods are called\n  // directly by Angular and expects a value\n  // so we have to define it within ngx-sub-form\n  // and this should *never* be overridden by the component\n  Partial<Record<keyof ControlValueAccessor, never> & Record<keyof Validator, never>>;\n\nexport interface NgxSubForm<\n  ControlInterface,\n  FormInterface,\n  FormControlsType extends ControlsType<FormInterface> = ControlsType<FormInterface>\n> {\n  readonly formGroup: TypedFormGroup<FormInterface, FormControlsType>;\n  readonly formControlNames: ControlsNames<FormInterface>;\n  readonly formGroupErrors: NewFormErrors<FormInterface>;\n  readonly createFormArrayControl: CreateFormArrayControlMethod<FormInterface>;\n  readonly controlValue$: Observable<Nilable<ControlInterface>>;\n  readonly value: ControlInterface;\n}\n\nexport type CreateFormArrayControlMethod<FormInterface> = <K extends ArrayPropertyKey<FormInterface>>(\n  key: K,\n  initialValue: ArrayPropertyValue<FormInterface, K>,\n) => FormControl;\n\nexport interface NgxRootForm<\n  ControlInterface,\n  FormInterface,\n  FormControlsType extends ControlsType<FormInterface> = ControlsType<FormInterface>\n> extends NgxSubForm<ControlInterface, FormInterface, FormControlsType> {\n  // @todo: anything else needed here?\n}\n\nexport interface NgxSubFormArrayOptions<FormInterface> {\n  createFormArrayControl?: CreateFormArrayControlMethod<FormInterface>;\n}\n\nexport interface NgxSubFormRemapOptions<ControlInterface, FormInterface> {\n  toFormGroup: (obj: ControlInterface) => FormInterface;\n  fromFormGroup: (formValue: FormInterface) => ControlInterface;\n}\n\nexport type AreTypesSimilar<T, U> = T extends U ? (U extends T ? true : false) : false;\n\n// if the 2 types are the same, instead of hiding the remap options\n// we expose them as optional so that it's possible for example to\n// override some defaults\ntype NgxSubFormRemap<ControlInterface, FormInterface> = AreTypesSimilar<ControlInterface, FormInterface> extends true // we expose them\n  ? Partial<NgxSubFormRemapOptions<ControlInterface, FormInterface>>\n  : NgxSubFormRemapOptions<ControlInterface, FormInterface>;\n\ntype NgxSubFormArray<FormInterface> = ArrayPropertyKey<FormInterface> extends never\n  ? {} // no point defining `createFormArrayControl` if there's not a single array in the `FormInterface`\n  : NgxSubFormArrayOptions<FormInterface>;\n\nexport type NgxAbstractFormOptions<\n  FType extends FormType,\n  ControlInterface,\n  FormInterface = ControlInterface,\n  FormControlsType extends ControlsType<FormInterface> = ControlsType<FormInterface>\n> = {\n  formType: FType;\n  formControls: FormControlsType;\n  formGroupOptions?: TypedAbstractControlOptions<FormInterface>;\n  emitNullOnDestroy?: boolean;\n  componentHooks?: ComponentHooks;\n  // emit on this observable to mark the control as touched\n  touched$?: Observable<void>;\n} & NgxSubFormRemap<ControlInterface, FormInterface> &\n  NgxSubFormArray<FormInterface>;\n\nexport type NgxSubFormOptions<\n  ControlInterface,\n  FormInterface = ControlInterface,\n  FormControlsType extends ControlsType<FormInterface> = ControlsType<FormInterface>\n> = NgxAbstractFormOptions<FormType.SUB, ControlInterface, FormInterface, FormControlsType>;\n\nexport type NgxRootFormOptions<\n  ControlInterface,\n  FormInterface = ControlInterface,\n  FormControlsType extends ControlsType<FormInterface> = ControlsType<FormInterface>\n> = NgxAbstractFormOptions<FormType.ROOT, ControlInterface, FormInterface, FormControlsType> & {\n  input$: Observable<ControlInterface | undefined>;\n  output$: Subject<ControlInterface>;\n  disabled$?: Observable<boolean>;\n  // by default, a root form is considered as an automatic root form\n  // if you want to transform it into a manual root form, provide the\n  // following observable which trigger a save every time a value is emitted\n  manualSave$?: Observable<void>;\n  // The default behavior is to compare the current transformed value of input$ with the current value of the form, and\n  // if these are equal emission on output$ is suppressed to prevent the from broadcasting the current value.\n  // Configure this option to provide your own custom predicate whether or not the form should emit.\n  outputFilterPredicate?: (currentInputValue: FormInterface, outputValue: FormInterface) => boolean;\n  // if you want to control how frequently the form emits on the output$, you can customise the emission rate with this\n  // option. e.g. `handleEmissionRate: formValue$ => formValue$.pipe(debounceTime(300)),`\n  handleEmissionRate?: (obs$: Observable<FormInterface>) => Observable<FormInterface>;\n};\n\nexport enum FormType {\n  SUB = 'Sub',\n  ROOT = 'Root',\n}\n\nexport type NgxFormOptions<\n  ControlInterface,\n  FormInterface,\n  FormControlsType extends ControlsType<FormInterface> = ControlsType<FormInterface>\n> =\n  | NgxSubFormOptions<ControlInterface, FormInterface, FormControlsType>\n  | NgxRootFormOptions<ControlInterface, FormInterface, FormControlsType>;\n","import { ɵmarkDirty as markDirty } from '@angular/core';\nimport { FormControl } from '@angular/forms';\nimport isEqual from 'fast-deep-equal';\nimport { getObservableLifecycle } from 'ngx-observable-lifecycle';\nimport { combineLatest, concat, EMPTY, identity, merge, Observable, of, timer } from 'rxjs';\nimport {\n  delay,\n  filter,\n  map,\n  mapTo,\n  shareReplay,\n  startWith,\n  switchMap,\n  take,\n  takeUntil,\n  tap,\n  withLatestFrom,\n} from 'rxjs/operators';\nimport {\n  createFormDataFromOptions,\n  getControlValueAccessorBindings,\n  getFormGroupErrors,\n  handleFormArrays,\n  patchClassInstance,\n} from './helpers';\nimport {\n  ComponentHooks,\n  ControlValueAccessorComponentInstance,\n  FormBindings,\n  FormType,\n  NgxFormOptions,\n  NgxRootForm,\n  NgxRootFormOptions,\n  NgxSubForm,\n  NgxSubFormArrayOptions,\n  NgxSubFormOptions,\n} from './ngx-sub-form.types';\nimport { ControlsType, isNullOrUndefined } from './shared/ngx-sub-form-utils';\n\nconst optionsHaveInstructionsToCreateArrays = <\n  ControlInterface,\n  FormInterface,\n  FormControlsType extends ControlsType<FormInterface>\n>(\n  options: NgxFormOptions<ControlInterface, FormInterface, FormControlsType> &\n    Partial<NgxSubFormArrayOptions<FormInterface>>,\n): options is NgxSubFormOptions<ControlInterface, FormInterface, FormControlsType> &\n  NgxSubFormArrayOptions<FormInterface> => !!options.createFormArrayControl;\n\n// @todo find a better name\nconst isRoot = <ControlInterface, FormInterface>(\n  options: any,\n): options is NgxRootFormOptions<ControlInterface, FormInterface> => {\n  const opt = options as NgxRootFormOptions<ControlInterface, FormInterface>;\n  return opt.formType === FormType.ROOT;\n};\n\nexport function createForm<\n  ControlInterface,\n  FormInterface = ControlInterface,\n  FormControlsType extends ControlsType<FormInterface> = ControlsType<FormInterface>\n>(\n  componentInstance: ControlValueAccessorComponentInstance,\n  options: NgxRootFormOptions<ControlInterface, FormInterface, FormControlsType>,\n): NgxRootForm<ControlInterface, FormInterface, FormControlsType>;\nexport function createForm<\n  ControlInterface,\n  FormInterface = ControlInterface,\n  FormControlsType extends ControlsType<FormInterface> = ControlsType<FormInterface>\n>(\n  componentInstance: ControlValueAccessorComponentInstance,\n  options: NgxSubFormOptions<ControlInterface, FormInterface, FormControlsType>,\n): NgxSubForm<ControlInterface, FormInterface, FormControlsType>;\nexport function createForm<\n  ControlInterface,\n  FormInterface,\n  FormControlsType extends ControlsType<FormInterface> = ControlsType<FormInterface>\n>(\n  componentInstance: ControlValueAccessorComponentInstance,\n  options: NgxFormOptions<ControlInterface, FormInterface, FormControlsType>,\n): NgxSubForm<ControlInterface, FormInterface, FormControlsType> {\n  const { formGroup, defaultValues, formControlNames, formArrays } = createFormDataFromOptions<\n    ControlInterface,\n    FormInterface,\n    FormControlsType\n  >(options);\n\n  let isRemoved = false;\n\n  const lifecyleHooks: ComponentHooks = options.componentHooks ?? {\n    onDestroy: getObservableLifecycle(componentInstance).ngOnDestroy,\n    afterViewInit: getObservableLifecycle(componentInstance).ngAfterViewInit,\n  };\n\n  lifecyleHooks.onDestroy.pipe(take(1)).subscribe(() => {\n    isRemoved = true;\n  });\n\n  // define the `validate` method to improve errors\n  // and support nested errors\n  patchClassInstance(componentInstance, {\n    validate: () => {\n      if (isRemoved) return null;\n\n      if (formGroup.valid) {\n        return null;\n      }\n\n      return getFormGroupErrors<ControlInterface, FormInterface>(formGroup);\n    },\n  });\n\n  // in order to ensure the form has the correct state (and validation errors) we update the value and validity\n  // immediately after the first tick\n  const updateValueAndValidity$ = timer(0);\n\n  const componentHooks = getControlValueAccessorBindings<ControlInterface>(componentInstance);\n\n  const writeValue$: FormBindings<ControlInterface>['writeValue$'] = isRoot<ControlInterface, FormInterface>(options)\n    ? options.input$.pipe(\n        // we need to start with a value here otherwise if a root form does not bind\n        // its input (and only uses an output, for example a filter) then\n        // `broadcastValueToParent$` would never start and we would never get updates\n        startWith(null),\n      )\n    : componentHooks.writeValue$;\n\n  const registerOnChange$: FormBindings<ControlInterface>['registerOnChange$'] = isRoot<\n    ControlInterface,\n    FormInterface\n  >(options)\n    ? of(data => {\n        if (!data) {\n          return;\n        }\n        options.output$.next(data);\n      })\n    : componentHooks.registerOnChange$;\n\n  const setDisabledState$: FormBindings<ControlInterface>['setDisabledState$'] = isRoot<\n    ControlInterface,\n    FormInterface\n  >(options)\n    ? options.disabled$ ?? of(false)\n    : componentHooks.setDisabledState$;\n\n  const transformedValue$: Observable<FormInterface> = writeValue$.pipe(\n    map(value => {\n      if (isNullOrUndefined(value)) {\n        return defaultValues;\n      }\n\n      if (options.toFormGroup) {\n        return options.toFormGroup(value);\n      }\n\n      // if it's not a remap component, the ControlInterface === the FormInterface\n      return (value as any) as FormInterface;\n    }),\n    shareReplay({ refCount: true, bufferSize: 1 }),\n  );\n\n  const broadcastValueToParent$: Observable<ControlInterface> = transformedValue$.pipe(\n    switchMap(transformedValue => {\n      if (!isRoot<ControlInterface, FormInterface>(options)) {\n        return formGroup.valueChanges.pipe(delay(0));\n      } else {\n        const formValues$ = options.manualSave$\n          ? options.manualSave$.pipe(\n              withLatestFrom(formGroup.valueChanges),\n              map(([_, formValue]) => formValue),\n            )\n          : formGroup.valueChanges;\n\n        // it might be surprising to see formGroup validity being checked twice\n        // here, however this is intentional. The delay(0) allows any sub form\n        // components to populate values into the form, and it is possible for\n        // the form to be invalid after this process. In which case we suppress\n        // outputting an invalid value, and wait for the user to make the value\n        // become valid.\n        return formValues$.pipe(\n          filter(() => formGroup.valid),\n          delay(0),\n          filter(formValue => {\n            if (formGroup.invalid) {\n              return false;\n            }\n\n            if (options.outputFilterPredicate) {\n              return options.outputFilterPredicate(transformedValue, formValue);\n            }\n\n            return !isEqual(transformedValue, formValue);\n          }),\n          options.handleEmissionRate ?? identity,\n        );\n      }\n    }),\n    map(value =>\n      options.fromFormGroup\n        ? options.fromFormGroup(value)\n        : // if it's not a remap component, the ControlInterface === the FormInterface\n          ((value as any) as ControlInterface),\n    ),\n  );\n\n  // components often need to know what the current value of the FormControl that it is representing is, usually for\n  // display purposes in the template. This value is the composition of the value written from the parent, and the\n  // transformed current value that was most recently written to the parent\n  const controlValue$: NgxSubForm<ControlInterface, FormInterface>['controlValue$'] = merge(\n    writeValue$,\n    broadcastValueToParent$,\n  ).pipe(shareReplay({ bufferSize: 1, refCount: true }));\n\n  const emitNullOnDestroy$: Observable<null> =\n    // emit null when destroyed by default\n    isNullOrUndefined(options.emitNullOnDestroy) || options.emitNullOnDestroy\n      ? lifecyleHooks.onDestroy.pipe(mapTo(null))\n      : EMPTY;\n\n  const createFormArrayControl: Required<NgxSubFormArrayOptions<FormInterface>>['createFormArrayControl'] =\n    optionsHaveInstructionsToCreateArrays<ControlInterface, FormInterface, FormControlsType>(options) &&\n    options.createFormArrayControl\n      ? options.createFormArrayControl\n      : (key, initialValue) => new FormControl(initialValue);\n\n  const sideEffects = {\n    broadcastValueToParent$: registerOnChange$.pipe(\n      switchMap(onChange => broadcastValueToParent$.pipe(tap(value => onChange(value)))),\n    ),\n    applyUpstreamUpdateOnLocalForm$: transformedValue$.pipe(\n      tap(value => {\n        handleFormArrays<FormInterface>(formArrays, value, createFormArrayControl);\n\n        formGroup.reset(value, { emitEvent: false });\n      }),\n    ),\n    supportChangeDetectionStrategyOnPush: concat(\n      lifecyleHooks.afterViewInit.pipe(take(1)),\n      merge(controlValue$, setDisabledState$).pipe(\n        delay(0),\n        tap(() => {\n          // support `changeDetection: ChangeDetectionStrategy.OnPush`\n          // on the component hosting a form\n          // fixes https://github.com/cloudnc/ngx-sub-form/issues/93\n          markDirty(componentInstance);\n        }),\n      ),\n    ),\n    setDisabledState$: setDisabledState$.pipe(\n      tap((shouldDisable: boolean) => {\n        shouldDisable ? formGroup.disable({ emitEvent: false }) : formGroup.enable({ emitEvent: false });\n      }),\n    ),\n    updateValue$: updateValueAndValidity$.pipe(\n      tap(() => {\n        formGroup.updateValueAndValidity({ emitEvent: false });\n      }),\n    ),\n    bindTouched$: combineLatest([componentHooks.registerOnTouched$, options.touched$ ?? EMPTY]).pipe(\n      delay(0),\n      tap(([onTouched]) => onTouched()),\n    ),\n  };\n\n  merge(...Object.values(sideEffects))\n    .pipe(takeUntil(lifecyleHooks.onDestroy))\n    .subscribe();\n\n  // following cannot be part of `forkJoin(sideEffects)`\n  // because it uses `takeUntilDestroyed` which destroys\n  // the subscription when the component is being destroyed\n  // and therefore prevents the emit of the null value if needed\n  registerOnChange$\n    .pipe(\n      switchMap(onChange => emitNullOnDestroy$.pipe(tap(value => onChange(value)))),\n      takeUntil(lifecyleHooks.onDestroy.pipe(delay(0))),\n    )\n    .subscribe();\n\n  return {\n    formGroup,\n    formControlNames,\n    get formGroupErrors() {\n      return getFormGroupErrors<ControlInterface, FormInterface>(formGroup);\n    },\n    createFormArrayControl,\n    controlValue$,\n    get value() {\n      const v = formGroup.value;\n      return options.fromFormGroup\n        ? options.fromFormGroup(v)\n        : // if it's not a remap component, the ControlInterface === the FormInterface\n          ((v as any) as ControlInterface);\n    },\n  };\n}\n\nclass NgxFormBuilder<ControlInterface, FormInterface = ControlInterface> {\n  create<FormControlsType extends ControlsType<FormInterface>>(\n    componentInstance: ControlValueAccessorComponentInstance,\n    options: NgxRootFormOptions<ControlInterface, FormInterface, FormControlsType>,\n  ): NgxRootForm<ControlInterface, FormInterface, FormControlsType>;\n  create<FormControlsType extends ControlsType<FormInterface>>(\n    componentInstance: ControlValueAccessorComponentInstance,\n    options: NgxSubFormOptions<ControlInterface, FormInterface, FormControlsType>,\n  ): NgxSubForm<ControlInterface, FormInterface, FormControlsType>;\n  create<FormControlsType extends ControlsType<FormInterface>>(\n    componentInstance: ControlValueAccessorComponentInstance,\n    options: NgxFormOptions<ControlInterface, FormInterface, FormControlsType>,\n  ): NgxSubForm<ControlInterface, FormInterface, FormControlsType> {\n    return createForm<ControlInterface, FormInterface, FormControlsType>(\n      componentInstance,\n      options as NgxSubFormOptions<ControlInterface, FormInterface, FormControlsType>,\n    );\n  }\n}\n\nexport function formBuilder<ControlInterface, FormInterface = ControlInterface>() {\n  return new NgxFormBuilder<ControlInterface, FormInterface>();\n}\n","/*\n * Public API Surface of sub-form\n */\n\nexport * from './lib/deprecated/ngx-automatic-root-form.component';\nexport * from './lib/deprecated/ngx-root-form.component';\nexport * from './lib/deprecated/ngx-sub-form.component';\nexport * from './lib/deprecated/ngx-sub-form.decorators';\nexport * from './lib/shared/ngx-sub-form-utils';\nexport * from './lib/shared/ngx-sub-form.types';\n\nexport * from './lib/helpers';\nexport * from './lib/ngx-sub-form';\nexport * from './lib/ngx-sub-form.types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["markDirty"],"mappings":";;;;;;;;SAgHgB,yBAAyB,CACvC,SAAc;IAMd,OAAO;QACL;YACE,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,IAAI;SACZ;QACD;YACE,OAAO,EAAE,aAAa;YACtB,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,IAAI;SACZ;KACF,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,GAAW,KAAa,IAAI,GAAG,GAAG,CAAC;MAE3C,wBAA2C,SAAQ,KAAK;IACnE,YAAY,mBAAwB;QAClC,KAAK,CACH,2HAA2H,mBAAmB;aAC3I,GAAG,CAAC,WAAW,CAAC;aAChB,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;KACH;CACF;MAEY,iDAAiD,GAAG;IAC/D,QAAQ,EAAE,CAAO,IAAY,KAAkE,GAAG,IAChG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC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