diff --git a/classes/Visualizer/Gutenberg/build/block.js b/classes/Visualizer/Gutenberg/build/block.js index 489e9044..711b15ae 100644 --- a/classes/Visualizer/Gutenberg/build/block.js +++ b/classes/Visualizer/Gutenberg/build/block.js @@ -66,4 +66,4 @@ object-assign * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */class Cc extends r.Component{constructor(e){super(e),this.updateInternalProps=this.updateInternalProps.bind(this),this.createMarkup=this.createMarkup.bind(this),this.onClick=this.onClick.bind(this),this.onBlur=this.onBlur.bind(this),this.update=this.update.bind(this),this.getCursorPosition=this.getCursorPosition.bind(this),this.setCursorPosition=this.setCursorPosition.bind(this),this.scheduledUpdate=this.scheduledUpdate.bind(this),this.setUpdateTime=this.setUpdateTime.bind(this),this.renderLabels=this.renderLabels.bind(this),this.newSpan=this.newSpan.bind(this),this.renderErrorMessage=this.renderErrorMessage.bind(this),this.onScroll=this.onScroll.bind(this),this.showPlaceholder=this.showPlaceholder.bind(this),this.tokenize=this.tokenize.bind(this),this.onKeyPress=this.onKeyPress.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.stopEvent=this.stopEvent.bind(this),this.refContent=null,this.refLabels=null,this.updateInternalProps(),this.renderCount=1,this.state={prevPlaceholder:"",markupText:"",plainText:"",json:"",jsObject:void 0,lines:!1,error:!1},this.props.locale||console.warn("[react-json-editor-ajrm - Deprecation Warning] You did not provide a 'locale' prop for your JSON input - This will be required in a future version. English has been set as a default.")}updateInternalProps(){let e={},t={},n=Sc.dark_vscode_tribute;"theme"in this.props&&"string"==typeof this.props.theme&&this.props.theme in Sc&&(n=Sc[this.props.theme]),e=n,"colors"in this.props&&(e={default:"default"in this.props.colors?this.props.colors.default:e.default,string:"string"in this.props.colors?this.props.colors.string:e.string,number:"number"in this.props.colors?this.props.colors.number:e.number,colon:"colon"in this.props.colors?this.props.colors.colon:e.colon,keys:"keys"in this.props.colors?this.props.colors.keys:e.keys,keys_whiteSpace:"keys_whiteSpace"in this.props.colors?this.props.colors.keys_whiteSpace:e.keys_whiteSpace,primitive:"primitive"in this.props.colors?this.props.colors.primitive:e.primitive,error:"error"in this.props.colors?this.props.colors.error:e.error,background:"background"in this.props.colors?this.props.colors.background:e.background,background_warning:"background_warning"in this.props.colors?this.props.colors.background_warning:e.background_warning}),this.colors=e,t="style"in this.props?{outerBox:"outerBox"in this.props.style?this.props.style.outerBox:{},container:"container"in this.props.style?this.props.style.container:{},warningBox:"warningBox"in this.props.style?this.props.style.warningBox:{},errorMessage:"errorMessage"in this.props.style?this.props.style.errorMessage:{},body:"body"in this.props.style?this.props.style.body:{},labelColumn:"labelColumn"in this.props.style?this.props.style.labelColumn:{},labels:"labels"in this.props.style?this.props.style.labels:{},contentBox:"contentBox"in this.props.style?this.props.style.contentBox:{}}:{outerBox:{},container:{},warningBox:{},errorMessage:{},body:{},labelColumn:{},labels:{},contentBox:{}},this.style=t,this.confirmGood=!("confirmGood"in this.props)||this.props.confirmGood;const r=this.props.height||"610px",a=this.props.width||"479px";this.totalHeight=r,this.totalWidth=a,!("onKeyPressUpdate"in this.props)||this.props.onKeyPressUpdate?this.timer||(this.timer=setInterval(this.scheduledUpdate,100)):this.timer&&(clearInterval(this.timer),this.timer=!1),this.updateTime=!1,this.waitAfterKeyPress="waitAfterKeyPress"in this.props?this.props.waitAfterKeyPress:1e3,this.resetConfiguration="reset"in this.props&&this.props.reset}render(){const e=this.props.id,t=this.state.markupText,n=this.props.error||this.state.error,r=this.colors,o=this.style,i=this.confirmGood,s=this.totalHeight,l=this.totalWidth,u=!!this.props.error||!!n&&"token"in n;return this.renderCount++,a.a.createElement("div",{name:"outer-box",id:e&&e+"-outer-box",style:Dc({display:"block",overflow:"none",height:s,width:l,margin:0,boxSizing:"border-box",position:"relative"},o.outerBox)},i?a.a.createElement("div",{style:{opacity:u?0:1,height:"30px",width:"30px",position:"absolute",top:0,right:0,transform:"translate(-25%,25%)",pointerEvents:"none",transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"}},a.a.createElement("svg",{height:"30px",width:"30px",viewBox:"0 0 100 100"},a.a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"green",opacity:"0.85",d:"M39.363,79L16,55.49l11.347-11.419L39.694,56.49L72.983,23L84,34.085L39.363,79z"}))):void 0,a.a.createElement("div",{name:"container",id:e&&e+"-container",style:Dc({display:"block",height:s,width:l,margin:0,boxSizing:"border-box",overflow:"hidden",fontFamily:"Roboto, sans-serif"},o.container),onClick:this.onClick},a.a.createElement("div",{name:"warning-box",id:e&&e+"-warning-box",style:Dc({display:"block",overflow:"hidden",height:u?"60px":"0px",width:"100%",margin:0,backgroundColor:r.background_warning,transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"},o.warningBox),onClick:this.onClick},a.a.createElement("span",{style:{display:"inline-block",height:"60px",width:"60px",margin:0,boxSizing:"border-box",overflow:"hidden",verticalAlign:"top",pointerEvents:"none"},onClick:this.onClick},a.a.createElement("div",{style:{position:"relative",top:0,left:0,height:"60px",width:"60px",margin:0,pointerEvents:"none"},onClick:this.onClick},a.a.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"},onClick:this.onClick},a.a.createElement("svg",{height:"25px",width:"25px",viewBox:"0 0 100 100"},a.a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"red",d:"M73.9,5.75c0.467-0.467,1.067-0.7,1.8-0.7c0.7,0,1.283,0.233,1.75,0.7l16.8,16.8 c0.467,0.5,0.7,1.084,0.7,1.75c0,0.733-0.233,1.334-0.7,1.801L70.35,50l23.9,23.95c0.5,0.467,0.75,1.066,0.75,1.8 c0,0.667-0.25,1.25-0.75,1.75l-16.8,16.75c-0.534,0.467-1.117,0.7-1.75,0.7s-1.233-0.233-1.8-0.7L50,70.351L26.1,94.25 c-0.567,0.467-1.167,0.7-1.8,0.7c-0.667,0-1.283-0.233-1.85-0.7L5.75,77.5C5.25,77,5,76.417,5,75.75c0-0.733,0.25-1.333,0.75-1.8 L29.65,50L5.75,26.101C5.25,25.667,5,25.066,5,24.3c0-0.666,0.25-1.25,0.75-1.75l16.8-16.8c0.467-0.467,1.05-0.7,1.75-0.7 c0.733,0,1.333,0.233,1.8,0.7L50,29.65L73.9,5.75z"}))))),a.a.createElement("span",{style:{display:"inline-block",height:"60px",width:"calc(100% - 60px)",margin:0,overflow:"hidden",verticalAlign:"top",position:"absolute",pointerEvents:"none"},onClick:this.onClick},this.renderErrorMessage())),a.a.createElement("div",{name:"body",id:e&&e+"-body",style:Dc({display:"flex",overflow:"none",height:u?"calc(100% - 60px)":"100%",width:"",margin:0,resize:"none",fontFamily:"Roboto Mono, Monaco, monospace",fontSize:"11px",backgroundColor:r.background,transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"},o.body),onClick:this.onClick},a.a.createElement("span",{name:"labels",id:e&&e+"-labels",ref:e=>this.refLabels=e,style:Dc({display:"inline-block",boxSizing:"border-box",verticalAlign:"top",height:"100%",width:"44px",margin:0,padding:"5px 0px 5px 10px",overflow:"hidden",color:"#D4D4D4"},o.labelColumn),onClick:this.onClick},this.renderLabels()),a.a.createElement("span",{id:e,ref:e=>this.refContent=e,contentEditable:!0,style:Dc({display:"inline-block",boxSizing:"border-box",verticalAlign:"top",height:"100%",width:"",flex:1,margin:0,padding:"5px",overflowX:"hidden",overflowY:"auto",wordWrap:"break-word",whiteSpace:"pre-line",color:"#D4D4D4",outline:"none"},o.contentBox),dangerouslySetInnerHTML:this.createMarkup(t),onKeyPress:this.onKeyPress,onKeyDown:this.onKeyDown,onClick:this.onClick,onBlur:this.onBlur,onScroll:this.onScroll,onPaste:this.onPaste,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}))))}renderErrorMessage(){const e=this.props.locale||Pc,t=this.props.error||this.state.error,n=this.style;if(t)return a.a.createElement("p",{style:Dc({color:"red",fontSize:"12px",position:"absolute",width:"calc(100% - 60px)",height:"60px",boxSizing:"border-box",margin:0,padding:0,paddingRight:"10px",overflowWrap:"break-word",display:"flex",flexDirection:"column",justifyContent:"center"},n.errorMessage)},Ec(e.format,t))}renderLabels(){const e=this.colors,t=this.style,n=this.props.error||this.state.error,r=n?n.line:-1,o=this.state.lines?this.state.lines:1;let i=new Array(o);for(var s=0;s{const o=n!==r?e.default:"red";return a.a.createElement("div",{key:n,style:Dc({},t.labels,{color:o})},n)})}createMarkup(e){return void 0===e?{__html:""}:{__html:""+e}}newSpan(e,t,n){let r=this.colors,a=t.type,o=t.string,i="";switch(a){case"string":case"number":case"primitive":case"error":i=r[t.type];break;case"key":i=" "===o?r.keys_whiteSpace:r.keys;break;case"symbol":i=":"===o?r.colon:r.default;break;default:i=r.default}return o.length!==o.replace(//g,"").length&&(o=""+o+""),''+o+""}getCursorPosition(e){let t,n=window.getSelection(),r=-1,a=0;if(n.focusNode&&(e=>{for(;null!==e;){if(e===this.refContent)return!0;e=e.parentNode}return!1})(n.focusNode))for(t=n.focusNode,r=n.focusOffset;t&&t!==this.refContent;)if(t.previousSibling)t=t.previousSibling,e&&"BR"===t.nodeName&&a++,r+=t.textContent.length;else if(t=t.parentNode,null===t)break;return r+a}setCursorPosition(e){if([!1,null,void 0].indexOf(e)>-1)return;const t=(e,n,r)=>{if(r||((r=document.createRange()).selectNode(e),r.setStart(e,0)),0===n.count)r.setEnd(e,n.count);else if(e&&n.count>0)if(e.nodeType===Node.TEXT_NODE)e.textContent.length0?(e=>{if(e<0)return;let n=window.getSelection(),r=t(this.refContent,{count:e});r&&(r.collapse(!1),n.removeAllRanges(),n.addRange(r))})(e):this.refContent.focus()}update(e=0,t=!0){const n=this.refContent,r=this.tokenize(n);"onChange"in this.props&&this.props.onChange({plainText:r.indented,markupText:r.markup,json:r.json,jsObject:r.jsObject,lines:r.lines,error:r.error});let a=this.getCursorPosition(r.error)+e;this.setState({plainText:r.indented,markupText:r.markup,json:r.json,jsObject:r.jsObject,lines:r.lines,error:r.error}),this.updateTime=!1,t&&this.setCursorPosition(a)}scheduledUpdate(){if("onKeyPressUpdate"in this.props&&!1===this.props.onKeyPressUpdate)return;const{updateTime:e}=this;!1!==e&&(e>(new Date).getTime()||this.update())}setUpdateTime(){"onKeyPressUpdate"in this.props&&!1===this.props.onKeyPressUpdate||(this.updateTime=(new Date).getTime()+this.waitAfterKeyPress)}stopEvent(e){e&&(e.preventDefault(),e.stopPropagation())}onKeyPress(e){const t=e.ctrlKey||e.metaKey;this.props.viewOnly&&!t&&this.stopEvent(e),t||this.setUpdateTime()}onKeyDown(e){const t=!!this.props.viewOnly,n=e.ctrlKey||e.metaKey;switch(e.key){case"Tab":if(this.stopEvent(e),t)break;document.execCommand("insertText",!1," "),this.setUpdateTime();break;case"Backspace":case"Delete":t&&this.stopEvent(e),this.setUpdateTime();break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":this.setUpdateTime();break;case"a":case"c":t&&!n&&this.stopEvent(e);break;default:t&&this.stopEvent(e)}}onPaste(e){if(this.props.viewOnly)this.stopEvent(e);else{e.preventDefault();var t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}this.update()}onClick(){!("viewOnly"in this.props)||this.props.viewOnly}onBlur(){if("viewOnly"in this.props&&this.props.viewOnly)return;const e=this.refContent,t=this.tokenize(e);"onBlur"in this.props&&this.props.onBlur({plainText:t.indented,markupText:t.markup,json:t.json,jsObject:t.jsObject,lines:t.lines,error:t.error})}onScroll(e){this.refLabels.scrollTop=e.target.scrollTop}componentDidUpdate(){this.updateInternalProps(),this.showPlaceholder()}componentDidMount(){this.showPlaceholder()}componentWillUnmount(){this.timer&&clearInterval(this.timer)}showPlaceholder(){if(!("placeholder"in this.props))return;const{placeholder:e}=this.props;if([void 0,null].indexOf(e)>-1)return;const{prevPlaceholder:t,jsObject:n}=this.state,{resetConfiguration:r}=this,a=Object(Oc.getType)(e);-1===["object","array"].indexOf(a)&&xc.throwError("showPlaceholder","placeholder","either an object or an array");let o=!Object(Oc.identical)(e,t);if(o||r&&void 0!==n&&(o=!Object(Oc.identical)(e,n)),!o)return;const i=this.tokenize(e);this.setState({prevPlaceholder:e,plainText:i.indentation,markupText:i.markup,lines:i.lines,error:i.error})}tokenize(e){if("object"!=typeof e)return console.error("tokenize() expects object type properties only. Got '"+typeof e+"' type instead.");const t=this.props.locale||Pc,n=this.newSpan;if("nodeType"in e){const v=e.cloneNode(!0);if(!v.hasChildNodes())return"";const w=v.childNodes;let M={tokens_unknown:[],tokens_proto:[],tokens_split:[],tokens_fallback:[],tokens_normalize:[],tokens_merge:[],tokens_plainText:"",indented:"",json:"",jsObject:void 0,markup:""};for(var r=0;r-1?(n.active&&n.quarks.push({string:n[n.active],type:t+"-"+n.active}),n[n.active]="",n.active=r,n[n.active]=e):n[r]+=e}}for(var a=0;a-1){r(t,"number");break}case".":if(a0&&"0123456789".indexOf(e.charAt(a+1))>-1&&"0123456789".indexOf(e.charAt(a-1))>-1){r(t,"number");break}default:r(t,"string")}}return n.active&&(n.quarks.push({string:n[n.active],type:t+"-"+n.active}),n[n.active]="",n.active=!1),n.quarks}for(r=0;r0&&o-1){if(1===e.length)return!1;if(n!==r)return!1;for(o=0;o0&&o=~*%\\|/-+!?@^  ";for(o=0;o-1)return!1}}break;case"number":for(o=0;o1)return!1;if(-1==="{[:]},".indexOf(e))return!1;break;case"colon":if(e.length>1)return!1;if(":"!==e)return!1;break;default:return!0}return!0}for(r=0;r-1&&(t=t.slice(t.indexOf("-")+1),"string"!==t&&o.push("string"),o.push("key"),o.push("error"));let i={string:n,length:a,type:t,fallback:o};M.tokens_fallback.push(i)}function i(){const e=M.tokens_normalize.length-1;if(e<1)return!1;for(var t=e;t>=0;t--){const e=M.tokens_normalize[t];switch(e.type){case"space":case"linebreak":break;default:return e}}return!1}let k={brackets:[],stringOpen:!1,isValue:!1};for(r=0;r0){const e=M.tokens_fallback[r-1],t=e.string,n=e.type,a=t.charAt(t.length-1);if("string"===n&&"\\"===a)break}if(k.stringOpen===n){k.stringOpen=!1;break}break;case"primitive":case"string":if(["false","true","null","undefined"].indexOf(n)>-1){const e=M.tokens_normalize.length-1;if(e>=0){if("string"!==M.tokens_normalize[e].type){a.type="primitive";break}a.type="string";break}a.type="primitive";break}if("\n"===n&&!k.stringOpen){a.type="linebreak";break}k.isValue?a.type="string":a.type="key";break;case"space":case"number":k.stringOpen&&(k.isValue?a.type="string":a.type="key")}M.tokens_normalize.push(a)}for(r=0;r0?1:0;function c(e,t,n=0){l={token:e,line:u,reason:t},M.tokens_merge[e+n].type="error"}function d(e,t){if(void 0===e&&console.error("tokenID argument must be an integer."),void 0===t&&console.error("options argument must be an array."),e===M.tokens_merge.length-1)return!1;for(var n=e+1;n-1&&n;default:return!1}}return!1}function p(e,t){if(void 0===e&&console.error("tokenID argument must be an integer."),void 0===t&&console.error("options argument must be an array."),0===e)return!1;for(var n=e-1;n>=0;n--){const e=M.tokens_merge[n];switch(e.type){case"space":case"linebreak":break;case"symbol":case"colon":return t.indexOf(e.string)>-1;default:return!1}}return!1}function m(e){if(void 0===e&&console.error("tokenID argument must be an integer."),0===e)return!1;for(var t=e-1;t>=0;t--){const e=M.tokens_merge[t];switch(e.type){case"space":case"linebreak":break;default:return e.type}}return!1}k={brackets:[],stringOpen:!1,isValue:!1};let T=[];for(r=0;r0&&!p(r,[":","[",","])){c(r,Ec(t.invalidToken.tokenSequence.permitted,{firstToken:"[",secondToken:[":","[",","]}));break}if("{"===n&&p(r,["{"])){c(r,Ec(t.invalidToken.double,{token:"{"}));break}k.brackets.push(n),k.isValue="["===k.brackets[k.brackets.length-1],T.push({i:r,line:u,string:n});break;case"}":case"]":if("}"===n&&"{"!==k.brackets[k.brackets.length-1]){c(r,Ec(t.brace.curly.missingOpen));break}if("}"===n&&p(r,[","])){c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:",",secondToken:"}"}));break}if("]"===n&&"["!==k.brackets[k.brackets.length-1]){c(r,Ec(t.brace.square.missingOpen));break}if("]"===n&&p(r,[":"])){c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:":",secondToken:"]"}));break}k.brackets.pop(),k.isValue="["===k.brackets[k.brackets.length-1],T.push({i:r,line:u,string:n});break;case",":if(o=p(r,["{"]),o){if(d(r,["}"])){c(r,Ec(t.brace.curly.cannotWrap,{token:","}));break}c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:"{",secondToken:","}));break}if(d(r,["}",",","]"])){c(r,Ec(t.noTrailingOrLeadingComma));break}switch(o=m(r),o){case"key":case"colon":c(r,Ec(t.invalidToken.termSequence.prohibited,{firstTerm:"key"===o?t.types.key:t.symbols.colon,secondTerm:t.symbols.comma}));break;case"symbol":if(p(r,["{"])){c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:"{",secondToken:","}));break}}k.isValue="["===k.brackets[k.brackets.length-1]}M.json+=n;break;case"colon":if(o=p(r,["["]),o&&d(r,["]"])){c(r,Ec(t.brace.square.cannotWrap,{token:":"}));break}if(o){c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:"[",secondToken:":"}));break}if("key"!==m(r)){c(r,Ec(t.invalidToken.termSequence.permitted,{firstTerm:t.symbols.colon,secondTerm:t.types.key}));break}if(d(r,["}","]"])){c(r,Ec(t.invalidToken.termSequence.permitted,{firstTerm:t.symbols.colon,secondTerm:t.types.value}));break}k.isValue=!0,M.json+=n;break;case"key":case"string":let e=n.charAt(0),i=n.charAt(n.length-1);L.indexOf(e);if(-1===L.indexOf(e)&&-1!==L.indexOf(i)){c(r,Ec(t.string.missingOpen,{quote:e}));break}if(-1===L.indexOf(i)&&-1!==L.indexOf(e)){c(r,Ec(t.string.missingClose,{quote:e}));break}if(L.indexOf(e)>-1&&e!==i){c(r,Ec(t.string.missingClose,{quote:e}));break}if("string"===a&&-1===L.indexOf(e)&&-1===L.indexOf(i)){c(r,Ec(t.string.mustBeWrappedByQuotes));break}if("key"===a&&d(r,["}","]"])&&c(r,Ec(t.invalidToken.termSequence.permitted,{firstTerm:t.types.key,secondTerm:t.symbols.colon})),-1===L.indexOf(e)&&-1===L.indexOf(i))for(var h=0;h0&&!isNaN(M.tokens_merge[r-1])){M.tokens_merge[r-1]+=M.tokens_merge[r],c(r,Ec(t.key.numberAndLetterMissingQuotes));break}c(r,Ec(t.key.spaceMissingQuotes));break}if("key"===a&&!p(r,["{",","])){c(r,Ec(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["{",","]}));break}if("string"===a&&!p(r,["[",":",","])){c(r,Ec(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["[",":",","]}));break}if("key"===a&&k.isValue){c(r,Ec(t.string.unexpectedKey));break}if("string"===a&&!k.isValue){c(r,Ec(t.key.unexpectedString));break}M.json+=n;break;case"number":case"primitive":if(p(r,["{"]))M.tokens_merge[r].type="key",a=M.tokens_merge[r].type,n='"'+n+'"';else if("key"===m(r))M.tokens_merge[r].type="key",a=M.tokens_merge[r].type;else if(!p(r,["[",":",","])){c(r,Ec(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["[",":",","]}));break}"key"!==a&&(k.isValue||(M.tokens_merge[r].type="key",a=M.tokens_merge[r].type,n='"'+n+'"')),"primitive"===a&&"undefined"===n&&c(r,Ec(t.invalidToken.useInstead,{badToken:"undefined",goodToken:"null"})),M.json+=n}}let D="";for(r=0;r0;){r=!1;for(var _=0;_-1&&f(_)}if(n++,!r)break;if(n>=e)break}if(T.length>0){const e=T[0].string,n=T[0].i,r="["===e?"]":"}";u=T[0].line,c(n,Ec(t.brace["]"===r?"square":"curly"].missingClose))}}if(!l&&-1===[void 0,""].indexOf(M.json))try{M.jsObject=JSON.parse(M.json)}catch(e){const n=e.message,r=n.indexOf("position");if(-1===r)throw new Error("Error parsing failed");const a=n.substring(r+9,n.length),o=parseInt(a);let i=0,s=0,d=!1,p=1,m=!1;for(;i=o));)s++,M.tokens_merge[s+1]||(m=!0);u=p;let h=0;for(let e=0;e0?h+1:1:(h%2==0&&0!==h||-1==="'\"bfnrt".indexOf(n)&&c(s,Ec(t.invalidToken.unexpected,{token:"\\"})),h=0)}l||c(s,Ec(t.invalidToken.unexpected,{token:d.string}))}let S=1,O=0;function y(e=!1){return function(e=!1){return S++,O>0||e?"
":""}(e)+function(){for(var e=[],t=0;t<2*O;t++)e.push(" ");return e.join("")}()}if(!l)for(r=0;r0?["[","{"].indexOf(M.tokens_merge[r-1].string)>-1?"":y(t):"";M.markup+=a+n(r,e,O);break;case",":M.markup+=n(r,e,O)}}}if(l){let e=1;function b(e){let t=0;for(var n=0;n-1&&t++;return t}S=1;for(r=0;r{let t="",n="",r="";switch(e){case",":t="symbol",n=e,r=e,a.isValue="["===a.brackets[a.brackets.length-1];break;case":":t="symbol",n=e,r=e,a.isValue=!0;break;case"{":case"[":t="symbol",n=e,r=e,a.brackets.push(e),a.isValue="["===a.brackets[a.brackets.length-1];break;case"}":case"]":t="symbol",n=e,r=e,a.brackets.pop(),a.isValue="["===a.brackets[a.brackets.length-1];break;case"undefined":t="primitive",n=e,r=void 0;break;case"null":t="primitive",n=e,r=null;break;case"false":t="primitive",n=e,r=!1;break;case"true":t="primitive",n=e,r=!0;break;default:const i=e.charAt(0);if("'\"".indexOf(i)>-1){if(t=a.isValue?"string":"key","key"===t&&(n=function(e){if(0===e.length)return e;if(['""',"''"].indexOf(e)>-1)return"''";let t=!1;for(var n=0;n<2;n++)if([e.charAt(0),e.charAt(e.length-1)].indexOf(['"',"'"][n])>-1){t=!0;break}t&&e.length>=2&&(e=e.slice(1,-1));const r=e.replace(/\w/g,""),a=(e.replace(/\W+/g,""),((e,t)=>{let n=!1;for(var r=0;r0||n)})(r,e));if((e=>{for(var t=0;t-1)return!0;return!1})(r)){let t="";const n=e.split("");for(var o=0;o-1&&(e="\\"+e),t+=e}e=t}return a?e:"'"+e+"'"}(e)),"string"===t){n="";const t=e.slice(1,-1).split("");for(var o=0;o-1&&(e="\\"+e),n+=e}n="'"+n+"'"}r=n;break}if(!isNaN(e)){t="number",n=e,r=Number(e);break}if(e.length>0&&!a.isValue){t="key",n=e,n.indexOf(" ")>-1&&(n="'"+n+"'"),r=n;break}}return{type:t,string:n,value:r,depth:a.brackets.length}});let o="";for(r=0;r0?"\n":"")+t.join("")}let i="";for(r=0;r0?a.tokens[r-1]:"";-1==="[{".indexOf(n.string)?i+=Y(e.depth)+e.string:i+=e.string;break;case":":i+=e.string+" ";break;case",":i+=e.string+Y(e.depth);break;default:i+=e.string}}let s=1;function T(e){var t=[];e>0&&s++;for(var n=0;n<2*e;n++)t.push(" ");return(e>0?"
":"")+t.join("")}let l="";const u=a.tokens.length-1;for(r=0;r0?a.tokens[r-1]:"";-1==="[{".indexOf(o.string)?l+=T(e.depth)+(u===r?"
":"")+t:l+=t;break;case":":l+=t+" ";break;case",":l+=t+T(e.depth);break;default:l+=t}}return s+=2,{tokens:a.tokens,noSpaces:o,indented:i,json:JSON.stringify(e),jsObject:e,markup:l,lines:s}}}}var Hc=Cc,zc=n(133),Ac=n.n(zc);function Rc(e){return(Rc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Nc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Fc(e,t){for(var n=0;n=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(e)&&wp.element.createElement(sa,{chart:this.props.chart,edit:this.props.edit}),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(e)&&wp.element.createElement(Ta,{chart:this.props.chart,edit:this.props.edit}),0<=["pie"].indexOf(e)&&wp.element.createElement(sd,null,wp.element.createElement(Ua,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(io,{chart:this.props.chart,edit:this.props.edit})),0<=["area","scatter","line"].indexOf(e)&&wp.element.createElement(ko,{chart:this.props.chart,edit:this.props.edit}),0<=["bar","column"].indexOf(e)&&wp.element.createElement(Ao,{chart:this.props.chart,edit:this.props.edit}),0<=["candlestick"].indexOf(e)&&wp.element.createElement(Xo,{chart:this.props.chart,edit:this.props.edit}),0<=["geo"].indexOf(e)&&wp.element.createElement(sd,null,wp.element.createElement(hi,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Oi,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Ui,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(os,{chart:this.props.chart,edit:this.props.edit})),0<=["gauge"].indexOf(e)&&wp.element.createElement(ks,{chart:this.props.chart,edit:this.props.edit}),0<=["timeline"].indexOf(e)&&wp.element.createElement(Ns,{chart:this.props.chart,edit:this.props.edit}),0<=["tabular","dataTable"].indexOf(e)&&wp.element.createElement(sd,null,wp.element.createElement(nl,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(gl,{chart:this.props.chart,edit:this.props.edit})),0<=["combo"].indexOf(e)&&wp.element.createElement(El,{chart:this.props.chart,edit:this.props.edit}),-1>=["timeline","bubble","gauge","geo","pie","tabular","dataTable"].indexOf(e)&&wp.element.createElement(Zl,{chart:this.props.chart,edit:this.props.edit}),"tabular"===e&&"GoogleCharts"===t&&wp.element.createElement(Zl,{chart:this.props.chart,edit:this.props.edit}),0<=["bubble"].indexOf(e)&&wp.element.createElement(Su,{chart:this.props.chart,edit:this.props.edit}),0<=["pie"].indexOf(e)&&wp.element.createElement(pu,{chart:this.props.chart,edit:this.props.edit}),"DataTable"===t&&wp.element.createElement(Ju,{chart:this.props.chart,edit:this.props.edit}),"DataTable"!==t&&wp.element.createElement(uc,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Yc,{chart:this.props.chart,edit:this.props.edit}),"DataTable"!==t&&wp.element.createElement(Zc,{chart:this.props.chart,edit:this.props.edit}))}}])&&ed(t.prototype,n),r&&ed(t,r),Object.defineProperty(t,"prototype",{writable:!1}),o}(id);function ud(e){return(ud="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function cd(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */cd=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",i=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=t&&t.prototype instanceof d?t:d,o=Object.create(a.prototype),i=new k(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return Y()}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var s=v(i,n);if(s){if(s===c)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=u(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===c)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}(e,n,i),o}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var c={};function d(){}function p(){}function m(){}var h={};s(h,a,(function(){return this}));var f=Object.getPrototypeOf,_=f&&f(f(L([])));_&&_!==t&&n.call(_,a)&&(h=_);var y=m.prototype=d.prototype=Object.create(h);function b(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var r;this._invoke=function(a,o){function i(){return new t((function(r,i){!function r(a,o,i,s){var l=u(e[a],e,o);if("throw"!==l.type){var c=l.arg,d=c.value;return d&&"object"==ud(d)&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(d).then((function(e){c.value=e,i(c)}),(function(e){return r("throw",e,i,s)}))}s(l.arg)}(a,o,r,i)}))}return r=r?r.then(i,i):i()}}function v(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,v(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function L(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(s&&l){if(this.prev=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),M(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;M(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}function dd(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function pd(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){dd(o,r,a,i,s,"next",e)}function s(e){dd(o,r,a,i,s,"throw",e)}i(void 0)}))}}function md(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hd(e,t){for(var n=0;n=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(s&&l){if(this.prev=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),M(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;M(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}function Tp(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function Dp(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Tp(o,r,a,i,s,"next",e)}function s(e){Tp(o,r,a,i,s,"throw",e)}i(void 0)}))}}function Sp(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Op(e,t){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];this.setState({isLoading:"uploadData",isScheduled:t}),Rp({path:"/visualizer/v1/upload-data?url=".concat(this.state.chart["visualizer-chart-url"]),method:"POST"}).then((function(t){if(2<=Object.keys(t).length){var n=kp({},e.state.chart);n["visualizer-source"]="Visualizer_Source_Csv_Remote",n["visualizer-default-data"]=0,n["visualizer-series"]=t.series,n["visualizer-data"]=t.data;var r=n["visualizer-series"],a=n["visualizer-settings"],o=r,i="series";return"pie"===n["visualizer-chart-type"]&&(o=n["visualizer-data"],i="slices"),o.map((function(e,t){if("pie"===n["visualizer-chart-type"]||0!==t){var r="pie"!==n["visualizer-chart-type"]?t-1:t;void 0===a[i][r]&&(a[i][r]={},a[i][r].temp=1)}})),a[i]=a[i].filter((function(e,t){return t<("pie"!==n["visualizer-chart-type"]?o.length-1:o.length)})),n["visualizer-settings"]=a,e.setState({chart:n,isModified:!0,isLoading:!1}),t}e.setState({isLoading:!1})}),(function(t){return e.setState({isLoading:!1}),t}))}},{key:"getChartData",value:(a=Dp(Yp().mark((function e(t){var n,r;return Yp().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setState({isLoading:"getChartData"});case 2:return e.next=4,Ap({path:"wp/v2/visualizer/".concat(t)});case 4:n=e.sent,(r=kp({},this.state.chart))["visualizer-source"]="Visualizer_Source_Csv",r["visualizer-default-data"]=0,r["visualizer-series"]=n.chart_data["visualizer-series"],r["visualizer-data"]=n.chart_data["visualizer-data"],this.setState({isLoading:!1,chart:r});case 11:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"editChartData",value:function(e,t){var n=kp({},this.state.chart),r=[],a=kp({},n["visualizer-settings"]),o=n["visualizer-chart-type"];e[0].map((function(t,n){r[n]={label:t,type:e[1][n]}})),e.splice(0,2);var i=r,s="series";switch(o){case"pie":i=e,s="slices",e.map((function(e,t){switch(r[1].type){case"number":e[1]=parseFloat(e[1])}}));break;case"tabular":e.map((function(e,t){r.map((function(t,n){switch(t.type){case"boolean":"string"==typeof e[n]&&(e[n]="true"===e[n])}}))}))}i.map((function(e,t){if("pie"===o||0!==t){var n="pie"!==o?t-1:t;Array.isArray(a[s])&&void 0===a[s][n]&&(a[s][n]={},a[s][n].temp=1)}})),Array.isArray(a[s])&&(a[s]=a[s].filter((function(e,t){return t<(-1>=["pie","tabular","dataTable"].indexOf(o)?i.length-1:i.length)}))),n["visualizer-source"]=t,n["visualizer-default-data"]=0,n["visualizer-data"]=e,n["visualizer-series"]=r,n["visualizer-settings"]=a,n["visualizer-chart-url"]="",this.setState({chart:n,isModified:!0,isScheduled:!1})}},{key:"updateChart",value:function(){var e=this;this.setState({isLoading:"updateChart"});var t=this.state.chart;!1===this.state.isScheduled&&(t["visualizer-chart-schedule"]="");var n="series";"pie"===t["visualizer-chart-type"]&&(n="slices"),-1>=["bubble","timeline"].indexOf(t["visualizer-chart-type"])&&Object.keys(t["visualizer-settings"][n]).map((function(e){void 0!==t["visualizer-settings"][n][e]&&void 0!==t["visualizer-settings"][n][e].temp&&delete t["visualizer-settings"][n][e].temp})),Rp({path:"/visualizer/v1/update-chart?id=".concat(this.props.attributes.id),method:"POST",data:t}).then((function(t){return e.setState({isLoading:!1,isModified:!1}),t}),(function(e){return e}))}},{key:"render",value:function(){var e=this;return"error"===this.state.route?wp.element.createElement(Vp,{status:"error",isDismissible:!1},wp.element.createElement(Up,{icon:"chart-pie"}),Hp("This chart is not available; it might have been deleted. Please delete this block and resubmit your chart.")):"renderChart"===this.state.route&&null!==this.state.chart?wp.element.createElement(gp,{id:this.props.attributes.id,chart:this.state.chart,className:this.props.className,editChart:this.editChart}):wp.element.createElement("div",{className:"visualizer-settings"},wp.element.createElement("div",{className:"visualizer-settings__title"},wp.element.createElement(Up,{icon:"chart-pie"}),Hp("Visualizer")),"home"===this.state.route&&wp.element.createElement("div",{className:"visualizer-settings__content"},wp.element.createElement("div",{className:"visualizer-settings__content-description"},Hp("Make a new chart or display an existing one?")),wp.element.createElement("a",{href:visualizerLocalize.adminPage,target:"_blank",className:"visualizer-settings__content-option"},wp.element.createElement("span",{className:"visualizer-settings__content-option-title"},Hp("Create a new chart")),wp.element.createElement("div",{className:"visualizer-settings__content-option-icon"},wp.element.createElement(Up,{icon:"arrow-right-alt2"}))),wp.element.createElement("div",{className:"visualizer-settings__content-option",onClick:function(){e.setState({route:"showCharts"}),e.props.setAttributes({route:"showCharts"})}},wp.element.createElement("span",{className:"visualizer-settings__content-option-title"},Hp("Display an existing chart")),wp.element.createElement("div",{className:"visualizer-settings__content-option-icon"},wp.element.createElement(Up,{icon:"arrow-right-alt2"})))),("getChart"===this.state.isLoading||"chartSelect"===this.state.route&&null===this.state.chart||"renderChart"===this.state.route&&null===this.state.chart)&&wp.element.createElement(Gp,null,wp.element.createElement(qp,null)),"showCharts"===this.state.route&&!1===this.state.isLoading&&wp.element.createElement(De,{getChart:this.getChart}),"chartSelect"===this.state.route&&null!==this.state.chart&&wp.element.createElement(ep,{id:this.props.attributes.id,attributes:this.props.attributes,chart:this.state.chart,editSettings:this.editSettings,editPermissions:this.editPermissions,url:this.state.url,readUploadedFile:this.readUploadedFile,editURL:this.editURL,editSchedule:this.editSchedule,editJSONURL:this.editJSONURL,editJSONHeaders:this.editJSONHeaders,editJSONSchedule:this.editJSONSchedule,editJSONRoot:this.editJSONRoot,editJSONPaging:this.editJSONPaging,JSONImportData:this.JSONImportData,editDatabaseSchedule:this.editDatabaseSchedule,databaseImportData:this.databaseImportData,uploadData:this.uploadData,getChartData:this.getChartData,editChartData:this.editChartData,isLoading:this.state.isLoading}),wp.element.createElement("div",{className:"visualizer-settings__controls"},("showCharts"===this.state.route||"chartSelect"===this.state.route)&&wp.element.createElement(Jp,null,wp.element.createElement(Bp,{isDefault:!0,isLarge:!0,onClick:function(){var t;"showCharts"===e.state.route?t="home":"chartSelect"===e.state.route&&(t="showCharts"),e.setState({route:t}),e.props.setAttributes({route:t})}},Hp("Back")),"chartSelect"===this.state.route&&wp.element.createElement(Wp,null,!1===this.state.isModified?wp.element.createElement(Bp,{isDefault:!0,isLarge:!0,className:"visualizer-bttn-done",onClick:function(){e.setState({route:"renderChart",isModified:!0}),e.props.setAttributes({route:"renderChart"})}},Hp("Done")):wp.element.createElement(Bp,{isPrimary:!0,isLarge:!0,className:"visualizer-bttn-save",isBusy:"updateChart"===this.state.isLoading,disabled:"updateChart"===this.state.isLoading,onClick:this.updateChart},Hp("Save"))))))}}])&&Op(t.prototype,n),r&&Op(t,r),Object.defineProperty(t,"prototype",{writable:!1}),l}(Fp),Kp=(n(153),wp.i18n.__),Zp=wp.blocks.registerBlockType;t.default=Zp("visualizer/chart",{title:Kp("Visualizer Chart"),description:Kp("A simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages."),category:"common",icon:"chart-pie",keywords:[Kp("Visualizer"),Kp("Chart"),Kp("Google Charts")],attributes:{id:{type:"number"},lazy:{default:"-1",type:"string"},route:{type:"string"}},supports:{customClassName:!1},edit:$p,save:function(){return null}})}]); \ No newline at end of file + */class Cc extends r.Component{constructor(e){super(e),this.updateInternalProps=this.updateInternalProps.bind(this),this.createMarkup=this.createMarkup.bind(this),this.onClick=this.onClick.bind(this),this.onBlur=this.onBlur.bind(this),this.update=this.update.bind(this),this.getCursorPosition=this.getCursorPosition.bind(this),this.setCursorPosition=this.setCursorPosition.bind(this),this.scheduledUpdate=this.scheduledUpdate.bind(this),this.setUpdateTime=this.setUpdateTime.bind(this),this.renderLabels=this.renderLabels.bind(this),this.newSpan=this.newSpan.bind(this),this.renderErrorMessage=this.renderErrorMessage.bind(this),this.onScroll=this.onScroll.bind(this),this.showPlaceholder=this.showPlaceholder.bind(this),this.tokenize=this.tokenize.bind(this),this.onKeyPress=this.onKeyPress.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.stopEvent=this.stopEvent.bind(this),this.refContent=null,this.refLabels=null,this.updateInternalProps(),this.renderCount=1,this.state={prevPlaceholder:"",markupText:"",plainText:"",json:"",jsObject:void 0,lines:!1,error:!1},this.props.locale||console.warn("[react-json-editor-ajrm - Deprecation Warning] You did not provide a 'locale' prop for your JSON input - This will be required in a future version. English has been set as a default.")}updateInternalProps(){let e={},t={},n=Sc.dark_vscode_tribute;"theme"in this.props&&"string"==typeof this.props.theme&&this.props.theme in Sc&&(n=Sc[this.props.theme]),e=n,"colors"in this.props&&(e={default:"default"in this.props.colors?this.props.colors.default:e.default,string:"string"in this.props.colors?this.props.colors.string:e.string,number:"number"in this.props.colors?this.props.colors.number:e.number,colon:"colon"in this.props.colors?this.props.colors.colon:e.colon,keys:"keys"in this.props.colors?this.props.colors.keys:e.keys,keys_whiteSpace:"keys_whiteSpace"in this.props.colors?this.props.colors.keys_whiteSpace:e.keys_whiteSpace,primitive:"primitive"in this.props.colors?this.props.colors.primitive:e.primitive,error:"error"in this.props.colors?this.props.colors.error:e.error,background:"background"in this.props.colors?this.props.colors.background:e.background,background_warning:"background_warning"in this.props.colors?this.props.colors.background_warning:e.background_warning}),this.colors=e,t="style"in this.props?{outerBox:"outerBox"in this.props.style?this.props.style.outerBox:{},container:"container"in this.props.style?this.props.style.container:{},warningBox:"warningBox"in this.props.style?this.props.style.warningBox:{},errorMessage:"errorMessage"in this.props.style?this.props.style.errorMessage:{},body:"body"in this.props.style?this.props.style.body:{},labelColumn:"labelColumn"in this.props.style?this.props.style.labelColumn:{},labels:"labels"in this.props.style?this.props.style.labels:{},contentBox:"contentBox"in this.props.style?this.props.style.contentBox:{}}:{outerBox:{},container:{},warningBox:{},errorMessage:{},body:{},labelColumn:{},labels:{},contentBox:{}},this.style=t,this.confirmGood=!("confirmGood"in this.props)||this.props.confirmGood;const r=this.props.height||"610px",a=this.props.width||"479px";this.totalHeight=r,this.totalWidth=a,!("onKeyPressUpdate"in this.props)||this.props.onKeyPressUpdate?this.timer||(this.timer=setInterval(this.scheduledUpdate,100)):this.timer&&(clearInterval(this.timer),this.timer=!1),this.updateTime=!1,this.waitAfterKeyPress="waitAfterKeyPress"in this.props?this.props.waitAfterKeyPress:1e3,this.resetConfiguration="reset"in this.props&&this.props.reset}render(){const e=this.props.id,t=this.state.markupText,n=this.props.error||this.state.error,r=this.colors,o=this.style,i=this.confirmGood,s=this.totalHeight,l=this.totalWidth,u=!!this.props.error||!!n&&"token"in n;return this.renderCount++,a.a.createElement("div",{name:"outer-box",id:e&&e+"-outer-box",style:Dc({display:"block",overflow:"none",height:s,width:l,margin:0,boxSizing:"border-box",position:"relative"},o.outerBox)},i?a.a.createElement("div",{style:{opacity:u?0:1,height:"30px",width:"30px",position:"absolute",top:0,right:0,transform:"translate(-25%,25%)",pointerEvents:"none",transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"}},a.a.createElement("svg",{height:"30px",width:"30px",viewBox:"0 0 100 100"},a.a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"green",opacity:"0.85",d:"M39.363,79L16,55.49l11.347-11.419L39.694,56.49L72.983,23L84,34.085L39.363,79z"}))):void 0,a.a.createElement("div",{name:"container",id:e&&e+"-container",style:Dc({display:"block",height:s,width:l,margin:0,boxSizing:"border-box",overflow:"hidden",fontFamily:"Roboto, sans-serif"},o.container),onClick:this.onClick},a.a.createElement("div",{name:"warning-box",id:e&&e+"-warning-box",style:Dc({display:"block",overflow:"hidden",height:u?"60px":"0px",width:"100%",margin:0,backgroundColor:r.background_warning,transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"},o.warningBox),onClick:this.onClick},a.a.createElement("span",{style:{display:"inline-block",height:"60px",width:"60px",margin:0,boxSizing:"border-box",overflow:"hidden",verticalAlign:"top",pointerEvents:"none"},onClick:this.onClick},a.a.createElement("div",{style:{position:"relative",top:0,left:0,height:"60px",width:"60px",margin:0,pointerEvents:"none"},onClick:this.onClick},a.a.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"},onClick:this.onClick},a.a.createElement("svg",{height:"25px",width:"25px",viewBox:"0 0 100 100"},a.a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"red",d:"M73.9,5.75c0.467-0.467,1.067-0.7,1.8-0.7c0.7,0,1.283,0.233,1.75,0.7l16.8,16.8 c0.467,0.5,0.7,1.084,0.7,1.75c0,0.733-0.233,1.334-0.7,1.801L70.35,50l23.9,23.95c0.5,0.467,0.75,1.066,0.75,1.8 c0,0.667-0.25,1.25-0.75,1.75l-16.8,16.75c-0.534,0.467-1.117,0.7-1.75,0.7s-1.233-0.233-1.8-0.7L50,70.351L26.1,94.25 c-0.567,0.467-1.167,0.7-1.8,0.7c-0.667,0-1.283-0.233-1.85-0.7L5.75,77.5C5.25,77,5,76.417,5,75.75c0-0.733,0.25-1.333,0.75-1.8 L29.65,50L5.75,26.101C5.25,25.667,5,25.066,5,24.3c0-0.666,0.25-1.25,0.75-1.75l16.8-16.8c0.467-0.467,1.05-0.7,1.75-0.7 c0.733,0,1.333,0.233,1.8,0.7L50,29.65L73.9,5.75z"}))))),a.a.createElement("span",{style:{display:"inline-block",height:"60px",width:"calc(100% - 60px)",margin:0,overflow:"hidden",verticalAlign:"top",position:"absolute",pointerEvents:"none"},onClick:this.onClick},this.renderErrorMessage())),a.a.createElement("div",{name:"body",id:e&&e+"-body",style:Dc({display:"flex",overflow:"none",height:u?"calc(100% - 60px)":"100%",width:"",margin:0,resize:"none",fontFamily:"Roboto Mono, Monaco, monospace",fontSize:"11px",backgroundColor:r.background,transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"},o.body),onClick:this.onClick},a.a.createElement("span",{name:"labels",id:e&&e+"-labels",ref:e=>this.refLabels=e,style:Dc({display:"inline-block",boxSizing:"border-box",verticalAlign:"top",height:"100%",width:"44px",margin:0,padding:"5px 0px 5px 10px",overflow:"hidden",color:"#D4D4D4"},o.labelColumn),onClick:this.onClick},this.renderLabels()),a.a.createElement("span",{id:e,ref:e=>this.refContent=e,contentEditable:!0,style:Dc({display:"inline-block",boxSizing:"border-box",verticalAlign:"top",height:"100%",width:"",flex:1,margin:0,padding:"5px",overflowX:"hidden",overflowY:"auto",wordWrap:"break-word",whiteSpace:"pre-line",color:"#D4D4D4",outline:"none"},o.contentBox),dangerouslySetInnerHTML:this.createMarkup(t),onKeyPress:this.onKeyPress,onKeyDown:this.onKeyDown,onClick:this.onClick,onBlur:this.onBlur,onScroll:this.onScroll,onPaste:this.onPaste,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}))))}renderErrorMessage(){const e=this.props.locale||Pc,t=this.props.error||this.state.error,n=this.style;if(t)return a.a.createElement("p",{style:Dc({color:"red",fontSize:"12px",position:"absolute",width:"calc(100% - 60px)",height:"60px",boxSizing:"border-box",margin:0,padding:0,paddingRight:"10px",overflowWrap:"break-word",display:"flex",flexDirection:"column",justifyContent:"center"},n.errorMessage)},Ec(e.format,t))}renderLabels(){const e=this.colors,t=this.style,n=this.props.error||this.state.error,r=n?n.line:-1,o=this.state.lines?this.state.lines:1;let i=new Array(o);for(var s=0;s{const o=n!==r?e.default:"red";return a.a.createElement("div",{key:n,style:Dc({},t.labels,{color:o})},n)})}createMarkup(e){return void 0===e?{__html:""}:{__html:""+e}}newSpan(e,t,n){let r=this.colors,a=t.type,o=t.string,i="";switch(a){case"string":case"number":case"primitive":case"error":i=r[t.type];break;case"key":i=" "===o?r.keys_whiteSpace:r.keys;break;case"symbol":i=":"===o?r.colon:r.default;break;default:i=r.default}return o.length!==o.replace(//g,"").length&&(o=""+o+""),''+o+""}getCursorPosition(e){let t,n=window.getSelection(),r=-1,a=0;if(n.focusNode&&(e=>{for(;null!==e;){if(e===this.refContent)return!0;e=e.parentNode}return!1})(n.focusNode))for(t=n.focusNode,r=n.focusOffset;t&&t!==this.refContent;)if(t.previousSibling)t=t.previousSibling,e&&"BR"===t.nodeName&&a++,r+=t.textContent.length;else if(t=t.parentNode,null===t)break;return r+a}setCursorPosition(e){if([!1,null,void 0].indexOf(e)>-1)return;const t=(e,n,r)=>{if(r||((r=document.createRange()).selectNode(e),r.setStart(e,0)),0===n.count)r.setEnd(e,n.count);else if(e&&n.count>0)if(e.nodeType===Node.TEXT_NODE)e.textContent.length0?(e=>{if(e<0)return;let n=window.getSelection(),r=t(this.refContent,{count:e});r&&(r.collapse(!1),n.removeAllRanges(),n.addRange(r))})(e):this.refContent.focus()}update(e=0,t=!0){const n=this.refContent,r=this.tokenize(n);"onChange"in this.props&&this.props.onChange({plainText:r.indented,markupText:r.markup,json:r.json,jsObject:r.jsObject,lines:r.lines,error:r.error});let a=this.getCursorPosition(r.error)+e;this.setState({plainText:r.indented,markupText:r.markup,json:r.json,jsObject:r.jsObject,lines:r.lines,error:r.error}),this.updateTime=!1,t&&this.setCursorPosition(a)}scheduledUpdate(){if("onKeyPressUpdate"in this.props&&!1===this.props.onKeyPressUpdate)return;const{updateTime:e}=this;!1!==e&&(e>(new Date).getTime()||this.update())}setUpdateTime(){"onKeyPressUpdate"in this.props&&!1===this.props.onKeyPressUpdate||(this.updateTime=(new Date).getTime()+this.waitAfterKeyPress)}stopEvent(e){e&&(e.preventDefault(),e.stopPropagation())}onKeyPress(e){const t=e.ctrlKey||e.metaKey;this.props.viewOnly&&!t&&this.stopEvent(e),t||this.setUpdateTime()}onKeyDown(e){const t=!!this.props.viewOnly,n=e.ctrlKey||e.metaKey;switch(e.key){case"Tab":if(this.stopEvent(e),t)break;document.execCommand("insertText",!1," "),this.setUpdateTime();break;case"Backspace":case"Delete":t&&this.stopEvent(e),this.setUpdateTime();break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":this.setUpdateTime();break;case"a":case"c":t&&!n&&this.stopEvent(e);break;default:t&&this.stopEvent(e)}}onPaste(e){if(this.props.viewOnly)this.stopEvent(e);else{e.preventDefault();var t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}this.update()}onClick(){!("viewOnly"in this.props)||this.props.viewOnly}onBlur(){if("viewOnly"in this.props&&this.props.viewOnly)return;const e=this.refContent,t=this.tokenize(e);"onBlur"in this.props&&this.props.onBlur({plainText:t.indented,markupText:t.markup,json:t.json,jsObject:t.jsObject,lines:t.lines,error:t.error})}onScroll(e){this.refLabels.scrollTop=e.target.scrollTop}componentDidUpdate(){this.updateInternalProps(),this.showPlaceholder()}componentDidMount(){this.showPlaceholder()}componentWillUnmount(){this.timer&&clearInterval(this.timer)}showPlaceholder(){if(!("placeholder"in this.props))return;const{placeholder:e}=this.props;if([void 0,null].indexOf(e)>-1)return;const{prevPlaceholder:t,jsObject:n}=this.state,{resetConfiguration:r}=this,a=Object(Oc.getType)(e);-1===["object","array"].indexOf(a)&&xc.throwError("showPlaceholder","placeholder","either an object or an array");let o=!Object(Oc.identical)(e,t);if(o||r&&void 0!==n&&(o=!Object(Oc.identical)(e,n)),!o)return;const i=this.tokenize(e);this.setState({prevPlaceholder:e,plainText:i.indentation,markupText:i.markup,lines:i.lines,error:i.error})}tokenize(e){if("object"!=typeof e)return console.error("tokenize() expects object type properties only. Got '"+typeof e+"' type instead.");const t=this.props.locale||Pc,n=this.newSpan;if("nodeType"in e){const v=e.cloneNode(!0);if(!v.hasChildNodes())return"";const w=v.childNodes;let M={tokens_unknown:[],tokens_proto:[],tokens_split:[],tokens_fallback:[],tokens_normalize:[],tokens_merge:[],tokens_plainText:"",indented:"",json:"",jsObject:void 0,markup:""};for(var r=0;r-1?(n.active&&n.quarks.push({string:n[n.active],type:t+"-"+n.active}),n[n.active]="",n.active=r,n[n.active]=e):n[r]+=e}}for(var a=0;a-1){r(t,"number");break}case".":if(a0&&"0123456789".indexOf(e.charAt(a+1))>-1&&"0123456789".indexOf(e.charAt(a-1))>-1){r(t,"number");break}default:r(t,"string")}}return n.active&&(n.quarks.push({string:n[n.active],type:t+"-"+n.active}),n[n.active]="",n.active=!1),n.quarks}for(r=0;r0&&o-1){if(1===e.length)return!1;if(n!==r)return!1;for(o=0;o0&&o=~*%\\|/-+!?@^  ";for(o=0;o-1)return!1}}break;case"number":for(o=0;o1)return!1;if(-1==="{[:]},".indexOf(e))return!1;break;case"colon":if(e.length>1)return!1;if(":"!==e)return!1;break;default:return!0}return!0}for(r=0;r-1&&(t=t.slice(t.indexOf("-")+1),"string"!==t&&o.push("string"),o.push("key"),o.push("error"));let i={string:n,length:a,type:t,fallback:o};M.tokens_fallback.push(i)}function i(){const e=M.tokens_normalize.length-1;if(e<1)return!1;for(var t=e;t>=0;t--){const e=M.tokens_normalize[t];switch(e.type){case"space":case"linebreak":break;default:return e}}return!1}let k={brackets:[],stringOpen:!1,isValue:!1};for(r=0;r0){const e=M.tokens_fallback[r-1],t=e.string,n=e.type,a=t.charAt(t.length-1);if("string"===n&&"\\"===a)break}if(k.stringOpen===n){k.stringOpen=!1;break}break;case"primitive":case"string":if(["false","true","null","undefined"].indexOf(n)>-1){const e=M.tokens_normalize.length-1;if(e>=0){if("string"!==M.tokens_normalize[e].type){a.type="primitive";break}a.type="string";break}a.type="primitive";break}if("\n"===n&&!k.stringOpen){a.type="linebreak";break}k.isValue?a.type="string":a.type="key";break;case"space":case"number":k.stringOpen&&(k.isValue?a.type="string":a.type="key")}M.tokens_normalize.push(a)}for(r=0;r0?1:0;function c(e,t,n=0){l={token:e,line:u,reason:t},M.tokens_merge[e+n].type="error"}function d(e,t){if(void 0===e&&console.error("tokenID argument must be an integer."),void 0===t&&console.error("options argument must be an array."),e===M.tokens_merge.length-1)return!1;for(var n=e+1;n-1&&n;default:return!1}}return!1}function p(e,t){if(void 0===e&&console.error("tokenID argument must be an integer."),void 0===t&&console.error("options argument must be an array."),0===e)return!1;for(var n=e-1;n>=0;n--){const e=M.tokens_merge[n];switch(e.type){case"space":case"linebreak":break;case"symbol":case"colon":return t.indexOf(e.string)>-1;default:return!1}}return!1}function m(e){if(void 0===e&&console.error("tokenID argument must be an integer."),0===e)return!1;for(var t=e-1;t>=0;t--){const e=M.tokens_merge[t];switch(e.type){case"space":case"linebreak":break;default:return e.type}}return!1}k={brackets:[],stringOpen:!1,isValue:!1};let T=[];for(r=0;r0&&!p(r,[":","[",","])){c(r,Ec(t.invalidToken.tokenSequence.permitted,{firstToken:"[",secondToken:[":","[",","]}));break}if("{"===n&&p(r,["{"])){c(r,Ec(t.invalidToken.double,{token:"{"}));break}k.brackets.push(n),k.isValue="["===k.brackets[k.brackets.length-1],T.push({i:r,line:u,string:n});break;case"}":case"]":if("}"===n&&"{"!==k.brackets[k.brackets.length-1]){c(r,Ec(t.brace.curly.missingOpen));break}if("}"===n&&p(r,[","])){c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:",",secondToken:"}"}));break}if("]"===n&&"["!==k.brackets[k.brackets.length-1]){c(r,Ec(t.brace.square.missingOpen));break}if("]"===n&&p(r,[":"])){c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:":",secondToken:"]"}));break}k.brackets.pop(),k.isValue="["===k.brackets[k.brackets.length-1],T.push({i:r,line:u,string:n});break;case",":if(o=p(r,["{"]),o){if(d(r,["}"])){c(r,Ec(t.brace.curly.cannotWrap,{token:","}));break}c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:"{",secondToken:","}));break}if(d(r,["}",",","]"])){c(r,Ec(t.noTrailingOrLeadingComma));break}switch(o=m(r),o){case"key":case"colon":c(r,Ec(t.invalidToken.termSequence.prohibited,{firstTerm:"key"===o?t.types.key:t.symbols.colon,secondTerm:t.symbols.comma}));break;case"symbol":if(p(r,["{"])){c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:"{",secondToken:","}));break}}k.isValue="["===k.brackets[k.brackets.length-1]}M.json+=n;break;case"colon":if(o=p(r,["["]),o&&d(r,["]"])){c(r,Ec(t.brace.square.cannotWrap,{token:":"}));break}if(o){c(r,Ec(t.invalidToken.tokenSequence.prohibited,{firstToken:"[",secondToken:":"}));break}if("key"!==m(r)){c(r,Ec(t.invalidToken.termSequence.permitted,{firstTerm:t.symbols.colon,secondTerm:t.types.key}));break}if(d(r,["}","]"])){c(r,Ec(t.invalidToken.termSequence.permitted,{firstTerm:t.symbols.colon,secondTerm:t.types.value}));break}k.isValue=!0,M.json+=n;break;case"key":case"string":let e=n.charAt(0),i=n.charAt(n.length-1);L.indexOf(e);if(-1===L.indexOf(e)&&-1!==L.indexOf(i)){c(r,Ec(t.string.missingOpen,{quote:e}));break}if(-1===L.indexOf(i)&&-1!==L.indexOf(e)){c(r,Ec(t.string.missingClose,{quote:e}));break}if(L.indexOf(e)>-1&&e!==i){c(r,Ec(t.string.missingClose,{quote:e}));break}if("string"===a&&-1===L.indexOf(e)&&-1===L.indexOf(i)){c(r,Ec(t.string.mustBeWrappedByQuotes));break}if("key"===a&&d(r,["}","]"])&&c(r,Ec(t.invalidToken.termSequence.permitted,{firstTerm:t.types.key,secondTerm:t.symbols.colon})),-1===L.indexOf(e)&&-1===L.indexOf(i))for(var h=0;h0&&!isNaN(M.tokens_merge[r-1])){M.tokens_merge[r-1]+=M.tokens_merge[r],c(r,Ec(t.key.numberAndLetterMissingQuotes));break}c(r,Ec(t.key.spaceMissingQuotes));break}if("key"===a&&!p(r,["{",","])){c(r,Ec(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["{",","]}));break}if("string"===a&&!p(r,["[",":",","])){c(r,Ec(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["[",":",","]}));break}if("key"===a&&k.isValue){c(r,Ec(t.string.unexpectedKey));break}if("string"===a&&!k.isValue){c(r,Ec(t.key.unexpectedString));break}M.json+=n;break;case"number":case"primitive":if(p(r,["{"]))M.tokens_merge[r].type="key",a=M.tokens_merge[r].type,n='"'+n+'"';else if("key"===m(r))M.tokens_merge[r].type="key",a=M.tokens_merge[r].type;else if(!p(r,["[",":",","])){c(r,Ec(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["[",":",","]}));break}"key"!==a&&(k.isValue||(M.tokens_merge[r].type="key",a=M.tokens_merge[r].type,n='"'+n+'"')),"primitive"===a&&"undefined"===n&&c(r,Ec(t.invalidToken.useInstead,{badToken:"undefined",goodToken:"null"})),M.json+=n}}let D="";for(r=0;r0;){r=!1;for(var _=0;_-1&&f(_)}if(n++,!r)break;if(n>=e)break}if(T.length>0){const e=T[0].string,n=T[0].i,r="["===e?"]":"}";u=T[0].line,c(n,Ec(t.brace["]"===r?"square":"curly"].missingClose))}}if(!l&&-1===[void 0,""].indexOf(M.json))try{M.jsObject=JSON.parse(M.json)}catch(e){const n=e.message,r=n.indexOf("position");if(-1===r)throw new Error("Error parsing failed");const a=n.substring(r+9,n.length),o=parseInt(a);let i=0,s=0,d=!1,p=1,m=!1;for(;i=o));)s++,M.tokens_merge[s+1]||(m=!0);u=p;let h=0;for(let e=0;e0?h+1:1:(h%2==0&&0!==h||-1==="'\"bfnrt".indexOf(n)&&c(s,Ec(t.invalidToken.unexpected,{token:"\\"})),h=0)}l||c(s,Ec(t.invalidToken.unexpected,{token:d.string}))}let S=1,O=0;function y(e=!1){return function(e=!1){return S++,O>0||e?"
":""}(e)+function(){for(var e=[],t=0;t<2*O;t++)e.push(" ");return e.join("")}()}if(!l)for(r=0;r0?["[","{"].indexOf(M.tokens_merge[r-1].string)>-1?"":y(t):"";M.markup+=a+n(r,e,O);break;case",":M.markup+=n(r,e,O)}}}if(l){let e=1;function b(e){let t=0;for(var n=0;n-1&&t++;return t}S=1;for(r=0;r{let t="",n="",r="";switch(e){case",":t="symbol",n=e,r=e,a.isValue="["===a.brackets[a.brackets.length-1];break;case":":t="symbol",n=e,r=e,a.isValue=!0;break;case"{":case"[":t="symbol",n=e,r=e,a.brackets.push(e),a.isValue="["===a.brackets[a.brackets.length-1];break;case"}":case"]":t="symbol",n=e,r=e,a.brackets.pop(),a.isValue="["===a.brackets[a.brackets.length-1];break;case"undefined":t="primitive",n=e,r=void 0;break;case"null":t="primitive",n=e,r=null;break;case"false":t="primitive",n=e,r=!1;break;case"true":t="primitive",n=e,r=!0;break;default:const i=e.charAt(0);if("'\"".indexOf(i)>-1){if(t=a.isValue?"string":"key","key"===t&&(n=function(e){if(0===e.length)return e;if(['""',"''"].indexOf(e)>-1)return"''";let t=!1;for(var n=0;n<2;n++)if([e.charAt(0),e.charAt(e.length-1)].indexOf(['"',"'"][n])>-1){t=!0;break}t&&e.length>=2&&(e=e.slice(1,-1));const r=e.replace(/\w/g,""),a=(e.replace(/\W+/g,""),((e,t)=>{let n=!1;for(var r=0;r0||n)})(r,e));if((e=>{for(var t=0;t-1)return!0;return!1})(r)){let t="";const n=e.split("");for(var o=0;o-1&&(e="\\"+e),t+=e}e=t}return a?e:"'"+e+"'"}(e)),"string"===t){n="";const t=e.slice(1,-1).split("");for(var o=0;o-1&&(e="\\"+e),n+=e}n="'"+n+"'"}r=n;break}if(!isNaN(e)){t="number",n=e,r=Number(e);break}if(e.length>0&&!a.isValue){t="key",n=e,n.indexOf(" ")>-1&&(n="'"+n+"'"),r=n;break}}return{type:t,string:n,value:r,depth:a.brackets.length}});let o="";for(r=0;r0?"\n":"")+t.join("")}let i="";for(r=0;r0?a.tokens[r-1]:"";-1==="[{".indexOf(n.string)?i+=Y(e.depth)+e.string:i+=e.string;break;case":":i+=e.string+" ";break;case",":i+=e.string+Y(e.depth);break;default:i+=e.string}}let s=1;function T(e){var t=[];e>0&&s++;for(var n=0;n<2*e;n++)t.push(" ");return(e>0?"
":"")+t.join("")}let l="";const u=a.tokens.length-1;for(r=0;r0?a.tokens[r-1]:"";-1==="[{".indexOf(o.string)?l+=T(e.depth)+(u===r?"
":"")+t:l+=t;break;case":":l+=t+" ";break;case",":l+=t+T(e.depth);break;default:l+=t}}return s+=2,{tokens:a.tokens,noSpaces:o,indented:i,json:JSON.stringify(e),jsObject:e,markup:l,lines:s}}}}var Hc=Cc,zc=n(133),Ac=n.n(zc);function Rc(e){return(Rc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Nc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Fc(e,t){for(var n=0;n=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(e)&&wp.element.createElement(sa,{chart:this.props.chart,edit:this.props.edit}),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(e)&&wp.element.createElement(Ta,{chart:this.props.chart,edit:this.props.edit}),0<=["pie"].indexOf(e)&&wp.element.createElement(sd,null,wp.element.createElement(Ua,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(io,{chart:this.props.chart,edit:this.props.edit})),0<=["area","scatter","line"].indexOf(e)&&wp.element.createElement(ko,{chart:this.props.chart,edit:this.props.edit}),0<=["bar","column"].indexOf(e)&&wp.element.createElement(Ao,{chart:this.props.chart,edit:this.props.edit}),0<=["candlestick"].indexOf(e)&&wp.element.createElement(Xo,{chart:this.props.chart,edit:this.props.edit}),0<=["geo"].indexOf(e)&&wp.element.createElement(sd,null,wp.element.createElement(hi,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Oi,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Ui,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(os,{chart:this.props.chart,edit:this.props.edit})),0<=["gauge"].indexOf(e)&&wp.element.createElement(ks,{chart:this.props.chart,edit:this.props.edit}),0<=["timeline"].indexOf(e)&&wp.element.createElement(Ns,{chart:this.props.chart,edit:this.props.edit}),0<=["tabular","dataTable"].indexOf(e)&&wp.element.createElement(sd,null,wp.element.createElement(nl,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(gl,{chart:this.props.chart,edit:this.props.edit})),0<=["combo"].indexOf(e)&&wp.element.createElement(El,{chart:this.props.chart,edit:this.props.edit}),-1>=["timeline","bubble","gauge","geo","pie","tabular","dataTable"].indexOf(e)&&wp.element.createElement(Zl,{chart:this.props.chart,edit:this.props.edit}),"tabular"===e&&"GoogleCharts"===t&&wp.element.createElement(Zl,{chart:this.props.chart,edit:this.props.edit}),0<=["bubble"].indexOf(e)&&wp.element.createElement(Su,{chart:this.props.chart,edit:this.props.edit}),0<=["pie"].indexOf(e)&&wp.element.createElement(pu,{chart:this.props.chart,edit:this.props.edit}),"DataTable"===t&&wp.element.createElement(Ju,{chart:this.props.chart,edit:this.props.edit}),"DataTable"!==t&&wp.element.createElement(uc,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Yc,{chart:this.props.chart,edit:this.props.edit}),"DataTable"!==t&&wp.element.createElement(Zc,{chart:this.props.chart,edit:this.props.edit}))}}])&&ed(t.prototype,n),r&&ed(t,r),Object.defineProperty(t,"prototype",{writable:!1}),o}(id);function ud(e){return(ud="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function cd(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */cd=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",i=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=t&&t.prototype instanceof d?t:d,o=Object.create(a.prototype),i=new k(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return Y()}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var s=v(i,n);if(s){if(s===c)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=u(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===c)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}(e,n,i),o}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var c={};function d(){}function p(){}function m(){}var h={};s(h,a,(function(){return this}));var f=Object.getPrototypeOf,_=f&&f(f(L([])));_&&_!==t&&n.call(_,a)&&(h=_);var y=m.prototype=d.prototype=Object.create(h);function b(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var r;this._invoke=function(a,o){function i(){return new t((function(r,i){!function r(a,o,i,s){var l=u(e[a],e,o);if("throw"!==l.type){var c=l.arg,d=c.value;return d&&"object"==ud(d)&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(d).then((function(e){c.value=e,i(c)}),(function(e){return r("throw",e,i,s)}))}s(l.arg)}(a,o,r,i)}))}return r=r?r.then(i,i):i()}}function v(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,v(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function L(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(s&&l){if(this.prev=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),M(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;M(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}function dd(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function pd(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){dd(o,r,a,i,s,"next",e)}function s(e){dd(o,r,a,i,s,"throw",e)}i(void 0)}))}}function md(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hd(e,t){for(var n=0;n=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(s&&l){if(this.prev=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),M(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;M(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}function Tp(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function Dp(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Tp(o,r,a,i,s,"next",e)}function s(e){Tp(o,r,a,i,s,"throw",e)}i(void 0)}))}}function Sp(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Op(e,t){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];this.setState({isLoading:"uploadData",isScheduled:t}),Rp({path:"/visualizer/v1/upload-data?url=".concat(this.state.chart["visualizer-chart-url"]),method:"POST"}).then((function(t){if(2<=Object.keys(t).length){var n=kp({},e.state.chart);n["visualizer-source"]="Visualizer_Source_Csv_Remote",n["visualizer-default-data"]=0,n["visualizer-series"]=t.series,n["visualizer-data"]=t.data;var r=n["visualizer-series"],a=n["visualizer-settings"],o=r,i="series";return"pie"===n["visualizer-chart-type"]&&(o=n["visualizer-data"],i="slices"),o.map((function(e,t){if("pie"===n["visualizer-chart-type"]||0!==t){var r="pie"!==n["visualizer-chart-type"]?t-1:t;void 0===a[i][r]&&(a[i][r]={},a[i][r].temp=1)}})),a[i]=a[i].filter((function(e,t){return t<("pie"!==n["visualizer-chart-type"]?o.length-1:o.length)})),n["visualizer-settings"]=a,e.setState({chart:n,isModified:!0,isLoading:!1}),t}e.setState({isLoading:!1})}),(function(t){return e.setState({isLoading:!1}),t}))}},{key:"getChartData",value:(a=Dp(Yp().mark((function e(t){var n,r;return Yp().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setState({isLoading:"getChartData"});case 2:return e.next=4,Ap({path:"wp/v2/visualizer/".concat(t)});case 4:n=e.sent,(r=kp({},this.state.chart))["visualizer-source"]="Visualizer_Source_Csv",r["visualizer-default-data"]=0,r["visualizer-series"]=n.chart_data["visualizer-series"],r["visualizer-data"]=n.chart_data["visualizer-data"],this.setState({isLoading:!1,chart:r});case 11:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"editChartData",value:function(e,t){var n=kp({},this.state.chart),r=[],a=kp({},n["visualizer-settings"]),o=n["visualizer-chart-type"];e[0].map((function(t,n){r[n]={label:t,type:e[1][n]}})),e.splice(0,2);var i=r,s="series";switch(o){case"pie":i=e,s="slices",e.map((function(e,t){switch(r[1].type){case"number":e[1]=parseFloat(e[1])}}));break;case"tabular":e.map((function(e,t){r.map((function(t,n){switch(t.type){case"boolean":"string"==typeof e[n]&&(e[n]="true"===e[n])}}))}))}i.map((function(e,t){if("pie"===o||0!==t){var n="pie"!==o?t-1:t;Array.isArray(a[s])&&void 0===a[s][n]&&(a[s][n]={},a[s][n].temp=1)}})),Array.isArray(a[s])&&(a[s]=a[s].filter((function(e,t){return t<(-1>=["pie","tabular","dataTable"].indexOf(o)?i.length-1:i.length)}))),n["visualizer-source"]=t,n["visualizer-default-data"]=0,n["visualizer-data"]=e,n["visualizer-series"]=r,n["visualizer-settings"]=a,n["visualizer-chart-url"]="",this.setState({chart:n,isModified:!0,isScheduled:!1})}},{key:"updateChart",value:function(){var e=this;this.setState({isLoading:"updateChart"});var t=this.state.chart;!1===this.state.isScheduled&&(t["visualizer-chart-schedule"]="");var n="series";"pie"===t["visualizer-chart-type"]&&(n="slices"),-1>=["bubble","timeline"].indexOf(t["visualizer-chart-type"])&&Object.keys(t["visualizer-settings"][n]).map((function(e){void 0!==t["visualizer-settings"][n][e]&&void 0!==t["visualizer-settings"][n][e].temp&&delete t["visualizer-settings"][n][e].temp})),Rp({path:"/visualizer/v1/update-chart?id=".concat(this.props.attributes.id),method:"POST",data:t}).then((function(t){return e.setState({isLoading:!1,isModified:!1}),t}),(function(e){return e}))}},{key:"render",value:function(){var e=this;return"error"===this.state.route?wp.element.createElement(Vp,{status:"error",isDismissible:!1},wp.element.createElement(Up,{icon:"chart-pie"}),Hp("This chart is not available; it might have been deleted. Please delete this block and resubmit your chart.")):"renderChart"===this.state.route&&null!==this.state.chart?wp.element.createElement(gp,{id:this.props.attributes.id,chart:this.state.chart,className:this.props.className,editChart:this.editChart}):wp.element.createElement("div",{className:"visualizer-settings"},wp.element.createElement("div",{className:"visualizer-settings__title"},wp.element.createElement(Up,{icon:"chart-pie"}),Hp("Visualizer")),"home"===this.state.route&&wp.element.createElement("div",{className:"visualizer-settings__content"},wp.element.createElement("div",{className:"visualizer-settings__content-description"},Hp("Make a new chart or display an existing one?")),wp.element.createElement("a",{href:visualizerLocalize.adminPage,target:"_blank",className:"visualizer-settings__content-option"},wp.element.createElement("span",{className:"visualizer-settings__content-option-title"},Hp("Create a new chart")),wp.element.createElement("div",{className:"visualizer-settings__content-option-icon"},wp.element.createElement(Up,{icon:"arrow-right-alt2"}))),wp.element.createElement("div",{className:"visualizer-settings__content-option",onClick:function(){e.setState({route:"showCharts"}),e.props.setAttributes({route:"showCharts"})}},wp.element.createElement("span",{className:"visualizer-settings__content-option-title"},Hp("Display an existing chart")),wp.element.createElement("div",{className:"visualizer-settings__content-option-icon"},wp.element.createElement(Up,{icon:"arrow-right-alt2"})))),("getChart"===this.state.isLoading||"chartSelect"===this.state.route&&null===this.state.chart||"renderChart"===this.state.route&&null===this.state.chart)&&wp.element.createElement(Gp,null,wp.element.createElement(qp,null)),"showCharts"===this.state.route&&!1===this.state.isLoading&&wp.element.createElement(De,{getChart:this.getChart}),"chartSelect"===this.state.route&&null!==this.state.chart&&wp.element.createElement(ep,{id:this.props.attributes.id,attributes:this.props.attributes,chart:this.state.chart,editSettings:this.editSettings,editPermissions:this.editPermissions,url:this.state.url,readUploadedFile:this.readUploadedFile,editURL:this.editURL,editSchedule:this.editSchedule,editJSONURL:this.editJSONURL,editJSONHeaders:this.editJSONHeaders,editJSONSchedule:this.editJSONSchedule,editJSONRoot:this.editJSONRoot,editJSONPaging:this.editJSONPaging,JSONImportData:this.JSONImportData,editDatabaseSchedule:this.editDatabaseSchedule,databaseImportData:this.databaseImportData,uploadData:this.uploadData,getChartData:this.getChartData,editChartData:this.editChartData,isLoading:this.state.isLoading}),wp.element.createElement("div",{className:"visualizer-settings__controls"},("showCharts"===this.state.route||"chartSelect"===this.state.route)&&wp.element.createElement(Jp,null,wp.element.createElement(Bp,{isDefault:!0,isLarge:!0,onClick:function(){var t;"showCharts"===e.state.route?t="home":"chartSelect"===e.state.route&&(t="showCharts"),e.setState({route:t,isLoading:!1}),e.props.setAttributes({route:t})}},Hp("Back")),"chartSelect"===this.state.route&&wp.element.createElement(Wp,null,!1===this.state.isModified?wp.element.createElement(Bp,{isDefault:!0,isLarge:!0,className:"visualizer-bttn-done",onClick:function(){e.setState({route:"renderChart",isModified:!0}),e.props.setAttributes({route:"renderChart"})}},Hp("Done")):wp.element.createElement(Bp,{isPrimary:!0,isLarge:!0,className:"visualizer-bttn-save",isBusy:"updateChart"===this.state.isLoading,disabled:"updateChart"===this.state.isLoading,onClick:this.updateChart},Hp("Save"))))))}}])&&Op(t.prototype,n),r&&Op(t,r),Object.defineProperty(t,"prototype",{writable:!1}),l}(Fp),Kp=(n(153),wp.i18n.__),Zp=wp.blocks.registerBlockType;t.default=Zp("visualizer/chart",{title:Kp("Visualizer Chart"),description:Kp("A simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages."),category:"common",icon:"chart-pie",keywords:[Kp("Visualizer"),Kp("Chart"),Kp("Google Charts")],attributes:{id:{type:"number"},lazy:{default:"-1",type:"string"},route:{type:"string"}},supports:{customClassName:!1},edit:$p,save:function(){return null}})}]); \ No newline at end of file diff --git a/classes/Visualizer/Gutenberg/src/Editor.js b/classes/Visualizer/Gutenberg/src/Editor.js index 0b41e64c..7c3337ae 100644 --- a/classes/Visualizer/Gutenberg/src/Editor.js +++ b/classes/Visualizer/Gutenberg/src/Editor.js @@ -581,7 +581,7 @@ class Editor extends Component { } else if ( 'chartSelect' === this.state.route ) { route = 'showCharts'; } - this.setState({ route }); + this.setState({ route, isLoading: false }); this.props.setAttributes({ route }); } } >