"""Move workflow-designer menu item from 业务管理 to 访客模块"""
with open('mp-sc-admin/src/pages/Layout.vue', 'rb') as f:
    content = f.read()

# File uses \r\n line endings, so search with \r\n
old = (
    b"      { path: '/pending-employees', label: '\xe9\x80\x9a\xe8\xae\xaf\xe5\xbd\x95\xe5\xaf\xbc\xe5\x85\xa5', icon: 'i-carbon-import-export' },\n"
    b"      { path: '/workflow-designer', label: '\xe6\xb5\x81\xe7\xa8\x8b\xe8\xae\xbe\xe8\xae\xa1\xe5\x99\xa8', icon: 'i-carbon-diagram' },\r\n"
    b"    ],\r\n"
    b"  },\r\n"
    b"  {\r\n"
    b"    label: '\xe8\xae\xbf\xe5\xae\xa2\xe6\xa8\xa1\xe5\x9d\x97',\r\n"
    b"    items: [\r\n"
    b"      { path: '/appointments', label: '\xe9\xa2\x84\xe7\xba\xa6\xe7\xae\xa1\xe7\x90\x86', icon: 'i-carbon-calendar' },\r\n"
    b"      { path: '/visit-types', label: '\xe6\x9d\xa5\xe8\xae\xbf\xe7\x9b\xae\xe7\x9a\x84', icon: 'i-carbon-list-dropdown' },\r\n"
    b"      { path: '/visitor-areas', label: '\xe5\x88\xb0\xe8\xae\xbf\xe5\x8c\xba\xe5\x9f\x9f', icon: 'i-carbon-location' },\r\n"
    b"      { path: '/config', label: '\xe5\xae\xa1\xe6\x89\xb9\xe9\x85\x8d\xe7\xbd\xae', icon: 'i-carbon-settings-adjust' },"
)

new = (
    b"      { path: '/pending-employees', label: '\xe9\x80\x9a\xe8\xae\xaf\xe5\xbd\x95\xe5\xaf\xbc\xe5\x85\xa5', icon: 'i-carbon-import-export' },\n"
    b"    ],\r\n"
    b"  },\r\n"
    b"  {\r\n"
    b"    label: '\xe8\xae\xbf\xe5\xae\xa2\xe6\xa8\xa1\xe5\x9d\x97',\r\n"
    b"    items: [\r\n"
    b"      { path: '/appointments', label: '\xe9\xa2\x84\xe7\xba\xa6\xe7\xae\xa1\xe7\x90\x86', icon: 'i-carbon-calendar' },\r\n"
    b"      { path: '/visit-types', label: '\xe6\x9d\xa5\xe8\xae\xbf\xe7\x9b\xae\xe7\x9a\x84', icon: 'i-carbon-list-dropdown' },\r\n"
    b"      { path: '/visitor-areas', label: '\xe5\x88\xb0\xe8\xae\xbf\xe5\x8c\xba\xe5\x9f\x9f', icon: 'i-carbon-location' },\r\n"
    b"      { path: '/workflow-designer', label: '\xe6\xb5\x81\xe7\xa8\x8b\xe8\xae\xbe\xe8\xae\xa1\xe5\x99\xa8', icon: 'i-carbon-diagram' },\r\n"
    b"      { path: '/config', label: '\xe5\xae\xa1\xe6\x89\xb9\xe9\x85\x8d\xe7\xbd\xae', icon: 'i-carbon-settings-adjust' },"
)

if old in content:
    content = content.replace(old, new)
    with open('mp-sc-admin/src/pages/Layout.vue', 'wb') as f:
        f.write(content)
    print('done - replaced successfully')
else:
    print('pattern not found')
    idx = content.find(b'pending-employees')
    if idx >= 0:
        # Show bytes around it
        print(content[idx:idx+400])
