#!/usr/bin/env python3
import sys
from drive import run,still,ROOT
from urllib.parse import urlencode
import uuid
side=sys.argv[1]
name=f'R01-{side}-light'
run(['record','start',str(ROOT/f'{name}.mp4'),'--scope','device','--fps','30','--quality','high','--hide-touches'])
env={'before':'582cd8fe-ca86-4bcd-a434-c9086ed4485c','after':'338fe878-93b9-4fae-a23f-51d740db9fae'}[side]
run(['open','com.t3tools.t3code.dev','t3code-dev://new/draft?'+urlencode({'environmentId':env,'projectId':'11111111-1111-4111-8111-111111111111','branch':'proof-seed','requestId':str(uuid.uuid4())}),'--no-test-ime'])
run(['wait','text','Ask anything','15000'])
run(['fill','role="text-field"','P1-RESUME','--settle'])
run(['back','--settle'])
for i in (1,2):
 run(['press','label="Navigate up"','--settle'])
 run(['press','label="New thread"','--settle'])
 state=run(['snapshot','-i'])
 if 'Search projects' in state:run(['press','text="Proof P1"','--settle'])
 run(['wait','text','P1-RESUME' if side=='after' else 'Ask anything','15000'])
 still(name if i==1 else name+'-repeat')
run(['press','label="Navigate up"','--settle'])
run(['snapshot','-i'])
run(['record','stop'])
