AlkantarClanX12
Current Path : /home/thanudqk/shenpokertour.com/wp-content/plugins/tablepress/admin/js/build/ |
Current File : /home/thanudqk/shenpokertour.com/wp-content/plugins/tablepress/admin/js/build/edit.js |
(()=>{"use strict";const e=window.wp.i18n,t=window.wp.hooks,s=window.wp.url,o=e=>"#"===e[0]?document.getElementById(e.slice(1)):document.querySelectorAll(e);window.tp=window.tp||{},tp.made_changes=!1,tp.helpers=tp.helpers||{},tp.callbacks=tp.callbacks||{},tp.helpers.selection=tp.helpers.selection||{rows:[0],columns:[0]},tp.helpers.unsaved_changes=tp.helpers.unsaved_changes||{},tp.helpers.unsaved_changes.unload_dialog=function(e){e.preventDefault(),e.returnValue=""},tp.helpers.unsaved_changes.set=function(){tp.made_changes||(tp.made_changes=!0,window.addEventListener("beforeunload",tp.helpers.unsaved_changes.unload_dialog))},tp.helpers.unsaved_changes.unset=function(){tp.made_changes=!1,window.removeEventListener("beforeunload",tp.helpers.unsaved_changes.unload_dialog)},tp.helpers.options=tp.helpers.options||{},tp.helpers.options.load=function(){Object.keys(tp.table.options).forEach((function(e){if("last_editor"===e)return;if(""===(e=(0,t.applyFilters)("tablepress.optionsLoad",e)))return;let s=o(`#option-${e}`);s||(s=o(`#option-${e}-${tp.table.options[e]}`)),s&&(s instanceof HTMLInputElement&&"checkbox"===s.type?s.checked=tp.table.options[e]:s instanceof HTMLInputElement&&"radio"===s.type?s.checked=!0:s.value=tp.table.options[e])})),tp.table.options.use_datatables&&tp.helpers.editor.has_merged_cells()&&(tp.table.options.use_datatables=!1,o("#option-use_datatables").checked=!1),tp.helpers.options.check_dependencies()},tp.helpers.options.change=function(s){if(!s.target)return;const l=s.target.name||"";if(""===l)return;const n=s.target instanceof HTMLInputElement&&"checkbox"===s.target.type?"checked":"value";tp.table.options[l]=s.target[n],s.target instanceof HTMLInputElement&&"number"===s.target.type&&(tp.table.options[l].includes(".")?tp.table.options[l]=parseFloat(tp.table.options[l]):tp.table.options[l]=parseInt(tp.table.options[l],10)),"use_datatables"===l&&tp.table.options.use_datatables&&tp.helpers.editor.has_merged_cells()&&(tp.table.options.use_datatables=!1,o("#option-use_datatables").checked=!1,window.alert((0,e.__)("You can not enable the Table Features for Site Visitors, because your table contains combined/merged cells.","tablepress"))),(0,t.doAction)("tablepress.optionsChange",l,n,s),tp.helpers.options.check_dependencies(),tp.helpers.unsaved_changes.set(),tp.editor.updateTable()},tp.helpers.options.check_dependencies=function(){o("#option-use_datatables").disabled=!tp.table.options.table_head,o("#notice-datatables-head-row").style.display=tp.table.options.table_head?"none":"block",o("#option-print_name_position").disabled=!tp.table.options.print_name,o("#option-print_description_position").disabled=!tp.table.options.print_description;const e=tp.table.options.use_datatables&&tp.table.options.table_head;o("#tablepress_edit-datatables-features").querySelectorAll(":scope input:not(#option-use_datatables), :scope textarea").forEach((t=>t.disabled=!e));const s=e&&tp.table.options.datatables_paginate;o("#option-datatables_lengthchange").disabled=!s,o("#option-datatables_paginate_entries").disabled=!s,(0,t.doAction)("tablepress.optionsCheckDependencies")},tp.helpers.options.validate_fields=function(){if(tp.table.options.datatables_paginate&&(isNaN(tp.table.options.datatables_paginate_entries)||tp.table.options.datatables_paginate_entries<1||tp.table.options.datatables_paginate_entries>9999)){window.alert((0,e.sprintf)((0,e.__)("The entered value in the “%1$s” field is invalid.","tablepress"),(0,e.__)("Pagination Entries","tablepress")));const t=o("#option-datatables_paginate_entries");return t.focus(),t.select(),!1}if(/[^A-Za-z0-9- _:]/.test(tp.table.options.extra_css_classes)){window.alert((0,e.sprintf)((0,e.__)("The entered value in the “%1$s” field is invalid.","tablepress"),(0,e.__)("Extra CSS Classes","tablepress")));const t=o("#option-extra_css_classes");return t.focus(),t.select(),!1}return(0,t.applyFilters)("tablepress.optionsValidateFields",!0)},tp.helpers.visibility=tp.helpers.visibility||{},tp.helpers.visibility.load=function(){const e=tp.table.visibility.rows.length,t=tp.table.visibility.columns.length,s={};for(let o=0;o<e;o++)if(1!==tp.table.visibility.rows[o])for(let e=0;e<t;e++){const t=jspreadsheet.getColumnNameFromId([e,o]);s[t]=s[t]||{},s[t].row_hidden=!0}for(let o=0;o<t;o++)if(1!==tp.table.visibility.columns[o])for(let t=0;t<e;t++){const e=jspreadsheet.getColumnNameFromId([o,t]);s[e]=s[e]||{},s[e].column_hidden=!0}return s},tp.helpers.visibility.update=function(){tp.table.visibility.rows=[];for(let e=0;e<tp.editor.options.data.length;e++)tp.table.visibility.rows[e]=1;tp.table.visibility.columns=[];for(let e=0;e<tp.editor.options.columns.length;e++)tp.table.visibility.columns[e]=1;Object.keys(tp.editor.options.meta).forEach((function(e){const t=jspreadsheet.getIdFromColumnName(e,!0);1===tp.table.visibility.rows[t[1]]&&tp.editor.options.meta[e].row_hidden&&(tp.table.visibility.rows[t[1]]=0),1===tp.table.visibility.columns[t[0]]&&tp.editor.options.meta[e].column_hidden&&(tp.table.visibility.columns[t[0]]=0)}))},tp.helpers.visibility.selection_contains=function(e,t){return tp.helpers.selection[e].some((s=>tp.table.visibility[e][s]===t))},tp.helpers.move_allowed=function(e,t){let s=tp.helpers.selection[e][0],o=0;return"down"!==t&&"right"!==t&&"bottom"!==t&&"last"!==t||(s=tp.helpers.selection[e][tp.helpers.selection[e].length-1],o="rows"===e?tp.editor.options.data.length-1:tp.editor.options.columns.length-1),o!==s},tp.helpers.cell_merge_allowed=function(t,s={}){const o="alert"===t;if(tp.table.options.table_head&&tp.table.options.use_datatables)return s.text=(0,e.sprintf)((0,e.__)("You can not combine these cells, because the “%1$s” checkbox in the “%2$s” section is checked.","tablepress"),(0,e.__)("Enable Visitor Features","tablepress"),(0,e.__)("Table Features for Site Visitors","tablepress"))+" "+(0,e.__)("The Table Features for Site Visitors are not compatible with merged cells.","tablepress"),o&&window.alert(s.text),!1;const l=tp.helpers.selection.rows[0],n=tp.helpers.selection.rows[tp.helpers.selection.rows.length-1];if(tp.table.options.table_head&&0===l&&n>0)return s.text=(0,e.sprintf)((0,e.__)("You can not combine these cells, because the “%1$s” checkbox in the “%2$s” section is checked.","tablepress"),(0,e.__)("Table Head Row","tablepress"),(0,e.__)("Table Options","tablepress")),o&&window.alert(s.text),!1;const a=tp.editor.options.data.length-1;return!(tp.table.options.table_foot&&a===n&&l<a&&(s.text=(0,e.sprintf)((0,e.__)("You can not combine these cells, because the “%1$s” checkbox in the “%2$s” section is checked.","tablepress"),(0,e.__)("Table Foot Row","tablepress"),(0,e.__)("Table Options","tablepress")),o&&window.alert(s.text),1))},tp.helpers.editor=tp.helpers.editor||{},tp.helpers.editor.reselect=function(e,t){void 0===t&&(t=tp.editor),t.updateSelectionFromCoords(tp.helpers.selection.columns[0],tp.helpers.selection.rows[0],tp.helpers.selection.columns[tp.helpers.selection.columns.length-1],tp.helpers.selection.rows[tp.helpers.selection.rows.length-1])},tp.helpers.editor.has_merged_cells=function(){const e=tp.editor.options.data.length,t=tp.editor.options.columns.length;for(let s=0;s<e;s++)for(let e=0;e<t;e++)if("#rowspan#"===tp.editor.options.data[s][e]||"#colspan#"===tp.editor.options.data[s][e])return!0;return!1},tp.helpers.editor.sorting=function(e){return e=e?-1:1,function(t,s){const o=t[1].localeCompare(s[1],void 0,{numeric:!0,sensitivity:"base"});return e*o}},tp.callbacks.editor=tp.callbacks.editor||{},tp.callbacks.editor.onselection=function(e,t,s,o,l){tp.helpers.selection={rows:[],columns:[]};for(let e=s;e<=l;e++)tp.helpers.selection.rows.push(e);for(let e=t;e<=o;e++)tp.helpers.selection.columns.push(e)},tp.callbacks.editor.onupdatetable=function(e,t,s,o,l,n,a){const i=e.jspreadsheet.options.meta[a];if(t.classList.toggle("column-hidden",Boolean(i?.column_hidden)),0===s&&(t.parentNode.classList.toggle("row-hidden",Boolean(i?.row_hidden)),t.parentNode.classList.remove("head-row","foot-row"),o===e.jspreadsheet.rows.length-1)){const t=e.jspreadsheet.content.querySelectorAll(":scope tbody tr:not(.row-hidden)");1<t.length&&(tp.table.options.table_head&&t[0].classList.add("head-row"),tp.table.options.table_foot&&t[t.length-1].classList.add("foot-row"))}},tp.callbacks.editor.oninsertroc=function(e,t,s,o,l,n,a){const i="rows"===e,r=i?"column_hidden":"row_hidden",c="duplicate"===t,p=o+(a?l:0),d=i?tp.editor.options.columns.length:tp.editor.options.data.length,b={};for(let e=0;e<d;e++){const t=i?[e,p]:[p,e],s=tp.editor.options.meta[jspreadsheet.getColumnNameFromId(t)];s&&(c?b[e]=s:s[r]&&(b[e]=b[e]||{},b[e][r]=!0))}const u=Object.keys(b);if(!u.length)return;const h={};a||o++;for(let e=0;e<l;e++){const t=o+e;u.forEach((function(e){const s=i?[e,t]:[t,e];h[jspreadsheet.getColumnNameFromId(s)]=b[e]}))}tp.editor.setMeta(h),tp.editor.updateTable()},tp.callbacks.editor.onmove=function(){tp.helpers.editor.reselect(),tp.helpers.unsaved_changes.set()},tp.callbacks.editor.onsort=function(){tp.editor.updateTable(),tp.helpers.unsaved_changes.set()},tp.helpers.editor.insert_from_helper_textarea=function(){tp.editor.setValueFromCoords(tp.helpers.selection.columns[0],tp.helpers.selection.rows[0],this.value)},tp.callbacks.insert_link={},tp.callbacks.insert_link.open_dialog=function(t=null){const s=o("#textarea-insert-helper");s.value=tp.editor.options.data[tp.helpers.selection.rows[0]][tp.helpers.selection.columns[0]],t?(s.selectionStart=t.selectionStart,s.selectionEnd=t.selectionEnd):(s.selectionStart=s.value.length,s.selectionEnd=s.value.length);const l=jexcel.getColumnNameFromId([tp.helpers.selection.columns[0],tp.helpers.selection.rows[0]]);o("#link-modal-title").textContent=(0,e.sprintf)((0,e.__)("Insert Link into cell %1$s","tablepress"),l),wpLink.open("textarea-insert-helper"),jexcel.current=null},tp.callbacks.insert_image={},tp.callbacks.insert_image.open_dialog=function(t=null){const s=o("#textarea-insert-helper");s.value=tp.editor.options.data[tp.helpers.selection.rows[0]][tp.helpers.selection.columns[0]],t?(s.selectionStart=t.selectionStart,s.selectionEnd=t.selectionEnd):(s.selectionStart=s.value.length,s.selectionEnd=s.value.length),wp.media.editor.open("textarea-insert-helper",{frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0});const l=jexcel.getColumnNameFromId([tp.helpers.selection.columns[0],tp.helpers.selection.rows[0]]);document.querySelector("#media-frame-title h1").textContent=(0,e.sprintf)((0,e.__)("Add media to cell %1$s","tablepress"),l),jexcel.current=null},tp.callbacks.advanced_editor={},tp.callbacks.advanced_editor.$textarea=o("#advanced-editor-content"),tp.callbacks.advanced_editor.open_dialog=function(t=null){tp.callbacks.advanced_editor.$textarea.value=tp.editor.options.data[tp.helpers.selection.rows[0]][tp.helpers.selection.columns[0]];const s=jexcel.getColumnNameFromId([tp.helpers.selection.columns[0],tp.helpers.selection.rows[0]]),l=(0,e.sprintf)((0,e.__)("Advanced Editor for cell %1$s","tablepress"),s);o("#advanced-editor-label").textContent=l,o("#link-modal-title").textContent=(0,e.sprintf)((0,e.__)("Insert Link into cell %1$s","tablepress"),s),jQuery("#advanced-editor").wpdialog({width:600,modal:!0,title:l,resizable:!1,closeOnEscape:!0,buttons:[{text:(0,e.__)("Cancel","tablepress"),class:"button button-cancel",click(){jQuery(this).wpdialog("close")}},{text:(0,e.__)("OK","tablepress"),class:"button button-primary button-ok",click:tp.callbacks.advanced_editor.confirm_save}]}),jexcel.current=null,t?(tp.callbacks.advanced_editor.$textarea.selectionStart=t.selectionStart,tp.callbacks.advanced_editor.$textarea.selectionEnd=t.selectionEnd):(tp.callbacks.advanced_editor.$textarea.selectionStart=tp.callbacks.advanced_editor.$textarea.value.length,tp.callbacks.advanced_editor.$textarea.selectionEnd=tp.callbacks.advanced_editor.$textarea.value.length),tp.callbacks.advanced_editor.$textarea.focus()},tp.callbacks.advanced_editor.confirm_save=function(){const e=tp.editor.options.data[tp.helpers.selection.rows[0]][tp.helpers.selection.columns[0]];tp.callbacks.advanced_editor.$textarea.value!==e&&tp.editor.setValueFromCoords(tp.helpers.selection.columns[0],tp.helpers.selection.rows[0],tp.callbacks.advanced_editor.$textarea.value),jQuery(this).wpdialog("close")},tp.callbacks.help_box={},tp.callbacks.help_box.open_dialog=function(t){const s=o(t.target.dataset.helpBox);jQuery(s).wpdialog({height:s.dataset.height,width:s.dataset.width,minWidth:260,modal:!0,closeOnEscape:!0,buttons:[{text:(0,e.__)("OK","tablepress"),class:"button button-ok",click(){jQuery(this).wpdialog("close")}}],open(){jQuery(this).next().find(".button-ok").trigger("focus")}})},tp.callbacks.table_preview={},tp.callbacks.table_preview.process=function(t){t.preventDefault();let l=o("#table-name").value;if(""===l.trim()&&(l=(0,e.__)("(no name)","tablepress")),tp.callbacks.table_preview.$dialog=jQuery("#table-preview").wpdialog({autoOpen:!1,width:window.innerWidth-80,height:window.innerHeight-80,modal:!0,title:(0,e.sprintf)((0,e.__)("Preview of table “%1$s” (ID %2$s)","tablepress"),l,tp.table.id),closeOnEscape:!0,buttons:[{text:(0,e.__)("OK","tablepress"),class:"button button-ok",click(){jQuery(this).wpdialog("close")}}]}),!tp.made_changes){const e=o("#table-preview-iframe");return e.src=t.target.href,e.removeAttribute("srcdoc"),void tp.callbacks.table_preview.$dialog.wpdialog("open")}tp.helpers.visibility.update();const n={action:"tablepress_preview_table",_ajax_nonce:tp.nonces.preview_table,tablepress:{id:tp.table.id,new_id:tp.table.new_id,name:o("#table-name").value,description:o("#table-description").value,data:JSON.stringify(tp.editor.options.data),options:JSON.stringify(tp.table.options),visibility:JSON.stringify(tp.table.visibility),number:{rows:tp.editor.options.data.length,columns:tp.editor.options.columns.length}}};t.target.parentNode.insertAdjacentHTML("beforeend",`<span id="spinner-table-preview" class="spinner-table-preview spinner is-active" title="${(0,e.__)("The Table Preview is being loaded …","tablepress")}"></span>`),o(".button-preview").forEach((e=>e.classList.add("disabled"))),document.body.classList.add("wait"),fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:(0,s.buildQueryString)(n)}).then((e=>{if(!e.ok)throw new Error(`There was a problem with the server, HTTP response code ${e.status} (${e.statusText}).`);return e.json()})).then((e=>{if(null==e||"-1"===e||void 0===e.success)throw new Error("The JSON data returned from the server is unclear or incomplete.");if(!0!==e.success)throw new Error("The preview could not be loaded.");tp.callbacks.table_preview.success(e)})).catch((e=>tp.callbacks.table_preview.error(e.message))).finally((()=>{o("#spinner-table-preview").remove(),o(".button-preview").forEach((e=>e.classList.remove("disabled"))),document.body.classList.remove("wait")}))},tp.callbacks.table_preview.success=function(e){const t=o("#table-preview-iframe");t.src="",t.srcdoc=`<!DOCTYPE html><html><head>${e.head_html}</head><body>${e.body_html}</body></html>`,tp.callbacks.table_preview.$dialog.wpdialog("open")},tp.callbacks.table_preview.error=function(t){t=(0,e.__)("Attention: Unfortunately, an error occurred.","tablepress")+" "+t;const s=`show-preview-${Date.now()}`;o("#spinner-table-preview").parentNode.insertAdjacentHTML("afterend",`<div id="${s}" class="ajax-alert notice notice-error"><p>${t}</p></div>`);const l=o(`#${s}`);l.offsetWidth,l.style.opacity=0,l.addEventListener("transitionend",(()=>l.remove()))},tp.callbacks.save_changes={},tp.callbacks.save_changes.process=function(t){if(!tp.helpers.options.validate_fields())return;tp.helpers.visibility.update();const l={action:"tablepress_save_table",_ajax_nonce:tp.nonces.edit_table,tablepress:{id:tp.table.id,new_id:tp.table.new_id,name:o("#table-name").value,description:o("#table-description").value,data:JSON.stringify(tp.editor.options.data),options:JSON.stringify(tp.table.options),visibility:JSON.stringify(tp.table.visibility),number:{rows:tp.editor.options.data.length,columns:tp.editor.options.columns.length}}};t.target.parentNode.insertAdjacentHTML("beforeend",`<span id="spinner-save-changes" class="spinner-save-changes spinner is-active" title="${(0,e.__)("Changes are being saved …","tablepress")}"></span>`),o(".button-save-changes").forEach((e=>e.disabled=!0)),document.body.classList.add("wait"),fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:(0,s.buildQueryString)(l)}).then((e=>{if(!e.ok)throw new Error(`There was a problem with the server, HTTP response code ${e.status} (${e.statusText}).`);return e.json()})).then((t=>{if(null==t||"-1"===t||void 0===t.success)throw new Error("The JSON data returned from the server is unclear or incomplete.");if(!0!==t.success){const s=(0,e.__)("These errors were encountered:","tablepress"),o=t.error_details?`</p><p>${s}</p><pre>${t.error_details}</pre><p>`:"";throw new Error(`The table could not be saved to the database properly.${o}`)}tp.callbacks.save_changes.success(t)})).catch((e=>tp.callbacks.save_changes.error(e.message))).finally((()=>{o("#spinner-save-changes").remove(),o(".button-save-changes").forEach((e=>e.disabled=!1)),document.body.classList.remove("wait")}))},tp.callbacks.save_changes.success=function(t){tp.table.id!==t.table_id&&window?.history?.pushState&&window.history.pushState("","",window.location.href.replace(/table_id=[0-9a-zA-Z-_]+/gi,`table_id=${t.table_id}`)),tp.table.id=t.table_id,tp.table.new_id=t.table_id,o("#table-id").value=t.table_id;const s=o("#table-information-shortcode");s&&(s.value=`[${tp.table.shortcode} id=${t.table_id} /]`),tp.nonces.edit_table=t.new_edit_nonce,tp.nonces.preview_table=t.new_preview_nonce,tp.nonces.copy_table=t.new_copy_nonce,tp.nonces.delete_table=t.new_delete_nonce,["preview","copy","delete"].forEach((e=>{o(`.button-${e}`).forEach((s=>{s.href=s.href.replace(/item=[a-zA-Z0-9_-]+/g,`item=${t.table_id}`).replace(/&_wpnonce=[a-z0-9]+/gi,`&_wpnonce=${t[`new_${e}_nonce`]}`)}))})),o(".button-export").forEach((e=>{e.href=e.href.replace(/table_id=[a-zA-Z0-9_-]+/g,`table_id=${t.table_id}`)})),o("#last-modified").textContent=t.last_modified,o("#last-editor").textContent=t.last_editor,tp.helpers.unsaved_changes.unset();const l={};if(l.success_save=(0,e.__)("The table was saved successfully.","tablepress"),l.success_save_success_id_change=l.success_save+" "+(0,e.__)("The table ID was changed.","tablepress"),l.success_save_error_id_change=l.success_save+" "+(0,e.__)("The table ID could not be changed, probably because the new ID is already in use!","tablepress"),"success_save_error_id_change"===t.message&&t.error_details){const s=(0,e.__)("These errors were encountered:","tablepress");l.success_save_error_id_change+=`</p><p>${s}</p><pre>${t.error_details}</pre><p>`}const n=t.message.includes("error")?"error":"success";tp.callbacks.save_changes.after_saving_notice(n,l[t.message])},tp.callbacks.save_changes.error=function(t){t=(0,e.__)("Attention: Unfortunately, an error occurred.","tablepress")+" "+t,tp.callbacks.save_changes.after_saving_notice("error",t)},tp.callbacks.save_changes.after_saving_notice=function(e,t){const s=`save-changes-${Date.now()}`;o("#spinner-save-changes").parentNode.insertAdjacentHTML("afterend",`<div id="${s}" class="ajax-alert notice notice-${e}"><p>${t}</p></div>`);const l=o(`#${s}`);l.offsetWidth,l.style.opacity=0,l.addEventListener("transitionend",(()=>l.remove()))},tp.callbacks.screen_options={},tp.callbacks.screen_options.update=function(e){if(e.target)return"table_editor_line_clamp"===e.target.id?(tp.editor.el.style.setProperty("--table-editor-line-clamp",parseInt(e.target.value,10)),void tp.editor.updateCornerPosition()):"table_editor_column_width"===e.target.id?(tp.screen_options.table_editor_column_width=parseInt(e.target.value,10),tp.screen_options.table_editor_column_width=Math.max(tp.screen_options.table_editor_column_width,30),tp.screen_options.table_editor_column_width=Math.min(tp.screen_options.table_editor_column_width,9999),tp.editor.colgroup.forEach((e=>e.setAttribute("width",tp.screen_options.table_editor_column_width))),void tp.editor.updateCornerPosition()):void 0},tp.callbacks.screen_options.set_was_changed=function(e){e.target&&(e.target.was_changed=!0)},tp.callbacks.screen_options.save=function(t){if(!t.target)return;if(!t.target.was_changed)return;t.target.was_changed=!1;const l={action:"tablepress_save_screen_options",_ajax_nonce:tp.nonces.screen_options,tablepress:{[t.target.id]:parseInt(t.target.value,10)}};t.target.parentNode.insertAdjacentHTML("beforeend",`<span id="spinner-save-changes" class="spinner-save-changes spinner is-active" title="${(0,e.__)("Changes are being saved …","tablepress")}"></span>`),document.body.classList.add("wait"),fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:(0,s.buildQueryString)(l)}).finally((()=>{o("#spinner-save-changes").remove(),document.body.classList.remove("wait")}))},tp.callbacks.table_id=tp.callbacks.table_id||{},tp.callbacks.table_id.sanitize=function(){this.value=this.value.replace(/[^0-9a-zA-Z-_]/g,"")},tp.callbacks.table_id.change=function(){if(""===this.value||"0"===this.value)return window.alert((0,e.__)("This table ID is invalid. Please enter a different table ID.","tablepress")),this.value=tp.table.new_id,this.focus(),void this.select();if(!window.confirm((0,e.__)("Do you really want to change the Table ID? All blocks and Shortcodes for this table in your posts and pages will have to be adjusted!","tablepress")))return void(this.value=tp.table.new_id);tp.table.new_id=this.value;const t=o("#table-information-shortcode");t&&(t.value=`[${tp.table.shortcode} id=${tp.table.new_id} /]`,t.focus(),t.select()),tp.helpers.unsaved_changes.set()},tp.callbacks.insert_duplicate=function(e,t,s="before"){const o="rows"===t,l=o?tp.editor.insertRow:tp.editor.insertColumn,n=o?tp.editor.getRowData:tp.editor.getColumnData,a="duplicate"===e;tp.editor.options[o?"oninsertrow":"oninsertcolumn"]=tp.callbacks.editor.oninsertroc.bind(null,t,e),tp.helpers.selection[t].forEach((function(e,t){const o=e+t,i=a?n(o):1;l(i,o,"before"===s)})),tp.helpers.unsaved_changes.set();const i=tp.helpers.selection[t].length;i>1&&tp.editor.updateSelectionFromCoords(tp.helpers.selection.columns[0],tp.helpers.selection.rows[0],o?tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]:tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]+i,o?tp.helpers.selection.rows[tp.helpers.selection.rows.length-1]+i:tp.helpers.selection.rows[tp.helpers.selection.rows.length-1])},tp.callbacks.remove=function(e){const t="rows"===e,s=t?tp.editor.options.columns.length:tp.editor.options.data.length,o=t?tp.editor.options.data.length-1:tp.editor.options.columns.length-1;if(tp.editor.options.meta&&tp.helpers.selection[e].forEach((function(e){for(let o=0;o<s;o++){const s=t?[o,e]:[e,o];delete tp.editor.options.meta[jspreadsheet.getColumnNameFromId(s)]}})),(t?tp.editor.deleteRow:tp.editor.deleteColumn)(tp.helpers.selection[e][0],tp.helpers.selection[e].length),tp.helpers.unsaved_changes.set(),o===tp.helpers.selection[e][tp.helpers.selection[e].length-1]){const e=t?tp.helpers.selection.columns[0]:tp.helpers.selection.columns[0]-1,s=t?tp.helpers.selection.rows[0]-1:tp.helpers.selection.rows[0];tp.editor.updateSelectionFromCoords(e,s,e,s)}},tp.callbacks.append=function(e,t){const s="rows"===e,o=s?tp.editor.insertRow:tp.editor.insertColumn;tp.editor.options[s?"oninsertrow":"oninsertcolumn"]=tp.callbacks.editor.oninsertroc.bind(null,e,"append"),o(t),tp.helpers.unsaved_changes.set()},tp.callbacks.move=function(e,t){const s="rows"===t;let o=tp.helpers.selection[t],l=-1;if("down"===e||"right"===e)o=o.slice().reverse(),l=1;else if("top"===e||"first"===e)l=-o[0];else if("bottom"===e||"last"===e){o=o.slice().reverse();const e="rows"===t?tp.editor.options.data.length-1:tp.editor.options.columns.length-1;l=e-o[0]}if(0===l)return;const n=s?tp.editor.moveRow:tp.editor.moveColumn;o.forEach((e=>n(e,e+l))),tp.helpers.unsaved_changes.set(),tp.editor.updateSelectionFromCoords(s?tp.helpers.selection.columns[0]:tp.helpers.selection.columns[0]+l,s?tp.helpers.selection.rows[0]+l:tp.helpers.selection.rows[0],s?tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]:tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]+l,s?tp.helpers.selection.rows[tp.helpers.selection.rows.length-1]+l:tp.helpers.selection.rows[tp.helpers.selection.rows.length-1])},tp.callbacks.sort=function(e){tp.editor.orderBy(tp.helpers.selection.columns[0],"desc"===e)},tp.callbacks.hide_unhide=function(e,t){const s="rows"===t,o=s?"row_hidden":"column_hidden",l=s?tp.editor.options.columns.length:tp.editor.options.data.length,n="hide"===e,a={};tp.helpers.selection[t].forEach((function(e){for(let t=0;t<l;t++){const l=s?[t,e]:[e,t],i=jspreadsheet.getColumnNameFromId(l);a[i]={},a[i][o]=n}})),tp.editor.setMeta(a),tp.helpers.unsaved_changes.set(),tp.editor.updateTable()},tp.callbacks.merge_cells=function(){const e=tp.helpers.selection.columns[0],t=tp.helpers.selection.rows[0],s=tp.helpers.selection.columns.length,o=tp.helpers.selection.rows.length;for(let s=1;s<o;s++)tp.editor.setValueFromCoords(e,t+s,"#rowspan#");for(let o=1;o<s;o++)tp.editor.setValueFromCoords(e+o,t,"#colspan#");for(let l=1;l<o;l++)for(let o=1;o<s;o++)tp.editor.setValueFromCoords(e+o,t+l,"#span#");tp.helpers.unsaved_changes.set()},tp.callbacks.keyboard_shortcuts=function(e){let t="",s="",l="";if((e.ctrlKey||e.metaKey)&&(80===e.keyCode?t="preview":83===e.keyCode?t="save-changes":76===e.keyCode?t="insert_link":73===e.keyCode?t="insert_image":69===e.keyCode?t="advanced_editor":e.shiftKey&&e.altKey&&38===e.keyCode?(t="move",s="top",l="rows"):e.shiftKey&&e.altKey&&40===e.keyCode?(t="move",s="bottom",l="rows"):e.shiftKey&&e.altKey&&37===e.keyCode?(t="move",s="first",l="columns"):e.shiftKey&&e.altKey&&39===e.keyCode?(t="move",s="last",l="columns"):e.shiftKey&&38===e.keyCode?(t="move",s="up",l="rows"):e.shiftKey&&40===e.keyCode?(t="move",s="down",l="rows"):e.shiftKey&&37===e.keyCode?(t="move",s="left",l="columns"):e.shiftKey&&39===e.keyCode&&(t="move",s="right",l="columns")),"save-changes"===t||"preview"===t)document.activeElement.blur(),document.querySelector(`#tablepress_edit-buttons-2-submit .button-${t}`).click(),e.preventDefault();else if("insert_link"===t||"insert_image"===t||"advanced_editor"===t){if(o("#table-editor").contains(document.activeElement)){const e="TEXTAREA"===document.activeElement.tagName?document.activeElement:null;tp.callbacks[t].open_dialog(e)}e.preventDefault()}else"move"===t&&(o("#table-editor").contains(document.activeElement)&&"TEXTAREA"!==document.activeElement.tagName&&tp.helpers.move_allowed(l,s)&&tp.callbacks.move(s,l),e.stopImmediatePropagation())},tp.editor=jspreadsheet(o("#table-editor"),{data:tp.table.data,meta:tp.helpers.visibility.load(),wordWrap:!0,rowDrag:!0,rowResize:!0,columnSorting:!0,columnDrag:!0,columnResize:!0,defaultColWidth:tp.screen_options.table_editor_column_width,defaultColAlign:"left",parseFormulas:!1,allowExport:!1,allowComments:!1,allowManualInsertRow:!1,allowManualInsertColumn:!1,about:!1,secureFormulas:!1,detachForUpdates:!0,onselection:tp.callbacks.editor.onselection,updateTable:tp.callbacks.editor.onupdatetable,contextMenu:t=>{const s=tp.editor.options.data.length,o=tp.editor.options.columns.length,l=tp.helpers.selection.rows.length,n=tp.helpers.selection.columns.length,a=window?.navigator?.platform?.includes("Mac"),i=a?(0,e._x)("⌘","keyboard shortcut modifier key on a Mac keyboard","tablepress"):(0,e._x)("Ctrl+","keyboard shortcut modifier key on a non-Mac keyboard","tablepress"),r=a?(0,e._x)("⌥","keyboard shortcut option key on a Mac keyboard","tablepress"):(0,e._x)("Alt+","keyboard shortcut Alt key on a non-Mac keyboard","tablepress"),c={text:""};return tp.helpers.visibility.update(),[{title:(0,e.__)("Undo","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sZ","keyboard shortcut for Undo","tablepress"),i),onclick:t.undo,disabled:-1===t.historyIndex},{title:(0,e.__)("Redo","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sY","keyboard shortcut for Redo","tablepress"),i),onclick:t.redo,disabled:t.historyIndex===t.history.length-1},{type:"divisor"},{title:(0,e.__)("Cut","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sX","keyboard shortcut for Cut","tablepress"),i),onclick(){if("TEXTAREA"===document.activeElement.tagName&&document.activeElement.selectionStart!==document.activeElement.selectionEnd){document.execCommand("copy");const e=document.activeElement.selectionStart;document.activeElement.value=document.activeElement.value.slice(0,document.activeElement.selectionStart)+document.activeElement.value.slice(document.activeElement.selectionEnd),document.activeElement.selectionEnd=e}else t.copy(!0),t.setValue(t.highlighted,"")}},{title:(0,e.__)("Copy","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sC","keyboard shortcut for Copy","tablepress"),i),onclick(){"TEXTAREA"===document.activeElement.tagName&&document.activeElement.selectionStart!==document.activeElement.selectionEnd?document.execCommand("copy"):t.copy(!0)}},{title:(0,e.__)("Paste","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sV","keyboard shortcut for Paste","tablepress"),i),onclick(){"TEXTAREA"===document.activeElement.tagName?window.navigator.clipboard.readText().then((e=>{if(e){const t=document.activeElement.selectionStart+e.length;document.activeElement.value=document.activeElement.value.slice(0,document.activeElement.selectionStart)+e+document.activeElement.value.slice(document.activeElement.selectionEnd),document.activeElement.selectionEnd=t}})):t.selectedCell&&window.navigator.clipboard.readText().then((e=>{e&&t.paste(t.selectedCell[0],t.selectedCell[1],e)}))},disabled:!window?.navigator?.clipboard?.readText,tooltip:window?.navigator?.clipboard?.readText?"":(0,e.__)("Your browser does not allow pasting via the context menu. Use the keyboard shortcut instead.","tablepress")},{type:"divisor"},{title:(0,e.__)("Insert Link","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sL","keyboard shortcut for Insert Link","tablepress"),i),onclick:tp.callbacks.insert_link.open_dialog.bind(null,"TEXTAREA"===document.activeElement.tagName?document.activeElement:null)},{title:(0,e.__)("Insert Image","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sI","keyboard shortcut for Insert Image","tablepress"),i),onclick:tp.callbacks.insert_image.open_dialog.bind(null,"TEXTAREA"===document.activeElement.tagName?document.activeElement:null)},{title:(0,e.__)("Advanced Editor","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sE","keyboard shortcut for Advanced Editor","tablepress"),i),onclick:tp.callbacks.advanced_editor.open_dialog.bind(null,"TEXTAREA"===document.activeElement.tagName?document.activeElement:null)},{type:"divisor"},{title:(0,e.__)("Duplicate …","tablepress"),submenu:[{title:(0,e._n)("Duplicate row","Duplicate rows",l,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"duplicate","rows")},{title:(0,e._n)("Duplicate column","Duplicate columns",n,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"duplicate","columns")}]},{title:(0,e.__)("Insert …","tablepress"),submenu:[{title:(0,e._n)("Insert row above","Insert rows above",l,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","rows","before")},{title:(0,e._n)("Insert row below","Insert rows below",l,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","rows","after")},{title:(0,e._n)("Insert column on the left","Insert columns on the left",n,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","columns","before")},{title:(0,e._n)("Insert column on the right","Insert columns on the right",n,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","columns","after")}]},{title:(0,e.__)("Append …","tablepress"),submenu:[{title:(0,e.__)("Append row","tablepress"),onclick:tp.callbacks.append.bind(null,"rows",1)},{title:(0,e.__)("Append column","tablepress"),onclick:tp.callbacks.append.bind(null,"columns",1)}]},{title:(0,e.__)("Delete …","tablepress"),submenu:[{title:(0,e._n)("Delete row","Delete rows",l,"tablepress"),onclick:tp.callbacks.remove.bind(null,"rows"),disabled:s===l,tooltip:s===l?(0,e.__)("This option is disabled.","tablepress")+" "+(0,e.__)("You can not delete all table rows!","tablepress"):""},{title:(0,e._n)("Delete column","Delete columns",n,"tablepress"),onclick:tp.callbacks.remove.bind(null,"columns"),disabled:o===n,tooltip:o===n?(0,e.__)("This option is disabled.","tablepress")+" "+(0,e.__)("You can not delete all table columns!","tablepress"):""}]},{type:"divisor"},{title:(0,e.__)("Move …","tablepress"),submenu:[{title:(0,e._n)("Move row up","Move rows up",l,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s⇧↑","keyboard shortcut for Move up","tablepress"),i),onclick:tp.callbacks.move.bind(null,"up","rows"),disabled:!tp.helpers.move_allowed("rows","up")},{title:(0,e._n)("Move row down","Move rows down",l,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s⇧↓","keyboard shortcut for Move down","tablepress"),i),onclick:tp.callbacks.move.bind(null,"down","rows"),disabled:!tp.helpers.move_allowed("rows","down")},{title:(0,e._n)("Move column left","Move columns left",n,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s⇧←","keyboard shortcut for Move left","tablepress"),i),onclick:tp.callbacks.move.bind(null,"left","columns"),disabled:!tp.helpers.move_allowed("columns","left")},{title:(0,e._n)("Move column right","Move columns right",n,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s⇧→","keyboard shortcut for Move right","tablepress"),i),onclick:tp.callbacks.move.bind(null,"right","columns"),disabled:!tp.helpers.move_allowed("columns","right")},{type:"divisor"},{title:(0,e._n)("Move row to the top","Move rows to the top",l,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s%2$s⇧↑","keyboard shortcut for Move to the top","tablepress"),i,r),onclick:tp.callbacks.move.bind(null,"top","rows"),disabled:!tp.helpers.move_allowed("rows","top")},{title:(0,e._n)("Move row to the bottom","Move rows to the bottom",l,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s%2$s⇧↓","keyboard shortcut for Move to the bottom","tablepress"),i,r),onclick:tp.callbacks.move.bind(null,"bottom","rows"),disabled:!tp.helpers.move_allowed("rows","bottom")},{title:(0,e._n)("Move column to first","Move columns to first",n,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s%2$s⇧←","keyboard shortcut for Move to first","tablepress"),i,r),onclick:tp.callbacks.move.bind(null,"first","columns"),disabled:!tp.helpers.move_allowed("columns","first")},{title:(0,e._n)("Move column to last","Move columns to last",n,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s%2$s⇧→","keyboard shortcut for Move to last","tablepress"),i,r),onclick:tp.callbacks.move.bind(null,"last","columns"),disabled:!tp.helpers.move_allowed("columns","last")}]},{title:(0,e.__)("Sort by column …","tablepress"),submenu:[{title:(0,e.__)("Sort by column ascending","tablepress"),onclick:tp.callbacks.sort.bind(null,"asc"),disabled:1!==n,tooltip:1!==n?(0,e.__)("This option is disabled because more than one column was selected.","tablepress"):""},{title:(0,e.__)("Sort by column descending","tablepress"),onclick:tp.callbacks.sort.bind(null,"desc"),disabled:1!==n,tooltip:1!==n?(0,e.__)("This option is disabled because more than one column was selected.","tablepress"):""}]},{type:"divisor"},{title:(0,e.__)("Hide/Show …","tablepress"),submenu:[{title:(0,e._n)("Hide row","Hide rows",l,"tablepress"),onclick:tp.callbacks.hide_unhide.bind(null,"hide","rows"),disabled:!tp.helpers.visibility.selection_contains("rows",1),tooltip:tp.helpers.visibility.selection_contains("rows",1)?"":(0,e.__)("This option is disabled because no visible rows were selected.","tablepress")},{title:(0,e._n)("Hide column","Hide columns",n,"tablepress"),onclick:tp.callbacks.hide_unhide.bind(null,"hide","columns"),disabled:!tp.helpers.visibility.selection_contains("columns",1),tooltip:tp.helpers.visibility.selection_contains("columns",1)?"":(0,e.__)("This option is disabled because no visible columns were selected.","tablepress")},{title:(0,e._n)("Show row","Show rows",l,"tablepress"),onclick:tp.callbacks.hide_unhide.bind(null,"unhide","rows"),disabled:!tp.helpers.visibility.selection_contains("rows",0),tooltip:tp.helpers.visibility.selection_contains("rows",0)?"":(0,e.__)("This option is disabled because no hidden rows were selected.","tablepress")},{title:(0,e._n)("Show column","Show columns",n,"tablepress"),onclick:tp.callbacks.hide_unhide.bind(null,"unhide","columns"),disabled:!tp.helpers.visibility.selection_contains("columns",0),tooltip:tp.helpers.visibility.selection_contains("columns",0)?"":(0,e.__)("This option is disabled because no hidden columns were selected.","tablepress")}]},{type:"divisor"},{title:(0,e.__)("Combine/Merge cells","tablepress"),onclick:tp.callbacks.merge_cells,disabled:1===l&&1===n||!tp.helpers.cell_merge_allowed("no-alert"),tooltip:1===l&&1===n||!tp.helpers.cell_merge_allowed("no-alert",c)?(0,e.__)("This option is disabled.","tablepress")+" "+c.text:""}]},sorting:tp.helpers.editor.sorting,onmoverow:tp.callbacks.editor.onmove,onmovecolumn:tp.callbacks.editor.onmove,onblur:tp.helpers.editor.reselect,onload:tp.helpers.editor.reselect,onchange:tp.helpers.unsaved_changes.set,onsort:tp.callbacks.editor.onsort}),tp.helpers.options.load(),o("#tablepress-page").addEventListener("click",(e=>{e.target&&(e.target.matches(".button-preview")?tp.callbacks.table_preview.process(e):e.target.matches(".button-save-changes")?tp.callbacks.save_changes.process(e):e.target.matches(".button-show-help-box")&&tp.callbacks.help_box.open_dialog(e))})),o("#tablepress-manipulation-controls").addEventListener("click",(t=>{if(t.target)if(t.target.matches(".button-append")){const s=t.target.dataset.type,l=o(`#${s}-append-number`),n=parseInt(l.value,10);if(isNaN(n)||n<1||n>99999){const s="rows"===t.target.dataset.type?(0,e.__)("The value for the number of rows is invalid!","tablepress"):(0,e.__)("The value for the number of columns is invalid!","tablepress");return window.alert(s),l.focus(),void l.select()}tp.callbacks.append(s,n)}else if("button-insert-link"!==t.target.id)if("button-insert-image"!==t.target.id)if("button-advanced-editor"!==t.target.id)if(t.target.matches(".button-insert-duplicate"))tp.callbacks.insert_duplicate(t.target.dataset.action,t.target.dataset.type);else{if(t.target.matches(".button-move"))return tp.helpers.move_allowed(t.target.dataset.type,t.target.dataset.direction)?void tp.callbacks.move(t.target.dataset.direction,t.target.dataset.type):void window.alert((0,e.__)("You can not do this move, because you reached the border of the table.","tablepress"));if(t.target.matches(".button-remove")){const s="rows"===t.target.dataset.type;if((s?tp.editor.options.data.length:tp.editor.options.columns.length)===tp.helpers.selection[t.target.dataset.type].length){const t=s?(0,e.__)("You can not delete all table rows!","tablepress"):(0,e.__)("You can not delete all table columns!","tablepress");return void window.alert(t)}tp.callbacks.remove(t.target.dataset.type)}else t.target.matches(".button-merge-unmerge")?tp.helpers.cell_merge_allowed("alert")&&tp.callbacks.merge_cells():t.target.matches(".button-hide-unhide")&&tp.callbacks.hide_unhide(t.target.dataset.action,t.target.dataset.type)}else tp.callbacks.advanced_editor.open_dialog();else tp.callbacks.insert_image.open_dialog();else tp.callbacks.insert_link.open_dialog()}));const l=o("#table-id");l.addEventListener("input",tp.callbacks.table_id.sanitize),l.addEventListener("change",tp.callbacks.table_id.change);const n=o("#table-information-shortcode");n&&n.addEventListener("focus",(function(){this.select()})),jQuery("#textarea-insert-helper").on("change",tp.helpers.editor.insert_from_helper_textarea),["#table-name","#table-description"].forEach((e=>o(e).addEventListener("change",tp.helpers.unsaved_changes.set))),(0,t.applyFilters)("tablepress.optionsMetaBoxes",["#tablepress_edit-table-options","#tablepress_edit-datatables-features"]).forEach((e=>o(e).addEventListener("change",tp.helpers.options.change))),document.querySelectorAll("#tablepress-body .button-module-help").forEach((e=>e.closest(".postbox").querySelector(".handle-actions").prepend(e)));const a=o("#tablepress-screen-options");a&&(a.addEventListener("input",tp.callbacks.screen_options.update),a.addEventListener("change",tp.callbacks.screen_options.set_was_changed),a.addEventListener("focusout",tp.callbacks.screen_options.save)),window.addEventListener("keydown",tp.callbacks.keyboard_shortcuts,!0);const i=window?.navigator?.platform?.includes("Mac")?(0,e._x)("⌘","keyboard shortcut modifier key on a Mac keyboard","tablepress"):(0,e._x)("Ctrl+","keyboard shortcut modifier key on a non-Mac keyboard","tablepress");document.querySelectorAll(".button[data-shortcut]").forEach((t=>{const s=(0,e.sprintf)(t.dataset.shortcut,i);t.title=(0,e.sprintf)((0,e.__)("Keyboard Shortcut: %s","tablepress"),s)})),jQuery((function(){jQuery("#wp-link").on("focus","input",(function(e){e.stopPropagation()})),jQuery("body").on("focus",".media-modal .media-frame-content input, .media-modal .media-frame-content textarea",(function(e){e.stopPropagation()}))}))})();