import{o as e}from"./chunk.DuxOD-Sk.js";import{r as t}from"./emotion-is-prop-valid.esm.DV_OErv-.js";import{c as n}from"./emotion-styled.browser.esm.BPUx6WuE.js";import{Lt as r,Rt as i,_t as a,at as o,ft as s,ht as c,st as l,vt as u,zt as d}from"./src.sR_9Xh2m.js";import{t as f}from"./useRequiredContext.DPvSYqB2.js";import{t as p}from"./iconPosition.CAyE8Pjc.js";var m=e(t(),1);function h(e){let{disabled:t,element:o,widgetMgr:h,fragmentId:g}=e,{formId:_}=o,v=o.shortcut?o.shortcut:void 0,{formsData:y}=f(l),b=y.formsWithUploads.has(_),x=i.SECONDARY_FORM_SUBMIT;o.type===`primary`?x=i.PRIMARY_FORM_SUBMIT:o.type===`tertiary`&&(x=i.TERTIARY_FORM_SUBMIT);let S=t||b;(0,m.useEffect)(()=>(h.addSubmitButton(_,o),()=>h.removeSubmitButton(_,o)),[h,_,o]);let C=(0,m.useCallback)(()=>{S||h.submitForm(o.formId,g,o)},[S,h,o,g]);return c({shortcut:v,disabled:S,onActivate:C}),n(u,{className:`stFormSubmitButton`,"data-testid":`stFormSubmitButton`,children:n(a,{help:o.help,containerWidth:!0,children:n(r,{kind:x,size:d.SMALL,containerWidth:!0,disabled:S,onClick:C,children:n(s,{icon:o.icon,iconPosition:p(o.iconPosition),label:o.label,shortcut:v})})})})}function g(e){return n(o,{children:n(h,{...e})})}export{g as FormSubmitContent};