import{a as n,L as e,j as o,C as t,k as r,l as s,m as a,n as i,o as p,t as l,u,f}from"../../vendor.js";import{createPortal as c}from"react-dom";import{forwardRef as m,useState as d,useReducer as v,useEffect as g,useImperativeHandle as j,cloneElement as b,Children as h}from"react";import{usePopper as y}from"react-popper";import{u as x,a as k}from"../../hooks.js";import{F as C}from"./Form.js";function E(n,e){var o=l(n);if(u){var t=u(n);e&&(t=f(t).call(t,(function(e){return p(n,e).enumerable}))),o.push.apply(o,t)}return o}var O=m((function(l,u){var f,m,O,S=l.children,F=l.element,R=l.component,N=x(),w=N._settingsHolderRef,B=N.overrides,H=N.oakRef,L=k(),_=d(),q=n(_,2),z=q[0],A=q[1],D=d(),G=n(D,2),I=G[0],J=G[1],K=v(e,{opened:!1}),M=n(K,2),P=M[0],Q=M[1];g((function(){X()}),[B]);var T=y(I,z,function(n){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?E(Object(o),!0).forEach((function(e){r(n,e,o[e])})):s?a(n,s(o)):E(Object(o)).forEach((function(e){i(n,e,p(o,e))}))}return n}({},("function"==typeof(null==R||null===(f=R.settings)||void 0===f?void 0:f.popperSettings)?null==R||null===(m=R.settings)||void 0===m?void 0:m.popperSettings({optionButtonElement:I}):null==R||null===(O=R.settings)||void 0===O?void 0:O.popperSettings)||{modifiers:[{name:"preventOverflow",enabled:!0,options:{boundary:null==H?void 0:H.current}},{name:"offset",options:{offset:[0,5]}}]})),U=T.styles,V=T.attributes;j(u,(function(){return{open:W,close:X,toggle:Y}}));var W=function(){Q({opened:!0})},X=function(){Q({opened:!1})},Y=function(){return P.opened?X():W()},Z=function(){return o.exports.jsx(C,{ref:A,popper:z,element:F,component:R,styles:U,attributes:V,onSave:X,onCancel:X})};return o.exports.jsxs(o.exports.Fragment,{children:[S&&b(h.only(S),{ref:function(n){J(null!=n&&n.isOak?n.innerRef.current:n)},className:t(h.only(S).props.className,{"oak-opened":P.opened})}),P.opened?L.settingsContainer||w?c(Z(),L.settingsContainer||w):Z():null]})}));export{O as E};
//# sourceMappingURL=index.js.map
