import{L as e,m as o,j as n,A as t,X as s,M as r}from"../../vendor.js";import{useRef as l,useCallback as i,Fragment as a}from"react";import{C as c}from"../../defaults.js";import{E as p}from"../../contexts.js";import{a as d}from"../../hooks.js";import{O as m}from"../Option/index.js";import{D as x}from"../Draggable/index.js";import{D as u}from"../Droppable/index.js";import{E as f}from"../Editable/index.js";import{I as v}from"../Icon/index.js";import{T as j}from"../Text/index.js";import{P as h}from"./Property.js";var k=function(k){var N,y,b,g,D,E=k.element,C=k.parent,w=k.className,I=l(),P=l(),O=d(),T=O.getComponent,A=O.removeElement,L=O.duplicateElement,M=O.moveElement,R=i((function(){return{element:E,parent:C}}),[E,C]),S=T(E.type)||c,X=(null==S||null===(N=S.render)||void 0===N?void 0:N.call(S,{element:E,component:S,parent:C,builder:O,className:e("oak-element-content-inner",E.className)}))||null,_=(null===(y=S.settings)||void 0===y||null===(b=y.fields)||void 0===b?void 0:o(b).call(b,(function(e){return!0===e.displayable&&(!e.condition||e.condition(E))})))||[];return n.exports.jsx(p.Provider,{value:R(),children:n.exports.jsx(u,{disabled:"row"===E.type,onDrop:function(e,o){null==M||M(e,E,{parent:C,position:o})},children:n.exports.jsx(x,{data:E,disabled:"row"===E.type,children:n.exports.jsxs("div",{ref:P,id:E.id||t(),className:e("oak-element","oak-"+E.type,w),children:[s(g=["row","col"]).call(g,E.type)?n.exports.jsx("div",{className:"oak-inner",children:X}):n.exports.jsxs("div",{className:"oak-inner oak-with-info",children:[n.exports.jsx("div",{className:"oak-element-icon",children:"function"==typeof(null==S?void 0:S.icon)?S.icon({component:S,className:"oak-icons"}):n.exports.jsx(v,{children:null==S?void 0:S.icon})}),n.exports.jsxs("div",{className:"oak-element-info",children:[n.exports.jsx("div",{className:"oak-element-type",children:n.exports.jsx(j,{children:null==S?void 0:S.name})}),n.exports.jsx("div",{className:"oak-element-content",children:X}),_.length>0&&n.exports.jsx("div",{className:"oak-element-props",children:r(_).call(_,(function(e,o){return n.exports.jsxs(a,{children:[n.exports.jsx(h,{field:e}),o<_.length-1&&n.exports.jsx(j,{name:"core.propertySeparator",default:", "})]},o)}))})]})]}),n.exports.jsxs("div",{className:"oak-options",children:[n.exports.jsx(m,{option:{icon:"clear"},className:"oak-remove",onClick:function(e){null==e||e.preventDefault(),A(E,{parent:C})}}),n.exports.jsx(m,{option:{icon:"content_copy"},className:"oak-duplicate",onClick:function(e){null==e||e.preventDefault(),L(E,{parent:C})}}),null===(D=S.options)||void 0===D?void 0:r(D).call(D,(function(e,o){var t;return n.exports.jsx(a,{children:null==e||null===(t=e.render)||void 0===t?void 0:t.call(e,{option:e,className:"oak-option",element:E,elementInnerRef:P,parent:C,component:S,builder:O,index:o})},o)})),S.editable&&n.exports.jsx(f,{element:E,component:S,ref:I,children:n.exports.jsx(m,{option:{icon:"edit"},className:"oak-edit",onClick:function(e){var o;null==e||e.preventDefault(),null===(o=I.current)||void 0===o||o.toggle()}})})]})]})})})})};export{k as E};
//# sourceMappingURL=index.js.map
