(()=>{"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}const t=window.tinymce;var n=function(e){return Object.keys(e).map((function(t){return{text:e[Number(t)],value:t}}))},o=function(e,t){return{text:t.getLang("code_snippets.insert_source_menu"),onclick:function(){e.windowManager.open({title:t.getLang("code_snippets.insert_source_title"),body:[{type:"listbox",name:"id",label:t.getLang("code_snippets.snippet_label"),values:n(t.getLang("code_snippets.all_snippets"))},{type:"checkbox",name:"line_numbers",label:t.getLang("code_snippets.show_line_numbers_label")}],onsubmit:function(t){var n=parseInt(t.data.id,10);if(n){var o="";t.data.line_numbers&&(o+=" line_numbers=true"),e.insertContent("[code_snippet_source id=".concat(n).concat(o,"]"))}}},{})}}},r=function(t,o){return{text:o.getLang("code_snippets.insert_content_menu"),onclick:function(){t.windowManager.open({title:o.getLang("code_snippets.insert_content_title"),body:[{type:"listbox",name:"id",label:o.getLang("code_snippets.snippet_label"),values:n(o.getLang("code_snippets.content_snippets"))},{type:"checkbox",name:"php",label:o.getLang("code_snippets.php_att_label")},{type:"checkbox",name:"format",label:o.getLang("code_snippets.format_att_label")},{type:"checkbox",name:"shortcodes",label:o.getLang("code_snippets.shortcodes_att_label")}],onsubmit:function(n){var o,r,a=parseInt(n.data.id,10);if(a){for(var i="",c=0,s=Object.entries(n.data);c<s.length;c++){var l=(o=s[c],r=2,function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(a.push(o.value),!t||a.length!==t);i=!0);}catch(e){c=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw r}}return a}}(o,r)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,n):void 0}}(o,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),p=l[0],u=l[1];"id"!==p&&u&&(i+=" ".concat(p,"=").concat(u))}t.insertContent("[code_snippet id=".concat(a).concat(i,"]"))}}},{})}}};t.PluginManager.add("code_snippets",(function(e){var n=t.activeEditor;e.addButton("code_snippets",{icon:"code",menu:[o(e,n),r(e,n)],type:"menubutton"})}))})();