{"version":3,"file":"keycloakify-angular-login-components-input-field-by-type.mjs","names":[],"sources":["../../src/login/components/input-field-by-type/input-field-by-type.component.ts","../../src/login/components/input-field-by-type/input-field-by-type.component.html"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, forwardRef, inject, input, output } from '@angular/core';\nimport { ToArrayPipe } from '@keycloakify/angular/lib/pipes/to-array';\nimport { USE_DEFAULT_CSS } from '@keycloakify/angular/lib/tokens/use-default-css';\nimport { ComponentReference } from '@keycloakify/angular/login/classes/component-reference';\nimport { InputTagComponent } from '@keycloakify/angular/login/components/input-tag';\nimport { InputTagSelectsComponent } from '@keycloakify/angular/login/components/input-tag-selects';\nimport { PasswordWrapperComponent } from '@keycloakify/angular/login/components/password-wrapper';\nimport { SelectTagComponent } from '@keycloakify/angular/login/components/select-tag';\nimport { TextareaTagComponent } from '@keycloakify/angular/login/components/textarea-tag';\nimport { type FormAction, type FormFieldError } from '@keycloakify/angular/login/services/user-profile-form';\nimport { LOGIN_CLASSES } from '@keycloakify/angular/login/tokens/classes';\nimport type { Attribute } from 'keycloakify/login/KcContext';\nimport type { ClassKey } from 'keycloakify/login/lib/kcClsx';\n\n@Component({\n    styles: [\n        `\n            :host {\n                display: contents;\n            }\n        `\n    ],\n    imports: [ToArrayPipe, TextareaTagComponent, SelectTagComponent, InputTagSelectsComponent, InputTagComponent, PasswordWrapperComponent],\n    selector: 'kc-input-field-by-type',\n    templateUrl: 'input-field-by-type.component.html',\n    changeDetection: ChangeDetectionStrategy.OnPush,\n    providers: [\n        {\n            provide: ComponentReference,\n            useExisting: forwardRef(() => InputFieldByTypeComponent)\n        }\n    ]\n})\nexport class InputFieldByTypeComponent extends ComponentReference {\n    attribute = input<Attribute>();\n    valueOrValues = input<string | string[]>();\n    displayableErrors = input<FormFieldError[]>();\n    dispatchFormAction = output<FormAction>();\n    override doUseDefaultCss = inject<boolean>(USE_DEFAULT_CSS);\n    override classes = inject<Partial<Record<ClassKey, string>>>(LOGIN_CLASSES);\n\n    attributePassword = computed<Attribute>(() => {\n        const attribute: Attribute = this.attribute() ?? ({} as Attribute);\n        return {\n            ...attribute,\n            annotations: { ...(attribute.annotations ?? {}), inputType: 'password' }\n        };\n    });\n}\n","@let attr = attribute();\n@if (attr) {\n    @let type = attr.annotations.inputType;\n    @switch (type) {\n        @case ('hidden') {\n            <input\n                type=\"hidden\"\n                [name]=\"attr.name\"\n                [value]=\"$any(valueOrValues())\"\n            />\n        }\n        @case ('textarea') {\n            <kc-textarea-tag\n                [attribute]=\"attribute()\"\n                [value]=\"$any(valueOrValues())\"\n                [displayableErrors]=\"displayableErrors()\"\n                (dispatchFormAction)=\"dispatchFormAction.emit($event)\"\n            />\n        }\n        @case (type === 'select' || type === 'multiselect' ? type : '') {\n            <kc-select-tag\n                [attribute]=\"attribute()\"\n                [valueOrValues]=\"valueOrValues()\"\n                [displayableErrors]=\"displayableErrors()\"\n                (dispatchFormAction)=\"dispatchFormAction.emit($event)\"\n            />\n        }\n        @case (type === 'select-radiobuttons' || type === 'multiselect-checkboxes' ? type : '') {\n            <kc-input-tag-selects\n                [attribute]=\"attribute()\"\n                [valueOrValues]=\"valueOrValues()\"\n                [displayableErrors]=\"displayableErrors()\"\n                (dispatchFormAction)=\"dispatchFormAction.emit($event)\"\n            />\n        }\n        @default {\n            @let values = valueOrValues();\n            <!-- if valueOrValues is string skip -->\n            @if (values && (values | toArray: true).length) {\n                @for (value of values; track value; let i = $index) {\n                    <kc-input-tag\n                        [attribute]=\"attribute()\"\n                        [valueOrValues]=\"valueOrValues()\"\n                        [fieldIndex]=\"i\"\n                        [displayableErrors]=\"displayableErrors()\"\n                        (dispatchFormAction)=\"dispatchFormAction.emit($event)\"\n                    />\n                }\n            } @else {\n                @if (attr.name === 'password' || attr.name === 'password-confirm') {\n                    <kc-password-wrapper [passwordInputId]=\"attr.name\">\n                        <kc-input-tag\n                            [attribute]=\"attributePassword()\"\n                            [valueOrValues]=\"valueOrValues()\"\n                            [displayableErrors]=\"displayableErrors()\"\n                            (dispatchFormAction)=\"dispatchFormAction.emit($event)\"\n                        />\n                    </kc-password-wrapper>\n                } @else {\n                    <kc-input-tag\n                        [attribute]=\"attribute()\"\n                        [valueOrValues]=\"valueOrValues()\"\n                        [displayableErrors]=\"displayableErrors()\"\n                        (dispatchFormAction)=\"dispatchFormAction.emit($event)\"\n                    />\n                }\n            }\n        }\n    }\n}\n"],"mappings":";;;;;;;;;;;;AAiCA,IAAa,4BAAb,MAAa,kCAAkC,mBAAkB;CAnBjE,cAAA;;EAoBI,KAAA,YAAY,MAAkB,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;EAC9B,KAAA,gBAAgB,MAA0B,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,gBAAA,CAAA,+BAAA,CAAA,CAAA;EAC1C,KAAA,oBAAoB,MAAyB,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,oBAAA,CAAA,+BAAA,CAAA,CAAA;EAC7C,KAAA,qBAAqB,OAAM;EAClB,KAAA,kBAAkB,OAAgB,eAAe;EACjD,KAAA,UAAU,OAA0C,aAAa;EAE1E,KAAA,oBAAoB,eAAyB;GACzC,MAAM,YAAuB,KAAK,UAAS,KAAO,CAAA;GAClD,OAAO;IACH,GAAG;IACH,aAAa;KAAE,GAAI,UAAU,eAAe,CAAA;KAAK,WAAW;IAAU;GACzE;EACL,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,oBAAA,CAAA,+BAAA,CAAA,CAAA;CACL;CAfY;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAyB,MAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAzB;EAAA,KAAA,OAAA,GAAA,qBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,MAAA;GAAyB,cAAA;GAAA,UAAA;GAAA,QAAA;IAAA,WAAA;KAAA,mBAAA;KAAA,YAAA;KA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