ESPHome IR Receiver/Sender

My intent is to to create a kind of translator between IR and Home Assistant. Im using an universal remote that sends samsung IR codes, and an amp that needs certain nec codes. My current approach captures each received samsung command and sends an event with the received value to HA. a node-red flow splits this event into multiple events, for each key one event to which i react. With this i can assign many functions to my remote and also control other devices like my xbox. This approach works, but now my wifi AP went bad and thus i cant connect from LAN to my nodes and this means, i cant control my amp, even tho theres technical no need to use the network, since receiver and transmitter are on the same node.
My old code looks like this:

 remote_receiver:
  pin: 
    number: GPIO14
    inverted: true
  dump: all
  on_samsung:
    then:

    - homeassistant.event:
        event: esphome.Remote
        data_template: 
          value: !lambda "return x.data;"

Like i said, this works. Now i wanted to add the if-condition, what code was received and then send other codes based on that. That new code looks like this:

remote_receiver:
  pin: 
    number: GPIO14
    inverted: true
  dump: all
  on_samsung:
    then:

    - homeassistant.event:
        event: esphome.Remote
        data_template: 
          value: !lambda "return x.data;"
    - if:
       x = 3772833823
        - then:
          - remote_transmitter.transmit_nec:
              address: 0x1D00
              command: 0xD926
    - if:
        x = 3772829743
        then: 
          remote_transmitter.transmit_nec:
            address: 0x1D00
            command: 0x59A6

Now the Problem is, that this throws me this: (line 62 is the then: line of the if-condition)

mapping values are not allowed here
  in "/config/esphome/testamo.yaml", line 62, column 15:
            - then:
                  ^

Any ideas, whats wrong?

Try this

    - if:
        condition:
          lambda: 'return x == 3772833823;'
        then:
          - remote_transmitter.transmit_nec:
              address: 0x1D00
              command: 0xD926