import { adminPortalAssets } from '../../../../../internal/assets/dist/index.mjs';
import React__default, { useState } from 'react';
import { Instruction } from '../components/Instruction.mjs';
import { InstructionSet } from '../components/InstructionSet.mjs';
import { Switch } from '../components/Switch.mjs';
import { Table } from '../components/Table.mjs';
import { Typography } from '../components/Typography.mjs';
import { Screenshot } from '../shared/components/Screenshot.mjs';
import { useOrgInfo } from '../utils/useOrgInfo.mjs';
import { AttributeMappingTable } from './AttributeMappingTable.mjs';
import { getIdpAndConnectionInfo } from './IdpInfo.mjs';

const createAttributeItems = (attributeMap)=>{
    return Object.entries(attributeMap).map(([key, value])=>({
            key,
            value
        }));
};
const AttributeTable = ({ itemsMap, itemRenderer })=>{
    const items = createAttributeItems(itemsMap);
    return /*#__PURE__*/ React__default.createElement(Table, {
        titleVariant: "caption",
        rowKeyExtractor: ({ key })=>key,
        itemRenderer: itemRenderer,
        items: items
    });
};
const OktaSamlInstructions$1 = ({ isGroupInfoIncluded, handleIncludeGroupInfoChange })=>{
    const { data } = useOrgInfo();
    const organizationName = data?.organization_name ?? '';
    return /*#__PURE__*/ React__default.createElement(InstructionSet, null, /*#__PURE__*/ React__default.createElement(Instruction, null, "Under ", /*#__PURE__*/ React__default.createElement("b", null, "Attribute Statements (optional)"), " add the following attributes to send to ", organizationName, " as part of the SAML Assertion with the ", /*#__PURE__*/ React__default.createElement("b", null, "Basic"), " name format:"), /*#__PURE__*/ React__default.createElement(AttributeTable, {
        itemsMap: {
            firstName: 'user.firstName',
            lastName: 'user.lastName',
            id: 'user.id'
        },
        itemRenderer: [
            {
                title: 'Name',
                getValue: ({ key })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, key)
            },
            {
                title: 'Value',
                getValue: ({ value })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, value)
            }
        ]
    }), /*#__PURE__*/ React__default.createElement(Switch, {
        label: "Include group info in the SAML Assertion.",
        checked: isGroupInfoIncluded,
        onChange: handleIncludeGroupInfoChange
    }), isGroupInfoIncluded && /*#__PURE__*/ React__default.createElement(React__default.Fragment, null, /*#__PURE__*/ React__default.createElement(Instruction, null, "Under ", /*#__PURE__*/ React__default.createElement("b", null, "Group Attribute Statements"), " add a mapping with the ", /*#__PURE__*/ React__default.createElement("b", null, "Basic"), " name format:"), /*#__PURE__*/ React__default.createElement(AttributeTable, {
        itemsMap: {
            groups: 'Matches regex'
        },
        itemRenderer: [
            {
                title: 'Name',
                getValue: ({ key })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, key)
            },
            {
                title: 'Filter',
                getValue: ({ value })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, value)
            },
            {
                title: 'Value',
                getValue: ()=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, ".*")
            }
        ]
    }), /*#__PURE__*/ React__default.createElement(Instruction, null, "Save and continue, selecting ", /*#__PURE__*/ React__default.createElement("b", null, "internal"), " as the ", /*#__PURE__*/ React__default.createElement("b", null, "App Type"), ".")), /*#__PURE__*/ React__default.createElement(Instruction, null, "Your configuration page should look like the following:"), /*#__PURE__*/ React__default.createElement(Screenshot, {
        src: adminPortalAssets.oktaSamlSettingsConfig,
        alt: "Okta SAML settings config"
    }));
};
const EntraSamlInstructions$1 = ()=>/*#__PURE__*/ React__default.createElement(InstructionSet, null, /*#__PURE__*/ React__default.createElement(Instruction, null, "Next select ", /*#__PURE__*/ React__default.createElement("b", null, "Edit"), " on Step 2 of the setup ", /*#__PURE__*/ React__default.createElement("b", null, "Attributes & Claims"), "."), /*#__PURE__*/ React__default.createElement(Instruction, null, "Under ", /*#__PURE__*/ React__default.createElement("b", null, "Required Claims"), " click on ", /*#__PURE__*/ React__default.createElement("b", null, "Unique User Identifier (Name ID)"), " and set the following values and save:"), /*#__PURE__*/ React__default.createElement(AttributeTable, {
        itemsMap: {
            'Email address': 'user.primaryauthoritativeemail'
        },
        itemRenderer: [
            {
                title: 'Name Identifier Format',
                getValue: ({ key })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, key)
            },
            {
                title: 'Source attribute',
                getValue: ({ value })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, value)
            }
        ]
    }), /*#__PURE__*/ React__default.createElement(Screenshot, {
        src: adminPortalAssets.entraEditNameidClaim,
        alt: "Entra Edit NameID Claim"
    }), /*#__PURE__*/ React__default.createElement(Instruction, null, "After saving the Name ID claim, under ", /*#__PURE__*/ React__default.createElement("b", null, "Additional Claims"), " edit the following claims to match the below format:"), /*#__PURE__*/ React__default.createElement(AttributeTable, {
        itemsMap: {
            firstName: 'user.givenname',
            lastName: 'user.surname',
            id: 'user.objectid'
        },
        itemRenderer: [
            {
                title: 'Name',
                getValue: ({ key })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, key)
            },
            {
                title: 'Source Attribute',
                getValue: ({ value })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, value)
            }
        ]
    }), /*#__PURE__*/ React__default.createElement(Screenshot, {
        src: adminPortalAssets.entraAttributesAndClaims,
        alt: "Entra Attributes and Claims"
    }), /*#__PURE__*/ React__default.createElement(Instruction, null, "Click ", /*#__PURE__*/ React__default.createElement("b", null, "Save"), " and close out of the ", /*#__PURE__*/ React__default.createElement("b", null, "Attributes & Claims"), " page."));
const GoogleSamlInstructions = ({ isGroupInfoIncluded, handleIncludeGroupInfoChange })=>{
    return /*#__PURE__*/ React__default.createElement(InstructionSet, null, /*#__PURE__*/ React__default.createElement(Instruction, null, "On the ", /*#__PURE__*/ React__default.createElement("b", null, "Attributes"), " page select ", /*#__PURE__*/ React__default.createElement("b", null, "Add Mapping"), " and select the following fields for the Google Directory attribute mapping to the provided string for the App attribute input:"), /*#__PURE__*/ React__default.createElement(AttributeTable, {
        itemsMap: {
            'First Name': 'firstName',
            'Last Name': 'lastName'
        },
        itemRenderer: [
            {
                title: 'Google Directory attribute: Basic Information',
                getValue: ({ key })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, key)
            },
            {
                title: 'App attributes',
                getValue: ({ value })=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, value)
            }
        ]
    }), /*#__PURE__*/ React__default.createElement(Switch, {
        label: "Include group info in Google Groups.",
        checked: isGroupInfoIncluded,
        onChange: handleIncludeGroupInfoChange
    }), isGroupInfoIncluded && /*#__PURE__*/ React__default.createElement(React__default.Fragment, null, /*#__PURE__*/ React__default.createElement(Instruction, null, "Under Group membership select the groups that you wish to include information about and set the App attribute input to:"), /*#__PURE__*/ React__default.createElement(AttributeTable, {
        itemsMap: {
            groups: 'groups'
        },
        itemRenderer: [
            {
                title: 'App attribute',
                getValue: ()=>/*#__PURE__*/ React__default.createElement(Typography, {
                        variant: "body2"
                    }, "groups")
            }
        ]
    }), /*#__PURE__*/ React__default.createElement(Instruction, null, "Click ", /*#__PURE__*/ React__default.createElement("b", null, "Finish"), ".")), /*#__PURE__*/ React__default.createElement(Instruction, null, "On the app page under ", /*#__PURE__*/ React__default.createElement("b", null, "User Access"), " click on ", /*#__PURE__*/ React__default.createElement("b", null, "OFF for everyone"), " to open the ", /*#__PURE__*/ React__default.createElement("b", null, "Service status"), " to", ' ', /*#__PURE__*/ React__default.createElement("b", null, "ON for everyone"), ", or search for specific Groups on the left hand navigation in order to selectively enable for particular Google Groups."), /*#__PURE__*/ React__default.createElement(Screenshot, {
        src: adminPortalAssets.googleUserAccess,
        alt: "Google User Access"
    }), /*#__PURE__*/ React__default.createElement(Screenshot, {
        src: adminPortalAssets.googleAccessOn,
        alt: "Google Access ON"
    }));
};
const DetailedAttributeMappingTable = ({ connection: connectionProp, localState, setLocalState, remoteState })=>{
    const { connection } = getIdpAndConnectionInfo(connectionProp);
    const [isGroupInfoIncluded, setIsGroupInfoIncluded] = useState(false);
    const handleIncludeGroupInfoChange = (value)=>{
        setIsGroupInfoIncluded(value);
        setLocalState((prevState)=>{
            return {
                ...prevState,
                attributeMapping: {
                    ...prevState.attributeMapping,
                    groups: value ? 'groups' : ''
                }
            };
        });
    };
    const samlMap = {
        okta: /*#__PURE__*/ React__default.createElement(OktaSamlInstructions$1, {
            isGroupInfoIncluded: isGroupInfoIncluded,
            handleIncludeGroupInfoChange: handleIncludeGroupInfoChange
        }),
        'microsoft-entra': /*#__PURE__*/ React__default.createElement(EntraSamlInstructions$1, null),
        'google-workspace': /*#__PURE__*/ React__default.createElement(GoogleSamlInstructions, {
            isGroupInfoIncluded: isGroupInfoIncluded,
            handleIncludeGroupInfoChange: handleIncludeGroupInfoChange
        })
    };
    return connection.identity_provider in samlMap ? samlMap[connection.identity_provider] : /*#__PURE__*/ React__default.createElement(AttributeMappingTable, {
        editing: true,
        localState: localState,
        setLocalState: setLocalState,
        remoteState: remoteState
    });
};

export { DetailedAttributeMappingTable };
//# sourceMappingURL=DetailedAttributeMappingTable.mjs.map
