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