/**
 * 获取操作
 * @param {string} cName 操作对应的自定义名称
 * @param {object} Params 自定义参数，覆盖 Params 中对应的部分
 * @returns JSON String
 */
function getFn(cName, cParams = {}) {
  const target = fnList.find(i => i.cName === cName)
  if (!target) return ''
  const targetDup = JSON.parse(JSON.stringify(target))
  const paramKeys = Object.keys(cParams)
  if (paramKeys.length !== 0) {
    paramKeys.forEach(key => {
      targetDup.content.Params[key] = cParams[key]
    })
  }
  return JSON.stringify(targetDup.content)
}

const fnList = [
  {
    cName: "toggleGrid",
    remark: '网格显示/隐藏',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "AirGrid",
        "ActionName": "ShowHidden",
        "Id": "Green",  // 'Green' | 'Red'
        "Visible": true
      }
    }

  },
  {
    cName: 'toggleRoute',
    remark: '航路显示/隐藏',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "AirRoute",
        "ActionName": "ShowHidden",
        "Id": "1",
        "Visible": true
      }
    }

  },
  {
    cName: 'toggleLine',
    remark: '航线显示/隐藏(Block--碰撞,Normal--无碰撞,Back--返回)',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "AirLine",
        "ActionName": "ShowHidden",
        "Id": "Block",   // 'Normal' | 'Block' | 'Back'
        "Visible": true
      }
    }
  },
  {
    cName: 'initUavNormal',
    remark: '初始化无人机飞行路线--无碰撞路线',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "InitUav",
        "Id": "UavId",
        "Speed": 2000.0,
        "SplinePoints": [
          {
            "Location": "X=443230,Y=-736980,Z=5250",
            "Rotation": "Pitch=89,Yaw=71,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=443240,Y=-736952,Z=6610",
            "Rotation": "Pitch=26,Yaw=101,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=442020,Y=-730610,Z=9720",
            "Rotation": "Pitch=-3,Yaw=68,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=449660,Y=-711980,Z=8820",
            "Rotation": "Pitch=-1,Yaw=73,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=454810,Y=-695130,Z=8650",
            "Rotation": "Pitch=0,Yaw=70,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=466190,Y=-664600,Z=8830",
            "Rotation": "Pitch=-1,Yaw=49,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=471450,Y=-658450,Z=8710",
            "Rotation": "Pitch=1,Yaw=33,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=474820,Y=-656240,Z=8780",
            "Rotation": "Pitch=3,Yaw=-14,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=480660,Y=-657700,Z=9130",
            "Rotation": "Pitch=0,Yaw=-21,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=489870,Y=-661280,Z=9200",
            "Rotation": "Pitch=-2,Yaw=-22,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=502730,Y=-666350,Z=8830",
            "Rotation": "Pitch=0,Yaw=-17,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=517900,Y=-671020,Z=8910",
            "Rotation": "Pitch=0,Yaw=-34,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=520366,Y=-672669,Z=8910",
            "Rotation": "Pitch=1,Yaw=-36,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=528910,Y=-678970,Z=9070",
            "Rotation": "Pitch=1,Yaw=-37,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=536911,Y=-685079,Z=9162",
            "Rotation": "Pitch=-1,Yaw=1,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=538750,Y=-685060,Z=9130",
            "Rotation": "Pitch=-10,Yaw=56,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=544910,Y=-675790,Z=7150",
            "Rotation": "Pitch=0,Yaw=52,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=547850,Y=-672060,Z=7150",
            "Rotation": "Pitch=0,Yaw=65,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=550480,Y=-666430,Z=7150",
            "Rotation": "Pitch=-34,Yaw=28,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=554110,Y=-664540,Z=4370",
            "Rotation": "Pitch=-90,Yaw=0,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=554110,Y=-664540,Z=2040",
            "Rotation": "Pitch=0,Yaw=0,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          }
        ]
      }
    }
  },
  {
    cName: 'initUavBlock',
    remark: '初始化无人机飞行路线--有碰撞路线',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "InitUav",
        "Id": "UavId",
        "Speed": 2000.0,
        "SplinePoints": [
          {
            "Location": "X=443230,Y=-736980,Z=5250",
            "Rotation": "Pitch=89,Yaw=71,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=443240,Y=-736952,Z=6610",
            "Rotation": "Pitch=26,Yaw=84,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=443890,Y=-730610,Z=9720",
            "Rotation": "Pitch=-3,Yaw=68,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=451260,Y=-711980,Z=8820",
            "Rotation": "Pitch=-1,Yaw=70,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=457420,Y=-695130,Z=8650",
            "Rotation": "Pitch=0,Yaw=69,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=469110,Y=-664600,Z=8830",
            "Rotation": "Pitch=-1,Yaw=69,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=471450,Y=-658450,Z=8710",
            "Rotation": "Pitch=1,Yaw=33,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=474820,Y=-656240,Z=8780",
            "Rotation": "Pitch=3,Yaw=-14,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=480660,Y=-657700,Z=9130",
            "Rotation": "Pitch=0,Yaw=-21,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=489870,Y=-661280,Z=9200",
            "Rotation": "Pitch=-2,Yaw=-22,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=502730,Y=-666350,Z=8830",
            "Rotation": "Pitch=0,Yaw=-17,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=517900,Y=-671020,Z=8910",
            "Rotation": "Pitch=0,Yaw=-34,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=520366,Y=-672669,Z=8910",
            "Rotation": "Pitch=1,Yaw=-36,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=528910,Y=-678970,Z=9070",
            "Rotation": "Pitch=1,Yaw=-37,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=536911,Y=-685079,Z=9162",
            "Rotation": "Pitch=-1,Yaw=1,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=538750,Y=-685060,Z=9130",
            "Rotation": "Pitch=-10,Yaw=56,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=544910,Y=-675790,Z=7150",
            "Rotation": "Pitch=0,Yaw=52,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=547850,Y=-672060,Z=7150",
            "Rotation": "Pitch=0,Yaw=65,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=550480,Y=-666430,Z=7150",
            "Rotation": "Pitch=-34,Yaw=28,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=554110,Y=-664540,Z=4370",
            "Rotation": "Pitch=-90,Yaw=0,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=554110,Y=-664540,Z=2040",
            "Rotation": "Pitch=0,Yaw=0,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          }
        ]
      }
    }
  },
  {
    cName: 'initUavBack',
    remark: '初始化无人机飞行路线--返航路线',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "InitUav",
        "Id": "UavId",
        "Speed": 2000.0,
        "SplinePoints": [
          {
            "Location": "X=554110,Y=-664540,Z=2040",
            "Rotation": "Pitch=0,Yaw=0,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=554110,Y=-664540,Z=4370",
            "Rotation": "Pitch=-90,Yaw=0,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=550480,Y=-666430,Z=7150",
            "Rotation": "Pitch=-34,Yaw=28,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=547850,Y=-672060,Z=9640",
            "Rotation": "Pitch=-22,Yaw=65,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=544910,Y=-675790,Z=9890",
            "Rotation": "Pitch=-3,Yaw=52,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=538750,Y=-685060,Z=10990",
            "Rotation": "Pitch=-6,Yaw=56,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=536911,Y=-685079,Z=10982",
            "Rotation": "Pitch=0,Yaw=1,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=528910,Y=-678970,Z=11490",
            "Rotation": "Pitch=-3,Yaw=-37,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=520366,Y=-672669,Z=11310",
            "Rotation": "Pitch=1,Yaw=-36,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=517900,Y=-671020,Z=11180",
            "Rotation": "Pitch=3,Yaw=-34,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=502730,Y=-666350,Z=10840",
            "Rotation": "Pitch=1,Yaw=-17,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=489870,Y=-661280,Z=10980",
            "Rotation": "Pitch=-1,Yaw=-22,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=480660,Y=-657700,Z=11030",
            "Rotation": "Pitch=0,Yaw=-21,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=474820,Y=-656240,Z=11090",
            "Rotation": "Pitch=-1,Yaw=-14,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=471450,Y=-658450,Z=10900",
            "Rotation": "Pitch=3,Yaw=33,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=467700,Y=-664600,Z=10880",
            "Rotation": "Pitch=0,Yaw=59,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=456270,Y=-695130,Z=11360",
            "Rotation": "Pitch=-1,Yaw=69,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=449660,Y=-711980,Z=11570",
            "Rotation": "Pitch=-1,Yaw=69,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=442020,Y=-730610,Z=11930",
            "Rotation": "Pitch=-1,Yaw=68,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=443240,Y=-736952,Z=6610",
            "Rotation": "Pitch=39,Yaw=101,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=443230,Y=-736980,Z=5250",
            "Rotation": "Pitch=89,Yaw=71,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          }
        ]
      }
    }
  },
  {
    cName: 'initUavFall',
    remark: '初始化无人机飞行路线--坠落路线',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "InitUav",
        "Id": "UavId",
        "Speed": 2000.0,
        "SplinePoints": [
          {
            "Location": "X=443230,Y=-736980,Z=5250",
            "Rotation": "Pitch=89,Yaw=71,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=443240,Y=-736952,Z=6610",
            "Rotation": "Pitch=39,Yaw=101,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=442020,Y=-730610,Z=11930",
            "Rotation": "Pitch=-1,Yaw=68,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=449660,Y=-711980,Z=11570",
            "Rotation": "Pitch=-1,Yaw=69,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=456270,Y=-695130,Z=11360",
            "Rotation": "Pitch=-86,Yaw=90,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=456270,Y=-694860,Z=7390",
            "Rotation": "Pitch=-83,Yaw=90,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          },
          {
            "Location": "X=456270,Y=-694270,Z=2290",
            "Rotation": "Pitch=0,Yaw=0,Roll=0",
            "Scale": "X=1,Y=1,Z=1"
          }
        ]
      }
    }
  },
  {
    cName: 'startUav',
    remark: '无人机开始飞行',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "StartUav",
        "Id": "UavId"
      }
    }
  },
  {
    cName: 'pauseUav',
    remark: '无人机暂停飞行',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "PauseUav",
        "Id": "UavId"
      }
    }
  },
  {
    cName: 'stopUav',
    remark: '无人机停止飞行',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "StopUav",
        "Id": "UavId"
      }
    }
  },
  {
    cName: 'startFollowUav',
    remark: '无人机视角跟随-开始',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "StartPawnFollowUav",
        "Id": "UavId"
      }
    }
  },
  {
    cName: 'endFollowUav',
    remark: '无人机视角跟随-结束',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "EndPawnFollowUav"
      }
    }
  },
  {
    cName: 'setGoodsVisible',
    remark: '无人机设置货物显隐',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "SetGoodsBox",
        "Id": "UavId",
        "Visible": false
      }
    }
  },
  {
    cName: 'destroyUav',
    remark: '无人机销毁',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "Uav",
        "ActionName": "DestroyUav",
        "Id": "UavId"
      }
    }
  },
  {
    cName: 'toggleSignalTower',
    remark: '信号塔显示/隐藏',
    content: {
      "ModuleName": "BluePrint",
      "ActionName": "",
      "Params": {
        "ModuleName": "SignalTower",
        "ActionName": "PoiShowHidden",
        "Visible": true
      }
    }
  },
  {
    cName: 'locateTakeoff',
    remark: '起飞点定位',
    content: {
      "ModuleName": "Roam",
      "ActionName": "Goto",
      "Params": {
        "X": 441357.803266,
        "Y": -738441.043188,
        "Z": 6880.074496,
        "Pitch": -37.385139,
        "Yaw": 36.402233,
        "Roll": -0.000219,
        "Duration": 0.1
      }
    }
  },
  {
    cName: 'locateLandfall',
    remark: '降落点定位',
    content: {
      "ModuleName": "Roam",
      "ActionName": "Goto",
      "Params": {
        "X": 552993.01402,
        "Y": -663972.824815,
        "Z": 2846.776697,
        "Pitch": -32.906322,
        "Yaw": -30.157532,
        "Roll": -1.833872,
        "Duration": 0.1
      }
    }
  },
  {
    cName: 'resetCamera',
    remark: '回到初始视角',
    content: {
      "ModuleName": "Roam",
      "ActionName": "Goto",
      "Params": {
        "X": 424678.164214,
        "Y": -750393.023912,
        "Z": 26005.213753,
        "Pitch": -21.6,
        "Yaw": 42.600002,
        "Roll": 0.0,
        "Duration": 0.1
      }
    }
  },
  {
    cName: 'setRotateSpeed',
    remark: '调整操控灵敏度',
    content: {
      "ModuleName": "Roam",
      "ActionName": "Update",
      "Params": {
        "MovementSpeedMultiplier": 0.03,
        "RotationSpeedMultiplier": 0.5,
        "ScaleSpeedMultiplier": 0.1,
        "MinMovementLimit": {
          "X": 0,
          "Y": 0,
          "Z": 0
        },
        "MaxMovementLimit": {
          "X": 0,
          "Y": 0,
          "Z": 0
        }
      }
    }
  }
]

// 旧版功能
const nameFunctions = {
  // '正常航线': "rodOkShow", ✅
  // '异常航线': "rodNoShow", ✅
  // '隐藏航线': "rodHidden", ✅
  // '网格展示': "netShow", ✅
  // '网格隐藏': "netHidden", ✅
  // '适飞区': "netGreen", ✅
  // '禁飞区': "netRed", ✅
  // '跟随飞行（自动来回）': "flay", ✅ (暂无法实现自动来回)
  // '清除跟随无人机': "clearFlowFlay", ✅
  // '起飞点定位': "upLocation", ✅
  // '降落点定位': "downLocation", ✅
  // '航路显示': "rowShow", ✅
  // '航路隐藏': "rowHidden", ✅
  // '信号塔显示': "signShow", ✅
  // '信号塔隐藏': "signHidden", ✅
  // '坠落飞行': "downFly", ✅
  // '风险区': "netYellow", ❌
  // '空间网格整体查看': "netLookUp", ❌
  // '查看航路视角移动': "lookFlyRow", ❌
  // '飞行全景查看': "LookflayAll", ❌
  // '场景概览': "lookAll", ❌
  // '预警视角移动': "yujingFly" ❌


  '区域展示': "areaInfoShow",
  '区域隐藏': "areaInfoHidden",
  '清除有问题航线并查看没问题航线': "autoRow",
  '自动生成对面无人机': "autoMakeFlay",
  '清除自动生成无人机': "closeAutoFlay",
}

export default getFn