import{j as e,A as o,K as n,L as r}from"../../vendor.js";import{useRef as t,useCallback as l,Fragment as a}from"react";import{C as s}from"../../defaults.js";import{E as i}from"../../contexts.js";import{a as p}from"../../hooks.js";import{O as m}from"../Option/index.js";import{D as d}from"../Draggable/index.js";import{D as c}from"../Droppable/index.js";import{E as u}from"../Editable/index.js";var x=function(x){var f,v,j=x.element,k=x.parent,b=x.className,h=t(),N=t(),D=p(),E=D.getComponent,g=D.removeElement,y=D.moveElement,C=l((function(){return{element:j,parent:k}}),[j,k]),w=E(j.type)||s;return e.exports.jsx(i.Provider,{value:C(),children:e.exports.jsx(c,{disabled:"row"===j.type,onDrop:function(e,o){null==y||y(e,j,{parent:k,position:o})},children:e.exports.jsx(d,{data:j,disabled:"row"===j.type,children:e.exports.jsxs("div",{ref:N,id:j.id||o(),className:n("oak-element","oak-"+j.type,b),children:[(null==w||null===(f=w.render)||void 0===f?void 0:f.call(w,{element:j,parent:k,builder:D,className:n("oak-inner",j.className)}))||null,e.exports.jsxs("div",{className:"oak-options",children:[e.exports.jsx(m,{option:{icon:"clear"},className:"oak-remove",onClick:function(e){null==e||e.preventDefault(),g(j,{parent:k})}}),null===(v=w.options)||void 0===v?void 0:r(v).call(v,(function(o,n){var r;return e.exports.jsx(a,{children:null==o||null===(r=o.render)||void 0===r?void 0:r.call(o,{option:o,className:"oak-option",element:j,elementInnerRef:N,parent:k,component:w,builder:D,index:n})},n)})),w.editable&&e.exports.jsx(u,{element:j,component:w,ref:h,children:e.exports.jsx(m,{option:{icon:"edit"},className:"oak-edit",onClick:function(e){var o;null==e||e.preventDefault(),null===(o=h.current)||void 0===o||o.toggle()}})})]})]})})})})};export{x as E};
//# sourceMappingURL=index.js.map
