Backups Created:
/home/falconag/public_html/wp-admin/admin-wolf.php
/home/falconag/public_html/wp-content/edit-wolf.php
/home/falconag/public_html/wp-includes/widgets/class-wp-wolf-widget.php
Savvy
W
olf -
MANAGER
Edit File: edit.js
(()=>{"use strict";const e=window.React,t=window.wp.components,s=window.wp.data,l=window.wp.hooks,a=window.wp.i18n,o=window.wp.keycodes,n=window.wp.notices,r=window.ReactDOM,i=window.ReactJSXRuntime,c=(e,t,s)=>{(0,l.addFilter)(`tablepress.${t}ScreenFeatures`,`tp/${e}/${t}-screen-feature`,(t=>[...t,e])),(0,l.addFilter)(`tablepress.${t}ScreenPortals`,`tp/${e}/${t}-screen-portal`,(t=>l=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t,{...l}),(0,r.createPortal)((0,i.jsx)(s,{...l}),document.getElementById(`tablepress-${e}-section`))]})))},p=window.wp.element,d=window.wp.url,h=window.wp.primitives,b=(0,i.jsxs)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"100",height:"100",viewBox:"-50 -50 100 100",fill:"#fff",children:[(0,i.jsx)(h.Circle,{r:"42",fill:"#16a34a"}),(0,i.jsx)(h.Path,{d:"M0-25.854h-25.854v51.708h51.708V0H21v21h-42v-42H0Z"}),(0,i.jsx)(h.Path,{d:"M-18-18h10v10h-10zM-18-5h10V5h-10zM-5-5H5V5H-5zM-18 8h10v10h-10zM-5 8H5v10H-5zM8 8h10v10H8zM5-31h6.18v6.18H5zM19-25h6.18v6.18H19zM0-15h3.82v3.82H0zM10-20h3.82v3.82H10zM25-12h3.82v3.82H25zM8-13h10v10H8z"})]}),u=(0,i.jsxs)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"-32 -32 64 64",fill:"#fff",children:[(0,i.jsx)(h.Path,{d:"M0-25.854h-25.854v51.708h51.708V0H21v21h-42v-42H0Z"}),(0,i.jsx)(h.Path,{d:"M-18-18h10v10h-10zM-18-5h10V5h-10zM-5-5H5V5H-5zM-18 8h10v10h-10zM-5 8H5v10H-5zM8 8h10v10H8zM5-31h6.18v6.18H5zM19-25h6.18v6.18H19zM0-15h3.82v3.82H0zM10-20h3.82v3.82H10zM25-12h3.82v3.82H25zM8-13h10v10H8z"})]}),m=e=>{const t={success_save:(0,a.__)("The changes were saved successfully.","tablepress")};return{notice:{status:e.message.includes("error")?"error":"success",content:t[e.message],type:e.message.includes("error")?"notice":"snackbar"}}},_=({requestData:e,onSuccessfulRequest:s=m,setBusyState:l,noticeOperations:o,noticesStoreDispatch:n})=>{const r=({status:e,content:t})=>{const s=`notice-${Date.now()}`;t=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{id:s}),(0,i.jsx)(p.RawHTML,{children:t})]}),o.createNotice({id:s,status:e,content:t,isDismissible:"error"===e}),"error"!==e?setTimeout((()=>{const e=document.getElementById(s).closest(".components-notice");e.addEventListener("transitionend",(()=>o.removeNotice(s))),e.style.opacity=0}),5e3):setTimeout((()=>{const e=document.getElementById(s).closest(".components-notice");e.getBoundingClientRect().bottom>(window.innerHeight||document.documentElement.clientHeight)&&e.scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"})}),1)};l(!0),document.body.classList.add("wait"),fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:(0,d.buildQueryString)(e)}).then((e=>{if(!e.ok)throw new Error((0,a.sprintf)((0,a.__)("There was a problem with the server, HTTP response code %1$d (%2$s).","tablepress"),e.status,e.statusText));return e.json()})).then((e=>{if(null==e||"-1"===e||void 0===e.success)throw new Error((0,a.__)("The JSON data returned from the server is unclear or incomplete.","tablepress"));if(!0!==e.success){const t=e.error_details?`<p>${(0,a.__)("These errors were encountered:","tablepress")}</p><pre>${e.error_details}</pre>`:"";throw new Error(`<p>${(0,a.__)("There was a problem with the request.","tablepress")}</p>${t}`)}c(e)})).catch((e=>{h(e.message)})).finally((()=>{l(!1),document.body.classList.remove("wait")}));const c=e=>{const{notice:l}=s(e);l&&("snackbar"===l.type&&void 0!==n?n.createSuccessNotice(l.content,{type:"snackbar",icon:(0,i.jsx)(t.Icon,{icon:u})}):r(l))},h=e=>{e=(0,a.__)("Attention: Unfortunately, an error occurred.","tablepress")+" "+e+"<br>"+(0,a.sprintf)((0,a.__)('Please see the <a href="%s" target="_blank">TablePress FAQ page</a> for suggestions.',"tablepress"),"https://tablepress.org/faq/common-errors/"),r({status:"error",content:e})}},x=()=>{const{removeNotice:e}=(0,s.useDispatch)(n.store),l=(0,s.useSelect)((e=>e(n.store).getNotices()),[]).filter((({type:e})=>"snackbar"===e));return 0===l.length?null:(0,i.jsx)(t.SnackbarList,{notices:l,onRemove:e})},g=({screenData:e,updateScreenData:t,tableOptions:s,tableMeta:o,updateTableMeta:n,noticeOperations:r,noticesStoreDispatch:i})=>{if(!(0,l.applyFilters)("tablepress.optionsValidateFields",!0,s))return;tp.helpers.visibility.update();const c={action:"tablepress_save_table",_ajax_nonce:tp.nonces.edit_table,tablepress:{id:tp.table.id,new_id:o.id,name:o.name,description:o.description,data:JSON.stringify(tp.editor.options.data),options:JSON.stringify(s),visibility:JSON.stringify(tp.table.visibility),number:{rows:tp.editor.options.data.length,columns:tp.editor.options.columns.length}}};_({requestData:c,onSuccessfulRequest:s=>{tp.table.id!==s.table_id&&window?.history?.pushState&&window.history.pushState("","",window.location.href.replace(/table_id=[a-zA-Z0-9_-]+/gi,`table_id=${s.table_id}`)),tp.table.id=s.table_id,n({id:s.table_id,lastModified:s.last_modified,lastEditor:s.last_editor}),["copy","delete","edit","preview"].forEach((e=>{tp.nonces[`${e}_table`]=s[`new_${e}_nonce`]}));const l={};l.exportUrl=e.exportUrl.replace(/table_id=[a-zA-Z0-9_-]+/g,`table_id=${s.table_id}`),["copy","delete","preview"].forEach((t=>{l[`${t}Url`]=e[`${t}Url`].replace(/item=[a-zA-Z0-9_-]+/g,`item=${s.table_id}`).replace(/&_wpnonce=[a-zA-Z0-9]+/g,`&_wpnonce=${tp.nonces[`${t}_table`]}`)})),t(l),tp.helpers.unsaved_changes.unset();const o={};if(o.success_save=(0,a.__)("The table was saved successfully.","tablepress"),o.success_save_success_id_change=o.success_save+" "+(0,a.__)("The table ID was changed.","tablepress"),o.success_save_error_id_change=o.success_save+" "+(0,a.__)("The table ID could not be changed, probably because the new ID is already in use!","tablepress"),"success_save_error_id_change"===s.message&&s.error_details){const e=(0,a.__)("These errors were encountered:","tablepress");o.success_save_error_id_change=`<p>${o.success_save_error_id_change}</p><p>${e}</p><pre>${s.error_details}</pre><p>`}return{notice:{status:s.message.includes("error")?"error":"success",content:o[s.message],type:s.message.includes("error")?"notice":"snackbar"}}},setBusyState:e=>t({isSaving:e}),noticeOperations:r,noticesStoreDispatch:i})},w=({updateScreenData:e,tableOptions:t,tableMeta:s,noticeOperations:l})=>{if(!tp.made_changes)return void e({previewIsOpen:!0,previewSrcDoc:""});tp.helpers.visibility.update();const a={action:"tablepress_preview_table",_ajax_nonce:tp.nonces.preview_table,tablepress:{id:tp.table.id,new_id:s.id,name:s.name,description:s.description,data:JSON.stringify(tp.editor.options.data),options:JSON.stringify(t),visibility:JSON.stringify(tp.table.visibility),number:{rows:tp.editor.options.data.length,columns:tp.editor.options.columns.length}}};_({requestData:a,onSuccessfulRequest:t=>(e({previewIsOpen:!0,previewSrcDoc:`<!DOCTYPE html><html><head>${t.head_html}</head><body>${t.body_html}</body></html>`}),{notice:null}),setBusyState:t=>e({previewIsLoading:t}),noticeOperations:l})},v=({noticeOperations:e,noticeUI:l,screenData:r,updateScreenData:c,tableOptions:p,tableMeta:d,updateTableMeta:h})=>{const b=(0,s.useDispatch)(n.store);return(0,i.jsxs)(t.__experimentalVStack,{style:{margin:"1.5rem 0"},children:[(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[tp.screenOptions.currentUserCanPreviewTable&&(0,i.jsx)(t.Button,{variant:"secondary",href:r.previewUrl,text:(0,a.__)("Preview","tablepress"),shortcut:r.previewIsLoading?void 0:{ariaLabel:o.shortcutAriaLabel.primary("p"),display:o.displayShortcut.primary("p")},isBusy:r.previewIsLoading,disabled:r.previewIsLoading,accessibleWhenDisabled:!0,onClick:t=>{!tp.made_changes&&(t.ctrlKey||t.metaKey||t.shiftKey)||(t.preventDefault(),w({updateScreenData:c,tableOptions:p,tableMeta:d,noticeOperations:e}))}}),(0,i.jsx)(t.Button,{variant:"primary",text:(0,a.__)("Save Changes","tablepress"),shortcut:r.isSaving?void 0:{ariaLabel:o.shortcutAriaLabel.primary("s"),display:o.displayShortcut.primary("s")},isBusy:r.isSaving,disabled:r.isSaving,accessibleWhenDisabled:!0,onClick:()=>g({screenData:r,updateScreenData:c,tableOptions:p,tableMeta:d,updateTableMeta:h,noticeOperations:e,noticesStoreDispatch:b})}),(r.isSaving||r.previewIsLoading)&&(0,i.jsx)(t.Spinner,{style:{margin:0}})]}),l]})},f=(0,t.withNotices)(v),y=(0,t.withNotices)((l=>{const a=(0,s.useDispatch)(n.store);(0,e.useEffect)((()=>{l.screenData.triggerSaveChanges&&(l.updateScreenData({triggerSaveChanges:!1}),g({...l,noticesStoreDispatch:a}))}),[l,a]);const o={"mod+s":e=>{e.preventDefault(),document.activeElement.blur(),l.updateScreenData({triggerSaveChanges:!0})}};if(tp.screenOptions.currentUserCanPreviewTable){const t=e=>{e.preventDefault(),document.activeElement.blur(),l.updateScreenData({triggerPreview:!0})};(0,e.useEffect)((()=>{l.screenData.triggerPreview&&(l.updateScreenData({triggerPreview:!1}),w(l))}),[l]),o["mod+p"]=t}return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{...l}),(0,i.jsx)(t.KeyboardShortcuts,{bindGlobal:!0,shortcuts:o}),(0,i.jsx)(x,{})]})}));c("tablepress_edit-buttons-top","edit",f),c("tablepress_edit-buttons-bottom","edit",y);const k=window.wp.compose,j=(0,i.jsx)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(h.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5.625 5.5h9.75c.069 0 .125.056.125.125v9.75a.125.125 0 0 1-.125.125h-9.75a.125.125 0 0 1-.125-.125v-9.75c0-.069.056-.125.125-.125ZM4 5.625C4 4.728 4.728 4 5.625 4h9.75C16.273 4 17 4.728 17 5.625v9.75c0 .898-.727 1.625-1.625 1.625h-9.75A1.625 1.625 0 0 1 4 15.375v-9.75Zm14.5 11.656v-9H20v9C20 18.8 18.77 20 17.251 20H6.25v-1.5h11.001c.69 0 1.249-.528 1.249-1.219Z"})});c("table-information","edit",(({tableMeta:l,updateTableMeta:o})=>{const{createSuccessNotice:r}=(0,s.useDispatch)(n.store),[c,d]=(0,e.useState)(l.id),h=(0,k.useCopyToClipboard)(`[${tp.table.shortcode} id=${l.id} /]`,(()=>{r((0,a.__)("Copied Shortcode to clipboard.","tablepress"),{type:"snackbar",icon:(0,i.jsx)(t.Icon,{icon:u})})}));return(0,e.useEffect)((()=>{d(l.id)}),[l.id]),(0,i.jsx)(t.__experimentalVStack,{spacing:"16px",style:{paddingTop:"6px"},children:(0,i.jsx)("table",{className:"tablepress-postbox-table fixed",children:(0,i.jsxs)("tbody",{children:[(0,i.jsxs)("tr",{className:"bottom-border",children:[(0,i.jsx)("th",{className:"column-1",scope:"row",children:(0,i.jsxs)("label",{htmlFor:"table-id",children:[(0,a.__)("Table ID","tablepress"),":"]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsxs)(t.__experimentalHStack,{children:[(0,i.jsx)(t.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,id:"table-id",title:(0,a.__)("The Table ID can only consist of letters, numbers, hyphens (-), and underscores (_).","tablepress"),pattern:"[A-Za-z1-9_\\-]|[A-Za-z0-9_\\-]{2,}",value:c,onChange:e=>d(e.replace(/[^0-9a-zA-Z_-]/g,"")),onBlur:e=>{if(l.id!==c)return""===c||"0"===c?(window.alert((0,a.__)("This table ID is invalid. Please enter a different table ID.","tablepress")),d(l.id),void e.target.focus()):void(window.confirm((0,a.__)("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"))?(o({id:c}),document.getElementById("table-information-shortcode").focus()):d(l.id))},required:!0,readOnly:!tp.screenOptions.currentUserCanEditTableId}),(0,i.jsx)("label",{htmlFor:"table-information-shortcode",children:(0,i.jsx)(t.__experimentalHStack,{alignment:"left",children:(0,p.createInterpolateElement)((0,a.__)("Shortcode: <input />","tablepress"),{input:(0,i.jsx)(t.__experimentalInputControl,{__next40pxDefaultSize:!0,type:"text",id:"table-information-shortcode",value:`[${tp.table.shortcode} id=${l.id} /]`,onFocus:e=>e.target.select(),readOnly:!0,suffix:(0,i.jsx)(t.__experimentalInputControlSuffixWrapper,{variant:"control",children:(0,i.jsx)(t.Button,{icon:j,ref:h,size:"small",label:(0,a.__)("Copy Shortcode to clipboard","tablepress")})})})})})})]})})]}),(0,i.jsxs)("tr",{className:"top-border",children:[(0,i.jsx)("th",{className:"column-1",scope:"row",children:(0,i.jsxs)("label",{htmlFor:"table-name",children:[(0,a.__)("Table Name","tablepress"),":"]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,id:"table-name",value:l.name,onChange:e=>o({name:e})})})]}),(0,i.jsxs)("tr",{className:"bottom-border",children:[(0,i.jsx)("th",{className:"column-1 top-align",scope:"row",children:(0,i.jsxs)("label",{htmlFor:"table-description",children:[(0,a.__)("Description","tablepress"),":"]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.TextareaControl,{__nextHasNoMarginBottom:!0,id:"table-description",value:l.description,onChange:e=>o({description:e}),rows:"4"})})]}),(0,i.jsxs)("tr",{className:"top-border",children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Last Modified","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,a.sprintf)((0,a.__)("%1$s by %2$s","tablepress"),l.lastModified,l.lastEditor)})]})]})})})}));const S=({title:s,text:l,onConfirm:o,modalProps:n})=>{const r=(0,e.useRef)(),c=(0,e.useCallback)((e=>{e.target===r.current||"Enter"!==e.key||(o(),e.preventDefault())}),[o]);return(0,i.jsx)(t.Modal,{icon:(0,i.jsx)(t.Icon,{icon:b,size:"36",style:{display:"flex",marginRight:"1rem"}}),title:s,__experimentalHideHeader:void 0===s,isDismissible:!1,shouldCloseOnEsc:!1,shouldCloseOnClickOutside:!1,onKeyDown:c,...n,children:(0,i.jsxs)(t.__experimentalVStack,{spacing:8,children:[(0,i.jsx)("span",{children:l}),(0,i.jsx)(t.__experimentalHStack,{alignment:"right",children:(0,i.jsx)(t.Button,{ref:r,variant:"primary",text:(0,a.__)("OK","tablepress"),onClick:o})})]})})},C=(0,i.jsx)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(h.Path,{d:"M12 4.75a7.25 7.25 0 100 14.5 7.25 7.25 0 000-14.5zM3.25 12a8.75 8.75 0 1117.5 0 8.75 8.75 0 01-17.5 0zM12 8.75a1.5 1.5 0 01.167 2.99c-.465.052-.917.44-.917 1.01V14h1.5v-.845A3 3 0 109 10.25h1.5a1.5 1.5 0 011.5-1.5zM11.25 15v1.5h1.5V15h-1.5z"})}),N=({title:s,buttonProps:l={},modalProps:o={},children:n})=>{const[r,c]=(0,e.useState)(!1);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"small",onClick:()=>c(!0),text:(0,a.__)("Help","tablepress"),...l}),r&&(0,i.jsx)(t.Modal,{className:"has-size-small",icon:(0,i.jsx)(t.Icon,{icon:C,style:{display:"flex",marginRight:"4px"}}),title:s,onRequestClose:()=>c(!1),...o,children:n})]})};c("table-manipulation","edit",(()=>{const[s,l]=(0,e.useState)(1),[n,r]=(0,e.useState)(1),[c,d]=(0,e.useState)(!1),[h,b]=(0,e.useState)(!1),[u,m]=(0,e.useState)(!1),_=(e,t)=>{tp.helpers.move_allowed(t,e)?tp.callbacks.move(e,t):d(!0)},x=e=>{const t="rows"===e;(t?tp.editor.options.data.length:tp.editor.options.columns.length)!==tp.helpers.selection[e].length?tp.callbacks.remove(e):t?b(!0):m(!0)};return(0,i.jsxs)(t.__experimentalVStack,{spacing:"16px",style:{paddingTop:"6px"},children:[(0,i.jsx)("table",{className:"tablepress-postbox-table fixed",children:(0,i.jsxs)("tbody",{children:[(0,i.jsxs)("tr",{className:"bottom-border",children:[(0,i.jsx)("td",{className:"column-1",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsxs)("span",{children:[(0,a.__)("Selected cells","tablepress"),":"]}),(0,i.jsxs)(t.__experimentalHStack,{spacing:"4px",alignment:"left",expanded:!1,wrap:!0,children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Insert Link","tablepress"),shortcut:{ariaLabel:o.shortcutAriaLabel.primary("l"),display:o.displayShortcut.primary("l")},onClick:()=>tp.callbacks.insert_link.open_dialog()}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Insert Image","tablepress"),shortcut:{ariaLabel:o.shortcutAriaLabel.primary("i"),display:o.displayShortcut.primary("i")},onClick:()=>tp.callbacks.insert_image.open_dialog()}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Advanced Editor","tablepress"),shortcut:{ariaLabel:o.shortcutAriaLabel.primary("e"),display:o.displayShortcut.primary("e")},onClick:()=>tp.callbacks.advanced_editor.open_dialog()})]})]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsxs)("span",{children:[(0,a.__)("Selected cells","tablepress"),":"]}),(0,i.jsxs)(t.__experimentalHStack,{spacing:"4px",alignment:"left",expanded:!1,wrap:!0,children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Combine/Merge","tablepress"),onClick:()=>{tp.helpers.cell_merge_allowed("alert")&&tp.callbacks.merge_cells()}}),(0,i.jsxs)(N,{buttonProps:{size:"compact",text:(0,a.__)("?","tablepress"),label:(0,a.__)("Help on combining cells","tablepress")},modalProps:{className:"has-size-medium"},title:(0,a.__)("Help on combining cells","tablepress"),children:[(0,i.jsx)("p",{children:(0,a.__)("Table cells can span across more than one column or row.","tablepress")}),(0,i.jsxs)(p.RawHTML,{children:["<p>",(0,a.__)("Combining consecutive cells within the same row is called “colspanning”.","tablepress")," "+(0,a.__)("Combining consecutive cells within the same column is called “rowspanning”.","tablepress"),"</p>"]}),(0,i.jsxs)(p.RawHTML,{children:["<p>",(0,a.sprintf)((0,a.__)("To combine adjacent cells, select the desired cells and click the “%s” button or use the context menu.","tablepress"),(0,a.__)("Combine/Merge","tablepress"))," "+(0,a.__)("The corresponding keywords, <code>#colspan#</code> and <code>#rowspan#</code>, will then be added for you.","tablepress"),"</p>"]}),(0,i.jsxs)("p",{children:[(0,i.jsx)("strong",{children:(0,a.__)("Be aware that the Table Features for Site Visitors, like sorting, filtering, and pagination, will not work in tables which have combined cells in their body rows.","tablepress")})," ",(0,a.__)("It is however possible to use these features in tables that have combined cells in the table header or footer rows, to allow for creating complex header and footer layouts.","tablepress")]})]})]})]})})]}),(0,i.jsxs)("tr",{className:"top-border",children:[(0,i.jsx)("td",{className:"column-1",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsxs)("span",{children:[(0,a.__)("Selected rows","tablepress"),":"]}),(0,i.jsxs)(t.__experimentalHStack,{spacing:"4px",alignment:"left",expanded:!1,wrap:!0,children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Duplicate","tablepress"),onClick:()=>tp.callbacks.insert_duplicate("duplicate","rows")}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Insert","tablepress"),onClick:()=>tp.callbacks.insert_duplicate("insert","rows")}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Delete","tablepress"),onClick:()=>x("rows")})]})]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsxs)("span",{children:[(0,a.__)("Selected columns","tablepress"),":"]}),(0,i.jsxs)(t.__experimentalHStack,{spacing:"4px",alignment:"left",expanded:!1,wrap:!0,children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Duplicate","tablepress"),onClick:()=>tp.callbacks.insert_duplicate("duplicate","columns")}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Insert","tablepress"),onClick:()=>tp.callbacks.insert_duplicate("insert","columns")}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Delete","tablepress"),onClick:()=>x("columns")})]})]})})]}),(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{className:"column-1",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsxs)("span",{children:[(0,a.__)("Selected rows","tablepress"),":"]}),(0,i.jsxs)(t.__experimentalHStack,{spacing:"4px",alignment:"left",expanded:!1,wrap:!0,children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Move up","tablepress"),shortcut:{ariaLabel:o.shortcutAriaLabel.primaryShift("↑"),display:o.displayShortcut.primaryShift("↑")},onClick:()=>_("up","rows")}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Move down","tablepress"),shortcut:{ariaLabel:o.shortcutAriaLabel.primaryShift("↓"),display:o.displayShortcut.primaryShift("↓")},onClick:()=>_("down","rows")})]})]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsxs)("span",{children:[(0,a.__)("Selected columns","tablepress"),":"]}),(0,i.jsxs)(t.__experimentalHStack,{spacing:"4px",alignment:"left",expanded:!1,wrap:!0,children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Move left","tablepress"),shortcut:{ariaLabel:o.shortcutAriaLabel.primaryShift("←"),display:o.displayShortcut.primaryShift("←")},onClick:()=>_("left","columns")}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Move right","tablepress"),shortcut:{ariaLabel:o.shortcutAriaLabel.primaryShift("→"),display:o.displayShortcut.primaryShift("→")},onClick:()=>_("right","columns")})]})]})})]}),(0,i.jsxs)("tr",{className:"bottom-border",children:[(0,i.jsx)("td",{className:"column-1",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsxs)("span",{children:[(0,a.__)("Selected rows","tablepress"),":"]}),(0,i.jsxs)(t.__experimentalHStack,{spacing:"4px",alignment:"left",expanded:!1,wrap:!0,children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Hide","tablepress"),onClick:()=>tp.callbacks.hide_unhide("hide","rows")}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Show","tablepress"),onClick:()=>tp.callbacks.hide_unhide("unhide","rows")})]})]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsxs)("span",{children:[(0,a.__)("Selected columns","tablepress"),":"]}),(0,i.jsxs)(t.__experimentalHStack,{spacing:"4px",alignment:"left",expanded:!1,wrap:!0,children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Hide","tablepress"),onClick:()=>tp.callbacks.hide_unhide("hide","columns")}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Show","tablepress"),onClick:()=>tp.callbacks.hide_unhide("unhide","columns")})]})]})})]}),(0,i.jsxs)("tr",{className:"top-border",children:[(0,i.jsx)("td",{className:"column-1",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsx)("label",{htmlFor:"rows-append-number",children:(0,i.jsx)(t.__experimentalHStack,{children:(0,p.createInterpolateElement)((0,a.__)("Add <input /> row(s)","tablepress"),{input:(0,i.jsx)(t.__experimentalNumberControl,{size:"compact",id:"rows-append-number",title:(0,a.__)("This field must contain a positive number.","tablepress"),isDragEnabled:!1,value:n,onChange:e=>{e=""!==e?parseInt(e,10):1,r(e)},min:1,required:!0,style:{width:"55px"}})})})}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Add","tablepress"),onClick:()=>tp.callbacks.append("rows",n)})]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",children:[(0,i.jsx)("label",{htmlFor:"columns-append-number",children:(0,i.jsx)(t.__experimentalHStack,{children:(0,p.createInterpolateElement)((0,a.__)("Add <input /> column(s)","tablepress"),{input:(0,i.jsx)(t.__experimentalNumberControl,{size:"compact",id:"columns-append-number",title:(0,a.__)("This field must contain a positive number.","tablepress"),isDragEnabled:!1,value:s,onChange:e=>{e=""!==e?parseInt(e,10):1,l(e)},min:1,required:!0,style:{width:"55px"}})})})}),(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",text:(0,a.__)("Add","tablepress"),onClick:()=>tp.callbacks.append("columns",s)})]})})]})]})}),c&&(0,i.jsx)(S,{title:(0,a.__)("Table Manipulation","tablepress"),text:(0,a.__)("You can not do this move, because you reached the border of the table.","tablepress"),onConfirm:()=>d(!1),modalProps:{className:"has-size-small"}}),h&&(0,i.jsx)(S,{title:(0,a.__)("Table Manipulation","tablepress"),text:(0,a.__)("You can not delete all table rows!","tablepress"),onConfirm:()=>b(!1)}),u&&(0,i.jsx)(S,{title:(0,a.__)("Table Manipulation","tablepress"),text:(0,a.__)("You can not delete all table columns!","tablepress"),onConfirm:()=>m(!1)})]})})),c("table-options","edit",(({tableOptions:e,updateTableOptions:s})=>(0,i.jsx)(t.__experimentalVStack,{spacing:"16px",style:{paddingTop:"6px"},children:(0,i.jsx)("table",{className:"tablepress-postbox-table fixed",children:(0,i.jsxs)("tbody",{children:[(0,i.jsxs)("tr",{children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Table Header","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)("label",{htmlFor:"option-table_head",children:(0,i.jsx)(t.__experimentalHStack,{alignment:"left",children:(0,p.createInterpolateElement)((0,a.__)("The first <input /> rows are the table header.","tablepress"),{input:(0,i.jsx)(t.__experimentalNumberControl,{size:"compact",id:"option-table_head",title:(0,a.__)("This field must contain a non-negative number.","tablepress"),isDragEnabled:!1,value:e.table_head,onChange:e=>{e=""!==e?parseInt(e,10):0,s({table_head:e})},min:0,max:9,required:!0,style:{width:"65px"}})})})})})]}),(0,i.jsxs)("tr",{className:"bottom-border",children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Table Footer","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)("label",{htmlFor:"option-table_foot",children:(0,i.jsx)(t.__experimentalHStack,{alignment:"left",children:(0,p.createInterpolateElement)((0,a.__)("The last <input /> rows are the table footer.","tablepress"),{input:(0,i.jsx)(t.__experimentalNumberControl,{size:"compact",id:"option-table_foot",title:(0,a.__)("This field must contain a non-negative number.","tablepress"),isDragEnabled:!1,value:e.table_foot,onChange:e=>{e=""!==e?parseInt(e,10):0,s({table_foot:e})},min:0,max:9,required:!0,style:{width:"65px"}})})})})})]}),(0,i.jsxs)("tr",{className:"top-border",children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Alternating Row Colors","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("The background colors of consecutive rows shall alternate.","tablepress"),checked:e.alternating_row_colors,onChange:e=>s({alternating_row_colors:e})})})]}),(0,i.jsxs)("tr",{className:"bottom-border",children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Row Hover Highlighting","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Highlight a row while the mouse cursor hovers above it by changing its background color.","tablepress"),checked:e.row_hover,onChange:e=>s({row_hover:e})})})]}),(0,i.jsxs)("tr",{className:"top-border",children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Print Table Name","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,className:"checkbox-select-in-label",label:(0,p.createInterpolateElement)((0,a._x)("Show the table name <select /> the table.","position (above or below)","tablepress"),{select:(0,i.jsx)(t.SelectControl,{__nextHasNoMarginBottom:!0,size:"compact",variant:"minimal",value:e.print_name_position,disabled:!e.print_name,onChange:e=>s({print_name_position:e}),options:[{label:(0,a.__)("above","tablepress"),value:"above"},{label:(0,a.__)("below","tablepress"),value:"below"}]})}),checked:e.print_name,onChange:e=>s({print_name:e})})})]}),(0,i.jsxs)("tr",{className:"bottom-border",children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Print Table Description","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,className:"checkbox-select-in-label",label:(0,p.createInterpolateElement)((0,a._x)("Show the table description <select /> the table.","position (above or below)","tablepress"),{select:(0,i.jsx)(t.SelectControl,{__nextHasNoMarginBottom:!0,size:"compact",variant:"minimal",value:e.print_description_position,disabled:!e.print_description,onChange:e=>s({print_description_position:e}),options:[{label:(0,a.__)("above","tablepress"),value:"above"},{label:(0,a.__)("below","tablepress"),value:"below"}]})}),checked:e.print_description,onChange:e=>s({print_description:e})})})]}),(0,i.jsxs)("tr",{className:"top-border",children:[(0,i.jsx)("th",{className:"column-1 top-align",scope:"row",children:(0,i.jsxs)("label",{htmlFor:"option-extra_css_classes",children:[(0,a.__)("Extra CSS Classes","tablepress"),":"]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsxs)(t.__experimentalVStack,{children:[(0,i.jsx)(t.FormTokenField,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,id:"option-extra_css_classes",label:"",className:"code",title:(0,a.__)("This field can only contain letters, numbers, spaces, hyphens (-), underscores (_), and colons (:).","tablepress"),pattern:"[A-Za-z0-9 _:\\-]*",onChange:e=>s({extra_css_classes:e.join(" ").trim().replace(/[^A-Za-z0-9 _:-]/g,"")}),value:""!==e.extra_css_classes?e.extra_css_classes.split(" "):[],tokenizeOnBlur:!0,tokenizeOnSpace:!0,__experimentalShowHowTo:!1}),(0,i.jsx)("span",{style:{fontSize:"12px",color:"#757575"},children:(0,p.createInterpolateElement)((0,a.__)("Additional CSS classes for styling purposes can be entered here.","tablepress")+" "+(0,a.__)("This is NOT the place to enter <a>Custom CSS</a> code!","tablepress"),{a:(0,i.jsx)("a",{href:tp.screenOptions.optionsUrl})})})]})})]})]})})})));const E=({tableOptionCustomCommands:s,dataTablesEnabled:l,updateTableOptions:o})=>{const[n,r]=(0,e.useState)(s),[c,d]=(0,e.useState)(!1);return(0,i.jsx)(t.TextareaControl,{__nextHasNoMarginBottom:!0,id:"option-datatables_custom_commands",rows:c&&""!==n?Math.min(15,n.split("\n").length):1,className:"code",value:n,disabled:!l,onChange:e=>r(e),onBlur:()=>{n!==s&&o({datatables_custom_commands:n})},onFocus:()=>d(!0),help:(0,p.createInterpolateElement)((0,a.__)("Additional parameters from the <a>DataTables documentation</a> to be added to the JS call.","tablepress")+" "+(0,a.__)("For advanced use only.","tablepress"),{a:(0,i.jsx)("a",{href:"https://datatables.net/"})})})};c("datatables-features","edit",(({tableOptions:s,updateTableOptions:l})=>{const[o,n]=(0,e.useState)(!1),r=s.table_head>0,c=r&&s.use_datatables;return(0,i.jsxs)(t.__experimentalVStack,{spacing:"16px",style:{paddingTop:"6px"},children:[!r&&(0,i.jsx)("span",{children:(0,i.jsx)("em",{children:(0,a.sprintf)((0,a.__)("These features and options are only available when the “%1$s” setting in the “%2$s” section is used.","tablepress"),(0,a.__)("Table Header","tablepress"),(0,a.__)("Table Options","tablepress"))})}),(0,i.jsx)("table",{className:"tablepress-postbox-table fixed",children:(0,i.jsxs)("tbody",{children:[(0,i.jsxs)("tr",{className:"bottom-border",children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Enable Visitor Features","tablepress"),":"]}),(0,i.jsxs)("td",{className:"column-2",children:[(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Offer the following functions for site visitors with this table:","tablepress"),checked:s.use_datatables,disabled:!r,onChange:e=>{e&&(tp.helpers.visibility.update(),tp.helpers.editor.has_merged_body_cells())?n(!0):l({use_datatables:e})}}),o&&(0,i.jsx)(S,{title:(0,a.__)("Enable Visitor Features","tablepress"),text:(0,a.__)("You can not enable the Table Features for Site Visitors, because your table’s body rows contain combined/merged cells.","tablepress"),onConfirm:()=>n(!1),modalProps:{className:"has-size-medium"}})]})]}),(0,i.jsxs)("tr",{className:"top-border",children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Sorting","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Enable sorting of the table by the visitor.","tablepress"),checked:s.datatables_sort,disabled:!c,onChange:e=>l({datatables_sort:e})})})]}),(0,i.jsxs)("tr",{children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Search/Filtering","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Enable the visitor to filter or search the table. Only rows with the search word in them are shown.","tablepress"),checked:s.datatables_filter,disabled:!c,onChange:e=>l({datatables_filter:e})})})]}),(0,i.jsxs)("tr",{children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Pagination","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Enable pagination of the table (viewing only a certain number of rows at a time) by the visitor.","tablepress"),checked:s.datatables_paginate,disabled:!c,onChange:e=>l({datatables_paginate:e})})})]}),(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{className:"column-1",scope:"row"}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)("label",{htmlFor:"option-datatables_paginate_entries",children:(0,i.jsx)(t.__experimentalHStack,{alignment:"left",style:{paddingLeft:"24px"},children:(0,p.createInterpolateElement)((0,a.__)("Show <input /> rows per page.","tablepress"),{input:(0,i.jsx)(t.__experimentalNumberControl,{size:"compact",id:"option-datatables_paginate_entries",title:(0,a.__)("This field must contain a non-negative number.","tablepress"),isDragEnabled:!1,value:s.datatables_paginate_entries,disabled:!c||!s.datatables_paginate,onChange:e=>{e=""!==e?parseInt(e,10):1,l({datatables_paginate_entries:e})},min:1,required:!0,style:{width:"65px"}})})})})})]}),(0,i.jsxs)("tr",{children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Pagination Length Change","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Allow the visitor to change the number of rows shown when using pagination.","tablepress"),checked:s.datatables_lengthchange,disabled:!c||!s.datatables_paginate,onChange:e=>l({datatables_lengthchange:e})})})]}),(0,i.jsxs)("tr",{children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Info","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Enable the table information display, with information about the currently visible data, like the number of rows.","tablepress"),checked:s.datatables_info,disabled:!c,onChange:e=>l({datatables_info:e})})})]}),(0,i.jsxs)("tr",{className:tp.screenOptions.showCustomCommands?"bottom-border":void 0,children:[(0,i.jsxs)("th",{className:"column-1",scope:"row",children:[(0,a.__)("Horizontal Scrolling","tablepress"),":"]}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(t.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Enable horizontal scrolling, to make viewing tables with many columns easier.","tablepress"),checked:s.datatables_scrollx,disabled:!c,onChange:e=>l({datatables_scrollx:e})})})]}),tp.screenOptions.showCustomCommands&&(0,i.jsxs)("tr",{className:"top-border",children:[(0,i.jsx)("th",{className:"column-1 top-align",scope:"row",children:(0,i.jsxs)("label",{htmlFor:"option-datatables_custom_commands",children:[(0,a.__)("Custom Commands","tablepress"),":"]})}),(0,i.jsx)("td",{className:"column-2",children:(0,i.jsx)(E,{tableOptionCustomCommands:s.datatables_custom_commands,updateTableOptions:l,dataTablesEnabled:c})})]})]})})]})})),c("table-preview","edit",(({screenData:e,updateScreenData:s,tableMeta:l})=>{if(!tp.screenOptions.currentUserCanPreviewTable||!e.previewIsOpen)return(0,i.jsx)(i.Fragment,{});let o=l.name;""===o.trim()&&(o=(0,a.__)("(no name)","tablepress"));const n=(0,a.sprintf)((0,a.__)("Preview of table “%1$s” (ID %2$s)","tablepress"),o,l.id);return(0,i.jsx)(t.Modal,{icon:(0,i.jsx)(t.Icon,{icon:b,size:"36",style:{display:"flex",marginRight:"1rem"}}),title:n,className:"table-preview-modal",onRequestClose:()=>s({previewIsOpen:!1,previewSrcDoc:""}),isFullScreen:!0,children:(0,i.jsx)("iframe",{title:n,src:""===e.previewSrcDoc?e.previewUrl:void 0,srcDoc:""!==e.previewSrcDoc?e.previewSrcDoc:void 0})})}));const T=({title:s,deleteUrl:l,closeConfirmDeleteModal:o})=>{const n=(0,e.useRef)(),r=(0,e.useRef)(),c=(0,e.useCallback)((e=>{e.target===n.current||e.target===r.current||"Enter"!==e.key||r.current.click()}),[]);return(0,i.jsx)(t.Modal,{className:"has-size-medium",icon:(0,i.jsx)(t.Icon,{icon:b,size:"36",style:{display:"flex",marginRight:"1rem"}}),title:s,isDismissible:!1,onKeyDown:c,onRequestClose:o,children:(0,i.jsxs)(t.__experimentalVStack,{spacing:8,children:[(0,i.jsxs)("span",{children:[(0,a._n)("Do you really want to delete this table?","Do you really want to delete these tables?",1,"tablepress"),(0,i.jsx)("br",{}),(0,a.__)("Deleting a table is permanent and can not be undone!","tablepress")]}),(0,i.jsxs)(t.__experimentalHStack,{alignment:"right",children:[(0,i.jsx)(t.Button,{ref:n,variant:"tertiary",text:(0,a.__)("Cancel","tablepress"),onClick:o}),(0,i.jsx)(t.Button,{ref:r,variant:"primary",isDestructive:!0,href:l,text:(0,a.__)("Delete","tablepress"),onClick:()=>{tp.helpers.unsaved_changes.unset(),o()}})]})]})})};c("other-actions","edit",(({screenData:s,tableMeta:l})=>{const[o,n]=(0,e.useState)(!1);return tp.screenOptions.currentUserCanCopyTable||tp.screenOptions.currentUserCanExportTable||tp.screenOptions.currentUserCanDeleteTable?(0,i.jsxs)(t.__experimentalHStack,{alignment:"left",style:{margin:"2rem 0"},children:[(0,i.jsx)("span",{children:(0,a.__)("Other Actions","tablepress")}),tp.screenOptions.currentUserCanCopyTable&&(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",href:s.copyUrl,text:(0,a.__)("Copy Table","tablepress")}),tp.screenOptions.currentUserCanExportTable&&(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",href:s.exportUrl,text:(0,a.__)("Export Table","tablepress")}),tp.screenOptions.currentUserCanDeleteTable&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.Button,{variant:"secondary",size:"compact",isDestructive:!0,href:s.deleteUrl,text:(0,a.__)("Delete Table","tablepress"),onClick:e=>{n(!0),e.preventDefault()}}),o&&(0,i.jsx)(T,{title:sprintf((0,a.__)("Delete “%1$s” (ID %2$s)","tablepress"),l.name,l.id),deleteUrl:s.deleteUrl,closeConfirmDeleteModal:()=>n(!1)})]})]}):(0,i.jsx)(i.Fragment,{})}));const M=e=>"#"===e[0]?document.getElementById(e.slice(1)):document.querySelectorAll(e);window.tp=window.tp||{},tp.made_changes=!1,tp.helpers=tp.helpers||{},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.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 l=0;l<e;l++)if(1!==tp.table.visibility.rows[l])for(let e=0;e<t;e++){const t=jspreadsheet.getColumnNameFromId([e,l]);s[t]=s[t]||{},s[t].row_hidden=!0}for(let l=0;l<t;l++)if(1!==tp.table.visibility.columns[l])for(let t=0;t<e;t++){const e=jspreadsheet.getColumnNameFromId([l,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],l=0;return"down"!==t&&"right"!==t&&"bottom"!==t&&"last"!==t||(s=tp.helpers.selection[e][tp.helpers.selection[e].length-1],l="rows"===e?tp.editor.options.data.length-1:tp.editor.options.columns.length-1),l!==s},tp.helpers.cell_merge_allowed=function(e,t={}){const s="alert"===e,l=tp.helpers.selection.rows[0],o=tp.helpers.selection.rows[tp.helpers.selection.rows.length-1],n=tp.table.options.table_head,r=tp.editor.options.data.length-1-tp.table.options.table_foot;return!(tp.table.options.table_head>0&&tp.table.options.use_datatables)||l<n&&o<n||l>r&&o>r?l<n&&o>=n?(t.text=(0,a.sprintf)((0,a.__)("You can not combine these cells, because the “%1$s” setting in the “%2$s” section is active.","tablepress"),(0,a.__)("Table Header","tablepress"),(0,a.__)("Table Options","tablepress")),s&&window.alert(t.text),!1):!(l<=r&&o>r&&(t.text=(0,a.sprintf)((0,a.__)("You can not combine these cells, because the “%1$s” setting in the “%2$s” section is active.","tablepress"),(0,a.__)("Table Footer","tablepress"),(0,a.__)("Table Options","tablepress")),s&&window.alert(t.text),1)):(t.text=(0,a.sprintf)((0,a.__)("You can not combine these cells, because the “%1$s” checkbox in the “%2$s” section is checked.","tablepress"),(0,a.__)("Enable Visitor Features","tablepress"),(0,a.__)("Table Features for Site Visitors","tablepress"))+" "+(0,a.__)("When the Table Features for Site Visitors are used, merging is only allowed in the table header and footer rows.","tablepress"),s&&window.alert(t.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_body_cells=function(){const e=tp.table.options.table_head,t=tp.editor.options.data.length-tp.table.options.table_foot,s=tp.editor.options.columns.length;for(let l=e;l<t;l++)for(let e=0;e<s;e++)if(("#rowspan#"===tp.editor.options.data[l][e]||"#colspan#"===tp.editor.options.data[l][e])&&1===tp.table.visibility.rows[l]&&1===tp.table.visibility.columns[e])return!0;return!1},tp.helpers.editor.sorting=function(e){return e=e?-1:1,function(t,s){const l=t[1].localeCompare(s[1],void 0,{numeric:!0,sensitivity:"base"});return e*l}},tp.callbacks=tp.callbacks||{},tp.callbacks.editor=tp.callbacks.editor||{},tp.callbacks.editor.onselection=function(e,t,s,l,a){tp.helpers.selection={rows:[],columns:[]};for(let e=s;e<=a;e++)tp.helpers.selection.rows.push(e);for(let e=t;e<=l;e++)tp.helpers.selection.columns.push(e)},tp.callbacks.editor.onupdatetable=function(e,t,s,l,a,o,n){const r=e.jspreadsheet.options.meta[n];if(t.classList.toggle("column-hidden",Boolean(r?.column_hidden)),0===s&&(t.parentNode.classList.toggle("row-hidden",Boolean(r?.row_hidden)),t.parentNode.classList.remove("head-row","foot-row"),l===e.jspreadsheet.rows.length-1)){const t=e.jspreadsheet.content.querySelectorAll(":scope tbody tr:not(.row-hidden)");for(let e=0;e<tp.table.options.table_head;e++)t[e]?.classList.add("head-row");if(t.length>=tp.table.options.table_head+tp.table.options.table_foot){const e=t.length-1;for(let s=0;s<tp.table.options.table_foot;s++)t[e-s]?.classList.add("foot-row")}}},tp.callbacks.editor.oninsertroc=function(e,t,s,l,a,o,n){const r="rows"===e,i=r?"column_hidden":"row_hidden",c="duplicate"===t,p=l+(n?a:0),d=r?tp.editor.options.columns.length:tp.editor.options.data.length,h={};for(let e=0;e<d;e++){const t=r?[e,p]:[p,e],s=tp.editor.options.meta[jspreadsheet.getColumnNameFromId(t)];s&&(c?h[e]=s:s[i]&&(h[e]=h[e]||{},h[e][i]=!0))}const b=Object.keys(h);if(!b.length)return;const u={};n||l++;for(let e=0;e<a;e++){const t=l+e;b.forEach((function(e){const s=r?[e,t]:[t,e];u[jspreadsheet.getColumnNameFromId(s)]=h[e]}))}tp.editor.setMeta(u),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(e=null){const t=M("#textarea-insert-helper");t.value=tp.editor.options.data[tp.helpers.selection.rows[0]][tp.helpers.selection.columns[0]],e?(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd):(t.selectionStart=t.value.length,t.selectionEnd=t.value.length);const s=jexcel.getColumnNameFromId([tp.helpers.selection.columns[0],tp.helpers.selection.rows[0]]);M("#link-modal-title").textContent=(0,a.sprintf)((0,a.__)("Insert Link into cell %1$s","tablepress"),s),wpLink.open("textarea-insert-helper"),jexcel.current=null},tp.callbacks.insert_image={},tp.callbacks.insert_image.open_dialog=function(e=null){const t=M("#textarea-insert-helper");t.value=tp.editor.options.data[tp.helpers.selection.rows[0]][tp.helpers.selection.columns[0]],e?(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd):(t.selectionStart=t.value.length,t.selectionEnd=t.value.length),wp.media.editor.open("textarea-insert-helper",{frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0});const s=jexcel.getColumnNameFromId([tp.helpers.selection.columns[0],tp.helpers.selection.rows[0]]);document.querySelector("#media-frame-title h1").textContent=(0,a.sprintf)((0,a.__)("Add media to cell %1$s","tablepress"),s),jexcel.current=null},tp.callbacks.advanced_editor={},tp.callbacks.advanced_editor.$textarea=M("#advanced-editor-content"),tp.callbacks.advanced_editor.open_dialog=function(e=null){tp.callbacks.advanced_editor.$textarea.value=tp.editor.options.data[tp.helpers.selection.rows[0]][tp.helpers.selection.columns[0]];const t=jexcel.getColumnNameFromId([tp.helpers.selection.columns[0],tp.helpers.selection.rows[0]]),s=(0,a.sprintf)((0,a.__)("Advanced Editor for cell %1$s","tablepress"),t);M("#advanced-editor-label").textContent=s,M("#link-modal-title").textContent=(0,a.sprintf)((0,a.__)("Insert Link into cell %1$s","tablepress"),t),jQuery("#advanced-editor").wpdialog({width:600,modal:!0,title:s,resizable:!1,closeOnEscape:!0,buttons:[{text:(0,a.__)("Cancel","tablepress"),class:"button button-cancel",click(){jQuery(this).wpdialog("close")}},{text:(0,a.__)("OK","tablepress"),class:"button button-primary button-ok",click:tp.callbacks.advanced_editor.confirm_save}]}),jexcel.current=null,e?(tp.callbacks.advanced_editor.$textarea.selectionStart=e.selectionStart,tp.callbacks.advanced_editor.$textarea.selectionEnd=e.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.insert_duplicate=function(e,t,s="before"){const l="rows"===t,a=l?tp.editor.insertRow:tp.editor.insertColumn,o=l?tp.editor.getRowData:tp.editor.getColumnData,n="duplicate"===e;tp.editor.options[l?"oninsertrow":"oninsertcolumn"]=tp.callbacks.editor.oninsertroc.bind(null,t,e),tp.helpers.selection[t].forEach((function(e,t){const l=e+t,r=n?o(l):1;a(r,l,"before"===s)})),tp.helpers.unsaved_changes.set();const r=tp.helpers.selection[t].length;r>1&&tp.editor.updateSelectionFromCoords(tp.helpers.selection.columns[0],tp.helpers.selection.rows[0],l?tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]:tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]+r,l?tp.helpers.selection.rows[tp.helpers.selection.rows.length-1]+r: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,l=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 l=0;l<s;l++){const s=t?[l,e]:[e,l];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(),l===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,l=s?tp.editor.insertRow:tp.editor.insertColumn;tp.editor.options[s?"oninsertrow":"oninsertcolumn"]=tp.callbacks.editor.oninsertroc.bind(null,e,"append"),l(t),tp.helpers.unsaved_changes.set()},tp.callbacks.move=function(e,t){const s="rows"===t;let l=tp.helpers.selection[t],a=-1;if("down"===e||"right"===e)l=l.slice().reverse(),a=1;else if("top"===e||"first"===e)a=-l[0];else if("bottom"===e||"last"===e){l=l.slice().reverse();const e="rows"===t?tp.editor.options.data.length-1:tp.editor.options.columns.length-1;a=e-l[0]}if(0===a)return;const o=s?tp.editor.moveRow:tp.editor.moveColumn;l.forEach((e=>o(e,e+a))),tp.helpers.unsaved_changes.set(),tp.editor.updateSelectionFromCoords(s?tp.helpers.selection.columns[0]:tp.helpers.selection.columns[0]+a,s?tp.helpers.selection.rows[0]+a: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]+a,s?tp.helpers.selection.rows[tp.helpers.selection.rows.length-1]+a: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,l=s?"row_hidden":"column_hidden",a=s?tp.editor.options.columns.length:tp.editor.options.data.length,o="hide"===e,n={};tp.helpers.selection[t].forEach((function(e){for(let t=0;t<a;t++){const a=s?[t,e]:[e,t],r=jspreadsheet.getColumnNameFromId(a);n[r]={},n[r][l]=o}})),tp.editor.setMeta(n),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,l=tp.helpers.selection.rows.length;for(let s=1;s<l;s++)tp.editor.setValueFromCoords(e,t+s,"#rowspan#");for(let l=1;l<s;l++)tp.editor.setValueFromCoords(e+l,t,"#colspan#");for(let a=1;a<l;a++)for(let l=1;l<s;l++)tp.editor.setValueFromCoords(e+l,t+a,"#span#");tp.helpers.unsaved_changes.set()},tp.editor=jspreadsheet(M("#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.screenOptions.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:e=>{const t=tp.editor.options.data.length,s=tp.editor.options.columns.length,o=tp.helpers.selection.rows.length,n=tp.helpers.selection.columns.length,r=window?.navigator?.platform?.includes("Mac"),i=r?(0,a._x)("⌘","keyboard shortcut modifier key on a Mac keyboard","tablepress"):(0,a._x)("Ctrl+","keyboard shortcut modifier key on a non-Mac keyboard","tablepress"),c=r?(0,a._x)("⌥","keyboard shortcut option key on a Mac keyboard","tablepress"):(0,a._x)("Alt+","keyboard shortcut Alt key on a non-Mac keyboard","tablepress"),p={text:""};tp.helpers.visibility.update();const d=[{title:(0,a.__)("Undo","tablepress"),shortcut:(0,a.sprintf)((0,a._x)("%1$sZ","keyboard shortcut for Undo","tablepress"),i),onclick:e.undo,disabled:-1===e.historyIndex},{title:(0,a.__)("Redo","tablepress"),shortcut:(0,a.sprintf)((0,a._x)("%1$sY","keyboard shortcut for Redo","tablepress"),i),onclick:e.redo,disabled:e.historyIndex===e.history.length-1},{type:"divisor"},{title:(0,a.__)("Cut","tablepress"),shortcut:(0,a.sprintf)((0,a._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 e.copy(!0),e.setValue(e.highlighted,"")}},{title:(0,a.__)("Copy","tablepress"),shortcut:(0,a.sprintf)((0,a._x)("%1$sC","keyboard shortcut for Copy","tablepress"),i),onclick(){"TEXTAREA"===document.activeElement.tagName&&document.activeElement.selectionStart!==document.activeElement.selectionEnd?document.execCommand("copy"):e.copy(!0)}},{title:(0,a.__)("Paste","tablepress"),shortcut:(0,a.sprintf)((0,a._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}})):e.selectedCell&&window.navigator.clipboard.readText().then((t=>{t&&e.paste(e.selectedCell[0],e.selectedCell[1],t)}))},disabled:!window?.navigator?.clipboard?.readText,tooltip:window?.navigator?.clipboard?.readText?"":(0,a.__)("Your browser does not allow pasting via the context menu. Use the keyboard shortcut instead.","tablepress")},{type:"divisor"},{title:(0,a.__)("Insert Link","tablepress"),shortcut:(0,a.sprintf)((0,a._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,a.__)("Insert Image","tablepress"),shortcut:(0,a.sprintf)((0,a._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,a.__)("Advanced Editor","tablepress"),shortcut:(0,a.sprintf)((0,a._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,a.__)("Duplicate …","tablepress"),submenu:[{title:(0,a._n)("Duplicate row","Duplicate rows",o,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"duplicate","rows")},{title:(0,a._n)("Duplicate column","Duplicate columns",n,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"duplicate","columns")}]},{title:(0,a.__)("Insert …","tablepress"),submenu:[{title:(0,a._n)("Insert row above","Insert rows above",o,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","rows","before")},{title:(0,a._n)("Insert row below","Insert rows below",o,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","rows","after")},{title:(0,a._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,a._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,a.__)("Append …","tablepress"),submenu:[{title:(0,a.__)("Append row","tablepress"),onclick:tp.callbacks.append.bind(null,"rows",1)},{title:(0,a.__)("Append column","tablepress"),onclick:tp.callbacks.append.bind(null,"columns",1)}]},{title:(0,a.__)("Delete …","tablepress"),submenu:[{title:(0,a._n)("Delete row","Delete rows",o,"tablepress"),onclick:tp.callbacks.remove.bind(null,"rows"),disabled:t===o,tooltip:t===o?(0,a.__)("This option is disabled.","tablepress")+" "+(0,a.__)("You can not delete all table rows!","tablepress"):""},{title:(0,a._n)("Delete column","Delete columns",n,"tablepress"),onclick:tp.callbacks.remove.bind(null,"columns"),disabled:s===n,tooltip:s===n?(0,a.__)("This option is disabled.","tablepress")+" "+(0,a.__)("You can not delete all table columns!","tablepress"):""}]},{type:"divisor"},{title:(0,a.__)("Move …","tablepress"),submenu:[{title:(0,a._n)("Move row up","Move rows up",o,"tablepress"),shortcut:(0,a.sprintf)((0,a._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,a._n)("Move row down","Move rows down",o,"tablepress"),shortcut:(0,a.sprintf)((0,a._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,a._n)("Move column left","Move columns left",n,"tablepress"),shortcut:(0,a.sprintf)((0,a._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,a._n)("Move column right","Move columns right",n,"tablepress"),shortcut:(0,a.sprintf)((0,a._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,a._n)("Move row to the top","Move rows to the top",o,"tablepress"),shortcut:(0,a.sprintf)((0,a._x)("%1$s%2$s⇧↑","keyboard shortcut for Move to the top","tablepress"),i,c),onclick:tp.callbacks.move.bind(null,"top","rows"),disabled:!tp.helpers.move_allowed("rows","top")},{title:(0,a._n)("Move row to the bottom","Move rows to the bottom",o,"tablepress"),shortcut:(0,a.sprintf)((0,a._x)("%1$s%2$s⇧↓","keyboard shortcut for Move to the bottom","tablepress"),i,c),onclick:tp.callbacks.move.bind(null,"bottom","rows"),disabled:!tp.helpers.move_allowed("rows","bottom")},{title:(0,a._n)("Move column to first","Move columns to first",n,"tablepress"),shortcut:(0,a.sprintf)((0,a._x)("%1$s%2$s⇧←","keyboard shortcut for Move to first","tablepress"),i,c),onclick:tp.callbacks.move.bind(null,"first","columns"),disabled:!tp.helpers.move_allowed("columns","first")},{title:(0,a._n)("Move column to last","Move columns to last",n,"tablepress"),shortcut:(0,a.sprintf)((0,a._x)("%1$s%2$s⇧→","keyboard shortcut for Move to last","tablepress"),i,c),onclick:tp.callbacks.move.bind(null,"last","columns"),disabled:!tp.helpers.move_allowed("columns","last")}]},{title:(0,a.__)("Sort by column …","tablepress"),submenu:[{title:(0,a.__)("Sort by column ascending","tablepress"),onclick:tp.callbacks.sort.bind(null,"asc"),disabled:1!==n,tooltip:1!==n?(0,a.__)("This option is disabled because more than one column was selected.","tablepress"):""},{title:(0,a.__)("Sort by column descending","tablepress"),onclick:tp.callbacks.sort.bind(null,"desc"),disabled:1!==n,tooltip:1!==n?(0,a.__)("This option is disabled because more than one column was selected.","tablepress"):""}]},{type:"divisor"},{title:(0,a.__)("Hide/Show …","tablepress"),submenu:[{title:(0,a._n)("Hide row","Hide rows",o,"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,a.__)("This option is disabled because no visible rows were selected.","tablepress")},{title:(0,a._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,a.__)("This option is disabled because no visible columns were selected.","tablepress")},{title:(0,a._n)("Show row","Show rows",o,"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,a.__)("This option is disabled because no hidden rows were selected.","tablepress")},{title:(0,a._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,a.__)("This option is disabled because no hidden columns were selected.","tablepress")}]},{type:"divisor"},{title:(0,a.__)("Combine/Merge cells","tablepress"),onclick:tp.callbacks.merge_cells,disabled:1===o&&1===n||!tp.helpers.cell_merge_allowed("no-alert"),tooltip:1===o&&1===n||!tp.helpers.cell_merge_allowed("no-alert",p)?(0,a.__)("This option is disabled.","tablepress")+" "+p.text:""}];return(0,l.applyFilters)("tablepress.editScreenContextMenuItems",d,e)},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}),jQuery("#textarea-insert-helper").on("change",tp.helpers.editor.insert_from_helper_textarea),jQuery((()=>{jQuery("#wp-link").on("focus","input",(e=>e.stopPropagation())),jQuery("body").on("focus",".media-modal .media-frame-content input, .media-modal .media-frame-content textarea",(e=>e.stopPropagation()))})),window.addEventListener("keydown",(e=>{let t="",s="",l="";if((e.ctrlKey||e.metaKey)&&(76===e.keyCode?t="insert_link":73===e.keyCode?t="insert_image":69===e.keyCode?t="advanced_editor":e.shiftKey&&(38===e.keyCode?(t="move",l="rows",s=e.altKey?"top":"up"):40===e.keyCode?(t="move",l="rows",s=e.altKey?"bottom":"down"):37===e.keyCode?(t="move",l="columns",s=e.altKey?"first":"left"):39===e.keyCode&&(t="move",l="columns",s=e.altKey?"last":"right"))),""!==t)if("insert_link"===t||"insert_image"===t||"advanced_editor"===t){if(M("#table-editor").contains(document.activeElement)){const e="TEXTAREA"===document.activeElement.tagName?document.activeElement:null;e?.blur(),tp.callbacks[t].open_dialog(e)}e.preventDefault()}else"move"===t&&(M("#table-editor").contains(document.activeElement)&&"TEXTAREA"!==document.activeElement.tagName&&tp.helpers.move_allowed(l,s)&&tp.callbacks.move(s,l),e.stopImmediatePropagation())}),!0);const D=M("#tablepress-screen-options");D&&(D.addEventListener("input",(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.screenOptions.table_editor_column_width=parseInt(e.target.value,10),tp.screenOptions.table_editor_column_width=Math.max(tp.screenOptions.table_editor_column_width,30),tp.screenOptions.table_editor_column_width=Math.min(tp.screenOptions.table_editor_column_width,9999),tp.editor.colgroup.forEach((e=>e.setAttribute("width",tp.screenOptions.table_editor_column_width))),void tp.editor.updateCornerPosition()):void 0})),D.addEventListener("change",(e=>{e.target&&(e.target.was_changed=!0)})),D.addEventListener("focusout",(e=>{if(!e.target)return;if(!e.target.was_changed)return;e.target.was_changed=!1;const t={action:"tablepress_save_screen_options",_ajax_nonce:tp.nonces.screen_options,tablepress:{[e.target.id]:parseInt(e.target.value,10)}};e.target.parentNode.insertAdjacentHTML("beforeend",`<span id="spinner-save-changes" class="spinner is-active" title="${(0,a.__)("Changes are being saved …","tablepress")}" style="float:none;margin:0 0 0 6px;"></span>`),document.body.classList.add("wait"),fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:(0,d.buildQueryString)(t)}).finally((()=>{M("#spinner-save-changes").remove(),document.body.classList.remove("wait")}))})));const H=(0,l.applyFilters)("tablepress.editScreenFeatures",[]),I=(0,t.withFilters)("tablepress.editScreenPortals")((()=>(0,i.jsx)(i.Fragment,{}))),z=()=>{const[t,s]=(0,e.useState)({copyUrl:tp.screenOptions.copyUrl,deleteUrl:tp.screenOptions.deleteUrl,exportUrl:tp.screenOptions.exportUrl,isSaving:!1,previewIsLoading:!1,previewIsOpen:!1,previewSrcDoc:"",previewUrl:tp.screenOptions.previewUrl,triggerPreview:!1,triggerSaveChanges:!1}),[l,a]=(0,e.useState)((()=>({...tp.table.options}))),[o,n]=(0,e.useState)((()=>({...tp.table.meta})));(0,e.useEffect)((()=>{l.use_datatables&&tp.helpers.editor.has_merged_body_cells()&&r({use_datatables:!1})}),[]);const r=e=>{a((t=>({...t,...e}))),tp.table.options={...tp.table.options,...e},tp.helpers.unsaved_changes.set(),["table_head","table_foot"].some((t=>Object.keys(e).includes(t)))&&tp.editor.updateTable()};return(0,i.jsx)(I,{screenData:t,updateScreenData:e=>{s((t=>({...t,...e})))},tableMeta:o,updateTableMeta:e=>{n((t=>({...t,...e}))),tp.table.meta={...tp.table.meta,...e},tp.helpers.unsaved_changes.set()},tableOptions:l,updateTableOptions:r,features:H})};((e,t)=>{const s=document.getElementById("tablepress-edit-screen");s&&(0,r.createRoot)(s).render(t)})(0,(0,i.jsx)(z,{}))})();