Unicode rectangles

Given

• a matrix a of characters from u=" ╶╺╵└┕╹┖┗╴─╼┘┴┶┚┸┺╸╾━┙┵┷┛┹┻╷┌┍│├┝╿┞┡┐┬┮┤┼┾┦╀╄┑┭┯┥┽┿┩╃╇╻┎┏╽┟┢┃┠┣┒┰┲┧╁╆┨╂╊┓┱┳┪╅╈┫╉╋"
• the coordinates of a submatrix as x,y,w,h (left, top, width>1, height>1)
• a thickness t of 1 (as in ┌) or 2 (as in ┏)

render an inner border for the submatrix with the specified thickness, taking into account existing lines.

x=4;y=1;w=2;h=3;t=2;
a=[' ┌───┐',
'┌┼┐  │',
'│└┼──┘',
'└─┘   ']

// output
r=[' ┌───┐',
'┌┼┐ ┏┪',
'│└┼─╂┨',
'└─┘ ┗┛']


When overwriting a line fragment, the new thickness should be the greater of the old thickness and t.

This isn't about input parsing or finding the Kolmogorov complexity of Unicode, so you may assume a,u,x,y,w,h,t are available to you as variables. Also, you may put the result in a variable r instead of returning or outputting it, as long as r is of the same type as a.

If your language forces you to put code in functions (C, Java, Haskell, etc) and your solution consists of a single function, you can omit the function header and footer.

Larger test:

x=4;y=1;w=24;h=4;t=1;
a=['┏┱─────┐         ┌┐     ┎──┲━┓',
'┠╂─────┘         ││     ┃  ┗━┛',
'┃┃               ││     ┃     ',
'┠╂──┲━━┓  ┏━━━━┓ ││    ┌╂┰┐   ',
'┃┃  ┗━━┩  ┃    ┃ └╆━┓  └╂┸┘   ',
'┃┃     │  ┃    ┃  ┃ ┃   ┃     ',
'┗┹─────┘  ┗━━━━┛  ┗━┛   ╹     ']

// output
r=['┏┱─────┐         ┌┐     ┎──┲━┓',
'┠╂──┬──┴─────────┼┼─────╂──╄━┛',
'┃┃  │            ││     ┃  │  ',
'┠╂──╆━━┓  ┏━━━━┓ ││    ┌╂┰┐│  ',
'┃┃  ┗━━╃──╂────╂─┴╆━┱──┴╂┸┴┘  ',
'┃┃     │  ┃    ┃  ┃ ┃   ┃     ',
'┗┹─────┘  ┗━━━━┛  ┗━┛   ╹     ']

• will the input always hold 0 <= x < x + w < width(a) and 0 <= y < y + h < height(a)? – tsh Aug 29 '17 at 10:30
• @tsh yes, input will be valid – ngn Aug 29 '17 at 10:42
• Bah, my default font is dodgy - it shows some of those characters with the wrong heaviness unless you zoom in a lot. – Neil Aug 29 '17 at 11:51
• @Neil I'm sorry about that. One workaround is to paste the examples in an editor where you can choose the font. – ngn Aug 29 '17 at 12:04
• About your bounty - it is impossible to award three 150-rep bounties. You have to double the rep count every time you start another bounty on the same question. – MD XF Sep 5 '17 at 20:42

JavaScript, 218 bytes

(a,x,y,w,h,t,u)=>a.map((l,j)=>l.map((c,i)=>u[(g=(a,b)=>a?g(a/3|0,b/3|0)*3+Math.max(a%3,b%3):b)(u.indexOf(c),t*((j==y||j==y+h-1)*((i>x&&i<x+w)*9+(i>=x&&i<x+w-1))+(i==x||i==x+w-1)*((j>y&&j<y+h)*3+(j>=y&&j<y+h-1)*27)))]))


a should be taken as array of array of char.

f =

(a,x,y,w,h,t,u)=>a.map((l,j)=>l.map((c,i)=>u[(g=(a,b)=>a?g(a/3|0,b/3|0)*3+Math.max(a%3,b%3):b)(u.indexOf(c),t*((j==y||j==y+h-1)*((i>x&&i<x+w)*9+(i>=x&&i<x+w-1))+(i==x||i==x+w-1)*((j>y&&j<y+h)*3+(j>=y&&j<y+h-1)*27)))]))

x=4;y=1;w=24;h=4;t=1;
a=['┏┱─────┐         ┌┐     ┎──┲━┓',
'┠╂─────┘         ││     ┃  ┗━┛',
'┃┃               ││     ┃     ',
'┠╂──┲━━┓  ┏━━━━┓ ││    ┌╂┰┐   ',
'┃┃  ┗━━┩  ┃    ┃ └╆━┓  └╂┸┘   ',
'┃┃     │  ┃    ┃  ┃ ┃   ┃     ',
'┗┹─────┘  ┗━━━━┛  ┗━┛   ╹     '].map(x => [...x])
u=" ╶╺╵└┕╹┖┗╴─╼┘┴┶┚┸┺╸╾━┙┵┷┛┹┻╷┌┍│├┝╿┞┡┐┬┮┤┼┾┦╀╄┑┭┯┥┽┿┩╃╇╻┎┏╽┟┢┃┠┣┒┰┲┧╁╆┨╂╊┓┱┳┪╅╈┫╉╋";

output = f(a,x,y,w,h,t,u).map(x => x.join('')).join('\n');