BaseScreen As screen:
    Fill: =RGBA(0, 52, 128, 1)
    ImagePosition: =ImagePosition.Fill

    ConBan As groupContainer.manualLayoutContainer:
        BorderStyle: =BorderStyle.None
        DropShadow: =DropShadow.None
        Height: =Parent.Height/13
        Width: =Parent.Width
        ZIndex: =1

        Banlabel1 As label:
            Align: =Align.Center
            AutoHeight: =true
            BorderColor: =RGBA(0, 0, 0, 0)
            BorderStyle: =BorderStyle.None
            BorderThickness: =2
            Color: =RGBA(255, 255, 255, 1)
            DisabledBorderColor: =RGBA(0, 0, 0, 0)
            DisabledColor: =RGBA(255, 255, 255, 1)
            Fill: =RGBA(0, 52, 128, 1)
            FocusedBorderThickness: =2
            Font: =Font.'Segoe UI'
            Height: =ConBan.Height
            Italic: =true
            Size: =ConBan.Height/3.6
            Text: |-
                ="Ask
                ChatGPT"
            Width: =ConBan.Height*1.6
            X: |-
                =//ConBan.Width - (ConBan.Width - ConBan.Width/25)
                ConBan.Width - ConBan.Width/25 - Banlabel1.Width
            Y: =ConBan.Y
            ZIndex: =1

        Logo As image:
            AccessibleLabel: ="ARD Logo"
            Fill: =RGBA(0, 52, 128, 1)
            Height: =ConBan.Height - (ConBan.Height/6)
            Image: ='ard-logo'
            Width: =ConBan.Width/3.5
            X: =ConBan.Width/3
            Y: =ConBan.Y + (ConBan.Height/7)
            ZIndex: =2

        behave1 As dropdown:
            Default: ="Ich bin ein hilfsbereiter Assistent"
            Height: =ConBan.Height/1.6
            Items: |
                =Table(
                    { Text: "Norm", Val: "You are a helpful assistent" }, 
                    { Text: "Kid", Val: "You answer in kid language and no longer than 3 sentences" }, 
                    { Text: "Pirat", Val: "Antworte wie ein Pirat in maximal 3 Sätzen" }
                )
            Size: =21
            Width: =ConBan.Height*1.6
            X: =ConBan.Width - (ConBan.Width - ConBan.Width/25)
            Y: =ConBan.Y + (ConBan.Height/4)
            ZIndex: =3

    ConFkt1 As groupContainer.manualLayoutContainer:
        BorderStyle: =BorderStyle.None
        DropShadow: =DropShadow.None
        Height: =Parent.Height/11
        Width: =Parent.Width
        Y: =ConResp.Y + ConResp.Height
        ZIndex: =2

        Creativity1 As toggleSwitch:
            AccessibleLabel: ="Kreativitätsmodus aktivieren oder deaktivieren"
            BorderColor: =RGBA(0, 52, 128, 1)
            Color: =RGBA(255, 255, 255, 1)
            DisabledBorderColor: =RGBA(0, 52, 128, 1)
            FalseFill: =RGBA(255, 255, 255, 1)
            FalseHoverFill: =RGBA(251, 188, 159, 1)
            FalseText: ="false"
            Font: =Font.'Segoe UI'
            HandleFill: =RGBA(128, 128, 128, 1)
            Height: =ConFkt1.Height/2
            HoverBorderColor: =RGBA(0, 52, 128, 1)
            LabelPaddingLeft: =7
            OnChange: =true
            OnCheck: =false   
            PressedBorderColor: =RGBA(0, 52, 128, 1)
            Size: =18
            Tooltip: ="Creativity Mode"
            TrueFill: =RGBA(251, 188, 159, 1)
            TrueHoverFill: =RGBA(251, 188, 159, 1)
            TrueText: ="true"
            Width: |-
                =If(ConFkt1.Height<=ConFkt1.Width/6, ConFkt1.Height, 
                ConFkt1.Height > ConFkt1.Width/6, ConFkt1.Width/6)
            X: =ConFkt1.Width - (ConFkt1.Width - ConFkt1.Width/25)
            Y: =ConFkt1.Height - (ConFkt1.Height - ConFkt1.Height/4)
            ZIndex: =1

        Fktlabel1 As label:
            Align: =Align.Center
            AutoHeight: =true
            BorderColor: =RGBA(0, 0, 0, 0)
            BorderStyle: =BorderStyle.None
            BorderThickness: =2
            Color: =RGBA(255, 255, 255, 1)
            DisabledBorderColor: =RGBA(0, 0, 0, 0)
            DisabledColor: =RGBA(161, 159, 157, 1)
            Fill: =RGBA(0, 52, 128, 1)
            FocusedBorderThickness: =2
            Font: =Font.'Segoe UI'
            Height: =Creativity1.Height
            Size: =Creativity1.Height/2
            Text: ="Creativity" & Char(10) & "Mode"
            Tooltip: ="Creativity Mode"
            Width: |-
                =If(ConFkt1.Height<=ConFkt1.Width/6, ConFkt1.Height*1.7, 
                ConFkt1.Height > ConFkt1.Width/6, ConFkt1.Width/3)
            X: =(ConFkt1.Width - (ConFkt1.Width - ConFkt1.Width/25)) + Creativity1.Width
            Y: =Creativity1.Y + (Creativity1.Height - Fktlabel1.Height)/2	
            ZIndex: =2

        Eraser1 As icon.Erase:
            AccessibleLabel: ="Lösche deine Konversation mit dem Assistenten"
            BorderColor: =RGBA(0, 0, 0, 0)
            Color: =RGBA(255, 255, 255, 1)
            DisabledBorderColor: =RGBA(245, 245, 245, 1)
            DisabledColor: =RGBA(204, 204, 204, 1)
            DisabledFill: =RGBA(0, 0, 0, 0)
            Fill: =RGBA(0, 52, 128, 1)
            Height: =Creativity1.Height*1.6
            HoverBorderColor: =RGBA(0, 0, 0, 0)
            HoverColor: =RGBA(251, 188, 159, 1)
            HoverFill: =RGBA(0, 0, 0, 0)
            Icon: =Icon.Erase
            OnSelect: =Set(varResp, Blank());
            PressedBorderColor: =RGBA(0, 0, 0, 0)
            PressedColor: =RGBA(251, 188, 159, 1)
            PressedFill: =RGBA(0, 0, 0, 0)
            TabIndex: =0
            Tooltip: ="3"
            Width: |-
                =If(ConFkt1.Height<=ConFkt1.Width/6, ConFkt1.Height, 
                ConFkt1.Height > ConFkt1.Width/6, ConFkt1.Width/6)
            X: =ConFkt1.Width - ConFkt1.Width/25 - Eraser1.Width
            Y: =Creativity1.Y + (Creativity1.Height - Eraser1.Height)/2	
            ZIndex: =3

        SendMail1 As icon.Mail:
            AccessibleLabel: ="Sende deine Konversation mit dem Assistenten an deinen E-mail Account"
            BorderColor: =RGBA(0, 0, 0, 0)
            Color: =RGBA(255, 255, 255, 1)
            DisabledBorderColor: =RGBA(245, 245, 245, 1)
            DisabledColor: =RGBA(204, 204, 204, 1)
            DisabledFill: =RGBA(0, 0, 0, 0)
            Fill: =RGBA(0, 52, 128, 1)
            Height: =Creativity1.Height*1.6
            HoverBorderColor: =RGBA(0, 0, 0, 0)
            HoverColor: =RGBA(251, 188, 159, 1)
            HoverFill: =RGBA(0, 0, 0, 0)
            Icon: =Icon.Mail
            OnSelect: |-
                =Set(varRespMail, Substitute(Substitute(chatbox1.Text,Char(10),"<br>"),"GPT: ", "<b>GPT: </b>"));
                Office365Outlook.SendEmailV2(User().Email,"# Assistentenchat #", varRespMail);
                //Office365Outlook.SendEmailV2("manuel.geyer@rbb-online.de","#RBB - TK-Formular-mob-TK" & " " & TextInput_Betreff.Text,TextInput_Nachricht.Text & "<br><br>" & "RBB - PowerPlatform")
            PressedBorderColor: =RGBA(0, 0, 0, 0)
            PressedColor: =RGBA(251, 188, 159, 1)
            PressedFill: =RGBA(0, 0, 0, 0)
            Rotation: =20
            TabIndex: =0
            Tooltip: ="6"
            Width: |-
                =If(ConFkt1.Height<=ConFkt1.Width/6, ConFkt1.Height, 
                ConFkt1.Height > ConFkt1.Width/6, ConFkt1.Width/6)
            X: =(ConFkt1.Width - (ConFkt1.Width - ConFkt1.Width/25)) + Creativity1.Width + Fktlabel1.Width + ConFkt1.Width/40
            Y: =Creativity1.Y + (Creativity1.Height - SendMail1.Height)/2	
            ZIndex: =4

    ConResp As groupContainer.manualLayoutContainer:
        BorderStyle: =BorderStyle.None
        DropShadow: =DropShadow.None
        Height: =Parent.Height/1.6
        Width: =Parent.Width
        Y: =ConBan.Y + ConBan.Height
        ZIndex: =3

        chatboxhtml As htmlViewer:
            Height: =ConResp.Height - 2* (ConResp.Height/50)
            HtmlText: =varResp
            Width: =ConResp.Width - 2*(ConResp.Width/25)
            X: =ConResp.Width - (ConResp.Width - ConResp.Width/25)
            Y: =ConResp.Height - (ConResp.Height - ConResp.Height/50)
            ZIndex: =1

        chatbox1 As text:
            AccessibleLabel: ="Deine Konversation mit dem Assistenten"
            BorderColor: =RGBA(224, 24, 24, 1)
            BorderThickness: =0
            Default: =varResp
            DisabledBorderColor: =RGBA(255, 255, 255, 1)
            DisabledColor: =RGBA(161, 159, 157, 1)
            DisabledFill: =RGBA(242, 242, 241, 0)
            DisplayMode: =DisplayMode.View
            Fill: =RGBA(236, 236, 235, 1)
            Font: =Font.'Segoe UI'
            Height: =ConResp.Height - 2* (ConResp.Height/50)
            HoverBorderColor: =RGBA(255, 255, 255, 1)
            HoverFill: =RGBA(255, 255, 255, 1)
            MaxLength: =3000
            Mode: =TextMode.MultiLine
            OnChange: =//chatbox1.ScrollToEnd();
            OnSelect: =
            PressedBorderColor: =RGBA(255, 255, 255, 1)
            PressedColor: =RGBA(50, 49, 48, 1)
            PressedFill: =RGBA(255, 255, 255, 1)
            RadiusBottomLeft: =10
            RadiusBottomRight: =10
            RadiusTopLeft: =10
            RadiusTopRight: =10
            Reset: =
            Size: =28
            Tooltip: ="7"
            Width: =ConResp.Width - 2*(ConResp.Width/25)
            X: =ConResp.Width - (ConResp.Width - ConResp.Width/25)
            Y: =ConResp.Height - (ConResp.Height - ConResp.Height/50)
            ZIndex: =2

    ConSend As groupContainer.manualLayoutContainer:
        BorderStyle: =BorderStyle.None
        DropShadow: =DropShadow.None
        Height: =Parent.Height - ConSend.Y
        Width: =Parent.Width
        Y: =ConFkt1.Y + ConFkt1.Height
        ZIndex: =4

        textinput1 As text:
            AccessibleLabel: ="Hier kannst du deine Frage schreiben"
            BorderColor: =RGBA(224, 24, 24, 1)
            BorderThickness: =0
            Default: =""
            DisabledBorderColor: =RGBA(255, 255, 255, 1)
            DisabledColor: =RGBA(161, 159, 157, 1)
            DisabledFill: =RGBA(242, 242, 241, 0)
            EnableSpellCheck: =true
            Font: =Font.'Segoe UI'
            Height: =ConSend.Height - 2* (ConSend.Height/10)
            HoverBorderColor: =RGBA(255, 255, 255, 1)
            HoverFill: =RGBA(255, 255, 255, 1)
            MaxLength: =188
            Mode: =TextMode.MultiLine
            OnChange: =
            OnSelect: =
            PressedBorderColor: =RGBA(255, 255, 255, 1)
            PressedColor: =RGBA(50, 49, 48, 1)
            PressedFill: =RGBA(255, 255, 255, 1)
            RadiusBottomLeft: =10
            RadiusBottomRight: =10
            RadiusTopLeft: =10
            RadiusTopRight: =10
            Reset: =
            Size: =24
            Tooltip: ="1"
            Width: |+
                =ConSend.Width - ((ConSend.Width/25)*2.5) - send1.Width
                
            X: =ConSend.Width - (ConSend.Width - ConSend.Width/25)
            Y: =ConSend.Height - (ConSend.Height - ConSend.Height/15)
            ZIndex: =1

        send1 As icon.Send:
            AccessibleLabel: ="Sende deine Frage"
            AutoDisableOnSelect: =
            BorderColor: =RGBA(0, 0, 0, 0)
            Color: =RGBA(255, 255, 255, 1)
            DisabledBorderColor: =RGBA(245, 245, 245, 1)
            DisabledColor: =RGBA(225, 223, 221, 1)
            DisabledFill: =RGBA(0, 0, 0, 0)
            Fill: =RGBA(0, 52, 128, 1)
            Height: =Creativity1.Height*1.3
            HoverBorderColor: =RGBA(0, 0, 0, 0)
            HoverColor: =RGBA(251, 188, 159, 1)
            HoverFill: =RGBA(0, 0, 0, 0)
            Icon: =Icon.Send
            OnSelect: |
                =If(
                    Creativity1.Value = false,
                    Set(Creativity,0.3),
                    Set(Creativity,0.9)
                );
                
                If(
                    !IsBlank(textinput1.Text),
                        textinput1.Text;          // you
                        behave1.SelectedText.'data-ADB4D7A662F548B49FAC2B986E348A1BVal'; // sys
                        Set(assiresp, "bbb"); // Assi
                );
                //ConnectAzureOpenai.Run(textinput1.Text, Creativity, behave1.SelectedText.Val)
                Set(varRes, varResp & Char(10) & "You: " & Char(10) & textinput1.Text & Char(10) & Char(10) & "Assistent: " & Char(10) & assiresp & Char(10));
                /*Set(
                    varResp,
                    varResp & Char(10) & "You: " & Char(10) & textinput1.Text & Char(10) & Char(10) & "Assistent: " & Char(10) & "x" & Char(10)
                );
                
                /*
                If(
                    !IsBlank(textinput1.Text),
                    Set(
                        varResp,
                        varResp & Char(10) & "You: " & Char(10) & textinput1.Text & Char(10) & Char(10) & "Assistent: " & Char(10) & ConnectAzureOpenai.Run(
                            textinput1.Text,
                            Creativity, 
                            behave1.SelectedText.Val
                        ).assi & Char(10)
                    )
                );*/
                Reset(textinput1);
                Notify(
                    "ChatGPT asked",
                    NotificationType.Success,
                    1000
                );
            PressedBorderColor: =RGBA(0, 0, 0, 0)
            PressedColor: =RGBA(251, 188, 159, 1)
            PressedFill: =RGBA(0, 0, 0, 0)
            TabIndex: =0
            Tooltip: ="2"
            Width: |-
                =If(ConSend.Height<=ConSend.Width/6, ConSend.Height, 
                ConSend.Height > ConSend.Width/6, ConSend.Width/8)
            X: =ConSend.Width - ConSend.Width/25 - send1.Width
            Y: =textinput1.Y + (textinput1.Height - send1.Height)/2	
            ZIndex: =2

