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