You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/p__Shixuns__Edit__body__Lev...

1 line
20 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[94498],{58271:function(e,t,n){n.d(t,{t:function(){return f}});var i=n(82242),a=n.n(i),o=(n(59301),n(3113)),s="buttonFixed___vyq30",l="button___hxmYv",r="buttonWrap___uK8dl",c=n(92310),u=n.n(c),d=n(37712),f=function(e){var t=e.cancelText,n=void 0===t?"取消":t,i=e.okText,c=void 0===i?"确定":i,f=e.loading,p=void 0!==f&&f,m=e.hasOkBtn,h=void 0===m||m,v=e.hasCancelBtn,g=void 0===v||v,x=e.okButtonProps,b=void 0===x?{}:x,y=e.onCancel,_=void 0===y?function(){}:y,j=e.onOk,w=void 0===j?function(){}:j,C=e.className,k=void 0===C?"":C;return(0,d.jsx)("div",{className:u()(s,k),children:(0,d.jsxs)("div",{className:r,children:[g&&(0,d.jsx)(o.ZP,{size:"middle",className:"".concat(l," mr20"),onClick:_,children:n}),h&&(0,d.jsx)(o.ZP,a()(a()({size:"middle",type:"primary",className:"".concat(l," mr20"),loading:p,onClick:w},b),{},{children:c}))]})})}},35188:function(e,t,n){n.r(t),n.d(t,{default:function(){return $}});var i=n(7557),a=n.n(i),o=n(41498),s=n.n(o),l=n(82242),r=n.n(l),c=n(79800),u=n.n(c),d=n(59301),f=n(7880),p=n(78241),m=n(43418),h=n(8591),v=n(8772),g=n(5112),x=n(95237),b=n(43604),y=n(57809),_=n(11094),j=n(85062),w="bg___Y4VEx",C="formWrap___JY9de",k=n(89392),S=n(58271),Z=n(79236),N=n(42322),O=n(55648),I=n(37205),P=n.n(I),E=n(39647),T=n.n(E),F=n(49127),L=n(3113),M=n(37712),R=["InputRight","value","onChange"],B=function(e){var t=e.InputRight,n=e.value,i=void 0===n?[]:n,a=e.onChange,o=void 0===a?function(){}:a,s=T()(e,R),l=(0,d.useState)(),c=u()(l,2),f=c[0],p=c[1],m=function(e){e.preventDefault(),f&&(o([].concat(P()(i),[f])),p(null))};return(0,M.jsxs)("div",{children:[(0,M.jsx)(v.Z,r()(r()({},s),{},{value:f,onChange:function(e){return p(e.target.value)},onPressEnter:m,onBlur:m})),t,(0,M.jsx)("div",{className:"mt20",children:null==i?void 0:i.map((function(e,t){return(0,M.jsx)(F.Z,{className:"ml10 mr10",count:"x",onClick:function(){return function(e){var t=i.filter((function(t,n){return n!==e}));o(t)}(t)},children:(0,M.jsx)(L.ZP,{type:"primary",ghost:!0,children:e})})}))})]})},V={1:[100,200],2:[300,400,500,600],3:[700,800,900,1e3]},$=(0,f.connect)((function(e){return{shixunsDetail:e.shixunsDetail,newCourse:e.newCourse,globalSetting:e.globalSetting,practiceSetting:e.practiceSetting}}))((function(e){var t,n,i,o,l,c=e.shixunsDetail,I=e.dispatch,P=e.practiceSetting,E=(0,f.useParams)(),T=p.Z.useForm(),F=u()(T,1)[0],L=(0,d.useState)({}),R=u()(L,2),$=R[0],A=R[1],D=(0,d.useState)([100,200]),W=u()(D,2),q=W[0],H=W[1],Y=c.challengesNew,Q=(0,d.useState)(),z=u()(Q,2),U=z[0],X=z[1],G=(0,d.useState)(),J=u()(G,2),K=J[0],ee=J[1],te=(0,d.useState)(!0),ne=u()(te,2),ie=ne[0],ae=ne[1],oe=(0,d.useState)(1),se=u()(oe,2),le=se[0],re=(se[1],(0,d.useRef)({subject:"",difficulty:1,hide_task_pass:!1,score:100,hide_width_rate:40,task_pass:(0,O.S)(Y.task_pass_default),has_relation:!1})),ce=(0,d.useRef)(null),ue=(P.selectQuestionParams,P.id),de=P.newQuestion;(0,d.useEffect)((function(){E.challengesId?(ee(!0),fe()):(ae(!0),ee(!1),I({type:"shixunsDetail/getChallengesNew",payload:r()({},E)}),ae(!1)),setTimeout((function(){var e;null===(e=document.getElementById("practice-scroll"))||void 0===e||e.scrollTo(0,0)}),300)}),[E]),(0,d.useEffect)((function(){return he(),function(){clearTimeout(ce.current)}}),[$]);var fe=function(){var e=s()(a()().mark((function e(){var t,n;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ae(!0),e.next=3,(0,j.ii)({id:E.id,challengeId:E.challengesId,tab:0});case 3:(t=e.sent)&&(n=r()(r()({},t),{},{task_pass:(0,O.S)(t.task_pass)}),X(n),pe(n),ae(!1),re.current={subject:n.subject,difficulty:n.difficulty,score:n.score,task_pass:n.task_pass,hide_task_pass:n.hide_task_pass,hide_width_rate:n.hide_width_rate,has_relation:null==n?void 0:n.has_relation});case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),pe=function(e){var t={subject:e.name,difficulty:e.difficulty,score:e.score,challenge_tag:e.tags,task_pass:e.task_pass,hide_task_pass:e.hide_task_pass,hide_width_rate:e.hide_width_rate,has_relation:null==e?void 0:e.has_relation},n=V[e.difficulty];H(n),F.setFieldsValue(r()({},t)),A(r()({},t))},me=function(){var e=s()(a()().mark((function e(){var t,n,i,o,s,l,u,d=arguments;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=d.length>0&&void 0!==d[0]?d[0]:{},n=d.length>1&&void 0!==d[1]&&d[1],i=d.length>2&&void 0!==d[2]?d[2]:1,!K){e.next=9;break}return e.next=6,(0,j.Rs)(r()(r()({},E),{},{tab:0,challenge:r()({},t),challenge_tag:t.challenge_tag,sync_origin_shixun:n}));case 6:return e.sent&&(I({type:"practiceSetting/setUpdateIndex"}),null!=c&&null!==(o=c.detail)&&void 0!==o&&o.copy_for_exercise&&(0,O.m)(I,c,E.id,i),f.history.replace("/shixuns/".concat(E.id,"/edit/").concat(E.challengesId,"/tab=2"))),e.abrupt("return");case 9:return(s=r()({},$)).identifier=E.id,s.st=0,s.sync_origin_shixun=n,e.next=15,(0,j.al)(r()({},s));case 15:1===(l=e.sent).status&&(null!=c&&null!==(u=c.detail)&&void 0!==u&&u.copy_for_exercise&&(0,O.m)(I,c,E.id,i),f.history.replace("/shixuns/".concat(E.id,"/edit/").concat(l.challenge_id,"/tab=2")),setTimeout((function(){I({type:"practiceSetting/setParams",payload:{newQuestion:null}}),I({type:"practiceSetting/setUpdateIndex"})}),200));case 17:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),he=function(){clearTimeout(ce.current),ce.current=setTimeout(ve,500)},ve=function(){"subject"in $&&de&&I({type:"practiceSetting/setParams",payload:{newQuestion:{st:0,name:null==$?void 0:$.subject}}});var e=["subject","difficulty","score","task_pass"].some((function(e){var t=(0,k.isNumber)($[e])?String($[e]):$[e],n=(0,k.isNumber)(re.current[e])?String(re.current[e]):re.current[e];return!(0,k.isEqual)(t,n)}));I(e?{type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!0}}:{type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})},ge=function(){var e,t=function(){f.history.push("/shixuns/".concat(ue,"/challenges")),I({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};null!=P&&null!==(e=P.sideBar)&&void 0!==e&&e.confirmLeave?m.Z.confirm({title:"离开此页提示",content:"系统可能不会保存您所做的更改。",okText:"离开",cancelText:"取消",onOk:function(){t()}}):t()};return(0,M.jsxs)(d.Fragment,{children:[(0,M.jsx)("section",{className:w,id:"practice-scroll",children:(0,M.jsxs)(p.Z,{form:F,className:C,scrollToFirstError:!0,layout:"vertical",onValuesChange:function(e,t){var n,i,a;A(r()({},F.getFieldsValue())),"difficulty"in e&&(n=e.difficulty,a=null==(i=V[n])?void 0:i[0],H(i),F.setFieldsValue({score:a}),A(r()(r()({},F.getFieldsValue()),{score:a})))},onFinish:function(e){var t,n,i;K||2!==(null===(t=c.detail)||void 0===t?void 0:t.shixun_status)?null!=c&&null!==(n=c.detail)&&void 0!==n&&n.is_fork_from_creator&&null!=c&&null!==(i=c.detail)&&void 0!==i&&i.copy_for_exercise&&re.current.has_relation?I({type:"classroomList/setActionTabs",payload:{key:"同步修改",value:e,type:"taskLevel",fn:function(e,t,n){me(e,t,n)}}}):me(e):h.ZP.info("该实训已经发布不能新建")},children:[(0,M.jsx)(N.Z,{activeIndex:0,isEdit:K}),(0,M.jsx)(p.Z.Item,{initialValue:"",name:"subject",label:"任务名称:",rules:[{required:!0,message:"请输入任务名称"}],children:(0,M.jsx)(v.Z,{bordered:!1,maxLength:60,suffix:"".concat((null===(t=$.subject)||void 0===t?void 0:t.length)||0,"/60"),placeholder:"例如从Python程序设计-入门精通"})}),(0,M.jsx)(p.Z.Item,{name:"task_pass",label:"任务要求:",rules:[{required:!0,message:"请输入作业的简介"},{max:35e3,message:"过关任务简介最大限制35000个字符"}],children:(0,M.jsx)(_.Z,{watch:!0,defaultValue:K?null==U?void 0:U.task_pass:Y.task_pass_default},E.challengesId||"3")}),(0,M.jsx)(p.Z.Item,{initialValue:40,name:"hide_width_rate",label:"任务要求默认展示宽度:",children:(0,M.jsxs)(g.ZP.Group,{children:[(0,M.jsx)(g.ZP,{value:0,children:"0%"}),(0,M.jsx)(g.ZP,{style:{marginLeft:70},value:30,children:"30%"}),(0,M.jsx)(g.ZP,{style:{marginLeft:70},value:40,children:"40%"}),(0,M.jsx)(g.ZP,{style:{marginLeft:70},value:50,children:"50%"})]})}),$.unity_3d&&(null===(n=c.detail)||void 0===n?void 0:n.identity)<3&&(0,M.jsx)(p.Z.Item,{name:"unity_3d_routes",label:"路径:",rules:[{required:!0,message:"必填项:不能为空"}],children:(0,M.jsx)(v.Z,{bordered:!1,disabled:2===(null===(i=c.detail)||void 0===i?void 0:i.shixun_status),placeholder:"请选择版本库中的代码文件。例: src/step1/HelloWorld.java"})}),(0,M.jsx)(p.Z.Item,{initialValue:1,name:"difficulty",label:"难度系数:",rules:[{required:!0,message:"请选择难度系数"}],children:(0,M.jsxs)(g.ZP.Group,{disabled:2===(null===(o=c.detail)||void 0===o?void 0:o.shixun_status),children:[(0,M.jsx)(g.ZP,{value:1,children:"简单"}),(0,M.jsx)(g.ZP,{style:{marginLeft:70},value:2,children:"中等"}),(0,M.jsx)(g.ZP,{style:{marginLeft:70},value:3,children:"困难"})]})}),(0,M.jsx)(p.Z.Item,{name:"challenge_tag",label:(0,M.jsxs)("div",{children:["技能标签 ",(0,M.jsx)("span",{className:"pl20 font12 c-light-black",children:"学员答题正确将获得技能,否则不能获得技能(回车添加标签)"})]}),rules:[{required:!0,message:"请输入技能标签"}],children:(0,M.jsx)(B,{placeholder:"添加标签",style:{width:"260px"},InputRight:(0,M.jsx)("span",{className:"ml5",children:"(回车添加标签)"})})}),(0,M.jsxs)(x.Z,{className:"customItemSelect",children:[(0,M.jsx)(b.Z,{children:(0,M.jsx)(p.Z.Item,{name:"score",initialValue:100,label:"奖励金币:",rules:[{required:!0,message:"请选择奖励经验值"}],children:(0,M.jsx)(y.default,{disabled:2===(null===(l=c.detail)||void 0===l?void 0:l.shixun_status),bordered:!1,getPopupContainer:function(e){return e.parentNode},style:{width:260},children:null==q?void 0:q.map((function(e,t){return(0,M.jsx)(y.default.Option,{value:e,children:e},t)}))})})}),(0,M.jsx)(b.Z,{flex:1,children:(0,M.jsx)("div",{style:{marginTop:88},className:"font12 c-light-black ml10",children:" 学员正确答题时获得金币,并且获得等量的经验值。如:+100金币、+100经验值"})})]})]},le)},1),(0,M.jsx)(S.t,{onOk:function(){return F.submit()},className:"customFixedButton",onCancel:function(){ge()}},2),(0,M.jsx)(Z.Z,{loading:ie})]})}))},42322:function(e,t,n){n.d(t,{Z:function(){return l}});var i=n(59301),a=n(43418),o=n(7880),s=n(37712),l=(0,o.connect)((function(e){return{globalSetting:e.globalSetting,practiceSetting:e.practiceSetting}}))((function(e){var t=e.activeIndex,n=e.isEdit,l=void 0===n||n,r=e.dispatch,c=e.practiceSetting,u=(0,o.useParams)(),d=u.id,f=u.challengesId,p=(0,i.useMemo)((function(){return[{name:"本关任务",url:"/shixuns/".concat(d,"/edit/").concat(f,"/editcheckpoint")},{name:"评测设置",url:"/shixuns/".concat(d,"/edit/").concat(f,"/tab=2")},{name:"参考答案",url:"/shixuns/".concat(d,"/edit/").concat(f,"/tab=3")},{name:"关卡排行榜",url:"/shixuns/".concat(d,"/edit/").concat(f,"/tab=4")}]}),[d,f]);return(0,s.jsx)("ul",{className:"challenge-nav",children:l?p.map((function(e,n){return t===n?(0,s.jsxs)("li",{children:[" ",(0,s.jsx)("a",{className:"active",children:e.name})," "]},e.url):(0,s.jsxs)("li",{children:[" ",(0,s.jsx)("a",{onClick:function(){return t=e.url,i=function(){o.history.push(t),r({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})},void(null!=c&&null!==(n=c.sideBar)&&void 0!==n&&n.confirmLeave?a.Z.confirm({title:"离开此页提示",content:"系统可能不会保存您所做的更改。",okText:"离开",cancelText:"取消",onOk:function(){i()}}):i());var t,n,i},children:e.name})," "]},e.url)})):(0,s.jsxs)("li",{children:[" ",(0,s.jsx)("a",{className:"active",children:p[0].name})," "]},p[0].url)})}))},79236:function(e,t,n){n.d(t,{Z:function(){return s}});n(59301);var i=n(71418),a="loading___lueiN",o=n(37712),s=function(e){return e.loading?(0,o.jsx)("div",{className:a,children:(0,o.jsx)(i.Z,{})}):(0,o.jsx)(o.Fragment,{})}},55648:function(e,t,n){n.d(t,{S:function(){return d},m:function(){return f}});var i=n(7557),a=n.n(i),o=n(41498),s=n.n(o),l=n(6457),r=n(8591),c=n(43418),u=n(37712),d=function(e){var t=document.createElement("textarea");return t.value=e,t.value},f=function(){var e=s()(a()().mark((function e(t,n,i,o,s){var d,f,p;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t({type:"shixunsDetail/saveCopyForExercise",payload:{id:i,save_type:o}});case 2:d=e.sent,1===o?(0==(null==d?void 0:d.status)&&r.ZP.success("保存成功"),null!=d&&null!==(f=d.data)&&void 0!==f&&f.exists_same_shixun_name?t({type:"classroomList/setActionTabs",payload:{key:"重名修改",name:null==d||null===(p=d.data)||void 0===p?void 0:p.shixun_name}}):t({type:"classroomList/setActionTabs",payload:{}})):(t({type:"classroomList/setActionTabs",payload:{}}),0===(null==d?void 0:d.status)&&c.Z.info({title:"提示",width:460,icon:null,centered:!0,content:(0,u.jsx)("div",{children:(0,u.jsx)("div",{children:"实训同步修改完成,请验证实训是否可以正常使用。"})}),okText:"前往原实训",onOk:function(){var e;(0,l.xg)("/shixuns/".concat(null==n||null===(e=n.detail)||void 0===e||null===(e=e.fork_from)||void 0===e?void 0:e.fork_identifier,"/challenges"))}}));case 4:case"end":return e.stop()}}),e)})));return function(t,n,i,a,o){return e.apply(this,arguments)}}()},57809:function(e,t,n){var i=n(92310),a=n.n(i),o=n(77861),s=n(62805),l=n(59301),r=n(53487),c=n(62892),u=n(19080),d=n(36355),f=n(1684),p=n(93891),m=n(19716),h=n(32441),v=n(33234),g=n(14154),x=n(58582),b=n(84443),y=n(66339),_=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n};const j="SECRET_COMBOBOX_MODE_DO_NOT_USE",w=(e,t)=>{var n,{prefixCls:i,bordered:r=!0,className:w,rootClassName:C,getPopupContainer:k,popupClassName:S,dropdownClassName:Z,listHeight:N=256,placement:O,listItemHeight:I=24,size:P,disabled:E,notFoundContent:T,status:F,builtinPlacements:L,dropdownMatchSelectWidth:M,popupMatchSelectWidth:R,direction:B,style:V,allowClear:$}=e,A=_(e,["prefixCls","bordered","className","rootClassName","getPopupContainer","popupClassName","dropdownClassName","listHeight","placement","listItemHeight","size","disabled","notFoundContent","status","builtinPlacements","dropdownMatchSelectWidth","popupMatchSelectWidth","direction","style","allowClear"]);const{getPopupContainer:D,getPrefixCls:W,renderEmpty:q,direction:H,virtual:Y,popupMatchSelectWidth:Q,popupOverflow:z,select:U}=l.useContext(d.E_),X=W("select",i),G=W(),J=null!=B?B:H,{compactSize:K,compactItemClassnames:ee}=(0,v.ri)(X,J),[te,ne]=(0,g.Z)(X),ie=l.useMemo((()=>{const{mode:e}=A;if("combobox"!==e)return e===j?"combobox":e}),[A.mode]),ae="multiple"===ie||"tags"===ie,oe=(0,b.Z)(A.suffixIcon,A.showArrow),se=null!==(n=null!=R?R:M)&&void 0!==n?n:Q,{status:le,hasFeedback:re,isFormItemInput:ce,feedbackIcon:ue}=l.useContext(h.aM),de=(0,u.F)(le,F);let fe;fe=void 0!==T?T:"combobox"===ie?null:(null==q?void 0:q("Select"))||l.createElement(p.Z,{componentName:"Select"});const{suffixIcon:pe,itemIcon:me,removeIcon:he,clearIcon:ve}=(0,y.Z)(Object.assign(Object.assign({},A),{multiple:ae,hasFeedback:re,feedbackIcon:ue,showSuffixIcon:oe,prefixCls:X,showArrow:A.showArrow,componentName:"Select"})),ge=!0===$?{clearIcon:ve}:$,xe=(0,s.Z)(A,["suffixIcon","itemIcon"]),be=a()(S||Z,{[`${X}-dropdown-${J}`]:"rtl"===J},C,ne),ye=(0,m.Z)((e=>{var t;return null!==(t=null!=P?P:K)&&void 0!==t?t:e})),_e=l.useContext(f.Z),je=null!=E?E:_e,we=a()({[`${X}-lg`]:"large"===ye,[`${X}-sm`]:"small"===ye,[`${X}-rtl`]:"rtl"===J,[`${X}-borderless`]:!r,[`${X}-in-form-item`]:ce},(0,u.Z)(X,de,re),ee,null==U?void 0:U.className,w,C,ne),Ce=l.useMemo((()=>void 0!==O?O:"rtl"===J?"bottomRight":"bottomLeft"),[O,J]),ke=(0,x.Z)(L,z);return te(l.createElement(o.ZP,Object.assign({ref:t,virtual:Y,showSearch:null==U?void 0:U.showSearch},xe,{style:Object.assign(Object.assign({},null==U?void 0:U.style),V),dropdownMatchSelectWidth:se,builtinPlacements:ke,transitionName:(0,c.m)(G,"slide-up",A.transitionName),listHeight:N,listItemHeight:I,mode:ie,prefixCls:X,placement:Ce,direction:J,suffixIcon:pe,menuItemSelectedIcon:me,removeIcon:he,allowClear:ge,notFoundContent:fe,className:we,getPopupContainer:k||D,dropdownClassName:be,disabled:je})))};const C=l.forwardRef(w),k=(0,r.Z)(C);C.SECRET_COMBOBOX_MODE_DO_NOT_USE=j,C.Option=o.Wx,C.OptGroup=o.Xo,C._InternalPanelDoNotUseOrYouWillBeFired=k,t.default=C},8378:function(e,t){t.Z=e=>({[e.componentCls]:{[`${e.antCls}-motion-collapse-legacy`]:{overflow:"hidden","&-active":{transition:`height ${e.motionDurationMid} ${e.motionEaseInOut},\n opacity ${e.motionDurationMid} ${e.motionEaseInOut} !important`}},[`${e.antCls}-motion-collapse`]:{overflow:"hidden",transition:`height ${e.motionDurationMid} ${e.motionEaseInOut},\n opacity ${e.motionDurationMid} ${e.motionEaseInOut} !important`}}})},31561:function(e,t,n){n.d(t,{Z:function(){return j}});var i=n(1565),a=n(22386),o=n(88703),s=n(52167),l=n(35593),r=n(92310),c=n.n(r),u=n(76466),d=n(59301),f=n(81331),p=n(91659),m=f.Z.ESC,h=f.Z.TAB;var v=(0,d.forwardRef)((function(e,t){var n=e.overlay,i=e.arrow,a=e.prefixCls,o=(0,d.useMemo)((function(){return"function"==typeof n?n():n}),[n]),s=(0,u.sQ)(t,null==o?void 0:o.ref);return d.createElement(d.Fragment,null,i&&d.createElement("div",{className:"".concat(a,"-arrow")}),d.cloneElement(o,{ref:(0,u.Yr)(o)?s:void 0}))})),g={adjustX:1,adjustY:1},x=[0,0],b={topLeft:{points:["bl","tl"],overflow:g,offset:[0,-4],targetOffset:x},top:{points:["bc","tc"],overflow:g,offset:[0,-4],targetOffset:x},topRight:{points:["br","tr"],overflow:g,offset:[0,-4],targetOffset:x},bottomLeft:{points:["tl","bl"],overflow:g,offset:[0,4],targetOffset:x},bottom:{points:["tc","bc"],overflow:g,offset:[0,4],targetOffset:x},bottomRight:{points:["tr","br"],overflow:g,offset:[0,4],targetOffset:x}},y=["arrow","prefixCls","transitionName","animation","align","placement","placements","getPopupContainer","showAction","hideAction","overlayClassName","overlayStyle","visible","trigger","autoFocus","overlay","children","onVisibleChange"];function _(e,t){var n,r=e.arrow,f=void 0!==r&&r,g=e.prefixCls,x=void 0===g?"rc-dropdown":g,_=e.transitionName,j=e.animation,w=e.align,C=e.placement,k=void 0===C?"bottomLeft":C,S=e.placements,Z=void 0===S?b:S,N=e.getPopupContainer,O=e.showAction,I=e.hideAction,P=e.overlayClassName,E=e.overlayStyle,T=e.visible,F=e.trigger,L=void 0===F?["hover"]:F,M=e.autoFocus,R=e.overlay,B=e.children,V=e.onVisibleChange,$=(0,s.Z)(e,y),A=d.useState(),D=(0,o.Z)(A,2),W=D[0],q=D[1],H="visible"in e?T:W,Y=d.useRef(null),Q=d.useRef(null),z=d.useRef(null);d.useImperativeHandle(t,(function(){return Y.current}));var U=function(e){q(e),null==V||V(e)};!function(e){var t=e.visible,n=e.triggerRef,i=e.onVisibleChange,a=e.autoFocus,o=e.overlayRef,s=d.useRef(!1),l=function(){var e,a;t&&(null===(e=n.current)||void 0===e||null===(a=e.focus)||void 0===a||a.call(e),null==i||i(!1))},r=function(){var e;return!(null===(e=o.current)||void 0===e||!e.focus||(o.current.focus(),s.current=!0,0))},c=function(e){switch(e.keyCode){case m:l();break;case h:var t=!1;s.current||(t=r()),t?e.preventDefault():l()}};d.useEffect((function(){return t?(window.addEventListener("keydown",c),a&&(0,p.Z)(r,3),function(){window.removeEventListener("keydown",c),s.current=!1}):function(){s.current=!1}}),[t])}({visible:H,triggerRef:z,onVisibleChange:U,autoFocus:M,overlayRef:Q});var X,G,J,K=function(){return d.createElement(v,{ref:Q,overlay:R,prefixCls:x,arrow:f})},ee=d.cloneElement(B,{className:c()(null===(n=B.props)||void 0===n?void 0:n.className,H&&(X=e.openClassName,void 0!==X?X:"".concat(x,"-open"))),ref:(0,u.Yr)(B)?(0,u.sQ)(z,B.ref):void 0}),te=I;return te||-1===L.indexOf("contextMenu")||(te=["click"]),d.createElement(l.Z,(0,i.Z)({builtinPlacements:Z},$,{prefixCls:x,ref:Y,popupClassName:c()(P,(0,a.Z)({},"".concat(x,"-show-arrow"),f)),popupStyle:E,action:L,showAction:O,hideAction:te,popupPlacement:k,popupAlign:w,popupTransitionName:_,popupAnimation:j,popupVisible:H,stretch:(G=e.minOverlayWidthMatchTrigger,J=e.alignPoint,("minOverlayWidthMatchTrigger"in e?G:!J)?"minWidth":""),popup:"function"==typeof R?K:K(),onPopupVisibleChange:U,onPopupClick:function(t){var n=e.onOverlayClick;q(!1),n&&n(t)},getPopupContainer:N}),ee)}var j=d.forwardRef(_)}}]);