Stax, 3030 29 bytes
é║¡▒§▓,≤x6iúaj⌂¶:,♦-uDáïÖ▀i∙☻6£└≤☻╘pÿ╖╡A[ô%æτ⌐}►ºôßHl4⌡π%^
Run and debug itRun and debug it
ASCII equivalent:
139$VA+cz{;3%+,^3/~;wY2|I@'|+sy1|I@+
Uses the unpacked version to explain.
139$VA+cz{;3%+,^3/~;wY2|I@'|+sy1|I@+~;wY1|I@'|ay2|I@L
139$VA+c "139AB...Z", make a copy
z Empty array to store the digits
{ w Do the following until 0.
;3%+ Append `a%3``b%3` to the digits
Originally, `a``b` is the input
,^3/ `a=`b=(a+1b+1)/3`
~; Make a copy of `a``b` which is used as the condition for the loop
Y Save array of digits in `y` for later use
2|I 1|I Find index of 2's1's
@ Find the characters in "139AB...Z" corresponding to those indices
'|+ '| Append aA bar
sy1|I@ay2|I@ Do the same for 1's2's
+L AppendJoin the string corresponding to indices of 1's
two strings and the bar and Implicitimplicit output