import e from"@babel/runtime/helpers/defineProperty";import{withStyles as r,Tooltip as t}from"@material-ui/core";import a from"@material-ui/icons/Language";import n from"classnames";import{TEXT_FORMATS as i}from"./Constants.js";import l from"./Elements/ImageElement/ImageElement.js";import s from"./Elements/VideoElement/VideoElement.js";import c from"./style.css.js";import{jsx as o,jsxs as m}from"react/jsx-runtime";function d(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,a)}return t}function h(r){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?d(Object(a),!0).forEach((function(t){e(r,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):d(Object(a)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(a,e))}))}return r}var u=r({tooltip:{height:24,maxWidth:168}})(t),p=r({root:{color:"#bdbdbd",fontSize:14,marginRight:8}})(a),b=function(r){var t=r.attributes,a=r.leaf,i=r.children;return a.bold&&(i=o("strong",{children:i})),a.italic&&(i=o("em",{children:i})),a.underline&&(i=o("u",{children:i})),a.contrastText&&(i=o("span",{className:c.contrastText,children:i})),a.textPrimary&&(i=o("span",{className:c.textPrimary,children:i})),a.bodyLeaf&&(i=o("span",{className:c.body,children:i})),a.captionLeaf&&(i=o("span",{className:c.caption,children:i})),a.codeLeaf&&(i=o("span",{className:c.code,children:i})),a.headerOneLeaf&&(i=o("span",{className:c.headerOne,children:i})),a.headerTwoLeaf&&(i=o("span",{className:c.headerTwo,children:i})),a.headerThreeLeaf&&(i=o("span",{className:c.headerThree,children:i})),o("span",h(h({},t),{},{className:n("token",e({"attr-name":a["attr-name"],"class-name":a["class-name"],boolean:a.boolean,char:a.char,comment:a.comment||a.visiblePragma,constant:a.constant,constants:a.constants,function:a.function,keyword:a.keyword,number:a.number,operator:a.operator,punctuation:a.punctuation,regex:a.regex,selector:a.selector,string:a.string,symbol:a.symbol,tag:a.tag,url:a.url,variable:a.variable},c.invisible,a.invisiblePragma)),children:i}))},f=function(e){var r=e.attributes,t=e.children,a=e.element;switch(a.type){case"block-quote":return o("blockquote",h(h({},r),{},{children:t}));case"bulleted-list":return o("ul",h(h({},r),{},{className:c.bulletedList,children:t}));case"numbered-list":var d,b,f=c.numberedList;return 1===(null===(d=a.children)||void 0===d?void 0:d.length)&&null!==(b=a.children)&&void 0!==b&&b[0].textPrimary&&(f=n(c.listItem,c.listItemPrimary)),o("ol",h(h({},r),{},{className:f,start:null==a?void 0:a.startPosition,children:t}));case"list-item":var v,y,g=c.listItem;return 1===(null===(v=a.children)||void 0===v?void 0:v.length)&&null!==(y=a.children)&&void 0!==y&&y[0].textPrimary&&(g=n(c.listItem,c.listItemPrimary)),o("li",h(h({},r),{},{className:g,children:t}));case"image":return o(l,h({},e));case i.headerOne:return o("div",{className:c.headerOne,children:t});case i.headerTwo:return o("div",{className:c.headerTwo,children:t});case i.headerThree:return o("div",{className:c.headerThree,children:t});case i.body:return o("div",{className:c.body,children:t});case i.caption:return o("div",{className:c.caption,children:t});case i.code:return o("pre",{className:n("language-js",c.codeBlock),children:t});case"video":return o(s,h({},e));case"link":return o(u,{placement:"bottom-start",title:m("span",{className:c.richTextEditorPopoverLinkElement,children:[o(p,{}),o("a",{href:a.url,children:a.url})]}),children:o("a",h(h({},r),{},{href:a.url,className:c.richTextEditorLinkElement,children:t}))});default:return o("div",{className:c.body,children:t})}};export{f as Element,b as Leaf};
