import invoker,{Container_Type_Enum,PLATFORM_TYPE_ENUM}from"./invoker";import getContainerType from"./getContainerType";invoker.registerAPI("setOptionMenu",{mobile:function(n,e){var i=e.resolve,o=e.reject,t=e.context,l=e.containerType,s=e.platformType;if(l){var a,r,u={text:n.title,show:void 0===n.show||n.show,control:void 0===n.control||n.control};if(s===PLATFORM_TYPE_ENUM.ANDROID)t&&t((function(e){n.onSuccess&&n.onSuccess(e),i(e)}),(function e(i){n.onFail&&n.onFail(i),o(e)}),"biz.navigation",(null==n||null===(a=n.menus)||void 0===a?void 0:a.length)>1?"setMenu":"setRight",(null==n||null===(r=n.menus)||void 0===r?void 0:r.length)>1?n:u);else if(s===PLATFORM_TYPE_ENUM.IOS){var v,c;t.callHandler((null==n||null===(v=n.menus)||void 0===v?void 0:v.length)>1?"biz.navigation.setMenu":"biz.navigation.setRight",Object.assign({},(null==n||null===(c=n.menus)||void 0===c?void 0:c.length)>1?n:u),(function(){i()}))}}else t&&t.call("setOptionMenu",n,(function(){i()}))}}),setOptionMenu.version={android:"1.1.0",ios:"1.1.0"};export default function setOptionMenu(n){var e=getContainerType();return invoker.invoke("setOptionMenu",e===Container_Type_Enum.isDingTalk?Object.assign({watch:!0,show:!0,control:!1,showIcon:!0,text:""},n):n,e===Container_Type_Enum.isDingTalk?{dingTalkAPIName:"biz.navigation.setRight"}:null)}