{"version":3,"file":"ngx-sub-form.mjs","sources":["../../../projects/ngx-sub-form/src/lib/shared/ngx-sub-form-utils.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/create-form.ts","../../../projects/ngx-sub-form/src/public_api.ts","../../../projects/ngx-sub-form/src/ngx-sub-form.ts"],"sourcesContent":["import { InjectionToken, Type } from '@angular/core';\nimport {\n  AbstractControl,\n  ControlValueAccessor,\n  NG_VALIDATORS,\n  NG_VALUE_ACCESSOR,\n  UntypedFormArray,\n  UntypedFormControl,\n  UntypedFormGroup,\n  ValidationErrors,\n} from '@angular/forms';\nimport { getObservableLifecycle } from 'ngx-observable-lifecycle';\nimport { Observable, timer } from 'rxjs';\nimport { debounce, takeUntil } from 'rxjs/operators';\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 ControlsType<T> = {\n  [K in keyof T]-?: T[K] extends any[]\n    ? TypedFormArray<T[K]>\n    : TypedFormControl<T[K]> | (T[K] extends {} ? TypedFormGroup<T[K]> : never);\n};\n\nexport type OneOfControlsTypes<T = any> = ControlsType<T>[keyof ControlsType<T>];\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 extends {}> extends UntypedFormGroup {\n  value: TValue;\n  valueChanges: Observable<TValue>;\n  controls: ControlsType<TValue>;\n  setValue(value: TValue, options?: Parameters<UntypedFormGroup['setValue']>[1]): void;\n  patchValue(value: Partial<TValue>, options?: Parameters<UntypedFormGroup['patchValue']>[1]): void;\n  getRawValue(): TValue;\n}\n\nexport interface TypedFormArray<TValue extends any[]> extends UntypedFormArray {\n  value: TValue;\n  valueChanges: Observable<TValue>;\n  controls: TypedAbstractControl<TValue[0]>[];\n  setValue(value: TValue, options?: Parameters<UntypedFormArray['setValue']>[1]): void;\n  patchValue(value: TValue, options?: Parameters<UntypedFormArray['patchValue']>[1]): void;\n  getRawValue(): TValue;\n}\n\nexport interface TypedFormControl<TValue> extends UntypedFormControl {\n  value: TValue;\n  valueChanges: Observable<TValue>;\n  setValue(value: TValue, options?: Parameters<UntypedFormControl['setValue']>[1]): void;\n  patchValue(value: Partial<TValue>, options?: Parameters<UntypedFormControl['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(component: any): {\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:\n    <T>(time: number) =>\n    (obs: Observable<T>): Observable<T> =>\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","import {\n  AbstractControlOptions,\n  ControlValueAccessor,\n  UntypedFormArray,\n  UntypedFormGroup,\n  ValidationErrors,\n} from '@angular/forms';\nimport { cloneDeep } from 'lodash-es';\nimport { ReplaySubject } from 'rxjs';\nimport { Nilable } from 'tsdef';\nimport {\n  ControlValueAccessorComponentInstance,\n  FormBindings,\n  NgxSubFormArrayOptions,\n  NgxSubFormOptions,\n} from './ngx-sub-form.types';\nimport {\n  ArrayPropertyKey,\n  Controls,\n  ControlsNames,\n  NewFormErrors,\n  OneOfControlsTypes,\n  TypedFormGroup,\n} from './shared/ngx-sub-form-utils';\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 extends {}>(\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 UntypedFormArray) {\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: UntypedFormArray;\n}\n\nexport function createFormDataFromOptions<ControlInterface, FormInterface extends {}>(\n  options: NgxSubFormOptions<ControlInterface, FormInterface>,\n) {\n  const formGroup: TypedFormGroup<FormInterface> = new UntypedFormGroup(\n    options.formControls,\n    options.formGroupOptions as AbstractControlOptions,\n  ) as TypedFormGroup<FormInterface>;\n  const defaultValues: FormInterface = cloneDeep(formGroup.value);\n  const formGroupKeys: (keyof Controls<FormInterface>)[] = Object.keys(\n    options.formControls,\n  ) as (keyof Controls<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 UntypedFormArray) {\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      const newControl = createFormArrayControl(key as ArrayPropertyKey<FormInterface>, value[i]);\n      if (control.disabled) {\n        newControl.disable();\n      }\n      control.insert(i, newControl);\n    }\n  });\n};\n","import { ControlValueAccessor, UntypedFormControl, Validator } from '@angular/forms';\nimport { Observable, Subject } from 'rxjs';\nimport { Nilable } from 'tsdef';\nimport {\n  ArrayPropertyKey,\n  ArrayPropertyValue,\n  Controls,\n  ControlsNames,\n  NewFormErrors,\n  TypedFormGroup,\n} from './shared/ngx-sub-form-utils';\nimport { FormGroupOptions } 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<ControlInterface, FormInterface extends {}> {\n  readonly formGroup: TypedFormGroup<FormInterface>;\n  readonly formControlNames: ControlsNames<FormInterface>;\n  readonly formGroupErrors: NewFormErrors<FormInterface>;\n  readonly createFormArrayControl: CreateFormArrayControlMethod<FormInterface>;\n  readonly controlValue$: Observable<Nilable<ControlInterface>>;\n}\n\nexport type CreateFormArrayControlMethod<FormInterface> = <K extends ArrayPropertyKey<FormInterface>>(\n  key: K,\n  initialValue: ArrayPropertyValue<FormInterface, K>,\n) => UntypedFormControl;\n\nexport interface NgxRootForm<ControlInterface, FormInterface extends {}>\n  extends NgxSubForm<ControlInterface, FormInterface> {\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 NgxSubFormOptions<\n  ControlInterface,\n  FormInterface extends {} = ControlInterface extends {} ? ControlInterface : never,\n> = {\n  formType: FormType;\n  formControls: Controls<FormInterface>;\n  formGroupOptions?: FormGroupOptions<FormInterface>;\n  emitNullOnDestroy?: boolean;\n  emitInitialValueOnInit?: 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 NgxRootFormOptions<\n  ControlInterface,\n  FormInterface extends {} = ControlInterface extends {} ? ControlInterface : never,\n> = NgxSubFormOptions<ControlInterface, FormInterface> & {\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<ControlInterface, FormInterface extends {}> =\n  | NgxSubFormOptions<ControlInterface, FormInterface>\n  | NgxRootFormOptions<ControlInterface, FormInterface>;\n","import { ChangeDetectorRef, inject } from '@angular/core';\nimport { UntypedFormControl } 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 { isNullOrUndefined } from './shared/ngx-sub-form-utils';\n\nconst optionsHaveInstructionsToCreateArrays = <ControlInterface, FormInterface extends {}>(\n  options: NgxFormOptions<ControlInterface, FormInterface> & Partial<NgxSubFormArrayOptions<FormInterface>>,\n): options is NgxSubFormOptions<ControlInterface, FormInterface> & NgxSubFormArrayOptions<FormInterface> =>\n  !!options.createFormArrayControl;\n\n// @todo find a better name\nconst isRoot = <ControlInterface, FormInterface extends {}>(\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 extends {} = ControlInterface extends {} ? ControlInterface : never,\n>(\n  componentInstance: ControlValueAccessorComponentInstance,\n  options: NgxRootFormOptions<ControlInterface, FormInterface>,\n): NgxRootForm<ControlInterface, FormInterface>;\nexport function createForm<\n  ControlInterface,\n  FormInterface extends {} = ControlInterface extends {} ? ControlInterface : never,\n>(\n  componentInstance: ControlValueAccessorComponentInstance,\n  options: NgxSubFormOptions<ControlInterface, FormInterface>,\n): NgxSubForm<ControlInterface, FormInterface>;\nexport function createForm<ControlInterface, FormInterface extends {}>(\n  componentInstance: ControlValueAccessorComponentInstance,\n  options: NgxFormOptions<ControlInterface, FormInterface>,\n): NgxSubForm<ControlInterface, FormInterface> {\n  const { formGroup, defaultValues, formControlNames, formArrays } = createFormDataFromOptions<\n    ControlInterface,\n    FormInterface\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  const changeDetectorRef = inject(ChangeDetectorRef);\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 broadcastDefaultValueToParent$: Observable<ControlInterface> = !options.emitInitialValueOnInit\n    ? EMPTY\n    : transformedValue$.pipe(\n        take(1),\n        switchMap(transformedValue => {\n          const transformedValueDelayed$ = of(transformedValue).pipe(\n            delay(0),\n            filter(() => formGroup.valid),\n          );\n\n          if (!isRoot<ControlInterface, FormInterface>(options)) {\n            return transformedValueDelayed$;\n          }\n\n          return of(transformedValue).pipe(\n            filter(formValue =>\n              !options.outputFilterPredicate ? true : options.outputFilterPredicate(transformedValue, formValue),\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  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>(options) && options.createFormArrayControl\n      ? options.createFormArrayControl\n      : (key, initialValue) => new UntypedFormControl(initialValue);\n\n  const sideEffects = {\n    broadcastValueToParent$: registerOnChange$.pipe(\n      switchMap(onChange => broadcastValueToParent$.pipe(tap(value => onChange(value)))),\n    ),\n    broadcastDefaultValueToParent$: registerOnChange$.pipe(\n      switchMap(onChange => broadcastDefaultValueToParent$.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          changeDetectorRef.markForCheck();\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  };\n}\n","/*\n * Public API Surface of sub-form\n */\n\nexport * from './lib/shared/ngx-sub-form-utils';\nexport * from './lib/shared/ngx-sub-form.types';\n\nexport * from './lib/helpers';\nexport * from './lib/create-form';\nexport * from './lib/ngx-sub-form.types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;AAkFM,SAAU,yBAAyB,CAAC,SAAc,EAAA;IAKtD,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,iBAAiB;AAC1B,YAAA,WAAW,EAAE,SAAS;AACtB,YAAA,KAAK,EAAE,IAAI;AACZ,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAE,aAAa;AACtB,YAAA,WAAW,EAAE,SAAS;AACtB,YAAA,KAAK,EAAE,IAAI;AACZ,SAAA;KACF;AACH;AAEA,MAAM,WAAW,GAAG,CAAC,GAAW,KAAa,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA,CAAG;AAEjD,MAAO,wBAA2C,SAAQ,KAAK,CAAA;AACnE,IAAA,WAAA,CAAY,mBAAwB,EAAA;QAClC,KAAK,CACH,2HAA2H;aACxH,GAAG,CAAC,WAAW;AACf,aAAA,IAAI,CAAC,CAAA,EAAA,CAAI,CAAC,CAAA,CAAE,CAChB;;AAEJ;AAEY,MAAA,iDAAiD,GAAG;IAC/D,QAAQ,EACN,CAAI,IAAY,KAChB,CAAC,GAAkB,KACjB,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;AAG3C;;;AAGG;AACG,SAAU,kBAAkB,CAAI,SAAc,EAAA;IAClD,MAAM,EAAE,WAAW,EAAE,GAAG,sBAAsB,CAAC,SAAS,CAAC;AACzD,IAAA,OAAO,CAAC,MAAqB,KAAoB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;AACtF;AAEA;AACM,SAAU,iBAAiB,CAAC,GA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