Changeset 3831455
- Timestamp:
- 11/28/2026 01:08:05 PM (82 minutes ago)
- Location:
- digimail-smtp
- Files:
-
- 26 edited
- 1 copied
-
tags/2.9.0 (copied) (copied from digimail-smtp/trunk )
-
tags/2.9.0/assets/guard.js (modified) (8 diffs)
-
tags/2.9.0/build/index.asset.php (modified) (1 diff)
-
tags/2.9.0/build/index.js (modified) (1 diff)
-
tags/2.9.0/digimail-smtp.php (modified) (2 diffs)
-
tags/2.9.0/includes/Connect.php (modified) (1 diff)
-
tags/2.9.0/includes/Guard.php (modified) (14 diffs)
-
tags/2.9.0/includes/Options.php (modified) (1 diff)
-
tags/2.9.0/includes/Plugin.php (modified) (1 diff)
-
tags/2.9.0/includes/Rest.php (modified) (1 diff)
-
tags/2.9.0/readme.txt (modified) (5 diffs)
-
tags/2.9.0/src/Guard.tsx (modified) (1 diff)
-
tags/2.9.0/src/api.ts (modified) (3 diffs)
-
tags/2.9.0/uninstall.php (modified) (2 diffs)
-
trunk/assets/guard.js (modified) (8 diffs)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (1 diff)
-
trunk/digimail-smtp.php (modified) (2 diffs)
-
trunk/includes/Connect.php (modified) (1 diff)
-
trunk/includes/Guard.php (modified) (14 diffs)
-
trunk/includes/Options.php (modified) (1 diff)
-
trunk/includes/Plugin.php (modified) (1 diff)
-
trunk/includes/Rest.php (modified) (1 diff)
-
trunk/readme.txt (modified) (5 diffs)
-
trunk/src/Guard.tsx (modified) (1 diff)
-
trunk/src/api.ts (modified) (3 diffs)
-
trunk/uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
digimail-smtp/tags/2.9.0/assets/guard.js
r3829755 r3831455 3 3 * 4 4 * - _digimail_smtp_js: the browser ran this script (bots that post directly do not). 5 * - _digimail_smtp_url: a trap field people never see; bots that fill every field do. 5 * - a trap field people never see (its name differs per site, cfg.trap); bots 6 * that fill every field fill it too. 6 7 * - _digimail_smtp_t: a signed token fetched after the page loads, with the answer to a 7 8 * small proof-of-work the browser finds while the visitor types ("p" and … … 10 11 * - _digimail_smtp_i: how many real key presses, clicks or touches happened in the form. 11 12 * 12 * Nothing is shown to visitors and nothing is stored in the browser. 13 * Nothing is shown to visitors and nothing is stored in the browser. Logged-in 14 * admins (cfg.badge) see a short note under each form: protected, token 15 * failed, or (for forms with an email field this script does not cover) not 16 * protected. 13 17 */ 14 18 ( function () { … … 28 32 'form.woocommerce-checkout', 29 33 'form[data-dms-guard]', 30 ].join( ',' ); 34 ] 35 .concat( cfg.core ? [ '#registerform', '#lostpasswordform', 'form.woocommerce-form-register', 'form.woocommerce-ResetPassword', '#commentform', 'form.comment-form' ] : [] ) 36 .join( ',' ); 37 var badges = []; 31 38 var forms = []; 32 39 var token = ''; … … 102 109 failed = false; 103 110 fill(); 111 mark( 'ok' ); 104 112 } ) 105 113 [ 'catch' ]( function () { 106 114 failed = true; 115 mark( 'failed' ); 107 116 } ) 108 117 .then( function () { … … 130 139 var hp = document.createElement( 'input' ); 131 140 hp.type = 'text'; 132 hp.name = '_digimail_smtp_url';141 hp.name = cfg.trap || '_digimail_smtp_url'; 133 142 hp.value = ''; 134 143 hp.tabIndex = -1; … … 145 154 form.__dms = state; 146 155 forms.push( form ); 156 if ( ! form.hasAttribute( 'data-dms-guard' ) ) { 157 badge( form, token ? 'ok' : failed ? 'failed' : 'checking' ); 158 } 147 159 function move( e ) { 148 160 if ( e.isTrusted === false ) { … … 172 184 } 173 185 186 // ---------- admin note ---------- 187 188 function badge( form, state ) { 189 if ( ! cfg.badge || form.__dmsBadge ) { 190 return; 191 } 192 var el = document.createElement( 'div' ); 193 el.className = 'dms-guard-note'; 194 el.setAttribute( 'role', 'note' ); 195 el.style.cssText = 'margin:6px 0 0;padding:6px 10px;border-radius:6px;font:12px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;max-width:100%;box-sizing:border-box;'; 196 form.__dmsBadge = el; 197 badges.push( el ); 198 paint( el, state ); 199 if ( form.parentNode ) { 200 form.parentNode.insertBefore( el, form.nextSibling ); 201 } 202 } 203 204 function paint( el, state ) { 205 var look = { 206 checking: [ '#f4f4f5', '#3f3f46', '\u23F3' ], 207 ok: [ '#ecfdf3', '#05603a', '\u2713' ], 208 failed: [ '#fef3f2', '#b42318', '!' ], 209 none: [ '#fffaeb', '#93370d', '!' ], 210 }[ state ]; 211 el.style.background = look[ 0 ]; 212 el.style.color = look[ 1 ]; 213 el.textContent = look[ 2 ] + ' ' + ( cfg.badge[ state ] || '' ); 214 } 215 216 function mark( state ) { 217 for ( var i = 0; i < badges.length; i++ ) { 218 if ( ! badges[ i ].__none ) { 219 paint( badges[ i ], state ); 220 } 221 } 222 } 223 224 // Forms with an email field that no supported plugin made: tell the admin. 225 function unguarded( root ) { 226 if ( ! cfg.badge ) { 227 return; 228 } 229 var list = ( root || document ).querySelectorAll( 'form' ); 230 for ( var i = 0; i < list.length; i++ ) { 231 var f = list[ i ]; 232 if ( f.__dms || f.__dmsBadge || ( f.method && f.method.toLowerCase() === 'get' ) || f.id === 'loginform' || f.closest( '#wpadminbar, .woocommerce-MyAccount-content' ) ) { 233 continue; 234 } 235 if ( ! f.querySelector( 'input[type="email"], input[name*="email" i]' ) ) { 236 continue; 237 } 238 badge( f, 'none' ); 239 f.__dmsBadge.__none = true; 240 } 241 } 242 174 243 function scan( root ) { 175 244 var list = ( root || document ).querySelectorAll( SELECTOR ); … … 180 249 load(); 181 250 } 251 unguarded( root ); 182 252 } 183 253 -
digimail-smtp/tags/2.9.0/build/index.asset.php
r3830946 r3831455 5 5 'wp-i18n' 6 6 ), 7 'version' => ' aa3d46a6aa63d53bdce4'7 'version' => '66a129ad7e4c0dd9e889' 8 8 ); -
digimail-smtp/tags/2.9.0/build/index.js
r3830946 r3831455 1 (()=>{"use strict";var e={897(e,t,a){const l=window.wp.element,i=window.wp.i18n,s=window.wp.apiFetch;var n=a.n(s);const m={honeypot:(0,i.__)("Filled in the hidden trap field","digimail-smtp"),no_js:(0,i.__)("Sent without the page script (posted straight by a bot)","digimail-smtp"),no_token:(0,i.__)("No protection token","digimail-smtp"),forged:(0,i.__)("Fake protection token","digimail-smtp"),bad_pow:(0,i.__)("Wrong answer to the browser check","digimail-smtp"),no_pow:(0,i.__)("Browser check not done","digimail-smtp"),reused:(0,i.__)("Same token used many times","digimail-smtp"),too_fast:(0,i.__)("Sent less than 2 seconds after the page opened","digimail-smtp"),fast:(0,i.__)("Sent very quickly","digimail-smtp"),no_interaction:(0,i.__)("No typing, click or touch in the form","digimail-smtp"),flood:(0,i.__)("15 or more submissions in an hour from the same address","digimail-smtp"),too_many:(0,i.__)("5 or more submissions in 10 minutes from the same address","digimail-smtp"),link_in_name:(0,i.__)("Link in the name, company or phone field","digimail-smtp"),html_links:(0,i.__)("HTML or BBCode links in the message","digimail-smtp"),many_links:(0,i.__)("3 or more links in the message","digimail-smtp"),foreign_script:(0,i.__)("Mostly written in another alphabet (Cyrillic, Chinese…)","digimail-smtp"),gibberish_name:(0,i.__)("Name looks random","digimail-smtp"),bad_phone:(0,i.__)("Letters in the phone field","digimail-smtp"),spam_words:(0,i.__)("Typical spam words (casino, crypto, backlinks…)","digimail-smtp"),repeated:(0,i.__)("Same message from several visitors","digimail-smtp"),disposable_email:(0,i.__)("Throwaway email address","digimail-smtp"), blocklist:(0,i.__)("Matches the comment blocklist in Settings › Discussion","digimail-smtp"),akismet:(0,i.__)("Akismet says spam","digimail-smtp")};class r extends Error{}async function c(e,t,a){try{return await n()({path:`/digimail-smtp/v1/${e}`,method:a??(void 0===t?"GET":"POST"),data:t})}catch(e){const t=e;throw new r(t?.error||t?.message||(0,i.__)("That did not work. Try again later.","digimail-smtp"))}}const o=(window.digimailSmtp?.locale||"en-US").replace("_","-"),d=e=>(e??0).toLocaleString(o);function p(e){if(!e)return"";const t=new Date(e),a=(Date.now()-t.getTime())/1e3;return a<60?(0,i.__)("just now","digimail-smtp"):a<3600?(0,i.sprintf)(/* translators: %d: number of minutes. */ /* translators: %d: number of minutes. */(0,i.__)("%d min ago","digimail-smtp"),Math.floor(a/60)):a<86400&&t.getDate()===(new Date).getDate()?(0,i.sprintf)(/* translators: %s: time of day. */ /* translators: %s: time of day. */(0,i.__)("%s today","digimail-smtp"),t.toLocaleTimeString(o,{hour:"2-digit",minute:"2-digit"})):t.toLocaleString(o,{hour:"2-digit",minute:"2-digit",day:"2-digit",month:"2-digit"})}const u={queued:{label:(0,i.__)("Waiting to send","digimail-smtp"),tone:"muted"},claimed:{label:(0,i.__)("Sending","digimail-smtp"),tone:"muted"},sending:{label:(0,i.__)("Sending","digimail-smtp"),tone:"muted"},sent:{label:(0,i.__)("Sent","digimail-smtp"),tone:"info"},delivered:{label:(0,i.__)("Delivered","digimail-smtp"),tone:"ok"},bounced:{label:(0,i.__)("Bounced","digimail-smtp"),tone:"bad"},complained:{label:(0,i.__)("Marked as spam","digimail-smtp"),tone:"bad"},rejected:{label:(0,i.__)("Rejected","digimail-smtp"),tone:"bad"},failed:{label:(0,i.__)("Failed","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Unknown","digimail-smtp"),tone:"muted"},suppressed:{label:(0,i.__)("Skipped (blocked)","digimail-smtp"),tone:"wait"},backup:{label:(0,i.__)("Sent via backup","digimail-smtp"),tone:"wait"},blocked:{label:(0,i.__)("Not sent (suspicious recipient)","digimail-smtp"),tone:"wait"}};function g(e){return e?e.startsWith("theme:")?(0,i.sprintf)(/* translators: %s: theme folder name. */ /* translators: %s: theme folder name. */(0,i.__)("Theme %s","digimail-smtp"),e.slice(6)):{wordpress:"WordPress",woocommerce:"WooCommerce","contact-form-7":"Contact Form 7",wpforms:"WPForms","wpforms-lite":"WPForms",gravityforms:"Gravity Forms",fluentform:"Fluent Forms",elementor:"Elementor","elementor-pro":"Elementor Pro","digimail-smtp":"DigiMail SMTP",digimail:"DigiMail","ninja-forms":"Ninja Forms",formidable:"Formidable",learnpress:"LearnPress","ultimate-member":"Ultimate Member",bricks:"Bricks"}[e]??e.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()):""}function _(){return _=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var l in a)({}).hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e},_.apply(null,arguments)}function h({tone:e="muted",children:t}){return(0,l.createElement)("span",{className:`dms-badge dms-${e}`},t)}function E({title:e,aside:t,children:a,className:i=""}){return(0,l.createElement)("section",{className:`dms-card ${i}`},(e||t)&&(0,l.createElement)("header",{className:"dms-card-head"},e&&(0,l.createElement)("h2",null,e),t),a)}function f({children:e,variant:t="primary",busy:a,size:i,className:s="",disabled:n,...m}){return(0,l.createElement)("button",_({type:"button"},m,{className:`dms-btn dms-btn-${t} ${i?`dms-btn-${i}`:""} ${s}`,disabled:a||n,"aria-busy":a||void 0}),a&&(0,l.createElement)("span",{className:"dms-spin","aria-hidden":!0}),e)}function b({checked:e,onChange:t,label:a,hint:i,disabled:s}){return(0,l.createElement)("label",{className:"dms-toggle "+(s?"is-disabled":"")},(0,l.createElement)("input",{type:"checkbox",role:"switch",checked:e,disabled:s,onChange:e=>t(e.target.checked)}),(0,l.createElement)("span",{className:"dms-switch","aria-hidden":!0}),(0,l.createElement)("span",{className:"dms-toggle-text"},(0,l.createElement)("span",null,a),i&&(0,l.createElement)("small",null,i)))}function y({label:e,hint:t,children:a,htmlFor:i}){return(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("label",{htmlFor:i},e),a,t&&(0,l.createElement)("small",{className:"dms-hint"},t))}function v({tone:e="info",title:t,children:a,action:i}){return(0,l.createElement)("div",{className:`dms-notice dms-notice-${e}`,role:"bad"===e?"alert":void 0},(0,l.createElement)("div",null,t&&(0,l.createElement)("strong",null,t),a&&(0,l.createElement)("div",null,a)),i&&(0,l.createElement)("div",{className:"dms-notice-action"},i))}function k({icon:e,title:t,children:a}){return(0,l.createElement)("div",{className:"dms-empty"},e&&(0,l.createElement)("div",{className:"dms-empty-icon"},e),(0,l.createElement)("strong",null,t),a&&(0,l.createElement)("p",null,a))}function w({name:e,size:t=18}){const a={check:(0,l.createElement)("path",{d:"M20 6 9 17l-5-5"}),plus:(0,l.createElement)("path",{d:"M12 5v14M5 12h14"}),trash:(0,l.createElement)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"}),back:(0,l.createElement)("path",{d:"M15 18l-6-6 6-6"}),form:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),(0,l.createElement)("path",{d:"M7 9h10M7 13h6"}),(0,l.createElement)("rect",{x:"13",y:"12",width:"5",height:"3",rx:"1"})),cart:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"8",cy:"21",r:"1"}),(0,l.createElement)("circle",{cx:"19",cy:"21",r:"1"}),(0,l.createElement)("path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"})),mail:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),(0,l.createElement)("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})),send:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M14.54 21.69a.5.5 0 0 0 .93-.03l6.5-19a.5.5 0 0 0-.63-.63l-19 6.5a.5.5 0 0 0-.03.93l7.93 3.18a2 2 0 0 1 1.11 1.11z"}),(0,l.createElement)("path",{d:"m21.85 2.15-10.94 10.94"})),list:(0,l.createElement)("path",{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),users:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),(0,l.createElement)("circle",{cx:"9",cy:"7",r:"4"}),(0,l.createElement)("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"})),settings:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),(0,l.createElement)("circle",{cx:"12",cy:"12",r:"3"})),chart:(0,l.createElement)("path",{d:"M3 3v16a2 2 0 0 0 2 2h16M7 16V9M12 16v-5M17 16V6"}),tools:(0,l.createElement)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"}),alert:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 8v4M12 16h.01"})),x:(0,l.createElement)("path",{d:"M18 6 6 18M6 6l12 12"}),external:(0,l.createElement)("path",{d:"M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),refresh:(0,l.createElement)("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8M21 3v5h-5M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16M8 16H3v5"}),shield:(0,l.createElement)("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}),globe:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20M2 12h20"})),zap:(0,l.createElement)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}),eye:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M2.06 12.35a1 1 0 0 1 0-.7 10.75 10.75 0 0 1 19.88 0 1 1 0 0 1 0 .7 10.75 10.75 0 0 1-19.88 0"}),(0,l.createElement)("circle",{cx:"12",cy:"12",r:"3"})),clock:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 6v6l4 2"})),search:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"11",cy:"11",r:"8"}),(0,l.createElement)("path",{d:"m21 21-4.3-4.3"})),paperclip:(0,l.createElement)("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),copy:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"8",y:"8",width:"14",height:"14",rx:"2"}),(0,l.createElement)("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})),bell:(0,l.createElement)("path",{d:"M10.27 21a2 2 0 0 0 3.46 0M3.26 15.33A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.67C19.41 13.96 18 12.5 18 8A6 6 0 0 0 6 8c0 4.5-1.41 5.96-2.74 7.33"}),download:(0,l.createElement)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"}),palette:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M12 22a10 10 0 1 1 10-10c0 2.2-1.8 3.5-4 3.5h-1.6a1.9 1.9 0 0 0-1.4 3.2A2 2 0 0 1 13.6 22z"}),(0,l.createElement)("circle",{cx:"7.5",cy:"10.5",r:"1",fill:"currentColor"}),(0,l.createElement)("circle",{cx:"11",cy:"6.5",r:"1",fill:"currentColor"}),(0,l.createElement)("circle",{cx:"16",cy:"8",r:"1",fill:"currentColor"}))};return(0,l.createElement)("svg",{className:"dms-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},a[e])}function N({open:e,onClose:t,title:a,children:s}){const n=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!e)return;const a=e=>"Escape"===e.key&&t();return document.addEventListener("keydown",a),n.current?.focus(),()=>document.removeEventListener("keydown",a)},[e,t]),e?(0,l.createElement)("div",{className:"dms-drawer-back",onClick:e=>e.target===e.currentTarget&&t()},(0,l.createElement)("div",{className:"dms-drawer",role:"dialog","aria-modal":"true",tabIndex:-1,ref:n},(0,l.createElement)("header",null,(0,l.createElement)("h2",null,a),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn",onClick:t,"aria-label":(0,i.__)("Close","digimail-smtp")},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("div",{className:"dms-drawer-body"},s))):null}const S=(0,l.createContext)(()=>{}),C=()=>(0,l.useContext)(S);function x({value:e,onChange:t,onDone:a,disabled:s}){const n=(0,l.useRef)([]);return(0,l.useEffect)(()=>n.current[0]?.focus(),[]),(0,l.createElement)("div",{className:"dms-code",role:"group","aria-label":(0,i.__)("6-digit code","digimail-smtp")},[0,1,2,3,4,5].map(m=>(0,l.createElement)("input",{key:m,ref:e=>n.current[m]=e,inputMode:"numeric",autoComplete:0===m?"one-time-code":"off",maxLength:6,"aria-label":(0,i.sprintf)(/* translators: %d: position of the digit, 1 to 6. */ /* translators: %d: position of the digit, 1 to 6. */(0,i.__)("Digit %d","digimail-smtp"),m+1),value:(e[m]??"").trim(),disabled:s,onChange:l=>((l,i)=>{const s=i.replace(/\D/g,"");if(s.length>1){const i=(e.slice(0,l)+s).slice(0,6);return t(i),n.current[Math.min(i.length,5)]?.focus(),void(6===i.length&&a(i))}const m=e.padEnd(6," ").split("");m[l]=s||" ";const r=m.join("").replace(/\s+$/,"");t(r),s&&l<5&&n.current[l+1]?.focus(),6===r.replace(/\s/g,"").length&&a(r.replace(/\s/g,""))})(m,l.target.value),onKeyDown:t=>{"Backspace"===t.key&&!(e[m]??"").trim()&&m>0&&n.current[m-1]?.focus()}})))}function M({state:e,reload:t}){const[a,s]=(0,l.useState)(e.pending?"code":"email"),[n,m]=(0,l.useState)(e.pending??e.site.user_email??""),[r,o]=(0,l.useState)(""),[d,p]=(0,l.useState)(null),[u,g]=(0,l.useState)(""),[_,h]=(0,l.useState)(0);(0,l.useEffect)(()=>{if(_<=0)return;const e=setTimeout(()=>h(_-1),1e3);return()=>clearTimeout(e)},[_]);const E=async()=>{p("start"),g("");try{await c("connect/start",{email:n}),s("code"),o(""),h(45)}catch(e){g(e.message)}finally{p(null)}},b=async e=>{p("verify"),g("");try{await c("connect/verify",{code:e}),await t()}catch(e){g(e.message),o("")}finally{p(null)}},y={strong:(0,l.createElement)("strong",null)};return(0,l.createElement)("div",{className:"dms-onboard"},(0,l.createElement)("div",{className:"dms-onboard-pitch"},(0,l.createElement)("span",{className:"dms-eyebrow"},"DigiMail SMTP"),(0,l.createElement)("h1",null,(0,i.__)("Send email from your website now, no SMTP setup","digimail-smtp")),(0,l.createElement)("p",{className:"dms-lead"},(0,i.__)("Enter your email, type the 6-digit code, done. Order emails, contact forms and password resets go through DigiMail’s professional mail servers instead of the mail() function that often lands in spam.","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-points"},(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"zap"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Working in 30 seconds.</strong> No host, port, app password or API key.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"eye"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Know whether email arrives.</strong> A log of every email: delivered, bounced, opened, with the reason for errors.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"shield"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>No lost email.</strong> Automatic retries on network errors, with your old SMTP server as backup.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"globe"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Manage all your websites</strong> in one account on digimail.vn.","digimail-smtp"),y)))),e.conflicts.length>0&&/* translators: %s: names of other active SMTP plugins. */ /* translators: %s: names of other active SMTP plugins. */2 (0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)((0,i.__)("%s is active","digimail-smtp"),e.conflicts.map(e=>e.name).join(", "))},(0,i.__)("After connecting, open Tools to import the old settings (the old SMTP server becomes the backup connection), then deactivate the other plugin.","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-card dms-onboard-card"},"email"===a?(0,l.createElement)("form",{onSubmit:e=>{e.preventDefault(),E()}},(0,l.createElement)("div",{className:"dms-step"},(0,l.createElement)("span",null,"1")," ",(0,i.__)("Enter your email","digimail-smtp")),(0,l.createElement)("h2",null,(0,i.__)("Start sending email","digimail-smtp")),(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("We send a 6-digit code to this email to confirm it. If you have no DigiMail account yet, a free one is created for you.","digimail-smtp")),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("label",{htmlFor:"dms-email"},(0,i.__)("Email","digimail-smtp")),(0,l.createElement)("input",{id:"dms-email",type:"email",required:!0,value:n,onChange:e=>m(e.target.value),placeholder:(0,i.__)("you@company.com","digimail-smtp"),autoComplete:"email"})), u&&(0,l.createElement)("p",{className:"dms-error",role:"alert"},u),(0,l.createElement)(f,{type:"submit",busy:"start"===d,size:"lg"},(0,i.__)("Send confirmation code","digimail-smtp")),(0,l.createElement)("div",{className:"dms-or"},(0,l.createElement)("span",null,(0,i.__)("or","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",onClick:async()=>{p("approve");try{const e=await c("connect/url");window.location.href=e.url}catch(e){g(e.message),p(null)}},busy:"approve"===d,size:"block"},(0,i.__)("Have a DigiMail account? Log in and connect","digimail-smtp")),(0,l.createElement)("p",{className:"dms-fine"},(0,l.createInterpolateElement)((0,i.__)("Once connected, your website’s email goes through DigiMail servers (api.digimail.vn) to reach recipients. By connecting you agree to the <terms>Terms of Service</terms> and <privacy>Privacy Policy</privacy>.","digimail-smtp"),{terms:(0,l.createElement)("a",{href:`${e.env.app}/dieu-khoan`,target:"_blank",rel:"noreferrer"}),privacy:(0,l.createElement)("a",{href:`${e.env.app}/chinh-sach-bao-mat`,target:"_blank",rel:"noreferrer"})}))):(0,l.createElement)("form",{onSubmit:e=>{e.preventDefault(),b(r)}},(0,l.createElement)("div",{className:"dms-step"},(0,l.createElement)("span",null,"2")," ",(0,i.__)("Enter the code","digimail-smtp")),(0,l.createElement)("h2",null,(0,i.__)("Check your inbox","digimail-smtp")),(0,l.createElement)("p",{className:"dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: email address the code was sent to. */ /* translators: %s: email address the code was sent to. */(0,i.__)("The 6-digit code was sent to <strong>%s</strong>. Not there? Check Spam or Promotions.","digimail-smtp"),n),y)),(0,l.createElement)(x,{value:r,onChange:o,onDone:b,disabled:"verify"===d}),u&&(0,l.createElement)("p",{className:"dms-error",role:"alert"},u),(0,l.createElement)(f,{type:"submit",busy:"verify"===d,disabled:r.replace(/\s/g,"").length<6,size:"lg"},(0,i.__)("Confirm and connect","digimail-smtp")),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>{s("email"),g("")}},(0,i.__)("Change email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-link",disabled:_>0||null!==d,onClick:E},_>0?(0,i.sprintf)(/* translators: %d: seconds until the code can be sent again. */ /* translators: %d: seconds until the code can be sent again. */(0,i.__)("Resend code in %d s","digimail-smtp"),_):(0,i.__)("Resend code","digimail-smtp"))))))}const T=(e,t)=>t>0?Math.round(e/t*1e3)/10:0;function D({days:e}){const[t,a]=(0,l.useState)(null),s=Math.max(4,...e.map(e=>e.sent)),n=(640-6*(e.length-1))/e.length,m=e=>e/s*152,r=null!==t?e[t]:null;return(0,l.createElement)("div",{className:"dms-chart"},(0,l.createElement)("svg",{viewBox:"0 0 640 192",role:"img","aria-label":(0,i.__)("Emails per day","digimail-smtp")},[.5,1].map(e=>(0,l.createElement)("line",{key:e,x1:0,x2:640,y1:170-m(s*e),y2:170-m(s*e),className:"dms-grid"})),e.map((t,i)=>{const s=i*(n+6),r=Math.max(0,t.sent-t.delivered-t.failed);let c=170;const d=(e,t)=>{if(e<=0)return null;const a=Math.max(2,m(e));return c-=a,(0,l.createElement)("rect",{x:s,y:c,width:n,height:Math.max(0,a-1.5),rx:3,className:t})};return(0,l.createElement)("g",{key:t.day,onMouseEnter:()=>a(i),onMouseLeave:()=>a(null)},(0,l.createElement)("rect",{x:s-3,y:0,width:n+6,height:192,fill:"transparent"}),d(t.delivered,"dms-bar-ok"),d(r,"dms-bar-transit"),d(t.failed,"dms-bar-bad"),0===t.sent&&(0,l.createElement)("rect",{x:s,y:168,width:n,height:2,rx:1,className:"dms-bar-zero"}),(i%Math.ceil(e.length/7)===0||i===e.length-1)&&(0,l.createElement)("text",{x:s+n/2,y:186,textAnchor:"middle",className:"dms-axis"},new Date(t.day).toLocaleDateString(o,{day:"2-digit",month:"2-digit"})))})),r&&(0,l.createElement)("div",{className:"dms-tip",style:{left:(t+.5)/e.length*100+"%"}},(0,l.createElement)("strong",null,new Date(r.day).toLocaleDateString(o,{weekday:"short",day:"2-digit",month:"2-digit"})),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-ok"})," ",(0,i.__)("Delivered","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.delivered))),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-transit"})," ",(0,i.__)("In transit","digimail-smtp")," ",(0,l.createElement)("b",null,d(Math.max(0,r.sent-r.delivered-r.failed)))),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-bad"})," ",(0,i.__)("Failed","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.failed))),(0,l.createElement)("span",null,(0,i.__)("Opened","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.opened)))),(0,l.createElement)("div",{className:"dms-legend"},(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-ok"})," ",(0,i.__)("Delivered","digimail-smtp")),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-transit"})," ",(0,i.__)("In transit","digimail-smtp")),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-bad"})," ",(0,i.__)("Failed or bounced","digimail-smtp"))))}function F({label:e,used:t,total:a}){const i=a>0?Math.min(100,t/a*100):0;return(0,l.createElement)("div",{className:"dms-meter"},(0,l.createElement)("div",{className:"dms-meter-head"},(0,l.createElement)("span",null,e),(0,l.createElement)("span",null,(0,l.createElement)("b",null,d(t))," / ",d(a))),(0,l.createElement)("div",{className:"dms-meter-bar"},(0,l.createElement)("span",{style:{width:`${i}%`},className:i>90?"is-bad":i>70?"is-wait":""})))}function z({state:e,go:t}){const[a,s]=(0,l.useState)(null),[n,m]=(0,l.useState)("");(0,l.useEffect)(()=>{c("stats?days=14").then(s).catch(e=>m(e.message))},[]);const r=e.status,o=r.sender,p=r.account,u=a?.days.reduce((e,t)=>e+t.sent,0)??0,_=a?.days.reduce((e,t)=>e+t.delivered,0)??0,b=a?.days.reduce((e,t)=>e+t.failed,0)??0,y=a?.days.reduce((e,t)=>e+t.opened,0)??0,k="shared"===o?.mode,N=r.site_domain,S=N&&!/^(localhost|[\d.]+|\[?[\da-f:]+\]?)$/i.test(N.domain)&&N.domain.includes(".")?N:null;return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-hero"},(0,l.createElement)("div",{className:"dms-hero-icon"},(0,l.createElement)(w,{name:"check",size:26})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("This website sends email through DigiMail","digimail-smtp")),o&&(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: sender name, 2: sender email. */ /* translators: 1: sender name, 2: sender email. */(0,i.__)("From <strong>%1$s</strong> (%2$s)","digimail-smtp"),o.name,o.email),{strong:(0,l.createElement)("strong",null)})," ",k?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Own domain","digimail-smtp")))),(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("test")},(0,l.createElement)(w,{name:"send",size:15})," ",(0,i.__)("Send test email","digimail-smtp"))),e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),!e.settings.capture.enabled&&(e.capture.forms.length>0||e.capture.woocommerce)&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Save form contacts to DigiMail","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.sprintf)(/* translators: %s: form plugins or WooCommerce found on the site. */ /* translators: %s: form plugins or WooCommerce found on the site. */1 (()=>{"use strict";var e={897(e,t,a){const l=window.wp.element,i=window.wp.i18n,s=window.wp.apiFetch;var n=a.n(s);const m={honeypot:(0,i.__)("Filled in the hidden trap field","digimail-smtp"),no_js:(0,i.__)("Sent without the page script (posted straight by a bot)","digimail-smtp"),no_token:(0,i.__)("No protection token","digimail-smtp"),forged:(0,i.__)("Fake protection token","digimail-smtp"),bad_pow:(0,i.__)("Wrong answer to the browser check","digimail-smtp"),no_pow:(0,i.__)("Browser check not done","digimail-smtp"),reused:(0,i.__)("Same token used many times","digimail-smtp"),too_fast:(0,i.__)("Sent less than 2 seconds after the page opened","digimail-smtp"),fast:(0,i.__)("Sent very quickly","digimail-smtp"),no_interaction:(0,i.__)("No typing, click or touch in the form","digimail-smtp"),flood:(0,i.__)("15 or more submissions in an hour from the same address","digimail-smtp"),too_many:(0,i.__)("5 or more submissions in 10 minutes from the same address","digimail-smtp"),link_in_name:(0,i.__)("Link in the name, company or phone field","digimail-smtp"),html_links:(0,i.__)("HTML or BBCode links in the message","digimail-smtp"),many_links:(0,i.__)("3 or more links in the message","digimail-smtp"),foreign_script:(0,i.__)("Mostly written in another alphabet (Cyrillic, Chinese…)","digimail-smtp"),gibberish_name:(0,i.__)("Name looks random","digimail-smtp"),bad_phone:(0,i.__)("Letters in the phone field","digimail-smtp"),spam_words:(0,i.__)("Typical spam words (casino, crypto, backlinks…)","digimail-smtp"),repeated:(0,i.__)("Same message from several visitors","digimail-smtp"),disposable_email:(0,i.__)("Throwaway email address","digimail-smtp"),dotted_gmail:(0,i.__)("Gmail address with random dots (bi.f.ewoy…@gmail.com)","digimail-smtp"),gmail_variants:(0,i.__)("Same Gmail mailbox sent with different dots","digimail-smtp"),tor:(0,i.__)("Sent through the Tor network","digimail-smtp"),blocklist:(0,i.__)("Matches the comment blocklist in Settings › Discussion","digimail-smtp"),akismet:(0,i.__)("Akismet says spam","digimail-smtp")};class r extends Error{}async function o(e,t,a){try{return await n()({path:`/digimail-smtp/v1/${e}`,method:a??(void 0===t?"GET":"POST"),data:t})}catch(e){const t=e;throw new r(t?.error||t?.message||(0,i.__)("That did not work. Try again later.","digimail-smtp"))}}const c=(window.digimailSmtp?.locale||"en-US").replace("_","-"),d=e=>(e??0).toLocaleString(c);function p(e){if(!e)return"";const t=new Date(e),a=(Date.now()-t.getTime())/1e3;return a<60?(0,i.__)("just now","digimail-smtp"):a<3600?(0,i.sprintf)(/* translators: %d: number of minutes. */ /* translators: %d: number of minutes. */(0,i.__)("%d min ago","digimail-smtp"),Math.floor(a/60)):a<86400&&t.getDate()===(new Date).getDate()?(0,i.sprintf)(/* translators: %s: time of day. */ /* translators: %s: time of day. */(0,i.__)("%s today","digimail-smtp"),t.toLocaleTimeString(c,{hour:"2-digit",minute:"2-digit"})):t.toLocaleString(c,{hour:"2-digit",minute:"2-digit",day:"2-digit",month:"2-digit"})}const g={queued:{label:(0,i.__)("Waiting to send","digimail-smtp"),tone:"muted"},claimed:{label:(0,i.__)("Sending","digimail-smtp"),tone:"muted"},sending:{label:(0,i.__)("Sending","digimail-smtp"),tone:"muted"},sent:{label:(0,i.__)("Sent","digimail-smtp"),tone:"info"},delivered:{label:(0,i.__)("Delivered","digimail-smtp"),tone:"ok"},bounced:{label:(0,i.__)("Bounced","digimail-smtp"),tone:"bad"},complained:{label:(0,i.__)("Marked as spam","digimail-smtp"),tone:"bad"},rejected:{label:(0,i.__)("Rejected","digimail-smtp"),tone:"bad"},failed:{label:(0,i.__)("Failed","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Unknown","digimail-smtp"),tone:"muted"},suppressed:{label:(0,i.__)("Skipped (blocked)","digimail-smtp"),tone:"wait"},backup:{label:(0,i.__)("Sent via backup","digimail-smtp"),tone:"wait"},blocked:{label:(0,i.__)("Not sent (suspicious recipient)","digimail-smtp"),tone:"wait"}};function u(e){if(!e)return"";const t={wordpress:"WordPress",woocommerce:"WooCommerce","contact-form-7":"Contact Form 7",wpforms:"WPForms","wpforms-lite":"WPForms",gravityforms:"Gravity Forms",fluentform:"Fluent Forms",elementor:"Elementor","elementor-pro":"Elementor Pro","digimail-smtp":"DigiMail SMTP",digimail:"DigiMail","ninja-forms":"Ninja Forms",formidable:"Formidable",learnpress:"LearnPress","ultimate-member":"Ultimate Member",bricks:"Bricks","wp-register":(0,i.__)("WordPress registration","digimail-smtp"),"wp-lostpassword":(0,i.__)("WordPress lost password","digimail-smtp"),"wp-comments":(0,i.__)("WordPress comments","digimail-smtp"),"woo-register":(0,i.__)("WooCommerce registration","digimail-smtp")};return e.startsWith("theme:")?(0,i.sprintf)(/* translators: %s: theme folder name. */ /* translators: %s: theme folder name. */(0,i.__)("Theme %s","digimail-smtp"),e.slice(6)):t[e]??e.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function _(){return _=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var l in a)({}).hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e},_.apply(null,arguments)}function h({tone:e="muted",children:t}){return(0,l.createElement)("span",{className:`dms-badge dms-${e}`},t)}function E({title:e,aside:t,children:a,className:i=""}){return(0,l.createElement)("section",{className:`dms-card ${i}`},(e||t)&&(0,l.createElement)("header",{className:"dms-card-head"},e&&(0,l.createElement)("h2",null,e),t),a)}function f({children:e,variant:t="primary",busy:a,size:i,className:s="",disabled:n,...m}){return(0,l.createElement)("button",_({type:"button"},m,{className:`dms-btn dms-btn-${t} ${i?`dms-btn-${i}`:""} ${s}`,disabled:a||n,"aria-busy":a||void 0}),a&&(0,l.createElement)("span",{className:"dms-spin","aria-hidden":!0}),e)}function b({checked:e,onChange:t,label:a,hint:i,disabled:s}){return(0,l.createElement)("label",{className:"dms-toggle "+(s?"is-disabled":"")},(0,l.createElement)("input",{type:"checkbox",role:"switch",checked:e,disabled:s,onChange:e=>t(e.target.checked)}),(0,l.createElement)("span",{className:"dms-switch","aria-hidden":!0}),(0,l.createElement)("span",{className:"dms-toggle-text"},(0,l.createElement)("span",null,a),i&&(0,l.createElement)("small",null,i)))}function y({label:e,hint:t,children:a,htmlFor:i}){return(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("label",{htmlFor:i},e),a,t&&(0,l.createElement)("small",{className:"dms-hint"},t))}function v({tone:e="info",title:t,children:a,action:i}){return(0,l.createElement)("div",{className:`dms-notice dms-notice-${e}`,role:"bad"===e?"alert":void 0},(0,l.createElement)("div",null,t&&(0,l.createElement)("strong",null,t),a&&(0,l.createElement)("div",null,a)),i&&(0,l.createElement)("div",{className:"dms-notice-action"},i))}function k({icon:e,title:t,children:a}){return(0,l.createElement)("div",{className:"dms-empty"},e&&(0,l.createElement)("div",{className:"dms-empty-icon"},e),(0,l.createElement)("strong",null,t),a&&(0,l.createElement)("p",null,a))}function w({name:e,size:t=18}){const a={check:(0,l.createElement)("path",{d:"M20 6 9 17l-5-5"}),plus:(0,l.createElement)("path",{d:"M12 5v14M5 12h14"}),trash:(0,l.createElement)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"}),back:(0,l.createElement)("path",{d:"M15 18l-6-6 6-6"}),form:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),(0,l.createElement)("path",{d:"M7 9h10M7 13h6"}),(0,l.createElement)("rect",{x:"13",y:"12",width:"5",height:"3",rx:"1"})),cart:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"8",cy:"21",r:"1"}),(0,l.createElement)("circle",{cx:"19",cy:"21",r:"1"}),(0,l.createElement)("path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"})),mail:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),(0,l.createElement)("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})),send:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M14.54 21.69a.5.5 0 0 0 .93-.03l6.5-19a.5.5 0 0 0-.63-.63l-19 6.5a.5.5 0 0 0-.03.93l7.93 3.18a2 2 0 0 1 1.11 1.11z"}),(0,l.createElement)("path",{d:"m21.85 2.15-10.94 10.94"})),list:(0,l.createElement)("path",{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),users:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),(0,l.createElement)("circle",{cx:"9",cy:"7",r:"4"}),(0,l.createElement)("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"})),settings:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),(0,l.createElement)("circle",{cx:"12",cy:"12",r:"3"})),chart:(0,l.createElement)("path",{d:"M3 3v16a2 2 0 0 0 2 2h16M7 16V9M12 16v-5M17 16V6"}),tools:(0,l.createElement)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"}),alert:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 8v4M12 16h.01"})),x:(0,l.createElement)("path",{d:"M18 6 6 18M6 6l12 12"}),external:(0,l.createElement)("path",{d:"M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),refresh:(0,l.createElement)("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8M21 3v5h-5M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16M8 16H3v5"}),shield:(0,l.createElement)("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}),globe:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20M2 12h20"})),zap:(0,l.createElement)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}),eye:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M2.06 12.35a1 1 0 0 1 0-.7 10.75 10.75 0 0 1 19.88 0 1 1 0 0 1 0 .7 10.75 10.75 0 0 1-19.88 0"}),(0,l.createElement)("circle",{cx:"12",cy:"12",r:"3"})),clock:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 6v6l4 2"})),search:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"11",cy:"11",r:"8"}),(0,l.createElement)("path",{d:"m21 21-4.3-4.3"})),paperclip:(0,l.createElement)("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),copy:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"8",y:"8",width:"14",height:"14",rx:"2"}),(0,l.createElement)("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})),bell:(0,l.createElement)("path",{d:"M10.27 21a2 2 0 0 0 3.46 0M3.26 15.33A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.67C19.41 13.96 18 12.5 18 8A6 6 0 0 0 6 8c0 4.5-1.41 5.96-2.74 7.33"}),download:(0,l.createElement)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"}),palette:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M12 22a10 10 0 1 1 10-10c0 2.2-1.8 3.5-4 3.5h-1.6a1.9 1.9 0 0 0-1.4 3.2A2 2 0 0 1 13.6 22z"}),(0,l.createElement)("circle",{cx:"7.5",cy:"10.5",r:"1",fill:"currentColor"}),(0,l.createElement)("circle",{cx:"11",cy:"6.5",r:"1",fill:"currentColor"}),(0,l.createElement)("circle",{cx:"16",cy:"8",r:"1",fill:"currentColor"}))};return(0,l.createElement)("svg",{className:"dms-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},a[e])}function N({open:e,onClose:t,title:a,children:s}){const n=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!e)return;const a=e=>"Escape"===e.key&&t();return document.addEventListener("keydown",a),n.current?.focus(),()=>document.removeEventListener("keydown",a)},[e,t]),e?(0,l.createElement)("div",{className:"dms-drawer-back",onClick:e=>e.target===e.currentTarget&&t()},(0,l.createElement)("div",{className:"dms-drawer",role:"dialog","aria-modal":"true",tabIndex:-1,ref:n},(0,l.createElement)("header",null,(0,l.createElement)("h2",null,a),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn",onClick:t,"aria-label":(0,i.__)("Close","digimail-smtp")},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("div",{className:"dms-drawer-body"},s))):null}const S=(0,l.createContext)(()=>{}),C=()=>(0,l.useContext)(S);function x({value:e,onChange:t,onDone:a,disabled:s}){const n=(0,l.useRef)([]);return(0,l.useEffect)(()=>n.current[0]?.focus(),[]),(0,l.createElement)("div",{className:"dms-code",role:"group","aria-label":(0,i.__)("6-digit code","digimail-smtp")},[0,1,2,3,4,5].map(m=>(0,l.createElement)("input",{key:m,ref:e=>n.current[m]=e,inputMode:"numeric",autoComplete:0===m?"one-time-code":"off",maxLength:6,"aria-label":(0,i.sprintf)(/* translators: %d: position of the digit, 1 to 6. */ /* translators: %d: position of the digit, 1 to 6. */(0,i.__)("Digit %d","digimail-smtp"),m+1),value:(e[m]??"").trim(),disabled:s,onChange:l=>((l,i)=>{const s=i.replace(/\D/g,"");if(s.length>1){const i=(e.slice(0,l)+s).slice(0,6);return t(i),n.current[Math.min(i.length,5)]?.focus(),void(6===i.length&&a(i))}const m=e.padEnd(6," ").split("");m[l]=s||" ";const r=m.join("").replace(/\s+$/,"");t(r),s&&l<5&&n.current[l+1]?.focus(),6===r.replace(/\s/g,"").length&&a(r.replace(/\s/g,""))})(m,l.target.value),onKeyDown:t=>{"Backspace"===t.key&&!(e[m]??"").trim()&&m>0&&n.current[m-1]?.focus()}})))}function M({state:e,reload:t}){const[a,s]=(0,l.useState)(e.pending?"code":"email"),[n,m]=(0,l.useState)(e.pending??e.site.user_email??""),[r,c]=(0,l.useState)(""),[d,p]=(0,l.useState)(null),[g,u]=(0,l.useState)(""),[_,h]=(0,l.useState)(0);(0,l.useEffect)(()=>{if(_<=0)return;const e=setTimeout(()=>h(_-1),1e3);return()=>clearTimeout(e)},[_]);const E=async()=>{p("start"),u("");try{await o("connect/start",{email:n}),s("code"),c(""),h(45)}catch(e){u(e.message)}finally{p(null)}},b=async e=>{p("verify"),u("");try{await o("connect/verify",{code:e}),await t()}catch(e){u(e.message),c("")}finally{p(null)}},y={strong:(0,l.createElement)("strong",null)};return(0,l.createElement)("div",{className:"dms-onboard"},(0,l.createElement)("div",{className:"dms-onboard-pitch"},(0,l.createElement)("span",{className:"dms-eyebrow"},"DigiMail SMTP"),(0,l.createElement)("h1",null,(0,i.__)("Send email from your website now, no SMTP setup","digimail-smtp")),(0,l.createElement)("p",{className:"dms-lead"},(0,i.__)("Enter your email, type the 6-digit code, done. Order emails, contact forms and password resets go through DigiMail’s professional mail servers instead of the mail() function that often lands in spam.","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-points"},(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"zap"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Working in 30 seconds.</strong> No host, port, app password or API key.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"eye"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Know whether email arrives.</strong> A log of every email: delivered, bounced, opened, with the reason for errors.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"shield"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>No lost email.</strong> Automatic retries on network errors, with your old SMTP server as backup.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"globe"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Manage all your websites</strong> in one account on digimail.vn.","digimail-smtp"),y)))),e.conflicts.length>0&&/* translators: %s: names of other active SMTP plugins. */ /* translators: %s: names of other active SMTP plugins. */ 2 (0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)((0,i.__)("%s is active","digimail-smtp"),e.conflicts.map(e=>e.name).join(", "))},(0,i.__)("After connecting, open Tools to import the old settings (the old SMTP server becomes the backup connection), then deactivate the other plugin.","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-card dms-onboard-card"},"email"===a?(0,l.createElement)("form",{onSubmit:e=>{e.preventDefault(),E()}},(0,l.createElement)("div",{className:"dms-step"},(0,l.createElement)("span",null,"1")," ",(0,i.__)("Enter your email","digimail-smtp")),(0,l.createElement)("h2",null,(0,i.__)("Start sending email","digimail-smtp")),(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("We send a 6-digit code to this email to confirm it. If you have no DigiMail account yet, a free one is created for you.","digimail-smtp")),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("label",{htmlFor:"dms-email"},(0,i.__)("Email","digimail-smtp")),(0,l.createElement)("input",{id:"dms-email",type:"email",required:!0,value:n,onChange:e=>m(e.target.value),placeholder:(0,i.__)("you@company.com","digimail-smtp"),autoComplete:"email"})),g&&(0,l.createElement)("p",{className:"dms-error",role:"alert"},g),(0,l.createElement)(f,{type:"submit",busy:"start"===d,size:"lg"},(0,i.__)("Send confirmation code","digimail-smtp")),(0,l.createElement)("div",{className:"dms-or"},(0,l.createElement)("span",null,(0,i.__)("or","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",onClick:async()=>{p("approve");try{const e=await o("connect/url");window.location.href=e.url}catch(e){u(e.message),p(null)}},busy:"approve"===d,size:"block"},(0,i.__)("Have a DigiMail account? Log in and connect","digimail-smtp")),(0,l.createElement)("p",{className:"dms-fine"},(0,l.createInterpolateElement)((0,i.__)("Once connected, your website’s email goes through DigiMail servers (api.digimail.vn) to reach recipients. By connecting you agree to the <terms>Terms of Service</terms> and <privacy>Privacy Policy</privacy>.","digimail-smtp"),{terms:(0,l.createElement)("a",{href:`${e.env.app}/dieu-khoan`,target:"_blank",rel:"noreferrer"}),privacy:(0,l.createElement)("a",{href:`${e.env.app}/chinh-sach-bao-mat`,target:"_blank",rel:"noreferrer"})}))):(0,l.createElement)("form",{onSubmit:e=>{e.preventDefault(),b(r)}},(0,l.createElement)("div",{className:"dms-step"},(0,l.createElement)("span",null,"2")," ",(0,i.__)("Enter the code","digimail-smtp")),(0,l.createElement)("h2",null,(0,i.__)("Check your inbox","digimail-smtp")),(0,l.createElement)("p",{className:"dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: email address the code was sent to. */ /* translators: %s: email address the code was sent to. */(0,i.__)("The 6-digit code was sent to <strong>%s</strong>. Not there? Check Spam or Promotions.","digimail-smtp"),n),y)),(0,l.createElement)(x,{value:r,onChange:c,onDone:b,disabled:"verify"===d}),g&&(0,l.createElement)("p",{className:"dms-error",role:"alert"},g),(0,l.createElement)(f,{type:"submit",busy:"verify"===d,disabled:r.replace(/\s/g,"").length<6,size:"lg"},(0,i.__)("Confirm and connect","digimail-smtp")),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>{s("email"),u("")}},(0,i.__)("Change email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-link",disabled:_>0||null!==d,onClick:E},_>0?(0,i.sprintf)(/* translators: %d: seconds until the code can be sent again. */ /* translators: %d: seconds until the code can be sent again. */(0,i.__)("Resend code in %d s","digimail-smtp"),_):(0,i.__)("Resend code","digimail-smtp"))))))}const T=(e,t)=>t>0?Math.round(e/t*1e3)/10:0;function D({days:e}){const[t,a]=(0,l.useState)(null),s=Math.max(4,...e.map(e=>e.sent)),n=(640-6*(e.length-1))/e.length,m=e=>e/s*152,r=null!==t?e[t]:null;return(0,l.createElement)("div",{className:"dms-chart"},(0,l.createElement)("svg",{viewBox:"0 0 640 192",role:"img","aria-label":(0,i.__)("Emails per day","digimail-smtp")},[.5,1].map(e=>(0,l.createElement)("line",{key:e,x1:0,x2:640,y1:170-m(s*e),y2:170-m(s*e),className:"dms-grid"})),e.map((t,i)=>{const s=i*(n+6),r=Math.max(0,t.sent-t.delivered-t.failed);let o=170;const d=(e,t)=>{if(e<=0)return null;const a=Math.max(2,m(e));return o-=a,(0,l.createElement)("rect",{x:s,y:o,width:n,height:Math.max(0,a-1.5),rx:3,className:t})};return(0,l.createElement)("g",{key:t.day,onMouseEnter:()=>a(i),onMouseLeave:()=>a(null)},(0,l.createElement)("rect",{x:s-3,y:0,width:n+6,height:192,fill:"transparent"}),d(t.delivered,"dms-bar-ok"),d(r,"dms-bar-transit"),d(t.failed,"dms-bar-bad"),0===t.sent&&(0,l.createElement)("rect",{x:s,y:168,width:n,height:2,rx:1,className:"dms-bar-zero"}),(i%Math.ceil(e.length/7)===0||i===e.length-1)&&(0,l.createElement)("text",{x:s+n/2,y:186,textAnchor:"middle",className:"dms-axis"},new Date(t.day).toLocaleDateString(c,{day:"2-digit",month:"2-digit"})))})),r&&(0,l.createElement)("div",{className:"dms-tip",style:{left:(t+.5)/e.length*100+"%"}},(0,l.createElement)("strong",null,new Date(r.day).toLocaleDateString(c,{weekday:"short",day:"2-digit",month:"2-digit"})),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-ok"})," ",(0,i.__)("Delivered","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.delivered))),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-transit"})," ",(0,i.__)("In transit","digimail-smtp")," ",(0,l.createElement)("b",null,d(Math.max(0,r.sent-r.delivered-r.failed)))),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-bad"})," ",(0,i.__)("Failed","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.failed))),(0,l.createElement)("span",null,(0,i.__)("Opened","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.opened)))),(0,l.createElement)("div",{className:"dms-legend"},(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-ok"})," ",(0,i.__)("Delivered","digimail-smtp")),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-transit"})," ",(0,i.__)("In transit","digimail-smtp")),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-bad"})," ",(0,i.__)("Failed or bounced","digimail-smtp"))))}function F({label:e,used:t,total:a}){const i=a>0?Math.min(100,t/a*100):0;return(0,l.createElement)("div",{className:"dms-meter"},(0,l.createElement)("div",{className:"dms-meter-head"},(0,l.createElement)("span",null,e),(0,l.createElement)("span",null,(0,l.createElement)("b",null,d(t))," / ",d(a))),(0,l.createElement)("div",{className:"dms-meter-bar"},(0,l.createElement)("span",{style:{width:`${i}%`},className:i>90?"is-bad":i>70?"is-wait":""})))}function z({state:e,go:t}){const[a,s]=(0,l.useState)(null),[n,m]=(0,l.useState)("");(0,l.useEffect)(()=>{o("stats?days=14").then(s).catch(e=>m(e.message))},[]);const r=e.status,c=r.sender,p=r.account,g=a?.days.reduce((e,t)=>e+t.sent,0)??0,_=a?.days.reduce((e,t)=>e+t.delivered,0)??0,b=a?.days.reduce((e,t)=>e+t.failed,0)??0,y=a?.days.reduce((e,t)=>e+t.opened,0)??0,k="shared"===c?.mode,N=r.site_domain,S=N&&!/^(localhost|[\d.]+|\[?[\da-f:]+\]?)$/i.test(N.domain)&&N.domain.includes(".")?N:null;return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-hero"},(0,l.createElement)("div",{className:"dms-hero-icon"},(0,l.createElement)(w,{name:"check",size:26})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("This website sends email through DigiMail","digimail-smtp")),c&&(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: sender name, 2: sender email. */ /* translators: 1: sender name, 2: sender email. */(0,i.__)("From <strong>%1$s</strong> (%2$s)","digimail-smtp"),c.name,c.email),{strong:(0,l.createElement)("strong",null)})," ",k?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Own domain","digimail-smtp")))),(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("test")},(0,l.createElement)(w,{name:"send",size:15})," ",(0,i.__)("Send test email","digimail-smtp"))),e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),!e.settings.capture.enabled&&(e.capture.forms.length>0||e.capture.woocommerce)&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Save form contacts to DigiMail","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.sprintf)(/* translators: %s: form plugins or WooCommerce found on the site. */ /* translators: %s: form plugins or WooCommerce found on the site. */ 3 3 (0,i.__)("People who fill in %s can go straight into a DigiMail contact list for your campaigns.","digimail-smtp"),[...e.capture.forms,...e.capture.woocommerce?["WooCommerce"]:[]].join(", "))),e.conflicts.length>0&&/* translators: %s: names of other active SMTP plugins. */ /* translators: %s: names of other active SMTP plugins. */ 4 4 (0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)((0,i.__)("%s is also active","digimail-smtp"),e.conflicts.map(e=>e.name).join(", ")),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("tools")},(0,i.__)("Import settings","digimail-smtp"))},(0,i.__)("Two plugins sending email will get in each other’s way. Import the old settings (the old SMTP server becomes the backup connection), then deactivate the other plugin on the Plugins page.","digimail-smtp")),(e.queue.failed>0||e.queue.queued>0)&&(0,l.createElement)(v,{tone:e.queue.failed?"bad":"info",title:e.queue.failed?(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */(0,i.__)("%s emails not sent yet","digimail-smtp"),d(e.queue.failed)):(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */(0,i.__)("%s emails waiting to send","digimail-smtp"),d(e.queue.queued)),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("logs")},(0,i.__)("View","digimail-smtp"))},e.last_failure?.error??(0,i.__)("The plugin resends them once DigiMail can be reached.","digimail-smtp")),"review"===p?.status&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Your DigiMail account is not active yet","digimail-smtp")},(0,i.sprintf)(/* translators: %s: daily email limit. */ /* translators: %s: daily email limit. */ 5 (0,i.__)("Click the confirmation link DigiMail sent to your account email to activate it. Until then, the website can send up to %s emails a day from the shared address.","digimail-smtp"),d(r.shared?.daily_limit??50))),(0,l.createElement)(E,{title:(0,i.__)("Last 14 days","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>t("logs")},(0,i.__)("Email log","digimail-smtp")," ",(0,l.createElement)(w,{name:"list",size:15}))},(0,l.createElement)("div",{className:"dms-kpis"},(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Sent","digimail-smtp")),(0,l.createElement)("strong",null,d( u))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Delivered","digimail-smtp")),(0,l.createElement)("strong",null,T(_,u),"%"),(0,l.createElement)("em",null,(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */(0,i.__)("%s emails","digimail-smtp"),d(_)))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Failed or bounced","digimail-smtp")),(0,l.createElement)("strong",{className:b>0?"is-bad":""},d(b)),(0,l.createElement)("em",null,T(b,u),"%")),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Opened","digimail-smtp")),(0,l.createElement)("strong",null,d(y)),(0,l.createElement)("em",null,T(y,u),"%"))),n&&(0,l.createElement)("p",{className:"dms-error"},n),a?(0,l.createElement)(D,{days:a.days}):!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:190}})),a&&a.sources.length>0&&(0,l.createElement)(E,{title:(0,i.__)("Email by sending plugin","digimail-smtp")},(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Emails","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Failed","digimail-smtp")))),(0,l.createElement)("tbody",null,a.sources.map(e=>(0,l.createElement)("tr",{key:e.source??"-"},(0,l.createElement)("td",null,g(e.source)||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("td",{className:"num"},d(e.sent)),(0,l.createElement)("td",{className:"num "+(e.failed?"is-bad":"dms-muted")},d(e.failed)))))))),(0,l.createElement)("div",{className:"dms-col"},k&&(0,l.createElement)(E,{className:"dms-upgrade"},(0,l.createElement)("div",{className:"dms-upgrade-icon"},(0,l.createElement)(w,{name:"globe",size:22})),(0,l.createElement)("h3",null,(0,i.__)("Send from your own domain","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared sender address, 2: reply-to address. */ /* translators: 1: shared sender address, 2: reply-to address. */(0,i.__)("Sending from <code>%1$s</code>; replies go to <strong>%2$s</strong>.","digimail-smtp"),o?.shared_email??"",o?.reply_to??e.site.admin_email),{code:(0,l.createElement)("code",null),strong:(0,l.createElement)("strong",null)})," ",S?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: example address on the domain, 3: daily limit of the shared address. */ /* translators: 1: domain, 2: example address on the domain, 3: daily limit of the shared address. */(0,i.__)("Verify <strong>%1$s</strong> to send from an address like <code>%2$s</code>: more trusted by Gmail and Outlook, and no %3$s emails/day limit of the shared address.","digimail-smtp"),S.domain,`noreply@${S.domain}`,d(r.shared?.daily_limit??0)),{code:(0,l.createElement)("code",null),strong:(0,l.createElement)("strong",null)}):(0,i.sprintf)(/* translators: %s: daily limit of the shared address. */ /* translators: %s: daily limit of the shared address. */6 (0,i.__)("Verify your domain on digimail.vn to send from your company email: more trusted, and no %s emails/day limit of the shared address.","digimail-smtp"),d(r.shared?.daily_limit??0))),"pending"===S?.status&&(0,l.createElement)("p",null,(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS records","digimail-smtp"))),S?(0,l.createElement)(f,{className:"dms-btn-block",onClick:()=>{t("settings"),setTimeout(()=>document.getElementById("dms-domain")?.scrollIntoView({behavior:"smooth",block:"start"}),400)}},"pending"===S.status?(0,i.__)("See the DNS records to add","digimail-smtp"):(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),S.domain)):(0,l.createElement)("a",{className:"dms-btn dms-btn-primary dms-btn-block",href:r.links?.domains,target:"_blank",rel:"noreferrer"},(0,i.__)("Verify your domain","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:15})),(0,l.createElement)("small",{className:"dms-muted"},(0,i.__)("Once verified, the plugin switches to your domain automatically.","digimail-smtp"))),p&&(0,l.createElement)(E,{title:(0,i.__)("Quota","digimail-smtp"),aside:p.plan?(0,l.createElement)(h,{tone:"info"},p.plan):(0,l.createElement)(h,null,(0,i.__)("Free","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-meters"},(0,l.createElement)(F,{label:(0,i.__)("Today","digimail-smtp"),used:p.sent_today,total:p.daily_limit}),(0,l.createElement)(F,{label:(0,i.__)("This month","digimail-smtp"),used:p.sent_month,total:p.monthly_limit}),k&&r.shared&&(0,l.createElement)(F,{label:(0,i.__)("Shared address, today","digimail-smtp"),used:r.shared.sent_today,total:r.shared.daily_limit})),(0,l.createElement)("a",{className:"dms-link",href:r.links?.billing,target:"_blank",rel:"noreferrer"},(0,i.__)("Upgrade plan","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)(E,{title:(0,i.__)("DigiMail account","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,p?.name),(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,r.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Background sending","digimail-smtp")),(0,l.createElement)("dd",null,e.settings.queue?(0,i.__)("On","digimail-smtp"):(0,i.__)("Off","digimail-smtp")),(0,l.createElement)("dt",null,(0,i.__)("Backup","digimail-smtp")),(0,l.createElement)("dd",null,e.settings.backup.enabled?e.settings.backup.host:(0,i.__)("Off","digimail-smtp"))),(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-block",href:r.links?.dashboard,target:"_blank",rel:"noreferrer"},(0,i.__)("Manage on digimail.vn","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:15})))))}const P=[{key:"",label:(0,i.__)("All","digimail-smtp")},{key:"delivered",label:(0,i.__)("Delivered","digimail-smtp")},{key:"sent",label:(0,i.__)("In transit","digimail-smtp")},{key:"failed",label:(0,i.__)("Failed","digimail-smtp")},{key:"opened",label:(0,i.__)("Opened","digimail-smtp")}],$={send:(0,i.__)("DigiMail sent it","digimail-smtp"),delivery:(0,i.__)("The receiving server accepted it","digimail-smtp"),bounce_permanent:(0,i.__)("Bounced permanently","digimail-smtp"),bounce_transient:(0,i.__)("Bounced temporarily","digimail-smtp"),complaint:(0,i.__)("The recipient marked it as spam","digimail-smtp"),reject:(0,i.__)("Rejected","digimail-smtp"),open:(0,i.__)("The recipient opened it","digimail-smtp"),click:(0,i.__)("The recipient clicked a link","digimail-smtp"),deliverydelay:(0,i.__)("Delivery delayed, retrying","digimail-smtp")};function O({d:e,onSent:t}){const a=C(),[s,n]=(0,l.useState)(!1),[m,r]=(0,l.useState)(""),[ o,d]=(0,l.useState)(!1);return e.resendable?(0,l.createElement)("form",{className:"dms-resend",onSubmit:l=>{l.preventDefault(),(async()=>{d(!0);try{const l=await c(`logs/${e.id}/resend`,s?{to:m}:{});a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("Sent again to %s.","digimail-smtp"),l.to),"ok"),n(!1),r(""),t()}catch(e){a(e.message,"bad")}finally{d(!1)}})()}},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:s?"":"is-on",onClick:()=>n(!1)},(0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("To %s","digimail-smtp"),e.to)),(0,l.createElement)("button",{type:"button",className:s?"is-on":"",onClick:()=>n(!0)},(0,i.__)("To another address","digimail-smtp"))),s&&(0,l.createElement)("input",{type:"email",required:!0,placeholder:"email@example.com","aria-label":(0,i.__)("Send to","digimail-smtp"),value:m,onChange:e=>r(e.target.value)}),(0,l.createElement)(f,{type:"submit",size:"sm",busy:o},(0,l.createElement)(w,{name:"refresh",size:14})," ",(0,i.__)("Send again","digimail-smtp"))):null}function A({id:e,onClose:t}){const[a,s]=(0,l.useState)(null),[n,m]=(0,l.useState)(""),[r,d]=(0,l.useState)("html");(0,l.useEffect)(()=>{s(null),m(""),e&&c(`logs/${e}`).then(s).catch(e=>m(e.message))},[e]);const _=a?u[a.status]??{label:a.status,tone:"muted"}:null;return(0,l.createElement)(N,{open:!!e,onClose:t,title:a?.subject??(0,i.__)("Email details","digimail-smtp")},n&&(0,l.createElement)("p",{className:"dms-error"},n),!a&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:300}}),a&&_&&(0,l.createElement)("div",{className:"dms-detail"},(0,l.createElement)("div",{className:"dms-detail-head"},(0,l.createElement)(h,{tone:_.tone},_.label),a.opened_at&&(0,l.createElement)(h,{tone:"info"},(0,i.__)("Opened","digimail-smtp")),a.clicked_at&&(0,l.createElement)(h,{tone:"info"},(0,i.__)("Clicked","digimail-smtp"))),(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("To","digimail-smtp")),(0,l.createElement)("dd",null,a.to),(0,l.createElement)("dt",null,(0,i.__)("From","digimail-smtp")),(0,l.createElement)("dd",null,a.from),a.reply_to&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("dt",null,(0,i.__)("Reply to","digimail-smtp")),(0,l.createElement)("dd",null,a.reply_to)),a.source&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("dt",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("dd",null,g(a.source))),(0,l.createElement)("dt",null,(0,i.__)("Created","digimail-smtp")),(0,l.createElement)("dd",null,new Date(a.created_at).toLocaleString(o))),a.error&&(0,l.createElement)("div",{className:"dms-errbox"},(0,l.createElement)("strong",null,(0,i.__)("Reason","digimail-smtp")),(0,l.createElement)("code",null,a.error)),a.resend_of&&(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("This is a copy sent again from the log.","digimail-smtp")),(0,l.createElement)(O,{d:a,onSent:()=>{}}),(0,l.createElement)("h3",null,(0,i.__)("Timeline","digimail-smtp")),(0,l.createElement)("ol",{className:"dms-timeline"},(0,l.createElement)("li",{className:"is-ok"},(0,l.createElement)("span",null,(0,i.__)("The website handed it to DigiMail","digimail-smtp")),(0,l.createElement)("time",null,p(a.created_at))),a.events.map((e,t)=>(0,l.createElement)("li",{key:t,className:/bounce|complaint|reject/.test(e.kind)?"is-bad":"is-ok"},(0,l.createElement)("span",null,$[e.kind]??e.kind),(0,l.createElement)("time",null,p(e.at)),e.detail&&(0,l.createElement)("code",null,e.detail))),!a.events.some(e=>"delivery"===e.kind||e.kind.startsWith("bounce"))&&!["bounced","failed","rejected","suppressed"].includes(a.status)&&(0,l.createElement)("li",{className:"is-wait"},(0,l.createElement)("span",null,(0,i.__)("Waiting for the receiving server to confirm","digimail-smtp")))),a.attachments.length>0&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("h3",null,(0,i.__)("Attachments","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-files"},a.attachments.map((e,t)=>(0,l.createElement)("li",{key:t},(0,l.createElement)(w,{name:"paperclip",size:14})," ",e.name," ",(0,l.createElement)("span",{className:"dms-muted"},Math.max(1,Math.round(e.size/1024))," KB"))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("h3",null,(0,i.__)("Content","digimail-smtp")),a.html&&a.text&&(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===r?"is-on":"",onClick:()=>d("html")},(0,i.__)("Rendered","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"text"===r?"is-on":"",onClick:()=>d("text")},(0,i.__)("Plain text","digimail-smtp")))),a.html&&"html"===r?(0,l.createElement)("iframe",{className:"dms-preview",title:(0,i.__)("Email content","digimail-smtp"),sandbox:"",srcDoc:a.html}):(0,l.createElement)("pre",{className:"dms-pre"},a.text??(a.html?(0,i.__)("(no plain-text version)","digimail-smtp"):(0,i.__)("(content no longer stored)","digimail-smtp")))))}function I({onChange:e}){const[t,a]=(0,l.useState)([]),[s,n]=(0,l.useState)(null),m=C(),r=(0,l.useCallback)(()=>c("queue").then(e=>a(e.items)),[]);(0,l.useEffect)(()=>{r().catch(()=>{})},[r]);const o=async(t,l,s={})=>{n(t);try{const t=await c(l,s);a(t.items),void 0!==t.sent&&m(t.failed?(0,i.sprintf)(/* translators: 1: emails sent, 2: emails still failing. */ /* translators: 1: emails sent, 2: emails still failing. */(0,i.__)("Sent %1$d, %2$d still failing.","digimail-smtp"),t.sent,t.failed):(0,i.sprintf)(/* translators: %d: number of emails sent. */ /* translators: %d: number of emails sent. */(0,i._n)("Sent %d email.","Sent %d emails.",t.sent,"digimail-smtp"),t.sent),t.failed?"bad":"ok"),e()}catch(e){m(e.message,"bad")}finally{n(null)}},_=t.filter(e=>"backup"!==e.status&&"blocked"!==e.status);return 0===t.length?null:(0,l.createElement)(E,{title:(0,l.createElement)(l.Fragment,null,(0,i.__)("Not yet at DigiMail","digimail-smtp")," ",(0,l.createElement)(h,{tone:_.some(e=>"failed"===e.status)?"bad":"muted"},d(t.length))),aside:(0,l.createElement)("div",{className:"dms-actions"},_.length>0&&(0,l.createElement)(f,{size:"sm",busy:"all"===s,onClick:()=>o("all","queue/retry")},(0,l.createElement)(w,{name:"refresh",size:14})," ",(0,i.__)("Resend all","digimail-smtp")),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:"clear"===s,onClick:()=>o("clear","queue/delete")},(0,i.__)("Clear handled items","digimail-smtp")))},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Emails that failed before reaching DigiMail (network down, quota used up…), went out through the backup server, or were not sent because DigiMail found the recipient suspicious (most likely typed into a form by a bot). The plugin keeps them for 30 days.","digimail-smtp")),(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Recipient","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Subject","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Reason","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,t.map(e=>{const t=u[e.status];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:t.tone},"queued"===e.status?e.attempts?(0,i.sprintf)(/* translators: %d: attempt number. */ /* translators: %d: attempt number. */(0,i.__)("Retrying (attempt %d)","digimail-smtp"),e.attempts+1):(0,i.__)("Waiting to retry","digimail-smtp"):t.label),(0,l.createElement)("div",{className:"dms-muted dms-small"},p(e.created_at))),(0,l.createElement)("td",{className:"dms-ellipsis"},e.recipients),(0,l.createElement)("td",{className:"dms-ellipsis"},e.subject,(0,l.createElement)("div",{className:"dms-muted dms-small"},g(e.source))),(0,l.createElement)("td",{className:"dms-small"},e.error),(0,l.createElement)("td",{className:"dms-actions"},"backup"!==e.status&&"blocked"!==e.status&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:s===`r${e.id}`,onClick:()=>o(`r${e.id}`,"queue/retry",{id:e.id})},(0,i.__)("Resend","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Delete","digimail-smtp"),onClick:()=>o(`d${e.id}`,"queue/delete",{id:e.id})},(0,l.createElement)(w,{name:"x",size:15}))))}))))}function L({reload:e}){const[t,a]=(0,l.useState)(""),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(1),[_,b]=(0,l.useState)(null),[y,v]=(0,l.useState)(""),[N,S]=(0,l.useState)(null),C=(0,l.useCallback)(()=>{const e=new URLSearchParams({page:String(m)});return t&&e.set("status",t),s.trim()&&e.set("q",s.trim()),c(`logs?${e}`).then(e=>{b(e),v("")}).catch(e=>v(e.message))},[m,t,s]);(0,l.useEffect)(()=>{const e=setTimeout(C,s?300:0);return()=>clearTimeout(e)},[C,s]),(0,l.useEffect)(()=>{const e=setInterval(()=>{N||"visible"!==document.visibilityState||C()},15e3);return()=>clearInterval(e)},[C,N]);const x=_?Math.max(1,Math.ceil(_.total/_.per_page)):1;return(0,l.createElement)("div",{className:"dms-stack"},(0,l.createElement)(I,{onChange:e}),(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-seg",role:"group","aria-label":(0,i.__)("Filter by status","digimail-smtp")},P.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:t===e.key?"is-on":"",onClick:()=>{a(e.key),r(1)}},e.label))),(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:s,onChange:e=>{n(e.target.value),r(1)},placeholder:(0,i.__)("Search recipient or subject","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>C(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))),y&&(0,l.createElement)("p",{className:"dms-error"},y),!_&&!y&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),_&&0===_.items.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"mail",size:26}),title:s||t?(0,i.__)("No matching emails","digimail-smtp"):(0,i.__)("No emails yet","digimail-smtp")},s||t?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("Email your website sends through DigiMail shows up here, with its real delivery status.","digimail-smtp")),_&&_.items.length>0&&(0,l.createElement)("table",{className:"dms-table dms-table-click"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Recipient","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Subject","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,_.items.map(e=>{const t=u[e.status]??{label:e.status,tone:"muted"};return(0,l.createElement)("tr",{key:e.id,tabIndex:0,onClick:()=>S(e.id),onKeyDown:t=>"Enter"===t.key&&S(e.id)},(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:t.tone},t.label),e.opened_at&&(0,l.createElement)("span",{className:"dms-opened",title:(0,i.sprintf)(/* translators: %s: date and time. */ /* translators: %s: date and time. */7 (0,i.__)("Opened %s","digimail-smtp"),new Date(e.opened_at).toLocaleString( o))},(0,l.createElement)(w,{name:"eye",size:14}))),(0,l.createElement)("td",{className:"dms-ellipsis"},e.to),(0,l.createElement)("td",{className:"dms-ellipsis"},e.subject,e.error&&(0,l.createElement)("div",{className:"dms-small is-bad dms-ellipsis"},e.error)),(0,l.createElement)("td",{className:"dms-small dms-muted"},g(e.source)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.created_at).toLocaleString(o)},p(e.created_at)))}))),_&&x>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */5 (0,i.__)("Click the confirmation link DigiMail sent to your account email to activate it. Until then, the website can send up to %s emails a day from the shared address.","digimail-smtp"),d(r.shared?.daily_limit??50))),(0,l.createElement)(E,{title:(0,i.__)("Last 14 days","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>t("logs")},(0,i.__)("Email log","digimail-smtp")," ",(0,l.createElement)(w,{name:"list",size:15}))},(0,l.createElement)("div",{className:"dms-kpis"},(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Sent","digimail-smtp")),(0,l.createElement)("strong",null,d(g))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Delivered","digimail-smtp")),(0,l.createElement)("strong",null,T(_,g),"%"),(0,l.createElement)("em",null,(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */(0,i.__)("%s emails","digimail-smtp"),d(_)))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Failed or bounced","digimail-smtp")),(0,l.createElement)("strong",{className:b>0?"is-bad":""},d(b)),(0,l.createElement)("em",null,T(b,g),"%")),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Opened","digimail-smtp")),(0,l.createElement)("strong",null,d(y)),(0,l.createElement)("em",null,T(y,g),"%"))),n&&(0,l.createElement)("p",{className:"dms-error"},n),a?(0,l.createElement)(D,{days:a.days}):!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:190}})),a&&a.sources.length>0&&(0,l.createElement)(E,{title:(0,i.__)("Email by sending plugin","digimail-smtp")},(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Emails","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Failed","digimail-smtp")))),(0,l.createElement)("tbody",null,a.sources.map(e=>(0,l.createElement)("tr",{key:e.source??"-"},(0,l.createElement)("td",null,u(e.source)||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("td",{className:"num"},d(e.sent)),(0,l.createElement)("td",{className:"num "+(e.failed?"is-bad":"dms-muted")},d(e.failed)))))))),(0,l.createElement)("div",{className:"dms-col"},k&&(0,l.createElement)(E,{className:"dms-upgrade"},(0,l.createElement)("div",{className:"dms-upgrade-icon"},(0,l.createElement)(w,{name:"globe",size:22})),(0,l.createElement)("h3",null,(0,i.__)("Send from your own domain","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared sender address, 2: reply-to address. */ /* translators: 1: shared sender address, 2: reply-to address. */(0,i.__)("Sending from <code>%1$s</code>; replies go to <strong>%2$s</strong>.","digimail-smtp"),c?.shared_email??"",c?.reply_to??e.site.admin_email),{code:(0,l.createElement)("code",null),strong:(0,l.createElement)("strong",null)})," ",S?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: example address on the domain, 3: daily limit of the shared address. */ /* translators: 1: domain, 2: example address on the domain, 3: daily limit of the shared address. */(0,i.__)("Verify <strong>%1$s</strong> to send from an address like <code>%2$s</code>: more trusted by Gmail and Outlook, and no %3$s emails/day limit of the shared address.","digimail-smtp"),S.domain,`noreply@${S.domain}`,d(r.shared?.daily_limit??0)),{code:(0,l.createElement)("code",null),strong:(0,l.createElement)("strong",null)}):(0,i.sprintf)(/* translators: %s: daily limit of the shared address. */ /* translators: %s: daily limit of the shared address. */ 6 (0,i.__)("Verify your domain on digimail.vn to send from your company email: more trusted, and no %s emails/day limit of the shared address.","digimail-smtp"),d(r.shared?.daily_limit??0))),"pending"===S?.status&&(0,l.createElement)("p",null,(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS records","digimail-smtp"))),S?(0,l.createElement)(f,{className:"dms-btn-block",onClick:()=>{t("settings"),setTimeout(()=>document.getElementById("dms-domain")?.scrollIntoView({behavior:"smooth",block:"start"}),400)}},"pending"===S.status?(0,i.__)("See the DNS records to add","digimail-smtp"):(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),S.domain)):(0,l.createElement)("a",{className:"dms-btn dms-btn-primary dms-btn-block",href:r.links?.domains,target:"_blank",rel:"noreferrer"},(0,i.__)("Verify your domain","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:15})),(0,l.createElement)("small",{className:"dms-muted"},(0,i.__)("Once verified, the plugin switches to your domain automatically.","digimail-smtp"))),p&&(0,l.createElement)(E,{title:(0,i.__)("Quota","digimail-smtp"),aside:p.plan?(0,l.createElement)(h,{tone:"info"},p.plan):(0,l.createElement)(h,null,(0,i.__)("Free","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-meters"},(0,l.createElement)(F,{label:(0,i.__)("Today","digimail-smtp"),used:p.sent_today,total:p.daily_limit}),(0,l.createElement)(F,{label:(0,i.__)("This month","digimail-smtp"),used:p.sent_month,total:p.monthly_limit}),k&&r.shared&&(0,l.createElement)(F,{label:(0,i.__)("Shared address, today","digimail-smtp"),used:r.shared.sent_today,total:r.shared.daily_limit})),(0,l.createElement)("a",{className:"dms-link",href:r.links?.billing,target:"_blank",rel:"noreferrer"},(0,i.__)("Upgrade plan","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)(E,{title:(0,i.__)("DigiMail account","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,p?.name),(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,r.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Background sending","digimail-smtp")),(0,l.createElement)("dd",null,e.settings.queue?(0,i.__)("On","digimail-smtp"):(0,i.__)("Off","digimail-smtp")),(0,l.createElement)("dt",null,(0,i.__)("Backup","digimail-smtp")),(0,l.createElement)("dd",null,e.settings.backup.enabled?e.settings.backup.host:(0,i.__)("Off","digimail-smtp"))),(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-block",href:r.links?.dashboard,target:"_blank",rel:"noreferrer"},(0,i.__)("Manage on digimail.vn","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:15})))))}const P=[{key:"",label:(0,i.__)("All","digimail-smtp")},{key:"delivered",label:(0,i.__)("Delivered","digimail-smtp")},{key:"sent",label:(0,i.__)("In transit","digimail-smtp")},{key:"failed",label:(0,i.__)("Failed","digimail-smtp")},{key:"opened",label:(0,i.__)("Opened","digimail-smtp")}],$={send:(0,i.__)("DigiMail sent it","digimail-smtp"),delivery:(0,i.__)("The receiving server accepted it","digimail-smtp"),bounce_permanent:(0,i.__)("Bounced permanently","digimail-smtp"),bounce_transient:(0,i.__)("Bounced temporarily","digimail-smtp"),complaint:(0,i.__)("The recipient marked it as spam","digimail-smtp"),reject:(0,i.__)("Rejected","digimail-smtp"),open:(0,i.__)("The recipient opened it","digimail-smtp"),click:(0,i.__)("The recipient clicked a link","digimail-smtp"),deliverydelay:(0,i.__)("Delivery delayed, retrying","digimail-smtp")};function O({d:e,onSent:t}){const a=C(),[s,n]=(0,l.useState)(!1),[m,r]=(0,l.useState)(""),[c,d]=(0,l.useState)(!1);return e.resendable?(0,l.createElement)("form",{className:"dms-resend",onSubmit:l=>{l.preventDefault(),(async()=>{d(!0);try{const l=await o(`logs/${e.id}/resend`,s?{to:m}:{});a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("Sent again to %s.","digimail-smtp"),l.to),"ok"),n(!1),r(""),t()}catch(e){a(e.message,"bad")}finally{d(!1)}})()}},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:s?"":"is-on",onClick:()=>n(!1)},(0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("To %s","digimail-smtp"),e.to)),(0,l.createElement)("button",{type:"button",className:s?"is-on":"",onClick:()=>n(!0)},(0,i.__)("To another address","digimail-smtp"))),s&&(0,l.createElement)("input",{type:"email",required:!0,placeholder:"email@example.com","aria-label":(0,i.__)("Send to","digimail-smtp"),value:m,onChange:e=>r(e.target.value)}),(0,l.createElement)(f,{type:"submit",size:"sm",busy:c},(0,l.createElement)(w,{name:"refresh",size:14})," ",(0,i.__)("Send again","digimail-smtp"))):null}function A({id:e,onClose:t}){const[a,s]=(0,l.useState)(null),[n,m]=(0,l.useState)(""),[r,d]=(0,l.useState)("html");(0,l.useEffect)(()=>{s(null),m(""),e&&o(`logs/${e}`).then(s).catch(e=>m(e.message))},[e]);const _=a?g[a.status]??{label:a.status,tone:"muted"}:null;return(0,l.createElement)(N,{open:!!e,onClose:t,title:a?.subject??(0,i.__)("Email details","digimail-smtp")},n&&(0,l.createElement)("p",{className:"dms-error"},n),!a&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:300}}),a&&_&&(0,l.createElement)("div",{className:"dms-detail"},(0,l.createElement)("div",{className:"dms-detail-head"},(0,l.createElement)(h,{tone:_.tone},_.label),a.opened_at&&(0,l.createElement)(h,{tone:"info"},(0,i.__)("Opened","digimail-smtp")),a.clicked_at&&(0,l.createElement)(h,{tone:"info"},(0,i.__)("Clicked","digimail-smtp"))),(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("To","digimail-smtp")),(0,l.createElement)("dd",null,a.to),(0,l.createElement)("dt",null,(0,i.__)("From","digimail-smtp")),(0,l.createElement)("dd",null,a.from),a.reply_to&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("dt",null,(0,i.__)("Reply to","digimail-smtp")),(0,l.createElement)("dd",null,a.reply_to)),a.source&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("dt",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("dd",null,u(a.source))),(0,l.createElement)("dt",null,(0,i.__)("Created","digimail-smtp")),(0,l.createElement)("dd",null,new Date(a.created_at).toLocaleString(c))),a.error&&(0,l.createElement)("div",{className:"dms-errbox"},(0,l.createElement)("strong",null,(0,i.__)("Reason","digimail-smtp")),(0,l.createElement)("code",null,a.error)),a.resend_of&&(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("This is a copy sent again from the log.","digimail-smtp")),(0,l.createElement)(O,{d:a,onSent:()=>{}}),(0,l.createElement)("h3",null,(0,i.__)("Timeline","digimail-smtp")),(0,l.createElement)("ol",{className:"dms-timeline"},(0,l.createElement)("li",{className:"is-ok"},(0,l.createElement)("span",null,(0,i.__)("The website handed it to DigiMail","digimail-smtp")),(0,l.createElement)("time",null,p(a.created_at))),a.events.map((e,t)=>(0,l.createElement)("li",{key:t,className:/bounce|complaint|reject/.test(e.kind)?"is-bad":"is-ok"},(0,l.createElement)("span",null,$[e.kind]??e.kind),(0,l.createElement)("time",null,p(e.at)),e.detail&&(0,l.createElement)("code",null,e.detail))),!a.events.some(e=>"delivery"===e.kind||e.kind.startsWith("bounce"))&&!["bounced","failed","rejected","suppressed"].includes(a.status)&&(0,l.createElement)("li",{className:"is-wait"},(0,l.createElement)("span",null,(0,i.__)("Waiting for the receiving server to confirm","digimail-smtp")))),a.attachments.length>0&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("h3",null,(0,i.__)("Attachments","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-files"},a.attachments.map((e,t)=>(0,l.createElement)("li",{key:t},(0,l.createElement)(w,{name:"paperclip",size:14})," ",e.name," ",(0,l.createElement)("span",{className:"dms-muted"},Math.max(1,Math.round(e.size/1024))," KB"))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("h3",null,(0,i.__)("Content","digimail-smtp")),a.html&&a.text&&(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===r?"is-on":"",onClick:()=>d("html")},(0,i.__)("Rendered","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"text"===r?"is-on":"",onClick:()=>d("text")},(0,i.__)("Plain text","digimail-smtp")))),a.html&&"html"===r?(0,l.createElement)("iframe",{className:"dms-preview",title:(0,i.__)("Email content","digimail-smtp"),sandbox:"",srcDoc:a.html}):(0,l.createElement)("pre",{className:"dms-pre"},a.text??(a.html?(0,i.__)("(no plain-text version)","digimail-smtp"):(0,i.__)("(content no longer stored)","digimail-smtp")))))}function W({onChange:e}){const[t,a]=(0,l.useState)([]),[s,n]=(0,l.useState)(null),m=C(),r=(0,l.useCallback)(()=>o("queue").then(e=>a(e.items)),[]);(0,l.useEffect)(()=>{r().catch(()=>{})},[r]);const c=async(t,l,s={})=>{n(t);try{const t=await o(l,s);a(t.items),void 0!==t.sent&&m(t.failed?(0,i.sprintf)(/* translators: 1: emails sent, 2: emails still failing. */ /* translators: 1: emails sent, 2: emails still failing. */(0,i.__)("Sent %1$d, %2$d still failing.","digimail-smtp"),t.sent,t.failed):(0,i.sprintf)(/* translators: %d: number of emails sent. */ /* translators: %d: number of emails sent. */(0,i._n)("Sent %d email.","Sent %d emails.",t.sent,"digimail-smtp"),t.sent),t.failed?"bad":"ok"),e()}catch(e){m(e.message,"bad")}finally{n(null)}},_=t.filter(e=>"backup"!==e.status&&"blocked"!==e.status);return 0===t.length?null:(0,l.createElement)(E,{title:(0,l.createElement)(l.Fragment,null,(0,i.__)("Not yet at DigiMail","digimail-smtp")," ",(0,l.createElement)(h,{tone:_.some(e=>"failed"===e.status)?"bad":"muted"},d(t.length))),aside:(0,l.createElement)("div",{className:"dms-actions"},_.length>0&&(0,l.createElement)(f,{size:"sm",busy:"all"===s,onClick:()=>c("all","queue/retry")},(0,l.createElement)(w,{name:"refresh",size:14})," ",(0,i.__)("Resend all","digimail-smtp")),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:"clear"===s,onClick:()=>c("clear","queue/delete")},(0,i.__)("Clear handled items","digimail-smtp")))},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Emails that failed before reaching DigiMail (network down, quota used up…), went out through the backup server, or were not sent because DigiMail found the recipient suspicious (most likely typed into a form by a bot). The plugin keeps them for 30 days.","digimail-smtp")),(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Recipient","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Subject","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Reason","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,t.map(e=>{const t=g[e.status];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:t.tone},"queued"===e.status?e.attempts?(0,i.sprintf)(/* translators: %d: attempt number. */ /* translators: %d: attempt number. */(0,i.__)("Retrying (attempt %d)","digimail-smtp"),e.attempts+1):(0,i.__)("Waiting to retry","digimail-smtp"):t.label),(0,l.createElement)("div",{className:"dms-muted dms-small"},p(e.created_at))),(0,l.createElement)("td",{className:"dms-ellipsis"},e.recipients),(0,l.createElement)("td",{className:"dms-ellipsis"},e.subject,(0,l.createElement)("div",{className:"dms-muted dms-small"},u(e.source))),(0,l.createElement)("td",{className:"dms-small"},e.error),(0,l.createElement)("td",{className:"dms-actions"},"backup"!==e.status&&"blocked"!==e.status&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:s===`r${e.id}`,onClick:()=>c(`r${e.id}`,"queue/retry",{id:e.id})},(0,i.__)("Resend","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Delete","digimail-smtp"),onClick:()=>c(`d${e.id}`,"queue/delete",{id:e.id})},(0,l.createElement)(w,{name:"x",size:15}))))}))))}function I({reload:e}){const[t,a]=(0,l.useState)(""),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(1),[_,b]=(0,l.useState)(null),[y,v]=(0,l.useState)(""),[N,S]=(0,l.useState)(null),C=(0,l.useCallback)(()=>{const e=new URLSearchParams({page:String(m)});return t&&e.set("status",t),s.trim()&&e.set("q",s.trim()),o(`logs?${e}`).then(e=>{b(e),v("")}).catch(e=>v(e.message))},[m,t,s]);(0,l.useEffect)(()=>{const e=setTimeout(C,s?300:0);return()=>clearTimeout(e)},[C,s]),(0,l.useEffect)(()=>{const e=setInterval(()=>{N||"visible"!==document.visibilityState||C()},15e3);return()=>clearInterval(e)},[C,N]);const x=_?Math.max(1,Math.ceil(_.total/_.per_page)):1;return(0,l.createElement)("div",{className:"dms-stack"},(0,l.createElement)(W,{onChange:e}),(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-seg",role:"group","aria-label":(0,i.__)("Filter by status","digimail-smtp")},P.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:t===e.key?"is-on":"",onClick:()=>{a(e.key),r(1)}},e.label))),(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:s,onChange:e=>{n(e.target.value),r(1)},placeholder:(0,i.__)("Search recipient or subject","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>C(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))),y&&(0,l.createElement)("p",{className:"dms-error"},y),!_&&!y&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),_&&0===_.items.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"mail",size:26}),title:s||t?(0,i.__)("No matching emails","digimail-smtp"):(0,i.__)("No emails yet","digimail-smtp")},s||t?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("Email your website sends through DigiMail shows up here, with its real delivery status.","digimail-smtp")),_&&_.items.length>0&&(0,l.createElement)("table",{className:"dms-table dms-table-click"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Recipient","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Subject","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,_.items.map(e=>{const t=g[e.status]??{label:e.status,tone:"muted"};return(0,l.createElement)("tr",{key:e.id,tabIndex:0,onClick:()=>S(e.id),onKeyDown:t=>"Enter"===t.key&&S(e.id)},(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:t.tone},t.label),e.opened_at&&(0,l.createElement)("span",{className:"dms-opened",title:(0,i.sprintf)(/* translators: %s: date and time. */ /* translators: %s: date and time. */ 7 (0,i.__)("Opened %s","digimail-smtp"),new Date(e.opened_at).toLocaleString(c))},(0,l.createElement)(w,{name:"eye",size:14}))),(0,l.createElement)("td",{className:"dms-ellipsis"},e.to),(0,l.createElement)("td",{className:"dms-ellipsis"},e.subject,e.error&&(0,l.createElement)("div",{className:"dms-small is-bad dms-ellipsis"},e.error)),(0,l.createElement)("td",{className:"dms-small dms-muted"},u(e.source)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.created_at).toLocaleString(c)},p(e.created_at)))}))),_&&x>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */ 8 8 (0,i._n)("%s email","%s emails",_.total,"digimail-smtp"),d(_.total))),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:m<=1,onClick:()=>r(m-1)},(0,i.__)("Previous","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: current page, 2: number of pages. */ /* translators: 1: current page, 2: number of pages. */ 9 (0,i.__)("Page %1$d of %2$d","digimail-smtp"),m,x)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:m>=x,onClick:()=>r(m+1)},(0,i.__)("Next","digimail-smtp")))),(0,l.createElement)(A,{id:N,onClose:()=>S(null)}))}function W({state:e,s:t,setS:a}){const s=t.guard,n=e.guard,m=e=>a({...t,guard:{...s,...e}});return(0,l.createElement)(E,{title:(0,i.__)("Block form spam","digimail-smtp"),aside:s.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.enabled,onChange:e=>m({enabled:e}),label:(0,i.__)("Stop bots before the form sends any email","digimail-smtp"),hint:(0,i.__)("Invisible to visitors: no puzzle, nothing to click. Bot submissions are refused, so no notification or auto-reply goes out and nothing reaches your contact list. Works with Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks and WooCommerce checkout.","digimail-smtp")}),s.enabled&&(0,l.createElement)(b,{checked:s.akismet&&n.akismet,disabled:!n.akismet,onChange:e=>m({akismet:e}),label:(0,i.__)("Also ask Akismet","digimail-smtp"),hint:n.akismet?(0,i.__)("Off by default. When on, only submissions that already look doubtful are sent to Akismet (name, email, message, IP address and browser) for a second opinion.","digimail-smtp"):(0,i.__)("Akismet is not set up on this site.","digimail-smtp")}),!s.enabled&&(0,l.createElement)("p",{className:"dms-small dms-error"},(0,i.__)("Without it, bots can use your forms to send email to addresses they type in. Bounces and spam reports from those emails can get sending paused.","digimail-smtp")),s.enabled&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */10 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. See them in the Customers tab.","digimail-smtp"),d(n.blocked),d(n.checked)))))}function j({summary:e}){const t=C(),[a,s]=(0,l.useState)(null),[n,r]=(0,l.useState)(""),[ o,u]=(0,l.useState)(""),[_,h]=(0,l.useState)(""),b=(0,l.useCallback)(()=>c("guard/log").then(e=>s(e.items)).catch(e=>r(e.message)),[]);(0,l.useEffect)(()=>{b()},[b]);const y=Object.entries(e.reasons).slice(0,4);return(0,l.createElement)(E,{title:(0,i.__)("Spam blocked","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:b,"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */11 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. No email was sent for them and they were not saved as contacts.","digimail-smtp"),d(e.blocked),d(e.checked)),y.length>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("Most common reasons:","digimail-smtp")," ",y.map(([e,t])=>`${m[e]??e} (${d(t)})`).join("; "),".")),n&&(0,l.createElement)("p",{className:"dms-error"},n),!a&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:240}}),a&&0===a.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"shield",size:26}),title:(0,i.__)("Nothing blocked yet","digimail-smtp")},(0,i.__)("Bot submissions show up here. If a real customer says the form did not work, find them here and click “Not spam”.","digimail-smtp")),a&&a.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Sender","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Why","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,a.map(e=>(0,l.createElement)(l.Fragment,{key:e.id},(0,l.createElement)("tr",null,(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email||"—"),e.name&&e.email&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.email),e.phone&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.phone)),(0,l.createElement)("td",{className:"dms-small"},[ g(e.source),e.form].filter(Boolean).join(" · "),(0,l.createElement)("div",{className:"dms-muted"},e.ip)),(0,l.createElement)("td",{className:"dms-small"},(0,l.createElement)("ul",{className:"dms-reasons"},e.reasons.map(e=>(0,l.createElement)("li",{key:e},m[e]??e))),e.text&&(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>h(_===e.id?"":e.id)},_===e.id?(0,i.__)("Hide message","digimail-smtp"):(0,i.__)("Show message","digimail-smtp"))),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(1e3*e.at).toLocaleString()},p(new Date(1e3*e.at).toISOString())),(0,l.createElement)("td",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:o===e.id,onClick:()=>(async e=>{u(e);try{await c("guard/restore",{id:e}),s(t=>(t??[]).filter(t=>t.id!==e)),t((0,i.__)("Marked as not spam. This address will not be blocked again.","digimail-smtp"))}catch(e){t(e.message,"bad")}finally{u("")}})(e.id)},(0,i.__)("Not spam","digimail-smtp")))),_===e.id&&(0,l.createElement)("tr",{className:"dms-subrow"},(0,l.createElement)("td",{colSpan:5},(0,l.createElement)("pre",{className:"dms-message"},e.text))))))),a&&a.length>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of entries kept. */ /* translators: %s: number of entries kept. */12 (0,i._n)("The latest %s blocked submission is kept on this website.","The latest %s blocked submissions are kept on this website.",a.length,"digimail-smtp"),d(a.length))))}const R={added:{label:(0,i.__)("New","digimail-smtp"),tone:"ok",hint:(0,i.__)("Added to the contact list.","digimail-smtp")},existing:{label:(0,i.__)("Already in list","digimail-smtp"),tone:"info",hint:(0,i.__)("This address was already in the list.","digimail-smtp")},blocked:{label:(0,i.__)("Blocked","digimail-smtp"),tone:"wait",hint:(0,i.__)("Unsubscribed, bounced or reported spam before, so it is not added back.","digimail-smtp")},invalid:{label:(0,i.__)("Invalid email","digimail-smtp"),tone:"bad",hint:(0,i.__)("The address cannot receive email.","digimail-smtp")},pending:{label:(0,i.__)("Awaiting confirmation","digimail-smtp"),tone:"wait",hint:(0,i.__)("A confirmation email was sent. They join the list after clicking it.","digimail-smtp")}}, q=e=>[g(e.source??"")||e.source,e.form].filter(Boolean).join(" · ")||(0,i.__)("Other","digimail-smtp");function B({state:e,go:t}){const a=C(),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[u,_]=(0,l.useState)(1),[b,y]=(0,l.useState)(null),[N,S]=(0,l.useState)(""),[x,M]=(0,l.useState)(!1),[T,D]=(0,l.useState)(!1),F=(0,l.useCallback)(e=>{const t=new URLSearchParams;return e&&t.set("page",String(u)),s&&t.set("form",s),m.trim()&&t.set("q",m.trim()),t.toString()},[u,s,m]),z=(0,l.useCallback)(()=>c(`entries?${F(!0)}`).then(e=>{y(e),S("")}).catch(e=>S(e.message)),[F]);(0,l.useEffect)(()=>{const e=setTimeout(z,m?300:0);return()=>clearTimeout(e)},[z,m]);const P=b?Math.max(1,Math.ceil(b.total/b.per_page)):1,$=b?b.forms.reduce((e,t)=>e+t.count,0):0,O=e.settings.capture.enabled,A=e.guard;return(0,l.createElement)("div",{className:"dms-stack"},!O&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Saving form contacts is off","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.__)("Turn it on in Settings and the people who fill in your forms show up here.","digimail-smtp")),b&&(b.forms.length>0||A.enabled)&&(0,l.createElement)("div",{className:"dms-formcards"},(0,l.createElement)("button",{type:"button",className:T||""!==s?"":"is-on",onClick:()=>{D(!1),n(""),_(1)}},(0,l.createElement)("span",null,(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("strong",null,d($))),b.forms.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:T||s!==e.key?"":"is-on",onClick:()=>{D(!1),n(e.key),_(1)}},(0,l.createElement)("span",{className:"dms-ellipsis",title:q(e)},e.form||g(e.source??"")||e.source||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("strong",null,d(e.count)),(0,l.createElement)("small",{className:"dms-ellipsis"},e.form&&e.source?(g(e.source)||e.source)+" · ":"",(0,i.sprintf)(/* translators: %s: time of the last entry. */ /* translators: %s: time of the last entry. */13 (0,i.__)("last %s","digimail-smtp"),p(e.last_at))))),A.enabled&&(0,l.createElement)("button",{type:"button",className:"is-spam "+(T?"is-on":""),onClick:()=>D(!0)},(0,l.createElement)("span",null,(0,l.createElement)(w,{name:"shield",size:14})," ",(0,i.__)("Spam blocked","digimail-smtp")),(0,l.createElement)("strong",null,d(A.blocked)),(0,l.createElement)("small",null,(0,i.__)("last 30 days","digimail-smtp")))),T&&(0,l.createElement)(j,{summary:A}),!T&&(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:m,onChange:e=>{r(e.target.value),_(1)},placeholder:(0,i.__)("Search name, email or phone","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>z(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15})),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:x,disabled:!b||0===b.total,onClick:async()=>{M(!0);try{const e=await c(`entries/export?${F(!1)}`),t=URL.createObjectURL(new Blob([e.csv],{type:"text/csv;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download="khach-dien-form.csv",a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{M(!1)}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Export CSV","digimail-smtp"))),e.capture.pending>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of contacts. */ /* translators: %s: number of contacts. */14 (0,i._n)("%s new entry is on its way to DigiMail.","%s new entries are on their way to DigiMail.",e.capture.pending,"digimail-smtp"),d(e.capture.pending))),N&&(0,l.createElement)("p",{className:"dms-error"},N),!b&&!N&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),b&&0===b.entries.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"users",size:26}),title:m||s?(0,i.__)("No matching entries","digimail-smtp"):(0,i.__)("No form entries yet","digimail-smtp")},m||s?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("When someone fills in a form or places an order, they show up here with the form and page they used.","digimail-smtp")),b&&b.entries.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Customer","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Phone","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Page","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Result","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,b.entries.map(e=>{const t=R[e.outcome];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email),e.name&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.email),e.company&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.company)),(0,l.createElement)("td",{className:"dms-small"},e.phone?(0,l.createElement)("a",{href:`tel:${e.phone.replace(/[^\d+]/g,"")}`},e.phone):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"}, q(e)),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},e.page?(0,l.createElement)("a",{href:e.page,target:"_blank",rel:"noreferrer"},(e=>{try{const t=new URL(e);return decodeURIComponent(t.pathname)||"/"}catch{return e}})(e.page)):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{title:t.hint},(0,l.createElement)(h,{tone:t.tone},t.label)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.submitted_at).toLocaleString(o)},p(e.submitted_at)))}))),b&&P>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of entries. */ /* translators: %s: number of entries. */15 (0,i._n)("%s entry","%s entries",b.total,"digimail-smtp"),d(b.total))),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled: u<=1,onClick:()=>_(u-1)},(0,i.__)("Previous","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: current page, 2: number of pages. */ /* translators: 1: current page, 2: number of pages. */16 (0,i.__)("Page %1$d of %2$d","digimail-smtp"), u,P)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:u>=P,onClick:()=>_(u+1)},(0,i.__)("Next","digimail-smtp")))))}function U({state:e,go:t}){const[a,s]=(0,l.useState)(e.site.user_email),[n,m]=(0,l.useState)("html"),[r,o]=(0,l.useState)(!1),[d,p]=(0,l.useState)(null),[u,g]=(0,l.useState)("");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)(E,{title:(0,i.__)("Send a test email","digimail-smtp")},e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),(0,l.createElement)("form",{className:"dms-form",onSubmit:e=>{e.preventDefault(),(async()=>{o(!0),g(""),p(null);try{p(await c("test",{to:a,format:n}))}catch(e){g(e.message)}finally{o(!1)}})()}},(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("The test goes through the same wp_mail() function your website and plugins use, so if it works, order emails and contact forms work too.","digimail-smtp")),(0,l.createElement)(y,{label:(0,i.__)("Send to","digimail-smtp"),htmlFor:"dms-to"},(0,l.createElement)("input",{id:"dms-to",type:"email",required:!0,value:a,onChange:e=>s(e.target.value)})),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Format","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===n?"is-on":"",onClick:()=>m("html")},"HTML"),(0,l.createElement)("button",{type:"button",className:"text"===n?"is-on":"",onClick:()=>m("text")},(0,i.__)("Plain text","digimail-smtp")))),(0,l.createElement)("div",null,(0,l.createElement)(f,{type:"submit",busy:r},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send test email","digimail-smtp")))),d&&(0,l.createElement)(v,{tone:"ok",title:"backup"===d.via?(0,i.__)("Sent through the backup server","digimail-smtp"):(0,i.__)("Sent. Check your inbox.","digimail-smtp"),action:"digimail"===d.via&&(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("logs")},(0,i.__)("See status","digimail-smtp"))},(0,i.sprintf)(/* translators: 1: sender name, 2: sender email, 3: seconds taken. */ /* translators: 1: sender name, 2: sender email, 3: seconds taken. */17 (0,i.__)("Sent from %1$s <%2$s> in %3$s seconds. The Delivered status shows in the email log a few seconds later.","digimail-smtp"),d.from?.name??"",d.from?.email??"",(d.took_ms/1e3).toFixed(1))), u&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("The email was not sent","digimail-smtp")},u)),(0,l.createElement)(E,{title:(0,i.__)("No email?","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-checklist"},(0,l.createElement)("li",null,(0,l.createInterpolateElement)((0,i.__)("Check the <strong>Spam</strong> folder and the Gmail <strong>Promotions</strong> tab.","digimail-smtp"),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("li",null,(0,l.createInterpolateElement)((0,i.__)("Open the <a>email log</a> and click the email to see whether the receiving server accepted or bounced it, and why.","digimail-smtp"),{a:(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>t("logs")})})),(0,l.createElement)("li",null,(0,i.__)("Sending from the shared address? Verify your own domain so Gmail and Outlook trust your email more.","digimail-smtp")),(0,l.createElement)("li",null,(0,i.__)("Some company networks block outside email: try a Gmail address.","digimail-smtp")))))}function V({state:e,s:t,setS:a}){const s=C(),n=t.capture,m=e.capture,[r,o]=(0,l.useState)(null),[u,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(m.last),[k,w]=(0,l.useState)(m.pending),N=e=>a({...t,capture:{...n,...e}});return(0,l.useEffect)(()=>{n.enabled&&!r&&c("lists").then(o).catch(()=>{})},[n.enabled,r]),(0,l.createElement)(E,{title:(0,i.__)("Save form contacts to DigiMail","digimail-smtp"),aside:n.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:n.enabled,onChange:e=>N({enabled:e}),label:(0,i.__)("Add people who fill in forms to a DigiMail contact list","digimail-smtp"),hint:(0,i.__)("Email, name and phone from contact, signup and order forms go straight into a list on digimail.vn, ready for your campaigns.","digimail-smtp")}),n.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(b,{checked:n.forms,onChange:e=>N({forms:e}),label:(0,i.__)("Forms on the website","digimail-smtp"),hint:m.forms.length18 /* translators: %s: names of form plugins found on the site. */?(0,i.sprintf)(/* translators: %s: list of form plugins. */ /* translators: %s: list of form plugins. */(0,i.__)("Found: %s.","digimail-smtp"),m.forms.join(", ")):(0,i.__)("No supported form plugin is active. Supported: Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks.","digimail-smtp")}),(0,l.createElement)(b,{checked:n.woocommerce&&m.woocommerce,onChange:e=>N({woocommerce:e}),label:(0,i.__)("WooCommerce buyers","digimail-smtp"),hint:m.woocommerce?(0,i.__)("Billing email, name and phone of each new order.","digimail-smtp"):(0,i.__)("WooCommerce is not active.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Contact list","digimail-smtp"),htmlFor:"dms-list",hint:(0,i.__)("Saved right away. New contacts go to this list.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-list",disabled:!r||"list"=== u,value:r?.list_id??"",onChange:e=>(async e=>{g("list");try{o(await c("list",{list_id:e})),s((0,i.__)("Contact list saved.","digimail-smtp"))}catch(e){s(e.message,"bad")}finally{g(null)}})(e.target.value)},!r&&(0,l.createElement)("option",{value:""},(0,i.__)("Loading…","digimail-smtp")),r&&!r.list_id&&(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: list name. */ /* translators: %s: list name. */9 (0,i.__)("Page %1$d of %2$d","digimail-smtp"),m,x)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:m>=x,onClick:()=>r(m+1)},(0,i.__)("Next","digimail-smtp")))),(0,l.createElement)(A,{id:N,onClose:()=>S(null)}))}function L({state:e,s:t,setS:a}){const s=t.guard,n=e.guard,m=e=>a({...t,guard:{...s,...e}});return(0,l.createElement)(E,{title:(0,i.__)("Block form spam","digimail-smtp"),aside:s.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.enabled,onChange:e=>m({enabled:e}),label:(0,i.__)("Stop bots before the form sends any email","digimail-smtp"),hint:(0,i.__)("Invisible to visitors: no puzzle, nothing to click. Bot submissions are refused, so no notification or auto-reply goes out and nothing reaches your contact list. Works with Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks and WooCommerce checkout.","digimail-smtp")}),s.enabled&&(0,l.createElement)(b,{checked:s.core,onChange:e=>m({core:e}),label:(0,i.__)("Also protect WordPress registration, lost password and comment forms","digimail-smtp"),hint:(0,i.__)("Bots use these forms to make your site email addresses they type in. Includes WooCommerce account registration. Logged-in users are never checked; spam comments go to the Spam folder.","digimail-smtp")}),s.enabled&&(0,l.createElement)(b,{checked:s.badge,onChange:e=>m({badge:e}),label:(0,i.__)("Show admins a note under each form","digimail-smtp"),hint:(0,i.__)("When you are logged in as an admin, each form on your site shows whether the spam guard protects it. Visitors never see it.","digimail-smtp")}),s.enabled&&(0,l.createElement)(b,{checked:s.akismet&&n.akismet,disabled:!n.akismet,onChange:e=>m({akismet:e}),label:(0,i.__)("Also ask Akismet","digimail-smtp"),hint:n.akismet?(0,i.__)("Off by default. When on, only submissions that already look doubtful are sent to Akismet (name, email, message, IP address and browser) for a second opinion.","digimail-smtp"):(0,i.__)("Akismet is not set up on this site.","digimail-smtp")}),!s.enabled&&(0,l.createElement)("p",{className:"dms-small dms-error"},(0,i.__)("Without it, bots can use your forms to send email to addresses they type in. Bounces and spam reports from those emails can get sending paused.","digimail-smtp")),s.enabled&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */ 10 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. See them in the Customers tab.","digimail-smtp"),d(n.blocked),d(n.checked)))))}function j({summary:e}){const t=C(),[a,s]=(0,l.useState)(null),[n,r]=(0,l.useState)(""),[c,g]=(0,l.useState)(""),[_,h]=(0,l.useState)(""),b=(0,l.useCallback)(()=>o("guard/log").then(e=>s(e.items)).catch(e=>r(e.message)),[]);(0,l.useEffect)(()=>{b()},[b]);const y=Object.entries(e.reasons).slice(0,4);return(0,l.createElement)(E,{title:(0,i.__)("Spam blocked","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:b,"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */ 11 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. No email was sent for them and they were not saved as contacts.","digimail-smtp"),d(e.blocked),d(e.checked)),y.length>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("Most common reasons:","digimail-smtp")," ",y.map(([e,t])=>`${m[e]??e} (${d(t)})`).join("; "),".")),n&&(0,l.createElement)("p",{className:"dms-error"},n),!a&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:240}}),a&&0===a.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"shield",size:26}),title:(0,i.__)("Nothing blocked yet","digimail-smtp")},(0,i.__)("Bot submissions show up here. If a real customer says the form did not work, find them here and click “Not spam”.","digimail-smtp")),a&&a.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Sender","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Why","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,a.map(e=>(0,l.createElement)(l.Fragment,{key:e.id},(0,l.createElement)("tr",null,(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email||"—"),e.name&&e.email&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.email),e.phone&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.phone)),(0,l.createElement)("td",{className:"dms-small"},[u(e.source),e.form].filter(Boolean).join(" · "),(0,l.createElement)("div",{className:"dms-muted"},e.ip)),(0,l.createElement)("td",{className:"dms-small"},(0,l.createElement)("ul",{className:"dms-reasons"},e.reasons.map(e=>(0,l.createElement)("li",{key:e},m[e]??e))),e.text&&(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>h(_===e.id?"":e.id)},_===e.id?(0,i.__)("Hide message","digimail-smtp"):(0,i.__)("Show message","digimail-smtp"))),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(1e3*e.at).toLocaleString()},p(new Date(1e3*e.at).toISOString())),(0,l.createElement)("td",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:c===e.id,onClick:()=>(async e=>{g(e);try{await o("guard/restore",{id:e}),s(t=>(t??[]).filter(t=>t.id!==e)),t((0,i.__)("Marked as not spam. This address will not be blocked again.","digimail-smtp"))}catch(e){t(e.message,"bad")}finally{g("")}})(e.id)},(0,i.__)("Not spam","digimail-smtp")))),_===e.id&&(0,l.createElement)("tr",{className:"dms-subrow"},(0,l.createElement)("td",{colSpan:5},(0,l.createElement)("pre",{className:"dms-message"},e.text))))))),a&&a.length>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of entries kept. */ /* translators: %s: number of entries kept. */ 12 (0,i._n)("The latest %s blocked submission is kept on this website.","The latest %s blocked submissions are kept on this website.",a.length,"digimail-smtp"),d(a.length))))}const R={added:{label:(0,i.__)("New","digimail-smtp"),tone:"ok",hint:(0,i.__)("Added to the contact list.","digimail-smtp")},existing:{label:(0,i.__)("Already in list","digimail-smtp"),tone:"info",hint:(0,i.__)("This address was already in the list.","digimail-smtp")},blocked:{label:(0,i.__)("Blocked","digimail-smtp"),tone:"wait",hint:(0,i.__)("Unsubscribed, bounced or reported spam before, so it is not added back.","digimail-smtp")},invalid:{label:(0,i.__)("Invalid email","digimail-smtp"),tone:"bad",hint:(0,i.__)("The address cannot receive email.","digimail-smtp")},pending:{label:(0,i.__)("Awaiting confirmation","digimail-smtp"),tone:"wait",hint:(0,i.__)("A confirmation email was sent. They join the list after clicking it.","digimail-smtp")}},B=e=>[u(e.source??"")||e.source,e.form].filter(Boolean).join(" · ")||(0,i.__)("Other","digimail-smtp");function q({state:e,go:t}){const a=C(),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[g,_]=(0,l.useState)(1),[b,y]=(0,l.useState)(null),[N,S]=(0,l.useState)(""),[x,M]=(0,l.useState)(!1),[T,D]=(0,l.useState)(!1),F=(0,l.useCallback)(e=>{const t=new URLSearchParams;return e&&t.set("page",String(g)),s&&t.set("form",s),m.trim()&&t.set("q",m.trim()),t.toString()},[g,s,m]),z=(0,l.useCallback)(()=>o(`entries?${F(!0)}`).then(e=>{y(e),S("")}).catch(e=>S(e.message)),[F]);(0,l.useEffect)(()=>{const e=setTimeout(z,m?300:0);return()=>clearTimeout(e)},[z,m]);const P=b?Math.max(1,Math.ceil(b.total/b.per_page)):1,$=b?b.forms.reduce((e,t)=>e+t.count,0):0,O=e.settings.capture.enabled,A=e.guard;return(0,l.createElement)("div",{className:"dms-stack"},!O&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Saving form contacts is off","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.__)("Turn it on in Settings and the people who fill in your forms show up here.","digimail-smtp")),b&&(b.forms.length>0||A.enabled)&&(0,l.createElement)("div",{className:"dms-formcards"},(0,l.createElement)("button",{type:"button",className:T||""!==s?"":"is-on",onClick:()=>{D(!1),n(""),_(1)}},(0,l.createElement)("span",null,(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("strong",null,d($))),b.forms.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:T||s!==e.key?"":"is-on",onClick:()=>{D(!1),n(e.key),_(1)}},(0,l.createElement)("span",{className:"dms-ellipsis",title:B(e)},e.form||u(e.source??"")||e.source||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("strong",null,d(e.count)),(0,l.createElement)("small",{className:"dms-ellipsis"},e.form&&e.source?(u(e.source)||e.source)+" · ":"",(0,i.sprintf)(/* translators: %s: time of the last entry. */ /* translators: %s: time of the last entry. */ 13 (0,i.__)("last %s","digimail-smtp"),p(e.last_at))))),A.enabled&&(0,l.createElement)("button",{type:"button",className:"is-spam "+(T?"is-on":""),onClick:()=>D(!0)},(0,l.createElement)("span",null,(0,l.createElement)(w,{name:"shield",size:14})," ",(0,i.__)("Spam blocked","digimail-smtp")),(0,l.createElement)("strong",null,d(A.blocked)),(0,l.createElement)("small",null,(0,i.__)("last 30 days","digimail-smtp")))),T&&(0,l.createElement)(j,{summary:A}),!T&&(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:m,onChange:e=>{r(e.target.value),_(1)},placeholder:(0,i.__)("Search name, email or phone","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>z(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15})),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:x,disabled:!b||0===b.total,onClick:async()=>{M(!0);try{const e=await o(`entries/export?${F(!1)}`),t=URL.createObjectURL(new Blob([e.csv],{type:"text/csv;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download="khach-dien-form.csv",a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{M(!1)}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Export CSV","digimail-smtp"))),e.capture.pending>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of contacts. */ /* translators: %s: number of contacts. */ 14 (0,i._n)("%s new entry is on its way to DigiMail.","%s new entries are on their way to DigiMail.",e.capture.pending,"digimail-smtp"),d(e.capture.pending))),N&&(0,l.createElement)("p",{className:"dms-error"},N),!b&&!N&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),b&&0===b.entries.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"users",size:26}),title:m||s?(0,i.__)("No matching entries","digimail-smtp"):(0,i.__)("No form entries yet","digimail-smtp")},m||s?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("When someone fills in a form or places an order, they show up here with the form and page they used.","digimail-smtp")),b&&b.entries.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Customer","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Phone","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Page","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Result","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,b.entries.map(e=>{const t=R[e.outcome];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email),e.name&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.email),e.company&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.company)),(0,l.createElement)("td",{className:"dms-small"},e.phone?(0,l.createElement)("a",{href:`tel:${e.phone.replace(/[^\d+]/g,"")}`},e.phone):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},B(e)),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},e.page?(0,l.createElement)("a",{href:e.page,target:"_blank",rel:"noreferrer"},(e=>{try{const t=new URL(e);return decodeURIComponent(t.pathname)||"/"}catch{return e}})(e.page)):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{title:t.hint},(0,l.createElement)(h,{tone:t.tone},t.label)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.submitted_at).toLocaleString(c)},p(e.submitted_at)))}))),b&&P>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of entries. */ /* translators: %s: number of entries. */ 15 (0,i._n)("%s entry","%s entries",b.total,"digimail-smtp"),d(b.total))),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:g<=1,onClick:()=>_(g-1)},(0,i.__)("Previous","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: current page, 2: number of pages. */ /* translators: 1: current page, 2: number of pages. */ 16 (0,i.__)("Page %1$d of %2$d","digimail-smtp"),g,P)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:g>=P,onClick:()=>_(g+1)},(0,i.__)("Next","digimail-smtp")))))}function V({state:e,go:t}){const[a,s]=(0,l.useState)(e.site.user_email),[n,m]=(0,l.useState)("html"),[r,c]=(0,l.useState)(!1),[d,p]=(0,l.useState)(null),[g,u]=(0,l.useState)("");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)(E,{title:(0,i.__)("Send a test email","digimail-smtp")},e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),(0,l.createElement)("form",{className:"dms-form",onSubmit:e=>{e.preventDefault(),(async()=>{c(!0),u(""),p(null);try{p(await o("test",{to:a,format:n}))}catch(e){u(e.message)}finally{c(!1)}})()}},(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("The test goes through the same wp_mail() function your website and plugins use, so if it works, order emails and contact forms work too.","digimail-smtp")),(0,l.createElement)(y,{label:(0,i.__)("Send to","digimail-smtp"),htmlFor:"dms-to"},(0,l.createElement)("input",{id:"dms-to",type:"email",required:!0,value:a,onChange:e=>s(e.target.value)})),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Format","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===n?"is-on":"",onClick:()=>m("html")},"HTML"),(0,l.createElement)("button",{type:"button",className:"text"===n?"is-on":"",onClick:()=>m("text")},(0,i.__)("Plain text","digimail-smtp")))),(0,l.createElement)("div",null,(0,l.createElement)(f,{type:"submit",busy:r},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send test email","digimail-smtp")))),d&&(0,l.createElement)(v,{tone:"ok",title:"backup"===d.via?(0,i.__)("Sent through the backup server","digimail-smtp"):(0,i.__)("Sent. Check your inbox.","digimail-smtp"),action:"digimail"===d.via&&(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("logs")},(0,i.__)("See status","digimail-smtp"))},(0,i.sprintf)(/* translators: 1: sender name, 2: sender email, 3: seconds taken. */ /* translators: 1: sender name, 2: sender email, 3: seconds taken. */ 17 (0,i.__)("Sent from %1$s <%2$s> in %3$s seconds. The Delivered status shows in the email log a few seconds later.","digimail-smtp"),d.from?.name??"",d.from?.email??"",(d.took_ms/1e3).toFixed(1))),g&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("The email was not sent","digimail-smtp")},g)),(0,l.createElement)(E,{title:(0,i.__)("No email?","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-checklist"},(0,l.createElement)("li",null,(0,l.createInterpolateElement)((0,i.__)("Check the <strong>Spam</strong> folder and the Gmail <strong>Promotions</strong> tab.","digimail-smtp"),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("li",null,(0,l.createInterpolateElement)((0,i.__)("Open the <a>email log</a> and click the email to see whether the receiving server accepted or bounced it, and why.","digimail-smtp"),{a:(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>t("logs")})})),(0,l.createElement)("li",null,(0,i.__)("Sending from the shared address? Verify your own domain so Gmail and Outlook trust your email more.","digimail-smtp")),(0,l.createElement)("li",null,(0,i.__)("Some company networks block outside email: try a Gmail address.","digimail-smtp")))))}function U({state:e,s:t,setS:a}){const s=C(),n=t.capture,m=e.capture,[r,c]=(0,l.useState)(null),[g,u]=(0,l.useState)(null),[_,v]=(0,l.useState)(m.last),[k,w]=(0,l.useState)(m.pending),N=e=>a({...t,capture:{...n,...e}});return(0,l.useEffect)(()=>{n.enabled&&!r&&o("lists").then(c).catch(()=>{})},[n.enabled,r]),(0,l.createElement)(E,{title:(0,i.__)("Save form contacts to DigiMail","digimail-smtp"),aside:n.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:n.enabled,onChange:e=>N({enabled:e}),label:(0,i.__)("Add people who fill in forms to a DigiMail contact list","digimail-smtp"),hint:(0,i.__)("Email, name and phone from contact, signup and order forms go straight into a list on digimail.vn, ready for your campaigns.","digimail-smtp")}),n.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(b,{checked:n.forms,onChange:e=>N({forms:e}),label:(0,i.__)("Forms on the website","digimail-smtp"),hint:m.forms.length 18 /* translators: %s: names of form plugins found on the site. */?(0,i.sprintf)(/* translators: %s: list of form plugins. */ /* translators: %s: list of form plugins. */(0,i.__)("Found: %s.","digimail-smtp"),m.forms.join(", ")):(0,i.__)("No supported form plugin is active. Supported: Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks.","digimail-smtp")}),(0,l.createElement)(b,{checked:n.woocommerce&&m.woocommerce,onChange:e=>N({woocommerce:e}),label:(0,i.__)("WooCommerce buyers","digimail-smtp"),hint:m.woocommerce?(0,i.__)("Billing email, name and phone of each new order.","digimail-smtp"):(0,i.__)("WooCommerce is not active.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Contact list","digimail-smtp"),htmlFor:"dms-list",hint:(0,i.__)("Saved right away. New contacts go to this list.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-list",disabled:!r||"list"===g,value:r?.list_id??"",onChange:e=>(async e=>{u("list");try{c(await o("list",{list_id:e})),s((0,i.__)("Contact list saved.","digimail-smtp"))}catch(e){s(e.message,"bad")}finally{u(null)}})(e.target.value)},!r&&(0,l.createElement)("option",{value:""},(0,i.__)("Loading…","digimail-smtp")),r&&!r.list_id&&(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: list name. */ /* translators: %s: list name. */ 19 19 (0,i.__)("%s (created automatically)","digimail-smtp"),r.default_name)),r?.lists.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},(0,i.sprintf)(/* translators: 1: list name, 2: number of subscribers. */ /* translators: 1: list name, 2: number of subscribers. */ 20 20 (0,i.__)("%1$s (%2$s subscribers)","digimail-smtp"),e.name,d(e.subscribed)))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("span",{className:"dms-small dms-muted"},_?.error 21 21 /* translators: %s: error message. */?(0,i.sprintf)(/* translators: %s: error message. */ /* translators: %s: error message. */(0,i.__)("Last sync failed: %s","digimail-smtp"),_.error):_?(0,i.sprintf)(/* translators: 1: number of contacts, 2: time. */ /* translators: 1: number of contacts, 2: time. */ 22 (0,i.__)("%1$s contacts added so far, last sync %2$s.","digimail-smtp"),d(_.total??0),p(new Date(1e3*_.at).toISOString())):(0,i.__)("No contacts yet. They show up a few seconds after someone submits a form.","digimail-smtp"),k>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of items waiting. */ /* translators: %s: number of items waiting. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),d(k)))),k>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"=== u,onClick:async()=>{g("sync");try{const e=await c("contacts/sync",{});w(e.pending),v(e.last),e.last?.error?s(e.last.error,"bad"):s((0,i.__)("Contacts sent to DigiMail.","digimail-smtp"))}catch(e){s(e.message,"bad")}finally{g(null)}}},(0,i.__)("Send now","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send marketing email only to people who agreed to receive it. Add an “I agree to receive news” checkbox to your forms.","digimail-smtp")))))}const H={ok:{label:(0,i.__)("Correct","digimail-smtp"),tone:"ok"},missing:{label:(0,i.__)("Not added yet","digimail-smtp"),tone:"wait"},wrong:{label:(0,i.__)("Wrong value","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Could not check","digimail-smtp"),tone:"muted"}};function G({text:e,label:t}){const a=C();return(0,l.createElement)("button",{type:"button",className:"dms-copy",title:(0,i.__)("Copy","digimail-smtp"),"aria-label":(0,i.sprintf)(/* translators: %s: what is copied. */ /* translators: %s: what is copied. */(0,i.__)("Copy %s","digimail-smtp"),t),onClick:async()=>a(await async function(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const a=document.execCommand("copy");return t.remove(),a}}(e)?(0,i.__)("Copied.","digimail-smtp"):(0,i.__)("Could not copy. Select the text and copy it by hand.","digimail-smtp"))},(0,l.createElement)("code",null,e),(0,l.createElement)(w,{name:"copy",size:14}))}function J({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[o,p]=(0,l.useState)(""),[u,g]=(0,l.useState)(""),[_,b]=(0,l.useState)(""),k=(0,l.useCallback)(()=>c("domain").then(e=>(n(e),r(""),e)).catch(e=>(r(e.message),null)),[]);(0,l.useEffect)(()=>{k()},[k]);const N="pending"===s?.state;(0,l.useEffect)(()=>{if(!N)return;let e=0;const t=setInterval(()=>{e++,e>20||document.hidden?e>20&&clearInterval(t):k()},3e4);return()=>clearInterval(t)},[N,k]);const S="verified"===s?.state;(0,l.useEffect)(()=>{S&&"shared"===e.status.sender?.mode&&c("state?refresh=1").then(t).catch(()=>{})},[S,e.status.sender?.mode,t]);const x=async(e,t,l={})=>{p(e);try{const e=await c(t,l);return n(e),e}catch(e){return a(e.message,"bad"),null}finally{p("")}},M=async()=>{const e=await x("cf","domain/cloudflare",{token:u});e?.applied&&(g(""),a(e.applied.problems>0?(0,i.sprintf)(/* translators: %s: number of records. */ /* translators: %s: number of records. */(0,i.__)("Added what could be added. %s records need a look: see the list.","digimail-smtp"),d(e.applied.problems)):(0,i.__)("Records added in Cloudflare. Verification usually finishes within a few minutes.","digimail-smtp")))},T=s?"verified"===s.state?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Verified","digimail-smtp")):"pending"===s.state?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS","digimail-smtp")):"failed"===s.state?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Not verified","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Shared address","digimail-smtp")):null,D=s?.dns?.zone??s?.zone??null,F="cloudflare"===D?.provider.key||(s?.dns?.cloudflare.can_apply??s?.can_apply??!1),z=s?.dns?.cloudflare.can_apply??s?.can_apply??!1,P=s?.dns?.cloudflare.token_url??s?.token_url??"",$=s&&D&&D.apex!==s.domain&&s.domain.endsWith(`.${D.apex}`)?[s.domain,D.apex]:null;return(0,l.createElement)(E,{title:(0,l.createElement)("span",{id:"dms-domain"},(0,i.__)("Sending domain","digimail-smtp")),aside:T},m&&(0,l.createElement)("p",{className:"dms-error"},m),!s&&!m&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),s&&!s.eligible&&(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("This website runs on an IP address or localhost, so it has no domain to verify. It keeps sending from the shared address.","digimail-smtp")),s?.eligible&&"taken"===s.state&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is already in another DigiMail account","digimail-smtp"),s.domain)},(0,i.__)("Log in to that account on digimail.vn, or contact DigiMail if you own this domain.","digimail-smtp")),s?.eligible&&"none"===s.state&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared address, 2: example address on the site's domain. */ /* translators: 1: shared address, 2: example address on the site's domain. */23 (0,i.__)("The website sends from <code>%1$s</code>. Verify your domain to send from an address like <code>%2$s</code>: Gmail and Outlook trust it more, emails land in the inbox more often, and the shared address’s daily limit no longer applies.","digimail-smtp"),s.sender?.email??"",`noreply@${_||s.domain}`),{code:(0,l.createElement)("code",null)})),$&&(0,l.createElement)(y,{label:(0,i.__)("Domain to verify","digimail-smtp"),htmlFor:"dms-domain-pick",hint:(0,i.__)("Verifying the main domain covers every subdomain of it.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-domain-pick",value:_||$[0],onChange:e=>b(e.target.value)},$.map(e=>(0,l.createElement)("option",{key:e,value:e},e)))),D&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: DNS provider. */ /* translators: 1: domain, 2: DNS provider. */(0,i.__)("DNS of <strong>%1$s</strong> is managed at <strong>%2$s</strong>.","digimail-smtp"),D.apex,D.provider.name),{strong:(0,l.createElement)("strong",null)}),F&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("You can add the records with one click through Cloudflare.","digimail-smtp"))),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"add"=== o,onClick:()=>x("add","domain/add",_?{domain:_}:{})},(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),_||s.domain)))),s?.eligible&&"verified"===s.state&&(0,l.createElement)(v,{tone:"ok",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is verified","digimail-smtp"),s.dns?.domain??s.domain)},"domain"===s.sender?.mode?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender address. */ /* translators: %s: sender address. */(0,i.__)("The website sends from <code>%s</code>.","digimail-smtp"),s.sender.email),{code:(0,l.createElement)("code",null)}):(0,i.__)("The website switches to your domain within a minute.","digimail-smtp")),s?.eligible&&("pending"===s.state||"failed"===s.state)&&s.dns&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: correct records, 2: required records. */ /* translators: 1: correct records, 2: required records. */24 (0,i.__)("%1$s of %2$s required DNS records are correct.","digimail-smtp"),d(s.dns.summary.ok_required),d(s.dns.summary.required))," ",s.dns.summary.dns_ready?(0,i.__)("DNS is ready: DigiMail confirms the domain within a few minutes, then the website switches to it by itself.","digimail-smtp"):(0,i.__)("Add the records below where your domain’s DNS is managed. Changes usually show within minutes, sometimes a few hours.","digimail-smtp")),F&&!s.dns.summary.dns_ready&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Add them automatically through Cloudflare","digimail-smtp")),z?(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"cf"=== o,onClick:M},(0,i.__)("Add records in Cloudflare","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.__)("<a>Create a Cloudflare API token</a> (the link fills in the right permissions: Zone Read, DNS Edit), then paste it here. DigiMail stores it encrypted and only uses it to add these records.","digimail-smtp"),{a:(0,l.createElement)("a",{href:P,target:"_blank",rel:"noreferrer"})})),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("input",{type:"password",autoComplete:"off",value:u,onChange:e=>g(e.target.value),placeholder:(0,i.__)("Cloudflare API token","digimail-smtp"),"aria-label":(0,i.__)("Cloudflare API token","digimail-smtp")}),(0,l.createElement)(f,{busy:"cf"===o,disabled:u.trim().length<20,onClick:M},(0,i.__)("Connect and add records","digimail-smtp"))))),D&&!F&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: DNS provider, 2: how to add records there. */ /* translators: 1: DNS provider, 2: how to add records there. */(0,i.__)("DNS is at <strong>%1$s</strong>. %2$s","digimail-smtp"),D.provider.name,D.provider.guide),{strong:(0,l.createElement)("strong",null)}),D.provider.url&&(0,l.createElement)(l.Fragment,null," ",(0,l.createElement)("a",{href:D.provider.url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:12})))),s.applied&&s.applied.problems>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.__)("Some records were left alone in Cloudflare","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-reasons"},s.applied.outcomes.filter(e=>"conflict"===e.action||"failed"===e.action).map(e=>(0,l.createElement)("li",{key:e.name+e.type},e.type," ",e.name,": ",e.message)))),(0,l.createElement)("div",{className:"dms-table-wrap"},(0,l.createElement)("table",{className:"dms-table dms-dns"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Type","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Name (host)","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Value","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")))),(0,l.createElement)("tbody",null,s.dns.records.map(e=>(0,l.createElement)("tr",{key:e.type+e.name+e.value},(0,l.createElement)("td",null,(0,l.createElement)("strong",null,e.type),!e.required&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("recommended","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(G,{text:e.host||"@",label:(0,i.__)("name","digimail-smtp")})),(0,l.createElement)("td",null,(0,l.createElement)(G,{text:e.value,label:(0,i.__)("value","digimail-smtp")}),null!==e.priority&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: MX priority. */ /* translators: %s: MX priority. */(0,i.__)("Priority: %s","digimail-smtp"),e.priority)),"CNAME"===e.type&&F&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("Proxy off (DNS only)","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:H[e.state].tone},H[e.state].label),"ok"!==e.state&&e.note&&(0,l.createElement)("div",{className:"dms-small dms-muted"},e.note))))))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{busy:"check"===o,onClick:()=>x("check","domain/check")},(0,l.createElement)(w,{name:"refresh",size:15})," ",(0,i.__)("Check again","digimail-smtp")),(0,l.createElement)(f,{variant:"secondary",busy:"zone"===o,onClick:async()=>{p("zone");try{const e=await c("domain/zonefile"),t=URL.createObjectURL(new Blob([e.text],{type:"text/plain;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download=`digimail-${s?.dns?.domain??"dns"}.txt`,a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{p("")}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Download zone file","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("When the domain is verified, DigiMail tells you by Telegram or email (see Alerts).","digimail-smtp"))))}const Y={bad:"bad",warn:"wait",good:"ok"};function K(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[o,u]=(0,l.useState)(null),g=(0,l.useRef)(null),_=(0,l.useCallback)(()=>c("alerts").then(e=>(a(e),n(""),e)).catch(e=>(n(e.message),null)),[]);(0,l.useEffect)(()=>(_(),()=>{g.current&&clearInterval(g.current)}),[_]);const y=async t=>{r("prefs");try{a(await c("alerts/prefs",t))}catch(t){e(t.message,"bad")}finally{r("")}},v=t?.telegram.chats??[],k=!!t&&(t.prefs.telegram&&v.length>0||t.prefs.email&&t.emails.length>0);return(0,l.createElement)(E,{title:(0,i.__)("Alerts","digimail-smtp"),aside:t?k?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp")):null},s&&(0,l.createElement)("p",{className:"dms-error"},s),!t&&!s&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),t&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("DigiMail tells you when emails fail, the quota is nearly used up, bounces or spam reports rise, the plugin stops reporting, forms are hit by bots, or something changes with your domain. The same problem is repeated at most once a day.","digimail-smtp")),(0,l.createElement)(b,{checked:t.prefs.telegram,disabled:"prefs"===m||!t.telegram.available,onChange:e=>y({...t.prefs,telegram:e}),label:(0,i.__)("Telegram","digimail-smtp"),hint:t.telegram.available?v.length?(0,i.sprintf)(/* translators: %s: number of chats. */ /* translators: %s: number of chats. */(0,i._n)("Sent to %s connected chat.","Sent to %s connected chats.",v.length,"digimail-smtp"),d(v.length)):(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Connect your Telegram (or a group) to the %s bot.","digimail-smtp"),t.telegram.bot??""):(0,i.__)("Telegram alerts are not available yet.","digimail-smtp")}),t.telegram.available&&(0,l.createElement)("div",{className:"dms-chats"},v.map(t=>(0,l.createElement)("div",{key:t.id,className:"dms-chat"},(0,l.createElement)(w,{name:"private"===t.kind?"send":"users",size:15}),(0,l.createElement)("span",{className:"dms-grow"},t.title,"private"!==t.kind&&(0,l.createElement)("span",{className:"dms-muted dms-small"}," · ",(0,i.__)("group","digimail-smtp"))),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:m===t.id,onClick:()=>(async t=>{r(t.id);try{a(await c("alerts/telegram/remove",{id:t.id}))}catch(t){e(t.message,"bad")}finally{r("")}})(t)},(0,i.__)("Remove","digimail-smtp")))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",busy:"link"===m,onClick:async()=>{r("link");try{const a=await c("alerts/telegram",{});u(a),window.open(a.start_url,"_blank","noopener");const l=t?.telegram.chats.length??0;let s=0;g.current&&clearInterval(g.current),g.current=setInterval(async()=>{s++;const t=await _();(t&&t.telegram.chats.length>l||s>40)&&(g.current&&clearInterval(g.current),t&&t.telegram.chats.length>l&&(u(null),e((0,i.__)("Telegram connected.","digimail-smtp"))))},3e3)}catch(t){e(t.message,"bad")}finally{r("")}}},v.length?(0,i.__)("Connect another Telegram","digimail-smtp"):(0,i.__)("Connect Telegram","digimail-smtp"))),o&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Finish in Telegram","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Telegram opens a chat with %s: press Start. This page updates by itself once it is connected.","digimail-smtp"),o.bot)),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:o.start_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open Telegram","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13})),(0,l.createElement)("a",{className:"dms-btn dms-btn-ghost dms-btn-sm",href:o.group_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Add to a group instead","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("The link works once and expires in 30 minutes.","digimail-smtp")))),(0,l.createElement)(b,{checked:t.prefs.email,disabled:"prefs"===m,onChange:e=>y({...t.prefs,email:e}),label:(0,i.__)("Email","digimail-smtp"),hint:(0,i.sprintf)(/* translators: %s: email addresses. */ /* translators: %s: email addresses. */(0,i.__)("To %s (the users of your DigiMail account).","digimail-smtp"),t.emails.join(", "))}),void 0!==t.prefs.weekly&&(0,l.createElement)(b,{checked:t.prefs.weekly,disabled:"prefs"===m,onChange:e=>y({...t.prefs,weekly:e}),label:(0,i.__)("Weekly summary by email","digimail-smtp"),hint:(0,i.__)("Every Monday morning: emails sent last week, delivery rate, spam blocked on each website and the month’s quota. Nothing is sent after a quiet week.","digimail-smtp")}),(0,l.createElement)("div",null,(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:"test"===m,disabled:!k,onClick:async()=>{r("test");try{const t=await c("alerts/test",{});e(t.telegram+t.email>0?(0,i.sprintf)(/* translators: 1: Telegram chats, 2: email addresses. */ /* translators: 1: Telegram chats, 2: email addresses. */(0,i.__)("Test alert sent: %1$s Telegram, %2$s email.","digimail-smtp"),d(t.telegram),d(t.email)):(0,i.__)("Nothing was sent: turn on email or connect Telegram first.","digimail-smtp"),t.telegram+t.email>0?"ok":"bad"),_()}catch(t){e(t.message,"bad")}finally{r("")}}},(0,l.createElement)(w,{name:"bell",size:14})," ",(0,i.__)("Send a test alert","digimail-smtp"))),t.recent.length>0&&(0,l.createElement)("div",{className:"dms-recent"},(0,l.createElement)("strong",{className:"dms-small"},(0,i.__)("Recent alerts","digimail-smtp")),(0,l.createElement)("ul",null,t.recent.slice(0,5).map(e=>(0,l.createElement)("li",{key:e.created_at+e.kind,title:e.body},(0,l.createElement)(h,{tone:Y[e.level]},p(e.created_at))," ",e.title))))))}function Q({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(e.settings),[m,r]=(0,l.useState)(null),o=e.status.sender,d=o?.verified_domains??[],[p,u]=(0,l.useState)("domain"===o?.mode?o.email:""),[g,_]=(0,l.useState)(e.site.user_email),k=JSON.stringify(s)!==JSON.stringify(e.settings),N=async(e,l=(0,i.__)("Settings saved.","digimail-smtp"))=>{r("save");try{const i=await c("settings",e??s);return t(i),n(i.settings),a(l),!0}catch(e){return a(e.message,"bad"),!1}finally{r(null)}},S=Object.entries(e.controls).reduce((e,[t,a])=>((e[a.group]=e[a.group]??[]).push([t,a]),e),{}),x=s.backup,M=e=>n({...s,backup:{...x,...e}});return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Sender","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Sender name","digimail-smtp"),htmlFor:"dms-name",hint:(0,i.__)("Leave empty to use the website name. Recipients see this name in their inbox.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-name",value:s.from_name,placeholder:o?.name??e.site.name,onChange:e=>n({...s,from_name:e.target.value})})),(0,l.createElement)(b,{checked:s.force_from_name,onChange:e=>n({...s,force_from_name:e}),label:(0,i.__)("Always use this name","digimail-smtp"),hint:(0,i.__)("Even when another plugin (WooCommerce, a contact form) sets its own sender name.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Sender email","digimail-smtp"),htmlFor:"dms-from",hint:d.length?(0,i.__)("Only addresses on domains verified in DigiMail can be used.","digimail-smtp"):(0,i.__)("Verify your domain on digimail.vn to send from your company email.","digimail-smtp")},d.length?(0,l.createElement)("select",{id:"dms-from",value:p,onChange:e=>u(e.target.value)},(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: email address chosen automatically. */ /* translators: %s: email address chosen automatically. */25 (0,i.__)("Automatic (%s)","digimail-smtp"),"domain"=== o?.mode?o.email:`noreply@${d[0]}`)),d.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).map(e=>(0,l.createElement)("option",{key:e,value:e},e)),p&&!d.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).includes(p)&&(0,l.createElement)("option",{value:p},p)):(0,l.createElement)("div",{className:"dms-readonly"},o?.email," ",(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")))),"shared"===o?.mode&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: reply-to email address. */ /* translators: %s: reply-to email address. */(0,i.__)("Replies go to <strong>%s</strong>.","digimail-smtp"),o.reply_to??e.site.admin_email),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"sender"===m,onClick:async()=>{r("sender");try{const e=await c("sender",{from_email:p,from_name:s.from_name});t(e),await N({from_name:s.from_name,force_from_name:s.force_from_name},(0,i.__)("Sender saved.","digimail-smtp"))}catch(e){a(e.message,"bad")}finally{r(null)}}},(0,i.__)("Save sender","digimail-smtp"))))),(0,l.createElement)(J,{state:e,setState:t}),(0,l.createElement)(K,null),(0,l.createElement)(E,{title:(0,i.__)("Sending email","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.queue,onChange:e=>n({...s,queue:e}),label:(0,i.__)("Background sending","digimail-smtp"),hint:(0,i.__)("Checkout and contact forms do not wait for email: messages are queued and sent right after. Recommended for online shops.","digimail-smtp")}),s.queue&&!e.env.cron&&(0,l.createElement)(v,{tone:"wait"},(0,l.createInterpolateElement)((0,i.__)("WP-Cron is off (DISABLE_WP_CRON). A server cron job must call wp-cron.php every minute, or run <code>wp digimail queue</code>.","digimail-smtp"),{code:(0,l.createElement)("code",null)})))),(0,l.createElement)(W,{state:e,s,setS:n}),(0,l.createElement)(V,{state:e,s,setS:n}),(0,l.createElement)(E,{title:(0,i.__)("Backup connection","digimail-smtp"),aside:x.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("When DigiMail cannot send (network down, quota used up), the plugin sends through this SMTP server so no email is lost. Your hosting SMTP, Gmail or Microsoft 365 all work.","digimail-smtp")),(0,l.createElement)(b,{checked:x.enabled,onChange:e=>M({enabled:e}),label:(0,i.__)("Turn on backup connection","digimail-smtp")}),x.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("SMTP server","digimail-smtp"),htmlFor:"dms-bh"},(0,l.createElement)("input",{id:"dms-bh",value:x.host,onChange:e=>M({host:e.target.value}),placeholder:"smtp.gmail.com"})),(0,l.createElement)(y,{label:(0,i.__)("Port","digimail-smtp"),htmlFor:"dms-bp"},(0,l.createElement)("input",{id:"dms-bp",type:"number",value:x.port,onChange:e=>M({port:Number(e.target.value)})}))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Encryption","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},[["tls","TLS (587)"],["ssl","SSL (465)"],["none",(0,i.__)("None","digimail-smtp")]].map(([e,t])=>(0,l.createElement)("button",{key:e,type:"button",className:x.encryption===e?"is-on":"",onClick:()=>M({encryption:e,port:"ssl"===e?465:"tls"===e?587:25})},t)))),(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("Username","digimail-smtp"),htmlFor:"dms-bu"},(0,l.createElement)("input",{id:"dms-bu",value:x.username,autoComplete:"off",onChange:e=>M({username:e.target.value})})),(0,l.createElement)(y,{label:(0,i.__)("Password","digimail-smtp"),htmlFor:"dms-bpw",hint:(0,i.__)("Encrypted when saved.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bpw",type:"password",autoComplete:"new-password",value:x.password,onChange:e=>M({password:e.target.value})}))),(0,l.createElement)(y,{label:(0,i.__)("From email on this server","digimail-smtp"),htmlFor:"dms-bf",hint:(0,i.__)("Leave empty to use the SMTP username.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bf",type:"email",value:x.from_email,onChange:e=>M({from_email:e.target.value})})),(0,l.createElement)("div",{className:"dms-inline"},(0,l.createElement)("input",{type:"email","aria-label":(0,i.__)("Send a test email to","digimail-smtp"),value:g,onChange:e=>_(e.target.value)}),(0,l.createElement)(f,{variant:"secondary",busy:"backup"===m,onClick:async()=>{if(!k||await N()){r("backup");try{await c("backup/test",{to:g}),a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("The backup server sent an email to %s.","digimail-smtp"),g))}catch(e){a(e.message,"bad")}finally{r(null)}}}},(0,i.__)("Save and send test","digimail-smtp")))))),(0,l.createElement)(E,{title:(0,i.__)("Turn off WordPress default emails","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Fewer unneeded emails for administrators. Order emails, contact forms and password resets are not affected.","digimail-smtp")),Object.entries(S).map(([e,t])=>(0,l.createElement)("div",{key:e,className:"dms-group"},(0,l.createElement)("h3",null,e),t.map(([e,t])=>(0,l.createElement)(b,{key:e,checked:!1!==s.controls[e],onChange:t=>{const a={...s.controls};t?delete a[e]:a[e]=!1,n({...s,controls:a})},label:t.label,hint:t.hint||void 0})))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-sticky"},(0,l.createElement)(E,{title:(0,i.__)("Save changes","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},k?(0,i.__)("You have unsaved changes.","digimail-smtp"):(0,i.__)("All changes are saved.","digimail-smtp")),(0,l.createElement)(f,{size:"block",busy:"save"===m,disabled:!k,onClick:()=>N()},(0,i.__)("Save settings","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Connection","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,e.status.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,e.status.account?.name),(0,l.createElement)("dt",null,(0,i.__)("Key","digimail-smtp")),(0,l.createElement)("dd",null,e.token_constant?(0,i.__)("Set in wp-config.php","digimail-smtp"):(0,i.__)("Stored in the database","digimail-smtp"))),(0,l.createElement)(b,{checked:s.keep_data,onChange:e=>n({...s,keep_data:e}),label:(0,i.__)("Keep settings when the plugin is deleted","digimail-smtp")}),(0,l.createElement)(b,{checked:!!s.diagnostics,onChange:e=>n({...s,diagnostics:e}),label:(0,i.__)("Share diagnostics with DigiMail support","digimail-smtp"),hint:(0,i.__)("Off by default. When on, the WordPress, PHP and WooCommerce versions, language, a few of this plugin's settings and the names of other active email plugins are sent with the twice-daily status check, so support can see problems on digimail.vn.","digimail-smtp")}),!e.token_constant&&(0,l.createElement)(f,{variant:"danger",size:"block",busy:"disconnect"===m,onClick:async()=>{window.confirm((0,i.__)("Disconnect DigiMail? The website will go back to sending email through your hosting server (or the backup server, if set).","digimail-smtp"))&&(r("disconnect"),await c("disconnect",{}),window.location.reload())}},(0,l.createElement)(w,{name:"x",size:15})," ",(0,i.__)("Disconnect DigiMail","digimail-smtp"))))))}function Z({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(null),m=e.conflicts.map(e=>e.name),r=[`DigiMail SMTP ${e.env.plugin}`,`WordPress ${e.env.wordpress}, PHP ${e.env.php}`,`Website: ${e.site.url}`,`Connected: ${e.connected?"yes":"no"}${e.revoked?" (revoked)":""}`,`From: ${e.status.sender?.email??"-"} (${e.status.sender?.mode??"-"})`,`Background sending: ${e.settings.queue?"on":"off"}, WP-Cron: ${e.env.cron?"on":"off"}`,`Backup: ${e.settings.backup.enabled?e.settings.backup.host:"off"}`,`Queue: ${e.queue.queued} waiting, ${e.queue.failed} failed`,`Other SMTP plugins: ${m.join(", ")||"none"}`].join("\n");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Switch from another SMTP plugin","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Imports the sender name and the emails you turned off. The old SMTP server becomes the backup connection: DigiMail sends, and the old server is used only when DigiMail cannot.","digimail-smtp")),0===e.importable.length?(0,l.createElement)(k,{title:(0,i.__)("No settings found to import","digimail-smtp")},(0,i.__)("Supports WP Mail SMTP, Easy WP SMTP, Post SMTP, FluentSMTP and SMTP Mailer.","digimail-smtp")):(0,l.createElement)("ul",{className:"dms-list"},e.importable.map(e=>(0,l.createElement)("li",{key:e.key},(0,l.createElement)("span",null,(0,l.createElement)("strong",null,e.name),m.includes(e.name)&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Active","digimail-smtp")),(0,l.createElement)("small",null,e.smtp?(0,i.__)("Has an SMTP server to use as backup","digimail-smtp"):(0,i.__)("Sender name only","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:s===e.key,onClick:()=>(async(e,l)=>{n(e);try{const s=await c("import",{from:e});t(s),a(s.settings.backup.host?(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s. The old SMTP server is now the backup connection.","digimail-smtp"),l):(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s.","digimail-smtp"),l))}catch(e){a(e.message,"bad")}finally{n(null)}})(e.key,e.name)},(0,i.__)("Import","digimail-smtp"))))),m.length>0&&(0,l.createElement)("p",{className:"dms-small"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("After importing, deactivate %s on the <a>Plugins page</a> so the two plugins do not both try to send email.","digimail-smtp"),m.join(", ")),{a:(0,l.createElement)("a",{href:"plugins.php"})}))),(0,l.createElement)(E,{title:(0,i.__)("Command line (WP-CLI)","digimail-smtp")},(0,l.createElement)("pre",{className:"dms-pre"},[`wp digimail status # ${(0,i.__)("connection, sender, quota","digimail-smtp")}`,`wp digimail test you@company.com # ${(0,i.__)("send a test email","digimail-smtp")}`,`wp digimail queue --retry-failed # ${(0,i.__)("resend waiting and failed emails","digimail-smtp")}`,"wp digimail connect you@company.com","wp digimail disconnect"].join("\n")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Agencies can set the key in wp-config.php:","digimail-smtp")," ",(0,l.createElement)("code",null,"define( 'DIGIMAIL_SMTP_TOKEN', 'dm_…' );")))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Support information","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard?.writeText(r),a((0,i.__)("Copied.","digimail-smtp"))}},(0,l.createElement)(w,{name:"download",size:14})," ",(0,i.__)("Copy","digimail-smtp"))},(0,l.createElement)("pre",{className:"dms-pre"},r),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send this when you contact DigiMail support. It contains no secret keys.","digimail-smtp")))))}const X=[{key:"modern",label:(0,i.__)("Modern","digimail-smtp"),hint:(0,i.__)("White card with a line in your colour","digimail-smtp")},{key:"minimal",label:(0,i.__)("Minimal","digimail-smtp"),hint:(0,i.__)("All white, logo in the middle","digimail-smtp")},{key:"bold",label:(0,i.__)("Bold","digimail-smtp"),hint:(0,i.__)("Your colour across the top","digimail-smtp")}],ee=[{key:"sans",label:(0,i.__)("Modern sans-serif","digimail-smtp")},{key:"serif",label:(0,i.__)("Classic serif","digimail-smtp")},{key:"rounded",label:(0,i.__)("Friendly","digimail-smtp")}],te=["#1b2550","#0f766e","#2563eb","#7c3aed","#db2777","#dc2626","#ea580c","#111827"];function ae({t:e,color:t}){return(0,l.createElement)("svg",{viewBox:"0 0 120 84",width:"100%","aria-hidden":"true"},(0,l.createElement)("rect",{width:"120",height:"84",rx:"6",fill:"minimal"===e?"#ffffff":"#eef0f3"}),"modern"===e&&(0,l.createElement)("rect",{x:"16",y:"8",width:"26",height:"5",rx:"2",fill:"#9aa1ad"}),(0,l.createElement)("rect",{x:"14",y:"modern"===e?18:10,width:"92",height:"modern"===e?60:68,rx:"5",fill:"#ffffff",stroke:"minimal"===e?"#e3e5e9":"none"}),"modern"===e&&(0,l.createElement)("rect",{x:"14",y:"18",width:"92",height:"3",rx:"1.5",fill:t}),"bold"===e&&(0,l.createElement)("path",{d:"M14 15a5 5 0 0 1 5-5h82a5 5 0 0 1 5 5v19H14z",fill:t}),"minimal"===e&&(0,l.createElement)("rect",{x:"48",y:"17",width:"24",height:"5",rx:"2",fill:"#9aa1ad"}),(0,l.createElement)("rect",{x:"minimal"===e?34:22,y:"bold"===e?22:28,width:"52",height:"6",rx:"2",fill:"bold"===e?"#ffffff":"#2b3040"}),[0,1,2].map(a=>(0,l.createElement)("rect",{key:a,x:22+26*a,y:"bold"===e?41:39,width:"23",height:"3",rx:"1.5",fill:a<2?t:"#dfe2e7"})),(0,l.createElement)("rect",{x:"22",y:"50",width:"76",height:"3",rx:"1.5",fill:"#e3e5e9"}),(0,l.createElement)("rect",{x:"22",y:"57",width:"64",height:"3",rx:"1.5",fill:"#e3e5e9"}),(0,l.createElement)("rect",{x:"22",y:"66",width:"28",height:"7",rx:"2.5",fill:t}))}function le({value:e,onChange:t}){return(0,l.createElement)("div",{className:"dms-logo-pick"},(0,l.createElement)("div",{className:"dms-logo-box"},e?(0,l.createElement)("img",{src:e,alt:""}):(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.__)("No logo: the shop name is shown","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>{const e=window.wp?.media;if(!e)return;const a=e({title:(0,i.__)("Choose a logo","digimail-smtp"),library:{type:"image"},multiple:!1,button:{text:(0,i.__)("Use this image","digimail-smtp")}});a.on("select",()=>{const e=a.state().get("selection").first().toJSON();t(e.sizes?.medium?.url??e.url)}),a.open()}},e?(0,i.__)("Change logo","digimail-smtp"):(0,i.__)("Choose a logo","digimail-smtp")),e&&(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>t("")},(0,i.__)("Remove","digimail-smtp"))))}function ie({label:e,value:t,onChange:a,swatches:i}){return(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},e),(0,l.createElement)("div",{className:"dms-color"},(0,l.createElement)("input",{type:"color",value:t,onChange:e=>a(e.target.value),"aria-label":e}),(0,l.createElement)("input",{type:"text",value:t,maxLength:7,onChange:e=>a(e.target.value),"aria-label":e}),i&&i.map(e=>(0,l.createElement)("button",{key:e,type:"button",className:"dms-swatch "+(e===t?"is-on":""),style:{background:e},"aria-label":e,onClick:()=>a(e)}))))}function se(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[o,d]=(0,l.useState)(""),[p,u]=(0,l.useState)(""),[g,_]=(0,l.useState)("desktop"),[k,N]=(0,l.useState)(!1),[S,x]=(0,l.useState)(""),[M,T]=(0,l.useState)(""),[D,F]=(0,l.useState)(""),[z,P]=(0,l.useState)(!1),[$,O]=(0,l.useState)(null),[A,I]=(0,l.useState)(""),L=(0,l.useRef)(0);(0,l.useEffect)(()=>{c("design").then(e=>{a(e),n(e.settings),r(JSON.stringify(e.settings)),u(e.types.find(e=>"WC_Email_Customer_Processing_Order"===e.id)?.id??e.types[0]?.id??"")}).catch(e=>d(e.message)),c("state").then(e=>I(e.site.admin_email)).catch(()=>{})},[]);const W=(0,l.useCallback)(async(e,t,a)=>{const l=++L.current;P(!0);try{const i=await c("design/preview",{type:t,settings:{...e,enabled:!a}});l===L.current&&(x(i.html),T(i.subject),F(""))}catch(e){l===L.current&&F(e.message)}finally{l===L.current&&P(!1)}},[]);if((0,l.useEffect)(()=>{if(!s||!p)return;const e=window.setTimeout(()=>W(s,p,k),350);return()=>window.clearTimeout(e)},[s,p,k,W]),o)return(0,l.createElement)(v,{tone:"bad"},o);if(!t||!s)return(0,l.createElement)("div",{className:"dms-skel",style:{height:520}});const j=(e,t)=>n({...s,[e]:t}),R=JSON.stringify(s)!==m,q=Array.from(new Set([...t.detected.palette??[],...te])).slice(0,8),B=async(t=s)=>{O("save");try{const a=await c("design/save",{settings:t});n(a.settings),r(JSON.stringify(a.settings)),e(a.settings.enabled?(0,i.__)("Saved. New emails use this design.","digimail-smtp"):(0,i.__)("Saved. The design is off.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{O(null)}},U=(e,t,a)=>(0,l.createElement)(y,{label:t,htmlFor:`dms-so-${e}`},(0,l.createElement)("input",{id:`dms-so-${e}`,type:"text",inputMode:"url",placeholder:a,value:s.socials[e],onChange:t=>j("socials",{...s.socials,[e]:t.target.value})}));return(0,l.createElement)("div",{className:"dms-design"},(0,l.createElement)("div",{className:"dms-design-side"},(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-design-on"},(0,l.createElement)(b,{checked:s.enabled,onChange:e=>B({...s,enabled:e}),disabled:"save"===$,label:(0,i.__)("Use this design for emails","digimail-smtp"),hint:s.enabled?(0,i.__)("On: new emails go out in this design.","digimail-smtp"):(0,i.__)("Off: emails look as they do now. Design and preview freely, nothing changes until you turn it on.","digimail-smtp")})),t.conflicts.length>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s also changes how emails look","digimail-smtp"),t.conflicts.join(", "))},(0,i.__)("Use one email designer at a time: deactivate the other plugin, or leave this design off.","digimail-smtp")),!t.woocommerce&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("WooCommerce is not active, so only the other WordPress emails can use the design.","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Template","digimail-smtp")},(0,l.createElement)("div",{className:"dms-templates"},X.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-tpl "+(s.template===e.key?"is-on":""),onClick:()=>j("template",e.key),"aria-pressed":s.template===e.key},(0,l.createElement)(ae,{t:e.key,color:s.color}),(0,l.createElement)("strong",null,e.label),(0,l.createElement)("span",null,e.hint))))),(0,l.createElement)(E,{title:(0,i.__)("Brand","digimail-smtp"),aside:(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>{const a=t.detected;n({...s,logo:a.logo??s.logo,color:a.color??s.color,company:a.company??s.company,email:a.email??s.email,address:a.address??s.address}),e((0,i.__)("Filled in from the website. Check the preview, then save.","digimail-smtp"))}},(0,l.createElement)(w,{name:"zap",size:14})," ",(0,i.__)("Fill in from the website","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Logo","digimail-smtp")),(0,l.createElement)(le,{value:s.logo,onChange:e=>j("logo",e)}),s.logo&&(0,l.createElement)("label",{className:"dms-range"},(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Width","digimail-smtp")),(0,l.createElement)("input",{type:"range",min:60,max:260,step:5,value:s.logo_width,onChange:e=>j("logo_width",Number(e.target.value))}),(0,l.createElement)("span",{className:"dms-small"},s.logo_width,"px"))),(0,l.createElement)(ie,{label:(0,i.__)("Brand colour","digimail-smtp"),value:s.color,onChange:e=>j("color",e),swatches:q}),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(ie,{label:(0,i.__)("Background","digimail-smtp"),value:s.bg,onChange:e=>j("bg",e)}),(0,l.createElement)(ie,{label:(0,i.__)("Text","digimail-smtp"),value:s.text,onChange:e=>j("text",e)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Font","digimail-smtp"),htmlFor:"dms-font"},(0,l.createElement)("select",{id:"dms-font",value:s.font,onChange:e=>j("font",e.target.value)},ee.map(e=>(0,l.createElement)("option",{key:e.key,value:e.key},e.label)))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Corners","digimail-smtp")),(0,l.createElement)("label",{className:"dms-range"},(0,l.createElement)("input",{type:"range",min:0,max:24,value:s.radius,onChange:e=>j("radius",Number(e.target.value)),"aria-label":(0,i.__)("Corners","digimail-smtp")}),(0,l.createElement)("span",{className:"dms-small"},s.radius,"px")))))),(0,l.createElement)(E,{title:(0,i.__)("Order emails","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.tracker,onChange:e=>j("tracker",e),label:(0,i.__)("Progress bar","digimail-smtp"),hint:(0,i.__)("Order placed → Processing → Completed, in the customer’s order emails.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.cta,onChange:e=>j("cta",e),label:(0,i.__)("Button under the order","digimail-smtp"),hint:(0,i.__)("View your order, Pay for this order, or Open the order in emails to the shop.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.images,onChange:e=>j("images",e),label:(0,i.__)("Product pictures","digimail-smtp")}))),(0,l.createElement)(E,{title:(0,i.__)("Footer","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Company or shop name","digimail-smtp"),htmlFor:"dms-company"},(0,l.createElement)("input",{id:"dms-company",type:"text",value:s.company,onChange:e=>j("company",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Address","digimail-smtp"),htmlFor:"dms-address"},(0,l.createElement)("input",{id:"dms-address",type:"text",value:s.address,onChange:e=>j("address",e.target.value)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Phone","digimail-smtp"),htmlFor:"dms-phone"},(0,l.createElement)("input",{id:"dms-phone",type:"text",inputMode:"tel",value:s.phone,onChange:e=>j("phone",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Email","digimail-smtp"),htmlFor:"dms-email"},(0,l.createElement)("input",{id:"dms-email",type:"email",value:s.email,onChange:e=>j("email",e.target.value)}))),(0,l.createElement)("div",{className:"dms-grid-2"},U("facebook","Facebook","https://facebook.com/…"),U("zalo","Zalo","https://zalo.me/…"),U("tiktok","TikTok","https://tiktok.com/@…"),U("instagram","Instagram","https://instagram.com/…")),U("youtube","YouTube","https://youtube.com/@…"),(0,l.createElement)(y,{label:(0,i.__)("Note at the bottom","digimail-smtp"),hint:(0,i.__)("For example your return policy or opening hours.","digimail-smtp"),htmlFor:"dms-note"},(0,l.createElement)("textarea",{id:"dms-note",rows:2,value:s.note,onChange:e=>j("note",e.target.value)})))),(0,l.createElement)(E,{title:(0,i.__)("Which emails","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.woo,onChange:e=>j("woo",e),disabled:!t.woocommerce,label:(0,i.__)("WooCommerce emails","digimail-smtp"),hint:(0,i.__)("Orders, invoices, accounts and refunds.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.wp,onChange:e=>j("wp",e),label:(0,i.__)("Other plain-text WordPress emails","digimail-smtp"),hint:(0,i.__)("Password resets, new users, form notifications that have no design of their own. Emails other plugins already design are left alone.","digimail-smtp")})))),(0,l.createElement)("div",{className:"dms-design-main"},(0,l.createElement)("div",{className:"dms-preview-bar"},(0,l.createElement)("select",{value:p,onChange:e=>u(e.target.value),"aria-label":(0,i.__)("Email to preview","digimail-smtp")},t.types.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},e.title))),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"desktop"===g?"is-on":"",onClick:()=>_("desktop")},(0,i.__)("Computer","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"mobile"===g?"is-on":"",onClick:()=>_("mobile")},(0,i.__)("Phone","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:k?"":"is-on",onClick:()=>N(!1)},(0,i.__)("New design","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:k?"is-on":"",onClick:()=>N(!0)},(0,i.__)("As it is now","digimail-smtp"))),z&&(0,l.createElement)("span",{className:"dms-spin","aria-label":(0,i.__)("Loading","digimail-smtp")})),(0,l.createElement)("div",{className:`dms-inbox is-${g}`},(0,l.createElement)("div",{className:"dms-inbox-head"},(0,l.createElement)("span",{className:"dms-avatar",style:{background:s.color}},(s.company||"S").trim().charAt(0).toUpperCase()),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,s.company||(0,i.__)("Your shop","digimail-smtp")),(0,l.createElement)("span",null,M))),D?(0,l.createElement)("div",{className:"dms-preview-err"},(0,l.createElement)(v,{tone:"bad"},D)):(0,l.createElement)("iframe",{title:(0,i.__)("Email preview","digimail-smtp"),sandbox:"allow-popups",srcDoc:S})),(0,l.createElement)("div",{className:"dms-design-actions"},(0,l.createElement)("form",{className:"dms-row",onSubmit:t=>{t.preventDefault(),(async()=>{O("test");try{await c("design/test",{type:p,to:A,settings:{...s,enabled:!0}}),e((0,i.__)("Test email sent. Check the inbox.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{O(null)}})()}},(0,l.createElement)("input",{type:"email",required:!0,value:A,onChange:e=>I(e.target.value),"aria-label":(0,i.__)("Send to","digimail-smtp")}),(0,l.createElement)(f,{type:"submit",variant:"secondary",busy:"test"===$},(0,l.createElement)(w,{name:"send",size:14})," ",(0,i.__)("Send a test","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-row"},R&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Not saved","digimail-smtp")),(0,l.createElement)(f,{busy:"save"===$,disabled:!R,onClick:()=>B()},(0,i.__)("Save design","digimail-smtp"))))))}const ne=e=>`${Math.round(e).toLocaleString("vi-VN")}₫`,me={welcome:(0,i.__)("Welcome new subscribers","digimail-smtp"),order_followup:(0,i.__)("Thank-you after purchase","digimail-smtp"),abandoned_cart:(0,i.__)("Abandoned cart reminder","digimail-smtp"),review_request:(0,i.__)("Review request","digimail-smtp")};function re(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(null),[o,u]=(0,l.useState)(""),g=e=>{a(e),n({...e.settings})};if((0,l.useEffect)(()=>{c("shop").then(g).catch(e=>u(e.message))},[]),o&&!t)return(0,l.createElement)(v,{tone:"bad"},o);if(!t||!s)return(0,l.createElement)("div",{className:"dms-skel",style:{height:360}});if(!t.woocommerce)return(0,l.createElement)(v,{tone:"info",title:(0,i.__)("WooCommerce is not active","digimail-smtp")},(0,i.__)("Turn on WooCommerce to use the shop emails.","digimail-smtp"));const _=async t=>{r("save");try{g(await c("shop/save",t)),e(t.enabled?(0,i.__)("Shop settings saved.","digimail-smtp"):(0,i.__)("Shop emails are off.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{r(null)}},k=e=>n({...s,...e}),N=JSON.stringify(s)!==JSON.stringify(t.settings),S=t.summary?.automations.filter(e=>"welcome"!==e.kind)??[],x=t.summary?.manage_url??`${t.app}/app/tu-dong`;return t.settings.enabled?(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Shop emails","digimail-smtp"),aside:(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:x,target:"_blank",rel:"noreferrer"},(0,i.__)("Edit on digimail.vn","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:14}))},t.error&&(0,l.createElement)("p",{className:"dms-error"},t.error),t.summary&&(0,l.createElement)("div",{className:"dms-kpis dms-kpis-2"},(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Revenue from email, 30 days","digimail-smtp")),(0,l.createElement)("strong",null,ne(t.summary.email_revenue_30d))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Orders from email, 30 days","digimail-smtp")),(0,l.createElement)("strong",null,d(t.summary.email_orders_30d)),(0,l.createElement)("em",null,(0,i.__)("Clicked an email in the 7 days before paying","digimail-smtp")))),t.summary&&0===S.length&&(0,l.createElement)("div",{className:"dms-empty-inline"},(0,l.createElement)("p",null,(0,i.__)("No email series yet. Pick one on digimail.vn: the text is ready, you only turn it on.","digimail-smtp")),(0,l.createElement)("a",{className:"dms-btn dms-btn-primary",href:x,target:"_blank",rel:"noreferrer"},(0,i.__)("Set up shop emails","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:14}))),S.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Email series","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Sent","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Orders","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Revenue","digimail-smtp")))),(0,l.createElement)("tbody",null,S.map(e=>(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)("a",{href:e.url,target:"_blank",rel:"noreferrer"},e.name),(0,l.createElement)("div",{className:"dms-small dms-muted"},me[e.kind]??"")),(0,l.createElement)("td",null,"active"===e.status?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Running","digimail-smtp")):"paused"===e.status?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Paused","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Draft","digimail-smtp"))),(0,l.createElement)("td",{className:"num"},d(e.sent)),(0,l.createElement)("td",{className:"num"},d(e.orders)),(0,l.createElement)("td",{className:"num"},e.orders?ne(e.revenue):"–"))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("span",{className:"dms-small dms-muted"},t.last?.error?(0,i.sprintf)(/* translators: %s: error message. */ /* translators: %s: error message. */(0,i.__)("Last sync failed: %s","digimail-smtp"),t.last.error):t.last?(0,i.sprintf)(/* translators: %s: time. */ /* translators: %s: time. */(0,i.__)("Orders and carts last sent %s.","digimail-smtp"),p(new Date(1e3*t.last.at).toISOString())):(0,i.__)("Orders show up on digimail.vn a few seconds after they are placed.","digimail-smtp"),t.pending>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of items waiting. */ /* translators: %s: number of items waiting. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),d(t.pending)))),t.pending>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"===m,onClick:async()=>{r("sync");try{g(await c("shop/sync",{}))}catch(t){e(t.message,"bad")}finally{r(null)}}},(0,i.__)("Send now","digimail-smtp"))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Checkout","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.optin,onChange:e=>k({optin:e}),label:(0,i.__)("Show an “email me news” checkbox","digimail-smtp"),hint:(0,i.__)("Unticked by default. Shoppers who tick it join your contact list, and shop emails go to them.","digimail-smtp")}),s.optin&&(0,l.createElement)(y,{label:(0,i.__)("Checkbox text","digimail-smtp"),htmlFor:"dms-optin-label"},(0,l.createElement)("input",{id:"dms-optin-label",type:"text",maxLength:200,value:s.optin_label,onChange:e=>k({optin_label:e.target.value}),placeholder:t.default_label})),(0,l.createElement)(b,{checked:s.carts,onChange:e=>k({carts:e}),label:(0,i.__)("Save carts for the reminder email","digimail-smtp"),hint:(0,i.__)("When a shopper types their email at checkout, the cart is kept for 30 days. A short note under the email field tells them.","digimail-smtp")}),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>_({...s,enabled:!1})},(0,i.__)("Turn off shop emails","digimail-smtp")),(0,l.createElement)(f,{disabled:!N,busy:"save"===m,onClick:()=>_(s)},(0,i.__)("Save","digimail-smtp"))),!t.blocks&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Your WooCommerce shows the checkbox on the classic checkout only. Update WooCommerce to show it on the block checkout too.","digimail-smtp")))))):(0,l.createElement)("div",{className:"dms-shop-intro"},(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-shop-hero"},(0,l.createElement)("div",{className:"dms-shop-icon"},(0,l.createElement)(w,{name:"cart",size:22})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Emails that sell for your shop","digimail-smtp")),(0,l.createElement)("p",null,(0,i.__)("DigiMail sends these by itself, from your own domain, with the products of each order:","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-checks"},(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A thank-you after payment, and a check-in 7 days later.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A reminder when a shopper leaves checkout, with a button that brings their cart back.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A review request a few days after the order is completed.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("An unticked “Email me news and offers” checkbox at checkout, so you only email people who agreed.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A report of the revenue that came from your emails.","digimail-smtp"))),(0,l.createElement)(f,{busy:"save"===m,onClick:()=>_({...s,enabled:!0})},(0,i.__)("Turn on shop emails","digimail-smtp")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("This sends each order and saved cart (email, name, products, total) to your DigiMail account. Nothing is emailed until you turn on an email series on digimail.vn.","digimail-smtp"))))))}const ce=[{key:"popup",label:(0,i.__)("Popup","digimail-smtp"),hint:(0,i.__)("In the middle of the screen, after a few seconds, a scroll or when the visitor is about to leave.","digimail-smtp")},{key:"slide",label:(0,i.__)("Slide-in","digimail-smtp"),hint:(0,i.__)("A small box in the corner. Noticed without getting in the way.","digimail-smtp")},{key:"bar",label:(0,i.__)("Bar","digimail-smtp"),hint:(0,i.__)("A thin strip across the top or bottom of every page.","digimail-smtp")},{key:"inline",label:(0,i.__)("In the page","digimail-smtp"),hint:(0,i.__)("Inside a page or after each blog post, with a shortcode.","digimail-smtp")}],oe=[{key:"card",label:(0,i.__)("Card","digimail-smtp")},{key:"split",label:(0,i.__)("With picture","digimail-smtp")},{key:"minimal",label:(0,i.__)("Simple","digimail-smtp")},{key:"bold",label:(0,i.__)("Colour block","digimail-smtp")}],de=e=>ce.find(t=>t.key===e)?.label??e;function pe({type:e,color:t}){return(0,l.createElement)("svg",{viewBox:"0 0 120 76",width:"100%","aria-hidden":"true"},(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"74",rx:"6",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"10",y:"12",width:"56",height:"5",rx:"2.5",fill:"#e6e8ed"}),(0,l.createElement)("rect",{x:"10",y:"22",width:"90",height:"4",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"10",y:"30",width:"80",height:"4",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"10",y:"38",width:"86",height:"4",rx:"2",fill:"#eef0f3"}),"popup"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"74",rx:"6",fill:"#14182b",opacity:".35"}),(0,l.createElement)("rect",{x:"30",y:"16",width:"60",height:"44",rx:"5",fill:"#fff"}),(0,l.createElement)("rect",{x:"38",y:"24",width:"36",height:"4",rx:"2",fill:"#14182b"}),(0,l.createElement)("rect",{x:"38",y:"36",width:"44",height:"7",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"38",y:"46",width:"44",height:"7",rx:"2",fill:t})),"slide"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"70",y:"40",width:"44",height:"31",rx:"4",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"76",y:"46",width:"24",height:"3",rx:"1.5",fill:"#14182b"}),(0,l.createElement)("rect",{x:"76",y:"54",width:"32",height:"5",rx:"1.5",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"76",y:"61",width:"32",height:"5",rx:"1.5",fill:t})),"bar"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"9",fill:t}),(0,l.createElement)("rect",{x:"30",y:"4",width:"34",height:"3",rx:"1.5",fill:"#fff",opacity:".9"}),(0,l.createElement)("rect",{x:"68",y:"3.5",width:"20",height:"4",rx:"1",fill:"#fff"})),"inline"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"10",y:"48",width:"100",height:"20",rx:"4",fill:"#f6f7f9",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"16",y:"54",width:"54",height:"8",rx:"2",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"74",y:"54",width:"30",height:"8",rx:"2",fill:t})))}function ue({value:e,onChange:t}){return(0,l.createElement)("div",{className:"dms-row"},e&&(0,l.createElement)("img",{src:e,alt:"",className:"dms-form-thumb"}),(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>{const e=window.wp?.media;if(!e)return;const a=e({title:(0,i.__)("Choose a picture","digimail-smtp"),library:{type:"image"},multiple:!1,button:{text:(0,i.__)("Use this image","digimail-smtp")}});a.on("select",()=>{const e=a.state().get("selection").first().toJSON();t(e.sizes?.large?.url??e.url)}),a.open()}},e?(0,i.__)("Change picture","digimail-smtp"):(0,i.__)("Choose a picture","digimail-smtp")),e&&(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>t("")},(0,i.__)("Remove","digimail-smtp")))}function ge({id:e}){const t=C(),a=`[digimail_form id="${e}"]`;return(0,l.createElement)("button",{type:"button",className:"dms-code-btn",onClick:()=>navigator.clipboard?.writeText(a).then(()=>t((0,i.__)("Shortcode copied.","digimail-smtp"))),title:(0,i.__)("Copy","digimail-smtp")},(0,l.createElement)("code",null,a)," ",(0,l.createElement)(w,{name:"copy",size:14}))}function _e(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(null),[o,p]=(0,l.useState)("");if((0,l.useEffect)(()=>{c("forms").then(a).catch(e=>n(e.message))},[]),s&&!t)return(0,l.createElement)(v,{tone:"bad"},s);if(!t)return(0,l.createElement)("div",{className:"dms-skel",style:{height:360}});const u=async(t,l=!1)=>{p("save");try{const s=await c("forms/save",t);return a(s),s.form&&r(s.form),l||e("on"===t.status?(0,i.__)("Saved. The form is live on your site.","digimail-smtp"):(0,i.__)("Saved. The form is off.","digimail-smtp")),s.form??null}catch(t){return e(t.message,"bad"),null}finally{p("")}};if(m)return(0,l.createElement)(he,{form:m,screen:t,busy:"save"===o,onSave:u,onBack:()=>r(null),onDelete:async t=>{if(window.confirm((0,i.sprintf)(/* translators: %s: form name. */ /* translators: %s: form name. */(0,i.__)("Delete “%s”? Its numbers are deleted too. People who signed up stay in your DigiMail list.","digimail-smtp"),t.name)))try{a(await c("forms/delete",{id:t.id})),r(null)}catch(t){e(t.message,"bad")}}});const g=(0,l.createElement)("div",{className:"dms-form-types"},ce.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-form-type",onClick:()=>{return a=e.key,r({...t.defaults[a],id:"",created:0});var a}},(0,l.createElement)(pe,{type:e.key,color:t.defaults.popup.color}),(0,l.createElement)("strong",null,e.label),(0,l.createElement)("span",null,e.hint))));return 0===t.forms.length?(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-forms-intro"},(0,l.createElement)("h2",null,(0,i.__)("Grow your email list from your website","digimail-smtp")),(0,l.createElement)("p",null,(0,i.__)("Visitors who sign up go straight into your DigiMail contact list, ready for campaigns and the welcome email series. The spam guard keeps bots out. Pick a kind of form to start:","digimail-smtp")),g)):(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Signup forms","digimail-smtp")},(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Views","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Signups","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Rate","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,t.forms.map(e=>(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)("button",{type:"button",className:"dms-link-btn",onClick:()=>r(e)},e.name),(0,l.createElement)("div",{className:"dms-small dms-muted"},de(e.type)),"inline"===e.type&&"shortcode"===e.placement&&(0,l.createElement)(ge,{id:e.id})),(0,l.createElement)("td",null,(0,l.createElement)("label",{className:"dms-switch-inline"},(0,l.createElement)("input",{type:"checkbox",checked:"on"===e.status,onChange:t=>u({...e,status:t.target.checked?"on":"off"})}),"on"===e.status?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp")))),(0,l.createElement)("td",{className:"num"},d(e.views??0)),(0,l.createElement)("td",{className:"num"},d(e.signups??0)),(0,l.createElement)("td",{className:"num"},e.views?`${((e.signups??0)/e.views*100).toFixed(1)}%`:"–"),(0,l.createElement)("td",{className:"num"},(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>r(e)},(0,i.__)("Edit","digimail-smtp"))," ",(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>r({...e,id:"",name:(0,i.sprintf)(/* translators: %s: form name. */ /* translators: %s: form name. */(0,i.__)("%s (copy)","digimail-smtp"),e.name),status:"off",created:0}),"aria-label":(0,i.__)("Duplicate","digimail-smtp")},(0,l.createElement)(w,{name:"copy",size:15})))))))),(0,l.createElement)(E,{title:(0,i.__)("New form","digimail-smtp")},g))}function he({form:e,screen:t,busy:a,onSave:s,onBack:n,onDelete:m}){const[r,o]=(0,l.useState)(e),[p,u]=(0,l.useState)("desktop"),[g,_]=(0,l.useState)(""),[k,N]=(0,l.useState)(!1),S=(0,l.useRef)(void 0),C=(0,l.useRef)(JSON.stringify(e)),x=JSON.stringify(r)!==C.current,M=(e,t)=>o(a=>({...a,[e]:t}));(0,l.useEffect)(()=>(window.clearTimeout(S.current),S.current=window.setTimeout(()=>{N(!0),c("forms/preview",{form:r,device:p}).then(e=>_(e.html)).catch(()=>{}).then(()=>N(!1))},350),()=>window.clearTimeout(S.current)),[r,p]);const T=async e=>{const t=e?{...r,status:e}:r,a=await s(t);a&&(C.current=JSON.stringify(a),o(a))},D="inline"!==r.type;return(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-form-top"},(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:n},(0,l.createElement)(w,{name:"back",size:15})," ",(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("input",{className:"dms-form-name",value:r.name,onChange:e=>M("name",e.target.value),"aria-label":(0,i.__)("Form name (only you see it)","digimail-smtp"),maxLength:80}),(0,l.createElement)(h,null,de(r.type)),(0,l.createElement)("span",{className:"dms-grow"}),x&&(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Unsaved changes","digimail-smtp")),r.id&&(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>m(r),"aria-label":(0,i.__)("Delete form","digimail-smtp")},(0,l.createElement)(w,{name:"trash",size:15})),"on"===r.status?(0,l.createElement)(l.Fragment,null,(0,l.createElement)(f,{variant:"secondary",busy:a,onClick:()=>T("off")},(0,i.__)("Turn off","digimail-smtp")),(0,l.createElement)(f,{busy:a,disabled:!x,onClick:()=>T()},(0,i.__)("Save","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)(f,{variant:"secondary",busy:a,onClick:()=>T("off"),disabled:!x&&!!r.id},(0,i.__)("Save as draft","digimail-smtp")),(0,l.createElement)(f,{busy:a,onClick:()=>T("on")},(0,i.__)("Save and turn on","digimail-smtp")))),!t.guard&&(0,l.createElement)(v,{tone:"wait"},(0,i.__)("The spam guard is off, so bots can sign up through this form. Turn it on in Settings.","digimail-smtp")),(0,l.createElement)("div",{className:"dms-design"},(0,l.createElement)("div",{className:"dms-design-side"},(0,l.createElement)(E,{title:(0,i.__)("Design","digimail-smtp")},(0,l.createElement)("div",{className:"dms-templates dms-templates-4"},oe.filter(e=>!("bar"===r.type&&"split"===e.key)).map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-tpl "+(r.template===e.key?"is-on":""),onClick:()=>M("template",e.key),"aria-pressed":r.template===e.key},(0,l.createElement)("span",{className:`dms-tpl-art dms-tpl-${e.key}`,style:{"--c":r.color}},(0,l.createElement)("i",null),(0,l.createElement)("b",null),(0,l.createElement)("em",null)),(0,l.createElement)("strong",null,e.label)))),(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(ie,{label:(0,i.__)("Colour","digimail-smtp"),value:r.color,onChange:e=>M("color",e),swatches:["#1b2550","#0f766e","#c2410c","#be123c","#7c3aed","#111827"]}),"split"===r.template&&(0,l.createElement)(y,{label:(0,i.__)("Picture","digimail-smtp")},(0,l.createElement)(ue,{value:r.image,onChange:e=>M("image",e)})))),(0,l.createElement)(E,{title:(0,i.__)("Form text","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Title","digimail-smtp"),htmlFor:"dmf-title"},(0,l.createElement)("input",{id:"dmf-title",value:r.title,maxLength:120,onChange:e=>M("title",e.target.value)})),"bar"!==r.type&&(0,l.createElement)(y,{label:(0,i.__)("Description","digimail-smtp"),htmlFor:"dmf-text"},(0,l.createElement)("textarea",{id:"dmf-text",rows:3,value:r.text,maxLength:400,onChange:e=>M("text",e.target.value)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Button","digimail-smtp"),htmlFor:"dmf-btn"},(0,l.createElement)("input",{id:"dmf-btn",value:r.button,maxLength:40,onChange:e=>M("button",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Email box hint","digimail-smtp"),htmlFor:"dmf-ph"},(0,l.createElement)("input",{id:"dmf-ph",value:r.email_ph,maxLength:60,onChange:e=>M("email_ph",e.target.value)}))),"bar"!==r.type&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(b,{checked:r.ask_name,onChange:e=>M("ask_name",e),label:(0,i.__)("Ask for a name","digimail-smtp"),hint:(0,i.__)("Lets your emails greet people by name. Each extra field means a few fewer signups.","digimail-smtp")}),(0,l.createElement)(b,{checked:r.ask_phone,onChange:e=>M("ask_phone",e),label:(0,i.__)("Ask for a phone number (optional for the visitor)","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Small print under the button","digimail-smtp"),htmlFor:"dmf-consent"},(0,l.createElement)("input",{id:"dmf-consent",value:r.consent,maxLength:240,onChange:e=>M("consent",e.target.value)}))))),(0,l.createElement)(E,{title:D?(0,i.__)("When and where it shows","digimail-smtp"):(0,i.__)("Where it goes","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},D&&"bar"!==r.type&&(0,l.createElement)(y,{label:(0,i.__)("Show it","digimail-smtp"),htmlFor:"dmf-trigger"},(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("select",{id:"dmf-trigger",value:r.trigger,onChange:e=>M("trigger",e.target.value)},(0,l.createElement)("option",{value:"delay"},(0,i.__)("After some seconds","digimail-smtp")),(0,l.createElement)("option",{value:"scroll"},(0,i.__)("After scrolling part of the page","digimail-smtp")),(0,l.createElement)("option",{value:"exit"},(0,i.__)("When the visitor is about to leave","digimail-smtp"))),"delay"===r.trigger&&(0,l.createElement)("label",{className:"dms-inline-num"},(0,l.createElement)("input",{type:"number",min:0,max:300,value:r.delay,onChange:e=>M("delay",Number(e.target.value))})," ",(0,i.__)("seconds","digimail-smtp")),"scroll"===r.trigger&&(0,l.createElement)("label",{className:"dms-inline-num"},(0,l.createElement)("input",{type:"number",min:5,max:100,value:r.scroll,onChange:e=>M("scroll",Number(e.target.value))})," %")),"exit"===r.trigger&&(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("On phones, which have no mouse, it shows after 20 seconds instead.","digimail-smtp"))),"slide"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Corner","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"left"===r.position?"is-on":"",onClick:()=>M("position","left")},(0,i.__)("Bottom left","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"left"!==r.position?"is-on":"",onClick:()=>M("position","right")},(0,i.__)("Bottom right","digimail-smtp")))),"bar"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Position","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"bottom"!==r.position?"is-on":"",onClick:()=>M("position","top")},(0,i.__)("Top of the page","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"bottom"===r.position?"is-on":"",onClick:()=>M("position","bottom")},(0,i.__)("Bottom of the screen","digimail-smtp")))),"inline"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Place","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"shortcode"===r.placement?"is-on":"",onClick:()=>M("placement","shortcode")},(0,i.__)("Where I paste the shortcode","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"after_post"===r.placement?"is-on":"",onClick:()=>M("placement","after_post")},(0,i.__)("After every blog post","digimail-smtp"))),"shortcode"===r.placement&&(r.id?(0,l.createElement)(ge,{id:r.id}):(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Save the form to get its shortcode.","digimail-smtp")))),(D||"after_post"===r.placement)&&(0,l.createElement)("div",{className:"dms-grid-2"},D&&(0,l.createElement)(y,{label:(0,i.__)("Pages","digimail-smtp"),htmlFor:"dmf-pages"},(0,l.createElement)("select",{id:"dmf-pages",value:r.pages,onChange:e=>M("pages",e.target.value)},(0,l.createElement)("option",{value:"all"},(0,i.__)("Every page","digimail-smtp")),(0,l.createElement)("option",{value:"home"},(0,i.__)("Home page only","digimail-smtp")),(0,l.createElement)("option",{value:"posts"},(0,i.__)("Blog posts","digimail-smtp")),(0,l.createElement)("option",{value:"pages"},(0,i.__)("Pages","digimail-smtp")),(0,l.createElement)("option",{value:"shop"},(0,i.__)("Shop and product pages","digimail-smtp")))),(0,l.createElement)(y,{label:(0,i.__)("Devices","digimail-smtp"),htmlFor:"dmf-dev"},(0,l.createElement)("select",{id:"dmf-dev",value:r.devices,onChange:e=>M("devices",e.target.value)},(0,l.createElement)("option",{value:"all"},(0,i.__)("Computers and phones","digimail-smtp")),(0,l.createElement)("option",{value:"desktop"},(0,i.__)("Computers only","digimail-smtp")),(0,l.createElement)("option",{value:"mobile"},(0,i.__)("Phones only","digimail-smtp"))))),D&&(0,l.createElement)(y,{label:(0,i.__)("After someone closes it","digimail-smtp"),htmlFor:"dmf-again"},(0,l.createElement)("label",{className:"dms-inline-num"},(0,i.__)("Show again after","digimail-smtp")," ",(0,l.createElement)("input",{id:"dmf-again",type:"number",min:0,max:365,value:r.again,onChange:e=>M("again",Number(e.target.value))})," ",(0,i.__)("days","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("People who sign up never see it again. Checkout, cart and account pages never show forms.","digimail-smtp"))),(0,l.createElement)(b,{checked:r.logged,onChange:e=>M("logged",e),label:(0,i.__)("Also show to logged-in users","digimail-smtp")}))),(0,l.createElement)(E,{title:(0,i.__)("After signing up","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Add to the DigiMail list","digimail-smtp"),htmlFor:"dmf-list"},(0,l.createElement)("select",{id:"dmf-list",value:r.list_id,onChange:e=>M("list_id",e.target.value)},(0,l.createElement)("option",{value:""},t.site_list?(0,i.sprintf)(/* translators: %s: list name. */ /* translators: %s: list name. */(0,i.__)("This website’s list (%s)","digimail-smtp"),t.site_list):(0,i.__)("This website’s list","digimail-smtp")),t.lists.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},e.name," (",d(e.subscribed),")")))),(0,l.createElement)(b,{checked:r.confirm,onChange:e=>M("confirm",e),label:(0,i.__)("Ask people to confirm by email (double opt-in)","digimail-smtp"),hint:(0,i.__)("They join the list only after clicking the link in a confirmation email. Fewer signups, but every address is real and wanted.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Message after signing up","digimail-smtp"),htmlFor:"dmf-ok"},(0,l.createElement)("input",{id:"dmf-ok",value:r.confirm?r.pending:r.success,maxLength:200,onChange:e=>M(r.confirm?"pending":"success",e.target.value)})),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("To send a welcome email, turn on the “Welcome new subscribers” series for this list on digimail.vn (Automation).","digimail-smtp"))))),(0,l.createElement)("div",{className:"dms-design-main"},(0,l.createElement)("div",{className:"dms-preview-bar"},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"desktop"===p?"is-on":"",onClick:()=>u("desktop")},(0,i.__)("Computer","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"mobile"===p?"is-on":"",onClick:()=>u("mobile")},(0,i.__)("Phone","digimail-smtp"))),k&&(0,l.createElement)("span",{className:"dms-spin","aria-label":(0,i.__)("Loading","digimail-smtp")}),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Preview: try the form, nothing is sent.","digimail-smtp"))),(0,l.createElement)("div",{className:`dms-form-stage is-${p}`},(0,l.createElement)("iframe",{title:(0,i.__)("Form preview","digimail-smtp"),srcDoc:g,sandbox:"allow-scripts"})))))}const Ee=[{key:"overview",label:(0,i.__)("Overview","digimail-smtp"),icon:"chart"},{key:"logs",label:(0,i.__)("Email log","digimail-smtp"),icon:"list"},{key:"contacts",label:(0,i.__)("Customers","digimail-smtp"),icon:"users"},{key:"forms",label:(0,i.__)("Signup forms","digimail-smtp"),icon:"form"},{key:"test",label:(0,i.__)("Test email","digimail-smtp"),icon:"send"},{key:"design",label:(0,i.__)("Email design","digimail-smtp"),icon:"palette"},{key:"shop",label:(0,i.__)("Shop","digimail-smtp"),icon:"cart"},{key:"settings",label:(0,i.__)("Settings","digimail-smtp"),icon:"settings"},{key:"tools",label:(0,i.__)("Tools","digimail-smtp"),icon:"tools"}],fe=()=>{const e=window.location.hash.replace("#","");return Ee.some(t=>t.key===e)?e:"overview"},be=document.getElementById("digimail-smtp-app");if(be){const e=(0,l.createElement)(function({children:e}){const[t,a]=(0,l.useState)([]),i=(0,l.useCallback)((e,t="ok")=>{const l=Date.now()+Math.random();a(a=>[...a,{id:l,msg:e,tone:t}]),setTimeout(()=>a(e=>e.filter(e=>e.id!==l)),4500)},[]);return(0,l.createElement)(S.Provider,{value:i},e,(0,l.createElement)("div",{className:"dms-toasts",role:"status","aria-live":"polite"},t.map(e=>(0,l.createElement)("div",{key:e.id,className:`dms-toast dms-toast-${e.tone}`},(0,l.createElement)(w,{name:"ok"===e.tone?"check":"alert",size:16}),e.msg))))},null,(0,l.createElement)(function(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(fe),[o,d]=(0,l.useState)(!1),p=(0,l.useCallback)(async(e=!1)=>{try{a(await c("state"+(e?"?refresh=1":""))),n("")}catch(e){n(e.message)}},[]);(0,l.useEffect)(()=>{p();const t=window.digimailSmtp?.flash;t&&e(t.message,t.ok?"ok":"bad")},[p,e]),(0,l.useEffect)(()=>{const e=()=>r(fe());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);const u=e=>{window.location.hash=e,r(e),window.scrollTo({top:0})};if(s&&!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("DigiMail SMTP could not load","digimail-smtp")},s));if(!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("div",{className:"dms-skel",style:{height:420}}));if(!t.connected)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(M,{state:t,reload:async()=>{await p(!0),d(!0),u("overview")}}));const g=t.status.sender;return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("header",{className:"dms-top"},(0,l.createElement)("div",{className:"dms-brand"},(0,l.createElement)("img",{src:window.digimailSmtp?.logo,alt:"",width:30,height:30}),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,"DigiMail SMTP"),(0,l.createElement)("span",null,t.revoked?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Disconnected","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i._x)("Active","connection status","digimail-smtp"))))),(0,l.createElement)("nav",{className:"dms-tabs","aria-label":"DigiMail SMTP"},Ee.filter(e=>"shop"!==e.key||t.capture.woocommerce).map(e=>(0,l.createElement)("a",{key:e.key,href:`#${e.key}`,className:m===e.key?"is-on":"","aria-current":m===e.key?"page":void 0,onClick:t=>{t.preventDefault(),u(e.key)}},(0,l.createElement)(w,{name:e.icon,size:16}),e.label,"logs"===e.key&&t.queue.failed>0&&(0,l.createElement)("span",{className:"dms-count"},t.queue.failed))))),t.revoked&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("This website was disconnected on digimail.vn","digimail-smtp"),action:(0,l.createElement)(f,{onClick:async()=>{await c("disconnect",{}),p(!0)}},(0,i.__)("Reconnect","digimail-smtp"))},t.settings.backup.enabled?(0,i.__)("Email is not going through DigiMail. The backup server is sending it.","digimail-smtp"):(0,i.__)("Email is not going through DigiMail.","digimail-smtp")),o&&g&&(0,l.createElement)("div",{className:"dms-welcome"},(0,l.createElement)("div",{className:"dms-welcome-icon"},(0,l.createElement)(w,{name:"check",size:28})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Done! This website can send email now.","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender email address. */ /* translators: %s: sender email address. */(0,i.__)("Email will be sent from <strong>%s</strong>. Send a test email to make sure everything works.","digimail-smtp"),g.email),{strong:(0,l.createElement)("strong",null)}))),(0,l.createElement)(f,{onClick:()=>{d(!1),u("test")}},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send a test email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Close","digimail-smtp"),onClick:()=>d(!1)},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("main",null,"overview"===m&&(0,l.createElement)(z,{state:t,go:u}),"logs"===m&&(0,l.createElement)(L,{reload:()=>p()}),"contacts"===m&&(0,l.createElement)(B,{state:t,go:u}),"test"===m&&(0,l.createElement)(U,{state:t,go:u}),"design"===m&&(0,l.createElement)(se,null),"shop"===m&&(0,l.createElement)(re,null),"forms"===m&&(0,l.createElement)(_e,null),"settings"===m&&(0,l.createElement)(Q,{state:t,setState:a}),"tools"===m&&(0,l.createElement)(Z,{state:t,setState:a})),(0,l.createElement)("footer",{className:"dms-foot"},"DigiMail SMTP ",t.env.plugin," · ",(0,l.createElement)("a",{href:t.env.app,target:"_blank",rel:"noreferrer"},"digimail.vn")))},null));"function"==typeof l.createRoot?(0,l.createRoot)(be).render(e):(0,l.render)(e,be)}}};const t={};function a(l){const i=t[l];if(void 0!==i)return i.exports;const s=t[l]={exports:{}};return e[l](s,s.exports,a),s.exports}a.m=e,(()=>{const e=[];a.O=(t,l,i)=>{if(!l){for(var s=0;s<e.length;s++){let[l,i]=e[s],m=!0;for(var n=0;n<l.length;n++)a.O.j(l[n])?l.splice(n--,1):m=!1;if(m){e.splice(s--,1);const a=i();void 0!==a&&(t=a)}}return t}e.push([l,i])}})(),a.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.hasOwn(e,t),(()=>{const e={57:0,350:0};a.O.j=t=>0===e[t];const t=(t,l)=>{let[i,s,n]=l;var m,r,c=0;if(i.some(t=>0!==e[t])){for(m in s)a.o(s,m)&&(a.m[m]=s[m]);if(n)var o=n(a)}for(t&&t(l);c<i.length;c++)r=i[c],a.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return a.O(o)},l=Array.isArray(globalThis.webpackChunkdigimail_smtp)?globalThis.webpackChunkdigimail_smtp:globalThis.webpackChunkdigimail_smtp=[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();let l=a.O(void 0,[350],()=>a(897));l=a.O(l)})();22 (0,i.__)("%1$s contacts added so far, last sync %2$s.","digimail-smtp"),d(_.total??0),p(new Date(1e3*_.at).toISOString())):(0,i.__)("No contacts yet. They show up a few seconds after someone submits a form.","digimail-smtp"),k>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of items waiting. */ /* translators: %s: number of items waiting. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),d(k)))),k>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"===g,onClick:async()=>{u("sync");try{const e=await o("contacts/sync",{});w(e.pending),v(e.last),e.last?.error?s(e.last.error,"bad"):s((0,i.__)("Contacts sent to DigiMail.","digimail-smtp"))}catch(e){s(e.message,"bad")}finally{u(null)}}},(0,i.__)("Send now","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send marketing email only to people who agreed to receive it. Add an “I agree to receive news” checkbox to your forms.","digimail-smtp")))))}const G={ok:{label:(0,i.__)("Correct","digimail-smtp"),tone:"ok"},missing:{label:(0,i.__)("Not added yet","digimail-smtp"),tone:"wait"},wrong:{label:(0,i.__)("Wrong value","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Could not check","digimail-smtp"),tone:"muted"}};function H({text:e,label:t}){const a=C();return(0,l.createElement)("button",{type:"button",className:"dms-copy",title:(0,i.__)("Copy","digimail-smtp"),"aria-label":(0,i.sprintf)(/* translators: %s: what is copied. */ /* translators: %s: what is copied. */(0,i.__)("Copy %s","digimail-smtp"),t),onClick:async()=>a(await async function(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const a=document.execCommand("copy");return t.remove(),a}}(e)?(0,i.__)("Copied.","digimail-smtp"):(0,i.__)("Could not copy. Select the text and copy it by hand.","digimail-smtp"))},(0,l.createElement)("code",null,e),(0,l.createElement)(w,{name:"copy",size:14}))}function J({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[c,p]=(0,l.useState)(""),[g,u]=(0,l.useState)(""),[_,b]=(0,l.useState)(""),k=(0,l.useCallback)(()=>o("domain").then(e=>(n(e),r(""),e)).catch(e=>(r(e.message),null)),[]);(0,l.useEffect)(()=>{k()},[k]);const N="pending"===s?.state;(0,l.useEffect)(()=>{if(!N)return;let e=0;const t=setInterval(()=>{e++,e>20||document.hidden?e>20&&clearInterval(t):k()},3e4);return()=>clearInterval(t)},[N,k]);const S="verified"===s?.state;(0,l.useEffect)(()=>{S&&"shared"===e.status.sender?.mode&&o("state?refresh=1").then(t).catch(()=>{})},[S,e.status.sender?.mode,t]);const x=async(e,t,l={})=>{p(e);try{const e=await o(t,l);return n(e),e}catch(e){return a(e.message,"bad"),null}finally{p("")}},M=async()=>{const e=await x("cf","domain/cloudflare",{token:g});e?.applied&&(u(""),a(e.applied.problems>0?(0,i.sprintf)(/* translators: %s: number of records. */ /* translators: %s: number of records. */(0,i.__)("Added what could be added. %s records need a look: see the list.","digimail-smtp"),d(e.applied.problems)):(0,i.__)("Records added in Cloudflare. Verification usually finishes within a few minutes.","digimail-smtp")))},T=s?"verified"===s.state?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Verified","digimail-smtp")):"pending"===s.state?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS","digimail-smtp")):"failed"===s.state?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Not verified","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Shared address","digimail-smtp")):null,D=s?.dns?.zone??s?.zone??null,F="cloudflare"===D?.provider.key||(s?.dns?.cloudflare.can_apply??s?.can_apply??!1),z=s?.dns?.cloudflare.can_apply??s?.can_apply??!1,P=s?.dns?.cloudflare.token_url??s?.token_url??"",$=s&&D&&D.apex!==s.domain&&s.domain.endsWith(`.${D.apex}`)?[s.domain,D.apex]:null;return(0,l.createElement)(E,{title:(0,l.createElement)("span",{id:"dms-domain"},(0,i.__)("Sending domain","digimail-smtp")),aside:T},m&&(0,l.createElement)("p",{className:"dms-error"},m),!s&&!m&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),s&&!s.eligible&&(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("This website runs on an IP address or localhost, so it has no domain to verify. It keeps sending from the shared address.","digimail-smtp")),s?.eligible&&"taken"===s.state&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is already in another DigiMail account","digimail-smtp"),s.domain)},(0,i.__)("Log in to that account on digimail.vn, or contact DigiMail if you own this domain.","digimail-smtp")),s?.eligible&&"none"===s.state&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared address, 2: example address on the site's domain. */ /* translators: 1: shared address, 2: example address on the site's domain. */ 23 (0,i.__)("The website sends from <code>%1$s</code>. Verify your domain to send from an address like <code>%2$s</code>: Gmail and Outlook trust it more, emails land in the inbox more often, and the shared address’s daily limit no longer applies.","digimail-smtp"),s.sender?.email??"",`noreply@${_||s.domain}`),{code:(0,l.createElement)("code",null)})),$&&(0,l.createElement)(y,{label:(0,i.__)("Domain to verify","digimail-smtp"),htmlFor:"dms-domain-pick",hint:(0,i.__)("Verifying the main domain covers every subdomain of it.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-domain-pick",value:_||$[0],onChange:e=>b(e.target.value)},$.map(e=>(0,l.createElement)("option",{key:e,value:e},e)))),D&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: DNS provider. */ /* translators: 1: domain, 2: DNS provider. */(0,i.__)("DNS of <strong>%1$s</strong> is managed at <strong>%2$s</strong>.","digimail-smtp"),D.apex,D.provider.name),{strong:(0,l.createElement)("strong",null)}),F&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("You can add the records with one click through Cloudflare.","digimail-smtp"))),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"add"===c,onClick:()=>x("add","domain/add",_?{domain:_}:{})},(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),_||s.domain)))),s?.eligible&&"verified"===s.state&&(0,l.createElement)(v,{tone:"ok",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is verified","digimail-smtp"),s.dns?.domain??s.domain)},"domain"===s.sender?.mode?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender address. */ /* translators: %s: sender address. */(0,i.__)("The website sends from <code>%s</code>.","digimail-smtp"),s.sender.email),{code:(0,l.createElement)("code",null)}):(0,i.__)("The website switches to your domain within a minute.","digimail-smtp")),s?.eligible&&("pending"===s.state||"failed"===s.state)&&s.dns&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: correct records, 2: required records. */ /* translators: 1: correct records, 2: required records. */ 24 (0,i.__)("%1$s of %2$s required DNS records are correct.","digimail-smtp"),d(s.dns.summary.ok_required),d(s.dns.summary.required))," ",s.dns.summary.dns_ready?(0,i.__)("DNS is ready: DigiMail confirms the domain within a few minutes, then the website switches to it by itself.","digimail-smtp"):(0,i.__)("Add the records below where your domain’s DNS is managed. Changes usually show within minutes, sometimes a few hours.","digimail-smtp")),F&&!s.dns.summary.dns_ready&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Add them automatically through Cloudflare","digimail-smtp")),z?(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"cf"===c,onClick:M},(0,i.__)("Add records in Cloudflare","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.__)("<a>Create a Cloudflare API token</a> (the link fills in the right permissions: Zone Read, DNS Edit), then paste it here. DigiMail stores it encrypted and only uses it to add these records.","digimail-smtp"),{a:(0,l.createElement)("a",{href:P,target:"_blank",rel:"noreferrer"})})),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("input",{type:"password",autoComplete:"off",value:g,onChange:e=>u(e.target.value),placeholder:(0,i.__)("Cloudflare API token","digimail-smtp"),"aria-label":(0,i.__)("Cloudflare API token","digimail-smtp")}),(0,l.createElement)(f,{busy:"cf"===c,disabled:g.trim().length<20,onClick:M},(0,i.__)("Connect and add records","digimail-smtp"))))),D&&!F&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: DNS provider, 2: how to add records there. */ /* translators: 1: DNS provider, 2: how to add records there. */(0,i.__)("DNS is at <strong>%1$s</strong>. %2$s","digimail-smtp"),D.provider.name,D.provider.guide),{strong:(0,l.createElement)("strong",null)}),D.provider.url&&(0,l.createElement)(l.Fragment,null," ",(0,l.createElement)("a",{href:D.provider.url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:12})))),s.applied&&s.applied.problems>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.__)("Some records were left alone in Cloudflare","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-reasons"},s.applied.outcomes.filter(e=>"conflict"===e.action||"failed"===e.action).map(e=>(0,l.createElement)("li",{key:e.name+e.type},e.type," ",e.name,": ",e.message)))),(0,l.createElement)("div",{className:"dms-table-wrap"},(0,l.createElement)("table",{className:"dms-table dms-dns"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Type","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Name (host)","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Value","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")))),(0,l.createElement)("tbody",null,s.dns.records.map(e=>(0,l.createElement)("tr",{key:e.type+e.name+e.value},(0,l.createElement)("td",null,(0,l.createElement)("strong",null,e.type),!e.required&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("recommended","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.host||"@",label:(0,i.__)("name","digimail-smtp")})),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.value,label:(0,i.__)("value","digimail-smtp")}),null!==e.priority&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: MX priority. */ /* translators: %s: MX priority. */(0,i.__)("Priority: %s","digimail-smtp"),e.priority)),"CNAME"===e.type&&F&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("Proxy off (DNS only)","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:G[e.state].tone},G[e.state].label),"ok"!==e.state&&e.note&&(0,l.createElement)("div",{className:"dms-small dms-muted"},e.note))))))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{busy:"check"===c,onClick:()=>x("check","domain/check")},(0,l.createElement)(w,{name:"refresh",size:15})," ",(0,i.__)("Check again","digimail-smtp")),(0,l.createElement)(f,{variant:"secondary",busy:"zone"===c,onClick:async()=>{p("zone");try{const e=await o("domain/zonefile"),t=URL.createObjectURL(new Blob([e.text],{type:"text/plain;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download=`digimail-${s?.dns?.domain??"dns"}.txt`,a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{p("")}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Download zone file","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("When the domain is verified, DigiMail tells you by Telegram or email (see Alerts).","digimail-smtp"))))}const Y={bad:"bad",warn:"wait",good:"ok"};function K(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[c,g]=(0,l.useState)(null),u=(0,l.useRef)(null),_=(0,l.useCallback)(()=>o("alerts").then(e=>(a(e),n(""),e)).catch(e=>(n(e.message),null)),[]);(0,l.useEffect)(()=>(_(),()=>{u.current&&clearInterval(u.current)}),[_]);const y=async t=>{r("prefs");try{a(await o("alerts/prefs",t))}catch(t){e(t.message,"bad")}finally{r("")}},v=t?.telegram.chats??[],k=!!t&&(t.prefs.telegram&&v.length>0||t.prefs.email&&t.emails.length>0);return(0,l.createElement)(E,{title:(0,i.__)("Alerts","digimail-smtp"),aside:t?k?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp")):null},s&&(0,l.createElement)("p",{className:"dms-error"},s),!t&&!s&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),t&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("DigiMail tells you when emails fail, the quota is nearly used up, bounces or spam reports rise, the plugin stops reporting, forms are hit by bots, or something changes with your domain. The same problem is repeated at most once a day.","digimail-smtp")),(0,l.createElement)(b,{checked:t.prefs.telegram,disabled:"prefs"===m||!t.telegram.available,onChange:e=>y({...t.prefs,telegram:e}),label:(0,i.__)("Telegram","digimail-smtp"),hint:t.telegram.available?v.length?(0,i.sprintf)(/* translators: %s: number of chats. */ /* translators: %s: number of chats. */(0,i._n)("Sent to %s connected chat.","Sent to %s connected chats.",v.length,"digimail-smtp"),d(v.length)):(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Connect your Telegram (or a group) to the %s bot.","digimail-smtp"),t.telegram.bot??""):(0,i.__)("Telegram alerts are not available yet.","digimail-smtp")}),t.telegram.available&&(0,l.createElement)("div",{className:"dms-chats"},v.map(t=>(0,l.createElement)("div",{key:t.id,className:"dms-chat"},(0,l.createElement)(w,{name:"private"===t.kind?"send":"users",size:15}),(0,l.createElement)("span",{className:"dms-grow"},t.title,"private"!==t.kind&&(0,l.createElement)("span",{className:"dms-muted dms-small"}," · ",(0,i.__)("group","digimail-smtp"))),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:m===t.id,onClick:()=>(async t=>{r(t.id);try{a(await o("alerts/telegram/remove",{id:t.id}))}catch(t){e(t.message,"bad")}finally{r("")}})(t)},(0,i.__)("Remove","digimail-smtp")))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",busy:"link"===m,onClick:async()=>{r("link");try{const a=await o("alerts/telegram",{});g(a),window.open(a.start_url,"_blank","noopener");const l=t?.telegram.chats.length??0;let s=0;u.current&&clearInterval(u.current),u.current=setInterval(async()=>{s++;const t=await _();(t&&t.telegram.chats.length>l||s>40)&&(u.current&&clearInterval(u.current),t&&t.telegram.chats.length>l&&(g(null),e((0,i.__)("Telegram connected.","digimail-smtp"))))},3e3)}catch(t){e(t.message,"bad")}finally{r("")}}},v.length?(0,i.__)("Connect another Telegram","digimail-smtp"):(0,i.__)("Connect Telegram","digimail-smtp"))),c&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Finish in Telegram","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Telegram opens a chat with %s: press Start. This page updates by itself once it is connected.","digimail-smtp"),c.bot)),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:c.start_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open Telegram","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13})),(0,l.createElement)("a",{className:"dms-btn dms-btn-ghost dms-btn-sm",href:c.group_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Add to a group instead","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("The link works once and expires in 30 minutes.","digimail-smtp")))),(0,l.createElement)(b,{checked:t.prefs.email,disabled:"prefs"===m,onChange:e=>y({...t.prefs,email:e}),label:(0,i.__)("Email","digimail-smtp"),hint:(0,i.sprintf)(/* translators: %s: email addresses. */ /* translators: %s: email addresses. */(0,i.__)("To %s (the users of your DigiMail account).","digimail-smtp"),t.emails.join(", "))}),void 0!==t.prefs.weekly&&(0,l.createElement)(b,{checked:t.prefs.weekly,disabled:"prefs"===m,onChange:e=>y({...t.prefs,weekly:e}),label:(0,i.__)("Weekly summary by email","digimail-smtp"),hint:(0,i.__)("Every Monday morning: emails sent last week, delivery rate, spam blocked on each website and the month’s quota. Nothing is sent after a quiet week.","digimail-smtp")}),(0,l.createElement)("div",null,(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:"test"===m,disabled:!k,onClick:async()=>{r("test");try{const t=await o("alerts/test",{});e(t.telegram+t.email>0?(0,i.sprintf)(/* translators: 1: Telegram chats, 2: email addresses. */ /* translators: 1: Telegram chats, 2: email addresses. */(0,i.__)("Test alert sent: %1$s Telegram, %2$s email.","digimail-smtp"),d(t.telegram),d(t.email)):(0,i.__)("Nothing was sent: turn on email or connect Telegram first.","digimail-smtp"),t.telegram+t.email>0?"ok":"bad"),_()}catch(t){e(t.message,"bad")}finally{r("")}}},(0,l.createElement)(w,{name:"bell",size:14})," ",(0,i.__)("Send a test alert","digimail-smtp"))),t.recent.length>0&&(0,l.createElement)("div",{className:"dms-recent"},(0,l.createElement)("strong",{className:"dms-small"},(0,i.__)("Recent alerts","digimail-smtp")),(0,l.createElement)("ul",null,t.recent.slice(0,5).map(e=>(0,l.createElement)("li",{key:e.created_at+e.kind,title:e.body},(0,l.createElement)(h,{tone:Y[e.level]},p(e.created_at))," ",e.title))))))}function Q({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(e.settings),[m,r]=(0,l.useState)(null),c=e.status.sender,d=c?.verified_domains??[],[p,g]=(0,l.useState)("domain"===c?.mode?c.email:""),[u,_]=(0,l.useState)(e.site.user_email),k=JSON.stringify(s)!==JSON.stringify(e.settings),N=async(e,l=(0,i.__)("Settings saved.","digimail-smtp"))=>{r("save");try{const i=await o("settings",e??s);return t(i),n(i.settings),a(l),!0}catch(e){return a(e.message,"bad"),!1}finally{r(null)}},S=Object.entries(e.controls).reduce((e,[t,a])=>((e[a.group]=e[a.group]??[]).push([t,a]),e),{}),x=s.backup,M=e=>n({...s,backup:{...x,...e}});return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Sender","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Sender name","digimail-smtp"),htmlFor:"dms-name",hint:(0,i.__)("Leave empty to use the website name. Recipients see this name in their inbox.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-name",value:s.from_name,placeholder:c?.name??e.site.name,onChange:e=>n({...s,from_name:e.target.value})})),(0,l.createElement)(b,{checked:s.force_from_name,onChange:e=>n({...s,force_from_name:e}),label:(0,i.__)("Always use this name","digimail-smtp"),hint:(0,i.__)("Even when another plugin (WooCommerce, a contact form) sets its own sender name.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Sender email","digimail-smtp"),htmlFor:"dms-from",hint:d.length?(0,i.__)("Only addresses on domains verified in DigiMail can be used.","digimail-smtp"):(0,i.__)("Verify your domain on digimail.vn to send from your company email.","digimail-smtp")},d.length?(0,l.createElement)("select",{id:"dms-from",value:p,onChange:e=>g(e.target.value)},(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: email address chosen automatically. */ /* translators: %s: email address chosen automatically. */ 25 (0,i.__)("Automatic (%s)","digimail-smtp"),"domain"===c?.mode?c.email:`noreply@${d[0]}`)),d.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).map(e=>(0,l.createElement)("option",{key:e,value:e},e)),p&&!d.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).includes(p)&&(0,l.createElement)("option",{value:p},p)):(0,l.createElement)("div",{className:"dms-readonly"},c?.email," ",(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")))),"shared"===c?.mode&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: reply-to email address. */ /* translators: %s: reply-to email address. */(0,i.__)("Replies go to <strong>%s</strong>.","digimail-smtp"),c.reply_to??e.site.admin_email),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"sender"===m,onClick:async()=>{r("sender");try{const e=await o("sender",{from_email:p,from_name:s.from_name});t(e),await N({from_name:s.from_name,force_from_name:s.force_from_name},(0,i.__)("Sender saved.","digimail-smtp"))}catch(e){a(e.message,"bad")}finally{r(null)}}},(0,i.__)("Save sender","digimail-smtp"))))),(0,l.createElement)(J,{state:e,setState:t}),(0,l.createElement)(K,null),(0,l.createElement)(E,{title:(0,i.__)("Sending email","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.queue,onChange:e=>n({...s,queue:e}),label:(0,i.__)("Background sending","digimail-smtp"),hint:(0,i.__)("Checkout and contact forms do not wait for email: messages are queued and sent right after. Recommended for online shops.","digimail-smtp")}),s.queue&&!e.env.cron&&(0,l.createElement)(v,{tone:"wait"},(0,l.createInterpolateElement)((0,i.__)("WP-Cron is off (DISABLE_WP_CRON). A server cron job must call wp-cron.php every minute, or run <code>wp digimail queue</code>.","digimail-smtp"),{code:(0,l.createElement)("code",null)})))),(0,l.createElement)(L,{state:e,s,setS:n}),(0,l.createElement)(U,{state:e,s,setS:n}),(0,l.createElement)(E,{title:(0,i.__)("Backup connection","digimail-smtp"),aside:x.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("When DigiMail cannot send (network down, quota used up), the plugin sends through this SMTP server so no email is lost. Your hosting SMTP, Gmail or Microsoft 365 all work.","digimail-smtp")),(0,l.createElement)(b,{checked:x.enabled,onChange:e=>M({enabled:e}),label:(0,i.__)("Turn on backup connection","digimail-smtp")}),x.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("SMTP server","digimail-smtp"),htmlFor:"dms-bh"},(0,l.createElement)("input",{id:"dms-bh",value:x.host,onChange:e=>M({host:e.target.value}),placeholder:"smtp.gmail.com"})),(0,l.createElement)(y,{label:(0,i.__)("Port","digimail-smtp"),htmlFor:"dms-bp"},(0,l.createElement)("input",{id:"dms-bp",type:"number",value:x.port,onChange:e=>M({port:Number(e.target.value)})}))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Encryption","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},[["tls","TLS (587)"],["ssl","SSL (465)"],["none",(0,i.__)("None","digimail-smtp")]].map(([e,t])=>(0,l.createElement)("button",{key:e,type:"button",className:x.encryption===e?"is-on":"",onClick:()=>M({encryption:e,port:"ssl"===e?465:"tls"===e?587:25})},t)))),(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("Username","digimail-smtp"),htmlFor:"dms-bu"},(0,l.createElement)("input",{id:"dms-bu",value:x.username,autoComplete:"off",onChange:e=>M({username:e.target.value})})),(0,l.createElement)(y,{label:(0,i.__)("Password","digimail-smtp"),htmlFor:"dms-bpw",hint:(0,i.__)("Encrypted when saved.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bpw",type:"password",autoComplete:"new-password",value:x.password,onChange:e=>M({password:e.target.value})}))),(0,l.createElement)(y,{label:(0,i.__)("From email on this server","digimail-smtp"),htmlFor:"dms-bf",hint:(0,i.__)("Leave empty to use the SMTP username.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bf",type:"email",value:x.from_email,onChange:e=>M({from_email:e.target.value})})),(0,l.createElement)("div",{className:"dms-inline"},(0,l.createElement)("input",{type:"email","aria-label":(0,i.__)("Send a test email to","digimail-smtp"),value:u,onChange:e=>_(e.target.value)}),(0,l.createElement)(f,{variant:"secondary",busy:"backup"===m,onClick:async()=>{if(!k||await N()){r("backup");try{await o("backup/test",{to:u}),a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("The backup server sent an email to %s.","digimail-smtp"),u))}catch(e){a(e.message,"bad")}finally{r(null)}}}},(0,i.__)("Save and send test","digimail-smtp")))))),(0,l.createElement)(E,{title:(0,i.__)("Turn off WordPress default emails","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Fewer unneeded emails for administrators. Order emails, contact forms and password resets are not affected.","digimail-smtp")),Object.entries(S).map(([e,t])=>(0,l.createElement)("div",{key:e,className:"dms-group"},(0,l.createElement)("h3",null,e),t.map(([e,t])=>(0,l.createElement)(b,{key:e,checked:!1!==s.controls[e],onChange:t=>{const a={...s.controls};t?delete a[e]:a[e]=!1,n({...s,controls:a})},label:t.label,hint:t.hint||void 0})))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-sticky"},(0,l.createElement)(E,{title:(0,i.__)("Save changes","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},k?(0,i.__)("You have unsaved changes.","digimail-smtp"):(0,i.__)("All changes are saved.","digimail-smtp")),(0,l.createElement)(f,{size:"block",busy:"save"===m,disabled:!k,onClick:()=>N()},(0,i.__)("Save settings","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Connection","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,e.status.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,e.status.account?.name),(0,l.createElement)("dt",null,(0,i.__)("Key","digimail-smtp")),(0,l.createElement)("dd",null,e.token_constant?(0,i.__)("Set in wp-config.php","digimail-smtp"):(0,i.__)("Stored in the database","digimail-smtp"))),(0,l.createElement)(b,{checked:s.keep_data,onChange:e=>n({...s,keep_data:e}),label:(0,i.__)("Keep settings when the plugin is deleted","digimail-smtp")}),(0,l.createElement)(b,{checked:!!s.diagnostics,onChange:e=>n({...s,diagnostics:e}),label:(0,i.__)("Share diagnostics with DigiMail support","digimail-smtp"),hint:(0,i.__)("Off by default. When on, the WordPress, PHP and WooCommerce versions, language, a few of this plugin's settings and the names of other active email plugins are sent with the twice-daily status check, so support can see problems on digimail.vn.","digimail-smtp")}),!e.token_constant&&(0,l.createElement)(f,{variant:"danger",size:"block",busy:"disconnect"===m,onClick:async()=>{window.confirm((0,i.__)("Disconnect DigiMail? The website will go back to sending email through your hosting server (or the backup server, if set).","digimail-smtp"))&&(r("disconnect"),await o("disconnect",{}),window.location.reload())}},(0,l.createElement)(w,{name:"x",size:15})," ",(0,i.__)("Disconnect DigiMail","digimail-smtp"))))))}function Z({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(null),m=e.conflicts.map(e=>e.name),r=[`DigiMail SMTP ${e.env.plugin}`,`WordPress ${e.env.wordpress}, PHP ${e.env.php}`,`Website: ${e.site.url}`,`Connected: ${e.connected?"yes":"no"}${e.revoked?" (revoked)":""}`,`From: ${e.status.sender?.email??"-"} (${e.status.sender?.mode??"-"})`,`Background sending: ${e.settings.queue?"on":"off"}, WP-Cron: ${e.env.cron?"on":"off"}`,`Backup: ${e.settings.backup.enabled?e.settings.backup.host:"off"}`,`Queue: ${e.queue.queued} waiting, ${e.queue.failed} failed`,`Other SMTP plugins: ${m.join(", ")||"none"}`].join("\n");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Switch from another SMTP plugin","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Imports the sender name and the emails you turned off. The old SMTP server becomes the backup connection: DigiMail sends, and the old server is used only when DigiMail cannot.","digimail-smtp")),0===e.importable.length?(0,l.createElement)(k,{title:(0,i.__)("No settings found to import","digimail-smtp")},(0,i.__)("Supports WP Mail SMTP, Easy WP SMTP, Post SMTP, FluentSMTP and SMTP Mailer.","digimail-smtp")):(0,l.createElement)("ul",{className:"dms-list"},e.importable.map(e=>(0,l.createElement)("li",{key:e.key},(0,l.createElement)("span",null,(0,l.createElement)("strong",null,e.name),m.includes(e.name)&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Active","digimail-smtp")),(0,l.createElement)("small",null,e.smtp?(0,i.__)("Has an SMTP server to use as backup","digimail-smtp"):(0,i.__)("Sender name only","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:s===e.key,onClick:()=>(async(e,l)=>{n(e);try{const s=await o("import",{from:e});t(s),a(s.settings.backup.host?(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s. The old SMTP server is now the backup connection.","digimail-smtp"),l):(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s.","digimail-smtp"),l))}catch(e){a(e.message,"bad")}finally{n(null)}})(e.key,e.name)},(0,i.__)("Import","digimail-smtp"))))),m.length>0&&(0,l.createElement)("p",{className:"dms-small"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("After importing, deactivate %s on the <a>Plugins page</a> so the two plugins do not both try to send email.","digimail-smtp"),m.join(", ")),{a:(0,l.createElement)("a",{href:"plugins.php"})}))),(0,l.createElement)(E,{title:(0,i.__)("Command line (WP-CLI)","digimail-smtp")},(0,l.createElement)("pre",{className:"dms-pre"},[`wp digimail status # ${(0,i.__)("connection, sender, quota","digimail-smtp")}`,`wp digimail test you@company.com # ${(0,i.__)("send a test email","digimail-smtp")}`,`wp digimail queue --retry-failed # ${(0,i.__)("resend waiting and failed emails","digimail-smtp")}`,"wp digimail connect you@company.com","wp digimail disconnect"].join("\n")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Agencies can set the key in wp-config.php:","digimail-smtp")," ",(0,l.createElement)("code",null,"define( 'DIGIMAIL_SMTP_TOKEN', 'dm_…' );")))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Support information","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard?.writeText(r),a((0,i.__)("Copied.","digimail-smtp"))}},(0,l.createElement)(w,{name:"download",size:14})," ",(0,i.__)("Copy","digimail-smtp"))},(0,l.createElement)("pre",{className:"dms-pre"},r),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send this when you contact DigiMail support. It contains no secret keys.","digimail-smtp")))))}const X=[{key:"modern",label:(0,i.__)("Modern","digimail-smtp"),hint:(0,i.__)("White card with a line in your colour","digimail-smtp")},{key:"minimal",label:(0,i.__)("Minimal","digimail-smtp"),hint:(0,i.__)("All white, logo in the middle","digimail-smtp")},{key:"bold",label:(0,i.__)("Bold","digimail-smtp"),hint:(0,i.__)("Your colour across the top","digimail-smtp")}],ee=[{key:"sans",label:(0,i.__)("Modern sans-serif","digimail-smtp")},{key:"serif",label:(0,i.__)("Classic serif","digimail-smtp")},{key:"rounded",label:(0,i.__)("Friendly","digimail-smtp")}],te=["#1b2550","#0f766e","#2563eb","#7c3aed","#db2777","#dc2626","#ea580c","#111827"];function ae({t:e,color:t}){return(0,l.createElement)("svg",{viewBox:"0 0 120 84",width:"100%","aria-hidden":"true"},(0,l.createElement)("rect",{width:"120",height:"84",rx:"6",fill:"minimal"===e?"#ffffff":"#eef0f3"}),"modern"===e&&(0,l.createElement)("rect",{x:"16",y:"8",width:"26",height:"5",rx:"2",fill:"#9aa1ad"}),(0,l.createElement)("rect",{x:"14",y:"modern"===e?18:10,width:"92",height:"modern"===e?60:68,rx:"5",fill:"#ffffff",stroke:"minimal"===e?"#e3e5e9":"none"}),"modern"===e&&(0,l.createElement)("rect",{x:"14",y:"18",width:"92",height:"3",rx:"1.5",fill:t}),"bold"===e&&(0,l.createElement)("path",{d:"M14 15a5 5 0 0 1 5-5h82a5 5 0 0 1 5 5v19H14z",fill:t}),"minimal"===e&&(0,l.createElement)("rect",{x:"48",y:"17",width:"24",height:"5",rx:"2",fill:"#9aa1ad"}),(0,l.createElement)("rect",{x:"minimal"===e?34:22,y:"bold"===e?22:28,width:"52",height:"6",rx:"2",fill:"bold"===e?"#ffffff":"#2b3040"}),[0,1,2].map(a=>(0,l.createElement)("rect",{key:a,x:22+26*a,y:"bold"===e?41:39,width:"23",height:"3",rx:"1.5",fill:a<2?t:"#dfe2e7"})),(0,l.createElement)("rect",{x:"22",y:"50",width:"76",height:"3",rx:"1.5",fill:"#e3e5e9"}),(0,l.createElement)("rect",{x:"22",y:"57",width:"64",height:"3",rx:"1.5",fill:"#e3e5e9"}),(0,l.createElement)("rect",{x:"22",y:"66",width:"28",height:"7",rx:"2.5",fill:t}))}function le({value:e,onChange:t}){return(0,l.createElement)("div",{className:"dms-logo-pick"},(0,l.createElement)("div",{className:"dms-logo-box"},e?(0,l.createElement)("img",{src:e,alt:""}):(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.__)("No logo: the shop name is shown","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>{const e=window.wp?.media;if(!e)return;const a=e({title:(0,i.__)("Choose a logo","digimail-smtp"),library:{type:"image"},multiple:!1,button:{text:(0,i.__)("Use this image","digimail-smtp")}});a.on("select",()=>{const e=a.state().get("selection").first().toJSON();t(e.sizes?.medium?.url??e.url)}),a.open()}},e?(0,i.__)("Change logo","digimail-smtp"):(0,i.__)("Choose a logo","digimail-smtp")),e&&(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>t("")},(0,i.__)("Remove","digimail-smtp"))))}function ie({label:e,value:t,onChange:a,swatches:i}){return(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},e),(0,l.createElement)("div",{className:"dms-color"},(0,l.createElement)("input",{type:"color",value:t,onChange:e=>a(e.target.value),"aria-label":e}),(0,l.createElement)("input",{type:"text",value:t,maxLength:7,onChange:e=>a(e.target.value),"aria-label":e}),i&&i.map(e=>(0,l.createElement)("button",{key:e,type:"button",className:"dms-swatch "+(e===t?"is-on":""),style:{background:e},"aria-label":e,onClick:()=>a(e)}))))}function se(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[c,d]=(0,l.useState)(""),[p,g]=(0,l.useState)(""),[u,_]=(0,l.useState)("desktop"),[k,N]=(0,l.useState)(!1),[S,x]=(0,l.useState)(""),[M,T]=(0,l.useState)(""),[D,F]=(0,l.useState)(""),[z,P]=(0,l.useState)(!1),[$,O]=(0,l.useState)(null),[A,W]=(0,l.useState)(""),I=(0,l.useRef)(0);(0,l.useEffect)(()=>{o("design").then(e=>{a(e),n(e.settings),r(JSON.stringify(e.settings)),g(e.types.find(e=>"WC_Email_Customer_Processing_Order"===e.id)?.id??e.types[0]?.id??"")}).catch(e=>d(e.message)),o("state").then(e=>W(e.site.admin_email)).catch(()=>{})},[]);const L=(0,l.useCallback)(async(e,t,a)=>{const l=++I.current;P(!0);try{const i=await o("design/preview",{type:t,settings:{...e,enabled:!a}});l===I.current&&(x(i.html),T(i.subject),F(""))}catch(e){l===I.current&&F(e.message)}finally{l===I.current&&P(!1)}},[]);if((0,l.useEffect)(()=>{if(!s||!p)return;const e=window.setTimeout(()=>L(s,p,k),350);return()=>window.clearTimeout(e)},[s,p,k,L]),c)return(0,l.createElement)(v,{tone:"bad"},c);if(!t||!s)return(0,l.createElement)("div",{className:"dms-skel",style:{height:520}});const j=(e,t)=>n({...s,[e]:t}),R=JSON.stringify(s)!==m,B=Array.from(new Set([...t.detected.palette??[],...te])).slice(0,8),q=async(t=s)=>{O("save");try{const a=await o("design/save",{settings:t});n(a.settings),r(JSON.stringify(a.settings)),e(a.settings.enabled?(0,i.__)("Saved. New emails use this design.","digimail-smtp"):(0,i.__)("Saved. The design is off.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{O(null)}},V=(e,t,a)=>(0,l.createElement)(y,{label:t,htmlFor:`dms-so-${e}`},(0,l.createElement)("input",{id:`dms-so-${e}`,type:"text",inputMode:"url",placeholder:a,value:s.socials[e],onChange:t=>j("socials",{...s.socials,[e]:t.target.value})}));return(0,l.createElement)("div",{className:"dms-design"},(0,l.createElement)("div",{className:"dms-design-side"},(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-design-on"},(0,l.createElement)(b,{checked:s.enabled,onChange:e=>q({...s,enabled:e}),disabled:"save"===$,label:(0,i.__)("Use this design for emails","digimail-smtp"),hint:s.enabled?(0,i.__)("On: new emails go out in this design.","digimail-smtp"):(0,i.__)("Off: emails look as they do now. Design and preview freely, nothing changes until you turn it on.","digimail-smtp")})),t.conflicts.length>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s also changes how emails look","digimail-smtp"),t.conflicts.join(", "))},(0,i.__)("Use one email designer at a time: deactivate the other plugin, or leave this design off.","digimail-smtp")),!t.woocommerce&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("WooCommerce is not active, so only the other WordPress emails can use the design.","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Template","digimail-smtp")},(0,l.createElement)("div",{className:"dms-templates"},X.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-tpl "+(s.template===e.key?"is-on":""),onClick:()=>j("template",e.key),"aria-pressed":s.template===e.key},(0,l.createElement)(ae,{t:e.key,color:s.color}),(0,l.createElement)("strong",null,e.label),(0,l.createElement)("span",null,e.hint))))),(0,l.createElement)(E,{title:(0,i.__)("Brand","digimail-smtp"),aside:(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>{const a=t.detected;n({...s,logo:a.logo??s.logo,color:a.color??s.color,company:a.company??s.company,email:a.email??s.email,address:a.address??s.address}),e((0,i.__)("Filled in from the website. Check the preview, then save.","digimail-smtp"))}},(0,l.createElement)(w,{name:"zap",size:14})," ",(0,i.__)("Fill in from the website","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Logo","digimail-smtp")),(0,l.createElement)(le,{value:s.logo,onChange:e=>j("logo",e)}),s.logo&&(0,l.createElement)("label",{className:"dms-range"},(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Width","digimail-smtp")),(0,l.createElement)("input",{type:"range",min:60,max:260,step:5,value:s.logo_width,onChange:e=>j("logo_width",Number(e.target.value))}),(0,l.createElement)("span",{className:"dms-small"},s.logo_width,"px"))),(0,l.createElement)(ie,{label:(0,i.__)("Brand colour","digimail-smtp"),value:s.color,onChange:e=>j("color",e),swatches:B}),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(ie,{label:(0,i.__)("Background","digimail-smtp"),value:s.bg,onChange:e=>j("bg",e)}),(0,l.createElement)(ie,{label:(0,i.__)("Text","digimail-smtp"),value:s.text,onChange:e=>j("text",e)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Font","digimail-smtp"),htmlFor:"dms-font"},(0,l.createElement)("select",{id:"dms-font",value:s.font,onChange:e=>j("font",e.target.value)},ee.map(e=>(0,l.createElement)("option",{key:e.key,value:e.key},e.label)))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Corners","digimail-smtp")),(0,l.createElement)("label",{className:"dms-range"},(0,l.createElement)("input",{type:"range",min:0,max:24,value:s.radius,onChange:e=>j("radius",Number(e.target.value)),"aria-label":(0,i.__)("Corners","digimail-smtp")}),(0,l.createElement)("span",{className:"dms-small"},s.radius,"px")))))),(0,l.createElement)(E,{title:(0,i.__)("Order emails","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.tracker,onChange:e=>j("tracker",e),label:(0,i.__)("Progress bar","digimail-smtp"),hint:(0,i.__)("Order placed → Processing → Completed, in the customer’s order emails.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.cta,onChange:e=>j("cta",e),label:(0,i.__)("Button under the order","digimail-smtp"),hint:(0,i.__)("View your order, Pay for this order, or Open the order in emails to the shop.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.images,onChange:e=>j("images",e),label:(0,i.__)("Product pictures","digimail-smtp")}))),(0,l.createElement)(E,{title:(0,i.__)("Footer","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Company or shop name","digimail-smtp"),htmlFor:"dms-company"},(0,l.createElement)("input",{id:"dms-company",type:"text",value:s.company,onChange:e=>j("company",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Address","digimail-smtp"),htmlFor:"dms-address"},(0,l.createElement)("input",{id:"dms-address",type:"text",value:s.address,onChange:e=>j("address",e.target.value)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Phone","digimail-smtp"),htmlFor:"dms-phone"},(0,l.createElement)("input",{id:"dms-phone",type:"text",inputMode:"tel",value:s.phone,onChange:e=>j("phone",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Email","digimail-smtp"),htmlFor:"dms-email"},(0,l.createElement)("input",{id:"dms-email",type:"email",value:s.email,onChange:e=>j("email",e.target.value)}))),(0,l.createElement)("div",{className:"dms-grid-2"},V("facebook","Facebook","https://facebook.com/…"),V("zalo","Zalo","https://zalo.me/…"),V("tiktok","TikTok","https://tiktok.com/@…"),V("instagram","Instagram","https://instagram.com/…")),V("youtube","YouTube","https://youtube.com/@…"),(0,l.createElement)(y,{label:(0,i.__)("Note at the bottom","digimail-smtp"),hint:(0,i.__)("For example your return policy or opening hours.","digimail-smtp"),htmlFor:"dms-note"},(0,l.createElement)("textarea",{id:"dms-note",rows:2,value:s.note,onChange:e=>j("note",e.target.value)})))),(0,l.createElement)(E,{title:(0,i.__)("Which emails","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.woo,onChange:e=>j("woo",e),disabled:!t.woocommerce,label:(0,i.__)("WooCommerce emails","digimail-smtp"),hint:(0,i.__)("Orders, invoices, accounts and refunds.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.wp,onChange:e=>j("wp",e),label:(0,i.__)("Other plain-text WordPress emails","digimail-smtp"),hint:(0,i.__)("Password resets, new users, form notifications that have no design of their own. Emails other plugins already design are left alone.","digimail-smtp")})))),(0,l.createElement)("div",{className:"dms-design-main"},(0,l.createElement)("div",{className:"dms-preview-bar"},(0,l.createElement)("select",{value:p,onChange:e=>g(e.target.value),"aria-label":(0,i.__)("Email to preview","digimail-smtp")},t.types.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},e.title))),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"desktop"===u?"is-on":"",onClick:()=>_("desktop")},(0,i.__)("Computer","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"mobile"===u?"is-on":"",onClick:()=>_("mobile")},(0,i.__)("Phone","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:k?"":"is-on",onClick:()=>N(!1)},(0,i.__)("New design","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:k?"is-on":"",onClick:()=>N(!0)},(0,i.__)("As it is now","digimail-smtp"))),z&&(0,l.createElement)("span",{className:"dms-spin","aria-label":(0,i.__)("Loading","digimail-smtp")})),(0,l.createElement)("div",{className:`dms-inbox is-${u}`},(0,l.createElement)("div",{className:"dms-inbox-head"},(0,l.createElement)("span",{className:"dms-avatar",style:{background:s.color}},(s.company||"S").trim().charAt(0).toUpperCase()),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,s.company||(0,i.__)("Your shop","digimail-smtp")),(0,l.createElement)("span",null,M))),D?(0,l.createElement)("div",{className:"dms-preview-err"},(0,l.createElement)(v,{tone:"bad"},D)):(0,l.createElement)("iframe",{title:(0,i.__)("Email preview","digimail-smtp"),sandbox:"allow-popups",srcDoc:S})),(0,l.createElement)("div",{className:"dms-design-actions"},(0,l.createElement)("form",{className:"dms-row",onSubmit:t=>{t.preventDefault(),(async()=>{O("test");try{await o("design/test",{type:p,to:A,settings:{...s,enabled:!0}}),e((0,i.__)("Test email sent. Check the inbox.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{O(null)}})()}},(0,l.createElement)("input",{type:"email",required:!0,value:A,onChange:e=>W(e.target.value),"aria-label":(0,i.__)("Send to","digimail-smtp")}),(0,l.createElement)(f,{type:"submit",variant:"secondary",busy:"test"===$},(0,l.createElement)(w,{name:"send",size:14})," ",(0,i.__)("Send a test","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-row"},R&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Not saved","digimail-smtp")),(0,l.createElement)(f,{busy:"save"===$,disabled:!R,onClick:()=>q()},(0,i.__)("Save design","digimail-smtp"))))))}const ne=e=>`${Math.round(e).toLocaleString("vi-VN")}₫`,me={welcome:(0,i.__)("Welcome new subscribers","digimail-smtp"),order_followup:(0,i.__)("Thank-you after purchase","digimail-smtp"),abandoned_cart:(0,i.__)("Abandoned cart reminder","digimail-smtp"),review_request:(0,i.__)("Review request","digimail-smtp")};function re(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(null),[c,g]=(0,l.useState)(""),u=e=>{a(e),n({...e.settings})};if((0,l.useEffect)(()=>{o("shop").then(u).catch(e=>g(e.message))},[]),c&&!t)return(0,l.createElement)(v,{tone:"bad"},c);if(!t||!s)return(0,l.createElement)("div",{className:"dms-skel",style:{height:360}});if(!t.woocommerce)return(0,l.createElement)(v,{tone:"info",title:(0,i.__)("WooCommerce is not active","digimail-smtp")},(0,i.__)("Turn on WooCommerce to use the shop emails.","digimail-smtp"));const _=async t=>{r("save");try{u(await o("shop/save",t)),e(t.enabled?(0,i.__)("Shop settings saved.","digimail-smtp"):(0,i.__)("Shop emails are off.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{r(null)}},k=e=>n({...s,...e}),N=JSON.stringify(s)!==JSON.stringify(t.settings),S=t.summary?.automations.filter(e=>"welcome"!==e.kind)??[],x=t.summary?.manage_url??`${t.app}/app/tu-dong`;return t.settings.enabled?(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Shop emails","digimail-smtp"),aside:(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:x,target:"_blank",rel:"noreferrer"},(0,i.__)("Edit on digimail.vn","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:14}))},t.error&&(0,l.createElement)("p",{className:"dms-error"},t.error),t.summary&&(0,l.createElement)("div",{className:"dms-kpis dms-kpis-2"},(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Revenue from email, 30 days","digimail-smtp")),(0,l.createElement)("strong",null,ne(t.summary.email_revenue_30d))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Orders from email, 30 days","digimail-smtp")),(0,l.createElement)("strong",null,d(t.summary.email_orders_30d)),(0,l.createElement)("em",null,(0,i.__)("Clicked an email in the 7 days before paying","digimail-smtp")))),t.summary&&0===S.length&&(0,l.createElement)("div",{className:"dms-empty-inline"},(0,l.createElement)("p",null,(0,i.__)("No email series yet. Pick one on digimail.vn: the text is ready, you only turn it on.","digimail-smtp")),(0,l.createElement)("a",{className:"dms-btn dms-btn-primary",href:x,target:"_blank",rel:"noreferrer"},(0,i.__)("Set up shop emails","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:14}))),S.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Email series","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Sent","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Orders","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Revenue","digimail-smtp")))),(0,l.createElement)("tbody",null,S.map(e=>(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)("a",{href:e.url,target:"_blank",rel:"noreferrer"},e.name),(0,l.createElement)("div",{className:"dms-small dms-muted"},me[e.kind]??"")),(0,l.createElement)("td",null,"active"===e.status?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Running","digimail-smtp")):"paused"===e.status?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Paused","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Draft","digimail-smtp"))),(0,l.createElement)("td",{className:"num"},d(e.sent)),(0,l.createElement)("td",{className:"num"},d(e.orders)),(0,l.createElement)("td",{className:"num"},e.orders?ne(e.revenue):"–"))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("span",{className:"dms-small dms-muted"},t.last?.error?(0,i.sprintf)(/* translators: %s: error message. */ /* translators: %s: error message. */(0,i.__)("Last sync failed: %s","digimail-smtp"),t.last.error):t.last?(0,i.sprintf)(/* translators: %s: time. */ /* translators: %s: time. */(0,i.__)("Orders and carts last sent %s.","digimail-smtp"),p(new Date(1e3*t.last.at).toISOString())):(0,i.__)("Orders show up on digimail.vn a few seconds after they are placed.","digimail-smtp"),t.pending>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of items waiting. */ /* translators: %s: number of items waiting. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),d(t.pending)))),t.pending>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"===m,onClick:async()=>{r("sync");try{u(await o("shop/sync",{}))}catch(t){e(t.message,"bad")}finally{r(null)}}},(0,i.__)("Send now","digimail-smtp"))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Checkout","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.optin,onChange:e=>k({optin:e}),label:(0,i.__)("Show an “email me news” checkbox","digimail-smtp"),hint:(0,i.__)("Unticked by default. Shoppers who tick it join your contact list, and shop emails go to them.","digimail-smtp")}),s.optin&&(0,l.createElement)(y,{label:(0,i.__)("Checkbox text","digimail-smtp"),htmlFor:"dms-optin-label"},(0,l.createElement)("input",{id:"dms-optin-label",type:"text",maxLength:200,value:s.optin_label,onChange:e=>k({optin_label:e.target.value}),placeholder:t.default_label})),(0,l.createElement)(b,{checked:s.carts,onChange:e=>k({carts:e}),label:(0,i.__)("Save carts for the reminder email","digimail-smtp"),hint:(0,i.__)("When a shopper types their email at checkout, the cart is kept for 30 days. A short note under the email field tells them.","digimail-smtp")}),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>_({...s,enabled:!1})},(0,i.__)("Turn off shop emails","digimail-smtp")),(0,l.createElement)(f,{disabled:!N,busy:"save"===m,onClick:()=>_(s)},(0,i.__)("Save","digimail-smtp"))),!t.blocks&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Your WooCommerce shows the checkbox on the classic checkout only. Update WooCommerce to show it on the block checkout too.","digimail-smtp")))))):(0,l.createElement)("div",{className:"dms-shop-intro"},(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-shop-hero"},(0,l.createElement)("div",{className:"dms-shop-icon"},(0,l.createElement)(w,{name:"cart",size:22})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Emails that sell for your shop","digimail-smtp")),(0,l.createElement)("p",null,(0,i.__)("DigiMail sends these by itself, from your own domain, with the products of each order:","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-checks"},(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A thank-you after payment, and a check-in 7 days later.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A reminder when a shopper leaves checkout, with a button that brings their cart back.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A review request a few days after the order is completed.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("An unticked “Email me news and offers” checkbox at checkout, so you only email people who agreed.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A report of the revenue that came from your emails.","digimail-smtp"))),(0,l.createElement)(f,{busy:"save"===m,onClick:()=>_({...s,enabled:!0})},(0,i.__)("Turn on shop emails","digimail-smtp")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("This sends each order and saved cart (email, name, products, total) to your DigiMail account. Nothing is emailed until you turn on an email series on digimail.vn.","digimail-smtp"))))))}const oe=[{key:"popup",label:(0,i.__)("Popup","digimail-smtp"),hint:(0,i.__)("In the middle of the screen, after a few seconds, a scroll or when the visitor is about to leave.","digimail-smtp")},{key:"slide",label:(0,i.__)("Slide-in","digimail-smtp"),hint:(0,i.__)("A small box in the corner. Noticed without getting in the way.","digimail-smtp")},{key:"bar",label:(0,i.__)("Bar","digimail-smtp"),hint:(0,i.__)("A thin strip across the top or bottom of every page.","digimail-smtp")},{key:"inline",label:(0,i.__)("In the page","digimail-smtp"),hint:(0,i.__)("Inside a page or after each blog post, with a shortcode.","digimail-smtp")}],ce=[{key:"card",label:(0,i.__)("Card","digimail-smtp")},{key:"split",label:(0,i.__)("With picture","digimail-smtp")},{key:"minimal",label:(0,i.__)("Simple","digimail-smtp")},{key:"bold",label:(0,i.__)("Colour block","digimail-smtp")}],de=e=>oe.find(t=>t.key===e)?.label??e;function pe({type:e,color:t}){return(0,l.createElement)("svg",{viewBox:"0 0 120 76",width:"100%","aria-hidden":"true"},(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"74",rx:"6",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"10",y:"12",width:"56",height:"5",rx:"2.5",fill:"#e6e8ed"}),(0,l.createElement)("rect",{x:"10",y:"22",width:"90",height:"4",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"10",y:"30",width:"80",height:"4",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"10",y:"38",width:"86",height:"4",rx:"2",fill:"#eef0f3"}),"popup"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"74",rx:"6",fill:"#14182b",opacity:".35"}),(0,l.createElement)("rect",{x:"30",y:"16",width:"60",height:"44",rx:"5",fill:"#fff"}),(0,l.createElement)("rect",{x:"38",y:"24",width:"36",height:"4",rx:"2",fill:"#14182b"}),(0,l.createElement)("rect",{x:"38",y:"36",width:"44",height:"7",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"38",y:"46",width:"44",height:"7",rx:"2",fill:t})),"slide"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"70",y:"40",width:"44",height:"31",rx:"4",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"76",y:"46",width:"24",height:"3",rx:"1.5",fill:"#14182b"}),(0,l.createElement)("rect",{x:"76",y:"54",width:"32",height:"5",rx:"1.5",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"76",y:"61",width:"32",height:"5",rx:"1.5",fill:t})),"bar"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"9",fill:t}),(0,l.createElement)("rect",{x:"30",y:"4",width:"34",height:"3",rx:"1.5",fill:"#fff",opacity:".9"}),(0,l.createElement)("rect",{x:"68",y:"3.5",width:"20",height:"4",rx:"1",fill:"#fff"})),"inline"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"10",y:"48",width:"100",height:"20",rx:"4",fill:"#f6f7f9",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"16",y:"54",width:"54",height:"8",rx:"2",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"74",y:"54",width:"30",height:"8",rx:"2",fill:t})))}function ge({value:e,onChange:t}){return(0,l.createElement)("div",{className:"dms-row"},e&&(0,l.createElement)("img",{src:e,alt:"",className:"dms-form-thumb"}),(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>{const e=window.wp?.media;if(!e)return;const a=e({title:(0,i.__)("Choose a picture","digimail-smtp"),library:{type:"image"},multiple:!1,button:{text:(0,i.__)("Use this image","digimail-smtp")}});a.on("select",()=>{const e=a.state().get("selection").first().toJSON();t(e.sizes?.large?.url??e.url)}),a.open()}},e?(0,i.__)("Change picture","digimail-smtp"):(0,i.__)("Choose a picture","digimail-smtp")),e&&(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>t("")},(0,i.__)("Remove","digimail-smtp")))}function ue({id:e}){const t=C(),a=`[digimail_form id="${e}"]`;return(0,l.createElement)("button",{type:"button",className:"dms-code-btn",onClick:()=>navigator.clipboard?.writeText(a).then(()=>t((0,i.__)("Shortcode copied.","digimail-smtp"))),title:(0,i.__)("Copy","digimail-smtp")},(0,l.createElement)("code",null,a)," ",(0,l.createElement)(w,{name:"copy",size:14}))}function _e(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(null),[c,p]=(0,l.useState)("");if((0,l.useEffect)(()=>{o("forms").then(a).catch(e=>n(e.message))},[]),s&&!t)return(0,l.createElement)(v,{tone:"bad"},s);if(!t)return(0,l.createElement)("div",{className:"dms-skel",style:{height:360}});const g=async(t,l=!1)=>{p("save");try{const s=await o("forms/save",t);return a(s),s.form&&r(s.form),l||e("on"===t.status?(0,i.__)("Saved. The form is live on your site.","digimail-smtp"):(0,i.__)("Saved. The form is off.","digimail-smtp")),s.form??null}catch(t){return e(t.message,"bad"),null}finally{p("")}};if(m)return(0,l.createElement)(he,{form:m,screen:t,busy:"save"===c,onSave:g,onBack:()=>r(null),onDelete:async t=>{if(window.confirm((0,i.sprintf)(/* translators: %s: form name. */ /* translators: %s: form name. */(0,i.__)("Delete “%s”? Its numbers are deleted too. People who signed up stay in your DigiMail list.","digimail-smtp"),t.name)))try{a(await o("forms/delete",{id:t.id})),r(null)}catch(t){e(t.message,"bad")}}});const u=(0,l.createElement)("div",{className:"dms-form-types"},oe.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-form-type",onClick:()=>{return a=e.key,r({...t.defaults[a],id:"",created:0});var a}},(0,l.createElement)(pe,{type:e.key,color:t.defaults.popup.color}),(0,l.createElement)("strong",null,e.label),(0,l.createElement)("span",null,e.hint))));return 0===t.forms.length?(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-forms-intro"},(0,l.createElement)("h2",null,(0,i.__)("Grow your email list from your website","digimail-smtp")),(0,l.createElement)("p",null,(0,i.__)("Visitors who sign up go straight into your DigiMail contact list, ready for campaigns and the welcome email series. The spam guard keeps bots out. Pick a kind of form to start:","digimail-smtp")),u)):(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Signup forms","digimail-smtp")},(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Views","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Signups","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Rate","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,t.forms.map(e=>(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)("button",{type:"button",className:"dms-link-btn",onClick:()=>r(e)},e.name),(0,l.createElement)("div",{className:"dms-small dms-muted"},de(e.type)),"inline"===e.type&&"shortcode"===e.placement&&(0,l.createElement)(ue,{id:e.id})),(0,l.createElement)("td",null,(0,l.createElement)("label",{className:"dms-switch-inline"},(0,l.createElement)("input",{type:"checkbox",checked:"on"===e.status,onChange:t=>g({...e,status:t.target.checked?"on":"off"})}),"on"===e.status?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp")))),(0,l.createElement)("td",{className:"num"},d(e.views??0)),(0,l.createElement)("td",{className:"num"},d(e.signups??0)),(0,l.createElement)("td",{className:"num"},e.views?`${((e.signups??0)/e.views*100).toFixed(1)}%`:"–"),(0,l.createElement)("td",{className:"num"},(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>r(e)},(0,i.__)("Edit","digimail-smtp"))," ",(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>r({...e,id:"",name:(0,i.sprintf)(/* translators: %s: form name. */ /* translators: %s: form name. */(0,i.__)("%s (copy)","digimail-smtp"),e.name),status:"off",created:0}),"aria-label":(0,i.__)("Duplicate","digimail-smtp")},(0,l.createElement)(w,{name:"copy",size:15})))))))),(0,l.createElement)(E,{title:(0,i.__)("New form","digimail-smtp")},u))}function he({form:e,screen:t,busy:a,onSave:s,onBack:n,onDelete:m}){const[r,c]=(0,l.useState)(e),[p,g]=(0,l.useState)("desktop"),[u,_]=(0,l.useState)(""),[k,N]=(0,l.useState)(!1),S=(0,l.useRef)(void 0),C=(0,l.useRef)(JSON.stringify(e)),x=JSON.stringify(r)!==C.current,M=(e,t)=>c(a=>({...a,[e]:t}));(0,l.useEffect)(()=>(window.clearTimeout(S.current),S.current=window.setTimeout(()=>{N(!0),o("forms/preview",{form:r,device:p}).then(e=>_(e.html)).catch(()=>{}).then(()=>N(!1))},350),()=>window.clearTimeout(S.current)),[r,p]);const T=async e=>{const t=e?{...r,status:e}:r,a=await s(t);a&&(C.current=JSON.stringify(a),c(a))},D="inline"!==r.type;return(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-form-top"},(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:n},(0,l.createElement)(w,{name:"back",size:15})," ",(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("input",{className:"dms-form-name",value:r.name,onChange:e=>M("name",e.target.value),"aria-label":(0,i.__)("Form name (only you see it)","digimail-smtp"),maxLength:80}),(0,l.createElement)(h,null,de(r.type)),(0,l.createElement)("span",{className:"dms-grow"}),x&&(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Unsaved changes","digimail-smtp")),r.id&&(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>m(r),"aria-label":(0,i.__)("Delete form","digimail-smtp")},(0,l.createElement)(w,{name:"trash",size:15})),"on"===r.status?(0,l.createElement)(l.Fragment,null,(0,l.createElement)(f,{variant:"secondary",busy:a,onClick:()=>T("off")},(0,i.__)("Turn off","digimail-smtp")),(0,l.createElement)(f,{busy:a,disabled:!x,onClick:()=>T()},(0,i.__)("Save","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)(f,{variant:"secondary",busy:a,onClick:()=>T("off"),disabled:!x&&!!r.id},(0,i.__)("Save as draft","digimail-smtp")),(0,l.createElement)(f,{busy:a,onClick:()=>T("on")},(0,i.__)("Save and turn on","digimail-smtp")))),!t.guard&&(0,l.createElement)(v,{tone:"wait"},(0,i.__)("The spam guard is off, so bots can sign up through this form. Turn it on in Settings.","digimail-smtp")),(0,l.createElement)("div",{className:"dms-design"},(0,l.createElement)("div",{className:"dms-design-side"},(0,l.createElement)(E,{title:(0,i.__)("Design","digimail-smtp")},(0,l.createElement)("div",{className:"dms-templates dms-templates-4"},ce.filter(e=>!("bar"===r.type&&"split"===e.key)).map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-tpl "+(r.template===e.key?"is-on":""),onClick:()=>M("template",e.key),"aria-pressed":r.template===e.key},(0,l.createElement)("span",{className:`dms-tpl-art dms-tpl-${e.key}`,style:{"--c":r.color}},(0,l.createElement)("i",null),(0,l.createElement)("b",null),(0,l.createElement)("em",null)),(0,l.createElement)("strong",null,e.label)))),(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(ie,{label:(0,i.__)("Colour","digimail-smtp"),value:r.color,onChange:e=>M("color",e),swatches:["#1b2550","#0f766e","#c2410c","#be123c","#7c3aed","#111827"]}),"split"===r.template&&(0,l.createElement)(y,{label:(0,i.__)("Picture","digimail-smtp")},(0,l.createElement)(ge,{value:r.image,onChange:e=>M("image",e)})))),(0,l.createElement)(E,{title:(0,i.__)("Form text","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Title","digimail-smtp"),htmlFor:"dmf-title"},(0,l.createElement)("input",{id:"dmf-title",value:r.title,maxLength:120,onChange:e=>M("title",e.target.value)})),"bar"!==r.type&&(0,l.createElement)(y,{label:(0,i.__)("Description","digimail-smtp"),htmlFor:"dmf-text"},(0,l.createElement)("textarea",{id:"dmf-text",rows:3,value:r.text,maxLength:400,onChange:e=>M("text",e.target.value)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Button","digimail-smtp"),htmlFor:"dmf-btn"},(0,l.createElement)("input",{id:"dmf-btn",value:r.button,maxLength:40,onChange:e=>M("button",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Email box hint","digimail-smtp"),htmlFor:"dmf-ph"},(0,l.createElement)("input",{id:"dmf-ph",value:r.email_ph,maxLength:60,onChange:e=>M("email_ph",e.target.value)}))),"bar"!==r.type&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(b,{checked:r.ask_name,onChange:e=>M("ask_name",e),label:(0,i.__)("Ask for a name","digimail-smtp"),hint:(0,i.__)("Lets your emails greet people by name. Each extra field means a few fewer signups.","digimail-smtp")}),(0,l.createElement)(b,{checked:r.ask_phone,onChange:e=>M("ask_phone",e),label:(0,i.__)("Ask for a phone number (optional for the visitor)","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Small print under the button","digimail-smtp"),htmlFor:"dmf-consent"},(0,l.createElement)("input",{id:"dmf-consent",value:r.consent,maxLength:240,onChange:e=>M("consent",e.target.value)}))))),(0,l.createElement)(E,{title:D?(0,i.__)("When and where it shows","digimail-smtp"):(0,i.__)("Where it goes","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},D&&"bar"!==r.type&&(0,l.createElement)(y,{label:(0,i.__)("Show it","digimail-smtp"),htmlFor:"dmf-trigger"},(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("select",{id:"dmf-trigger",value:r.trigger,onChange:e=>M("trigger",e.target.value)},(0,l.createElement)("option",{value:"delay"},(0,i.__)("After some seconds","digimail-smtp")),(0,l.createElement)("option",{value:"scroll"},(0,i.__)("After scrolling part of the page","digimail-smtp")),(0,l.createElement)("option",{value:"exit"},(0,i.__)("When the visitor is about to leave","digimail-smtp"))),"delay"===r.trigger&&(0,l.createElement)("label",{className:"dms-inline-num"},(0,l.createElement)("input",{type:"number",min:0,max:300,value:r.delay,onChange:e=>M("delay",Number(e.target.value))})," ",(0,i.__)("seconds","digimail-smtp")),"scroll"===r.trigger&&(0,l.createElement)("label",{className:"dms-inline-num"},(0,l.createElement)("input",{type:"number",min:5,max:100,value:r.scroll,onChange:e=>M("scroll",Number(e.target.value))})," %")),"exit"===r.trigger&&(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("On phones, which have no mouse, it shows after 20 seconds instead.","digimail-smtp"))),"slide"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Corner","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"left"===r.position?"is-on":"",onClick:()=>M("position","left")},(0,i.__)("Bottom left","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"left"!==r.position?"is-on":"",onClick:()=>M("position","right")},(0,i.__)("Bottom right","digimail-smtp")))),"bar"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Position","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"bottom"!==r.position?"is-on":"",onClick:()=>M("position","top")},(0,i.__)("Top of the page","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"bottom"===r.position?"is-on":"",onClick:()=>M("position","bottom")},(0,i.__)("Bottom of the screen","digimail-smtp")))),"inline"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Place","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"shortcode"===r.placement?"is-on":"",onClick:()=>M("placement","shortcode")},(0,i.__)("Where I paste the shortcode","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"after_post"===r.placement?"is-on":"",onClick:()=>M("placement","after_post")},(0,i.__)("After every blog post","digimail-smtp"))),"shortcode"===r.placement&&(r.id?(0,l.createElement)(ue,{id:r.id}):(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Save the form to get its shortcode.","digimail-smtp")))),(D||"after_post"===r.placement)&&(0,l.createElement)("div",{className:"dms-grid-2"},D&&(0,l.createElement)(y,{label:(0,i.__)("Pages","digimail-smtp"),htmlFor:"dmf-pages"},(0,l.createElement)("select",{id:"dmf-pages",value:r.pages,onChange:e=>M("pages",e.target.value)},(0,l.createElement)("option",{value:"all"},(0,i.__)("Every page","digimail-smtp")),(0,l.createElement)("option",{value:"home"},(0,i.__)("Home page only","digimail-smtp")),(0,l.createElement)("option",{value:"posts"},(0,i.__)("Blog posts","digimail-smtp")),(0,l.createElement)("option",{value:"pages"},(0,i.__)("Pages","digimail-smtp")),(0,l.createElement)("option",{value:"shop"},(0,i.__)("Shop and product pages","digimail-smtp")))),(0,l.createElement)(y,{label:(0,i.__)("Devices","digimail-smtp"),htmlFor:"dmf-dev"},(0,l.createElement)("select",{id:"dmf-dev",value:r.devices,onChange:e=>M("devices",e.target.value)},(0,l.createElement)("option",{value:"all"},(0,i.__)("Computers and phones","digimail-smtp")),(0,l.createElement)("option",{value:"desktop"},(0,i.__)("Computers only","digimail-smtp")),(0,l.createElement)("option",{value:"mobile"},(0,i.__)("Phones only","digimail-smtp"))))),D&&(0,l.createElement)(y,{label:(0,i.__)("After someone closes it","digimail-smtp"),htmlFor:"dmf-again"},(0,l.createElement)("label",{className:"dms-inline-num"},(0,i.__)("Show again after","digimail-smtp")," ",(0,l.createElement)("input",{id:"dmf-again",type:"number",min:0,max:365,value:r.again,onChange:e=>M("again",Number(e.target.value))})," ",(0,i.__)("days","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("People who sign up never see it again. Checkout, cart and account pages never show forms.","digimail-smtp"))),(0,l.createElement)(b,{checked:r.logged,onChange:e=>M("logged",e),label:(0,i.__)("Also show to logged-in users","digimail-smtp")}))),(0,l.createElement)(E,{title:(0,i.__)("After signing up","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Add to the DigiMail list","digimail-smtp"),htmlFor:"dmf-list"},(0,l.createElement)("select",{id:"dmf-list",value:r.list_id,onChange:e=>M("list_id",e.target.value)},(0,l.createElement)("option",{value:""},t.site_list?(0,i.sprintf)(/* translators: %s: list name. */ /* translators: %s: list name. */(0,i.__)("This website’s list (%s)","digimail-smtp"),t.site_list):(0,i.__)("This website’s list","digimail-smtp")),t.lists.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},e.name," (",d(e.subscribed),")")))),(0,l.createElement)(b,{checked:r.confirm,onChange:e=>M("confirm",e),label:(0,i.__)("Ask people to confirm by email (double opt-in)","digimail-smtp"),hint:(0,i.__)("They join the list only after clicking the link in a confirmation email. Fewer signups, but every address is real and wanted.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Message after signing up","digimail-smtp"),htmlFor:"dmf-ok"},(0,l.createElement)("input",{id:"dmf-ok",value:r.confirm?r.pending:r.success,maxLength:200,onChange:e=>M(r.confirm?"pending":"success",e.target.value)})),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("To send a welcome email, turn on the “Welcome new subscribers” series for this list on digimail.vn (Automation).","digimail-smtp"))))),(0,l.createElement)("div",{className:"dms-design-main"},(0,l.createElement)("div",{className:"dms-preview-bar"},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"desktop"===p?"is-on":"",onClick:()=>g("desktop")},(0,i.__)("Computer","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"mobile"===p?"is-on":"",onClick:()=>g("mobile")},(0,i.__)("Phone","digimail-smtp"))),k&&(0,l.createElement)("span",{className:"dms-spin","aria-label":(0,i.__)("Loading","digimail-smtp")}),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Preview: try the form, nothing is sent.","digimail-smtp"))),(0,l.createElement)("div",{className:`dms-form-stage is-${p}`},(0,l.createElement)("iframe",{title:(0,i.__)("Form preview","digimail-smtp"),srcDoc:u,sandbox:"allow-scripts"})))))}const Ee=[{key:"overview",label:(0,i.__)("Overview","digimail-smtp"),icon:"chart"},{key:"logs",label:(0,i.__)("Email log","digimail-smtp"),icon:"list"},{key:"contacts",label:(0,i.__)("Customers","digimail-smtp"),icon:"users"},{key:"forms",label:(0,i.__)("Signup forms","digimail-smtp"),icon:"form"},{key:"test",label:(0,i.__)("Test email","digimail-smtp"),icon:"send"},{key:"design",label:(0,i.__)("Email design","digimail-smtp"),icon:"palette"},{key:"shop",label:(0,i.__)("Shop","digimail-smtp"),icon:"cart"},{key:"settings",label:(0,i.__)("Settings","digimail-smtp"),icon:"settings"},{key:"tools",label:(0,i.__)("Tools","digimail-smtp"),icon:"tools"}],fe=()=>{const e=window.location.hash.replace("#","");return Ee.some(t=>t.key===e)?e:"overview"},be=document.getElementById("digimail-smtp-app");if(be){const e=(0,l.createElement)(function({children:e}){const[t,a]=(0,l.useState)([]),i=(0,l.useCallback)((e,t="ok")=>{const l=Date.now()+Math.random();a(a=>[...a,{id:l,msg:e,tone:t}]),setTimeout(()=>a(e=>e.filter(e=>e.id!==l)),4500)},[]);return(0,l.createElement)(S.Provider,{value:i},e,(0,l.createElement)("div",{className:"dms-toasts",role:"status","aria-live":"polite"},t.map(e=>(0,l.createElement)("div",{key:e.id,className:`dms-toast dms-toast-${e.tone}`},(0,l.createElement)(w,{name:"ok"===e.tone?"check":"alert",size:16}),e.msg))))},null,(0,l.createElement)(function(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(fe),[c,d]=(0,l.useState)(!1),p=(0,l.useCallback)(async(e=!1)=>{try{a(await o("state"+(e?"?refresh=1":""))),n("")}catch(e){n(e.message)}},[]);(0,l.useEffect)(()=>{p();const t=window.digimailSmtp?.flash;t&&e(t.message,t.ok?"ok":"bad")},[p,e]),(0,l.useEffect)(()=>{const e=()=>r(fe());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);const g=e=>{window.location.hash=e,r(e),window.scrollTo({top:0})};if(s&&!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("DigiMail SMTP could not load","digimail-smtp")},s));if(!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("div",{className:"dms-skel",style:{height:420}}));if(!t.connected)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(M,{state:t,reload:async()=>{await p(!0),d(!0),g("overview")}}));const u=t.status.sender;return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("header",{className:"dms-top"},(0,l.createElement)("div",{className:"dms-brand"},(0,l.createElement)("img",{src:window.digimailSmtp?.logo,alt:"",width:30,height:30}),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,"DigiMail SMTP"),(0,l.createElement)("span",null,t.revoked?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Disconnected","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i._x)("Active","connection status","digimail-smtp"))))),(0,l.createElement)("nav",{className:"dms-tabs","aria-label":"DigiMail SMTP"},Ee.filter(e=>"shop"!==e.key||t.capture.woocommerce).map(e=>(0,l.createElement)("a",{key:e.key,href:`#${e.key}`,className:m===e.key?"is-on":"","aria-current":m===e.key?"page":void 0,onClick:t=>{t.preventDefault(),g(e.key)}},(0,l.createElement)(w,{name:e.icon,size:16}),e.label,"logs"===e.key&&t.queue.failed>0&&(0,l.createElement)("span",{className:"dms-count"},t.queue.failed))))),t.revoked&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("This website was disconnected on digimail.vn","digimail-smtp"),action:(0,l.createElement)(f,{onClick:async()=>{await o("disconnect",{}),p(!0)}},(0,i.__)("Reconnect","digimail-smtp"))},t.settings.backup.enabled?(0,i.__)("Email is not going through DigiMail. The backup server is sending it.","digimail-smtp"):(0,i.__)("Email is not going through DigiMail.","digimail-smtp")),c&&u&&(0,l.createElement)("div",{className:"dms-welcome"},(0,l.createElement)("div",{className:"dms-welcome-icon"},(0,l.createElement)(w,{name:"check",size:28})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Done! This website can send email now.","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender email address. */ /* translators: %s: sender email address. */(0,i.__)("Email will be sent from <strong>%s</strong>. Send a test email to make sure everything works.","digimail-smtp"),u.email),{strong:(0,l.createElement)("strong",null)}))),(0,l.createElement)(f,{onClick:()=>{d(!1),g("test")}},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send a test email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Close","digimail-smtp"),onClick:()=>d(!1)},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("main",null,"overview"===m&&(0,l.createElement)(z,{state:t,go:g}),"logs"===m&&(0,l.createElement)(I,{reload:()=>p()}),"contacts"===m&&(0,l.createElement)(q,{state:t,go:g}),"test"===m&&(0,l.createElement)(V,{state:t,go:g}),"design"===m&&(0,l.createElement)(se,null),"shop"===m&&(0,l.createElement)(re,null),"forms"===m&&(0,l.createElement)(_e,null),"settings"===m&&(0,l.createElement)(Q,{state:t,setState:a}),"tools"===m&&(0,l.createElement)(Z,{state:t,setState:a})),(0,l.createElement)("footer",{className:"dms-foot"},"DigiMail SMTP ",t.env.plugin," · ",(0,l.createElement)("a",{href:t.env.app,target:"_blank",rel:"noreferrer"},"digimail.vn")))},null));"function"==typeof l.createRoot?(0,l.createRoot)(be).render(e):(0,l.render)(e,be)}}};const t={};function a(l){const i=t[l];if(void 0!==i)return i.exports;const s=t[l]={exports:{}};return e[l](s,s.exports,a),s.exports}a.m=e,(()=>{const e=[];a.O=(t,l,i)=>{if(!l){for(var s=0;s<e.length;s++){let[l,i]=e[s],m=!0;for(var n=0;n<l.length;n++)a.O.j(l[n])?l.splice(n--,1):m=!1;if(m){e.splice(s--,1);const a=i();void 0!==a&&(t=a)}}return t}e.push([l,i])}})(),a.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.hasOwn(e,t),(()=>{const e={57:0,350:0};a.O.j=t=>0===e[t];const t=(t,l)=>{let[i,s,n]=l;var m,r,o=0;if(i.some(t=>0!==e[t])){for(m in s)a.o(s,m)&&(a.m[m]=s[m]);if(n)var c=n(a)}for(t&&t(l);o<i.length;o++)r=i[o],a.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return a.O(c)},l=Array.isArray(globalThis.webpackChunkdigimail_smtp)?globalThis.webpackChunkdigimail_smtp:globalThis.webpackChunkdigimail_smtp=[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();let l=a.O(void 0,[350],()=>a(897));l=a.O(l)})(); -
digimail-smtp/tags/2.9.0/digimail-smtp.php
r3830946 r3831455 4 4 * Plugin URI: https://digimail.vn 5 5 * Description: Send WordPress email without setting up SMTP: activate, enter your email, and your site sends mail right away. Email log with real delivery status, background sending, backup connection, email controls, and many sites managed on digimail.vn. 6 * Version: 2. 8.06 * Version: 2.9.0 7 7 * Requires at least: 6.2 8 8 * Requires PHP: 7.4 … … 20 20 } 21 21 22 define( 'DIGIMAIL_SMTP_VERSION', '2. 8.0' );22 define( 'DIGIMAIL_SMTP_VERSION', '2.9.0' ); 23 23 define( 'DIGIMAIL_SMTP_FILE', __FILE__ ); 24 24 define( 'DIGIMAIL_SMTP_DIR', plugin_dir_path( __FILE__ ) ); -
digimail-smtp/tags/2.9.0/includes/Connect.php
r3829755 r3831455 176 176 if ( ! Options::connected() ) { 177 177 return; 178 } 179 if ( Guard::enabled() ) { 180 Guard::refresh_tor(); 178 181 } 179 182 global $wp_version; -
digimail-smtp/tags/2.9.0/includes/Guard.php
r3830946 r3831455 21 21 * visitor types. On submit, those signals are scored together with the 22 22 * content (links, foreign scripts, gibberish names, throwaway addresses, 23 * the site's own comment blocklist, Akismet when set up) and how often the 24 * same visitor or message came in. Submissions that score 100 or more are 25 * refused before the form plugin sends any email, and kept in a local log 26 * so the site owner can put back anything blocked by mistake. 23 * Gmail addresses with random dots, the site's own comment blocklist, 24 * Akismet when set up), whether the visitor came through Tor, and how often 25 * the same visitor, mailbox or message came in. Submissions that score 100 26 * or more are refused before the form plugin sends any email, and kept in a 27 * local log so the site owner can put back anything blocked by mistake. 28 * 29 * WordPress's own registration, lost password and comment forms are 30 * covered too: bots use them to make the site email addresses they type. 31 * The trap field's name differs on every site, and logged-in admins see a 32 * small note under each form saying whether it is protected. 27 33 */ 28 34 final class Guard { … … 33 39 const SECRET = 'digimail_smtp_guard_secret'; 34 40 const ALLOW = 'digimail_smtp_guard_allow'; 41 const TOR = 'digimail_smtp_guard_tor'; 42 const TOR_CRON = 'digimail_smtp_guard_tor'; 35 43 const THRESHOLD = 100; 36 44 const MAX_LOG = 300; … … 44 52 45 53 /** 54 * WordPress and WooCommerce account forms: a person blocked there is not 55 * a form contact, so "not spam" does not add them to the contact list. 56 */ 57 const CORE = array( 'wp-register', 'wp-lostpassword', 'wp-comments', 'woo-register' ); 58 59 /** 46 60 * Verdict of the current request, once a form was checked. 47 61 * … … 59 73 } 60 74 add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue' ) ); 75 add_action( self::TOR_CRON, array( __CLASS__, 'refresh_tor' ) ); 61 76 add_filter( 'wpcf7_spam', array( __CLASS__, 'cf7' ), 20, 2 ); 62 77 add_filter( 'wpforms_process_initial_errors', array( __CLASS__, 'wpforms' ), 20, 2 ); … … 68 83 add_filter( 'bricks/form/validate', array( __CLASS__, 'bricks' ), 20, 2 ); 69 84 add_action( 'woocommerce_after_checkout_validation', array( __CLASS__, 'woo' ), 20, 2 ); 85 $g = Options::get( 'guard' ); 86 if ( ! empty( $g['core'] ) ) { 87 add_action( 'login_enqueue_scripts', array( __CLASS__, 'enqueue' ) ); 88 add_filter( 'registration_errors', array( __CLASS__, 'register' ), 20, 3 ); 89 add_filter( 'woocommerce_registration_errors', array( __CLASS__, 'woo_register' ), 20, 3 ); 90 add_action( 'lostpassword_post', array( __CLASS__, 'lostpassword' ), 20, 2 ); 91 add_filter( 'pre_comment_approved', array( __CLASS__, 'comment' ), 20, 2 ); 92 } 70 93 } 71 94 … … 113 136 */ 114 137 public static function enqueue() { 138 $g = Options::get( 'guard' ); 139 $cfg = array( 140 'url' => rest_url( Rest::NS . '/guard' ), 141 'trap' => self::trap_name(), 142 'core' => ! empty( $g['core'] ), 143 ); 144 if ( ! empty( $g['badge'] ) && current_user_can( 'manage_options' ) ) { 145 // Only for admins (their pages are not cached for visitors). 146 $cfg['badge'] = array( 147 'checking' => __( 'DigiMail spam guard: checking this form…', 'digimail-smtp' ), 148 'ok' => __( 'Protected by the DigiMail spam guard. Only admins see this note.', 'digimail-smtp' ), 149 /* translators: %s: address of the token route. */ 150 'failed' => sprintf( __( 'DigiMail spam guard could not get its token, so real visitors may be refused. Check that no cache or security plugin blocks %s.', 'digimail-smtp' ), rest_url( Rest::NS . '/guard' ) ), 151 'none' => __( 'This form is not protected by the DigiMail spam guard (its form plugin is not supported yet). Only admins see this note.', 'digimail-smtp' ), 152 ); 153 } 115 154 wp_enqueue_script( 'digimail-smtp-guard', plugins_url( 'assets/guard.js', DIGIMAIL_SMTP_FILE ), array(), DIGIMAIL_SMTP_VERSION, array( 'in_footer' => true ) ); 116 wp_add_inline_script( 'digimail-smtp-guard', 'window.digimailSmtpGuard=' . wp_json_encode( array( 'url' => rest_url( Rest::NS . '/guard' ) ) ) . ';', 'before' ); 155 wp_add_inline_script( 'digimail-smtp-guard', 'window.digimailSmtpGuard=' . wp_json_encode( $cfg ) . ';', 'before' ); 156 } 157 158 /** 159 * This site's own name for the trap field, so a bot written against the 160 * plugin cannot simply leave a known field empty. It looks like a field a 161 * bot wants to fill, and starts with "_" so form plugins do not store it. 162 * 163 * @return string 164 */ 165 public static function trap_name() { 166 $h = hash_hmac( 'sha256', 'trap-field', self::secret() ); 167 $words = array( 'website', 'url', 'homepage', 'web_address', 'site_link', 'company_url' ); 168 return '_' . $words[ hexdec( substr( $h, 0, 2 ) ) % count( $words ) ] . '_' . substr( $h, 2, 4 ); 117 169 } 118 170 … … 247 299 } 248 300 301 /** 302 * The trap field: this site's name, or the fixed names used before 2.9.0 303 * (pages cached with the old script). 304 * 305 * @param array $post Posted data. 306 * @return string 307 */ 308 private static function trap( array $post ) { 309 $name = self::trap_name(); 310 if ( isset( $post[ $name ] ) && is_scalar( $post[ $name ] ) ) { 311 return sanitize_text_field( wp_unslash( (string) $post[ $name ] ) ); 312 } 313 return self::field( $post, 'url' ); 314 } 315 249 316 // ---------- scoring ---------- 250 317 … … 281 348 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- public forms; the form plugin checks its own nonce. 282 349 $post = isset( $opts['post'] ) && is_array( $opts['post'] ) ? $opts['post'] : $_POST; 283 $hp = trim( self:: field( $post, 'url') );350 $hp = trim( self::trap( $post ) ); 284 351 $js = '' !== self::field( $post, 'js' ); 285 352 $token = self::field( $post, 't' ); … … 346 413 $add( 60, 'too_many' ); 347 414 } 415 if ( self::tor( $ip ) ) { 416 // Tor gives a bot a new IP for each submission, so the limits above 417 // never trip. Real visitors of these sites almost never use it. 418 $add( 60, 'tor' ); 419 } 348 420 349 421 if ( $opts['content'] && ! $allowed ) { … … 354 426 if ( '' !== $p['email'] && self::disposable( $p['email'] ) ) { 355 427 $add( 60, 'disposable_email' ); 428 } 429 $dots = '' !== $p['email'] ? self::dotted( $p['email'] ) : 0; 430 if ( 2 === $dots ) { 431 $add( 60, 'dotted_gmail' ); 432 } elseif ( 1 === $dots ) { 433 $add( 30, 'dotted_gmail' ); 434 } 435 $spellings = '' !== $p['email'] ? self::spellings( $p['email'] ) : 0; 436 if ( $spellings >= 3 ) { 437 $add( 100, 'gmail_variants' ); 438 } elseif ( 2 === $spellings ) { 439 $add( 40, 'gmail_variants' ); 356 440 } 357 441 if ( function_exists( 'wp_check_comment_disallowed_list' ) && '' !== trim( (string) get_option( 'disallowed_keys' ) ) … … 487 571 $list = apply_filters( 'digimail_smtp_disposable_domains', $list ); 488 572 return in_array( $domain, $list, true ); 573 } 574 575 /** 576 * The mailbox a Gmail address really goes to: Gmail ignores dots and 577 * anything after "+". Empty for other providers, where dots matter. 578 * 579 * @param string $email Email. 580 * @return string 581 */ 582 public static function gmail_base( $email ) { 583 $email = strtolower( trim( (string) $email ) ); 584 $at = strrpos( $email, '@' ); 585 if ( false === $at ) { 586 return ''; 587 } 588 $domain = substr( $email, $at + 1 ); 589 if ( 'gmail.com' !== $domain && 'googlemail.com' !== $domain ) { 590 return ''; 591 } 592 $local = explode( '+', substr( $email, 0, $at ) ); 593 $local = str_replace( '.', '', $local[0] ); 594 return '' === $local ? '' : $local . '@gmail.com'; 595 } 596 597 /** 598 * Gmail address with dots sprinkled in, such as bi.f.ewoy.oxu.s00.8@gmail.com: 599 * bots do this so one mailbox looks like a new person on every form. 600 * 601 * @param string $email Email. 602 * @return int 2: bot pattern (3+ dots with a one-letter piece, or 5+ dots); 603 * 1: 3 or 4 dots (also real names like nguyen.thi.thu.ha); 0: no. 604 */ 605 public static function dotted( $email ) { 606 if ( '' === self::gmail_base( $email ) ) { 607 return 0; 608 } 609 $email = strtolower( trim( (string) $email ) ); 610 $local = explode( '+', substr( $email, 0, (int) strrpos( $email, '@' ) ) ); 611 $parts = explode( '.', $local[0] ); 612 $dots = count( $parts ) - 1; 613 if ( $dots < 3 ) { 614 return 0; 615 } 616 $single = (bool) array_filter( 617 $parts, 618 static function ( $x ) { 619 return 1 === strlen( $x ); 620 } 621 ); 622 return ( $dots >= 5 || $single ) ? 2 : 1; 623 } 624 625 /** 626 * How many different spellings of one Gmail mailbox were sent in the last 627 * day, this one included. People type their address the same way each 628 * time; bots change the dots on every try. 629 * 630 * @param string $email Email. 631 * @return int 0 for addresses that are not Gmail. 632 */ 633 private static function spellings( $email ) { 634 $base = self::gmail_base( $email ); 635 if ( '' === $base ) { 636 return 0; 637 } 638 $key = 'digimail_smtp_gv_' . md5( $base . self::secret() ); 639 $seen = get_transient( $key ); 640 $seen = is_array( $seen ) ? $seen : array(); 641 $spell = md5( strtolower( trim( $email ) ) ); 642 $seen[ $spell ] = 1; 643 set_transient( $key, array_slice( $seen, -10, null, true ), DAY_IN_SECONDS ); 644 return count( $seen ); 645 } 646 647 /** 648 * Whether the visitor came through a Tor exit node. The list comes from 649 * DigiMail (which takes it from the Tor Project) twice a day, only while 650 * the site is connected. 651 * 652 * @param string $ip IP. 653 * @return bool 654 */ 655 public static function tor( $ip ) { 656 if ( '' === $ip ) { 657 return false; 658 } 659 $t = get_option( self::TOR, array() ); 660 $t = is_array( $t ) ? $t : array(); 661 if ( ( empty( $t['at'] ) || (int) $t['at'] < time() - 36 * HOUR_IN_SECONDS ) && Options::connected() && ! wp_next_scheduled( self::TOR_CRON ) ) { 662 wp_schedule_single_event( time() + 30, self::TOR_CRON ); 663 } 664 return ! empty( $t['ips'] ) && is_array( $t['ips'] ) && isset( $t['ips'][ $ip ] ); 665 } 666 667 /** 668 * Downloads the Tor exit list from DigiMail. 669 * 670 * @return bool Whether a list was saved. 671 */ 672 public static function refresh_tor() { 673 if ( ! Options::connected() ) { 674 return false; 675 } 676 $r = Api::get( '/v1/wp/tor-exits' ); 677 if ( empty( $r['ok'] ) || empty( $r['data']['ips'] ) || ! is_array( $r['data']['ips'] ) ) { 678 return false; 679 } 680 $ips = array(); 681 foreach ( $r['data']['ips'] as $ip ) { 682 if ( is_string( $ip ) && filter_var( $ip, FILTER_VALIDATE_IP ) ) { 683 $ips[ $ip ] = 1; 684 } 685 } 686 if ( count( $ips ) < 100 ) { 687 return false; 688 } 689 update_option( 690 self::TOR, 691 array( 692 'at' => time(), 693 'ips' => $ips, 694 ), 695 false 696 ); 697 return true; 489 698 } 490 699 … … 639 848 } 640 849 $key = 'digimail_smtp_gm_' . md5( $norm ); 641 $ips = (array) get_transient( $key ); 850 $ips = get_transient( $key ); 851 $ips = is_array( $ips ) ? $ips : array(); 642 852 $hash = md5( $ip ); 643 853 $ips[ $hash ] = 1; … … 821 1031 update_option( self::ALLOW, array_slice( array_values( array_unique( $allow ) ), -500 ), false ); 822 1032 $c = Options::get( 'capture' ); 823 // Signups from DigiMail forms always go to DigiMail. 824 if ( ( ! empty( $c['enabled'] ) || 'digimail' === $found['source'] ) && Options::connected() ) { 1033 // Signups from DigiMail forms always go to DigiMail; account and 1034 // comment forms never do. 1035 if ( ( ! empty( $c['enabled'] ) || 'digimail' === $found['source'] ) && ! in_array( $found['source'], self::CORE, true ) && Options::connected() ) { 825 1036 Contacts::add( 826 1037 $found['email'], … … 1186 1397 return $v; 1187 1398 } 1399 1400 // ---------- WordPress account and comment forms ---------- 1401 1402 /** 1403 * Whether this request was already checked (a WooCommerce checkout that 1404 * also creates an account runs both hooks). 1405 * 1406 * @return bool 1407 */ 1408 private static function checked() { 1409 return null !== self::$verdict; 1410 } 1411 1412 /** 1413 * WordPress registration (wp-login.php?action=register). 1414 * 1415 * @param \WP_Error $errors Errors. 1416 * @param string $login Username. 1417 * @param string $email Email. 1418 * @return \WP_Error 1419 */ 1420 public static function register( $errors, $login = '', $email = '' ) { 1421 return self::account( 'wp-register', $errors, $login, $email ); 1422 } 1423 1424 /** 1425 * WooCommerce "My account" registration. 1426 * 1427 * @param \WP_Error $errors Errors. 1428 * @param string $login Username. 1429 * @param string $email Email. 1430 * @return \WP_Error 1431 */ 1432 public static function woo_register( $errors, $login = '', $email = '' ) { 1433 return self::account( 'woo-register', $errors, $login, $email ); 1434 } 1435 1436 /** 1437 * Checks a new account. 1438 * 1439 * @param string $source Source slug. 1440 * @param \WP_Error $errors Errors. 1441 * @param string $login Username. 1442 * @param string $email Email. 1443 * @return \WP_Error 1444 */ 1445 private static function account( $source, $errors, $login, $email ) { 1446 if ( ! is_object( $errors ) || ! method_exists( $errors, 'add' ) || ( method_exists( $errors, 'has_errors' ) && $errors->has_errors() ) || self::checked() || is_user_logged_in() ) { 1447 return $errors; 1448 } 1449 $v = self::check( 1450 $source, 1451 __( 'Registration', 'digimail-smtp' ), 1452 array( 1453 array( 1454 'key' => 'email', 1455 'type' => 'email', 1456 'value' => (string) $email, 1457 ), 1458 array( 1459 'key' => 'name', 1460 'type' => 'text', 1461 'value' => (string) $login, 1462 ), 1463 ) 1464 ); 1465 if ( $v['spam'] ) { 1466 $errors->add( 'digimail_spam', self::message() ); 1467 } 1468 return $errors; 1469 } 1470 1471 /** 1472 * Lost password form: bots use it to make the site email real users. 1473 * 1474 * @param \WP_Error $errors Errors. 1475 * @param \WP_User|false $user_data The account, if found. 1476 */ 1477 public static function lostpassword( $errors, $user_data = false ) { 1478 // Admins sending a reset link from the Users screen are logged in. 1479 if ( ! is_object( $errors ) || ! method_exists( $errors, 'add' ) || ( method_exists( $errors, 'has_errors' ) && $errors->has_errors() ) || self::checked() || is_user_logged_in() ) { 1480 return; 1481 } 1482 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- core form without a nonce; the value is only scored. 1483 $typed = isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ? sanitize_text_field( wp_unslash( $_POST['user_login'] ) ) : ''; 1484 if ( '' === $typed && is_object( $user_data ) && isset( $user_data->user_email ) ) { 1485 $typed = (string) $user_data->user_email; 1486 } 1487 $is_email = false !== strpos( $typed, '@' ); 1488 $v = self::check( 1489 'wp-lostpassword', 1490 __( 'Lost password', 'digimail-smtp' ), 1491 array( 1492 array( 1493 'key' => $is_email ? 'email' : 'name', 1494 'type' => $is_email ? 'email' : 'text', 1495 'value' => $typed, 1496 ), 1497 ) 1498 ); 1499 if ( $v['spam'] ) { 1500 $errors->add( 'digimail_spam', self::message() ); 1501 } 1502 } 1503 1504 /** 1505 * Comments sent with the theme's comment form: spam goes to the Spam 1506 * folder, so no moderation email goes out. 1507 * 1508 * @param int|string|\WP_Error $approved Approval status. 1509 * @param array $commentdata Comment. 1510 * @return int|string|\WP_Error 1511 */ 1512 public static function comment( $approved, $commentdata = array() ) { 1513 global $pagenow; 1514 if ( 'wp-comments-post.php' !== $pagenow || is_user_logged_in() || is_wp_error( $approved ) || in_array( $approved, array( 'spam', 'trash' ), true ) || self::checked() ) { 1515 return $approved; 1516 } 1517 $c = is_array( $commentdata ) ? $commentdata : array(); 1518 $type = isset( $c['comment_type'] ) ? (string) $c['comment_type'] : ''; 1519 if ( '' !== $type && 'comment' !== $type ) { 1520 return $approved; 1521 } 1522 $v = self::check( 1523 'wp-comments', 1524 __( 'Comments', 'digimail-smtp' ), 1525 array( 1526 array( 1527 'key' => 'name', 1528 'type' => 'text', 1529 'value' => isset( $c['comment_author'] ) ? $c['comment_author'] : '', 1530 ), 1531 array( 1532 'key' => 'email', 1533 'type' => 'email', 1534 'value' => isset( $c['comment_author_email'] ) ? $c['comment_author_email'] : '', 1535 ), 1536 array( 1537 'key' => 'comment', 1538 'type' => 'textarea', 1539 'value' => isset( $c['comment_content'] ) ? $c['comment_content'] : '', 1540 ), 1541 ) 1542 ); 1543 return $v['spam'] ? 'spam' : $approved; 1544 } 1188 1545 } -
digimail-smtp/tags/2.9.0/includes/Options.php
r3830740 r3831455 57 57 'enabled' => true, 58 58 'akismet' => false, 59 'core' => true, 60 'badge' => true, 59 61 ), 60 62 'keep_data' => false, -
digimail-smtp/tags/2.9.0/includes/Plugin.php
r3830946 r3831455 75 75 wp_clear_scheduled_hook( self::CRON_QUEUE ); 76 76 wp_clear_scheduled_hook( Contacts::CRON ); 77 wp_clear_scheduled_hook( Guard::TOR_CRON ); 77 78 } 78 79 -
digimail-smtp/tags/2.9.0/includes/Rest.php
r3830946 r3831455 453 453 'enabled' => ! empty( $in['guard']['enabled'] ), 454 454 'akismet' => ! empty( $in['guard']['akismet'] ), 455 'core' => ! empty( $in['guard']['core'] ), 456 'badge' => ! empty( $in['guard']['badge'] ), 455 457 ); 456 458 } -
digimail-smtp/tags/2.9.0/readme.txt
r3830946 r3831455 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 2. 8.07 Stable tag: 2.9.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 36 36 * Save form contacts to DigiMail (optional): email, name and phone from your forms and WooCommerce orders go into a contact list on digimail.vn for your campaigns. 37 37 * Customers tab: see who filled in which form, on which page and when, filter by form, search, and export to CSV. 38 * Form spam guard (on by default): stops bots before a form sends any email, with no puzzle for visitors. A hidden trap field, a signed token with a small proof-of-work solved by the browser, timing and interaction checks, rate limits, content checks (links in name fields, foreign scripts, random names, throwaway addresses, your comment blocklist). Optionally, and off by default, doubtful submissions can also be checked by Akismet if your site uses it. Blocked submissions are listed so you can put back anything blocked by mistake.38 * Form spam guard (on by default): stops bots before a form sends any email, with no puzzle for visitors. A hidden trap field, a signed token with a small proof-of-work solved by the browser, timing and interaction checks, rate limits, content checks (links in name fields, foreign scripts, random names, throwaway addresses, Gmail addresses with random dots, your comment blocklist) and visitors coming through the Tor network. Also protects WordPress registration, lost password and comment forms and WooCommerce account registration. The trap field has its own name on every site, and when you are logged in as an admin each form shows a small note saying whether it is protected. Optionally, and off by default, doubtful submissions can also be checked by Akismet if your site uses it. Blocked submissions are listed so you can put back anything blocked by mistake. 39 39 * Verify your own domain from the plugin: the DNS records to add with copy buttons and live status, one-click setup through Cloudflare, a zone file to import, and the plugin switches to your domain by itself once verified. 40 40 * Alerts by Telegram and email: failing emails, quota nearly used up, rising bounces or spam reports, a plugin that stopped reporting, forms hit by bots, domain verified or failing. … … 54 54 This plugin connects to the DigiMail service, operated by DigiMail (digimail.vn). It is required: without it the plugin cannot send email, except through the optional backup SMTP server you configure yourself. 55 55 56 * **api.digimail.vn** — When you connect, the plugin sends your email address (quick start), the site URL and site name. Every time WordPress sends an email, the full message (recipients, subject, body, attachments, headers) and the name of the plugin that sent it are sent to DigiMail so it can be delivered. Twice a day the plugin sends a status check with the site URL and name, the plugin version, how many emails are waiting or failed on the site, and the spam guard's on/off state and counts of checked and blocked submissions, so DigiMail can warn you about mail that is not going out. Only if you turn on "Share diagnostics with DigiMail support" (off by default) does it also include the WordPress, PHP and WooCommerce versions, site language, multisite, a few of this plugin's settings and the names of other active email plugins. When you open the plugin screens, the plugin requests your send log, statistics and account status. If you turn on "Save form contacts to DigiMail", the email, name, phone and company that visitors enter in supported forms or at WooCommerce checkout, with the form name and page, are sent to DigiMail and added to your contact list. When a visitor signs up with one of this plugin's signup forms, the email, name and phone they type, the form's name, the page address, the chosen list and whether to send a confirmation email are sent to DigiMail; DigiMail adds them to your list or emails them a confirmation link. If you turn on "Shop emails" (off by default), each WooCommerce order (number, status, total, billing email and name, products with their picture and link, and whether the shopper ticked the newsletter checkbox) and, when a shopper types their email at checkout, the cart's products, total and that email are sent to DigiMail, so it can send the thank-you, abandoned cart and review emails you turn on and report the revenue they bring. Emails sent while an anonymous visitor submits a form are marked so DigiMail can check unfamiliar recipients before sending; if one of the recipients is the site's admin email, the message says so, so that address is not checked. The spam guard itself runs on your site and sends nothing to DigiMail .56 * **api.digimail.vn** — When you connect, the plugin sends your email address (quick start), the site URL and site name. Every time WordPress sends an email, the full message (recipients, subject, body, attachments, headers) and the name of the plugin that sent it are sent to DigiMail so it can be delivered. Twice a day the plugin sends a status check with the site URL and name, the plugin version, how many emails are waiting or failed on the site, and the spam guard's on/off state and counts of checked and blocked submissions, so DigiMail can warn you about mail that is not going out. Only if you turn on "Share diagnostics with DigiMail support" (off by default) does it also include the WordPress, PHP and WooCommerce versions, site language, multisite, a few of this plugin's settings and the names of other active email plugins. When you open the plugin screens, the plugin requests your send log, statistics and account status. If you turn on "Save form contacts to DigiMail", the email, name, phone and company that visitors enter in supported forms or at WooCommerce checkout, with the form name and page, are sent to DigiMail and added to your contact list. When a visitor signs up with one of this plugin's signup forms, the email, name and phone they type, the form's name, the page address, the chosen list and whether to send a confirmation email are sent to DigiMail; DigiMail adds them to your list or emails them a confirmation link. If you turn on "Shop emails" (off by default), each WooCommerce order (number, status, total, billing email and name, products with their picture and link, and whether the shopper ticked the newsletter checkbox) and, when a shopper types their email at checkout, the cart's products, total and that email are sent to DigiMail, so it can send the thank-you, abandoned cart and review emails you turn on and report the revenue they bring. Emails sent while an anonymous visitor submits a form are marked so DigiMail can check unfamiliar recipients before sending; if one of the recipients is the site's admin email, the message says so, so that address is not checked. The spam guard itself runs on your site and sends nothing to DigiMail; twice a day, while the guard is on, the plugin downloads from DigiMail the current list of Tor network exit addresses (DigiMail takes it from the Tor Project) and sends nothing with that request except its site key. 57 57 * **Cloudflare** (only if you choose *Add records in Cloudflare*) — The Cloudflare API token you paste is sent to DigiMail, stored encrypted, and used by DigiMail to add your domain's DNS records through the Cloudflare API. Cloudflare terms: https://www.cloudflare.com/website-terms/ — Privacy: https://www.cloudflare.com/privacypolicy/ 58 58 * **Telegram** (only if you connect Telegram alerts) — *Connect Telegram* opens t.me in your browser to start a chat with DigiMail's bot. The plugin sends nothing to Telegram; DigiMail's server sends the alerts. Telegram terms: https://telegram.org/tos — Privacy: https://telegram.org/privacy … … 121 121 == Changelog == 122 122 123 = 2.9.0 = 124 * Spam guard now protects WordPress registration, lost password and comment forms and WooCommerce account registration (can be turned off). Spam comments go to the Spam folder. 125 * Admins see a note under each form on the site: protected, not protected (form plugin not supported), or the guard could not get its token. 126 * The hidden trap field has its own name on each site. 127 * Catches bots that sign up with Gmail addresses full of random dots (bi.f.ewoy.oxu.s00.8@gmail.com), that send the same Gmail mailbox with different dots, or that come through the Tor network. 128 * Fix: the "same message from several visitors" check triggered one visitor too early. 129 123 130 = 2.8.0 = 124 131 * New Signup forms tab: popups, slide-ins, bars and in-page forms in four designs, with display rules, a live preview, optional double opt-in and views and signups for each form. … … 194 201 == Upgrade Notice == 195 202 203 = 2.9.0 = 204 Stronger spam guard: also protects registration, lost password and comments, blocks bots using Gmail addresses with random dots or Tor, and shows admins which forms are protected. 205 196 206 = 2.8.0 = 197 207 New Signup forms tab: popups, slide-ins, bars and in-page forms that add visitors to your DigiMail list. -
digimail-smtp/tags/2.9.0/src/Guard.tsx
r3829755 r3831455 17 17 <Toggle checked={ g.enabled } onChange={ ( v ) => set( { enabled: v } ) } label={ __( 'Stop bots before the form sends any email', 'digimail-smtp' ) } 18 18 hint={ __( 'Invisible to visitors: no puzzle, nothing to click. Bot submissions are refused, so no notification or auto-reply goes out and nothing reaches your contact list. Works with Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks and WooCommerce checkout.', 'digimail-smtp' ) } /> 19 { g.enabled && ( 20 <Toggle checked={ g.core } onChange={ ( v ) => set( { core: v } ) } label={ __( 'Also protect WordPress registration, lost password and comment forms', 'digimail-smtp' ) } 21 hint={ __( 'Bots use these forms to make your site email addresses they type in. Includes WooCommerce account registration. Logged-in users are never checked; spam comments go to the Spam folder.', 'digimail-smtp' ) } /> 22 ) } 23 { g.enabled && ( 24 <Toggle checked={ g.badge } onChange={ ( v ) => set( { badge: v } ) } label={ __( 'Show admins a note under each form', 'digimail-smtp' ) } 25 hint={ __( 'When you are logged in as an admin, each form on your site shows whether the spam guard protects it. Visitors never see it.', 'digimail-smtp' ) } /> 26 ) } 19 27 { g.enabled && ( 20 28 <Toggle checked={ g.akismet && sum.akismet } disabled={ ! sum.akismet } onChange={ ( v ) => set( { akismet: v } ) } label={ __( 'Also ask Akismet', 'digimail-smtp' ) } -
digimail-smtp/tags/2.9.0/src/api.ts
r3830946 r3831455 46 46 controls: Record< string, boolean >; 47 47 capture: { enabled: boolean; forms: boolean; woocommerce: boolean }; 48 guard: { enabled: boolean; akismet: boolean };48 guard: { enabled: boolean; akismet: boolean; core: boolean; badge: boolean }; 49 49 keep_data: boolean; 50 50 diagnostics: boolean; … … 120 120 repeated: __( 'Same message from several visitors', 'digimail-smtp' ), 121 121 disposable_email: __( 'Throwaway email address', 'digimail-smtp' ), 122 dotted_gmail: __( 'Gmail address with random dots (bi.f.ewoy…@gmail.com)', 'digimail-smtp' ), 123 gmail_variants: __( 'Same Gmail mailbox sent with different dots', 'digimail-smtp' ), 124 tor: __( 'Sent through the Tor network', 'digimail-smtp' ), 122 125 blocklist: __( 'Matches the comment blocklist in Settings › Discussion', 'digimail-smtp' ), 123 126 akismet: __( 'Akismet says spam', 'digimail-smtp' ), … … 241 244 'ultimate-member': 'Ultimate Member', 242 245 'bricks': 'Bricks', 246 'wp-register': __( 'WordPress registration', 'digimail-smtp' ), 247 'wp-lostpassword': __( 'WordPress lost password', 'digimail-smtp' ), 248 'wp-comments': __( 'WordPress comments', 'digimail-smtp' ), 249 'woo-register': __( 'WooCommerce registration', 'digimail-smtp' ), 243 250 }; 244 251 if ( s.startsWith( 'theme:' ) ) { -
digimail-smtp/tags/2.9.0/uninstall.php
r3830946 r3831455 17 17 global $wpdb; 18 18 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}digimail_smtp_queue" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 19 foreach ( array( 'digimail_smtp_settings', 'digimail_smtp_token', 'digimail_smtp_status', 'digimail_smtp_db', 'digimail_smtp_revoked', 'digimail_smtp_last_failure', 'digimail_smtp_imported', 'digimail_smtp_contacts', 'digimail_smtp_contacts_last', 'digimail_smtp_guard_log', 'digimail_smtp_guard_stats', 'digimail_smtp_guard_seen', 'digimail_smtp_guard_secret', 'digimail_smtp_guard_allow', 'digimail_smtp_ limit_hit', 'digimail_smtp_review', 'digimail_smtp_design', 'digimail_smtp_shop_events', 'digimail_smtp_shop_last', 'digimail_smtp_forms', 'digimail_smtp_form_stats' ) as $digimail_smtp_option ) {19 foreach ( array( 'digimail_smtp_settings', 'digimail_smtp_token', 'digimail_smtp_status', 'digimail_smtp_db', 'digimail_smtp_revoked', 'digimail_smtp_last_failure', 'digimail_smtp_imported', 'digimail_smtp_contacts', 'digimail_smtp_contacts_last', 'digimail_smtp_guard_log', 'digimail_smtp_guard_stats', 'digimail_smtp_guard_seen', 'digimail_smtp_guard_secret', 'digimail_smtp_guard_allow', 'digimail_smtp_guard_tor', 'digimail_smtp_limit_hit', 'digimail_smtp_review', 'digimail_smtp_design', 'digimail_smtp_shop_events', 'digimail_smtp_shop_last', 'digimail_smtp_forms', 'digimail_smtp_form_stats' ) as $digimail_smtp_option ) { 20 20 delete_option( $digimail_smtp_option ); 21 21 } … … 25 25 wp_clear_scheduled_hook( 'digimail_smtp_contacts' ); 26 26 wp_clear_scheduled_hook( 'digimail_smtp_shop' ); 27 wp_clear_scheduled_hook( 'digimail_smtp_guard_tor' ); -
digimail-smtp/trunk/assets/guard.js
r3829755 r3831455 3 3 * 4 4 * - _digimail_smtp_js: the browser ran this script (bots that post directly do not). 5 * - _digimail_smtp_url: a trap field people never see; bots that fill every field do. 5 * - a trap field people never see (its name differs per site, cfg.trap); bots 6 * that fill every field fill it too. 6 7 * - _digimail_smtp_t: a signed token fetched after the page loads, with the answer to a 7 8 * small proof-of-work the browser finds while the visitor types ("p" and … … 10 11 * - _digimail_smtp_i: how many real key presses, clicks or touches happened in the form. 11 12 * 12 * Nothing is shown to visitors and nothing is stored in the browser. 13 * Nothing is shown to visitors and nothing is stored in the browser. Logged-in 14 * admins (cfg.badge) see a short note under each form: protected, token 15 * failed, or (for forms with an email field this script does not cover) not 16 * protected. 13 17 */ 14 18 ( function () { … … 28 32 'form.woocommerce-checkout', 29 33 'form[data-dms-guard]', 30 ].join( ',' ); 34 ] 35 .concat( cfg.core ? [ '#registerform', '#lostpasswordform', 'form.woocommerce-form-register', 'form.woocommerce-ResetPassword', '#commentform', 'form.comment-form' ] : [] ) 36 .join( ',' ); 37 var badges = []; 31 38 var forms = []; 32 39 var token = ''; … … 102 109 failed = false; 103 110 fill(); 111 mark( 'ok' ); 104 112 } ) 105 113 [ 'catch' ]( function () { 106 114 failed = true; 115 mark( 'failed' ); 107 116 } ) 108 117 .then( function () { … … 130 139 var hp = document.createElement( 'input' ); 131 140 hp.type = 'text'; 132 hp.name = '_digimail_smtp_url';141 hp.name = cfg.trap || '_digimail_smtp_url'; 133 142 hp.value = ''; 134 143 hp.tabIndex = -1; … … 145 154 form.__dms = state; 146 155 forms.push( form ); 156 if ( ! form.hasAttribute( 'data-dms-guard' ) ) { 157 badge( form, token ? 'ok' : failed ? 'failed' : 'checking' ); 158 } 147 159 function move( e ) { 148 160 if ( e.isTrusted === false ) { … … 172 184 } 173 185 186 // ---------- admin note ---------- 187 188 function badge( form, state ) { 189 if ( ! cfg.badge || form.__dmsBadge ) { 190 return; 191 } 192 var el = document.createElement( 'div' ); 193 el.className = 'dms-guard-note'; 194 el.setAttribute( 'role', 'note' ); 195 el.style.cssText = 'margin:6px 0 0;padding:6px 10px;border-radius:6px;font:12px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;max-width:100%;box-sizing:border-box;'; 196 form.__dmsBadge = el; 197 badges.push( el ); 198 paint( el, state ); 199 if ( form.parentNode ) { 200 form.parentNode.insertBefore( el, form.nextSibling ); 201 } 202 } 203 204 function paint( el, state ) { 205 var look = { 206 checking: [ '#f4f4f5', '#3f3f46', '\u23F3' ], 207 ok: [ '#ecfdf3', '#05603a', '\u2713' ], 208 failed: [ '#fef3f2', '#b42318', '!' ], 209 none: [ '#fffaeb', '#93370d', '!' ], 210 }[ state ]; 211 el.style.background = look[ 0 ]; 212 el.style.color = look[ 1 ]; 213 el.textContent = look[ 2 ] + ' ' + ( cfg.badge[ state ] || '' ); 214 } 215 216 function mark( state ) { 217 for ( var i = 0; i < badges.length; i++ ) { 218 if ( ! badges[ i ].__none ) { 219 paint( badges[ i ], state ); 220 } 221 } 222 } 223 224 // Forms with an email field that no supported plugin made: tell the admin. 225 function unguarded( root ) { 226 if ( ! cfg.badge ) { 227 return; 228 } 229 var list = ( root || document ).querySelectorAll( 'form' ); 230 for ( var i = 0; i < list.length; i++ ) { 231 var f = list[ i ]; 232 if ( f.__dms || f.__dmsBadge || ( f.method && f.method.toLowerCase() === 'get' ) || f.id === 'loginform' || f.closest( '#wpadminbar, .woocommerce-MyAccount-content' ) ) { 233 continue; 234 } 235 if ( ! f.querySelector( 'input[type="email"], input[name*="email" i]' ) ) { 236 continue; 237 } 238 badge( f, 'none' ); 239 f.__dmsBadge.__none = true; 240 } 241 } 242 174 243 function scan( root ) { 175 244 var list = ( root || document ).querySelectorAll( SELECTOR ); … … 180 249 load(); 181 250 } 251 unguarded( root ); 182 252 } 183 253 -
digimail-smtp/trunk/build/index.asset.php
r3830946 r3831455 5 5 'wp-i18n' 6 6 ), 7 'version' => ' aa3d46a6aa63d53bdce4'7 'version' => '66a129ad7e4c0dd9e889' 8 8 ); -
digimail-smtp/trunk/build/index.js
r3830946 r3831455 1 (()=>{"use strict";var e={897(e,t,a){const l=window.wp.element,i=window.wp.i18n,s=window.wp.apiFetch;var n=a.n(s);const m={honeypot:(0,i.__)("Filled in the hidden trap field","digimail-smtp"),no_js:(0,i.__)("Sent without the page script (posted straight by a bot)","digimail-smtp"),no_token:(0,i.__)("No protection token","digimail-smtp"),forged:(0,i.__)("Fake protection token","digimail-smtp"),bad_pow:(0,i.__)("Wrong answer to the browser check","digimail-smtp"),no_pow:(0,i.__)("Browser check not done","digimail-smtp"),reused:(0,i.__)("Same token used many times","digimail-smtp"),too_fast:(0,i.__)("Sent less than 2 seconds after the page opened","digimail-smtp"),fast:(0,i.__)("Sent very quickly","digimail-smtp"),no_interaction:(0,i.__)("No typing, click or touch in the form","digimail-smtp"),flood:(0,i.__)("15 or more submissions in an hour from the same address","digimail-smtp"),too_many:(0,i.__)("5 or more submissions in 10 minutes from the same address","digimail-smtp"),link_in_name:(0,i.__)("Link in the name, company or phone field","digimail-smtp"),html_links:(0,i.__)("HTML or BBCode links in the message","digimail-smtp"),many_links:(0,i.__)("3 or more links in the message","digimail-smtp"),foreign_script:(0,i.__)("Mostly written in another alphabet (Cyrillic, Chinese…)","digimail-smtp"),gibberish_name:(0,i.__)("Name looks random","digimail-smtp"),bad_phone:(0,i.__)("Letters in the phone field","digimail-smtp"),spam_words:(0,i.__)("Typical spam words (casino, crypto, backlinks…)","digimail-smtp"),repeated:(0,i.__)("Same message from several visitors","digimail-smtp"),disposable_email:(0,i.__)("Throwaway email address","digimail-smtp"), blocklist:(0,i.__)("Matches the comment blocklist in Settings › Discussion","digimail-smtp"),akismet:(0,i.__)("Akismet says spam","digimail-smtp")};class r extends Error{}async function c(e,t,a){try{return await n()({path:`/digimail-smtp/v1/${e}`,method:a??(void 0===t?"GET":"POST"),data:t})}catch(e){const t=e;throw new r(t?.error||t?.message||(0,i.__)("That did not work. Try again later.","digimail-smtp"))}}const o=(window.digimailSmtp?.locale||"en-US").replace("_","-"),d=e=>(e??0).toLocaleString(o);function p(e){if(!e)return"";const t=new Date(e),a=(Date.now()-t.getTime())/1e3;return a<60?(0,i.__)("just now","digimail-smtp"):a<3600?(0,i.sprintf)(/* translators: %d: number of minutes. */ /* translators: %d: number of minutes. */(0,i.__)("%d min ago","digimail-smtp"),Math.floor(a/60)):a<86400&&t.getDate()===(new Date).getDate()?(0,i.sprintf)(/* translators: %s: time of day. */ /* translators: %s: time of day. */(0,i.__)("%s today","digimail-smtp"),t.toLocaleTimeString(o,{hour:"2-digit",minute:"2-digit"})):t.toLocaleString(o,{hour:"2-digit",minute:"2-digit",day:"2-digit",month:"2-digit"})}const u={queued:{label:(0,i.__)("Waiting to send","digimail-smtp"),tone:"muted"},claimed:{label:(0,i.__)("Sending","digimail-smtp"),tone:"muted"},sending:{label:(0,i.__)("Sending","digimail-smtp"),tone:"muted"},sent:{label:(0,i.__)("Sent","digimail-smtp"),tone:"info"},delivered:{label:(0,i.__)("Delivered","digimail-smtp"),tone:"ok"},bounced:{label:(0,i.__)("Bounced","digimail-smtp"),tone:"bad"},complained:{label:(0,i.__)("Marked as spam","digimail-smtp"),tone:"bad"},rejected:{label:(0,i.__)("Rejected","digimail-smtp"),tone:"bad"},failed:{label:(0,i.__)("Failed","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Unknown","digimail-smtp"),tone:"muted"},suppressed:{label:(0,i.__)("Skipped (blocked)","digimail-smtp"),tone:"wait"},backup:{label:(0,i.__)("Sent via backup","digimail-smtp"),tone:"wait"},blocked:{label:(0,i.__)("Not sent (suspicious recipient)","digimail-smtp"),tone:"wait"}};function g(e){return e?e.startsWith("theme:")?(0,i.sprintf)(/* translators: %s: theme folder name. */ /* translators: %s: theme folder name. */(0,i.__)("Theme %s","digimail-smtp"),e.slice(6)):{wordpress:"WordPress",woocommerce:"WooCommerce","contact-form-7":"Contact Form 7",wpforms:"WPForms","wpforms-lite":"WPForms",gravityforms:"Gravity Forms",fluentform:"Fluent Forms",elementor:"Elementor","elementor-pro":"Elementor Pro","digimail-smtp":"DigiMail SMTP",digimail:"DigiMail","ninja-forms":"Ninja Forms",formidable:"Formidable",learnpress:"LearnPress","ultimate-member":"Ultimate Member",bricks:"Bricks"}[e]??e.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()):""}function _(){return _=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var l in a)({}).hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e},_.apply(null,arguments)}function h({tone:e="muted",children:t}){return(0,l.createElement)("span",{className:`dms-badge dms-${e}`},t)}function E({title:e,aside:t,children:a,className:i=""}){return(0,l.createElement)("section",{className:`dms-card ${i}`},(e||t)&&(0,l.createElement)("header",{className:"dms-card-head"},e&&(0,l.createElement)("h2",null,e),t),a)}function f({children:e,variant:t="primary",busy:a,size:i,className:s="",disabled:n,...m}){return(0,l.createElement)("button",_({type:"button"},m,{className:`dms-btn dms-btn-${t} ${i?`dms-btn-${i}`:""} ${s}`,disabled:a||n,"aria-busy":a||void 0}),a&&(0,l.createElement)("span",{className:"dms-spin","aria-hidden":!0}),e)}function b({checked:e,onChange:t,label:a,hint:i,disabled:s}){return(0,l.createElement)("label",{className:"dms-toggle "+(s?"is-disabled":"")},(0,l.createElement)("input",{type:"checkbox",role:"switch",checked:e,disabled:s,onChange:e=>t(e.target.checked)}),(0,l.createElement)("span",{className:"dms-switch","aria-hidden":!0}),(0,l.createElement)("span",{className:"dms-toggle-text"},(0,l.createElement)("span",null,a),i&&(0,l.createElement)("small",null,i)))}function y({label:e,hint:t,children:a,htmlFor:i}){return(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("label",{htmlFor:i},e),a,t&&(0,l.createElement)("small",{className:"dms-hint"},t))}function v({tone:e="info",title:t,children:a,action:i}){return(0,l.createElement)("div",{className:`dms-notice dms-notice-${e}`,role:"bad"===e?"alert":void 0},(0,l.createElement)("div",null,t&&(0,l.createElement)("strong",null,t),a&&(0,l.createElement)("div",null,a)),i&&(0,l.createElement)("div",{className:"dms-notice-action"},i))}function k({icon:e,title:t,children:a}){return(0,l.createElement)("div",{className:"dms-empty"},e&&(0,l.createElement)("div",{className:"dms-empty-icon"},e),(0,l.createElement)("strong",null,t),a&&(0,l.createElement)("p",null,a))}function w({name:e,size:t=18}){const a={check:(0,l.createElement)("path",{d:"M20 6 9 17l-5-5"}),plus:(0,l.createElement)("path",{d:"M12 5v14M5 12h14"}),trash:(0,l.createElement)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"}),back:(0,l.createElement)("path",{d:"M15 18l-6-6 6-6"}),form:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),(0,l.createElement)("path",{d:"M7 9h10M7 13h6"}),(0,l.createElement)("rect",{x:"13",y:"12",width:"5",height:"3",rx:"1"})),cart:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"8",cy:"21",r:"1"}),(0,l.createElement)("circle",{cx:"19",cy:"21",r:"1"}),(0,l.createElement)("path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"})),mail:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),(0,l.createElement)("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})),send:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M14.54 21.69a.5.5 0 0 0 .93-.03l6.5-19a.5.5 0 0 0-.63-.63l-19 6.5a.5.5 0 0 0-.03.93l7.93 3.18a2 2 0 0 1 1.11 1.11z"}),(0,l.createElement)("path",{d:"m21.85 2.15-10.94 10.94"})),list:(0,l.createElement)("path",{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),users:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),(0,l.createElement)("circle",{cx:"9",cy:"7",r:"4"}),(0,l.createElement)("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"})),settings:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),(0,l.createElement)("circle",{cx:"12",cy:"12",r:"3"})),chart:(0,l.createElement)("path",{d:"M3 3v16a2 2 0 0 0 2 2h16M7 16V9M12 16v-5M17 16V6"}),tools:(0,l.createElement)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"}),alert:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 8v4M12 16h.01"})),x:(0,l.createElement)("path",{d:"M18 6 6 18M6 6l12 12"}),external:(0,l.createElement)("path",{d:"M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),refresh:(0,l.createElement)("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8M21 3v5h-5M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16M8 16H3v5"}),shield:(0,l.createElement)("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}),globe:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20M2 12h20"})),zap:(0,l.createElement)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}),eye:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M2.06 12.35a1 1 0 0 1 0-.7 10.75 10.75 0 0 1 19.88 0 1 1 0 0 1 0 .7 10.75 10.75 0 0 1-19.88 0"}),(0,l.createElement)("circle",{cx:"12",cy:"12",r:"3"})),clock:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 6v6l4 2"})),search:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"11",cy:"11",r:"8"}),(0,l.createElement)("path",{d:"m21 21-4.3-4.3"})),paperclip:(0,l.createElement)("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),copy:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"8",y:"8",width:"14",height:"14",rx:"2"}),(0,l.createElement)("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})),bell:(0,l.createElement)("path",{d:"M10.27 21a2 2 0 0 0 3.46 0M3.26 15.33A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.67C19.41 13.96 18 12.5 18 8A6 6 0 0 0 6 8c0 4.5-1.41 5.96-2.74 7.33"}),download:(0,l.createElement)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"}),palette:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M12 22a10 10 0 1 1 10-10c0 2.2-1.8 3.5-4 3.5h-1.6a1.9 1.9 0 0 0-1.4 3.2A2 2 0 0 1 13.6 22z"}),(0,l.createElement)("circle",{cx:"7.5",cy:"10.5",r:"1",fill:"currentColor"}),(0,l.createElement)("circle",{cx:"11",cy:"6.5",r:"1",fill:"currentColor"}),(0,l.createElement)("circle",{cx:"16",cy:"8",r:"1",fill:"currentColor"}))};return(0,l.createElement)("svg",{className:"dms-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},a[e])}function N({open:e,onClose:t,title:a,children:s}){const n=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!e)return;const a=e=>"Escape"===e.key&&t();return document.addEventListener("keydown",a),n.current?.focus(),()=>document.removeEventListener("keydown",a)},[e,t]),e?(0,l.createElement)("div",{className:"dms-drawer-back",onClick:e=>e.target===e.currentTarget&&t()},(0,l.createElement)("div",{className:"dms-drawer",role:"dialog","aria-modal":"true",tabIndex:-1,ref:n},(0,l.createElement)("header",null,(0,l.createElement)("h2",null,a),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn",onClick:t,"aria-label":(0,i.__)("Close","digimail-smtp")},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("div",{className:"dms-drawer-body"},s))):null}const S=(0,l.createContext)(()=>{}),C=()=>(0,l.useContext)(S);function x({value:e,onChange:t,onDone:a,disabled:s}){const n=(0,l.useRef)([]);return(0,l.useEffect)(()=>n.current[0]?.focus(),[]),(0,l.createElement)("div",{className:"dms-code",role:"group","aria-label":(0,i.__)("6-digit code","digimail-smtp")},[0,1,2,3,4,5].map(m=>(0,l.createElement)("input",{key:m,ref:e=>n.current[m]=e,inputMode:"numeric",autoComplete:0===m?"one-time-code":"off",maxLength:6,"aria-label":(0,i.sprintf)(/* translators: %d: position of the digit, 1 to 6. */ /* translators: %d: position of the digit, 1 to 6. */(0,i.__)("Digit %d","digimail-smtp"),m+1),value:(e[m]??"").trim(),disabled:s,onChange:l=>((l,i)=>{const s=i.replace(/\D/g,"");if(s.length>1){const i=(e.slice(0,l)+s).slice(0,6);return t(i),n.current[Math.min(i.length,5)]?.focus(),void(6===i.length&&a(i))}const m=e.padEnd(6," ").split("");m[l]=s||" ";const r=m.join("").replace(/\s+$/,"");t(r),s&&l<5&&n.current[l+1]?.focus(),6===r.replace(/\s/g,"").length&&a(r.replace(/\s/g,""))})(m,l.target.value),onKeyDown:t=>{"Backspace"===t.key&&!(e[m]??"").trim()&&m>0&&n.current[m-1]?.focus()}})))}function M({state:e,reload:t}){const[a,s]=(0,l.useState)(e.pending?"code":"email"),[n,m]=(0,l.useState)(e.pending??e.site.user_email??""),[r,o]=(0,l.useState)(""),[d,p]=(0,l.useState)(null),[u,g]=(0,l.useState)(""),[_,h]=(0,l.useState)(0);(0,l.useEffect)(()=>{if(_<=0)return;const e=setTimeout(()=>h(_-1),1e3);return()=>clearTimeout(e)},[_]);const E=async()=>{p("start"),g("");try{await c("connect/start",{email:n}),s("code"),o(""),h(45)}catch(e){g(e.message)}finally{p(null)}},b=async e=>{p("verify"),g("");try{await c("connect/verify",{code:e}),await t()}catch(e){g(e.message),o("")}finally{p(null)}},y={strong:(0,l.createElement)("strong",null)};return(0,l.createElement)("div",{className:"dms-onboard"},(0,l.createElement)("div",{className:"dms-onboard-pitch"},(0,l.createElement)("span",{className:"dms-eyebrow"},"DigiMail SMTP"),(0,l.createElement)("h1",null,(0,i.__)("Send email from your website now, no SMTP setup","digimail-smtp")),(0,l.createElement)("p",{className:"dms-lead"},(0,i.__)("Enter your email, type the 6-digit code, done. Order emails, contact forms and password resets go through DigiMail’s professional mail servers instead of the mail() function that often lands in spam.","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-points"},(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"zap"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Working in 30 seconds.</strong> No host, port, app password or API key.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"eye"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Know whether email arrives.</strong> A log of every email: delivered, bounced, opened, with the reason for errors.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"shield"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>No lost email.</strong> Automatic retries on network errors, with your old SMTP server as backup.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"globe"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Manage all your websites</strong> in one account on digimail.vn.","digimail-smtp"),y)))),e.conflicts.length>0&&/* translators: %s: names of other active SMTP plugins. */ /* translators: %s: names of other active SMTP plugins. */2 (0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)((0,i.__)("%s is active","digimail-smtp"),e.conflicts.map(e=>e.name).join(", "))},(0,i.__)("After connecting, open Tools to import the old settings (the old SMTP server becomes the backup connection), then deactivate the other plugin.","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-card dms-onboard-card"},"email"===a?(0,l.createElement)("form",{onSubmit:e=>{e.preventDefault(),E()}},(0,l.createElement)("div",{className:"dms-step"},(0,l.createElement)("span",null,"1")," ",(0,i.__)("Enter your email","digimail-smtp")),(0,l.createElement)("h2",null,(0,i.__)("Start sending email","digimail-smtp")),(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("We send a 6-digit code to this email to confirm it. If you have no DigiMail account yet, a free one is created for you.","digimail-smtp")),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("label",{htmlFor:"dms-email"},(0,i.__)("Email","digimail-smtp")),(0,l.createElement)("input",{id:"dms-email",type:"email",required:!0,value:n,onChange:e=>m(e.target.value),placeholder:(0,i.__)("you@company.com","digimail-smtp"),autoComplete:"email"})), u&&(0,l.createElement)("p",{className:"dms-error",role:"alert"},u),(0,l.createElement)(f,{type:"submit",busy:"start"===d,size:"lg"},(0,i.__)("Send confirmation code","digimail-smtp")),(0,l.createElement)("div",{className:"dms-or"},(0,l.createElement)("span",null,(0,i.__)("or","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",onClick:async()=>{p("approve");try{const e=await c("connect/url");window.location.href=e.url}catch(e){g(e.message),p(null)}},busy:"approve"===d,size:"block"},(0,i.__)("Have a DigiMail account? Log in and connect","digimail-smtp")),(0,l.createElement)("p",{className:"dms-fine"},(0,l.createInterpolateElement)((0,i.__)("Once connected, your website’s email goes through DigiMail servers (api.digimail.vn) to reach recipients. By connecting you agree to the <terms>Terms of Service</terms> and <privacy>Privacy Policy</privacy>.","digimail-smtp"),{terms:(0,l.createElement)("a",{href:`${e.env.app}/dieu-khoan`,target:"_blank",rel:"noreferrer"}),privacy:(0,l.createElement)("a",{href:`${e.env.app}/chinh-sach-bao-mat`,target:"_blank",rel:"noreferrer"})}))):(0,l.createElement)("form",{onSubmit:e=>{e.preventDefault(),b(r)}},(0,l.createElement)("div",{className:"dms-step"},(0,l.createElement)("span",null,"2")," ",(0,i.__)("Enter the code","digimail-smtp")),(0,l.createElement)("h2",null,(0,i.__)("Check your inbox","digimail-smtp")),(0,l.createElement)("p",{className:"dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: email address the code was sent to. */ /* translators: %s: email address the code was sent to. */(0,i.__)("The 6-digit code was sent to <strong>%s</strong>. Not there? Check Spam or Promotions.","digimail-smtp"),n),y)),(0,l.createElement)(x,{value:r,onChange:o,onDone:b,disabled:"verify"===d}),u&&(0,l.createElement)("p",{className:"dms-error",role:"alert"},u),(0,l.createElement)(f,{type:"submit",busy:"verify"===d,disabled:r.replace(/\s/g,"").length<6,size:"lg"},(0,i.__)("Confirm and connect","digimail-smtp")),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>{s("email"),g("")}},(0,i.__)("Change email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-link",disabled:_>0||null!==d,onClick:E},_>0?(0,i.sprintf)(/* translators: %d: seconds until the code can be sent again. */ /* translators: %d: seconds until the code can be sent again. */(0,i.__)("Resend code in %d s","digimail-smtp"),_):(0,i.__)("Resend code","digimail-smtp"))))))}const T=(e,t)=>t>0?Math.round(e/t*1e3)/10:0;function D({days:e}){const[t,a]=(0,l.useState)(null),s=Math.max(4,...e.map(e=>e.sent)),n=(640-6*(e.length-1))/e.length,m=e=>e/s*152,r=null!==t?e[t]:null;return(0,l.createElement)("div",{className:"dms-chart"},(0,l.createElement)("svg",{viewBox:"0 0 640 192",role:"img","aria-label":(0,i.__)("Emails per day","digimail-smtp")},[.5,1].map(e=>(0,l.createElement)("line",{key:e,x1:0,x2:640,y1:170-m(s*e),y2:170-m(s*e),className:"dms-grid"})),e.map((t,i)=>{const s=i*(n+6),r=Math.max(0,t.sent-t.delivered-t.failed);let c=170;const d=(e,t)=>{if(e<=0)return null;const a=Math.max(2,m(e));return c-=a,(0,l.createElement)("rect",{x:s,y:c,width:n,height:Math.max(0,a-1.5),rx:3,className:t})};return(0,l.createElement)("g",{key:t.day,onMouseEnter:()=>a(i),onMouseLeave:()=>a(null)},(0,l.createElement)("rect",{x:s-3,y:0,width:n+6,height:192,fill:"transparent"}),d(t.delivered,"dms-bar-ok"),d(r,"dms-bar-transit"),d(t.failed,"dms-bar-bad"),0===t.sent&&(0,l.createElement)("rect",{x:s,y:168,width:n,height:2,rx:1,className:"dms-bar-zero"}),(i%Math.ceil(e.length/7)===0||i===e.length-1)&&(0,l.createElement)("text",{x:s+n/2,y:186,textAnchor:"middle",className:"dms-axis"},new Date(t.day).toLocaleDateString(o,{day:"2-digit",month:"2-digit"})))})),r&&(0,l.createElement)("div",{className:"dms-tip",style:{left:(t+.5)/e.length*100+"%"}},(0,l.createElement)("strong",null,new Date(r.day).toLocaleDateString(o,{weekday:"short",day:"2-digit",month:"2-digit"})),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-ok"})," ",(0,i.__)("Delivered","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.delivered))),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-transit"})," ",(0,i.__)("In transit","digimail-smtp")," ",(0,l.createElement)("b",null,d(Math.max(0,r.sent-r.delivered-r.failed)))),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-bad"})," ",(0,i.__)("Failed","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.failed))),(0,l.createElement)("span",null,(0,i.__)("Opened","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.opened)))),(0,l.createElement)("div",{className:"dms-legend"},(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-ok"})," ",(0,i.__)("Delivered","digimail-smtp")),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-transit"})," ",(0,i.__)("In transit","digimail-smtp")),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-bad"})," ",(0,i.__)("Failed or bounced","digimail-smtp"))))}function F({label:e,used:t,total:a}){const i=a>0?Math.min(100,t/a*100):0;return(0,l.createElement)("div",{className:"dms-meter"},(0,l.createElement)("div",{className:"dms-meter-head"},(0,l.createElement)("span",null,e),(0,l.createElement)("span",null,(0,l.createElement)("b",null,d(t))," / ",d(a))),(0,l.createElement)("div",{className:"dms-meter-bar"},(0,l.createElement)("span",{style:{width:`${i}%`},className:i>90?"is-bad":i>70?"is-wait":""})))}function z({state:e,go:t}){const[a,s]=(0,l.useState)(null),[n,m]=(0,l.useState)("");(0,l.useEffect)(()=>{c("stats?days=14").then(s).catch(e=>m(e.message))},[]);const r=e.status,o=r.sender,p=r.account,u=a?.days.reduce((e,t)=>e+t.sent,0)??0,_=a?.days.reduce((e,t)=>e+t.delivered,0)??0,b=a?.days.reduce((e,t)=>e+t.failed,0)??0,y=a?.days.reduce((e,t)=>e+t.opened,0)??0,k="shared"===o?.mode,N=r.site_domain,S=N&&!/^(localhost|[\d.]+|\[?[\da-f:]+\]?)$/i.test(N.domain)&&N.domain.includes(".")?N:null;return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-hero"},(0,l.createElement)("div",{className:"dms-hero-icon"},(0,l.createElement)(w,{name:"check",size:26})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("This website sends email through DigiMail","digimail-smtp")),o&&(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: sender name, 2: sender email. */ /* translators: 1: sender name, 2: sender email. */(0,i.__)("From <strong>%1$s</strong> (%2$s)","digimail-smtp"),o.name,o.email),{strong:(0,l.createElement)("strong",null)})," ",k?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Own domain","digimail-smtp")))),(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("test")},(0,l.createElement)(w,{name:"send",size:15})," ",(0,i.__)("Send test email","digimail-smtp"))),e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),!e.settings.capture.enabled&&(e.capture.forms.length>0||e.capture.woocommerce)&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Save form contacts to DigiMail","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.sprintf)(/* translators: %s: form plugins or WooCommerce found on the site. */ /* translators: %s: form plugins or WooCommerce found on the site. */1 (()=>{"use strict";var e={897(e,t,a){const l=window.wp.element,i=window.wp.i18n,s=window.wp.apiFetch;var n=a.n(s);const m={honeypot:(0,i.__)("Filled in the hidden trap field","digimail-smtp"),no_js:(0,i.__)("Sent without the page script (posted straight by a bot)","digimail-smtp"),no_token:(0,i.__)("No protection token","digimail-smtp"),forged:(0,i.__)("Fake protection token","digimail-smtp"),bad_pow:(0,i.__)("Wrong answer to the browser check","digimail-smtp"),no_pow:(0,i.__)("Browser check not done","digimail-smtp"),reused:(0,i.__)("Same token used many times","digimail-smtp"),too_fast:(0,i.__)("Sent less than 2 seconds after the page opened","digimail-smtp"),fast:(0,i.__)("Sent very quickly","digimail-smtp"),no_interaction:(0,i.__)("No typing, click or touch in the form","digimail-smtp"),flood:(0,i.__)("15 or more submissions in an hour from the same address","digimail-smtp"),too_many:(0,i.__)("5 or more submissions in 10 minutes from the same address","digimail-smtp"),link_in_name:(0,i.__)("Link in the name, company or phone field","digimail-smtp"),html_links:(0,i.__)("HTML or BBCode links in the message","digimail-smtp"),many_links:(0,i.__)("3 or more links in the message","digimail-smtp"),foreign_script:(0,i.__)("Mostly written in another alphabet (Cyrillic, Chinese…)","digimail-smtp"),gibberish_name:(0,i.__)("Name looks random","digimail-smtp"),bad_phone:(0,i.__)("Letters in the phone field","digimail-smtp"),spam_words:(0,i.__)("Typical spam words (casino, crypto, backlinks…)","digimail-smtp"),repeated:(0,i.__)("Same message from several visitors","digimail-smtp"),disposable_email:(0,i.__)("Throwaway email address","digimail-smtp"),dotted_gmail:(0,i.__)("Gmail address with random dots (bi.f.ewoy…@gmail.com)","digimail-smtp"),gmail_variants:(0,i.__)("Same Gmail mailbox sent with different dots","digimail-smtp"),tor:(0,i.__)("Sent through the Tor network","digimail-smtp"),blocklist:(0,i.__)("Matches the comment blocklist in Settings › Discussion","digimail-smtp"),akismet:(0,i.__)("Akismet says spam","digimail-smtp")};class r extends Error{}async function o(e,t,a){try{return await n()({path:`/digimail-smtp/v1/${e}`,method:a??(void 0===t?"GET":"POST"),data:t})}catch(e){const t=e;throw new r(t?.error||t?.message||(0,i.__)("That did not work. Try again later.","digimail-smtp"))}}const c=(window.digimailSmtp?.locale||"en-US").replace("_","-"),d=e=>(e??0).toLocaleString(c);function p(e){if(!e)return"";const t=new Date(e),a=(Date.now()-t.getTime())/1e3;return a<60?(0,i.__)("just now","digimail-smtp"):a<3600?(0,i.sprintf)(/* translators: %d: number of minutes. */ /* translators: %d: number of minutes. */(0,i.__)("%d min ago","digimail-smtp"),Math.floor(a/60)):a<86400&&t.getDate()===(new Date).getDate()?(0,i.sprintf)(/* translators: %s: time of day. */ /* translators: %s: time of day. */(0,i.__)("%s today","digimail-smtp"),t.toLocaleTimeString(c,{hour:"2-digit",minute:"2-digit"})):t.toLocaleString(c,{hour:"2-digit",minute:"2-digit",day:"2-digit",month:"2-digit"})}const g={queued:{label:(0,i.__)("Waiting to send","digimail-smtp"),tone:"muted"},claimed:{label:(0,i.__)("Sending","digimail-smtp"),tone:"muted"},sending:{label:(0,i.__)("Sending","digimail-smtp"),tone:"muted"},sent:{label:(0,i.__)("Sent","digimail-smtp"),tone:"info"},delivered:{label:(0,i.__)("Delivered","digimail-smtp"),tone:"ok"},bounced:{label:(0,i.__)("Bounced","digimail-smtp"),tone:"bad"},complained:{label:(0,i.__)("Marked as spam","digimail-smtp"),tone:"bad"},rejected:{label:(0,i.__)("Rejected","digimail-smtp"),tone:"bad"},failed:{label:(0,i.__)("Failed","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Unknown","digimail-smtp"),tone:"muted"},suppressed:{label:(0,i.__)("Skipped (blocked)","digimail-smtp"),tone:"wait"},backup:{label:(0,i.__)("Sent via backup","digimail-smtp"),tone:"wait"},blocked:{label:(0,i.__)("Not sent (suspicious recipient)","digimail-smtp"),tone:"wait"}};function u(e){if(!e)return"";const t={wordpress:"WordPress",woocommerce:"WooCommerce","contact-form-7":"Contact Form 7",wpforms:"WPForms","wpforms-lite":"WPForms",gravityforms:"Gravity Forms",fluentform:"Fluent Forms",elementor:"Elementor","elementor-pro":"Elementor Pro","digimail-smtp":"DigiMail SMTP",digimail:"DigiMail","ninja-forms":"Ninja Forms",formidable:"Formidable",learnpress:"LearnPress","ultimate-member":"Ultimate Member",bricks:"Bricks","wp-register":(0,i.__)("WordPress registration","digimail-smtp"),"wp-lostpassword":(0,i.__)("WordPress lost password","digimail-smtp"),"wp-comments":(0,i.__)("WordPress comments","digimail-smtp"),"woo-register":(0,i.__)("WooCommerce registration","digimail-smtp")};return e.startsWith("theme:")?(0,i.sprintf)(/* translators: %s: theme folder name. */ /* translators: %s: theme folder name. */(0,i.__)("Theme %s","digimail-smtp"),e.slice(6)):t[e]??e.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function _(){return _=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var l in a)({}).hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e},_.apply(null,arguments)}function h({tone:e="muted",children:t}){return(0,l.createElement)("span",{className:`dms-badge dms-${e}`},t)}function E({title:e,aside:t,children:a,className:i=""}){return(0,l.createElement)("section",{className:`dms-card ${i}`},(e||t)&&(0,l.createElement)("header",{className:"dms-card-head"},e&&(0,l.createElement)("h2",null,e),t),a)}function f({children:e,variant:t="primary",busy:a,size:i,className:s="",disabled:n,...m}){return(0,l.createElement)("button",_({type:"button"},m,{className:`dms-btn dms-btn-${t} ${i?`dms-btn-${i}`:""} ${s}`,disabled:a||n,"aria-busy":a||void 0}),a&&(0,l.createElement)("span",{className:"dms-spin","aria-hidden":!0}),e)}function b({checked:e,onChange:t,label:a,hint:i,disabled:s}){return(0,l.createElement)("label",{className:"dms-toggle "+(s?"is-disabled":"")},(0,l.createElement)("input",{type:"checkbox",role:"switch",checked:e,disabled:s,onChange:e=>t(e.target.checked)}),(0,l.createElement)("span",{className:"dms-switch","aria-hidden":!0}),(0,l.createElement)("span",{className:"dms-toggle-text"},(0,l.createElement)("span",null,a),i&&(0,l.createElement)("small",null,i)))}function y({label:e,hint:t,children:a,htmlFor:i}){return(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("label",{htmlFor:i},e),a,t&&(0,l.createElement)("small",{className:"dms-hint"},t))}function v({tone:e="info",title:t,children:a,action:i}){return(0,l.createElement)("div",{className:`dms-notice dms-notice-${e}`,role:"bad"===e?"alert":void 0},(0,l.createElement)("div",null,t&&(0,l.createElement)("strong",null,t),a&&(0,l.createElement)("div",null,a)),i&&(0,l.createElement)("div",{className:"dms-notice-action"},i))}function k({icon:e,title:t,children:a}){return(0,l.createElement)("div",{className:"dms-empty"},e&&(0,l.createElement)("div",{className:"dms-empty-icon"},e),(0,l.createElement)("strong",null,t),a&&(0,l.createElement)("p",null,a))}function w({name:e,size:t=18}){const a={check:(0,l.createElement)("path",{d:"M20 6 9 17l-5-5"}),plus:(0,l.createElement)("path",{d:"M12 5v14M5 12h14"}),trash:(0,l.createElement)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"}),back:(0,l.createElement)("path",{d:"M15 18l-6-6 6-6"}),form:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),(0,l.createElement)("path",{d:"M7 9h10M7 13h6"}),(0,l.createElement)("rect",{x:"13",y:"12",width:"5",height:"3",rx:"1"})),cart:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"8",cy:"21",r:"1"}),(0,l.createElement)("circle",{cx:"19",cy:"21",r:"1"}),(0,l.createElement)("path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"})),mail:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),(0,l.createElement)("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})),send:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M14.54 21.69a.5.5 0 0 0 .93-.03l6.5-19a.5.5 0 0 0-.63-.63l-19 6.5a.5.5 0 0 0-.03.93l7.93 3.18a2 2 0 0 1 1.11 1.11z"}),(0,l.createElement)("path",{d:"m21.85 2.15-10.94 10.94"})),list:(0,l.createElement)("path",{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),users:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),(0,l.createElement)("circle",{cx:"9",cy:"7",r:"4"}),(0,l.createElement)("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"})),settings:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),(0,l.createElement)("circle",{cx:"12",cy:"12",r:"3"})),chart:(0,l.createElement)("path",{d:"M3 3v16a2 2 0 0 0 2 2h16M7 16V9M12 16v-5M17 16V6"}),tools:(0,l.createElement)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"}),alert:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 8v4M12 16h.01"})),x:(0,l.createElement)("path",{d:"M18 6 6 18M6 6l12 12"}),external:(0,l.createElement)("path",{d:"M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),refresh:(0,l.createElement)("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8M21 3v5h-5M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16M8 16H3v5"}),shield:(0,l.createElement)("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}),globe:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20M2 12h20"})),zap:(0,l.createElement)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}),eye:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M2.06 12.35a1 1 0 0 1 0-.7 10.75 10.75 0 0 1 19.88 0 1 1 0 0 1 0 .7 10.75 10.75 0 0 1-19.88 0"}),(0,l.createElement)("circle",{cx:"12",cy:"12",r:"3"})),clock:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.createElement)("path",{d:"M12 6v6l4 2"})),search:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("circle",{cx:"11",cy:"11",r:"8"}),(0,l.createElement)("path",{d:"m21 21-4.3-4.3"})),paperclip:(0,l.createElement)("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),copy:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"8",y:"8",width:"14",height:"14",rx:"2"}),(0,l.createElement)("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})),bell:(0,l.createElement)("path",{d:"M10.27 21a2 2 0 0 0 3.46 0M3.26 15.33A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.67C19.41 13.96 18 12.5 18 8A6 6 0 0 0 6 8c0 4.5-1.41 5.96-2.74 7.33"}),download:(0,l.createElement)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"}),palette:(0,l.createElement)(l.Fragment,null,(0,l.createElement)("path",{d:"M12 22a10 10 0 1 1 10-10c0 2.2-1.8 3.5-4 3.5h-1.6a1.9 1.9 0 0 0-1.4 3.2A2 2 0 0 1 13.6 22z"}),(0,l.createElement)("circle",{cx:"7.5",cy:"10.5",r:"1",fill:"currentColor"}),(0,l.createElement)("circle",{cx:"11",cy:"6.5",r:"1",fill:"currentColor"}),(0,l.createElement)("circle",{cx:"16",cy:"8",r:"1",fill:"currentColor"}))};return(0,l.createElement)("svg",{className:"dms-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},a[e])}function N({open:e,onClose:t,title:a,children:s}){const n=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!e)return;const a=e=>"Escape"===e.key&&t();return document.addEventListener("keydown",a),n.current?.focus(),()=>document.removeEventListener("keydown",a)},[e,t]),e?(0,l.createElement)("div",{className:"dms-drawer-back",onClick:e=>e.target===e.currentTarget&&t()},(0,l.createElement)("div",{className:"dms-drawer",role:"dialog","aria-modal":"true",tabIndex:-1,ref:n},(0,l.createElement)("header",null,(0,l.createElement)("h2",null,a),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn",onClick:t,"aria-label":(0,i.__)("Close","digimail-smtp")},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("div",{className:"dms-drawer-body"},s))):null}const S=(0,l.createContext)(()=>{}),C=()=>(0,l.useContext)(S);function x({value:e,onChange:t,onDone:a,disabled:s}){const n=(0,l.useRef)([]);return(0,l.useEffect)(()=>n.current[0]?.focus(),[]),(0,l.createElement)("div",{className:"dms-code",role:"group","aria-label":(0,i.__)("6-digit code","digimail-smtp")},[0,1,2,3,4,5].map(m=>(0,l.createElement)("input",{key:m,ref:e=>n.current[m]=e,inputMode:"numeric",autoComplete:0===m?"one-time-code":"off",maxLength:6,"aria-label":(0,i.sprintf)(/* translators: %d: position of the digit, 1 to 6. */ /* translators: %d: position of the digit, 1 to 6. */(0,i.__)("Digit %d","digimail-smtp"),m+1),value:(e[m]??"").trim(),disabled:s,onChange:l=>((l,i)=>{const s=i.replace(/\D/g,"");if(s.length>1){const i=(e.slice(0,l)+s).slice(0,6);return t(i),n.current[Math.min(i.length,5)]?.focus(),void(6===i.length&&a(i))}const m=e.padEnd(6," ").split("");m[l]=s||" ";const r=m.join("").replace(/\s+$/,"");t(r),s&&l<5&&n.current[l+1]?.focus(),6===r.replace(/\s/g,"").length&&a(r.replace(/\s/g,""))})(m,l.target.value),onKeyDown:t=>{"Backspace"===t.key&&!(e[m]??"").trim()&&m>0&&n.current[m-1]?.focus()}})))}function M({state:e,reload:t}){const[a,s]=(0,l.useState)(e.pending?"code":"email"),[n,m]=(0,l.useState)(e.pending??e.site.user_email??""),[r,c]=(0,l.useState)(""),[d,p]=(0,l.useState)(null),[g,u]=(0,l.useState)(""),[_,h]=(0,l.useState)(0);(0,l.useEffect)(()=>{if(_<=0)return;const e=setTimeout(()=>h(_-1),1e3);return()=>clearTimeout(e)},[_]);const E=async()=>{p("start"),u("");try{await o("connect/start",{email:n}),s("code"),c(""),h(45)}catch(e){u(e.message)}finally{p(null)}},b=async e=>{p("verify"),u("");try{await o("connect/verify",{code:e}),await t()}catch(e){u(e.message),c("")}finally{p(null)}},y={strong:(0,l.createElement)("strong",null)};return(0,l.createElement)("div",{className:"dms-onboard"},(0,l.createElement)("div",{className:"dms-onboard-pitch"},(0,l.createElement)("span",{className:"dms-eyebrow"},"DigiMail SMTP"),(0,l.createElement)("h1",null,(0,i.__)("Send email from your website now, no SMTP setup","digimail-smtp")),(0,l.createElement)("p",{className:"dms-lead"},(0,i.__)("Enter your email, type the 6-digit code, done. Order emails, contact forms and password resets go through DigiMail’s professional mail servers instead of the mail() function that often lands in spam.","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-points"},(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"zap"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Working in 30 seconds.</strong> No host, port, app password or API key.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"eye"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Know whether email arrives.</strong> A log of every email: delivered, bounced, opened, with the reason for errors.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"shield"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>No lost email.</strong> Automatic retries on network errors, with your old SMTP server as backup.","digimail-smtp"),y))),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"globe"}),(0,l.createElement)("span",null,(0,l.createInterpolateElement)((0,i.__)("<strong>Manage all your websites</strong> in one account on digimail.vn.","digimail-smtp"),y)))),e.conflicts.length>0&&/* translators: %s: names of other active SMTP plugins. */ /* translators: %s: names of other active SMTP plugins. */ 2 (0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)((0,i.__)("%s is active","digimail-smtp"),e.conflicts.map(e=>e.name).join(", "))},(0,i.__)("After connecting, open Tools to import the old settings (the old SMTP server becomes the backup connection), then deactivate the other plugin.","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-card dms-onboard-card"},"email"===a?(0,l.createElement)("form",{onSubmit:e=>{e.preventDefault(),E()}},(0,l.createElement)("div",{className:"dms-step"},(0,l.createElement)("span",null,"1")," ",(0,i.__)("Enter your email","digimail-smtp")),(0,l.createElement)("h2",null,(0,i.__)("Start sending email","digimail-smtp")),(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("We send a 6-digit code to this email to confirm it. If you have no DigiMail account yet, a free one is created for you.","digimail-smtp")),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("label",{htmlFor:"dms-email"},(0,i.__)("Email","digimail-smtp")),(0,l.createElement)("input",{id:"dms-email",type:"email",required:!0,value:n,onChange:e=>m(e.target.value),placeholder:(0,i.__)("you@company.com","digimail-smtp"),autoComplete:"email"})),g&&(0,l.createElement)("p",{className:"dms-error",role:"alert"},g),(0,l.createElement)(f,{type:"submit",busy:"start"===d,size:"lg"},(0,i.__)("Send confirmation code","digimail-smtp")),(0,l.createElement)("div",{className:"dms-or"},(0,l.createElement)("span",null,(0,i.__)("or","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",onClick:async()=>{p("approve");try{const e=await o("connect/url");window.location.href=e.url}catch(e){u(e.message),p(null)}},busy:"approve"===d,size:"block"},(0,i.__)("Have a DigiMail account? Log in and connect","digimail-smtp")),(0,l.createElement)("p",{className:"dms-fine"},(0,l.createInterpolateElement)((0,i.__)("Once connected, your website’s email goes through DigiMail servers (api.digimail.vn) to reach recipients. By connecting you agree to the <terms>Terms of Service</terms> and <privacy>Privacy Policy</privacy>.","digimail-smtp"),{terms:(0,l.createElement)("a",{href:`${e.env.app}/dieu-khoan`,target:"_blank",rel:"noreferrer"}),privacy:(0,l.createElement)("a",{href:`${e.env.app}/chinh-sach-bao-mat`,target:"_blank",rel:"noreferrer"})}))):(0,l.createElement)("form",{onSubmit:e=>{e.preventDefault(),b(r)}},(0,l.createElement)("div",{className:"dms-step"},(0,l.createElement)("span",null,"2")," ",(0,i.__)("Enter the code","digimail-smtp")),(0,l.createElement)("h2",null,(0,i.__)("Check your inbox","digimail-smtp")),(0,l.createElement)("p",{className:"dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: email address the code was sent to. */ /* translators: %s: email address the code was sent to. */(0,i.__)("The 6-digit code was sent to <strong>%s</strong>. Not there? Check Spam or Promotions.","digimail-smtp"),n),y)),(0,l.createElement)(x,{value:r,onChange:c,onDone:b,disabled:"verify"===d}),g&&(0,l.createElement)("p",{className:"dms-error",role:"alert"},g),(0,l.createElement)(f,{type:"submit",busy:"verify"===d,disabled:r.replace(/\s/g,"").length<6,size:"lg"},(0,i.__)("Confirm and connect","digimail-smtp")),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>{s("email"),u("")}},(0,i.__)("Change email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-link",disabled:_>0||null!==d,onClick:E},_>0?(0,i.sprintf)(/* translators: %d: seconds until the code can be sent again. */ /* translators: %d: seconds until the code can be sent again. */(0,i.__)("Resend code in %d s","digimail-smtp"),_):(0,i.__)("Resend code","digimail-smtp"))))))}const T=(e,t)=>t>0?Math.round(e/t*1e3)/10:0;function D({days:e}){const[t,a]=(0,l.useState)(null),s=Math.max(4,...e.map(e=>e.sent)),n=(640-6*(e.length-1))/e.length,m=e=>e/s*152,r=null!==t?e[t]:null;return(0,l.createElement)("div",{className:"dms-chart"},(0,l.createElement)("svg",{viewBox:"0 0 640 192",role:"img","aria-label":(0,i.__)("Emails per day","digimail-smtp")},[.5,1].map(e=>(0,l.createElement)("line",{key:e,x1:0,x2:640,y1:170-m(s*e),y2:170-m(s*e),className:"dms-grid"})),e.map((t,i)=>{const s=i*(n+6),r=Math.max(0,t.sent-t.delivered-t.failed);let o=170;const d=(e,t)=>{if(e<=0)return null;const a=Math.max(2,m(e));return o-=a,(0,l.createElement)("rect",{x:s,y:o,width:n,height:Math.max(0,a-1.5),rx:3,className:t})};return(0,l.createElement)("g",{key:t.day,onMouseEnter:()=>a(i),onMouseLeave:()=>a(null)},(0,l.createElement)("rect",{x:s-3,y:0,width:n+6,height:192,fill:"transparent"}),d(t.delivered,"dms-bar-ok"),d(r,"dms-bar-transit"),d(t.failed,"dms-bar-bad"),0===t.sent&&(0,l.createElement)("rect",{x:s,y:168,width:n,height:2,rx:1,className:"dms-bar-zero"}),(i%Math.ceil(e.length/7)===0||i===e.length-1)&&(0,l.createElement)("text",{x:s+n/2,y:186,textAnchor:"middle",className:"dms-axis"},new Date(t.day).toLocaleDateString(c,{day:"2-digit",month:"2-digit"})))})),r&&(0,l.createElement)("div",{className:"dms-tip",style:{left:(t+.5)/e.length*100+"%"}},(0,l.createElement)("strong",null,new Date(r.day).toLocaleDateString(c,{weekday:"short",day:"2-digit",month:"2-digit"})),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-ok"})," ",(0,i.__)("Delivered","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.delivered))),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-transit"})," ",(0,i.__)("In transit","digimail-smtp")," ",(0,l.createElement)("b",null,d(Math.max(0,r.sent-r.delivered-r.failed)))),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-bad"})," ",(0,i.__)("Failed","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.failed))),(0,l.createElement)("span",null,(0,i.__)("Opened","digimail-smtp")," ",(0,l.createElement)("b",null,d(r.opened)))),(0,l.createElement)("div",{className:"dms-legend"},(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-ok"})," ",(0,i.__)("Delivered","digimail-smtp")),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-transit"})," ",(0,i.__)("In transit","digimail-smtp")),(0,l.createElement)("span",null,(0,l.createElement)("i",{className:"dms-dot dms-bar-bad"})," ",(0,i.__)("Failed or bounced","digimail-smtp"))))}function F({label:e,used:t,total:a}){const i=a>0?Math.min(100,t/a*100):0;return(0,l.createElement)("div",{className:"dms-meter"},(0,l.createElement)("div",{className:"dms-meter-head"},(0,l.createElement)("span",null,e),(0,l.createElement)("span",null,(0,l.createElement)("b",null,d(t))," / ",d(a))),(0,l.createElement)("div",{className:"dms-meter-bar"},(0,l.createElement)("span",{style:{width:`${i}%`},className:i>90?"is-bad":i>70?"is-wait":""})))}function z({state:e,go:t}){const[a,s]=(0,l.useState)(null),[n,m]=(0,l.useState)("");(0,l.useEffect)(()=>{o("stats?days=14").then(s).catch(e=>m(e.message))},[]);const r=e.status,c=r.sender,p=r.account,g=a?.days.reduce((e,t)=>e+t.sent,0)??0,_=a?.days.reduce((e,t)=>e+t.delivered,0)??0,b=a?.days.reduce((e,t)=>e+t.failed,0)??0,y=a?.days.reduce((e,t)=>e+t.opened,0)??0,k="shared"===c?.mode,N=r.site_domain,S=N&&!/^(localhost|[\d.]+|\[?[\da-f:]+\]?)$/i.test(N.domain)&&N.domain.includes(".")?N:null;return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-hero"},(0,l.createElement)("div",{className:"dms-hero-icon"},(0,l.createElement)(w,{name:"check",size:26})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("This website sends email through DigiMail","digimail-smtp")),c&&(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: sender name, 2: sender email. */ /* translators: 1: sender name, 2: sender email. */(0,i.__)("From <strong>%1$s</strong> (%2$s)","digimail-smtp"),c.name,c.email),{strong:(0,l.createElement)("strong",null)})," ",k?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Own domain","digimail-smtp")))),(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("test")},(0,l.createElement)(w,{name:"send",size:15})," ",(0,i.__)("Send test email","digimail-smtp"))),e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),!e.settings.capture.enabled&&(e.capture.forms.length>0||e.capture.woocommerce)&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Save form contacts to DigiMail","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.sprintf)(/* translators: %s: form plugins or WooCommerce found on the site. */ /* translators: %s: form plugins or WooCommerce found on the site. */ 3 3 (0,i.__)("People who fill in %s can go straight into a DigiMail contact list for your campaigns.","digimail-smtp"),[...e.capture.forms,...e.capture.woocommerce?["WooCommerce"]:[]].join(", "))),e.conflicts.length>0&&/* translators: %s: names of other active SMTP plugins. */ /* translators: %s: names of other active SMTP plugins. */ 4 4 (0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)((0,i.__)("%s is also active","digimail-smtp"),e.conflicts.map(e=>e.name).join(", ")),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("tools")},(0,i.__)("Import settings","digimail-smtp"))},(0,i.__)("Two plugins sending email will get in each other’s way. Import the old settings (the old SMTP server becomes the backup connection), then deactivate the other plugin on the Plugins page.","digimail-smtp")),(e.queue.failed>0||e.queue.queued>0)&&(0,l.createElement)(v,{tone:e.queue.failed?"bad":"info",title:e.queue.failed?(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */(0,i.__)("%s emails not sent yet","digimail-smtp"),d(e.queue.failed)):(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */(0,i.__)("%s emails waiting to send","digimail-smtp"),d(e.queue.queued)),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("logs")},(0,i.__)("View","digimail-smtp"))},e.last_failure?.error??(0,i.__)("The plugin resends them once DigiMail can be reached.","digimail-smtp")),"review"===p?.status&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Your DigiMail account is not active yet","digimail-smtp")},(0,i.sprintf)(/* translators: %s: daily email limit. */ /* translators: %s: daily email limit. */ 5 (0,i.__)("Click the confirmation link DigiMail sent to your account email to activate it. Until then, the website can send up to %s emails a day from the shared address.","digimail-smtp"),d(r.shared?.daily_limit??50))),(0,l.createElement)(E,{title:(0,i.__)("Last 14 days","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>t("logs")},(0,i.__)("Email log","digimail-smtp")," ",(0,l.createElement)(w,{name:"list",size:15}))},(0,l.createElement)("div",{className:"dms-kpis"},(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Sent","digimail-smtp")),(0,l.createElement)("strong",null,d( u))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Delivered","digimail-smtp")),(0,l.createElement)("strong",null,T(_,u),"%"),(0,l.createElement)("em",null,(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */(0,i.__)("%s emails","digimail-smtp"),d(_)))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Failed or bounced","digimail-smtp")),(0,l.createElement)("strong",{className:b>0?"is-bad":""},d(b)),(0,l.createElement)("em",null,T(b,u),"%")),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Opened","digimail-smtp")),(0,l.createElement)("strong",null,d(y)),(0,l.createElement)("em",null,T(y,u),"%"))),n&&(0,l.createElement)("p",{className:"dms-error"},n),a?(0,l.createElement)(D,{days:a.days}):!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:190}})),a&&a.sources.length>0&&(0,l.createElement)(E,{title:(0,i.__)("Email by sending plugin","digimail-smtp")},(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Emails","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Failed","digimail-smtp")))),(0,l.createElement)("tbody",null,a.sources.map(e=>(0,l.createElement)("tr",{key:e.source??"-"},(0,l.createElement)("td",null,g(e.source)||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("td",{className:"num"},d(e.sent)),(0,l.createElement)("td",{className:"num "+(e.failed?"is-bad":"dms-muted")},d(e.failed)))))))),(0,l.createElement)("div",{className:"dms-col"},k&&(0,l.createElement)(E,{className:"dms-upgrade"},(0,l.createElement)("div",{className:"dms-upgrade-icon"},(0,l.createElement)(w,{name:"globe",size:22})),(0,l.createElement)("h3",null,(0,i.__)("Send from your own domain","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared sender address, 2: reply-to address. */ /* translators: 1: shared sender address, 2: reply-to address. */(0,i.__)("Sending from <code>%1$s</code>; replies go to <strong>%2$s</strong>.","digimail-smtp"),o?.shared_email??"",o?.reply_to??e.site.admin_email),{code:(0,l.createElement)("code",null),strong:(0,l.createElement)("strong",null)})," ",S?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: example address on the domain, 3: daily limit of the shared address. */ /* translators: 1: domain, 2: example address on the domain, 3: daily limit of the shared address. */(0,i.__)("Verify <strong>%1$s</strong> to send from an address like <code>%2$s</code>: more trusted by Gmail and Outlook, and no %3$s emails/day limit of the shared address.","digimail-smtp"),S.domain,`noreply@${S.domain}`,d(r.shared?.daily_limit??0)),{code:(0,l.createElement)("code",null),strong:(0,l.createElement)("strong",null)}):(0,i.sprintf)(/* translators: %s: daily limit of the shared address. */ /* translators: %s: daily limit of the shared address. */6 (0,i.__)("Verify your domain on digimail.vn to send from your company email: more trusted, and no %s emails/day limit of the shared address.","digimail-smtp"),d(r.shared?.daily_limit??0))),"pending"===S?.status&&(0,l.createElement)("p",null,(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS records","digimail-smtp"))),S?(0,l.createElement)(f,{className:"dms-btn-block",onClick:()=>{t("settings"),setTimeout(()=>document.getElementById("dms-domain")?.scrollIntoView({behavior:"smooth",block:"start"}),400)}},"pending"===S.status?(0,i.__)("See the DNS records to add","digimail-smtp"):(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),S.domain)):(0,l.createElement)("a",{className:"dms-btn dms-btn-primary dms-btn-block",href:r.links?.domains,target:"_blank",rel:"noreferrer"},(0,i.__)("Verify your domain","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:15})),(0,l.createElement)("small",{className:"dms-muted"},(0,i.__)("Once verified, the plugin switches to your domain automatically.","digimail-smtp"))),p&&(0,l.createElement)(E,{title:(0,i.__)("Quota","digimail-smtp"),aside:p.plan?(0,l.createElement)(h,{tone:"info"},p.plan):(0,l.createElement)(h,null,(0,i.__)("Free","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-meters"},(0,l.createElement)(F,{label:(0,i.__)("Today","digimail-smtp"),used:p.sent_today,total:p.daily_limit}),(0,l.createElement)(F,{label:(0,i.__)("This month","digimail-smtp"),used:p.sent_month,total:p.monthly_limit}),k&&r.shared&&(0,l.createElement)(F,{label:(0,i.__)("Shared address, today","digimail-smtp"),used:r.shared.sent_today,total:r.shared.daily_limit})),(0,l.createElement)("a",{className:"dms-link",href:r.links?.billing,target:"_blank",rel:"noreferrer"},(0,i.__)("Upgrade plan","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)(E,{title:(0,i.__)("DigiMail account","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,p?.name),(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,r.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Background sending","digimail-smtp")),(0,l.createElement)("dd",null,e.settings.queue?(0,i.__)("On","digimail-smtp"):(0,i.__)("Off","digimail-smtp")),(0,l.createElement)("dt",null,(0,i.__)("Backup","digimail-smtp")),(0,l.createElement)("dd",null,e.settings.backup.enabled?e.settings.backup.host:(0,i.__)("Off","digimail-smtp"))),(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-block",href:r.links?.dashboard,target:"_blank",rel:"noreferrer"},(0,i.__)("Manage on digimail.vn","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:15})))))}const P=[{key:"",label:(0,i.__)("All","digimail-smtp")},{key:"delivered",label:(0,i.__)("Delivered","digimail-smtp")},{key:"sent",label:(0,i.__)("In transit","digimail-smtp")},{key:"failed",label:(0,i.__)("Failed","digimail-smtp")},{key:"opened",label:(0,i.__)("Opened","digimail-smtp")}],$={send:(0,i.__)("DigiMail sent it","digimail-smtp"),delivery:(0,i.__)("The receiving server accepted it","digimail-smtp"),bounce_permanent:(0,i.__)("Bounced permanently","digimail-smtp"),bounce_transient:(0,i.__)("Bounced temporarily","digimail-smtp"),complaint:(0,i.__)("The recipient marked it as spam","digimail-smtp"),reject:(0,i.__)("Rejected","digimail-smtp"),open:(0,i.__)("The recipient opened it","digimail-smtp"),click:(0,i.__)("The recipient clicked a link","digimail-smtp"),deliverydelay:(0,i.__)("Delivery delayed, retrying","digimail-smtp")};function O({d:e,onSent:t}){const a=C(),[s,n]=(0,l.useState)(!1),[m,r]=(0,l.useState)(""),[ o,d]=(0,l.useState)(!1);return e.resendable?(0,l.createElement)("form",{className:"dms-resend",onSubmit:l=>{l.preventDefault(),(async()=>{d(!0);try{const l=await c(`logs/${e.id}/resend`,s?{to:m}:{});a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("Sent again to %s.","digimail-smtp"),l.to),"ok"),n(!1),r(""),t()}catch(e){a(e.message,"bad")}finally{d(!1)}})()}},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:s?"":"is-on",onClick:()=>n(!1)},(0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("To %s","digimail-smtp"),e.to)),(0,l.createElement)("button",{type:"button",className:s?"is-on":"",onClick:()=>n(!0)},(0,i.__)("To another address","digimail-smtp"))),s&&(0,l.createElement)("input",{type:"email",required:!0,placeholder:"email@example.com","aria-label":(0,i.__)("Send to","digimail-smtp"),value:m,onChange:e=>r(e.target.value)}),(0,l.createElement)(f,{type:"submit",size:"sm",busy:o},(0,l.createElement)(w,{name:"refresh",size:14})," ",(0,i.__)("Send again","digimail-smtp"))):null}function A({id:e,onClose:t}){const[a,s]=(0,l.useState)(null),[n,m]=(0,l.useState)(""),[r,d]=(0,l.useState)("html");(0,l.useEffect)(()=>{s(null),m(""),e&&c(`logs/${e}`).then(s).catch(e=>m(e.message))},[e]);const _=a?u[a.status]??{label:a.status,tone:"muted"}:null;return(0,l.createElement)(N,{open:!!e,onClose:t,title:a?.subject??(0,i.__)("Email details","digimail-smtp")},n&&(0,l.createElement)("p",{className:"dms-error"},n),!a&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:300}}),a&&_&&(0,l.createElement)("div",{className:"dms-detail"},(0,l.createElement)("div",{className:"dms-detail-head"},(0,l.createElement)(h,{tone:_.tone},_.label),a.opened_at&&(0,l.createElement)(h,{tone:"info"},(0,i.__)("Opened","digimail-smtp")),a.clicked_at&&(0,l.createElement)(h,{tone:"info"},(0,i.__)("Clicked","digimail-smtp"))),(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("To","digimail-smtp")),(0,l.createElement)("dd",null,a.to),(0,l.createElement)("dt",null,(0,i.__)("From","digimail-smtp")),(0,l.createElement)("dd",null,a.from),a.reply_to&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("dt",null,(0,i.__)("Reply to","digimail-smtp")),(0,l.createElement)("dd",null,a.reply_to)),a.source&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("dt",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("dd",null,g(a.source))),(0,l.createElement)("dt",null,(0,i.__)("Created","digimail-smtp")),(0,l.createElement)("dd",null,new Date(a.created_at).toLocaleString(o))),a.error&&(0,l.createElement)("div",{className:"dms-errbox"},(0,l.createElement)("strong",null,(0,i.__)("Reason","digimail-smtp")),(0,l.createElement)("code",null,a.error)),a.resend_of&&(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("This is a copy sent again from the log.","digimail-smtp")),(0,l.createElement)(O,{d:a,onSent:()=>{}}),(0,l.createElement)("h3",null,(0,i.__)("Timeline","digimail-smtp")),(0,l.createElement)("ol",{className:"dms-timeline"},(0,l.createElement)("li",{className:"is-ok"},(0,l.createElement)("span",null,(0,i.__)("The website handed it to DigiMail","digimail-smtp")),(0,l.createElement)("time",null,p(a.created_at))),a.events.map((e,t)=>(0,l.createElement)("li",{key:t,className:/bounce|complaint|reject/.test(e.kind)?"is-bad":"is-ok"},(0,l.createElement)("span",null,$[e.kind]??e.kind),(0,l.createElement)("time",null,p(e.at)),e.detail&&(0,l.createElement)("code",null,e.detail))),!a.events.some(e=>"delivery"===e.kind||e.kind.startsWith("bounce"))&&!["bounced","failed","rejected","suppressed"].includes(a.status)&&(0,l.createElement)("li",{className:"is-wait"},(0,l.createElement)("span",null,(0,i.__)("Waiting for the receiving server to confirm","digimail-smtp")))),a.attachments.length>0&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("h3",null,(0,i.__)("Attachments","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-files"},a.attachments.map((e,t)=>(0,l.createElement)("li",{key:t},(0,l.createElement)(w,{name:"paperclip",size:14})," ",e.name," ",(0,l.createElement)("span",{className:"dms-muted"},Math.max(1,Math.round(e.size/1024))," KB"))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("h3",null,(0,i.__)("Content","digimail-smtp")),a.html&&a.text&&(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===r?"is-on":"",onClick:()=>d("html")},(0,i.__)("Rendered","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"text"===r?"is-on":"",onClick:()=>d("text")},(0,i.__)("Plain text","digimail-smtp")))),a.html&&"html"===r?(0,l.createElement)("iframe",{className:"dms-preview",title:(0,i.__)("Email content","digimail-smtp"),sandbox:"",srcDoc:a.html}):(0,l.createElement)("pre",{className:"dms-pre"},a.text??(a.html?(0,i.__)("(no plain-text version)","digimail-smtp"):(0,i.__)("(content no longer stored)","digimail-smtp")))))}function I({onChange:e}){const[t,a]=(0,l.useState)([]),[s,n]=(0,l.useState)(null),m=C(),r=(0,l.useCallback)(()=>c("queue").then(e=>a(e.items)),[]);(0,l.useEffect)(()=>{r().catch(()=>{})},[r]);const o=async(t,l,s={})=>{n(t);try{const t=await c(l,s);a(t.items),void 0!==t.sent&&m(t.failed?(0,i.sprintf)(/* translators: 1: emails sent, 2: emails still failing. */ /* translators: 1: emails sent, 2: emails still failing. */(0,i.__)("Sent %1$d, %2$d still failing.","digimail-smtp"),t.sent,t.failed):(0,i.sprintf)(/* translators: %d: number of emails sent. */ /* translators: %d: number of emails sent. */(0,i._n)("Sent %d email.","Sent %d emails.",t.sent,"digimail-smtp"),t.sent),t.failed?"bad":"ok"),e()}catch(e){m(e.message,"bad")}finally{n(null)}},_=t.filter(e=>"backup"!==e.status&&"blocked"!==e.status);return 0===t.length?null:(0,l.createElement)(E,{title:(0,l.createElement)(l.Fragment,null,(0,i.__)("Not yet at DigiMail","digimail-smtp")," ",(0,l.createElement)(h,{tone:_.some(e=>"failed"===e.status)?"bad":"muted"},d(t.length))),aside:(0,l.createElement)("div",{className:"dms-actions"},_.length>0&&(0,l.createElement)(f,{size:"sm",busy:"all"===s,onClick:()=>o("all","queue/retry")},(0,l.createElement)(w,{name:"refresh",size:14})," ",(0,i.__)("Resend all","digimail-smtp")),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:"clear"===s,onClick:()=>o("clear","queue/delete")},(0,i.__)("Clear handled items","digimail-smtp")))},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Emails that failed before reaching DigiMail (network down, quota used up…), went out through the backup server, or were not sent because DigiMail found the recipient suspicious (most likely typed into a form by a bot). The plugin keeps them for 30 days.","digimail-smtp")),(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Recipient","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Subject","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Reason","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,t.map(e=>{const t=u[e.status];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:t.tone},"queued"===e.status?e.attempts?(0,i.sprintf)(/* translators: %d: attempt number. */ /* translators: %d: attempt number. */(0,i.__)("Retrying (attempt %d)","digimail-smtp"),e.attempts+1):(0,i.__)("Waiting to retry","digimail-smtp"):t.label),(0,l.createElement)("div",{className:"dms-muted dms-small"},p(e.created_at))),(0,l.createElement)("td",{className:"dms-ellipsis"},e.recipients),(0,l.createElement)("td",{className:"dms-ellipsis"},e.subject,(0,l.createElement)("div",{className:"dms-muted dms-small"},g(e.source))),(0,l.createElement)("td",{className:"dms-small"},e.error),(0,l.createElement)("td",{className:"dms-actions"},"backup"!==e.status&&"blocked"!==e.status&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:s===`r${e.id}`,onClick:()=>o(`r${e.id}`,"queue/retry",{id:e.id})},(0,i.__)("Resend","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Delete","digimail-smtp"),onClick:()=>o(`d${e.id}`,"queue/delete",{id:e.id})},(0,l.createElement)(w,{name:"x",size:15}))))}))))}function L({reload:e}){const[t,a]=(0,l.useState)(""),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(1),[_,b]=(0,l.useState)(null),[y,v]=(0,l.useState)(""),[N,S]=(0,l.useState)(null),C=(0,l.useCallback)(()=>{const e=new URLSearchParams({page:String(m)});return t&&e.set("status",t),s.trim()&&e.set("q",s.trim()),c(`logs?${e}`).then(e=>{b(e),v("")}).catch(e=>v(e.message))},[m,t,s]);(0,l.useEffect)(()=>{const e=setTimeout(C,s?300:0);return()=>clearTimeout(e)},[C,s]),(0,l.useEffect)(()=>{const e=setInterval(()=>{N||"visible"!==document.visibilityState||C()},15e3);return()=>clearInterval(e)},[C,N]);const x=_?Math.max(1,Math.ceil(_.total/_.per_page)):1;return(0,l.createElement)("div",{className:"dms-stack"},(0,l.createElement)(I,{onChange:e}),(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-seg",role:"group","aria-label":(0,i.__)("Filter by status","digimail-smtp")},P.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:t===e.key?"is-on":"",onClick:()=>{a(e.key),r(1)}},e.label))),(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:s,onChange:e=>{n(e.target.value),r(1)},placeholder:(0,i.__)("Search recipient or subject","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>C(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))),y&&(0,l.createElement)("p",{className:"dms-error"},y),!_&&!y&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),_&&0===_.items.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"mail",size:26}),title:s||t?(0,i.__)("No matching emails","digimail-smtp"):(0,i.__)("No emails yet","digimail-smtp")},s||t?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("Email your website sends through DigiMail shows up here, with its real delivery status.","digimail-smtp")),_&&_.items.length>0&&(0,l.createElement)("table",{className:"dms-table dms-table-click"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Recipient","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Subject","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,_.items.map(e=>{const t=u[e.status]??{label:e.status,tone:"muted"};return(0,l.createElement)("tr",{key:e.id,tabIndex:0,onClick:()=>S(e.id),onKeyDown:t=>"Enter"===t.key&&S(e.id)},(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:t.tone},t.label),e.opened_at&&(0,l.createElement)("span",{className:"dms-opened",title:(0,i.sprintf)(/* translators: %s: date and time. */ /* translators: %s: date and time. */7 (0,i.__)("Opened %s","digimail-smtp"),new Date(e.opened_at).toLocaleString( o))},(0,l.createElement)(w,{name:"eye",size:14}))),(0,l.createElement)("td",{className:"dms-ellipsis"},e.to),(0,l.createElement)("td",{className:"dms-ellipsis"},e.subject,e.error&&(0,l.createElement)("div",{className:"dms-small is-bad dms-ellipsis"},e.error)),(0,l.createElement)("td",{className:"dms-small dms-muted"},g(e.source)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.created_at).toLocaleString(o)},p(e.created_at)))}))),_&&x>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */5 (0,i.__)("Click the confirmation link DigiMail sent to your account email to activate it. Until then, the website can send up to %s emails a day from the shared address.","digimail-smtp"),d(r.shared?.daily_limit??50))),(0,l.createElement)(E,{title:(0,i.__)("Last 14 days","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>t("logs")},(0,i.__)("Email log","digimail-smtp")," ",(0,l.createElement)(w,{name:"list",size:15}))},(0,l.createElement)("div",{className:"dms-kpis"},(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Sent","digimail-smtp")),(0,l.createElement)("strong",null,d(g))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Delivered","digimail-smtp")),(0,l.createElement)("strong",null,T(_,g),"%"),(0,l.createElement)("em",null,(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */(0,i.__)("%s emails","digimail-smtp"),d(_)))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Failed or bounced","digimail-smtp")),(0,l.createElement)("strong",{className:b>0?"is-bad":""},d(b)),(0,l.createElement)("em",null,T(b,g),"%")),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Opened","digimail-smtp")),(0,l.createElement)("strong",null,d(y)),(0,l.createElement)("em",null,T(y,g),"%"))),n&&(0,l.createElement)("p",{className:"dms-error"},n),a?(0,l.createElement)(D,{days:a.days}):!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:190}})),a&&a.sources.length>0&&(0,l.createElement)(E,{title:(0,i.__)("Email by sending plugin","digimail-smtp")},(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Emails","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Failed","digimail-smtp")))),(0,l.createElement)("tbody",null,a.sources.map(e=>(0,l.createElement)("tr",{key:e.source??"-"},(0,l.createElement)("td",null,u(e.source)||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("td",{className:"num"},d(e.sent)),(0,l.createElement)("td",{className:"num "+(e.failed?"is-bad":"dms-muted")},d(e.failed)))))))),(0,l.createElement)("div",{className:"dms-col"},k&&(0,l.createElement)(E,{className:"dms-upgrade"},(0,l.createElement)("div",{className:"dms-upgrade-icon"},(0,l.createElement)(w,{name:"globe",size:22})),(0,l.createElement)("h3",null,(0,i.__)("Send from your own domain","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared sender address, 2: reply-to address. */ /* translators: 1: shared sender address, 2: reply-to address. */(0,i.__)("Sending from <code>%1$s</code>; replies go to <strong>%2$s</strong>.","digimail-smtp"),c?.shared_email??"",c?.reply_to??e.site.admin_email),{code:(0,l.createElement)("code",null),strong:(0,l.createElement)("strong",null)})," ",S?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: example address on the domain, 3: daily limit of the shared address. */ /* translators: 1: domain, 2: example address on the domain, 3: daily limit of the shared address. */(0,i.__)("Verify <strong>%1$s</strong> to send from an address like <code>%2$s</code>: more trusted by Gmail and Outlook, and no %3$s emails/day limit of the shared address.","digimail-smtp"),S.domain,`noreply@${S.domain}`,d(r.shared?.daily_limit??0)),{code:(0,l.createElement)("code",null),strong:(0,l.createElement)("strong",null)}):(0,i.sprintf)(/* translators: %s: daily limit of the shared address. */ /* translators: %s: daily limit of the shared address. */ 6 (0,i.__)("Verify your domain on digimail.vn to send from your company email: more trusted, and no %s emails/day limit of the shared address.","digimail-smtp"),d(r.shared?.daily_limit??0))),"pending"===S?.status&&(0,l.createElement)("p",null,(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS records","digimail-smtp"))),S?(0,l.createElement)(f,{className:"dms-btn-block",onClick:()=>{t("settings"),setTimeout(()=>document.getElementById("dms-domain")?.scrollIntoView({behavior:"smooth",block:"start"}),400)}},"pending"===S.status?(0,i.__)("See the DNS records to add","digimail-smtp"):(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),S.domain)):(0,l.createElement)("a",{className:"dms-btn dms-btn-primary dms-btn-block",href:r.links?.domains,target:"_blank",rel:"noreferrer"},(0,i.__)("Verify your domain","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:15})),(0,l.createElement)("small",{className:"dms-muted"},(0,i.__)("Once verified, the plugin switches to your domain automatically.","digimail-smtp"))),p&&(0,l.createElement)(E,{title:(0,i.__)("Quota","digimail-smtp"),aside:p.plan?(0,l.createElement)(h,{tone:"info"},p.plan):(0,l.createElement)(h,null,(0,i.__)("Free","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-meters"},(0,l.createElement)(F,{label:(0,i.__)("Today","digimail-smtp"),used:p.sent_today,total:p.daily_limit}),(0,l.createElement)(F,{label:(0,i.__)("This month","digimail-smtp"),used:p.sent_month,total:p.monthly_limit}),k&&r.shared&&(0,l.createElement)(F,{label:(0,i.__)("Shared address, today","digimail-smtp"),used:r.shared.sent_today,total:r.shared.daily_limit})),(0,l.createElement)("a",{className:"dms-link",href:r.links?.billing,target:"_blank",rel:"noreferrer"},(0,i.__)("Upgrade plan","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)(E,{title:(0,i.__)("DigiMail account","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,p?.name),(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,r.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Background sending","digimail-smtp")),(0,l.createElement)("dd",null,e.settings.queue?(0,i.__)("On","digimail-smtp"):(0,i.__)("Off","digimail-smtp")),(0,l.createElement)("dt",null,(0,i.__)("Backup","digimail-smtp")),(0,l.createElement)("dd",null,e.settings.backup.enabled?e.settings.backup.host:(0,i.__)("Off","digimail-smtp"))),(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-block",href:r.links?.dashboard,target:"_blank",rel:"noreferrer"},(0,i.__)("Manage on digimail.vn","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:15})))))}const P=[{key:"",label:(0,i.__)("All","digimail-smtp")},{key:"delivered",label:(0,i.__)("Delivered","digimail-smtp")},{key:"sent",label:(0,i.__)("In transit","digimail-smtp")},{key:"failed",label:(0,i.__)("Failed","digimail-smtp")},{key:"opened",label:(0,i.__)("Opened","digimail-smtp")}],$={send:(0,i.__)("DigiMail sent it","digimail-smtp"),delivery:(0,i.__)("The receiving server accepted it","digimail-smtp"),bounce_permanent:(0,i.__)("Bounced permanently","digimail-smtp"),bounce_transient:(0,i.__)("Bounced temporarily","digimail-smtp"),complaint:(0,i.__)("The recipient marked it as spam","digimail-smtp"),reject:(0,i.__)("Rejected","digimail-smtp"),open:(0,i.__)("The recipient opened it","digimail-smtp"),click:(0,i.__)("The recipient clicked a link","digimail-smtp"),deliverydelay:(0,i.__)("Delivery delayed, retrying","digimail-smtp")};function O({d:e,onSent:t}){const a=C(),[s,n]=(0,l.useState)(!1),[m,r]=(0,l.useState)(""),[c,d]=(0,l.useState)(!1);return e.resendable?(0,l.createElement)("form",{className:"dms-resend",onSubmit:l=>{l.preventDefault(),(async()=>{d(!0);try{const l=await o(`logs/${e.id}/resend`,s?{to:m}:{});a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("Sent again to %s.","digimail-smtp"),l.to),"ok"),n(!1),r(""),t()}catch(e){a(e.message,"bad")}finally{d(!1)}})()}},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:s?"":"is-on",onClick:()=>n(!1)},(0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("To %s","digimail-smtp"),e.to)),(0,l.createElement)("button",{type:"button",className:s?"is-on":"",onClick:()=>n(!0)},(0,i.__)("To another address","digimail-smtp"))),s&&(0,l.createElement)("input",{type:"email",required:!0,placeholder:"email@example.com","aria-label":(0,i.__)("Send to","digimail-smtp"),value:m,onChange:e=>r(e.target.value)}),(0,l.createElement)(f,{type:"submit",size:"sm",busy:c},(0,l.createElement)(w,{name:"refresh",size:14})," ",(0,i.__)("Send again","digimail-smtp"))):null}function A({id:e,onClose:t}){const[a,s]=(0,l.useState)(null),[n,m]=(0,l.useState)(""),[r,d]=(0,l.useState)("html");(0,l.useEffect)(()=>{s(null),m(""),e&&o(`logs/${e}`).then(s).catch(e=>m(e.message))},[e]);const _=a?g[a.status]??{label:a.status,tone:"muted"}:null;return(0,l.createElement)(N,{open:!!e,onClose:t,title:a?.subject??(0,i.__)("Email details","digimail-smtp")},n&&(0,l.createElement)("p",{className:"dms-error"},n),!a&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:300}}),a&&_&&(0,l.createElement)("div",{className:"dms-detail"},(0,l.createElement)("div",{className:"dms-detail-head"},(0,l.createElement)(h,{tone:_.tone},_.label),a.opened_at&&(0,l.createElement)(h,{tone:"info"},(0,i.__)("Opened","digimail-smtp")),a.clicked_at&&(0,l.createElement)(h,{tone:"info"},(0,i.__)("Clicked","digimail-smtp"))),(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("To","digimail-smtp")),(0,l.createElement)("dd",null,a.to),(0,l.createElement)("dt",null,(0,i.__)("From","digimail-smtp")),(0,l.createElement)("dd",null,a.from),a.reply_to&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("dt",null,(0,i.__)("Reply to","digimail-smtp")),(0,l.createElement)("dd",null,a.reply_to)),a.source&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("dt",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("dd",null,u(a.source))),(0,l.createElement)("dt",null,(0,i.__)("Created","digimail-smtp")),(0,l.createElement)("dd",null,new Date(a.created_at).toLocaleString(c))),a.error&&(0,l.createElement)("div",{className:"dms-errbox"},(0,l.createElement)("strong",null,(0,i.__)("Reason","digimail-smtp")),(0,l.createElement)("code",null,a.error)),a.resend_of&&(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("This is a copy sent again from the log.","digimail-smtp")),(0,l.createElement)(O,{d:a,onSent:()=>{}}),(0,l.createElement)("h3",null,(0,i.__)("Timeline","digimail-smtp")),(0,l.createElement)("ol",{className:"dms-timeline"},(0,l.createElement)("li",{className:"is-ok"},(0,l.createElement)("span",null,(0,i.__)("The website handed it to DigiMail","digimail-smtp")),(0,l.createElement)("time",null,p(a.created_at))),a.events.map((e,t)=>(0,l.createElement)("li",{key:t,className:/bounce|complaint|reject/.test(e.kind)?"is-bad":"is-ok"},(0,l.createElement)("span",null,$[e.kind]??e.kind),(0,l.createElement)("time",null,p(e.at)),e.detail&&(0,l.createElement)("code",null,e.detail))),!a.events.some(e=>"delivery"===e.kind||e.kind.startsWith("bounce"))&&!["bounced","failed","rejected","suppressed"].includes(a.status)&&(0,l.createElement)("li",{className:"is-wait"},(0,l.createElement)("span",null,(0,i.__)("Waiting for the receiving server to confirm","digimail-smtp")))),a.attachments.length>0&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("h3",null,(0,i.__)("Attachments","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-files"},a.attachments.map((e,t)=>(0,l.createElement)("li",{key:t},(0,l.createElement)(w,{name:"paperclip",size:14})," ",e.name," ",(0,l.createElement)("span",{className:"dms-muted"},Math.max(1,Math.round(e.size/1024))," KB"))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("h3",null,(0,i.__)("Content","digimail-smtp")),a.html&&a.text&&(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===r?"is-on":"",onClick:()=>d("html")},(0,i.__)("Rendered","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"text"===r?"is-on":"",onClick:()=>d("text")},(0,i.__)("Plain text","digimail-smtp")))),a.html&&"html"===r?(0,l.createElement)("iframe",{className:"dms-preview",title:(0,i.__)("Email content","digimail-smtp"),sandbox:"",srcDoc:a.html}):(0,l.createElement)("pre",{className:"dms-pre"},a.text??(a.html?(0,i.__)("(no plain-text version)","digimail-smtp"):(0,i.__)("(content no longer stored)","digimail-smtp")))))}function W({onChange:e}){const[t,a]=(0,l.useState)([]),[s,n]=(0,l.useState)(null),m=C(),r=(0,l.useCallback)(()=>o("queue").then(e=>a(e.items)),[]);(0,l.useEffect)(()=>{r().catch(()=>{})},[r]);const c=async(t,l,s={})=>{n(t);try{const t=await o(l,s);a(t.items),void 0!==t.sent&&m(t.failed?(0,i.sprintf)(/* translators: 1: emails sent, 2: emails still failing. */ /* translators: 1: emails sent, 2: emails still failing. */(0,i.__)("Sent %1$d, %2$d still failing.","digimail-smtp"),t.sent,t.failed):(0,i.sprintf)(/* translators: %d: number of emails sent. */ /* translators: %d: number of emails sent. */(0,i._n)("Sent %d email.","Sent %d emails.",t.sent,"digimail-smtp"),t.sent),t.failed?"bad":"ok"),e()}catch(e){m(e.message,"bad")}finally{n(null)}},_=t.filter(e=>"backup"!==e.status&&"blocked"!==e.status);return 0===t.length?null:(0,l.createElement)(E,{title:(0,l.createElement)(l.Fragment,null,(0,i.__)("Not yet at DigiMail","digimail-smtp")," ",(0,l.createElement)(h,{tone:_.some(e=>"failed"===e.status)?"bad":"muted"},d(t.length))),aside:(0,l.createElement)("div",{className:"dms-actions"},_.length>0&&(0,l.createElement)(f,{size:"sm",busy:"all"===s,onClick:()=>c("all","queue/retry")},(0,l.createElement)(w,{name:"refresh",size:14})," ",(0,i.__)("Resend all","digimail-smtp")),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:"clear"===s,onClick:()=>c("clear","queue/delete")},(0,i.__)("Clear handled items","digimail-smtp")))},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Emails that failed before reaching DigiMail (network down, quota used up…), went out through the backup server, or were not sent because DigiMail found the recipient suspicious (most likely typed into a form by a bot). The plugin keeps them for 30 days.","digimail-smtp")),(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Recipient","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Subject","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Reason","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,t.map(e=>{const t=g[e.status];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:t.tone},"queued"===e.status?e.attempts?(0,i.sprintf)(/* translators: %d: attempt number. */ /* translators: %d: attempt number. */(0,i.__)("Retrying (attempt %d)","digimail-smtp"),e.attempts+1):(0,i.__)("Waiting to retry","digimail-smtp"):t.label),(0,l.createElement)("div",{className:"dms-muted dms-small"},p(e.created_at))),(0,l.createElement)("td",{className:"dms-ellipsis"},e.recipients),(0,l.createElement)("td",{className:"dms-ellipsis"},e.subject,(0,l.createElement)("div",{className:"dms-muted dms-small"},u(e.source))),(0,l.createElement)("td",{className:"dms-small"},e.error),(0,l.createElement)("td",{className:"dms-actions"},"backup"!==e.status&&"blocked"!==e.status&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:s===`r${e.id}`,onClick:()=>c(`r${e.id}`,"queue/retry",{id:e.id})},(0,i.__)("Resend","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Delete","digimail-smtp"),onClick:()=>c(`d${e.id}`,"queue/delete",{id:e.id})},(0,l.createElement)(w,{name:"x",size:15}))))}))))}function I({reload:e}){const[t,a]=(0,l.useState)(""),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(1),[_,b]=(0,l.useState)(null),[y,v]=(0,l.useState)(""),[N,S]=(0,l.useState)(null),C=(0,l.useCallback)(()=>{const e=new URLSearchParams({page:String(m)});return t&&e.set("status",t),s.trim()&&e.set("q",s.trim()),o(`logs?${e}`).then(e=>{b(e),v("")}).catch(e=>v(e.message))},[m,t,s]);(0,l.useEffect)(()=>{const e=setTimeout(C,s?300:0);return()=>clearTimeout(e)},[C,s]),(0,l.useEffect)(()=>{const e=setInterval(()=>{N||"visible"!==document.visibilityState||C()},15e3);return()=>clearInterval(e)},[C,N]);const x=_?Math.max(1,Math.ceil(_.total/_.per_page)):1;return(0,l.createElement)("div",{className:"dms-stack"},(0,l.createElement)(W,{onChange:e}),(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-seg",role:"group","aria-label":(0,i.__)("Filter by status","digimail-smtp")},P.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:t===e.key?"is-on":"",onClick:()=>{a(e.key),r(1)}},e.label))),(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:s,onChange:e=>{n(e.target.value),r(1)},placeholder:(0,i.__)("Search recipient or subject","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>C(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))),y&&(0,l.createElement)("p",{className:"dms-error"},y),!_&&!y&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),_&&0===_.items.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"mail",size:26}),title:s||t?(0,i.__)("No matching emails","digimail-smtp"):(0,i.__)("No emails yet","digimail-smtp")},s||t?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("Email your website sends through DigiMail shows up here, with its real delivery status.","digimail-smtp")),_&&_.items.length>0&&(0,l.createElement)("table",{className:"dms-table dms-table-click"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Recipient","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Subject","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Source","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,_.items.map(e=>{const t=g[e.status]??{label:e.status,tone:"muted"};return(0,l.createElement)("tr",{key:e.id,tabIndex:0,onClick:()=>S(e.id),onKeyDown:t=>"Enter"===t.key&&S(e.id)},(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:t.tone},t.label),e.opened_at&&(0,l.createElement)("span",{className:"dms-opened",title:(0,i.sprintf)(/* translators: %s: date and time. */ /* translators: %s: date and time. */ 7 (0,i.__)("Opened %s","digimail-smtp"),new Date(e.opened_at).toLocaleString(c))},(0,l.createElement)(w,{name:"eye",size:14}))),(0,l.createElement)("td",{className:"dms-ellipsis"},e.to),(0,l.createElement)("td",{className:"dms-ellipsis"},e.subject,e.error&&(0,l.createElement)("div",{className:"dms-small is-bad dms-ellipsis"},e.error)),(0,l.createElement)("td",{className:"dms-small dms-muted"},u(e.source)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.created_at).toLocaleString(c)},p(e.created_at)))}))),_&&x>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of emails. */ /* translators: %s: number of emails. */ 8 8 (0,i._n)("%s email","%s emails",_.total,"digimail-smtp"),d(_.total))),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:m<=1,onClick:()=>r(m-1)},(0,i.__)("Previous","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: current page, 2: number of pages. */ /* translators: 1: current page, 2: number of pages. */ 9 (0,i.__)("Page %1$d of %2$d","digimail-smtp"),m,x)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:m>=x,onClick:()=>r(m+1)},(0,i.__)("Next","digimail-smtp")))),(0,l.createElement)(A,{id:N,onClose:()=>S(null)}))}function W({state:e,s:t,setS:a}){const s=t.guard,n=e.guard,m=e=>a({...t,guard:{...s,...e}});return(0,l.createElement)(E,{title:(0,i.__)("Block form spam","digimail-smtp"),aside:s.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.enabled,onChange:e=>m({enabled:e}),label:(0,i.__)("Stop bots before the form sends any email","digimail-smtp"),hint:(0,i.__)("Invisible to visitors: no puzzle, nothing to click. Bot submissions are refused, so no notification or auto-reply goes out and nothing reaches your contact list. Works with Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks and WooCommerce checkout.","digimail-smtp")}),s.enabled&&(0,l.createElement)(b,{checked:s.akismet&&n.akismet,disabled:!n.akismet,onChange:e=>m({akismet:e}),label:(0,i.__)("Also ask Akismet","digimail-smtp"),hint:n.akismet?(0,i.__)("Off by default. When on, only submissions that already look doubtful are sent to Akismet (name, email, message, IP address and browser) for a second opinion.","digimail-smtp"):(0,i.__)("Akismet is not set up on this site.","digimail-smtp")}),!s.enabled&&(0,l.createElement)("p",{className:"dms-small dms-error"},(0,i.__)("Without it, bots can use your forms to send email to addresses they type in. Bounces and spam reports from those emails can get sending paused.","digimail-smtp")),s.enabled&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */10 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. See them in the Customers tab.","digimail-smtp"),d(n.blocked),d(n.checked)))))}function j({summary:e}){const t=C(),[a,s]=(0,l.useState)(null),[n,r]=(0,l.useState)(""),[ o,u]=(0,l.useState)(""),[_,h]=(0,l.useState)(""),b=(0,l.useCallback)(()=>c("guard/log").then(e=>s(e.items)).catch(e=>r(e.message)),[]);(0,l.useEffect)(()=>{b()},[b]);const y=Object.entries(e.reasons).slice(0,4);return(0,l.createElement)(E,{title:(0,i.__)("Spam blocked","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:b,"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */11 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. No email was sent for them and they were not saved as contacts.","digimail-smtp"),d(e.blocked),d(e.checked)),y.length>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("Most common reasons:","digimail-smtp")," ",y.map(([e,t])=>`${m[e]??e} (${d(t)})`).join("; "),".")),n&&(0,l.createElement)("p",{className:"dms-error"},n),!a&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:240}}),a&&0===a.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"shield",size:26}),title:(0,i.__)("Nothing blocked yet","digimail-smtp")},(0,i.__)("Bot submissions show up here. If a real customer says the form did not work, find them here and click “Not spam”.","digimail-smtp")),a&&a.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Sender","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Why","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,a.map(e=>(0,l.createElement)(l.Fragment,{key:e.id},(0,l.createElement)("tr",null,(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email||"—"),e.name&&e.email&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.email),e.phone&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.phone)),(0,l.createElement)("td",{className:"dms-small"},[ g(e.source),e.form].filter(Boolean).join(" · "),(0,l.createElement)("div",{className:"dms-muted"},e.ip)),(0,l.createElement)("td",{className:"dms-small"},(0,l.createElement)("ul",{className:"dms-reasons"},e.reasons.map(e=>(0,l.createElement)("li",{key:e},m[e]??e))),e.text&&(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>h(_===e.id?"":e.id)},_===e.id?(0,i.__)("Hide message","digimail-smtp"):(0,i.__)("Show message","digimail-smtp"))),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(1e3*e.at).toLocaleString()},p(new Date(1e3*e.at).toISOString())),(0,l.createElement)("td",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:o===e.id,onClick:()=>(async e=>{u(e);try{await c("guard/restore",{id:e}),s(t=>(t??[]).filter(t=>t.id!==e)),t((0,i.__)("Marked as not spam. This address will not be blocked again.","digimail-smtp"))}catch(e){t(e.message,"bad")}finally{u("")}})(e.id)},(0,i.__)("Not spam","digimail-smtp")))),_===e.id&&(0,l.createElement)("tr",{className:"dms-subrow"},(0,l.createElement)("td",{colSpan:5},(0,l.createElement)("pre",{className:"dms-message"},e.text))))))),a&&a.length>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of entries kept. */ /* translators: %s: number of entries kept. */12 (0,i._n)("The latest %s blocked submission is kept on this website.","The latest %s blocked submissions are kept on this website.",a.length,"digimail-smtp"),d(a.length))))}const R={added:{label:(0,i.__)("New","digimail-smtp"),tone:"ok",hint:(0,i.__)("Added to the contact list.","digimail-smtp")},existing:{label:(0,i.__)("Already in list","digimail-smtp"),tone:"info",hint:(0,i.__)("This address was already in the list.","digimail-smtp")},blocked:{label:(0,i.__)("Blocked","digimail-smtp"),tone:"wait",hint:(0,i.__)("Unsubscribed, bounced or reported spam before, so it is not added back.","digimail-smtp")},invalid:{label:(0,i.__)("Invalid email","digimail-smtp"),tone:"bad",hint:(0,i.__)("The address cannot receive email.","digimail-smtp")},pending:{label:(0,i.__)("Awaiting confirmation","digimail-smtp"),tone:"wait",hint:(0,i.__)("A confirmation email was sent. They join the list after clicking it.","digimail-smtp")}}, q=e=>[g(e.source??"")||e.source,e.form].filter(Boolean).join(" · ")||(0,i.__)("Other","digimail-smtp");function B({state:e,go:t}){const a=C(),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[u,_]=(0,l.useState)(1),[b,y]=(0,l.useState)(null),[N,S]=(0,l.useState)(""),[x,M]=(0,l.useState)(!1),[T,D]=(0,l.useState)(!1),F=(0,l.useCallback)(e=>{const t=new URLSearchParams;return e&&t.set("page",String(u)),s&&t.set("form",s),m.trim()&&t.set("q",m.trim()),t.toString()},[u,s,m]),z=(0,l.useCallback)(()=>c(`entries?${F(!0)}`).then(e=>{y(e),S("")}).catch(e=>S(e.message)),[F]);(0,l.useEffect)(()=>{const e=setTimeout(z,m?300:0);return()=>clearTimeout(e)},[z,m]);const P=b?Math.max(1,Math.ceil(b.total/b.per_page)):1,$=b?b.forms.reduce((e,t)=>e+t.count,0):0,O=e.settings.capture.enabled,A=e.guard;return(0,l.createElement)("div",{className:"dms-stack"},!O&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Saving form contacts is off","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.__)("Turn it on in Settings and the people who fill in your forms show up here.","digimail-smtp")),b&&(b.forms.length>0||A.enabled)&&(0,l.createElement)("div",{className:"dms-formcards"},(0,l.createElement)("button",{type:"button",className:T||""!==s?"":"is-on",onClick:()=>{D(!1),n(""),_(1)}},(0,l.createElement)("span",null,(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("strong",null,d($))),b.forms.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:T||s!==e.key?"":"is-on",onClick:()=>{D(!1),n(e.key),_(1)}},(0,l.createElement)("span",{className:"dms-ellipsis",title:q(e)},e.form||g(e.source??"")||e.source||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("strong",null,d(e.count)),(0,l.createElement)("small",{className:"dms-ellipsis"},e.form&&e.source?(g(e.source)||e.source)+" · ":"",(0,i.sprintf)(/* translators: %s: time of the last entry. */ /* translators: %s: time of the last entry. */13 (0,i.__)("last %s","digimail-smtp"),p(e.last_at))))),A.enabled&&(0,l.createElement)("button",{type:"button",className:"is-spam "+(T?"is-on":""),onClick:()=>D(!0)},(0,l.createElement)("span",null,(0,l.createElement)(w,{name:"shield",size:14})," ",(0,i.__)("Spam blocked","digimail-smtp")),(0,l.createElement)("strong",null,d(A.blocked)),(0,l.createElement)("small",null,(0,i.__)("last 30 days","digimail-smtp")))),T&&(0,l.createElement)(j,{summary:A}),!T&&(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:m,onChange:e=>{r(e.target.value),_(1)},placeholder:(0,i.__)("Search name, email or phone","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>z(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15})),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:x,disabled:!b||0===b.total,onClick:async()=>{M(!0);try{const e=await c(`entries/export?${F(!1)}`),t=URL.createObjectURL(new Blob([e.csv],{type:"text/csv;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download="khach-dien-form.csv",a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{M(!1)}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Export CSV","digimail-smtp"))),e.capture.pending>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of contacts. */ /* translators: %s: number of contacts. */14 (0,i._n)("%s new entry is on its way to DigiMail.","%s new entries are on their way to DigiMail.",e.capture.pending,"digimail-smtp"),d(e.capture.pending))),N&&(0,l.createElement)("p",{className:"dms-error"},N),!b&&!N&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),b&&0===b.entries.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"users",size:26}),title:m||s?(0,i.__)("No matching entries","digimail-smtp"):(0,i.__)("No form entries yet","digimail-smtp")},m||s?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("When someone fills in a form or places an order, they show up here with the form and page they used.","digimail-smtp")),b&&b.entries.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Customer","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Phone","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Page","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Result","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,b.entries.map(e=>{const t=R[e.outcome];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email),e.name&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.email),e.company&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.company)),(0,l.createElement)("td",{className:"dms-small"},e.phone?(0,l.createElement)("a",{href:`tel:${e.phone.replace(/[^\d+]/g,"")}`},e.phone):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"}, q(e)),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},e.page?(0,l.createElement)("a",{href:e.page,target:"_blank",rel:"noreferrer"},(e=>{try{const t=new URL(e);return decodeURIComponent(t.pathname)||"/"}catch{return e}})(e.page)):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{title:t.hint},(0,l.createElement)(h,{tone:t.tone},t.label)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.submitted_at).toLocaleString(o)},p(e.submitted_at)))}))),b&&P>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of entries. */ /* translators: %s: number of entries. */15 (0,i._n)("%s entry","%s entries",b.total,"digimail-smtp"),d(b.total))),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled: u<=1,onClick:()=>_(u-1)},(0,i.__)("Previous","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: current page, 2: number of pages. */ /* translators: 1: current page, 2: number of pages. */16 (0,i.__)("Page %1$d of %2$d","digimail-smtp"), u,P)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:u>=P,onClick:()=>_(u+1)},(0,i.__)("Next","digimail-smtp")))))}function U({state:e,go:t}){const[a,s]=(0,l.useState)(e.site.user_email),[n,m]=(0,l.useState)("html"),[r,o]=(0,l.useState)(!1),[d,p]=(0,l.useState)(null),[u,g]=(0,l.useState)("");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)(E,{title:(0,i.__)("Send a test email","digimail-smtp")},e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),(0,l.createElement)("form",{className:"dms-form",onSubmit:e=>{e.preventDefault(),(async()=>{o(!0),g(""),p(null);try{p(await c("test",{to:a,format:n}))}catch(e){g(e.message)}finally{o(!1)}})()}},(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("The test goes through the same wp_mail() function your website and plugins use, so if it works, order emails and contact forms work too.","digimail-smtp")),(0,l.createElement)(y,{label:(0,i.__)("Send to","digimail-smtp"),htmlFor:"dms-to"},(0,l.createElement)("input",{id:"dms-to",type:"email",required:!0,value:a,onChange:e=>s(e.target.value)})),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Format","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===n?"is-on":"",onClick:()=>m("html")},"HTML"),(0,l.createElement)("button",{type:"button",className:"text"===n?"is-on":"",onClick:()=>m("text")},(0,i.__)("Plain text","digimail-smtp")))),(0,l.createElement)("div",null,(0,l.createElement)(f,{type:"submit",busy:r},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send test email","digimail-smtp")))),d&&(0,l.createElement)(v,{tone:"ok",title:"backup"===d.via?(0,i.__)("Sent through the backup server","digimail-smtp"):(0,i.__)("Sent. Check your inbox.","digimail-smtp"),action:"digimail"===d.via&&(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("logs")},(0,i.__)("See status","digimail-smtp"))},(0,i.sprintf)(/* translators: 1: sender name, 2: sender email, 3: seconds taken. */ /* translators: 1: sender name, 2: sender email, 3: seconds taken. */17 (0,i.__)("Sent from %1$s <%2$s> in %3$s seconds. The Delivered status shows in the email log a few seconds later.","digimail-smtp"),d.from?.name??"",d.from?.email??"",(d.took_ms/1e3).toFixed(1))), u&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("The email was not sent","digimail-smtp")},u)),(0,l.createElement)(E,{title:(0,i.__)("No email?","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-checklist"},(0,l.createElement)("li",null,(0,l.createInterpolateElement)((0,i.__)("Check the <strong>Spam</strong> folder and the Gmail <strong>Promotions</strong> tab.","digimail-smtp"),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("li",null,(0,l.createInterpolateElement)((0,i.__)("Open the <a>email log</a> and click the email to see whether the receiving server accepted or bounced it, and why.","digimail-smtp"),{a:(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>t("logs")})})),(0,l.createElement)("li",null,(0,i.__)("Sending from the shared address? Verify your own domain so Gmail and Outlook trust your email more.","digimail-smtp")),(0,l.createElement)("li",null,(0,i.__)("Some company networks block outside email: try a Gmail address.","digimail-smtp")))))}function V({state:e,s:t,setS:a}){const s=C(),n=t.capture,m=e.capture,[r,o]=(0,l.useState)(null),[u,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(m.last),[k,w]=(0,l.useState)(m.pending),N=e=>a({...t,capture:{...n,...e}});return(0,l.useEffect)(()=>{n.enabled&&!r&&c("lists").then(o).catch(()=>{})},[n.enabled,r]),(0,l.createElement)(E,{title:(0,i.__)("Save form contacts to DigiMail","digimail-smtp"),aside:n.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:n.enabled,onChange:e=>N({enabled:e}),label:(0,i.__)("Add people who fill in forms to a DigiMail contact list","digimail-smtp"),hint:(0,i.__)("Email, name and phone from contact, signup and order forms go straight into a list on digimail.vn, ready for your campaigns.","digimail-smtp")}),n.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(b,{checked:n.forms,onChange:e=>N({forms:e}),label:(0,i.__)("Forms on the website","digimail-smtp"),hint:m.forms.length18 /* translators: %s: names of form plugins found on the site. */?(0,i.sprintf)(/* translators: %s: list of form plugins. */ /* translators: %s: list of form plugins. */(0,i.__)("Found: %s.","digimail-smtp"),m.forms.join(", ")):(0,i.__)("No supported form plugin is active. Supported: Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks.","digimail-smtp")}),(0,l.createElement)(b,{checked:n.woocommerce&&m.woocommerce,onChange:e=>N({woocommerce:e}),label:(0,i.__)("WooCommerce buyers","digimail-smtp"),hint:m.woocommerce?(0,i.__)("Billing email, name and phone of each new order.","digimail-smtp"):(0,i.__)("WooCommerce is not active.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Contact list","digimail-smtp"),htmlFor:"dms-list",hint:(0,i.__)("Saved right away. New contacts go to this list.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-list",disabled:!r||"list"=== u,value:r?.list_id??"",onChange:e=>(async e=>{g("list");try{o(await c("list",{list_id:e})),s((0,i.__)("Contact list saved.","digimail-smtp"))}catch(e){s(e.message,"bad")}finally{g(null)}})(e.target.value)},!r&&(0,l.createElement)("option",{value:""},(0,i.__)("Loading…","digimail-smtp")),r&&!r.list_id&&(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: list name. */ /* translators: %s: list name. */9 (0,i.__)("Page %1$d of %2$d","digimail-smtp"),m,x)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:m>=x,onClick:()=>r(m+1)},(0,i.__)("Next","digimail-smtp")))),(0,l.createElement)(A,{id:N,onClose:()=>S(null)}))}function L({state:e,s:t,setS:a}){const s=t.guard,n=e.guard,m=e=>a({...t,guard:{...s,...e}});return(0,l.createElement)(E,{title:(0,i.__)("Block form spam","digimail-smtp"),aside:s.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.enabled,onChange:e=>m({enabled:e}),label:(0,i.__)("Stop bots before the form sends any email","digimail-smtp"),hint:(0,i.__)("Invisible to visitors: no puzzle, nothing to click. Bot submissions are refused, so no notification or auto-reply goes out and nothing reaches your contact list. Works with Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks and WooCommerce checkout.","digimail-smtp")}),s.enabled&&(0,l.createElement)(b,{checked:s.core,onChange:e=>m({core:e}),label:(0,i.__)("Also protect WordPress registration, lost password and comment forms","digimail-smtp"),hint:(0,i.__)("Bots use these forms to make your site email addresses they type in. Includes WooCommerce account registration. Logged-in users are never checked; spam comments go to the Spam folder.","digimail-smtp")}),s.enabled&&(0,l.createElement)(b,{checked:s.badge,onChange:e=>m({badge:e}),label:(0,i.__)("Show admins a note under each form","digimail-smtp"),hint:(0,i.__)("When you are logged in as an admin, each form on your site shows whether the spam guard protects it. Visitors never see it.","digimail-smtp")}),s.enabled&&(0,l.createElement)(b,{checked:s.akismet&&n.akismet,disabled:!n.akismet,onChange:e=>m({akismet:e}),label:(0,i.__)("Also ask Akismet","digimail-smtp"),hint:n.akismet?(0,i.__)("Off by default. When on, only submissions that already look doubtful are sent to Akismet (name, email, message, IP address and browser) for a second opinion.","digimail-smtp"):(0,i.__)("Akismet is not set up on this site.","digimail-smtp")}),!s.enabled&&(0,l.createElement)("p",{className:"dms-small dms-error"},(0,i.__)("Without it, bots can use your forms to send email to addresses they type in. Bounces and spam reports from those emails can get sending paused.","digimail-smtp")),s.enabled&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */ 10 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. See them in the Customers tab.","digimail-smtp"),d(n.blocked),d(n.checked)))))}function j({summary:e}){const t=C(),[a,s]=(0,l.useState)(null),[n,r]=(0,l.useState)(""),[c,g]=(0,l.useState)(""),[_,h]=(0,l.useState)(""),b=(0,l.useCallback)(()=>o("guard/log").then(e=>s(e.items)).catch(e=>r(e.message)),[]);(0,l.useEffect)(()=>{b()},[b]);const y=Object.entries(e.reasons).slice(0,4);return(0,l.createElement)(E,{title:(0,i.__)("Spam blocked","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:b,"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */ 11 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. No email was sent for them and they were not saved as contacts.","digimail-smtp"),d(e.blocked),d(e.checked)),y.length>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("Most common reasons:","digimail-smtp")," ",y.map(([e,t])=>`${m[e]??e} (${d(t)})`).join("; "),".")),n&&(0,l.createElement)("p",{className:"dms-error"},n),!a&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:240}}),a&&0===a.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"shield",size:26}),title:(0,i.__)("Nothing blocked yet","digimail-smtp")},(0,i.__)("Bot submissions show up here. If a real customer says the form did not work, find them here and click “Not spam”.","digimail-smtp")),a&&a.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Sender","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Why","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,a.map(e=>(0,l.createElement)(l.Fragment,{key:e.id},(0,l.createElement)("tr",null,(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email||"—"),e.name&&e.email&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.email),e.phone&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.phone)),(0,l.createElement)("td",{className:"dms-small"},[u(e.source),e.form].filter(Boolean).join(" · "),(0,l.createElement)("div",{className:"dms-muted"},e.ip)),(0,l.createElement)("td",{className:"dms-small"},(0,l.createElement)("ul",{className:"dms-reasons"},e.reasons.map(e=>(0,l.createElement)("li",{key:e},m[e]??e))),e.text&&(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>h(_===e.id?"":e.id)},_===e.id?(0,i.__)("Hide message","digimail-smtp"):(0,i.__)("Show message","digimail-smtp"))),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(1e3*e.at).toLocaleString()},p(new Date(1e3*e.at).toISOString())),(0,l.createElement)("td",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:c===e.id,onClick:()=>(async e=>{g(e);try{await o("guard/restore",{id:e}),s(t=>(t??[]).filter(t=>t.id!==e)),t((0,i.__)("Marked as not spam. This address will not be blocked again.","digimail-smtp"))}catch(e){t(e.message,"bad")}finally{g("")}})(e.id)},(0,i.__)("Not spam","digimail-smtp")))),_===e.id&&(0,l.createElement)("tr",{className:"dms-subrow"},(0,l.createElement)("td",{colSpan:5},(0,l.createElement)("pre",{className:"dms-message"},e.text))))))),a&&a.length>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of entries kept. */ /* translators: %s: number of entries kept. */ 12 (0,i._n)("The latest %s blocked submission is kept on this website.","The latest %s blocked submissions are kept on this website.",a.length,"digimail-smtp"),d(a.length))))}const R={added:{label:(0,i.__)("New","digimail-smtp"),tone:"ok",hint:(0,i.__)("Added to the contact list.","digimail-smtp")},existing:{label:(0,i.__)("Already in list","digimail-smtp"),tone:"info",hint:(0,i.__)("This address was already in the list.","digimail-smtp")},blocked:{label:(0,i.__)("Blocked","digimail-smtp"),tone:"wait",hint:(0,i.__)("Unsubscribed, bounced or reported spam before, so it is not added back.","digimail-smtp")},invalid:{label:(0,i.__)("Invalid email","digimail-smtp"),tone:"bad",hint:(0,i.__)("The address cannot receive email.","digimail-smtp")},pending:{label:(0,i.__)("Awaiting confirmation","digimail-smtp"),tone:"wait",hint:(0,i.__)("A confirmation email was sent. They join the list after clicking it.","digimail-smtp")}},B=e=>[u(e.source??"")||e.source,e.form].filter(Boolean).join(" · ")||(0,i.__)("Other","digimail-smtp");function q({state:e,go:t}){const a=C(),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[g,_]=(0,l.useState)(1),[b,y]=(0,l.useState)(null),[N,S]=(0,l.useState)(""),[x,M]=(0,l.useState)(!1),[T,D]=(0,l.useState)(!1),F=(0,l.useCallback)(e=>{const t=new URLSearchParams;return e&&t.set("page",String(g)),s&&t.set("form",s),m.trim()&&t.set("q",m.trim()),t.toString()},[g,s,m]),z=(0,l.useCallback)(()=>o(`entries?${F(!0)}`).then(e=>{y(e),S("")}).catch(e=>S(e.message)),[F]);(0,l.useEffect)(()=>{const e=setTimeout(z,m?300:0);return()=>clearTimeout(e)},[z,m]);const P=b?Math.max(1,Math.ceil(b.total/b.per_page)):1,$=b?b.forms.reduce((e,t)=>e+t.count,0):0,O=e.settings.capture.enabled,A=e.guard;return(0,l.createElement)("div",{className:"dms-stack"},!O&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Saving form contacts is off","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.__)("Turn it on in Settings and the people who fill in your forms show up here.","digimail-smtp")),b&&(b.forms.length>0||A.enabled)&&(0,l.createElement)("div",{className:"dms-formcards"},(0,l.createElement)("button",{type:"button",className:T||""!==s?"":"is-on",onClick:()=>{D(!1),n(""),_(1)}},(0,l.createElement)("span",null,(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("strong",null,d($))),b.forms.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:T||s!==e.key?"":"is-on",onClick:()=>{D(!1),n(e.key),_(1)}},(0,l.createElement)("span",{className:"dms-ellipsis",title:B(e)},e.form||u(e.source??"")||e.source||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("strong",null,d(e.count)),(0,l.createElement)("small",{className:"dms-ellipsis"},e.form&&e.source?(u(e.source)||e.source)+" · ":"",(0,i.sprintf)(/* translators: %s: time of the last entry. */ /* translators: %s: time of the last entry. */ 13 (0,i.__)("last %s","digimail-smtp"),p(e.last_at))))),A.enabled&&(0,l.createElement)("button",{type:"button",className:"is-spam "+(T?"is-on":""),onClick:()=>D(!0)},(0,l.createElement)("span",null,(0,l.createElement)(w,{name:"shield",size:14})," ",(0,i.__)("Spam blocked","digimail-smtp")),(0,l.createElement)("strong",null,d(A.blocked)),(0,l.createElement)("small",null,(0,i.__)("last 30 days","digimail-smtp")))),T&&(0,l.createElement)(j,{summary:A}),!T&&(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:m,onChange:e=>{r(e.target.value),_(1)},placeholder:(0,i.__)("Search name, email or phone","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>z(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15})),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:x,disabled:!b||0===b.total,onClick:async()=>{M(!0);try{const e=await o(`entries/export?${F(!1)}`),t=URL.createObjectURL(new Blob([e.csv],{type:"text/csv;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download="khach-dien-form.csv",a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{M(!1)}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Export CSV","digimail-smtp"))),e.capture.pending>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of contacts. */ /* translators: %s: number of contacts. */ 14 (0,i._n)("%s new entry is on its way to DigiMail.","%s new entries are on their way to DigiMail.",e.capture.pending,"digimail-smtp"),d(e.capture.pending))),N&&(0,l.createElement)("p",{className:"dms-error"},N),!b&&!N&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),b&&0===b.entries.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"users",size:26}),title:m||s?(0,i.__)("No matching entries","digimail-smtp"):(0,i.__)("No form entries yet","digimail-smtp")},m||s?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("When someone fills in a form or places an order, they show up here with the form and page they used.","digimail-smtp")),b&&b.entries.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Customer","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Phone","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Page","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Result","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,b.entries.map(e=>{const t=R[e.outcome];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email),e.name&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.email),e.company&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.company)),(0,l.createElement)("td",{className:"dms-small"},e.phone?(0,l.createElement)("a",{href:`tel:${e.phone.replace(/[^\d+]/g,"")}`},e.phone):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},B(e)),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},e.page?(0,l.createElement)("a",{href:e.page,target:"_blank",rel:"noreferrer"},(e=>{try{const t=new URL(e);return decodeURIComponent(t.pathname)||"/"}catch{return e}})(e.page)):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{title:t.hint},(0,l.createElement)(h,{tone:t.tone},t.label)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.submitted_at).toLocaleString(c)},p(e.submitted_at)))}))),b&&P>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of entries. */ /* translators: %s: number of entries. */ 15 (0,i._n)("%s entry","%s entries",b.total,"digimail-smtp"),d(b.total))),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:g<=1,onClick:()=>_(g-1)},(0,i.__)("Previous","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: current page, 2: number of pages. */ /* translators: 1: current page, 2: number of pages. */ 16 (0,i.__)("Page %1$d of %2$d","digimail-smtp"),g,P)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:g>=P,onClick:()=>_(g+1)},(0,i.__)("Next","digimail-smtp")))))}function V({state:e,go:t}){const[a,s]=(0,l.useState)(e.site.user_email),[n,m]=(0,l.useState)("html"),[r,c]=(0,l.useState)(!1),[d,p]=(0,l.useState)(null),[g,u]=(0,l.useState)("");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)(E,{title:(0,i.__)("Send a test email","digimail-smtp")},e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),(0,l.createElement)("form",{className:"dms-form",onSubmit:e=>{e.preventDefault(),(async()=>{c(!0),u(""),p(null);try{p(await o("test",{to:a,format:n}))}catch(e){u(e.message)}finally{c(!1)}})()}},(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("The test goes through the same wp_mail() function your website and plugins use, so if it works, order emails and contact forms work too.","digimail-smtp")),(0,l.createElement)(y,{label:(0,i.__)("Send to","digimail-smtp"),htmlFor:"dms-to"},(0,l.createElement)("input",{id:"dms-to",type:"email",required:!0,value:a,onChange:e=>s(e.target.value)})),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Format","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===n?"is-on":"",onClick:()=>m("html")},"HTML"),(0,l.createElement)("button",{type:"button",className:"text"===n?"is-on":"",onClick:()=>m("text")},(0,i.__)("Plain text","digimail-smtp")))),(0,l.createElement)("div",null,(0,l.createElement)(f,{type:"submit",busy:r},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send test email","digimail-smtp")))),d&&(0,l.createElement)(v,{tone:"ok",title:"backup"===d.via?(0,i.__)("Sent through the backup server","digimail-smtp"):(0,i.__)("Sent. Check your inbox.","digimail-smtp"),action:"digimail"===d.via&&(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("logs")},(0,i.__)("See status","digimail-smtp"))},(0,i.sprintf)(/* translators: 1: sender name, 2: sender email, 3: seconds taken. */ /* translators: 1: sender name, 2: sender email, 3: seconds taken. */ 17 (0,i.__)("Sent from %1$s <%2$s> in %3$s seconds. The Delivered status shows in the email log a few seconds later.","digimail-smtp"),d.from?.name??"",d.from?.email??"",(d.took_ms/1e3).toFixed(1))),g&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("The email was not sent","digimail-smtp")},g)),(0,l.createElement)(E,{title:(0,i.__)("No email?","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-checklist"},(0,l.createElement)("li",null,(0,l.createInterpolateElement)((0,i.__)("Check the <strong>Spam</strong> folder and the Gmail <strong>Promotions</strong> tab.","digimail-smtp"),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("li",null,(0,l.createInterpolateElement)((0,i.__)("Open the <a>email log</a> and click the email to see whether the receiving server accepted or bounced it, and why.","digimail-smtp"),{a:(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>t("logs")})})),(0,l.createElement)("li",null,(0,i.__)("Sending from the shared address? Verify your own domain so Gmail and Outlook trust your email more.","digimail-smtp")),(0,l.createElement)("li",null,(0,i.__)("Some company networks block outside email: try a Gmail address.","digimail-smtp")))))}function U({state:e,s:t,setS:a}){const s=C(),n=t.capture,m=e.capture,[r,c]=(0,l.useState)(null),[g,u]=(0,l.useState)(null),[_,v]=(0,l.useState)(m.last),[k,w]=(0,l.useState)(m.pending),N=e=>a({...t,capture:{...n,...e}});return(0,l.useEffect)(()=>{n.enabled&&!r&&o("lists").then(c).catch(()=>{})},[n.enabled,r]),(0,l.createElement)(E,{title:(0,i.__)("Save form contacts to DigiMail","digimail-smtp"),aside:n.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:n.enabled,onChange:e=>N({enabled:e}),label:(0,i.__)("Add people who fill in forms to a DigiMail contact list","digimail-smtp"),hint:(0,i.__)("Email, name and phone from contact, signup and order forms go straight into a list on digimail.vn, ready for your campaigns.","digimail-smtp")}),n.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(b,{checked:n.forms,onChange:e=>N({forms:e}),label:(0,i.__)("Forms on the website","digimail-smtp"),hint:m.forms.length 18 /* translators: %s: names of form plugins found on the site. */?(0,i.sprintf)(/* translators: %s: list of form plugins. */ /* translators: %s: list of form plugins. */(0,i.__)("Found: %s.","digimail-smtp"),m.forms.join(", ")):(0,i.__)("No supported form plugin is active. Supported: Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks.","digimail-smtp")}),(0,l.createElement)(b,{checked:n.woocommerce&&m.woocommerce,onChange:e=>N({woocommerce:e}),label:(0,i.__)("WooCommerce buyers","digimail-smtp"),hint:m.woocommerce?(0,i.__)("Billing email, name and phone of each new order.","digimail-smtp"):(0,i.__)("WooCommerce is not active.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Contact list","digimail-smtp"),htmlFor:"dms-list",hint:(0,i.__)("Saved right away. New contacts go to this list.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-list",disabled:!r||"list"===g,value:r?.list_id??"",onChange:e=>(async e=>{u("list");try{c(await o("list",{list_id:e})),s((0,i.__)("Contact list saved.","digimail-smtp"))}catch(e){s(e.message,"bad")}finally{u(null)}})(e.target.value)},!r&&(0,l.createElement)("option",{value:""},(0,i.__)("Loading…","digimail-smtp")),r&&!r.list_id&&(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: list name. */ /* translators: %s: list name. */ 19 19 (0,i.__)("%s (created automatically)","digimail-smtp"),r.default_name)),r?.lists.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},(0,i.sprintf)(/* translators: 1: list name, 2: number of subscribers. */ /* translators: 1: list name, 2: number of subscribers. */ 20 20 (0,i.__)("%1$s (%2$s subscribers)","digimail-smtp"),e.name,d(e.subscribed)))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("span",{className:"dms-small dms-muted"},_?.error 21 21 /* translators: %s: error message. */?(0,i.sprintf)(/* translators: %s: error message. */ /* translators: %s: error message. */(0,i.__)("Last sync failed: %s","digimail-smtp"),_.error):_?(0,i.sprintf)(/* translators: 1: number of contacts, 2: time. */ /* translators: 1: number of contacts, 2: time. */ 22 (0,i.__)("%1$s contacts added so far, last sync %2$s.","digimail-smtp"),d(_.total??0),p(new Date(1e3*_.at).toISOString())):(0,i.__)("No contacts yet. They show up a few seconds after someone submits a form.","digimail-smtp"),k>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of items waiting. */ /* translators: %s: number of items waiting. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),d(k)))),k>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"=== u,onClick:async()=>{g("sync");try{const e=await c("contacts/sync",{});w(e.pending),v(e.last),e.last?.error?s(e.last.error,"bad"):s((0,i.__)("Contacts sent to DigiMail.","digimail-smtp"))}catch(e){s(e.message,"bad")}finally{g(null)}}},(0,i.__)("Send now","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send marketing email only to people who agreed to receive it. Add an “I agree to receive news” checkbox to your forms.","digimail-smtp")))))}const H={ok:{label:(0,i.__)("Correct","digimail-smtp"),tone:"ok"},missing:{label:(0,i.__)("Not added yet","digimail-smtp"),tone:"wait"},wrong:{label:(0,i.__)("Wrong value","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Could not check","digimail-smtp"),tone:"muted"}};function G({text:e,label:t}){const a=C();return(0,l.createElement)("button",{type:"button",className:"dms-copy",title:(0,i.__)("Copy","digimail-smtp"),"aria-label":(0,i.sprintf)(/* translators: %s: what is copied. */ /* translators: %s: what is copied. */(0,i.__)("Copy %s","digimail-smtp"),t),onClick:async()=>a(await async function(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const a=document.execCommand("copy");return t.remove(),a}}(e)?(0,i.__)("Copied.","digimail-smtp"):(0,i.__)("Could not copy. Select the text and copy it by hand.","digimail-smtp"))},(0,l.createElement)("code",null,e),(0,l.createElement)(w,{name:"copy",size:14}))}function J({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[o,p]=(0,l.useState)(""),[u,g]=(0,l.useState)(""),[_,b]=(0,l.useState)(""),k=(0,l.useCallback)(()=>c("domain").then(e=>(n(e),r(""),e)).catch(e=>(r(e.message),null)),[]);(0,l.useEffect)(()=>{k()},[k]);const N="pending"===s?.state;(0,l.useEffect)(()=>{if(!N)return;let e=0;const t=setInterval(()=>{e++,e>20||document.hidden?e>20&&clearInterval(t):k()},3e4);return()=>clearInterval(t)},[N,k]);const S="verified"===s?.state;(0,l.useEffect)(()=>{S&&"shared"===e.status.sender?.mode&&c("state?refresh=1").then(t).catch(()=>{})},[S,e.status.sender?.mode,t]);const x=async(e,t,l={})=>{p(e);try{const e=await c(t,l);return n(e),e}catch(e){return a(e.message,"bad"),null}finally{p("")}},M=async()=>{const e=await x("cf","domain/cloudflare",{token:u});e?.applied&&(g(""),a(e.applied.problems>0?(0,i.sprintf)(/* translators: %s: number of records. */ /* translators: %s: number of records. */(0,i.__)("Added what could be added. %s records need a look: see the list.","digimail-smtp"),d(e.applied.problems)):(0,i.__)("Records added in Cloudflare. Verification usually finishes within a few minutes.","digimail-smtp")))},T=s?"verified"===s.state?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Verified","digimail-smtp")):"pending"===s.state?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS","digimail-smtp")):"failed"===s.state?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Not verified","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Shared address","digimail-smtp")):null,D=s?.dns?.zone??s?.zone??null,F="cloudflare"===D?.provider.key||(s?.dns?.cloudflare.can_apply??s?.can_apply??!1),z=s?.dns?.cloudflare.can_apply??s?.can_apply??!1,P=s?.dns?.cloudflare.token_url??s?.token_url??"",$=s&&D&&D.apex!==s.domain&&s.domain.endsWith(`.${D.apex}`)?[s.domain,D.apex]:null;return(0,l.createElement)(E,{title:(0,l.createElement)("span",{id:"dms-domain"},(0,i.__)("Sending domain","digimail-smtp")),aside:T},m&&(0,l.createElement)("p",{className:"dms-error"},m),!s&&!m&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),s&&!s.eligible&&(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("This website runs on an IP address or localhost, so it has no domain to verify. It keeps sending from the shared address.","digimail-smtp")),s?.eligible&&"taken"===s.state&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is already in another DigiMail account","digimail-smtp"),s.domain)},(0,i.__)("Log in to that account on digimail.vn, or contact DigiMail if you own this domain.","digimail-smtp")),s?.eligible&&"none"===s.state&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared address, 2: example address on the site's domain. */ /* translators: 1: shared address, 2: example address on the site's domain. */23 (0,i.__)("The website sends from <code>%1$s</code>. Verify your domain to send from an address like <code>%2$s</code>: Gmail and Outlook trust it more, emails land in the inbox more often, and the shared address’s daily limit no longer applies.","digimail-smtp"),s.sender?.email??"",`noreply@${_||s.domain}`),{code:(0,l.createElement)("code",null)})),$&&(0,l.createElement)(y,{label:(0,i.__)("Domain to verify","digimail-smtp"),htmlFor:"dms-domain-pick",hint:(0,i.__)("Verifying the main domain covers every subdomain of it.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-domain-pick",value:_||$[0],onChange:e=>b(e.target.value)},$.map(e=>(0,l.createElement)("option",{key:e,value:e},e)))),D&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: DNS provider. */ /* translators: 1: domain, 2: DNS provider. */(0,i.__)("DNS of <strong>%1$s</strong> is managed at <strong>%2$s</strong>.","digimail-smtp"),D.apex,D.provider.name),{strong:(0,l.createElement)("strong",null)}),F&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("You can add the records with one click through Cloudflare.","digimail-smtp"))),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"add"=== o,onClick:()=>x("add","domain/add",_?{domain:_}:{})},(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),_||s.domain)))),s?.eligible&&"verified"===s.state&&(0,l.createElement)(v,{tone:"ok",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is verified","digimail-smtp"),s.dns?.domain??s.domain)},"domain"===s.sender?.mode?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender address. */ /* translators: %s: sender address. */(0,i.__)("The website sends from <code>%s</code>.","digimail-smtp"),s.sender.email),{code:(0,l.createElement)("code",null)}):(0,i.__)("The website switches to your domain within a minute.","digimail-smtp")),s?.eligible&&("pending"===s.state||"failed"===s.state)&&s.dns&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: correct records, 2: required records. */ /* translators: 1: correct records, 2: required records. */24 (0,i.__)("%1$s of %2$s required DNS records are correct.","digimail-smtp"),d(s.dns.summary.ok_required),d(s.dns.summary.required))," ",s.dns.summary.dns_ready?(0,i.__)("DNS is ready: DigiMail confirms the domain within a few minutes, then the website switches to it by itself.","digimail-smtp"):(0,i.__)("Add the records below where your domain’s DNS is managed. Changes usually show within minutes, sometimes a few hours.","digimail-smtp")),F&&!s.dns.summary.dns_ready&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Add them automatically through Cloudflare","digimail-smtp")),z?(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"cf"=== o,onClick:M},(0,i.__)("Add records in Cloudflare","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.__)("<a>Create a Cloudflare API token</a> (the link fills in the right permissions: Zone Read, DNS Edit), then paste it here. DigiMail stores it encrypted and only uses it to add these records.","digimail-smtp"),{a:(0,l.createElement)("a",{href:P,target:"_blank",rel:"noreferrer"})})),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("input",{type:"password",autoComplete:"off",value:u,onChange:e=>g(e.target.value),placeholder:(0,i.__)("Cloudflare API token","digimail-smtp"),"aria-label":(0,i.__)("Cloudflare API token","digimail-smtp")}),(0,l.createElement)(f,{busy:"cf"===o,disabled:u.trim().length<20,onClick:M},(0,i.__)("Connect and add records","digimail-smtp"))))),D&&!F&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: DNS provider, 2: how to add records there. */ /* translators: 1: DNS provider, 2: how to add records there. */(0,i.__)("DNS is at <strong>%1$s</strong>. %2$s","digimail-smtp"),D.provider.name,D.provider.guide),{strong:(0,l.createElement)("strong",null)}),D.provider.url&&(0,l.createElement)(l.Fragment,null," ",(0,l.createElement)("a",{href:D.provider.url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:12})))),s.applied&&s.applied.problems>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.__)("Some records were left alone in Cloudflare","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-reasons"},s.applied.outcomes.filter(e=>"conflict"===e.action||"failed"===e.action).map(e=>(0,l.createElement)("li",{key:e.name+e.type},e.type," ",e.name,": ",e.message)))),(0,l.createElement)("div",{className:"dms-table-wrap"},(0,l.createElement)("table",{className:"dms-table dms-dns"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Type","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Name (host)","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Value","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")))),(0,l.createElement)("tbody",null,s.dns.records.map(e=>(0,l.createElement)("tr",{key:e.type+e.name+e.value},(0,l.createElement)("td",null,(0,l.createElement)("strong",null,e.type),!e.required&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("recommended","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(G,{text:e.host||"@",label:(0,i.__)("name","digimail-smtp")})),(0,l.createElement)("td",null,(0,l.createElement)(G,{text:e.value,label:(0,i.__)("value","digimail-smtp")}),null!==e.priority&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: MX priority. */ /* translators: %s: MX priority. */(0,i.__)("Priority: %s","digimail-smtp"),e.priority)),"CNAME"===e.type&&F&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("Proxy off (DNS only)","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:H[e.state].tone},H[e.state].label),"ok"!==e.state&&e.note&&(0,l.createElement)("div",{className:"dms-small dms-muted"},e.note))))))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{busy:"check"===o,onClick:()=>x("check","domain/check")},(0,l.createElement)(w,{name:"refresh",size:15})," ",(0,i.__)("Check again","digimail-smtp")),(0,l.createElement)(f,{variant:"secondary",busy:"zone"===o,onClick:async()=>{p("zone");try{const e=await c("domain/zonefile"),t=URL.createObjectURL(new Blob([e.text],{type:"text/plain;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download=`digimail-${s?.dns?.domain??"dns"}.txt`,a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{p("")}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Download zone file","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("When the domain is verified, DigiMail tells you by Telegram or email (see Alerts).","digimail-smtp"))))}const Y={bad:"bad",warn:"wait",good:"ok"};function K(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[o,u]=(0,l.useState)(null),g=(0,l.useRef)(null),_=(0,l.useCallback)(()=>c("alerts").then(e=>(a(e),n(""),e)).catch(e=>(n(e.message),null)),[]);(0,l.useEffect)(()=>(_(),()=>{g.current&&clearInterval(g.current)}),[_]);const y=async t=>{r("prefs");try{a(await c("alerts/prefs",t))}catch(t){e(t.message,"bad")}finally{r("")}},v=t?.telegram.chats??[],k=!!t&&(t.prefs.telegram&&v.length>0||t.prefs.email&&t.emails.length>0);return(0,l.createElement)(E,{title:(0,i.__)("Alerts","digimail-smtp"),aside:t?k?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp")):null},s&&(0,l.createElement)("p",{className:"dms-error"},s),!t&&!s&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),t&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("DigiMail tells you when emails fail, the quota is nearly used up, bounces or spam reports rise, the plugin stops reporting, forms are hit by bots, or something changes with your domain. The same problem is repeated at most once a day.","digimail-smtp")),(0,l.createElement)(b,{checked:t.prefs.telegram,disabled:"prefs"===m||!t.telegram.available,onChange:e=>y({...t.prefs,telegram:e}),label:(0,i.__)("Telegram","digimail-smtp"),hint:t.telegram.available?v.length?(0,i.sprintf)(/* translators: %s: number of chats. */ /* translators: %s: number of chats. */(0,i._n)("Sent to %s connected chat.","Sent to %s connected chats.",v.length,"digimail-smtp"),d(v.length)):(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Connect your Telegram (or a group) to the %s bot.","digimail-smtp"),t.telegram.bot??""):(0,i.__)("Telegram alerts are not available yet.","digimail-smtp")}),t.telegram.available&&(0,l.createElement)("div",{className:"dms-chats"},v.map(t=>(0,l.createElement)("div",{key:t.id,className:"dms-chat"},(0,l.createElement)(w,{name:"private"===t.kind?"send":"users",size:15}),(0,l.createElement)("span",{className:"dms-grow"},t.title,"private"!==t.kind&&(0,l.createElement)("span",{className:"dms-muted dms-small"}," · ",(0,i.__)("group","digimail-smtp"))),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:m===t.id,onClick:()=>(async t=>{r(t.id);try{a(await c("alerts/telegram/remove",{id:t.id}))}catch(t){e(t.message,"bad")}finally{r("")}})(t)},(0,i.__)("Remove","digimail-smtp")))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",busy:"link"===m,onClick:async()=>{r("link");try{const a=await c("alerts/telegram",{});u(a),window.open(a.start_url,"_blank","noopener");const l=t?.telegram.chats.length??0;let s=0;g.current&&clearInterval(g.current),g.current=setInterval(async()=>{s++;const t=await _();(t&&t.telegram.chats.length>l||s>40)&&(g.current&&clearInterval(g.current),t&&t.telegram.chats.length>l&&(u(null),e((0,i.__)("Telegram connected.","digimail-smtp"))))},3e3)}catch(t){e(t.message,"bad")}finally{r("")}}},v.length?(0,i.__)("Connect another Telegram","digimail-smtp"):(0,i.__)("Connect Telegram","digimail-smtp"))),o&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Finish in Telegram","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Telegram opens a chat with %s: press Start. This page updates by itself once it is connected.","digimail-smtp"),o.bot)),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:o.start_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open Telegram","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13})),(0,l.createElement)("a",{className:"dms-btn dms-btn-ghost dms-btn-sm",href:o.group_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Add to a group instead","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("The link works once and expires in 30 minutes.","digimail-smtp")))),(0,l.createElement)(b,{checked:t.prefs.email,disabled:"prefs"===m,onChange:e=>y({...t.prefs,email:e}),label:(0,i.__)("Email","digimail-smtp"),hint:(0,i.sprintf)(/* translators: %s: email addresses. */ /* translators: %s: email addresses. */(0,i.__)("To %s (the users of your DigiMail account).","digimail-smtp"),t.emails.join(", "))}),void 0!==t.prefs.weekly&&(0,l.createElement)(b,{checked:t.prefs.weekly,disabled:"prefs"===m,onChange:e=>y({...t.prefs,weekly:e}),label:(0,i.__)("Weekly summary by email","digimail-smtp"),hint:(0,i.__)("Every Monday morning: emails sent last week, delivery rate, spam blocked on each website and the month’s quota. Nothing is sent after a quiet week.","digimail-smtp")}),(0,l.createElement)("div",null,(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:"test"===m,disabled:!k,onClick:async()=>{r("test");try{const t=await c("alerts/test",{});e(t.telegram+t.email>0?(0,i.sprintf)(/* translators: 1: Telegram chats, 2: email addresses. */ /* translators: 1: Telegram chats, 2: email addresses. */(0,i.__)("Test alert sent: %1$s Telegram, %2$s email.","digimail-smtp"),d(t.telegram),d(t.email)):(0,i.__)("Nothing was sent: turn on email or connect Telegram first.","digimail-smtp"),t.telegram+t.email>0?"ok":"bad"),_()}catch(t){e(t.message,"bad")}finally{r("")}}},(0,l.createElement)(w,{name:"bell",size:14})," ",(0,i.__)("Send a test alert","digimail-smtp"))),t.recent.length>0&&(0,l.createElement)("div",{className:"dms-recent"},(0,l.createElement)("strong",{className:"dms-small"},(0,i.__)("Recent alerts","digimail-smtp")),(0,l.createElement)("ul",null,t.recent.slice(0,5).map(e=>(0,l.createElement)("li",{key:e.created_at+e.kind,title:e.body},(0,l.createElement)(h,{tone:Y[e.level]},p(e.created_at))," ",e.title))))))}function Q({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(e.settings),[m,r]=(0,l.useState)(null),o=e.status.sender,d=o?.verified_domains??[],[p,u]=(0,l.useState)("domain"===o?.mode?o.email:""),[g,_]=(0,l.useState)(e.site.user_email),k=JSON.stringify(s)!==JSON.stringify(e.settings),N=async(e,l=(0,i.__)("Settings saved.","digimail-smtp"))=>{r("save");try{const i=await c("settings",e??s);return t(i),n(i.settings),a(l),!0}catch(e){return a(e.message,"bad"),!1}finally{r(null)}},S=Object.entries(e.controls).reduce((e,[t,a])=>((e[a.group]=e[a.group]??[]).push([t,a]),e),{}),x=s.backup,M=e=>n({...s,backup:{...x,...e}});return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Sender","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Sender name","digimail-smtp"),htmlFor:"dms-name",hint:(0,i.__)("Leave empty to use the website name. Recipients see this name in their inbox.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-name",value:s.from_name,placeholder:o?.name??e.site.name,onChange:e=>n({...s,from_name:e.target.value})})),(0,l.createElement)(b,{checked:s.force_from_name,onChange:e=>n({...s,force_from_name:e}),label:(0,i.__)("Always use this name","digimail-smtp"),hint:(0,i.__)("Even when another plugin (WooCommerce, a contact form) sets its own sender name.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Sender email","digimail-smtp"),htmlFor:"dms-from",hint:d.length?(0,i.__)("Only addresses on domains verified in DigiMail can be used.","digimail-smtp"):(0,i.__)("Verify your domain on digimail.vn to send from your company email.","digimail-smtp")},d.length?(0,l.createElement)("select",{id:"dms-from",value:p,onChange:e=>u(e.target.value)},(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: email address chosen automatically. */ /* translators: %s: email address chosen automatically. */25 (0,i.__)("Automatic (%s)","digimail-smtp"),"domain"=== o?.mode?o.email:`noreply@${d[0]}`)),d.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).map(e=>(0,l.createElement)("option",{key:e,value:e},e)),p&&!d.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).includes(p)&&(0,l.createElement)("option",{value:p},p)):(0,l.createElement)("div",{className:"dms-readonly"},o?.email," ",(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")))),"shared"===o?.mode&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: reply-to email address. */ /* translators: %s: reply-to email address. */(0,i.__)("Replies go to <strong>%s</strong>.","digimail-smtp"),o.reply_to??e.site.admin_email),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"sender"===m,onClick:async()=>{r("sender");try{const e=await c("sender",{from_email:p,from_name:s.from_name});t(e),await N({from_name:s.from_name,force_from_name:s.force_from_name},(0,i.__)("Sender saved.","digimail-smtp"))}catch(e){a(e.message,"bad")}finally{r(null)}}},(0,i.__)("Save sender","digimail-smtp"))))),(0,l.createElement)(J,{state:e,setState:t}),(0,l.createElement)(K,null),(0,l.createElement)(E,{title:(0,i.__)("Sending email","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.queue,onChange:e=>n({...s,queue:e}),label:(0,i.__)("Background sending","digimail-smtp"),hint:(0,i.__)("Checkout and contact forms do not wait for email: messages are queued and sent right after. Recommended for online shops.","digimail-smtp")}),s.queue&&!e.env.cron&&(0,l.createElement)(v,{tone:"wait"},(0,l.createInterpolateElement)((0,i.__)("WP-Cron is off (DISABLE_WP_CRON). A server cron job must call wp-cron.php every minute, or run <code>wp digimail queue</code>.","digimail-smtp"),{code:(0,l.createElement)("code",null)})))),(0,l.createElement)(W,{state:e,s,setS:n}),(0,l.createElement)(V,{state:e,s,setS:n}),(0,l.createElement)(E,{title:(0,i.__)("Backup connection","digimail-smtp"),aside:x.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("When DigiMail cannot send (network down, quota used up), the plugin sends through this SMTP server so no email is lost. Your hosting SMTP, Gmail or Microsoft 365 all work.","digimail-smtp")),(0,l.createElement)(b,{checked:x.enabled,onChange:e=>M({enabled:e}),label:(0,i.__)("Turn on backup connection","digimail-smtp")}),x.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("SMTP server","digimail-smtp"),htmlFor:"dms-bh"},(0,l.createElement)("input",{id:"dms-bh",value:x.host,onChange:e=>M({host:e.target.value}),placeholder:"smtp.gmail.com"})),(0,l.createElement)(y,{label:(0,i.__)("Port","digimail-smtp"),htmlFor:"dms-bp"},(0,l.createElement)("input",{id:"dms-bp",type:"number",value:x.port,onChange:e=>M({port:Number(e.target.value)})}))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Encryption","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},[["tls","TLS (587)"],["ssl","SSL (465)"],["none",(0,i.__)("None","digimail-smtp")]].map(([e,t])=>(0,l.createElement)("button",{key:e,type:"button",className:x.encryption===e?"is-on":"",onClick:()=>M({encryption:e,port:"ssl"===e?465:"tls"===e?587:25})},t)))),(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("Username","digimail-smtp"),htmlFor:"dms-bu"},(0,l.createElement)("input",{id:"dms-bu",value:x.username,autoComplete:"off",onChange:e=>M({username:e.target.value})})),(0,l.createElement)(y,{label:(0,i.__)("Password","digimail-smtp"),htmlFor:"dms-bpw",hint:(0,i.__)("Encrypted when saved.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bpw",type:"password",autoComplete:"new-password",value:x.password,onChange:e=>M({password:e.target.value})}))),(0,l.createElement)(y,{label:(0,i.__)("From email on this server","digimail-smtp"),htmlFor:"dms-bf",hint:(0,i.__)("Leave empty to use the SMTP username.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bf",type:"email",value:x.from_email,onChange:e=>M({from_email:e.target.value})})),(0,l.createElement)("div",{className:"dms-inline"},(0,l.createElement)("input",{type:"email","aria-label":(0,i.__)("Send a test email to","digimail-smtp"),value:g,onChange:e=>_(e.target.value)}),(0,l.createElement)(f,{variant:"secondary",busy:"backup"===m,onClick:async()=>{if(!k||await N()){r("backup");try{await c("backup/test",{to:g}),a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("The backup server sent an email to %s.","digimail-smtp"),g))}catch(e){a(e.message,"bad")}finally{r(null)}}}},(0,i.__)("Save and send test","digimail-smtp")))))),(0,l.createElement)(E,{title:(0,i.__)("Turn off WordPress default emails","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Fewer unneeded emails for administrators. Order emails, contact forms and password resets are not affected.","digimail-smtp")),Object.entries(S).map(([e,t])=>(0,l.createElement)("div",{key:e,className:"dms-group"},(0,l.createElement)("h3",null,e),t.map(([e,t])=>(0,l.createElement)(b,{key:e,checked:!1!==s.controls[e],onChange:t=>{const a={...s.controls};t?delete a[e]:a[e]=!1,n({...s,controls:a})},label:t.label,hint:t.hint||void 0})))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-sticky"},(0,l.createElement)(E,{title:(0,i.__)("Save changes","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},k?(0,i.__)("You have unsaved changes.","digimail-smtp"):(0,i.__)("All changes are saved.","digimail-smtp")),(0,l.createElement)(f,{size:"block",busy:"save"===m,disabled:!k,onClick:()=>N()},(0,i.__)("Save settings","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Connection","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,e.status.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,e.status.account?.name),(0,l.createElement)("dt",null,(0,i.__)("Key","digimail-smtp")),(0,l.createElement)("dd",null,e.token_constant?(0,i.__)("Set in wp-config.php","digimail-smtp"):(0,i.__)("Stored in the database","digimail-smtp"))),(0,l.createElement)(b,{checked:s.keep_data,onChange:e=>n({...s,keep_data:e}),label:(0,i.__)("Keep settings when the plugin is deleted","digimail-smtp")}),(0,l.createElement)(b,{checked:!!s.diagnostics,onChange:e=>n({...s,diagnostics:e}),label:(0,i.__)("Share diagnostics with DigiMail support","digimail-smtp"),hint:(0,i.__)("Off by default. When on, the WordPress, PHP and WooCommerce versions, language, a few of this plugin's settings and the names of other active email plugins are sent with the twice-daily status check, so support can see problems on digimail.vn.","digimail-smtp")}),!e.token_constant&&(0,l.createElement)(f,{variant:"danger",size:"block",busy:"disconnect"===m,onClick:async()=>{window.confirm((0,i.__)("Disconnect DigiMail? The website will go back to sending email through your hosting server (or the backup server, if set).","digimail-smtp"))&&(r("disconnect"),await c("disconnect",{}),window.location.reload())}},(0,l.createElement)(w,{name:"x",size:15})," ",(0,i.__)("Disconnect DigiMail","digimail-smtp"))))))}function Z({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(null),m=e.conflicts.map(e=>e.name),r=[`DigiMail SMTP ${e.env.plugin}`,`WordPress ${e.env.wordpress}, PHP ${e.env.php}`,`Website: ${e.site.url}`,`Connected: ${e.connected?"yes":"no"}${e.revoked?" (revoked)":""}`,`From: ${e.status.sender?.email??"-"} (${e.status.sender?.mode??"-"})`,`Background sending: ${e.settings.queue?"on":"off"}, WP-Cron: ${e.env.cron?"on":"off"}`,`Backup: ${e.settings.backup.enabled?e.settings.backup.host:"off"}`,`Queue: ${e.queue.queued} waiting, ${e.queue.failed} failed`,`Other SMTP plugins: ${m.join(", ")||"none"}`].join("\n");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Switch from another SMTP plugin","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Imports the sender name and the emails you turned off. The old SMTP server becomes the backup connection: DigiMail sends, and the old server is used only when DigiMail cannot.","digimail-smtp")),0===e.importable.length?(0,l.createElement)(k,{title:(0,i.__)("No settings found to import","digimail-smtp")},(0,i.__)("Supports WP Mail SMTP, Easy WP SMTP, Post SMTP, FluentSMTP and SMTP Mailer.","digimail-smtp")):(0,l.createElement)("ul",{className:"dms-list"},e.importable.map(e=>(0,l.createElement)("li",{key:e.key},(0,l.createElement)("span",null,(0,l.createElement)("strong",null,e.name),m.includes(e.name)&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Active","digimail-smtp")),(0,l.createElement)("small",null,e.smtp?(0,i.__)("Has an SMTP server to use as backup","digimail-smtp"):(0,i.__)("Sender name only","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:s===e.key,onClick:()=>(async(e,l)=>{n(e);try{const s=await c("import",{from:e});t(s),a(s.settings.backup.host?(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s. The old SMTP server is now the backup connection.","digimail-smtp"),l):(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s.","digimail-smtp"),l))}catch(e){a(e.message,"bad")}finally{n(null)}})(e.key,e.name)},(0,i.__)("Import","digimail-smtp"))))),m.length>0&&(0,l.createElement)("p",{className:"dms-small"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("After importing, deactivate %s on the <a>Plugins page</a> so the two plugins do not both try to send email.","digimail-smtp"),m.join(", ")),{a:(0,l.createElement)("a",{href:"plugins.php"})}))),(0,l.createElement)(E,{title:(0,i.__)("Command line (WP-CLI)","digimail-smtp")},(0,l.createElement)("pre",{className:"dms-pre"},[`wp digimail status # ${(0,i.__)("connection, sender, quota","digimail-smtp")}`,`wp digimail test you@company.com # ${(0,i.__)("send a test email","digimail-smtp")}`,`wp digimail queue --retry-failed # ${(0,i.__)("resend waiting and failed emails","digimail-smtp")}`,"wp digimail connect you@company.com","wp digimail disconnect"].join("\n")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Agencies can set the key in wp-config.php:","digimail-smtp")," ",(0,l.createElement)("code",null,"define( 'DIGIMAIL_SMTP_TOKEN', 'dm_…' );")))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Support information","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard?.writeText(r),a((0,i.__)("Copied.","digimail-smtp"))}},(0,l.createElement)(w,{name:"download",size:14})," ",(0,i.__)("Copy","digimail-smtp"))},(0,l.createElement)("pre",{className:"dms-pre"},r),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send this when you contact DigiMail support. It contains no secret keys.","digimail-smtp")))))}const X=[{key:"modern",label:(0,i.__)("Modern","digimail-smtp"),hint:(0,i.__)("White card with a line in your colour","digimail-smtp")},{key:"minimal",label:(0,i.__)("Minimal","digimail-smtp"),hint:(0,i.__)("All white, logo in the middle","digimail-smtp")},{key:"bold",label:(0,i.__)("Bold","digimail-smtp"),hint:(0,i.__)("Your colour across the top","digimail-smtp")}],ee=[{key:"sans",label:(0,i.__)("Modern sans-serif","digimail-smtp")},{key:"serif",label:(0,i.__)("Classic serif","digimail-smtp")},{key:"rounded",label:(0,i.__)("Friendly","digimail-smtp")}],te=["#1b2550","#0f766e","#2563eb","#7c3aed","#db2777","#dc2626","#ea580c","#111827"];function ae({t:e,color:t}){return(0,l.createElement)("svg",{viewBox:"0 0 120 84",width:"100%","aria-hidden":"true"},(0,l.createElement)("rect",{width:"120",height:"84",rx:"6",fill:"minimal"===e?"#ffffff":"#eef0f3"}),"modern"===e&&(0,l.createElement)("rect",{x:"16",y:"8",width:"26",height:"5",rx:"2",fill:"#9aa1ad"}),(0,l.createElement)("rect",{x:"14",y:"modern"===e?18:10,width:"92",height:"modern"===e?60:68,rx:"5",fill:"#ffffff",stroke:"minimal"===e?"#e3e5e9":"none"}),"modern"===e&&(0,l.createElement)("rect",{x:"14",y:"18",width:"92",height:"3",rx:"1.5",fill:t}),"bold"===e&&(0,l.createElement)("path",{d:"M14 15a5 5 0 0 1 5-5h82a5 5 0 0 1 5 5v19H14z",fill:t}),"minimal"===e&&(0,l.createElement)("rect",{x:"48",y:"17",width:"24",height:"5",rx:"2",fill:"#9aa1ad"}),(0,l.createElement)("rect",{x:"minimal"===e?34:22,y:"bold"===e?22:28,width:"52",height:"6",rx:"2",fill:"bold"===e?"#ffffff":"#2b3040"}),[0,1,2].map(a=>(0,l.createElement)("rect",{key:a,x:22+26*a,y:"bold"===e?41:39,width:"23",height:"3",rx:"1.5",fill:a<2?t:"#dfe2e7"})),(0,l.createElement)("rect",{x:"22",y:"50",width:"76",height:"3",rx:"1.5",fill:"#e3e5e9"}),(0,l.createElement)("rect",{x:"22",y:"57",width:"64",height:"3",rx:"1.5",fill:"#e3e5e9"}),(0,l.createElement)("rect",{x:"22",y:"66",width:"28",height:"7",rx:"2.5",fill:t}))}function le({value:e,onChange:t}){return(0,l.createElement)("div",{className:"dms-logo-pick"},(0,l.createElement)("div",{className:"dms-logo-box"},e?(0,l.createElement)("img",{src:e,alt:""}):(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.__)("No logo: the shop name is shown","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>{const e=window.wp?.media;if(!e)return;const a=e({title:(0,i.__)("Choose a logo","digimail-smtp"),library:{type:"image"},multiple:!1,button:{text:(0,i.__)("Use this image","digimail-smtp")}});a.on("select",()=>{const e=a.state().get("selection").first().toJSON();t(e.sizes?.medium?.url??e.url)}),a.open()}},e?(0,i.__)("Change logo","digimail-smtp"):(0,i.__)("Choose a logo","digimail-smtp")),e&&(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>t("")},(0,i.__)("Remove","digimail-smtp"))))}function ie({label:e,value:t,onChange:a,swatches:i}){return(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},e),(0,l.createElement)("div",{className:"dms-color"},(0,l.createElement)("input",{type:"color",value:t,onChange:e=>a(e.target.value),"aria-label":e}),(0,l.createElement)("input",{type:"text",value:t,maxLength:7,onChange:e=>a(e.target.value),"aria-label":e}),i&&i.map(e=>(0,l.createElement)("button",{key:e,type:"button",className:"dms-swatch "+(e===t?"is-on":""),style:{background:e},"aria-label":e,onClick:()=>a(e)}))))}function se(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[o,d]=(0,l.useState)(""),[p,u]=(0,l.useState)(""),[g,_]=(0,l.useState)("desktop"),[k,N]=(0,l.useState)(!1),[S,x]=(0,l.useState)(""),[M,T]=(0,l.useState)(""),[D,F]=(0,l.useState)(""),[z,P]=(0,l.useState)(!1),[$,O]=(0,l.useState)(null),[A,I]=(0,l.useState)(""),L=(0,l.useRef)(0);(0,l.useEffect)(()=>{c("design").then(e=>{a(e),n(e.settings),r(JSON.stringify(e.settings)),u(e.types.find(e=>"WC_Email_Customer_Processing_Order"===e.id)?.id??e.types[0]?.id??"")}).catch(e=>d(e.message)),c("state").then(e=>I(e.site.admin_email)).catch(()=>{})},[]);const W=(0,l.useCallback)(async(e,t,a)=>{const l=++L.current;P(!0);try{const i=await c("design/preview",{type:t,settings:{...e,enabled:!a}});l===L.current&&(x(i.html),T(i.subject),F(""))}catch(e){l===L.current&&F(e.message)}finally{l===L.current&&P(!1)}},[]);if((0,l.useEffect)(()=>{if(!s||!p)return;const e=window.setTimeout(()=>W(s,p,k),350);return()=>window.clearTimeout(e)},[s,p,k,W]),o)return(0,l.createElement)(v,{tone:"bad"},o);if(!t||!s)return(0,l.createElement)("div",{className:"dms-skel",style:{height:520}});const j=(e,t)=>n({...s,[e]:t}),R=JSON.stringify(s)!==m,q=Array.from(new Set([...t.detected.palette??[],...te])).slice(0,8),B=async(t=s)=>{O("save");try{const a=await c("design/save",{settings:t});n(a.settings),r(JSON.stringify(a.settings)),e(a.settings.enabled?(0,i.__)("Saved. New emails use this design.","digimail-smtp"):(0,i.__)("Saved. The design is off.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{O(null)}},U=(e,t,a)=>(0,l.createElement)(y,{label:t,htmlFor:`dms-so-${e}`},(0,l.createElement)("input",{id:`dms-so-${e}`,type:"text",inputMode:"url",placeholder:a,value:s.socials[e],onChange:t=>j("socials",{...s.socials,[e]:t.target.value})}));return(0,l.createElement)("div",{className:"dms-design"},(0,l.createElement)("div",{className:"dms-design-side"},(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-design-on"},(0,l.createElement)(b,{checked:s.enabled,onChange:e=>B({...s,enabled:e}),disabled:"save"===$,label:(0,i.__)("Use this design for emails","digimail-smtp"),hint:s.enabled?(0,i.__)("On: new emails go out in this design.","digimail-smtp"):(0,i.__)("Off: emails look as they do now. Design and preview freely, nothing changes until you turn it on.","digimail-smtp")})),t.conflicts.length>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s also changes how emails look","digimail-smtp"),t.conflicts.join(", "))},(0,i.__)("Use one email designer at a time: deactivate the other plugin, or leave this design off.","digimail-smtp")),!t.woocommerce&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("WooCommerce is not active, so only the other WordPress emails can use the design.","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Template","digimail-smtp")},(0,l.createElement)("div",{className:"dms-templates"},X.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-tpl "+(s.template===e.key?"is-on":""),onClick:()=>j("template",e.key),"aria-pressed":s.template===e.key},(0,l.createElement)(ae,{t:e.key,color:s.color}),(0,l.createElement)("strong",null,e.label),(0,l.createElement)("span",null,e.hint))))),(0,l.createElement)(E,{title:(0,i.__)("Brand","digimail-smtp"),aside:(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>{const a=t.detected;n({...s,logo:a.logo??s.logo,color:a.color??s.color,company:a.company??s.company,email:a.email??s.email,address:a.address??s.address}),e((0,i.__)("Filled in from the website. Check the preview, then save.","digimail-smtp"))}},(0,l.createElement)(w,{name:"zap",size:14})," ",(0,i.__)("Fill in from the website","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Logo","digimail-smtp")),(0,l.createElement)(le,{value:s.logo,onChange:e=>j("logo",e)}),s.logo&&(0,l.createElement)("label",{className:"dms-range"},(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Width","digimail-smtp")),(0,l.createElement)("input",{type:"range",min:60,max:260,step:5,value:s.logo_width,onChange:e=>j("logo_width",Number(e.target.value))}),(0,l.createElement)("span",{className:"dms-small"},s.logo_width,"px"))),(0,l.createElement)(ie,{label:(0,i.__)("Brand colour","digimail-smtp"),value:s.color,onChange:e=>j("color",e),swatches:q}),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(ie,{label:(0,i.__)("Background","digimail-smtp"),value:s.bg,onChange:e=>j("bg",e)}),(0,l.createElement)(ie,{label:(0,i.__)("Text","digimail-smtp"),value:s.text,onChange:e=>j("text",e)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Font","digimail-smtp"),htmlFor:"dms-font"},(0,l.createElement)("select",{id:"dms-font",value:s.font,onChange:e=>j("font",e.target.value)},ee.map(e=>(0,l.createElement)("option",{key:e.key,value:e.key},e.label)))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Corners","digimail-smtp")),(0,l.createElement)("label",{className:"dms-range"},(0,l.createElement)("input",{type:"range",min:0,max:24,value:s.radius,onChange:e=>j("radius",Number(e.target.value)),"aria-label":(0,i.__)("Corners","digimail-smtp")}),(0,l.createElement)("span",{className:"dms-small"},s.radius,"px")))))),(0,l.createElement)(E,{title:(0,i.__)("Order emails","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.tracker,onChange:e=>j("tracker",e),label:(0,i.__)("Progress bar","digimail-smtp"),hint:(0,i.__)("Order placed → Processing → Completed, in the customer’s order emails.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.cta,onChange:e=>j("cta",e),label:(0,i.__)("Button under the order","digimail-smtp"),hint:(0,i.__)("View your order, Pay for this order, or Open the order in emails to the shop.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.images,onChange:e=>j("images",e),label:(0,i.__)("Product pictures","digimail-smtp")}))),(0,l.createElement)(E,{title:(0,i.__)("Footer","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Company or shop name","digimail-smtp"),htmlFor:"dms-company"},(0,l.createElement)("input",{id:"dms-company",type:"text",value:s.company,onChange:e=>j("company",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Address","digimail-smtp"),htmlFor:"dms-address"},(0,l.createElement)("input",{id:"dms-address",type:"text",value:s.address,onChange:e=>j("address",e.target.value)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Phone","digimail-smtp"),htmlFor:"dms-phone"},(0,l.createElement)("input",{id:"dms-phone",type:"text",inputMode:"tel",value:s.phone,onChange:e=>j("phone",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Email","digimail-smtp"),htmlFor:"dms-email"},(0,l.createElement)("input",{id:"dms-email",type:"email",value:s.email,onChange:e=>j("email",e.target.value)}))),(0,l.createElement)("div",{className:"dms-grid-2"},U("facebook","Facebook","https://facebook.com/…"),U("zalo","Zalo","https://zalo.me/…"),U("tiktok","TikTok","https://tiktok.com/@…"),U("instagram","Instagram","https://instagram.com/…")),U("youtube","YouTube","https://youtube.com/@…"),(0,l.createElement)(y,{label:(0,i.__)("Note at the bottom","digimail-smtp"),hint:(0,i.__)("For example your return policy or opening hours.","digimail-smtp"),htmlFor:"dms-note"},(0,l.createElement)("textarea",{id:"dms-note",rows:2,value:s.note,onChange:e=>j("note",e.target.value)})))),(0,l.createElement)(E,{title:(0,i.__)("Which emails","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.woo,onChange:e=>j("woo",e),disabled:!t.woocommerce,label:(0,i.__)("WooCommerce emails","digimail-smtp"),hint:(0,i.__)("Orders, invoices, accounts and refunds.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.wp,onChange:e=>j("wp",e),label:(0,i.__)("Other plain-text WordPress emails","digimail-smtp"),hint:(0,i.__)("Password resets, new users, form notifications that have no design of their own. Emails other plugins already design are left alone.","digimail-smtp")})))),(0,l.createElement)("div",{className:"dms-design-main"},(0,l.createElement)("div",{className:"dms-preview-bar"},(0,l.createElement)("select",{value:p,onChange:e=>u(e.target.value),"aria-label":(0,i.__)("Email to preview","digimail-smtp")},t.types.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},e.title))),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"desktop"===g?"is-on":"",onClick:()=>_("desktop")},(0,i.__)("Computer","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"mobile"===g?"is-on":"",onClick:()=>_("mobile")},(0,i.__)("Phone","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:k?"":"is-on",onClick:()=>N(!1)},(0,i.__)("New design","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:k?"is-on":"",onClick:()=>N(!0)},(0,i.__)("As it is now","digimail-smtp"))),z&&(0,l.createElement)("span",{className:"dms-spin","aria-label":(0,i.__)("Loading","digimail-smtp")})),(0,l.createElement)("div",{className:`dms-inbox is-${g}`},(0,l.createElement)("div",{className:"dms-inbox-head"},(0,l.createElement)("span",{className:"dms-avatar",style:{background:s.color}},(s.company||"S").trim().charAt(0).toUpperCase()),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,s.company||(0,i.__)("Your shop","digimail-smtp")),(0,l.createElement)("span",null,M))),D?(0,l.createElement)("div",{className:"dms-preview-err"},(0,l.createElement)(v,{tone:"bad"},D)):(0,l.createElement)("iframe",{title:(0,i.__)("Email preview","digimail-smtp"),sandbox:"allow-popups",srcDoc:S})),(0,l.createElement)("div",{className:"dms-design-actions"},(0,l.createElement)("form",{className:"dms-row",onSubmit:t=>{t.preventDefault(),(async()=>{O("test");try{await c("design/test",{type:p,to:A,settings:{...s,enabled:!0}}),e((0,i.__)("Test email sent. Check the inbox.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{O(null)}})()}},(0,l.createElement)("input",{type:"email",required:!0,value:A,onChange:e=>I(e.target.value),"aria-label":(0,i.__)("Send to","digimail-smtp")}),(0,l.createElement)(f,{type:"submit",variant:"secondary",busy:"test"===$},(0,l.createElement)(w,{name:"send",size:14})," ",(0,i.__)("Send a test","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-row"},R&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Not saved","digimail-smtp")),(0,l.createElement)(f,{busy:"save"===$,disabled:!R,onClick:()=>B()},(0,i.__)("Save design","digimail-smtp"))))))}const ne=e=>`${Math.round(e).toLocaleString("vi-VN")}₫`,me={welcome:(0,i.__)("Welcome new subscribers","digimail-smtp"),order_followup:(0,i.__)("Thank-you after purchase","digimail-smtp"),abandoned_cart:(0,i.__)("Abandoned cart reminder","digimail-smtp"),review_request:(0,i.__)("Review request","digimail-smtp")};function re(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(null),[o,u]=(0,l.useState)(""),g=e=>{a(e),n({...e.settings})};if((0,l.useEffect)(()=>{c("shop").then(g).catch(e=>u(e.message))},[]),o&&!t)return(0,l.createElement)(v,{tone:"bad"},o);if(!t||!s)return(0,l.createElement)("div",{className:"dms-skel",style:{height:360}});if(!t.woocommerce)return(0,l.createElement)(v,{tone:"info",title:(0,i.__)("WooCommerce is not active","digimail-smtp")},(0,i.__)("Turn on WooCommerce to use the shop emails.","digimail-smtp"));const _=async t=>{r("save");try{g(await c("shop/save",t)),e(t.enabled?(0,i.__)("Shop settings saved.","digimail-smtp"):(0,i.__)("Shop emails are off.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{r(null)}},k=e=>n({...s,...e}),N=JSON.stringify(s)!==JSON.stringify(t.settings),S=t.summary?.automations.filter(e=>"welcome"!==e.kind)??[],x=t.summary?.manage_url??`${t.app}/app/tu-dong`;return t.settings.enabled?(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Shop emails","digimail-smtp"),aside:(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:x,target:"_blank",rel:"noreferrer"},(0,i.__)("Edit on digimail.vn","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:14}))},t.error&&(0,l.createElement)("p",{className:"dms-error"},t.error),t.summary&&(0,l.createElement)("div",{className:"dms-kpis dms-kpis-2"},(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Revenue from email, 30 days","digimail-smtp")),(0,l.createElement)("strong",null,ne(t.summary.email_revenue_30d))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Orders from email, 30 days","digimail-smtp")),(0,l.createElement)("strong",null,d(t.summary.email_orders_30d)),(0,l.createElement)("em",null,(0,i.__)("Clicked an email in the 7 days before paying","digimail-smtp")))),t.summary&&0===S.length&&(0,l.createElement)("div",{className:"dms-empty-inline"},(0,l.createElement)("p",null,(0,i.__)("No email series yet. Pick one on digimail.vn: the text is ready, you only turn it on.","digimail-smtp")),(0,l.createElement)("a",{className:"dms-btn dms-btn-primary",href:x,target:"_blank",rel:"noreferrer"},(0,i.__)("Set up shop emails","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:14}))),S.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Email series","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Sent","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Orders","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Revenue","digimail-smtp")))),(0,l.createElement)("tbody",null,S.map(e=>(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)("a",{href:e.url,target:"_blank",rel:"noreferrer"},e.name),(0,l.createElement)("div",{className:"dms-small dms-muted"},me[e.kind]??"")),(0,l.createElement)("td",null,"active"===e.status?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Running","digimail-smtp")):"paused"===e.status?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Paused","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Draft","digimail-smtp"))),(0,l.createElement)("td",{className:"num"},d(e.sent)),(0,l.createElement)("td",{className:"num"},d(e.orders)),(0,l.createElement)("td",{className:"num"},e.orders?ne(e.revenue):"–"))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("span",{className:"dms-small dms-muted"},t.last?.error?(0,i.sprintf)(/* translators: %s: error message. */ /* translators: %s: error message. */(0,i.__)("Last sync failed: %s","digimail-smtp"),t.last.error):t.last?(0,i.sprintf)(/* translators: %s: time. */ /* translators: %s: time. */(0,i.__)("Orders and carts last sent %s.","digimail-smtp"),p(new Date(1e3*t.last.at).toISOString())):(0,i.__)("Orders show up on digimail.vn a few seconds after they are placed.","digimail-smtp"),t.pending>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of items waiting. */ /* translators: %s: number of items waiting. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),d(t.pending)))),t.pending>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"===m,onClick:async()=>{r("sync");try{g(await c("shop/sync",{}))}catch(t){e(t.message,"bad")}finally{r(null)}}},(0,i.__)("Send now","digimail-smtp"))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Checkout","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.optin,onChange:e=>k({optin:e}),label:(0,i.__)("Show an “email me news” checkbox","digimail-smtp"),hint:(0,i.__)("Unticked by default. Shoppers who tick it join your contact list, and shop emails go to them.","digimail-smtp")}),s.optin&&(0,l.createElement)(y,{label:(0,i.__)("Checkbox text","digimail-smtp"),htmlFor:"dms-optin-label"},(0,l.createElement)("input",{id:"dms-optin-label",type:"text",maxLength:200,value:s.optin_label,onChange:e=>k({optin_label:e.target.value}),placeholder:t.default_label})),(0,l.createElement)(b,{checked:s.carts,onChange:e=>k({carts:e}),label:(0,i.__)("Save carts for the reminder email","digimail-smtp"),hint:(0,i.__)("When a shopper types their email at checkout, the cart is kept for 30 days. A short note under the email field tells them.","digimail-smtp")}),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>_({...s,enabled:!1})},(0,i.__)("Turn off shop emails","digimail-smtp")),(0,l.createElement)(f,{disabled:!N,busy:"save"===m,onClick:()=>_(s)},(0,i.__)("Save","digimail-smtp"))),!t.blocks&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Your WooCommerce shows the checkbox on the classic checkout only. Update WooCommerce to show it on the block checkout too.","digimail-smtp")))))):(0,l.createElement)("div",{className:"dms-shop-intro"},(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-shop-hero"},(0,l.createElement)("div",{className:"dms-shop-icon"},(0,l.createElement)(w,{name:"cart",size:22})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Emails that sell for your shop","digimail-smtp")),(0,l.createElement)("p",null,(0,i.__)("DigiMail sends these by itself, from your own domain, with the products of each order:","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-checks"},(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A thank-you after payment, and a check-in 7 days later.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A reminder when a shopper leaves checkout, with a button that brings their cart back.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A review request a few days after the order is completed.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("An unticked “Email me news and offers” checkbox at checkout, so you only email people who agreed.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A report of the revenue that came from your emails.","digimail-smtp"))),(0,l.createElement)(f,{busy:"save"===m,onClick:()=>_({...s,enabled:!0})},(0,i.__)("Turn on shop emails","digimail-smtp")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("This sends each order and saved cart (email, name, products, total) to your DigiMail account. Nothing is emailed until you turn on an email series on digimail.vn.","digimail-smtp"))))))}const ce=[{key:"popup",label:(0,i.__)("Popup","digimail-smtp"),hint:(0,i.__)("In the middle of the screen, after a few seconds, a scroll or when the visitor is about to leave.","digimail-smtp")},{key:"slide",label:(0,i.__)("Slide-in","digimail-smtp"),hint:(0,i.__)("A small box in the corner. Noticed without getting in the way.","digimail-smtp")},{key:"bar",label:(0,i.__)("Bar","digimail-smtp"),hint:(0,i.__)("A thin strip across the top or bottom of every page.","digimail-smtp")},{key:"inline",label:(0,i.__)("In the page","digimail-smtp"),hint:(0,i.__)("Inside a page or after each blog post, with a shortcode.","digimail-smtp")}],oe=[{key:"card",label:(0,i.__)("Card","digimail-smtp")},{key:"split",label:(0,i.__)("With picture","digimail-smtp")},{key:"minimal",label:(0,i.__)("Simple","digimail-smtp")},{key:"bold",label:(0,i.__)("Colour block","digimail-smtp")}],de=e=>ce.find(t=>t.key===e)?.label??e;function pe({type:e,color:t}){return(0,l.createElement)("svg",{viewBox:"0 0 120 76",width:"100%","aria-hidden":"true"},(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"74",rx:"6",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"10",y:"12",width:"56",height:"5",rx:"2.5",fill:"#e6e8ed"}),(0,l.createElement)("rect",{x:"10",y:"22",width:"90",height:"4",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"10",y:"30",width:"80",height:"4",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"10",y:"38",width:"86",height:"4",rx:"2",fill:"#eef0f3"}),"popup"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"74",rx:"6",fill:"#14182b",opacity:".35"}),(0,l.createElement)("rect",{x:"30",y:"16",width:"60",height:"44",rx:"5",fill:"#fff"}),(0,l.createElement)("rect",{x:"38",y:"24",width:"36",height:"4",rx:"2",fill:"#14182b"}),(0,l.createElement)("rect",{x:"38",y:"36",width:"44",height:"7",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"38",y:"46",width:"44",height:"7",rx:"2",fill:t})),"slide"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"70",y:"40",width:"44",height:"31",rx:"4",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"76",y:"46",width:"24",height:"3",rx:"1.5",fill:"#14182b"}),(0,l.createElement)("rect",{x:"76",y:"54",width:"32",height:"5",rx:"1.5",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"76",y:"61",width:"32",height:"5",rx:"1.5",fill:t})),"bar"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"9",fill:t}),(0,l.createElement)("rect",{x:"30",y:"4",width:"34",height:"3",rx:"1.5",fill:"#fff",opacity:".9"}),(0,l.createElement)("rect",{x:"68",y:"3.5",width:"20",height:"4",rx:"1",fill:"#fff"})),"inline"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"10",y:"48",width:"100",height:"20",rx:"4",fill:"#f6f7f9",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"16",y:"54",width:"54",height:"8",rx:"2",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"74",y:"54",width:"30",height:"8",rx:"2",fill:t})))}function ue({value:e,onChange:t}){return(0,l.createElement)("div",{className:"dms-row"},e&&(0,l.createElement)("img",{src:e,alt:"",className:"dms-form-thumb"}),(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>{const e=window.wp?.media;if(!e)return;const a=e({title:(0,i.__)("Choose a picture","digimail-smtp"),library:{type:"image"},multiple:!1,button:{text:(0,i.__)("Use this image","digimail-smtp")}});a.on("select",()=>{const e=a.state().get("selection").first().toJSON();t(e.sizes?.large?.url??e.url)}),a.open()}},e?(0,i.__)("Change picture","digimail-smtp"):(0,i.__)("Choose a picture","digimail-smtp")),e&&(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>t("")},(0,i.__)("Remove","digimail-smtp")))}function ge({id:e}){const t=C(),a=`[digimail_form id="${e}"]`;return(0,l.createElement)("button",{type:"button",className:"dms-code-btn",onClick:()=>navigator.clipboard?.writeText(a).then(()=>t((0,i.__)("Shortcode copied.","digimail-smtp"))),title:(0,i.__)("Copy","digimail-smtp")},(0,l.createElement)("code",null,a)," ",(0,l.createElement)(w,{name:"copy",size:14}))}function _e(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(null),[o,p]=(0,l.useState)("");if((0,l.useEffect)(()=>{c("forms").then(a).catch(e=>n(e.message))},[]),s&&!t)return(0,l.createElement)(v,{tone:"bad"},s);if(!t)return(0,l.createElement)("div",{className:"dms-skel",style:{height:360}});const u=async(t,l=!1)=>{p("save");try{const s=await c("forms/save",t);return a(s),s.form&&r(s.form),l||e("on"===t.status?(0,i.__)("Saved. The form is live on your site.","digimail-smtp"):(0,i.__)("Saved. The form is off.","digimail-smtp")),s.form??null}catch(t){return e(t.message,"bad"),null}finally{p("")}};if(m)return(0,l.createElement)(he,{form:m,screen:t,busy:"save"===o,onSave:u,onBack:()=>r(null),onDelete:async t=>{if(window.confirm((0,i.sprintf)(/* translators: %s: form name. */ /* translators: %s: form name. */(0,i.__)("Delete “%s”? Its numbers are deleted too. People who signed up stay in your DigiMail list.","digimail-smtp"),t.name)))try{a(await c("forms/delete",{id:t.id})),r(null)}catch(t){e(t.message,"bad")}}});const g=(0,l.createElement)("div",{className:"dms-form-types"},ce.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-form-type",onClick:()=>{return a=e.key,r({...t.defaults[a],id:"",created:0});var a}},(0,l.createElement)(pe,{type:e.key,color:t.defaults.popup.color}),(0,l.createElement)("strong",null,e.label),(0,l.createElement)("span",null,e.hint))));return 0===t.forms.length?(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-forms-intro"},(0,l.createElement)("h2",null,(0,i.__)("Grow your email list from your website","digimail-smtp")),(0,l.createElement)("p",null,(0,i.__)("Visitors who sign up go straight into your DigiMail contact list, ready for campaigns and the welcome email series. The spam guard keeps bots out. Pick a kind of form to start:","digimail-smtp")),g)):(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Signup forms","digimail-smtp")},(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Views","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Signups","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Rate","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,t.forms.map(e=>(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)("button",{type:"button",className:"dms-link-btn",onClick:()=>r(e)},e.name),(0,l.createElement)("div",{className:"dms-small dms-muted"},de(e.type)),"inline"===e.type&&"shortcode"===e.placement&&(0,l.createElement)(ge,{id:e.id})),(0,l.createElement)("td",null,(0,l.createElement)("label",{className:"dms-switch-inline"},(0,l.createElement)("input",{type:"checkbox",checked:"on"===e.status,onChange:t=>u({...e,status:t.target.checked?"on":"off"})}),"on"===e.status?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp")))),(0,l.createElement)("td",{className:"num"},d(e.views??0)),(0,l.createElement)("td",{className:"num"},d(e.signups??0)),(0,l.createElement)("td",{className:"num"},e.views?`${((e.signups??0)/e.views*100).toFixed(1)}%`:"–"),(0,l.createElement)("td",{className:"num"},(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>r(e)},(0,i.__)("Edit","digimail-smtp"))," ",(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>r({...e,id:"",name:(0,i.sprintf)(/* translators: %s: form name. */ /* translators: %s: form name. */(0,i.__)("%s (copy)","digimail-smtp"),e.name),status:"off",created:0}),"aria-label":(0,i.__)("Duplicate","digimail-smtp")},(0,l.createElement)(w,{name:"copy",size:15})))))))),(0,l.createElement)(E,{title:(0,i.__)("New form","digimail-smtp")},g))}function he({form:e,screen:t,busy:a,onSave:s,onBack:n,onDelete:m}){const[r,o]=(0,l.useState)(e),[p,u]=(0,l.useState)("desktop"),[g,_]=(0,l.useState)(""),[k,N]=(0,l.useState)(!1),S=(0,l.useRef)(void 0),C=(0,l.useRef)(JSON.stringify(e)),x=JSON.stringify(r)!==C.current,M=(e,t)=>o(a=>({...a,[e]:t}));(0,l.useEffect)(()=>(window.clearTimeout(S.current),S.current=window.setTimeout(()=>{N(!0),c("forms/preview",{form:r,device:p}).then(e=>_(e.html)).catch(()=>{}).then(()=>N(!1))},350),()=>window.clearTimeout(S.current)),[r,p]);const T=async e=>{const t=e?{...r,status:e}:r,a=await s(t);a&&(C.current=JSON.stringify(a),o(a))},D="inline"!==r.type;return(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-form-top"},(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:n},(0,l.createElement)(w,{name:"back",size:15})," ",(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("input",{className:"dms-form-name",value:r.name,onChange:e=>M("name",e.target.value),"aria-label":(0,i.__)("Form name (only you see it)","digimail-smtp"),maxLength:80}),(0,l.createElement)(h,null,de(r.type)),(0,l.createElement)("span",{className:"dms-grow"}),x&&(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Unsaved changes","digimail-smtp")),r.id&&(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>m(r),"aria-label":(0,i.__)("Delete form","digimail-smtp")},(0,l.createElement)(w,{name:"trash",size:15})),"on"===r.status?(0,l.createElement)(l.Fragment,null,(0,l.createElement)(f,{variant:"secondary",busy:a,onClick:()=>T("off")},(0,i.__)("Turn off","digimail-smtp")),(0,l.createElement)(f,{busy:a,disabled:!x,onClick:()=>T()},(0,i.__)("Save","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)(f,{variant:"secondary",busy:a,onClick:()=>T("off"),disabled:!x&&!!r.id},(0,i.__)("Save as draft","digimail-smtp")),(0,l.createElement)(f,{busy:a,onClick:()=>T("on")},(0,i.__)("Save and turn on","digimail-smtp")))),!t.guard&&(0,l.createElement)(v,{tone:"wait"},(0,i.__)("The spam guard is off, so bots can sign up through this form. Turn it on in Settings.","digimail-smtp")),(0,l.createElement)("div",{className:"dms-design"},(0,l.createElement)("div",{className:"dms-design-side"},(0,l.createElement)(E,{title:(0,i.__)("Design","digimail-smtp")},(0,l.createElement)("div",{className:"dms-templates dms-templates-4"},oe.filter(e=>!("bar"===r.type&&"split"===e.key)).map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-tpl "+(r.template===e.key?"is-on":""),onClick:()=>M("template",e.key),"aria-pressed":r.template===e.key},(0,l.createElement)("span",{className:`dms-tpl-art dms-tpl-${e.key}`,style:{"--c":r.color}},(0,l.createElement)("i",null),(0,l.createElement)("b",null),(0,l.createElement)("em",null)),(0,l.createElement)("strong",null,e.label)))),(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(ie,{label:(0,i.__)("Colour","digimail-smtp"),value:r.color,onChange:e=>M("color",e),swatches:["#1b2550","#0f766e","#c2410c","#be123c","#7c3aed","#111827"]}),"split"===r.template&&(0,l.createElement)(y,{label:(0,i.__)("Picture","digimail-smtp")},(0,l.createElement)(ue,{value:r.image,onChange:e=>M("image",e)})))),(0,l.createElement)(E,{title:(0,i.__)("Form text","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Title","digimail-smtp"),htmlFor:"dmf-title"},(0,l.createElement)("input",{id:"dmf-title",value:r.title,maxLength:120,onChange:e=>M("title",e.target.value)})),"bar"!==r.type&&(0,l.createElement)(y,{label:(0,i.__)("Description","digimail-smtp"),htmlFor:"dmf-text"},(0,l.createElement)("textarea",{id:"dmf-text",rows:3,value:r.text,maxLength:400,onChange:e=>M("text",e.target.value)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Button","digimail-smtp"),htmlFor:"dmf-btn"},(0,l.createElement)("input",{id:"dmf-btn",value:r.button,maxLength:40,onChange:e=>M("button",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Email box hint","digimail-smtp"),htmlFor:"dmf-ph"},(0,l.createElement)("input",{id:"dmf-ph",value:r.email_ph,maxLength:60,onChange:e=>M("email_ph",e.target.value)}))),"bar"!==r.type&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(b,{checked:r.ask_name,onChange:e=>M("ask_name",e),label:(0,i.__)("Ask for a name","digimail-smtp"),hint:(0,i.__)("Lets your emails greet people by name. Each extra field means a few fewer signups.","digimail-smtp")}),(0,l.createElement)(b,{checked:r.ask_phone,onChange:e=>M("ask_phone",e),label:(0,i.__)("Ask for a phone number (optional for the visitor)","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Small print under the button","digimail-smtp"),htmlFor:"dmf-consent"},(0,l.createElement)("input",{id:"dmf-consent",value:r.consent,maxLength:240,onChange:e=>M("consent",e.target.value)}))))),(0,l.createElement)(E,{title:D?(0,i.__)("When and where it shows","digimail-smtp"):(0,i.__)("Where it goes","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},D&&"bar"!==r.type&&(0,l.createElement)(y,{label:(0,i.__)("Show it","digimail-smtp"),htmlFor:"dmf-trigger"},(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("select",{id:"dmf-trigger",value:r.trigger,onChange:e=>M("trigger",e.target.value)},(0,l.createElement)("option",{value:"delay"},(0,i.__)("After some seconds","digimail-smtp")),(0,l.createElement)("option",{value:"scroll"},(0,i.__)("After scrolling part of the page","digimail-smtp")),(0,l.createElement)("option",{value:"exit"},(0,i.__)("When the visitor is about to leave","digimail-smtp"))),"delay"===r.trigger&&(0,l.createElement)("label",{className:"dms-inline-num"},(0,l.createElement)("input",{type:"number",min:0,max:300,value:r.delay,onChange:e=>M("delay",Number(e.target.value))})," ",(0,i.__)("seconds","digimail-smtp")),"scroll"===r.trigger&&(0,l.createElement)("label",{className:"dms-inline-num"},(0,l.createElement)("input",{type:"number",min:5,max:100,value:r.scroll,onChange:e=>M("scroll",Number(e.target.value))})," %")),"exit"===r.trigger&&(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("On phones, which have no mouse, it shows after 20 seconds instead.","digimail-smtp"))),"slide"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Corner","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"left"===r.position?"is-on":"",onClick:()=>M("position","left")},(0,i.__)("Bottom left","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"left"!==r.position?"is-on":"",onClick:()=>M("position","right")},(0,i.__)("Bottom right","digimail-smtp")))),"bar"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Position","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"bottom"!==r.position?"is-on":"",onClick:()=>M("position","top")},(0,i.__)("Top of the page","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"bottom"===r.position?"is-on":"",onClick:()=>M("position","bottom")},(0,i.__)("Bottom of the screen","digimail-smtp")))),"inline"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Place","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"shortcode"===r.placement?"is-on":"",onClick:()=>M("placement","shortcode")},(0,i.__)("Where I paste the shortcode","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"after_post"===r.placement?"is-on":"",onClick:()=>M("placement","after_post")},(0,i.__)("After every blog post","digimail-smtp"))),"shortcode"===r.placement&&(r.id?(0,l.createElement)(ge,{id:r.id}):(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Save the form to get its shortcode.","digimail-smtp")))),(D||"after_post"===r.placement)&&(0,l.createElement)("div",{className:"dms-grid-2"},D&&(0,l.createElement)(y,{label:(0,i.__)("Pages","digimail-smtp"),htmlFor:"dmf-pages"},(0,l.createElement)("select",{id:"dmf-pages",value:r.pages,onChange:e=>M("pages",e.target.value)},(0,l.createElement)("option",{value:"all"},(0,i.__)("Every page","digimail-smtp")),(0,l.createElement)("option",{value:"home"},(0,i.__)("Home page only","digimail-smtp")),(0,l.createElement)("option",{value:"posts"},(0,i.__)("Blog posts","digimail-smtp")),(0,l.createElement)("option",{value:"pages"},(0,i.__)("Pages","digimail-smtp")),(0,l.createElement)("option",{value:"shop"},(0,i.__)("Shop and product pages","digimail-smtp")))),(0,l.createElement)(y,{label:(0,i.__)("Devices","digimail-smtp"),htmlFor:"dmf-dev"},(0,l.createElement)("select",{id:"dmf-dev",value:r.devices,onChange:e=>M("devices",e.target.value)},(0,l.createElement)("option",{value:"all"},(0,i.__)("Computers and phones","digimail-smtp")),(0,l.createElement)("option",{value:"desktop"},(0,i.__)("Computers only","digimail-smtp")),(0,l.createElement)("option",{value:"mobile"},(0,i.__)("Phones only","digimail-smtp"))))),D&&(0,l.createElement)(y,{label:(0,i.__)("After someone closes it","digimail-smtp"),htmlFor:"dmf-again"},(0,l.createElement)("label",{className:"dms-inline-num"},(0,i.__)("Show again after","digimail-smtp")," ",(0,l.createElement)("input",{id:"dmf-again",type:"number",min:0,max:365,value:r.again,onChange:e=>M("again",Number(e.target.value))})," ",(0,i.__)("days","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("People who sign up never see it again. Checkout, cart and account pages never show forms.","digimail-smtp"))),(0,l.createElement)(b,{checked:r.logged,onChange:e=>M("logged",e),label:(0,i.__)("Also show to logged-in users","digimail-smtp")}))),(0,l.createElement)(E,{title:(0,i.__)("After signing up","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Add to the DigiMail list","digimail-smtp"),htmlFor:"dmf-list"},(0,l.createElement)("select",{id:"dmf-list",value:r.list_id,onChange:e=>M("list_id",e.target.value)},(0,l.createElement)("option",{value:""},t.site_list?(0,i.sprintf)(/* translators: %s: list name. */ /* translators: %s: list name. */(0,i.__)("This website’s list (%s)","digimail-smtp"),t.site_list):(0,i.__)("This website’s list","digimail-smtp")),t.lists.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},e.name," (",d(e.subscribed),")")))),(0,l.createElement)(b,{checked:r.confirm,onChange:e=>M("confirm",e),label:(0,i.__)("Ask people to confirm by email (double opt-in)","digimail-smtp"),hint:(0,i.__)("They join the list only after clicking the link in a confirmation email. Fewer signups, but every address is real and wanted.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Message after signing up","digimail-smtp"),htmlFor:"dmf-ok"},(0,l.createElement)("input",{id:"dmf-ok",value:r.confirm?r.pending:r.success,maxLength:200,onChange:e=>M(r.confirm?"pending":"success",e.target.value)})),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("To send a welcome email, turn on the “Welcome new subscribers” series for this list on digimail.vn (Automation).","digimail-smtp"))))),(0,l.createElement)("div",{className:"dms-design-main"},(0,l.createElement)("div",{className:"dms-preview-bar"},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"desktop"===p?"is-on":"",onClick:()=>u("desktop")},(0,i.__)("Computer","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"mobile"===p?"is-on":"",onClick:()=>u("mobile")},(0,i.__)("Phone","digimail-smtp"))),k&&(0,l.createElement)("span",{className:"dms-spin","aria-label":(0,i.__)("Loading","digimail-smtp")}),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Preview: try the form, nothing is sent.","digimail-smtp"))),(0,l.createElement)("div",{className:`dms-form-stage is-${p}`},(0,l.createElement)("iframe",{title:(0,i.__)("Form preview","digimail-smtp"),srcDoc:g,sandbox:"allow-scripts"})))))}const Ee=[{key:"overview",label:(0,i.__)("Overview","digimail-smtp"),icon:"chart"},{key:"logs",label:(0,i.__)("Email log","digimail-smtp"),icon:"list"},{key:"contacts",label:(0,i.__)("Customers","digimail-smtp"),icon:"users"},{key:"forms",label:(0,i.__)("Signup forms","digimail-smtp"),icon:"form"},{key:"test",label:(0,i.__)("Test email","digimail-smtp"),icon:"send"},{key:"design",label:(0,i.__)("Email design","digimail-smtp"),icon:"palette"},{key:"shop",label:(0,i.__)("Shop","digimail-smtp"),icon:"cart"},{key:"settings",label:(0,i.__)("Settings","digimail-smtp"),icon:"settings"},{key:"tools",label:(0,i.__)("Tools","digimail-smtp"),icon:"tools"}],fe=()=>{const e=window.location.hash.replace("#","");return Ee.some(t=>t.key===e)?e:"overview"},be=document.getElementById("digimail-smtp-app");if(be){const e=(0,l.createElement)(function({children:e}){const[t,a]=(0,l.useState)([]),i=(0,l.useCallback)((e,t="ok")=>{const l=Date.now()+Math.random();a(a=>[...a,{id:l,msg:e,tone:t}]),setTimeout(()=>a(e=>e.filter(e=>e.id!==l)),4500)},[]);return(0,l.createElement)(S.Provider,{value:i},e,(0,l.createElement)("div",{className:"dms-toasts",role:"status","aria-live":"polite"},t.map(e=>(0,l.createElement)("div",{key:e.id,className:`dms-toast dms-toast-${e.tone}`},(0,l.createElement)(w,{name:"ok"===e.tone?"check":"alert",size:16}),e.msg))))},null,(0,l.createElement)(function(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(fe),[o,d]=(0,l.useState)(!1),p=(0,l.useCallback)(async(e=!1)=>{try{a(await c("state"+(e?"?refresh=1":""))),n("")}catch(e){n(e.message)}},[]);(0,l.useEffect)(()=>{p();const t=window.digimailSmtp?.flash;t&&e(t.message,t.ok?"ok":"bad")},[p,e]),(0,l.useEffect)(()=>{const e=()=>r(fe());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);const u=e=>{window.location.hash=e,r(e),window.scrollTo({top:0})};if(s&&!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("DigiMail SMTP could not load","digimail-smtp")},s));if(!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("div",{className:"dms-skel",style:{height:420}}));if(!t.connected)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(M,{state:t,reload:async()=>{await p(!0),d(!0),u("overview")}}));const g=t.status.sender;return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("header",{className:"dms-top"},(0,l.createElement)("div",{className:"dms-brand"},(0,l.createElement)("img",{src:window.digimailSmtp?.logo,alt:"",width:30,height:30}),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,"DigiMail SMTP"),(0,l.createElement)("span",null,t.revoked?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Disconnected","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i._x)("Active","connection status","digimail-smtp"))))),(0,l.createElement)("nav",{className:"dms-tabs","aria-label":"DigiMail SMTP"},Ee.filter(e=>"shop"!==e.key||t.capture.woocommerce).map(e=>(0,l.createElement)("a",{key:e.key,href:`#${e.key}`,className:m===e.key?"is-on":"","aria-current":m===e.key?"page":void 0,onClick:t=>{t.preventDefault(),u(e.key)}},(0,l.createElement)(w,{name:e.icon,size:16}),e.label,"logs"===e.key&&t.queue.failed>0&&(0,l.createElement)("span",{className:"dms-count"},t.queue.failed))))),t.revoked&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("This website was disconnected on digimail.vn","digimail-smtp"),action:(0,l.createElement)(f,{onClick:async()=>{await c("disconnect",{}),p(!0)}},(0,i.__)("Reconnect","digimail-smtp"))},t.settings.backup.enabled?(0,i.__)("Email is not going through DigiMail. The backup server is sending it.","digimail-smtp"):(0,i.__)("Email is not going through DigiMail.","digimail-smtp")),o&&g&&(0,l.createElement)("div",{className:"dms-welcome"},(0,l.createElement)("div",{className:"dms-welcome-icon"},(0,l.createElement)(w,{name:"check",size:28})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Done! This website can send email now.","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender email address. */ /* translators: %s: sender email address. */(0,i.__)("Email will be sent from <strong>%s</strong>. Send a test email to make sure everything works.","digimail-smtp"),g.email),{strong:(0,l.createElement)("strong",null)}))),(0,l.createElement)(f,{onClick:()=>{d(!1),u("test")}},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send a test email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Close","digimail-smtp"),onClick:()=>d(!1)},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("main",null,"overview"===m&&(0,l.createElement)(z,{state:t,go:u}),"logs"===m&&(0,l.createElement)(L,{reload:()=>p()}),"contacts"===m&&(0,l.createElement)(B,{state:t,go:u}),"test"===m&&(0,l.createElement)(U,{state:t,go:u}),"design"===m&&(0,l.createElement)(se,null),"shop"===m&&(0,l.createElement)(re,null),"forms"===m&&(0,l.createElement)(_e,null),"settings"===m&&(0,l.createElement)(Q,{state:t,setState:a}),"tools"===m&&(0,l.createElement)(Z,{state:t,setState:a})),(0,l.createElement)("footer",{className:"dms-foot"},"DigiMail SMTP ",t.env.plugin," · ",(0,l.createElement)("a",{href:t.env.app,target:"_blank",rel:"noreferrer"},"digimail.vn")))},null));"function"==typeof l.createRoot?(0,l.createRoot)(be).render(e):(0,l.render)(e,be)}}};const t={};function a(l){const i=t[l];if(void 0!==i)return i.exports;const s=t[l]={exports:{}};return e[l](s,s.exports,a),s.exports}a.m=e,(()=>{const e=[];a.O=(t,l,i)=>{if(!l){for(var s=0;s<e.length;s++){let[l,i]=e[s],m=!0;for(var n=0;n<l.length;n++)a.O.j(l[n])?l.splice(n--,1):m=!1;if(m){e.splice(s--,1);const a=i();void 0!==a&&(t=a)}}return t}e.push([l,i])}})(),a.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.hasOwn(e,t),(()=>{const e={57:0,350:0};a.O.j=t=>0===e[t];const t=(t,l)=>{let[i,s,n]=l;var m,r,c=0;if(i.some(t=>0!==e[t])){for(m in s)a.o(s,m)&&(a.m[m]=s[m]);if(n)var o=n(a)}for(t&&t(l);c<i.length;c++)r=i[c],a.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return a.O(o)},l=Array.isArray(globalThis.webpackChunkdigimail_smtp)?globalThis.webpackChunkdigimail_smtp:globalThis.webpackChunkdigimail_smtp=[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();let l=a.O(void 0,[350],()=>a(897));l=a.O(l)})();22 (0,i.__)("%1$s contacts added so far, last sync %2$s.","digimail-smtp"),d(_.total??0),p(new Date(1e3*_.at).toISOString())):(0,i.__)("No contacts yet. They show up a few seconds after someone submits a form.","digimail-smtp"),k>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of items waiting. */ /* translators: %s: number of items waiting. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),d(k)))),k>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"===g,onClick:async()=>{u("sync");try{const e=await o("contacts/sync",{});w(e.pending),v(e.last),e.last?.error?s(e.last.error,"bad"):s((0,i.__)("Contacts sent to DigiMail.","digimail-smtp"))}catch(e){s(e.message,"bad")}finally{u(null)}}},(0,i.__)("Send now","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send marketing email only to people who agreed to receive it. Add an “I agree to receive news” checkbox to your forms.","digimail-smtp")))))}const G={ok:{label:(0,i.__)("Correct","digimail-smtp"),tone:"ok"},missing:{label:(0,i.__)("Not added yet","digimail-smtp"),tone:"wait"},wrong:{label:(0,i.__)("Wrong value","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Could not check","digimail-smtp"),tone:"muted"}};function H({text:e,label:t}){const a=C();return(0,l.createElement)("button",{type:"button",className:"dms-copy",title:(0,i.__)("Copy","digimail-smtp"),"aria-label":(0,i.sprintf)(/* translators: %s: what is copied. */ /* translators: %s: what is copied. */(0,i.__)("Copy %s","digimail-smtp"),t),onClick:async()=>a(await async function(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const a=document.execCommand("copy");return t.remove(),a}}(e)?(0,i.__)("Copied.","digimail-smtp"):(0,i.__)("Could not copy. Select the text and copy it by hand.","digimail-smtp"))},(0,l.createElement)("code",null,e),(0,l.createElement)(w,{name:"copy",size:14}))}function J({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[c,p]=(0,l.useState)(""),[g,u]=(0,l.useState)(""),[_,b]=(0,l.useState)(""),k=(0,l.useCallback)(()=>o("domain").then(e=>(n(e),r(""),e)).catch(e=>(r(e.message),null)),[]);(0,l.useEffect)(()=>{k()},[k]);const N="pending"===s?.state;(0,l.useEffect)(()=>{if(!N)return;let e=0;const t=setInterval(()=>{e++,e>20||document.hidden?e>20&&clearInterval(t):k()},3e4);return()=>clearInterval(t)},[N,k]);const S="verified"===s?.state;(0,l.useEffect)(()=>{S&&"shared"===e.status.sender?.mode&&o("state?refresh=1").then(t).catch(()=>{})},[S,e.status.sender?.mode,t]);const x=async(e,t,l={})=>{p(e);try{const e=await o(t,l);return n(e),e}catch(e){return a(e.message,"bad"),null}finally{p("")}},M=async()=>{const e=await x("cf","domain/cloudflare",{token:g});e?.applied&&(u(""),a(e.applied.problems>0?(0,i.sprintf)(/* translators: %s: number of records. */ /* translators: %s: number of records. */(0,i.__)("Added what could be added. %s records need a look: see the list.","digimail-smtp"),d(e.applied.problems)):(0,i.__)("Records added in Cloudflare. Verification usually finishes within a few minutes.","digimail-smtp")))},T=s?"verified"===s.state?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Verified","digimail-smtp")):"pending"===s.state?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS","digimail-smtp")):"failed"===s.state?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Not verified","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Shared address","digimail-smtp")):null,D=s?.dns?.zone??s?.zone??null,F="cloudflare"===D?.provider.key||(s?.dns?.cloudflare.can_apply??s?.can_apply??!1),z=s?.dns?.cloudflare.can_apply??s?.can_apply??!1,P=s?.dns?.cloudflare.token_url??s?.token_url??"",$=s&&D&&D.apex!==s.domain&&s.domain.endsWith(`.${D.apex}`)?[s.domain,D.apex]:null;return(0,l.createElement)(E,{title:(0,l.createElement)("span",{id:"dms-domain"},(0,i.__)("Sending domain","digimail-smtp")),aside:T},m&&(0,l.createElement)("p",{className:"dms-error"},m),!s&&!m&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),s&&!s.eligible&&(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("This website runs on an IP address or localhost, so it has no domain to verify. It keeps sending from the shared address.","digimail-smtp")),s?.eligible&&"taken"===s.state&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is already in another DigiMail account","digimail-smtp"),s.domain)},(0,i.__)("Log in to that account on digimail.vn, or contact DigiMail if you own this domain.","digimail-smtp")),s?.eligible&&"none"===s.state&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared address, 2: example address on the site's domain. */ /* translators: 1: shared address, 2: example address on the site's domain. */ 23 (0,i.__)("The website sends from <code>%1$s</code>. Verify your domain to send from an address like <code>%2$s</code>: Gmail and Outlook trust it more, emails land in the inbox more often, and the shared address’s daily limit no longer applies.","digimail-smtp"),s.sender?.email??"",`noreply@${_||s.domain}`),{code:(0,l.createElement)("code",null)})),$&&(0,l.createElement)(y,{label:(0,i.__)("Domain to verify","digimail-smtp"),htmlFor:"dms-domain-pick",hint:(0,i.__)("Verifying the main domain covers every subdomain of it.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-domain-pick",value:_||$[0],onChange:e=>b(e.target.value)},$.map(e=>(0,l.createElement)("option",{key:e,value:e},e)))),D&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: DNS provider. */ /* translators: 1: domain, 2: DNS provider. */(0,i.__)("DNS of <strong>%1$s</strong> is managed at <strong>%2$s</strong>.","digimail-smtp"),D.apex,D.provider.name),{strong:(0,l.createElement)("strong",null)}),F&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("You can add the records with one click through Cloudflare.","digimail-smtp"))),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"add"===c,onClick:()=>x("add","domain/add",_?{domain:_}:{})},(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),_||s.domain)))),s?.eligible&&"verified"===s.state&&(0,l.createElement)(v,{tone:"ok",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is verified","digimail-smtp"),s.dns?.domain??s.domain)},"domain"===s.sender?.mode?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender address. */ /* translators: %s: sender address. */(0,i.__)("The website sends from <code>%s</code>.","digimail-smtp"),s.sender.email),{code:(0,l.createElement)("code",null)}):(0,i.__)("The website switches to your domain within a minute.","digimail-smtp")),s?.eligible&&("pending"===s.state||"failed"===s.state)&&s.dns&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: correct records, 2: required records. */ /* translators: 1: correct records, 2: required records. */ 24 (0,i.__)("%1$s of %2$s required DNS records are correct.","digimail-smtp"),d(s.dns.summary.ok_required),d(s.dns.summary.required))," ",s.dns.summary.dns_ready?(0,i.__)("DNS is ready: DigiMail confirms the domain within a few minutes, then the website switches to it by itself.","digimail-smtp"):(0,i.__)("Add the records below where your domain’s DNS is managed. Changes usually show within minutes, sometimes a few hours.","digimail-smtp")),F&&!s.dns.summary.dns_ready&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Add them automatically through Cloudflare","digimail-smtp")),z?(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"cf"===c,onClick:M},(0,i.__)("Add records in Cloudflare","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.__)("<a>Create a Cloudflare API token</a> (the link fills in the right permissions: Zone Read, DNS Edit), then paste it here. DigiMail stores it encrypted and only uses it to add these records.","digimail-smtp"),{a:(0,l.createElement)("a",{href:P,target:"_blank",rel:"noreferrer"})})),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("input",{type:"password",autoComplete:"off",value:g,onChange:e=>u(e.target.value),placeholder:(0,i.__)("Cloudflare API token","digimail-smtp"),"aria-label":(0,i.__)("Cloudflare API token","digimail-smtp")}),(0,l.createElement)(f,{busy:"cf"===c,disabled:g.trim().length<20,onClick:M},(0,i.__)("Connect and add records","digimail-smtp"))))),D&&!F&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: DNS provider, 2: how to add records there. */ /* translators: 1: DNS provider, 2: how to add records there. */(0,i.__)("DNS is at <strong>%1$s</strong>. %2$s","digimail-smtp"),D.provider.name,D.provider.guide),{strong:(0,l.createElement)("strong",null)}),D.provider.url&&(0,l.createElement)(l.Fragment,null," ",(0,l.createElement)("a",{href:D.provider.url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:12})))),s.applied&&s.applied.problems>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.__)("Some records were left alone in Cloudflare","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-reasons"},s.applied.outcomes.filter(e=>"conflict"===e.action||"failed"===e.action).map(e=>(0,l.createElement)("li",{key:e.name+e.type},e.type," ",e.name,": ",e.message)))),(0,l.createElement)("div",{className:"dms-table-wrap"},(0,l.createElement)("table",{className:"dms-table dms-dns"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Type","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Name (host)","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Value","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")))),(0,l.createElement)("tbody",null,s.dns.records.map(e=>(0,l.createElement)("tr",{key:e.type+e.name+e.value},(0,l.createElement)("td",null,(0,l.createElement)("strong",null,e.type),!e.required&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("recommended","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.host||"@",label:(0,i.__)("name","digimail-smtp")})),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.value,label:(0,i.__)("value","digimail-smtp")}),null!==e.priority&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: MX priority. */ /* translators: %s: MX priority. */(0,i.__)("Priority: %s","digimail-smtp"),e.priority)),"CNAME"===e.type&&F&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("Proxy off (DNS only)","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:G[e.state].tone},G[e.state].label),"ok"!==e.state&&e.note&&(0,l.createElement)("div",{className:"dms-small dms-muted"},e.note))))))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{busy:"check"===c,onClick:()=>x("check","domain/check")},(0,l.createElement)(w,{name:"refresh",size:15})," ",(0,i.__)("Check again","digimail-smtp")),(0,l.createElement)(f,{variant:"secondary",busy:"zone"===c,onClick:async()=>{p("zone");try{const e=await o("domain/zonefile"),t=URL.createObjectURL(new Blob([e.text],{type:"text/plain;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download=`digimail-${s?.dns?.domain??"dns"}.txt`,a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{p("")}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Download zone file","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("When the domain is verified, DigiMail tells you by Telegram or email (see Alerts).","digimail-smtp"))))}const Y={bad:"bad",warn:"wait",good:"ok"};function K(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[c,g]=(0,l.useState)(null),u=(0,l.useRef)(null),_=(0,l.useCallback)(()=>o("alerts").then(e=>(a(e),n(""),e)).catch(e=>(n(e.message),null)),[]);(0,l.useEffect)(()=>(_(),()=>{u.current&&clearInterval(u.current)}),[_]);const y=async t=>{r("prefs");try{a(await o("alerts/prefs",t))}catch(t){e(t.message,"bad")}finally{r("")}},v=t?.telegram.chats??[],k=!!t&&(t.prefs.telegram&&v.length>0||t.prefs.email&&t.emails.length>0);return(0,l.createElement)(E,{title:(0,i.__)("Alerts","digimail-smtp"),aside:t?k?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp")):null},s&&(0,l.createElement)("p",{className:"dms-error"},s),!t&&!s&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),t&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("DigiMail tells you when emails fail, the quota is nearly used up, bounces or spam reports rise, the plugin stops reporting, forms are hit by bots, or something changes with your domain. The same problem is repeated at most once a day.","digimail-smtp")),(0,l.createElement)(b,{checked:t.prefs.telegram,disabled:"prefs"===m||!t.telegram.available,onChange:e=>y({...t.prefs,telegram:e}),label:(0,i.__)("Telegram","digimail-smtp"),hint:t.telegram.available?v.length?(0,i.sprintf)(/* translators: %s: number of chats. */ /* translators: %s: number of chats. */(0,i._n)("Sent to %s connected chat.","Sent to %s connected chats.",v.length,"digimail-smtp"),d(v.length)):(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Connect your Telegram (or a group) to the %s bot.","digimail-smtp"),t.telegram.bot??""):(0,i.__)("Telegram alerts are not available yet.","digimail-smtp")}),t.telegram.available&&(0,l.createElement)("div",{className:"dms-chats"},v.map(t=>(0,l.createElement)("div",{key:t.id,className:"dms-chat"},(0,l.createElement)(w,{name:"private"===t.kind?"send":"users",size:15}),(0,l.createElement)("span",{className:"dms-grow"},t.title,"private"!==t.kind&&(0,l.createElement)("span",{className:"dms-muted dms-small"}," · ",(0,i.__)("group","digimail-smtp"))),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:m===t.id,onClick:()=>(async t=>{r(t.id);try{a(await o("alerts/telegram/remove",{id:t.id}))}catch(t){e(t.message,"bad")}finally{r("")}})(t)},(0,i.__)("Remove","digimail-smtp")))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",busy:"link"===m,onClick:async()=>{r("link");try{const a=await o("alerts/telegram",{});g(a),window.open(a.start_url,"_blank","noopener");const l=t?.telegram.chats.length??0;let s=0;u.current&&clearInterval(u.current),u.current=setInterval(async()=>{s++;const t=await _();(t&&t.telegram.chats.length>l||s>40)&&(u.current&&clearInterval(u.current),t&&t.telegram.chats.length>l&&(g(null),e((0,i.__)("Telegram connected.","digimail-smtp"))))},3e3)}catch(t){e(t.message,"bad")}finally{r("")}}},v.length?(0,i.__)("Connect another Telegram","digimail-smtp"):(0,i.__)("Connect Telegram","digimail-smtp"))),c&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Finish in Telegram","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Telegram opens a chat with %s: press Start. This page updates by itself once it is connected.","digimail-smtp"),c.bot)),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:c.start_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open Telegram","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13})),(0,l.createElement)("a",{className:"dms-btn dms-btn-ghost dms-btn-sm",href:c.group_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Add to a group instead","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("The link works once and expires in 30 minutes.","digimail-smtp")))),(0,l.createElement)(b,{checked:t.prefs.email,disabled:"prefs"===m,onChange:e=>y({...t.prefs,email:e}),label:(0,i.__)("Email","digimail-smtp"),hint:(0,i.sprintf)(/* translators: %s: email addresses. */ /* translators: %s: email addresses. */(0,i.__)("To %s (the users of your DigiMail account).","digimail-smtp"),t.emails.join(", "))}),void 0!==t.prefs.weekly&&(0,l.createElement)(b,{checked:t.prefs.weekly,disabled:"prefs"===m,onChange:e=>y({...t.prefs,weekly:e}),label:(0,i.__)("Weekly summary by email","digimail-smtp"),hint:(0,i.__)("Every Monday morning: emails sent last week, delivery rate, spam blocked on each website and the month’s quota. Nothing is sent after a quiet week.","digimail-smtp")}),(0,l.createElement)("div",null,(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:"test"===m,disabled:!k,onClick:async()=>{r("test");try{const t=await o("alerts/test",{});e(t.telegram+t.email>0?(0,i.sprintf)(/* translators: 1: Telegram chats, 2: email addresses. */ /* translators: 1: Telegram chats, 2: email addresses. */(0,i.__)("Test alert sent: %1$s Telegram, %2$s email.","digimail-smtp"),d(t.telegram),d(t.email)):(0,i.__)("Nothing was sent: turn on email or connect Telegram first.","digimail-smtp"),t.telegram+t.email>0?"ok":"bad"),_()}catch(t){e(t.message,"bad")}finally{r("")}}},(0,l.createElement)(w,{name:"bell",size:14})," ",(0,i.__)("Send a test alert","digimail-smtp"))),t.recent.length>0&&(0,l.createElement)("div",{className:"dms-recent"},(0,l.createElement)("strong",{className:"dms-small"},(0,i.__)("Recent alerts","digimail-smtp")),(0,l.createElement)("ul",null,t.recent.slice(0,5).map(e=>(0,l.createElement)("li",{key:e.created_at+e.kind,title:e.body},(0,l.createElement)(h,{tone:Y[e.level]},p(e.created_at))," ",e.title))))))}function Q({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(e.settings),[m,r]=(0,l.useState)(null),c=e.status.sender,d=c?.verified_domains??[],[p,g]=(0,l.useState)("domain"===c?.mode?c.email:""),[u,_]=(0,l.useState)(e.site.user_email),k=JSON.stringify(s)!==JSON.stringify(e.settings),N=async(e,l=(0,i.__)("Settings saved.","digimail-smtp"))=>{r("save");try{const i=await o("settings",e??s);return t(i),n(i.settings),a(l),!0}catch(e){return a(e.message,"bad"),!1}finally{r(null)}},S=Object.entries(e.controls).reduce((e,[t,a])=>((e[a.group]=e[a.group]??[]).push([t,a]),e),{}),x=s.backup,M=e=>n({...s,backup:{...x,...e}});return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Sender","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Sender name","digimail-smtp"),htmlFor:"dms-name",hint:(0,i.__)("Leave empty to use the website name. Recipients see this name in their inbox.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-name",value:s.from_name,placeholder:c?.name??e.site.name,onChange:e=>n({...s,from_name:e.target.value})})),(0,l.createElement)(b,{checked:s.force_from_name,onChange:e=>n({...s,force_from_name:e}),label:(0,i.__)("Always use this name","digimail-smtp"),hint:(0,i.__)("Even when another plugin (WooCommerce, a contact form) sets its own sender name.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Sender email","digimail-smtp"),htmlFor:"dms-from",hint:d.length?(0,i.__)("Only addresses on domains verified in DigiMail can be used.","digimail-smtp"):(0,i.__)("Verify your domain on digimail.vn to send from your company email.","digimail-smtp")},d.length?(0,l.createElement)("select",{id:"dms-from",value:p,onChange:e=>g(e.target.value)},(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: email address chosen automatically. */ /* translators: %s: email address chosen automatically. */ 25 (0,i.__)("Automatic (%s)","digimail-smtp"),"domain"===c?.mode?c.email:`noreply@${d[0]}`)),d.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).map(e=>(0,l.createElement)("option",{key:e,value:e},e)),p&&!d.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).includes(p)&&(0,l.createElement)("option",{value:p},p)):(0,l.createElement)("div",{className:"dms-readonly"},c?.email," ",(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")))),"shared"===c?.mode&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: reply-to email address. */ /* translators: %s: reply-to email address. */(0,i.__)("Replies go to <strong>%s</strong>.","digimail-smtp"),c.reply_to??e.site.admin_email),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"sender"===m,onClick:async()=>{r("sender");try{const e=await o("sender",{from_email:p,from_name:s.from_name});t(e),await N({from_name:s.from_name,force_from_name:s.force_from_name},(0,i.__)("Sender saved.","digimail-smtp"))}catch(e){a(e.message,"bad")}finally{r(null)}}},(0,i.__)("Save sender","digimail-smtp"))))),(0,l.createElement)(J,{state:e,setState:t}),(0,l.createElement)(K,null),(0,l.createElement)(E,{title:(0,i.__)("Sending email","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.queue,onChange:e=>n({...s,queue:e}),label:(0,i.__)("Background sending","digimail-smtp"),hint:(0,i.__)("Checkout and contact forms do not wait for email: messages are queued and sent right after. Recommended for online shops.","digimail-smtp")}),s.queue&&!e.env.cron&&(0,l.createElement)(v,{tone:"wait"},(0,l.createInterpolateElement)((0,i.__)("WP-Cron is off (DISABLE_WP_CRON). A server cron job must call wp-cron.php every minute, or run <code>wp digimail queue</code>.","digimail-smtp"),{code:(0,l.createElement)("code",null)})))),(0,l.createElement)(L,{state:e,s,setS:n}),(0,l.createElement)(U,{state:e,s,setS:n}),(0,l.createElement)(E,{title:(0,i.__)("Backup connection","digimail-smtp"),aside:x.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("When DigiMail cannot send (network down, quota used up), the plugin sends through this SMTP server so no email is lost. Your hosting SMTP, Gmail or Microsoft 365 all work.","digimail-smtp")),(0,l.createElement)(b,{checked:x.enabled,onChange:e=>M({enabled:e}),label:(0,i.__)("Turn on backup connection","digimail-smtp")}),x.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("SMTP server","digimail-smtp"),htmlFor:"dms-bh"},(0,l.createElement)("input",{id:"dms-bh",value:x.host,onChange:e=>M({host:e.target.value}),placeholder:"smtp.gmail.com"})),(0,l.createElement)(y,{label:(0,i.__)("Port","digimail-smtp"),htmlFor:"dms-bp"},(0,l.createElement)("input",{id:"dms-bp",type:"number",value:x.port,onChange:e=>M({port:Number(e.target.value)})}))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Encryption","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},[["tls","TLS (587)"],["ssl","SSL (465)"],["none",(0,i.__)("None","digimail-smtp")]].map(([e,t])=>(0,l.createElement)("button",{key:e,type:"button",className:x.encryption===e?"is-on":"",onClick:()=>M({encryption:e,port:"ssl"===e?465:"tls"===e?587:25})},t)))),(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("Username","digimail-smtp"),htmlFor:"dms-bu"},(0,l.createElement)("input",{id:"dms-bu",value:x.username,autoComplete:"off",onChange:e=>M({username:e.target.value})})),(0,l.createElement)(y,{label:(0,i.__)("Password","digimail-smtp"),htmlFor:"dms-bpw",hint:(0,i.__)("Encrypted when saved.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bpw",type:"password",autoComplete:"new-password",value:x.password,onChange:e=>M({password:e.target.value})}))),(0,l.createElement)(y,{label:(0,i.__)("From email on this server","digimail-smtp"),htmlFor:"dms-bf",hint:(0,i.__)("Leave empty to use the SMTP username.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bf",type:"email",value:x.from_email,onChange:e=>M({from_email:e.target.value})})),(0,l.createElement)("div",{className:"dms-inline"},(0,l.createElement)("input",{type:"email","aria-label":(0,i.__)("Send a test email to","digimail-smtp"),value:u,onChange:e=>_(e.target.value)}),(0,l.createElement)(f,{variant:"secondary",busy:"backup"===m,onClick:async()=>{if(!k||await N()){r("backup");try{await o("backup/test",{to:u}),a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("The backup server sent an email to %s.","digimail-smtp"),u))}catch(e){a(e.message,"bad")}finally{r(null)}}}},(0,i.__)("Save and send test","digimail-smtp")))))),(0,l.createElement)(E,{title:(0,i.__)("Turn off WordPress default emails","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Fewer unneeded emails for administrators. Order emails, contact forms and password resets are not affected.","digimail-smtp")),Object.entries(S).map(([e,t])=>(0,l.createElement)("div",{key:e,className:"dms-group"},(0,l.createElement)("h3",null,e),t.map(([e,t])=>(0,l.createElement)(b,{key:e,checked:!1!==s.controls[e],onChange:t=>{const a={...s.controls};t?delete a[e]:a[e]=!1,n({...s,controls:a})},label:t.label,hint:t.hint||void 0})))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-sticky"},(0,l.createElement)(E,{title:(0,i.__)("Save changes","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},k?(0,i.__)("You have unsaved changes.","digimail-smtp"):(0,i.__)("All changes are saved.","digimail-smtp")),(0,l.createElement)(f,{size:"block",busy:"save"===m,disabled:!k,onClick:()=>N()},(0,i.__)("Save settings","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Connection","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,e.status.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,e.status.account?.name),(0,l.createElement)("dt",null,(0,i.__)("Key","digimail-smtp")),(0,l.createElement)("dd",null,e.token_constant?(0,i.__)("Set in wp-config.php","digimail-smtp"):(0,i.__)("Stored in the database","digimail-smtp"))),(0,l.createElement)(b,{checked:s.keep_data,onChange:e=>n({...s,keep_data:e}),label:(0,i.__)("Keep settings when the plugin is deleted","digimail-smtp")}),(0,l.createElement)(b,{checked:!!s.diagnostics,onChange:e=>n({...s,diagnostics:e}),label:(0,i.__)("Share diagnostics with DigiMail support","digimail-smtp"),hint:(0,i.__)("Off by default. When on, the WordPress, PHP and WooCommerce versions, language, a few of this plugin's settings and the names of other active email plugins are sent with the twice-daily status check, so support can see problems on digimail.vn.","digimail-smtp")}),!e.token_constant&&(0,l.createElement)(f,{variant:"danger",size:"block",busy:"disconnect"===m,onClick:async()=>{window.confirm((0,i.__)("Disconnect DigiMail? The website will go back to sending email through your hosting server (or the backup server, if set).","digimail-smtp"))&&(r("disconnect"),await o("disconnect",{}),window.location.reload())}},(0,l.createElement)(w,{name:"x",size:15})," ",(0,i.__)("Disconnect DigiMail","digimail-smtp"))))))}function Z({state:e,setState:t}){const a=C(),[s,n]=(0,l.useState)(null),m=e.conflicts.map(e=>e.name),r=[`DigiMail SMTP ${e.env.plugin}`,`WordPress ${e.env.wordpress}, PHP ${e.env.php}`,`Website: ${e.site.url}`,`Connected: ${e.connected?"yes":"no"}${e.revoked?" (revoked)":""}`,`From: ${e.status.sender?.email??"-"} (${e.status.sender?.mode??"-"})`,`Background sending: ${e.settings.queue?"on":"off"}, WP-Cron: ${e.env.cron?"on":"off"}`,`Backup: ${e.settings.backup.enabled?e.settings.backup.host:"off"}`,`Queue: ${e.queue.queued} waiting, ${e.queue.failed} failed`,`Other SMTP plugins: ${m.join(", ")||"none"}`].join("\n");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Switch from another SMTP plugin","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Imports the sender name and the emails you turned off. The old SMTP server becomes the backup connection: DigiMail sends, and the old server is used only when DigiMail cannot.","digimail-smtp")),0===e.importable.length?(0,l.createElement)(k,{title:(0,i.__)("No settings found to import","digimail-smtp")},(0,i.__)("Supports WP Mail SMTP, Easy WP SMTP, Post SMTP, FluentSMTP and SMTP Mailer.","digimail-smtp")):(0,l.createElement)("ul",{className:"dms-list"},e.importable.map(e=>(0,l.createElement)("li",{key:e.key},(0,l.createElement)("span",null,(0,l.createElement)("strong",null,e.name),m.includes(e.name)&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Active","digimail-smtp")),(0,l.createElement)("small",null,e.smtp?(0,i.__)("Has an SMTP server to use as backup","digimail-smtp"):(0,i.__)("Sender name only","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:s===e.key,onClick:()=>(async(e,l)=>{n(e);try{const s=await o("import",{from:e});t(s),a(s.settings.backup.host?(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s. The old SMTP server is now the backup connection.","digimail-smtp"),l):(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s.","digimail-smtp"),l))}catch(e){a(e.message,"bad")}finally{n(null)}})(e.key,e.name)},(0,i.__)("Import","digimail-smtp"))))),m.length>0&&(0,l.createElement)("p",{className:"dms-small"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("After importing, deactivate %s on the <a>Plugins page</a> so the two plugins do not both try to send email.","digimail-smtp"),m.join(", ")),{a:(0,l.createElement)("a",{href:"plugins.php"})}))),(0,l.createElement)(E,{title:(0,i.__)("Command line (WP-CLI)","digimail-smtp")},(0,l.createElement)("pre",{className:"dms-pre"},[`wp digimail status # ${(0,i.__)("connection, sender, quota","digimail-smtp")}`,`wp digimail test you@company.com # ${(0,i.__)("send a test email","digimail-smtp")}`,`wp digimail queue --retry-failed # ${(0,i.__)("resend waiting and failed emails","digimail-smtp")}`,"wp digimail connect you@company.com","wp digimail disconnect"].join("\n")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Agencies can set the key in wp-config.php:","digimail-smtp")," ",(0,l.createElement)("code",null,"define( 'DIGIMAIL_SMTP_TOKEN', 'dm_…' );")))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Support information","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard?.writeText(r),a((0,i.__)("Copied.","digimail-smtp"))}},(0,l.createElement)(w,{name:"download",size:14})," ",(0,i.__)("Copy","digimail-smtp"))},(0,l.createElement)("pre",{className:"dms-pre"},r),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send this when you contact DigiMail support. It contains no secret keys.","digimail-smtp")))))}const X=[{key:"modern",label:(0,i.__)("Modern","digimail-smtp"),hint:(0,i.__)("White card with a line in your colour","digimail-smtp")},{key:"minimal",label:(0,i.__)("Minimal","digimail-smtp"),hint:(0,i.__)("All white, logo in the middle","digimail-smtp")},{key:"bold",label:(0,i.__)("Bold","digimail-smtp"),hint:(0,i.__)("Your colour across the top","digimail-smtp")}],ee=[{key:"sans",label:(0,i.__)("Modern sans-serif","digimail-smtp")},{key:"serif",label:(0,i.__)("Classic serif","digimail-smtp")},{key:"rounded",label:(0,i.__)("Friendly","digimail-smtp")}],te=["#1b2550","#0f766e","#2563eb","#7c3aed","#db2777","#dc2626","#ea580c","#111827"];function ae({t:e,color:t}){return(0,l.createElement)("svg",{viewBox:"0 0 120 84",width:"100%","aria-hidden":"true"},(0,l.createElement)("rect",{width:"120",height:"84",rx:"6",fill:"minimal"===e?"#ffffff":"#eef0f3"}),"modern"===e&&(0,l.createElement)("rect",{x:"16",y:"8",width:"26",height:"5",rx:"2",fill:"#9aa1ad"}),(0,l.createElement)("rect",{x:"14",y:"modern"===e?18:10,width:"92",height:"modern"===e?60:68,rx:"5",fill:"#ffffff",stroke:"minimal"===e?"#e3e5e9":"none"}),"modern"===e&&(0,l.createElement)("rect",{x:"14",y:"18",width:"92",height:"3",rx:"1.5",fill:t}),"bold"===e&&(0,l.createElement)("path",{d:"M14 15a5 5 0 0 1 5-5h82a5 5 0 0 1 5 5v19H14z",fill:t}),"minimal"===e&&(0,l.createElement)("rect",{x:"48",y:"17",width:"24",height:"5",rx:"2",fill:"#9aa1ad"}),(0,l.createElement)("rect",{x:"minimal"===e?34:22,y:"bold"===e?22:28,width:"52",height:"6",rx:"2",fill:"bold"===e?"#ffffff":"#2b3040"}),[0,1,2].map(a=>(0,l.createElement)("rect",{key:a,x:22+26*a,y:"bold"===e?41:39,width:"23",height:"3",rx:"1.5",fill:a<2?t:"#dfe2e7"})),(0,l.createElement)("rect",{x:"22",y:"50",width:"76",height:"3",rx:"1.5",fill:"#e3e5e9"}),(0,l.createElement)("rect",{x:"22",y:"57",width:"64",height:"3",rx:"1.5",fill:"#e3e5e9"}),(0,l.createElement)("rect",{x:"22",y:"66",width:"28",height:"7",rx:"2.5",fill:t}))}function le({value:e,onChange:t}){return(0,l.createElement)("div",{className:"dms-logo-pick"},(0,l.createElement)("div",{className:"dms-logo-box"},e?(0,l.createElement)("img",{src:e,alt:""}):(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.__)("No logo: the shop name is shown","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>{const e=window.wp?.media;if(!e)return;const a=e({title:(0,i.__)("Choose a logo","digimail-smtp"),library:{type:"image"},multiple:!1,button:{text:(0,i.__)("Use this image","digimail-smtp")}});a.on("select",()=>{const e=a.state().get("selection").first().toJSON();t(e.sizes?.medium?.url??e.url)}),a.open()}},e?(0,i.__)("Change logo","digimail-smtp"):(0,i.__)("Choose a logo","digimail-smtp")),e&&(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>t("")},(0,i.__)("Remove","digimail-smtp"))))}function ie({label:e,value:t,onChange:a,swatches:i}){return(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},e),(0,l.createElement)("div",{className:"dms-color"},(0,l.createElement)("input",{type:"color",value:t,onChange:e=>a(e.target.value),"aria-label":e}),(0,l.createElement)("input",{type:"text",value:t,maxLength:7,onChange:e=>a(e.target.value),"aria-label":e}),i&&i.map(e=>(0,l.createElement)("button",{key:e,type:"button",className:"dms-swatch "+(e===t?"is-on":""),style:{background:e},"aria-label":e,onClick:()=>a(e)}))))}function se(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[c,d]=(0,l.useState)(""),[p,g]=(0,l.useState)(""),[u,_]=(0,l.useState)("desktop"),[k,N]=(0,l.useState)(!1),[S,x]=(0,l.useState)(""),[M,T]=(0,l.useState)(""),[D,F]=(0,l.useState)(""),[z,P]=(0,l.useState)(!1),[$,O]=(0,l.useState)(null),[A,W]=(0,l.useState)(""),I=(0,l.useRef)(0);(0,l.useEffect)(()=>{o("design").then(e=>{a(e),n(e.settings),r(JSON.stringify(e.settings)),g(e.types.find(e=>"WC_Email_Customer_Processing_Order"===e.id)?.id??e.types[0]?.id??"")}).catch(e=>d(e.message)),o("state").then(e=>W(e.site.admin_email)).catch(()=>{})},[]);const L=(0,l.useCallback)(async(e,t,a)=>{const l=++I.current;P(!0);try{const i=await o("design/preview",{type:t,settings:{...e,enabled:!a}});l===I.current&&(x(i.html),T(i.subject),F(""))}catch(e){l===I.current&&F(e.message)}finally{l===I.current&&P(!1)}},[]);if((0,l.useEffect)(()=>{if(!s||!p)return;const e=window.setTimeout(()=>L(s,p,k),350);return()=>window.clearTimeout(e)},[s,p,k,L]),c)return(0,l.createElement)(v,{tone:"bad"},c);if(!t||!s)return(0,l.createElement)("div",{className:"dms-skel",style:{height:520}});const j=(e,t)=>n({...s,[e]:t}),R=JSON.stringify(s)!==m,B=Array.from(new Set([...t.detected.palette??[],...te])).slice(0,8),q=async(t=s)=>{O("save");try{const a=await o("design/save",{settings:t});n(a.settings),r(JSON.stringify(a.settings)),e(a.settings.enabled?(0,i.__)("Saved. New emails use this design.","digimail-smtp"):(0,i.__)("Saved. The design is off.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{O(null)}},V=(e,t,a)=>(0,l.createElement)(y,{label:t,htmlFor:`dms-so-${e}`},(0,l.createElement)("input",{id:`dms-so-${e}`,type:"text",inputMode:"url",placeholder:a,value:s.socials[e],onChange:t=>j("socials",{...s.socials,[e]:t.target.value})}));return(0,l.createElement)("div",{className:"dms-design"},(0,l.createElement)("div",{className:"dms-design-side"},(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-design-on"},(0,l.createElement)(b,{checked:s.enabled,onChange:e=>q({...s,enabled:e}),disabled:"save"===$,label:(0,i.__)("Use this design for emails","digimail-smtp"),hint:s.enabled?(0,i.__)("On: new emails go out in this design.","digimail-smtp"):(0,i.__)("Off: emails look as they do now. Design and preview freely, nothing changes until you turn it on.","digimail-smtp")})),t.conflicts.length>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s also changes how emails look","digimail-smtp"),t.conflicts.join(", "))},(0,i.__)("Use one email designer at a time: deactivate the other plugin, or leave this design off.","digimail-smtp")),!t.woocommerce&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("WooCommerce is not active, so only the other WordPress emails can use the design.","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Template","digimail-smtp")},(0,l.createElement)("div",{className:"dms-templates"},X.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-tpl "+(s.template===e.key?"is-on":""),onClick:()=>j("template",e.key),"aria-pressed":s.template===e.key},(0,l.createElement)(ae,{t:e.key,color:s.color}),(0,l.createElement)("strong",null,e.label),(0,l.createElement)("span",null,e.hint))))),(0,l.createElement)(E,{title:(0,i.__)("Brand","digimail-smtp"),aside:(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>{const a=t.detected;n({...s,logo:a.logo??s.logo,color:a.color??s.color,company:a.company??s.company,email:a.email??s.email,address:a.address??s.address}),e((0,i.__)("Filled in from the website. Check the preview, then save.","digimail-smtp"))}},(0,l.createElement)(w,{name:"zap",size:14})," ",(0,i.__)("Fill in from the website","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Logo","digimail-smtp")),(0,l.createElement)(le,{value:s.logo,onChange:e=>j("logo",e)}),s.logo&&(0,l.createElement)("label",{className:"dms-range"},(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Width","digimail-smtp")),(0,l.createElement)("input",{type:"range",min:60,max:260,step:5,value:s.logo_width,onChange:e=>j("logo_width",Number(e.target.value))}),(0,l.createElement)("span",{className:"dms-small"},s.logo_width,"px"))),(0,l.createElement)(ie,{label:(0,i.__)("Brand colour","digimail-smtp"),value:s.color,onChange:e=>j("color",e),swatches:B}),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(ie,{label:(0,i.__)("Background","digimail-smtp"),value:s.bg,onChange:e=>j("bg",e)}),(0,l.createElement)(ie,{label:(0,i.__)("Text","digimail-smtp"),value:s.text,onChange:e=>j("text",e)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Font","digimail-smtp"),htmlFor:"dms-font"},(0,l.createElement)("select",{id:"dms-font",value:s.font,onChange:e=>j("font",e.target.value)},ee.map(e=>(0,l.createElement)("option",{key:e.key,value:e.key},e.label)))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Corners","digimail-smtp")),(0,l.createElement)("label",{className:"dms-range"},(0,l.createElement)("input",{type:"range",min:0,max:24,value:s.radius,onChange:e=>j("radius",Number(e.target.value)),"aria-label":(0,i.__)("Corners","digimail-smtp")}),(0,l.createElement)("span",{className:"dms-small"},s.radius,"px")))))),(0,l.createElement)(E,{title:(0,i.__)("Order emails","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.tracker,onChange:e=>j("tracker",e),label:(0,i.__)("Progress bar","digimail-smtp"),hint:(0,i.__)("Order placed → Processing → Completed, in the customer’s order emails.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.cta,onChange:e=>j("cta",e),label:(0,i.__)("Button under the order","digimail-smtp"),hint:(0,i.__)("View your order, Pay for this order, or Open the order in emails to the shop.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.images,onChange:e=>j("images",e),label:(0,i.__)("Product pictures","digimail-smtp")}))),(0,l.createElement)(E,{title:(0,i.__)("Footer","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Company or shop name","digimail-smtp"),htmlFor:"dms-company"},(0,l.createElement)("input",{id:"dms-company",type:"text",value:s.company,onChange:e=>j("company",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Address","digimail-smtp"),htmlFor:"dms-address"},(0,l.createElement)("input",{id:"dms-address",type:"text",value:s.address,onChange:e=>j("address",e.target.value)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Phone","digimail-smtp"),htmlFor:"dms-phone"},(0,l.createElement)("input",{id:"dms-phone",type:"text",inputMode:"tel",value:s.phone,onChange:e=>j("phone",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Email","digimail-smtp"),htmlFor:"dms-email"},(0,l.createElement)("input",{id:"dms-email",type:"email",value:s.email,onChange:e=>j("email",e.target.value)}))),(0,l.createElement)("div",{className:"dms-grid-2"},V("facebook","Facebook","https://facebook.com/…"),V("zalo","Zalo","https://zalo.me/…"),V("tiktok","TikTok","https://tiktok.com/@…"),V("instagram","Instagram","https://instagram.com/…")),V("youtube","YouTube","https://youtube.com/@…"),(0,l.createElement)(y,{label:(0,i.__)("Note at the bottom","digimail-smtp"),hint:(0,i.__)("For example your return policy or opening hours.","digimail-smtp"),htmlFor:"dms-note"},(0,l.createElement)("textarea",{id:"dms-note",rows:2,value:s.note,onChange:e=>j("note",e.target.value)})))),(0,l.createElement)(E,{title:(0,i.__)("Which emails","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.woo,onChange:e=>j("woo",e),disabled:!t.woocommerce,label:(0,i.__)("WooCommerce emails","digimail-smtp"),hint:(0,i.__)("Orders, invoices, accounts and refunds.","digimail-smtp")}),(0,l.createElement)(b,{checked:s.wp,onChange:e=>j("wp",e),label:(0,i.__)("Other plain-text WordPress emails","digimail-smtp"),hint:(0,i.__)("Password resets, new users, form notifications that have no design of their own. Emails other plugins already design are left alone.","digimail-smtp")})))),(0,l.createElement)("div",{className:"dms-design-main"},(0,l.createElement)("div",{className:"dms-preview-bar"},(0,l.createElement)("select",{value:p,onChange:e=>g(e.target.value),"aria-label":(0,i.__)("Email to preview","digimail-smtp")},t.types.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},e.title))),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"desktop"===u?"is-on":"",onClick:()=>_("desktop")},(0,i.__)("Computer","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"mobile"===u?"is-on":"",onClick:()=>_("mobile")},(0,i.__)("Phone","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:k?"":"is-on",onClick:()=>N(!1)},(0,i.__)("New design","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:k?"is-on":"",onClick:()=>N(!0)},(0,i.__)("As it is now","digimail-smtp"))),z&&(0,l.createElement)("span",{className:"dms-spin","aria-label":(0,i.__)("Loading","digimail-smtp")})),(0,l.createElement)("div",{className:`dms-inbox is-${u}`},(0,l.createElement)("div",{className:"dms-inbox-head"},(0,l.createElement)("span",{className:"dms-avatar",style:{background:s.color}},(s.company||"S").trim().charAt(0).toUpperCase()),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,s.company||(0,i.__)("Your shop","digimail-smtp")),(0,l.createElement)("span",null,M))),D?(0,l.createElement)("div",{className:"dms-preview-err"},(0,l.createElement)(v,{tone:"bad"},D)):(0,l.createElement)("iframe",{title:(0,i.__)("Email preview","digimail-smtp"),sandbox:"allow-popups",srcDoc:S})),(0,l.createElement)("div",{className:"dms-design-actions"},(0,l.createElement)("form",{className:"dms-row",onSubmit:t=>{t.preventDefault(),(async()=>{O("test");try{await o("design/test",{type:p,to:A,settings:{...s,enabled:!0}}),e((0,i.__)("Test email sent. Check the inbox.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{O(null)}})()}},(0,l.createElement)("input",{type:"email",required:!0,value:A,onChange:e=>W(e.target.value),"aria-label":(0,i.__)("Send to","digimail-smtp")}),(0,l.createElement)(f,{type:"submit",variant:"secondary",busy:"test"===$},(0,l.createElement)(w,{name:"send",size:14})," ",(0,i.__)("Send a test","digimail-smtp"))),(0,l.createElement)("div",{className:"dms-row"},R&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Not saved","digimail-smtp")),(0,l.createElement)(f,{busy:"save"===$,disabled:!R,onClick:()=>q()},(0,i.__)("Save design","digimail-smtp"))))))}const ne=e=>`${Math.round(e).toLocaleString("vi-VN")}₫`,me={welcome:(0,i.__)("Welcome new subscribers","digimail-smtp"),order_followup:(0,i.__)("Thank-you after purchase","digimail-smtp"),abandoned_cart:(0,i.__)("Abandoned cart reminder","digimail-smtp"),review_request:(0,i.__)("Review request","digimail-smtp")};function re(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(null),[m,r]=(0,l.useState)(null),[c,g]=(0,l.useState)(""),u=e=>{a(e),n({...e.settings})};if((0,l.useEffect)(()=>{o("shop").then(u).catch(e=>g(e.message))},[]),c&&!t)return(0,l.createElement)(v,{tone:"bad"},c);if(!t||!s)return(0,l.createElement)("div",{className:"dms-skel",style:{height:360}});if(!t.woocommerce)return(0,l.createElement)(v,{tone:"info",title:(0,i.__)("WooCommerce is not active","digimail-smtp")},(0,i.__)("Turn on WooCommerce to use the shop emails.","digimail-smtp"));const _=async t=>{r("save");try{u(await o("shop/save",t)),e(t.enabled?(0,i.__)("Shop settings saved.","digimail-smtp"):(0,i.__)("Shop emails are off.","digimail-smtp"))}catch(t){e(t.message,"bad")}finally{r(null)}},k=e=>n({...s,...e}),N=JSON.stringify(s)!==JSON.stringify(t.settings),S=t.summary?.automations.filter(e=>"welcome"!==e.kind)??[],x=t.summary?.manage_url??`${t.app}/app/tu-dong`;return t.settings.enabled?(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Shop emails","digimail-smtp"),aside:(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:x,target:"_blank",rel:"noreferrer"},(0,i.__)("Edit on digimail.vn","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:14}))},t.error&&(0,l.createElement)("p",{className:"dms-error"},t.error),t.summary&&(0,l.createElement)("div",{className:"dms-kpis dms-kpis-2"},(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Revenue from email, 30 days","digimail-smtp")),(0,l.createElement)("strong",null,ne(t.summary.email_revenue_30d))),(0,l.createElement)("div",null,(0,l.createElement)("span",null,(0,i.__)("Orders from email, 30 days","digimail-smtp")),(0,l.createElement)("strong",null,d(t.summary.email_orders_30d)),(0,l.createElement)("em",null,(0,i.__)("Clicked an email in the 7 days before paying","digimail-smtp")))),t.summary&&0===S.length&&(0,l.createElement)("div",{className:"dms-empty-inline"},(0,l.createElement)("p",null,(0,i.__)("No email series yet. Pick one on digimail.vn: the text is ready, you only turn it on.","digimail-smtp")),(0,l.createElement)("a",{className:"dms-btn dms-btn-primary",href:x,target:"_blank",rel:"noreferrer"},(0,i.__)("Set up shop emails","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:14}))),S.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Email series","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Sent","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Orders","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Revenue","digimail-smtp")))),(0,l.createElement)("tbody",null,S.map(e=>(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)("a",{href:e.url,target:"_blank",rel:"noreferrer"},e.name),(0,l.createElement)("div",{className:"dms-small dms-muted"},me[e.kind]??"")),(0,l.createElement)("td",null,"active"===e.status?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Running","digimail-smtp")):"paused"===e.status?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Paused","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Draft","digimail-smtp"))),(0,l.createElement)("td",{className:"num"},d(e.sent)),(0,l.createElement)("td",{className:"num"},d(e.orders)),(0,l.createElement)("td",{className:"num"},e.orders?ne(e.revenue):"–"))))),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)("span",{className:"dms-small dms-muted"},t.last?.error?(0,i.sprintf)(/* translators: %s: error message. */ /* translators: %s: error message. */(0,i.__)("Last sync failed: %s","digimail-smtp"),t.last.error):t.last?(0,i.sprintf)(/* translators: %s: time. */ /* translators: %s: time. */(0,i.__)("Orders and carts last sent %s.","digimail-smtp"),p(new Date(1e3*t.last.at).toISOString())):(0,i.__)("Orders show up on digimail.vn a few seconds after they are placed.","digimail-smtp"),t.pending>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of items waiting. */ /* translators: %s: number of items waiting. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),d(t.pending)))),t.pending>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"===m,onClick:async()=>{r("sync");try{u(await o("shop/sync",{}))}catch(t){e(t.message,"bad")}finally{r(null)}}},(0,i.__)("Send now","digimail-smtp"))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Checkout","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:s.optin,onChange:e=>k({optin:e}),label:(0,i.__)("Show an “email me news” checkbox","digimail-smtp"),hint:(0,i.__)("Unticked by default. Shoppers who tick it join your contact list, and shop emails go to them.","digimail-smtp")}),s.optin&&(0,l.createElement)(y,{label:(0,i.__)("Checkbox text","digimail-smtp"),htmlFor:"dms-optin-label"},(0,l.createElement)("input",{id:"dms-optin-label",type:"text",maxLength:200,value:s.optin_label,onChange:e=>k({optin_label:e.target.value}),placeholder:t.default_label})),(0,l.createElement)(b,{checked:s.carts,onChange:e=>k({carts:e}),label:(0,i.__)("Save carts for the reminder email","digimail-smtp"),hint:(0,i.__)("When a shopper types their email at checkout, the cart is kept for 30 days. A short note under the email field tells them.","digimail-smtp")}),(0,l.createElement)("div",{className:"dms-row-between"},(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>_({...s,enabled:!1})},(0,i.__)("Turn off shop emails","digimail-smtp")),(0,l.createElement)(f,{disabled:!N,busy:"save"===m,onClick:()=>_(s)},(0,i.__)("Save","digimail-smtp"))),!t.blocks&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Your WooCommerce shows the checkbox on the classic checkout only. Update WooCommerce to show it on the block checkout too.","digimail-smtp")))))):(0,l.createElement)("div",{className:"dms-shop-intro"},(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-shop-hero"},(0,l.createElement)("div",{className:"dms-shop-icon"},(0,l.createElement)(w,{name:"cart",size:22})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Emails that sell for your shop","digimail-smtp")),(0,l.createElement)("p",null,(0,i.__)("DigiMail sends these by itself, from your own domain, with the products of each order:","digimail-smtp")),(0,l.createElement)("ul",{className:"dms-checks"},(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A thank-you after payment, and a check-in 7 days later.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A reminder when a shopper leaves checkout, with a button that brings their cart back.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A review request a few days after the order is completed.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("An unticked “Email me news and offers” checkbox at checkout, so you only email people who agreed.","digimail-smtp")),(0,l.createElement)("li",null,(0,l.createElement)(w,{name:"check",size:16})," ",(0,i.__)("A report of the revenue that came from your emails.","digimail-smtp"))),(0,l.createElement)(f,{busy:"save"===m,onClick:()=>_({...s,enabled:!0})},(0,i.__)("Turn on shop emails","digimail-smtp")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("This sends each order and saved cart (email, name, products, total) to your DigiMail account. Nothing is emailed until you turn on an email series on digimail.vn.","digimail-smtp"))))))}const oe=[{key:"popup",label:(0,i.__)("Popup","digimail-smtp"),hint:(0,i.__)("In the middle of the screen, after a few seconds, a scroll or when the visitor is about to leave.","digimail-smtp")},{key:"slide",label:(0,i.__)("Slide-in","digimail-smtp"),hint:(0,i.__)("A small box in the corner. Noticed without getting in the way.","digimail-smtp")},{key:"bar",label:(0,i.__)("Bar","digimail-smtp"),hint:(0,i.__)("A thin strip across the top or bottom of every page.","digimail-smtp")},{key:"inline",label:(0,i.__)("In the page","digimail-smtp"),hint:(0,i.__)("Inside a page or after each blog post, with a shortcode.","digimail-smtp")}],ce=[{key:"card",label:(0,i.__)("Card","digimail-smtp")},{key:"split",label:(0,i.__)("With picture","digimail-smtp")},{key:"minimal",label:(0,i.__)("Simple","digimail-smtp")},{key:"bold",label:(0,i.__)("Colour block","digimail-smtp")}],de=e=>oe.find(t=>t.key===e)?.label??e;function pe({type:e,color:t}){return(0,l.createElement)("svg",{viewBox:"0 0 120 76",width:"100%","aria-hidden":"true"},(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"74",rx:"6",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"10",y:"12",width:"56",height:"5",rx:"2.5",fill:"#e6e8ed"}),(0,l.createElement)("rect",{x:"10",y:"22",width:"90",height:"4",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"10",y:"30",width:"80",height:"4",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"10",y:"38",width:"86",height:"4",rx:"2",fill:"#eef0f3"}),"popup"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"74",rx:"6",fill:"#14182b",opacity:".35"}),(0,l.createElement)("rect",{x:"30",y:"16",width:"60",height:"44",rx:"5",fill:"#fff"}),(0,l.createElement)("rect",{x:"38",y:"24",width:"36",height:"4",rx:"2",fill:"#14182b"}),(0,l.createElement)("rect",{x:"38",y:"36",width:"44",height:"7",rx:"2",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"38",y:"46",width:"44",height:"7",rx:"2",fill:t})),"slide"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"70",y:"40",width:"44",height:"31",rx:"4",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"76",y:"46",width:"24",height:"3",rx:"1.5",fill:"#14182b"}),(0,l.createElement)("rect",{x:"76",y:"54",width:"32",height:"5",rx:"1.5",fill:"#eef0f3"}),(0,l.createElement)("rect",{x:"76",y:"61",width:"32",height:"5",rx:"1.5",fill:t})),"bar"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"1",y:"1",width:"118",height:"9",fill:t}),(0,l.createElement)("rect",{x:"30",y:"4",width:"34",height:"3",rx:"1.5",fill:"#fff",opacity:".9"}),(0,l.createElement)("rect",{x:"68",y:"3.5",width:"20",height:"4",rx:"1",fill:"#fff"})),"inline"===e&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("rect",{x:"10",y:"48",width:"100",height:"20",rx:"4",fill:"#f6f7f9",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"16",y:"54",width:"54",height:"8",rx:"2",fill:"#fff",stroke:"#e1e4ea"}),(0,l.createElement)("rect",{x:"74",y:"54",width:"30",height:"8",rx:"2",fill:t})))}function ge({value:e,onChange:t}){return(0,l.createElement)("div",{className:"dms-row"},e&&(0,l.createElement)("img",{src:e,alt:"",className:"dms-form-thumb"}),(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>{const e=window.wp?.media;if(!e)return;const a=e({title:(0,i.__)("Choose a picture","digimail-smtp"),library:{type:"image"},multiple:!1,button:{text:(0,i.__)("Use this image","digimail-smtp")}});a.on("select",()=>{const e=a.state().get("selection").first().toJSON();t(e.sizes?.large?.url??e.url)}),a.open()}},e?(0,i.__)("Change picture","digimail-smtp"):(0,i.__)("Choose a picture","digimail-smtp")),e&&(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>t("")},(0,i.__)("Remove","digimail-smtp")))}function ue({id:e}){const t=C(),a=`[digimail_form id="${e}"]`;return(0,l.createElement)("button",{type:"button",className:"dms-code-btn",onClick:()=>navigator.clipboard?.writeText(a).then(()=>t((0,i.__)("Shortcode copied.","digimail-smtp"))),title:(0,i.__)("Copy","digimail-smtp")},(0,l.createElement)("code",null,a)," ",(0,l.createElement)(w,{name:"copy",size:14}))}function _e(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(null),[c,p]=(0,l.useState)("");if((0,l.useEffect)(()=>{o("forms").then(a).catch(e=>n(e.message))},[]),s&&!t)return(0,l.createElement)(v,{tone:"bad"},s);if(!t)return(0,l.createElement)("div",{className:"dms-skel",style:{height:360}});const g=async(t,l=!1)=>{p("save");try{const s=await o("forms/save",t);return a(s),s.form&&r(s.form),l||e("on"===t.status?(0,i.__)("Saved. The form is live on your site.","digimail-smtp"):(0,i.__)("Saved. The form is off.","digimail-smtp")),s.form??null}catch(t){return e(t.message,"bad"),null}finally{p("")}};if(m)return(0,l.createElement)(he,{form:m,screen:t,busy:"save"===c,onSave:g,onBack:()=>r(null),onDelete:async t=>{if(window.confirm((0,i.sprintf)(/* translators: %s: form name. */ /* translators: %s: form name. */(0,i.__)("Delete “%s”? Its numbers are deleted too. People who signed up stay in your DigiMail list.","digimail-smtp"),t.name)))try{a(await o("forms/delete",{id:t.id})),r(null)}catch(t){e(t.message,"bad")}}});const u=(0,l.createElement)("div",{className:"dms-form-types"},oe.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-form-type",onClick:()=>{return a=e.key,r({...t.defaults[a],id:"",created:0});var a}},(0,l.createElement)(pe,{type:e.key,color:t.defaults.popup.color}),(0,l.createElement)("strong",null,e.label),(0,l.createElement)("span",null,e.hint))));return 0===t.forms.length?(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-forms-intro"},(0,l.createElement)("h2",null,(0,i.__)("Grow your email list from your website","digimail-smtp")),(0,l.createElement)("p",null,(0,i.__)("Visitors who sign up go straight into your DigiMail contact list, ready for campaigns and the welcome email series. The spam guard keeps bots out. Pick a kind of form to start:","digimail-smtp")),u)):(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Signup forms","digimail-smtp")},(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Views","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Signups","digimail-smtp")),(0,l.createElement)("th",{className:"num"},(0,i.__)("Rate","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,t.forms.map(e=>(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",null,(0,l.createElement)("button",{type:"button",className:"dms-link-btn",onClick:()=>r(e)},e.name),(0,l.createElement)("div",{className:"dms-small dms-muted"},de(e.type)),"inline"===e.type&&"shortcode"===e.placement&&(0,l.createElement)(ue,{id:e.id})),(0,l.createElement)("td",null,(0,l.createElement)("label",{className:"dms-switch-inline"},(0,l.createElement)("input",{type:"checkbox",checked:"on"===e.status,onChange:t=>g({...e,status:t.target.checked?"on":"off"})}),"on"===e.status?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp")))),(0,l.createElement)("td",{className:"num"},d(e.views??0)),(0,l.createElement)("td",{className:"num"},d(e.signups??0)),(0,l.createElement)("td",{className:"num"},e.views?`${((e.signups??0)/e.views*100).toFixed(1)}%`:"–"),(0,l.createElement)("td",{className:"num"},(0,l.createElement)(f,{size:"sm",variant:"secondary",onClick:()=>r(e)},(0,i.__)("Edit","digimail-smtp"))," ",(0,l.createElement)(f,{size:"sm",variant:"ghost",onClick:()=>r({...e,id:"",name:(0,i.sprintf)(/* translators: %s: form name. */ /* translators: %s: form name. */(0,i.__)("%s (copy)","digimail-smtp"),e.name),status:"off",created:0}),"aria-label":(0,i.__)("Duplicate","digimail-smtp")},(0,l.createElement)(w,{name:"copy",size:15})))))))),(0,l.createElement)(E,{title:(0,i.__)("New form","digimail-smtp")},u))}function he({form:e,screen:t,busy:a,onSave:s,onBack:n,onDelete:m}){const[r,c]=(0,l.useState)(e),[p,g]=(0,l.useState)("desktop"),[u,_]=(0,l.useState)(""),[k,N]=(0,l.useState)(!1),S=(0,l.useRef)(void 0),C=(0,l.useRef)(JSON.stringify(e)),x=JSON.stringify(r)!==C.current,M=(e,t)=>c(a=>({...a,[e]:t}));(0,l.useEffect)(()=>(window.clearTimeout(S.current),S.current=window.setTimeout(()=>{N(!0),o("forms/preview",{form:r,device:p}).then(e=>_(e.html)).catch(()=>{}).then(()=>N(!1))},350),()=>window.clearTimeout(S.current)),[r,p]);const T=async e=>{const t=e?{...r,status:e}:r,a=await s(t);a&&(C.current=JSON.stringify(a),c(a))},D="inline"!==r.type;return(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-form-top"},(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:n},(0,l.createElement)(w,{name:"back",size:15})," ",(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("input",{className:"dms-form-name",value:r.name,onChange:e=>M("name",e.target.value),"aria-label":(0,i.__)("Form name (only you see it)","digimail-smtp"),maxLength:80}),(0,l.createElement)(h,null,de(r.type)),(0,l.createElement)("span",{className:"dms-grow"}),x&&(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Unsaved changes","digimail-smtp")),r.id&&(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>m(r),"aria-label":(0,i.__)("Delete form","digimail-smtp")},(0,l.createElement)(w,{name:"trash",size:15})),"on"===r.status?(0,l.createElement)(l.Fragment,null,(0,l.createElement)(f,{variant:"secondary",busy:a,onClick:()=>T("off")},(0,i.__)("Turn off","digimail-smtp")),(0,l.createElement)(f,{busy:a,disabled:!x,onClick:()=>T()},(0,i.__)("Save","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)(f,{variant:"secondary",busy:a,onClick:()=>T("off"),disabled:!x&&!!r.id},(0,i.__)("Save as draft","digimail-smtp")),(0,l.createElement)(f,{busy:a,onClick:()=>T("on")},(0,i.__)("Save and turn on","digimail-smtp")))),!t.guard&&(0,l.createElement)(v,{tone:"wait"},(0,i.__)("The spam guard is off, so bots can sign up through this form. Turn it on in Settings.","digimail-smtp")),(0,l.createElement)("div",{className:"dms-design"},(0,l.createElement)("div",{className:"dms-design-side"},(0,l.createElement)(E,{title:(0,i.__)("Design","digimail-smtp")},(0,l.createElement)("div",{className:"dms-templates dms-templates-4"},ce.filter(e=>!("bar"===r.type&&"split"===e.key)).map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:"dms-tpl "+(r.template===e.key?"is-on":""),onClick:()=>M("template",e.key),"aria-pressed":r.template===e.key},(0,l.createElement)("span",{className:`dms-tpl-art dms-tpl-${e.key}`,style:{"--c":r.color}},(0,l.createElement)("i",null),(0,l.createElement)("b",null),(0,l.createElement)("em",null)),(0,l.createElement)("strong",null,e.label)))),(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(ie,{label:(0,i.__)("Colour","digimail-smtp"),value:r.color,onChange:e=>M("color",e),swatches:["#1b2550","#0f766e","#c2410c","#be123c","#7c3aed","#111827"]}),"split"===r.template&&(0,l.createElement)(y,{label:(0,i.__)("Picture","digimail-smtp")},(0,l.createElement)(ge,{value:r.image,onChange:e=>M("image",e)})))),(0,l.createElement)(E,{title:(0,i.__)("Form text","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Title","digimail-smtp"),htmlFor:"dmf-title"},(0,l.createElement)("input",{id:"dmf-title",value:r.title,maxLength:120,onChange:e=>M("title",e.target.value)})),"bar"!==r.type&&(0,l.createElement)(y,{label:(0,i.__)("Description","digimail-smtp"),htmlFor:"dmf-text"},(0,l.createElement)("textarea",{id:"dmf-text",rows:3,value:r.text,maxLength:400,onChange:e=>M("text",e.target.value)})),(0,l.createElement)("div",{className:"dms-grid-2"},(0,l.createElement)(y,{label:(0,i.__)("Button","digimail-smtp"),htmlFor:"dmf-btn"},(0,l.createElement)("input",{id:"dmf-btn",value:r.button,maxLength:40,onChange:e=>M("button",e.target.value)})),(0,l.createElement)(y,{label:(0,i.__)("Email box hint","digimail-smtp"),htmlFor:"dmf-ph"},(0,l.createElement)("input",{id:"dmf-ph",value:r.email_ph,maxLength:60,onChange:e=>M("email_ph",e.target.value)}))),"bar"!==r.type&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(b,{checked:r.ask_name,onChange:e=>M("ask_name",e),label:(0,i.__)("Ask for a name","digimail-smtp"),hint:(0,i.__)("Lets your emails greet people by name. Each extra field means a few fewer signups.","digimail-smtp")}),(0,l.createElement)(b,{checked:r.ask_phone,onChange:e=>M("ask_phone",e),label:(0,i.__)("Ask for a phone number (optional for the visitor)","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Small print under the button","digimail-smtp"),htmlFor:"dmf-consent"},(0,l.createElement)("input",{id:"dmf-consent",value:r.consent,maxLength:240,onChange:e=>M("consent",e.target.value)}))))),(0,l.createElement)(E,{title:D?(0,i.__)("When and where it shows","digimail-smtp"):(0,i.__)("Where it goes","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},D&&"bar"!==r.type&&(0,l.createElement)(y,{label:(0,i.__)("Show it","digimail-smtp"),htmlFor:"dmf-trigger"},(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("select",{id:"dmf-trigger",value:r.trigger,onChange:e=>M("trigger",e.target.value)},(0,l.createElement)("option",{value:"delay"},(0,i.__)("After some seconds","digimail-smtp")),(0,l.createElement)("option",{value:"scroll"},(0,i.__)("After scrolling part of the page","digimail-smtp")),(0,l.createElement)("option",{value:"exit"},(0,i.__)("When the visitor is about to leave","digimail-smtp"))),"delay"===r.trigger&&(0,l.createElement)("label",{className:"dms-inline-num"},(0,l.createElement)("input",{type:"number",min:0,max:300,value:r.delay,onChange:e=>M("delay",Number(e.target.value))})," ",(0,i.__)("seconds","digimail-smtp")),"scroll"===r.trigger&&(0,l.createElement)("label",{className:"dms-inline-num"},(0,l.createElement)("input",{type:"number",min:5,max:100,value:r.scroll,onChange:e=>M("scroll",Number(e.target.value))})," %")),"exit"===r.trigger&&(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("On phones, which have no mouse, it shows after 20 seconds instead.","digimail-smtp"))),"slide"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Corner","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"left"===r.position?"is-on":"",onClick:()=>M("position","left")},(0,i.__)("Bottom left","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"left"!==r.position?"is-on":"",onClick:()=>M("position","right")},(0,i.__)("Bottom right","digimail-smtp")))),"bar"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Position","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"bottom"!==r.position?"is-on":"",onClick:()=>M("position","top")},(0,i.__)("Top of the page","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"bottom"===r.position?"is-on":"",onClick:()=>M("position","bottom")},(0,i.__)("Bottom of the screen","digimail-smtp")))),"inline"===r.type&&(0,l.createElement)(y,{label:(0,i.__)("Place","digimail-smtp")},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"shortcode"===r.placement?"is-on":"",onClick:()=>M("placement","shortcode")},(0,i.__)("Where I paste the shortcode","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"after_post"===r.placement?"is-on":"",onClick:()=>M("placement","after_post")},(0,i.__)("After every blog post","digimail-smtp"))),"shortcode"===r.placement&&(r.id?(0,l.createElement)(ue,{id:r.id}):(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Save the form to get its shortcode.","digimail-smtp")))),(D||"after_post"===r.placement)&&(0,l.createElement)("div",{className:"dms-grid-2"},D&&(0,l.createElement)(y,{label:(0,i.__)("Pages","digimail-smtp"),htmlFor:"dmf-pages"},(0,l.createElement)("select",{id:"dmf-pages",value:r.pages,onChange:e=>M("pages",e.target.value)},(0,l.createElement)("option",{value:"all"},(0,i.__)("Every page","digimail-smtp")),(0,l.createElement)("option",{value:"home"},(0,i.__)("Home page only","digimail-smtp")),(0,l.createElement)("option",{value:"posts"},(0,i.__)("Blog posts","digimail-smtp")),(0,l.createElement)("option",{value:"pages"},(0,i.__)("Pages","digimail-smtp")),(0,l.createElement)("option",{value:"shop"},(0,i.__)("Shop and product pages","digimail-smtp")))),(0,l.createElement)(y,{label:(0,i.__)("Devices","digimail-smtp"),htmlFor:"dmf-dev"},(0,l.createElement)("select",{id:"dmf-dev",value:r.devices,onChange:e=>M("devices",e.target.value)},(0,l.createElement)("option",{value:"all"},(0,i.__)("Computers and phones","digimail-smtp")),(0,l.createElement)("option",{value:"desktop"},(0,i.__)("Computers only","digimail-smtp")),(0,l.createElement)("option",{value:"mobile"},(0,i.__)("Phones only","digimail-smtp"))))),D&&(0,l.createElement)(y,{label:(0,i.__)("After someone closes it","digimail-smtp"),htmlFor:"dmf-again"},(0,l.createElement)("label",{className:"dms-inline-num"},(0,i.__)("Show again after","digimail-smtp")," ",(0,l.createElement)("input",{id:"dmf-again",type:"number",min:0,max:365,value:r.again,onChange:e=>M("again",Number(e.target.value))})," ",(0,i.__)("days","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("People who sign up never see it again. Checkout, cart and account pages never show forms.","digimail-smtp"))),(0,l.createElement)(b,{checked:r.logged,onChange:e=>M("logged",e),label:(0,i.__)("Also show to logged-in users","digimail-smtp")}))),(0,l.createElement)(E,{title:(0,i.__)("After signing up","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Add to the DigiMail list","digimail-smtp"),htmlFor:"dmf-list"},(0,l.createElement)("select",{id:"dmf-list",value:r.list_id,onChange:e=>M("list_id",e.target.value)},(0,l.createElement)("option",{value:""},t.site_list?(0,i.sprintf)(/* translators: %s: list name. */ /* translators: %s: list name. */(0,i.__)("This website’s list (%s)","digimail-smtp"),t.site_list):(0,i.__)("This website’s list","digimail-smtp")),t.lists.map(e=>(0,l.createElement)("option",{key:e.id,value:e.id},e.name," (",d(e.subscribed),")")))),(0,l.createElement)(b,{checked:r.confirm,onChange:e=>M("confirm",e),label:(0,i.__)("Ask people to confirm by email (double opt-in)","digimail-smtp"),hint:(0,i.__)("They join the list only after clicking the link in a confirmation email. Fewer signups, but every address is real and wanted.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Message after signing up","digimail-smtp"),htmlFor:"dmf-ok"},(0,l.createElement)("input",{id:"dmf-ok",value:r.confirm?r.pending:r.success,maxLength:200,onChange:e=>M(r.confirm?"pending":"success",e.target.value)})),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("To send a welcome email, turn on the “Welcome new subscribers” series for this list on digimail.vn (Automation).","digimail-smtp"))))),(0,l.createElement)("div",{className:"dms-design-main"},(0,l.createElement)("div",{className:"dms-preview-bar"},(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"desktop"===p?"is-on":"",onClick:()=>g("desktop")},(0,i.__)("Computer","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"mobile"===p?"is-on":"",onClick:()=>g("mobile")},(0,i.__)("Phone","digimail-smtp"))),k&&(0,l.createElement)("span",{className:"dms-spin","aria-label":(0,i.__)("Loading","digimail-smtp")}),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("Preview: try the form, nothing is sent.","digimail-smtp"))),(0,l.createElement)("div",{className:`dms-form-stage is-${p}`},(0,l.createElement)("iframe",{title:(0,i.__)("Form preview","digimail-smtp"),srcDoc:u,sandbox:"allow-scripts"})))))}const Ee=[{key:"overview",label:(0,i.__)("Overview","digimail-smtp"),icon:"chart"},{key:"logs",label:(0,i.__)("Email log","digimail-smtp"),icon:"list"},{key:"contacts",label:(0,i.__)("Customers","digimail-smtp"),icon:"users"},{key:"forms",label:(0,i.__)("Signup forms","digimail-smtp"),icon:"form"},{key:"test",label:(0,i.__)("Test email","digimail-smtp"),icon:"send"},{key:"design",label:(0,i.__)("Email design","digimail-smtp"),icon:"palette"},{key:"shop",label:(0,i.__)("Shop","digimail-smtp"),icon:"cart"},{key:"settings",label:(0,i.__)("Settings","digimail-smtp"),icon:"settings"},{key:"tools",label:(0,i.__)("Tools","digimail-smtp"),icon:"tools"}],fe=()=>{const e=window.location.hash.replace("#","");return Ee.some(t=>t.key===e)?e:"overview"},be=document.getElementById("digimail-smtp-app");if(be){const e=(0,l.createElement)(function({children:e}){const[t,a]=(0,l.useState)([]),i=(0,l.useCallback)((e,t="ok")=>{const l=Date.now()+Math.random();a(a=>[...a,{id:l,msg:e,tone:t}]),setTimeout(()=>a(e=>e.filter(e=>e.id!==l)),4500)},[]);return(0,l.createElement)(S.Provider,{value:i},e,(0,l.createElement)("div",{className:"dms-toasts",role:"status","aria-live":"polite"},t.map(e=>(0,l.createElement)("div",{key:e.id,className:`dms-toast dms-toast-${e.tone}`},(0,l.createElement)(w,{name:"ok"===e.tone?"check":"alert",size:16}),e.msg))))},null,(0,l.createElement)(function(){const e=C(),[t,a]=(0,l.useState)(null),[s,n]=(0,l.useState)(""),[m,r]=(0,l.useState)(fe),[c,d]=(0,l.useState)(!1),p=(0,l.useCallback)(async(e=!1)=>{try{a(await o("state"+(e?"?refresh=1":""))),n("")}catch(e){n(e.message)}},[]);(0,l.useEffect)(()=>{p();const t=window.digimailSmtp?.flash;t&&e(t.message,t.ok?"ok":"bad")},[p,e]),(0,l.useEffect)(()=>{const e=()=>r(fe());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);const g=e=>{window.location.hash=e,r(e),window.scrollTo({top:0})};if(s&&!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("DigiMail SMTP could not load","digimail-smtp")},s));if(!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("div",{className:"dms-skel",style:{height:420}}));if(!t.connected)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(M,{state:t,reload:async()=>{await p(!0),d(!0),g("overview")}}));const u=t.status.sender;return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("header",{className:"dms-top"},(0,l.createElement)("div",{className:"dms-brand"},(0,l.createElement)("img",{src:window.digimailSmtp?.logo,alt:"",width:30,height:30}),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,"DigiMail SMTP"),(0,l.createElement)("span",null,t.revoked?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Disconnected","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i._x)("Active","connection status","digimail-smtp"))))),(0,l.createElement)("nav",{className:"dms-tabs","aria-label":"DigiMail SMTP"},Ee.filter(e=>"shop"!==e.key||t.capture.woocommerce).map(e=>(0,l.createElement)("a",{key:e.key,href:`#${e.key}`,className:m===e.key?"is-on":"","aria-current":m===e.key?"page":void 0,onClick:t=>{t.preventDefault(),g(e.key)}},(0,l.createElement)(w,{name:e.icon,size:16}),e.label,"logs"===e.key&&t.queue.failed>0&&(0,l.createElement)("span",{className:"dms-count"},t.queue.failed))))),t.revoked&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("This website was disconnected on digimail.vn","digimail-smtp"),action:(0,l.createElement)(f,{onClick:async()=>{await o("disconnect",{}),p(!0)}},(0,i.__)("Reconnect","digimail-smtp"))},t.settings.backup.enabled?(0,i.__)("Email is not going through DigiMail. The backup server is sending it.","digimail-smtp"):(0,i.__)("Email is not going through DigiMail.","digimail-smtp")),c&&u&&(0,l.createElement)("div",{className:"dms-welcome"},(0,l.createElement)("div",{className:"dms-welcome-icon"},(0,l.createElement)(w,{name:"check",size:28})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Done! This website can send email now.","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender email address. */ /* translators: %s: sender email address. */(0,i.__)("Email will be sent from <strong>%s</strong>. Send a test email to make sure everything works.","digimail-smtp"),u.email),{strong:(0,l.createElement)("strong",null)}))),(0,l.createElement)(f,{onClick:()=>{d(!1),g("test")}},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send a test email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Close","digimail-smtp"),onClick:()=>d(!1)},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("main",null,"overview"===m&&(0,l.createElement)(z,{state:t,go:g}),"logs"===m&&(0,l.createElement)(I,{reload:()=>p()}),"contacts"===m&&(0,l.createElement)(q,{state:t,go:g}),"test"===m&&(0,l.createElement)(V,{state:t,go:g}),"design"===m&&(0,l.createElement)(se,null),"shop"===m&&(0,l.createElement)(re,null),"forms"===m&&(0,l.createElement)(_e,null),"settings"===m&&(0,l.createElement)(Q,{state:t,setState:a}),"tools"===m&&(0,l.createElement)(Z,{state:t,setState:a})),(0,l.createElement)("footer",{className:"dms-foot"},"DigiMail SMTP ",t.env.plugin," · ",(0,l.createElement)("a",{href:t.env.app,target:"_blank",rel:"noreferrer"},"digimail.vn")))},null));"function"==typeof l.createRoot?(0,l.createRoot)(be).render(e):(0,l.render)(e,be)}}};const t={};function a(l){const i=t[l];if(void 0!==i)return i.exports;const s=t[l]={exports:{}};return e[l](s,s.exports,a),s.exports}a.m=e,(()=>{const e=[];a.O=(t,l,i)=>{if(!l){for(var s=0;s<e.length;s++){let[l,i]=e[s],m=!0;for(var n=0;n<l.length;n++)a.O.j(l[n])?l.splice(n--,1):m=!1;if(m){e.splice(s--,1);const a=i();void 0!==a&&(t=a)}}return t}e.push([l,i])}})(),a.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.hasOwn(e,t),(()=>{const e={57:0,350:0};a.O.j=t=>0===e[t];const t=(t,l)=>{let[i,s,n]=l;var m,r,o=0;if(i.some(t=>0!==e[t])){for(m in s)a.o(s,m)&&(a.m[m]=s[m]);if(n)var c=n(a)}for(t&&t(l);o<i.length;o++)r=i[o],a.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return a.O(c)},l=Array.isArray(globalThis.webpackChunkdigimail_smtp)?globalThis.webpackChunkdigimail_smtp:globalThis.webpackChunkdigimail_smtp=[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();let l=a.O(void 0,[350],()=>a(897));l=a.O(l)})(); -
digimail-smtp/trunk/digimail-smtp.php
r3830946 r3831455 4 4 * Plugin URI: https://digimail.vn 5 5 * Description: Send WordPress email without setting up SMTP: activate, enter your email, and your site sends mail right away. Email log with real delivery status, background sending, backup connection, email controls, and many sites managed on digimail.vn. 6 * Version: 2. 8.06 * Version: 2.9.0 7 7 * Requires at least: 6.2 8 8 * Requires PHP: 7.4 … … 20 20 } 21 21 22 define( 'DIGIMAIL_SMTP_VERSION', '2. 8.0' );22 define( 'DIGIMAIL_SMTP_VERSION', '2.9.0' ); 23 23 define( 'DIGIMAIL_SMTP_FILE', __FILE__ ); 24 24 define( 'DIGIMAIL_SMTP_DIR', plugin_dir_path( __FILE__ ) ); -
digimail-smtp/trunk/includes/Connect.php
r3829755 r3831455 176 176 if ( ! Options::connected() ) { 177 177 return; 178 } 179 if ( Guard::enabled() ) { 180 Guard::refresh_tor(); 178 181 } 179 182 global $wp_version; -
digimail-smtp/trunk/includes/Guard.php
r3830946 r3831455 21 21 * visitor types. On submit, those signals are scored together with the 22 22 * content (links, foreign scripts, gibberish names, throwaway addresses, 23 * the site's own comment blocklist, Akismet when set up) and how often the 24 * same visitor or message came in. Submissions that score 100 or more are 25 * refused before the form plugin sends any email, and kept in a local log 26 * so the site owner can put back anything blocked by mistake. 23 * Gmail addresses with random dots, the site's own comment blocklist, 24 * Akismet when set up), whether the visitor came through Tor, and how often 25 * the same visitor, mailbox or message came in. Submissions that score 100 26 * or more are refused before the form plugin sends any email, and kept in a 27 * local log so the site owner can put back anything blocked by mistake. 28 * 29 * WordPress's own registration, lost password and comment forms are 30 * covered too: bots use them to make the site email addresses they type. 31 * The trap field's name differs on every site, and logged-in admins see a 32 * small note under each form saying whether it is protected. 27 33 */ 28 34 final class Guard { … … 33 39 const SECRET = 'digimail_smtp_guard_secret'; 34 40 const ALLOW = 'digimail_smtp_guard_allow'; 41 const TOR = 'digimail_smtp_guard_tor'; 42 const TOR_CRON = 'digimail_smtp_guard_tor'; 35 43 const THRESHOLD = 100; 36 44 const MAX_LOG = 300; … … 44 52 45 53 /** 54 * WordPress and WooCommerce account forms: a person blocked there is not 55 * a form contact, so "not spam" does not add them to the contact list. 56 */ 57 const CORE = array( 'wp-register', 'wp-lostpassword', 'wp-comments', 'woo-register' ); 58 59 /** 46 60 * Verdict of the current request, once a form was checked. 47 61 * … … 59 73 } 60 74 add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue' ) ); 75 add_action( self::TOR_CRON, array( __CLASS__, 'refresh_tor' ) ); 61 76 add_filter( 'wpcf7_spam', array( __CLASS__, 'cf7' ), 20, 2 ); 62 77 add_filter( 'wpforms_process_initial_errors', array( __CLASS__, 'wpforms' ), 20, 2 ); … … 68 83 add_filter( 'bricks/form/validate', array( __CLASS__, 'bricks' ), 20, 2 ); 69 84 add_action( 'woocommerce_after_checkout_validation', array( __CLASS__, 'woo' ), 20, 2 ); 85 $g = Options::get( 'guard' ); 86 if ( ! empty( $g['core'] ) ) { 87 add_action( 'login_enqueue_scripts', array( __CLASS__, 'enqueue' ) ); 88 add_filter( 'registration_errors', array( __CLASS__, 'register' ), 20, 3 ); 89 add_filter( 'woocommerce_registration_errors', array( __CLASS__, 'woo_register' ), 20, 3 ); 90 add_action( 'lostpassword_post', array( __CLASS__, 'lostpassword' ), 20, 2 ); 91 add_filter( 'pre_comment_approved', array( __CLASS__, 'comment' ), 20, 2 ); 92 } 70 93 } 71 94 … … 113 136 */ 114 137 public static function enqueue() { 138 $g = Options::get( 'guard' ); 139 $cfg = array( 140 'url' => rest_url( Rest::NS . '/guard' ), 141 'trap' => self::trap_name(), 142 'core' => ! empty( $g['core'] ), 143 ); 144 if ( ! empty( $g['badge'] ) && current_user_can( 'manage_options' ) ) { 145 // Only for admins (their pages are not cached for visitors). 146 $cfg['badge'] = array( 147 'checking' => __( 'DigiMail spam guard: checking this form…', 'digimail-smtp' ), 148 'ok' => __( 'Protected by the DigiMail spam guard. Only admins see this note.', 'digimail-smtp' ), 149 /* translators: %s: address of the token route. */ 150 'failed' => sprintf( __( 'DigiMail spam guard could not get its token, so real visitors may be refused. Check that no cache or security plugin blocks %s.', 'digimail-smtp' ), rest_url( Rest::NS . '/guard' ) ), 151 'none' => __( 'This form is not protected by the DigiMail spam guard (its form plugin is not supported yet). Only admins see this note.', 'digimail-smtp' ), 152 ); 153 } 115 154 wp_enqueue_script( 'digimail-smtp-guard', plugins_url( 'assets/guard.js', DIGIMAIL_SMTP_FILE ), array(), DIGIMAIL_SMTP_VERSION, array( 'in_footer' => true ) ); 116 wp_add_inline_script( 'digimail-smtp-guard', 'window.digimailSmtpGuard=' . wp_json_encode( array( 'url' => rest_url( Rest::NS . '/guard' ) ) ) . ';', 'before' ); 155 wp_add_inline_script( 'digimail-smtp-guard', 'window.digimailSmtpGuard=' . wp_json_encode( $cfg ) . ';', 'before' ); 156 } 157 158 /** 159 * This site's own name for the trap field, so a bot written against the 160 * plugin cannot simply leave a known field empty. It looks like a field a 161 * bot wants to fill, and starts with "_" so form plugins do not store it. 162 * 163 * @return string 164 */ 165 public static function trap_name() { 166 $h = hash_hmac( 'sha256', 'trap-field', self::secret() ); 167 $words = array( 'website', 'url', 'homepage', 'web_address', 'site_link', 'company_url' ); 168 return '_' . $words[ hexdec( substr( $h, 0, 2 ) ) % count( $words ) ] . '_' . substr( $h, 2, 4 ); 117 169 } 118 170 … … 247 299 } 248 300 301 /** 302 * The trap field: this site's name, or the fixed names used before 2.9.0 303 * (pages cached with the old script). 304 * 305 * @param array $post Posted data. 306 * @return string 307 */ 308 private static function trap( array $post ) { 309 $name = self::trap_name(); 310 if ( isset( $post[ $name ] ) && is_scalar( $post[ $name ] ) ) { 311 return sanitize_text_field( wp_unslash( (string) $post[ $name ] ) ); 312 } 313 return self::field( $post, 'url' ); 314 } 315 249 316 // ---------- scoring ---------- 250 317 … … 281 348 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- public forms; the form plugin checks its own nonce. 282 349 $post = isset( $opts['post'] ) && is_array( $opts['post'] ) ? $opts['post'] : $_POST; 283 $hp = trim( self:: field( $post, 'url') );350 $hp = trim( self::trap( $post ) ); 284 351 $js = '' !== self::field( $post, 'js' ); 285 352 $token = self::field( $post, 't' ); … … 346 413 $add( 60, 'too_many' ); 347 414 } 415 if ( self::tor( $ip ) ) { 416 // Tor gives a bot a new IP for each submission, so the limits above 417 // never trip. Real visitors of these sites almost never use it. 418 $add( 60, 'tor' ); 419 } 348 420 349 421 if ( $opts['content'] && ! $allowed ) { … … 354 426 if ( '' !== $p['email'] && self::disposable( $p['email'] ) ) { 355 427 $add( 60, 'disposable_email' ); 428 } 429 $dots = '' !== $p['email'] ? self::dotted( $p['email'] ) : 0; 430 if ( 2 === $dots ) { 431 $add( 60, 'dotted_gmail' ); 432 } elseif ( 1 === $dots ) { 433 $add( 30, 'dotted_gmail' ); 434 } 435 $spellings = '' !== $p['email'] ? self::spellings( $p['email'] ) : 0; 436 if ( $spellings >= 3 ) { 437 $add( 100, 'gmail_variants' ); 438 } elseif ( 2 === $spellings ) { 439 $add( 40, 'gmail_variants' ); 356 440 } 357 441 if ( function_exists( 'wp_check_comment_disallowed_list' ) && '' !== trim( (string) get_option( 'disallowed_keys' ) ) … … 487 571 $list = apply_filters( 'digimail_smtp_disposable_domains', $list ); 488 572 return in_array( $domain, $list, true ); 573 } 574 575 /** 576 * The mailbox a Gmail address really goes to: Gmail ignores dots and 577 * anything after "+". Empty for other providers, where dots matter. 578 * 579 * @param string $email Email. 580 * @return string 581 */ 582 public static function gmail_base( $email ) { 583 $email = strtolower( trim( (string) $email ) ); 584 $at = strrpos( $email, '@' ); 585 if ( false === $at ) { 586 return ''; 587 } 588 $domain = substr( $email, $at + 1 ); 589 if ( 'gmail.com' !== $domain && 'googlemail.com' !== $domain ) { 590 return ''; 591 } 592 $local = explode( '+', substr( $email, 0, $at ) ); 593 $local = str_replace( '.', '', $local[0] ); 594 return '' === $local ? '' : $local . '@gmail.com'; 595 } 596 597 /** 598 * Gmail address with dots sprinkled in, such as bi.f.ewoy.oxu.s00.8@gmail.com: 599 * bots do this so one mailbox looks like a new person on every form. 600 * 601 * @param string $email Email. 602 * @return int 2: bot pattern (3+ dots with a one-letter piece, or 5+ dots); 603 * 1: 3 or 4 dots (also real names like nguyen.thi.thu.ha); 0: no. 604 */ 605 public static function dotted( $email ) { 606 if ( '' === self::gmail_base( $email ) ) { 607 return 0; 608 } 609 $email = strtolower( trim( (string) $email ) ); 610 $local = explode( '+', substr( $email, 0, (int) strrpos( $email, '@' ) ) ); 611 $parts = explode( '.', $local[0] ); 612 $dots = count( $parts ) - 1; 613 if ( $dots < 3 ) { 614 return 0; 615 } 616 $single = (bool) array_filter( 617 $parts, 618 static function ( $x ) { 619 return 1 === strlen( $x ); 620 } 621 ); 622 return ( $dots >= 5 || $single ) ? 2 : 1; 623 } 624 625 /** 626 * How many different spellings of one Gmail mailbox were sent in the last 627 * day, this one included. People type their address the same way each 628 * time; bots change the dots on every try. 629 * 630 * @param string $email Email. 631 * @return int 0 for addresses that are not Gmail. 632 */ 633 private static function spellings( $email ) { 634 $base = self::gmail_base( $email ); 635 if ( '' === $base ) { 636 return 0; 637 } 638 $key = 'digimail_smtp_gv_' . md5( $base . self::secret() ); 639 $seen = get_transient( $key ); 640 $seen = is_array( $seen ) ? $seen : array(); 641 $spell = md5( strtolower( trim( $email ) ) ); 642 $seen[ $spell ] = 1; 643 set_transient( $key, array_slice( $seen, -10, null, true ), DAY_IN_SECONDS ); 644 return count( $seen ); 645 } 646 647 /** 648 * Whether the visitor came through a Tor exit node. The list comes from 649 * DigiMail (which takes it from the Tor Project) twice a day, only while 650 * the site is connected. 651 * 652 * @param string $ip IP. 653 * @return bool 654 */ 655 public static function tor( $ip ) { 656 if ( '' === $ip ) { 657 return false; 658 } 659 $t = get_option( self::TOR, array() ); 660 $t = is_array( $t ) ? $t : array(); 661 if ( ( empty( $t['at'] ) || (int) $t['at'] < time() - 36 * HOUR_IN_SECONDS ) && Options::connected() && ! wp_next_scheduled( self::TOR_CRON ) ) { 662 wp_schedule_single_event( time() + 30, self::TOR_CRON ); 663 } 664 return ! empty( $t['ips'] ) && is_array( $t['ips'] ) && isset( $t['ips'][ $ip ] ); 665 } 666 667 /** 668 * Downloads the Tor exit list from DigiMail. 669 * 670 * @return bool Whether a list was saved. 671 */ 672 public static function refresh_tor() { 673 if ( ! Options::connected() ) { 674 return false; 675 } 676 $r = Api::get( '/v1/wp/tor-exits' ); 677 if ( empty( $r['ok'] ) || empty( $r['data']['ips'] ) || ! is_array( $r['data']['ips'] ) ) { 678 return false; 679 } 680 $ips = array(); 681 foreach ( $r['data']['ips'] as $ip ) { 682 if ( is_string( $ip ) && filter_var( $ip, FILTER_VALIDATE_IP ) ) { 683 $ips[ $ip ] = 1; 684 } 685 } 686 if ( count( $ips ) < 100 ) { 687 return false; 688 } 689 update_option( 690 self::TOR, 691 array( 692 'at' => time(), 693 'ips' => $ips, 694 ), 695 false 696 ); 697 return true; 489 698 } 490 699 … … 639 848 } 640 849 $key = 'digimail_smtp_gm_' . md5( $norm ); 641 $ips = (array) get_transient( $key ); 850 $ips = get_transient( $key ); 851 $ips = is_array( $ips ) ? $ips : array(); 642 852 $hash = md5( $ip ); 643 853 $ips[ $hash ] = 1; … … 821 1031 update_option( self::ALLOW, array_slice( array_values( array_unique( $allow ) ), -500 ), false ); 822 1032 $c = Options::get( 'capture' ); 823 // Signups from DigiMail forms always go to DigiMail. 824 if ( ( ! empty( $c['enabled'] ) || 'digimail' === $found['source'] ) && Options::connected() ) { 1033 // Signups from DigiMail forms always go to DigiMail; account and 1034 // comment forms never do. 1035 if ( ( ! empty( $c['enabled'] ) || 'digimail' === $found['source'] ) && ! in_array( $found['source'], self::CORE, true ) && Options::connected() ) { 825 1036 Contacts::add( 826 1037 $found['email'], … … 1186 1397 return $v; 1187 1398 } 1399 1400 // ---------- WordPress account and comment forms ---------- 1401 1402 /** 1403 * Whether this request was already checked (a WooCommerce checkout that 1404 * also creates an account runs both hooks). 1405 * 1406 * @return bool 1407 */ 1408 private static function checked() { 1409 return null !== self::$verdict; 1410 } 1411 1412 /** 1413 * WordPress registration (wp-login.php?action=register). 1414 * 1415 * @param \WP_Error $errors Errors. 1416 * @param string $login Username. 1417 * @param string $email Email. 1418 * @return \WP_Error 1419 */ 1420 public static function register( $errors, $login = '', $email = '' ) { 1421 return self::account( 'wp-register', $errors, $login, $email ); 1422 } 1423 1424 /** 1425 * WooCommerce "My account" registration. 1426 * 1427 * @param \WP_Error $errors Errors. 1428 * @param string $login Username. 1429 * @param string $email Email. 1430 * @return \WP_Error 1431 */ 1432 public static function woo_register( $errors, $login = '', $email = '' ) { 1433 return self::account( 'woo-register', $errors, $login, $email ); 1434 } 1435 1436 /** 1437 * Checks a new account. 1438 * 1439 * @param string $source Source slug. 1440 * @param \WP_Error $errors Errors. 1441 * @param string $login Username. 1442 * @param string $email Email. 1443 * @return \WP_Error 1444 */ 1445 private static function account( $source, $errors, $login, $email ) { 1446 if ( ! is_object( $errors ) || ! method_exists( $errors, 'add' ) || ( method_exists( $errors, 'has_errors' ) && $errors->has_errors() ) || self::checked() || is_user_logged_in() ) { 1447 return $errors; 1448 } 1449 $v = self::check( 1450 $source, 1451 __( 'Registration', 'digimail-smtp' ), 1452 array( 1453 array( 1454 'key' => 'email', 1455 'type' => 'email', 1456 'value' => (string) $email, 1457 ), 1458 array( 1459 'key' => 'name', 1460 'type' => 'text', 1461 'value' => (string) $login, 1462 ), 1463 ) 1464 ); 1465 if ( $v['spam'] ) { 1466 $errors->add( 'digimail_spam', self::message() ); 1467 } 1468 return $errors; 1469 } 1470 1471 /** 1472 * Lost password form: bots use it to make the site email real users. 1473 * 1474 * @param \WP_Error $errors Errors. 1475 * @param \WP_User|false $user_data The account, if found. 1476 */ 1477 public static function lostpassword( $errors, $user_data = false ) { 1478 // Admins sending a reset link from the Users screen are logged in. 1479 if ( ! is_object( $errors ) || ! method_exists( $errors, 'add' ) || ( method_exists( $errors, 'has_errors' ) && $errors->has_errors() ) || self::checked() || is_user_logged_in() ) { 1480 return; 1481 } 1482 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- core form without a nonce; the value is only scored. 1483 $typed = isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ? sanitize_text_field( wp_unslash( $_POST['user_login'] ) ) : ''; 1484 if ( '' === $typed && is_object( $user_data ) && isset( $user_data->user_email ) ) { 1485 $typed = (string) $user_data->user_email; 1486 } 1487 $is_email = false !== strpos( $typed, '@' ); 1488 $v = self::check( 1489 'wp-lostpassword', 1490 __( 'Lost password', 'digimail-smtp' ), 1491 array( 1492 array( 1493 'key' => $is_email ? 'email' : 'name', 1494 'type' => $is_email ? 'email' : 'text', 1495 'value' => $typed, 1496 ), 1497 ) 1498 ); 1499 if ( $v['spam'] ) { 1500 $errors->add( 'digimail_spam', self::message() ); 1501 } 1502 } 1503 1504 /** 1505 * Comments sent with the theme's comment form: spam goes to the Spam 1506 * folder, so no moderation email goes out. 1507 * 1508 * @param int|string|\WP_Error $approved Approval status. 1509 * @param array $commentdata Comment. 1510 * @return int|string|\WP_Error 1511 */ 1512 public static function comment( $approved, $commentdata = array() ) { 1513 global $pagenow; 1514 if ( 'wp-comments-post.php' !== $pagenow || is_user_logged_in() || is_wp_error( $approved ) || in_array( $approved, array( 'spam', 'trash' ), true ) || self::checked() ) { 1515 return $approved; 1516 } 1517 $c = is_array( $commentdata ) ? $commentdata : array(); 1518 $type = isset( $c['comment_type'] ) ? (string) $c['comment_type'] : ''; 1519 if ( '' !== $type && 'comment' !== $type ) { 1520 return $approved; 1521 } 1522 $v = self::check( 1523 'wp-comments', 1524 __( 'Comments', 'digimail-smtp' ), 1525 array( 1526 array( 1527 'key' => 'name', 1528 'type' => 'text', 1529 'value' => isset( $c['comment_author'] ) ? $c['comment_author'] : '', 1530 ), 1531 array( 1532 'key' => 'email', 1533 'type' => 'email', 1534 'value' => isset( $c['comment_author_email'] ) ? $c['comment_author_email'] : '', 1535 ), 1536 array( 1537 'key' => 'comment', 1538 'type' => 'textarea', 1539 'value' => isset( $c['comment_content'] ) ? $c['comment_content'] : '', 1540 ), 1541 ) 1542 ); 1543 return $v['spam'] ? 'spam' : $approved; 1544 } 1188 1545 } -
digimail-smtp/trunk/includes/Options.php
r3830740 r3831455 57 57 'enabled' => true, 58 58 'akismet' => false, 59 'core' => true, 60 'badge' => true, 59 61 ), 60 62 'keep_data' => false, -
digimail-smtp/trunk/includes/Plugin.php
r3830946 r3831455 75 75 wp_clear_scheduled_hook( self::CRON_QUEUE ); 76 76 wp_clear_scheduled_hook( Contacts::CRON ); 77 wp_clear_scheduled_hook( Guard::TOR_CRON ); 77 78 } 78 79 -
digimail-smtp/trunk/includes/Rest.php
r3830946 r3831455 453 453 'enabled' => ! empty( $in['guard']['enabled'] ), 454 454 'akismet' => ! empty( $in['guard']['akismet'] ), 455 'core' => ! empty( $in['guard']['core'] ), 456 'badge' => ! empty( $in['guard']['badge'] ), 455 457 ); 456 458 } -
digimail-smtp/trunk/readme.txt
r3830946 r3831455 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 2. 8.07 Stable tag: 2.9.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 36 36 * Save form contacts to DigiMail (optional): email, name and phone from your forms and WooCommerce orders go into a contact list on digimail.vn for your campaigns. 37 37 * Customers tab: see who filled in which form, on which page and when, filter by form, search, and export to CSV. 38 * Form spam guard (on by default): stops bots before a form sends any email, with no puzzle for visitors. A hidden trap field, a signed token with a small proof-of-work solved by the browser, timing and interaction checks, rate limits, content checks (links in name fields, foreign scripts, random names, throwaway addresses, your comment blocklist). Optionally, and off by default, doubtful submissions can also be checked by Akismet if your site uses it. Blocked submissions are listed so you can put back anything blocked by mistake.38 * Form spam guard (on by default): stops bots before a form sends any email, with no puzzle for visitors. A hidden trap field, a signed token with a small proof-of-work solved by the browser, timing and interaction checks, rate limits, content checks (links in name fields, foreign scripts, random names, throwaway addresses, Gmail addresses with random dots, your comment blocklist) and visitors coming through the Tor network. Also protects WordPress registration, lost password and comment forms and WooCommerce account registration. The trap field has its own name on every site, and when you are logged in as an admin each form shows a small note saying whether it is protected. Optionally, and off by default, doubtful submissions can also be checked by Akismet if your site uses it. Blocked submissions are listed so you can put back anything blocked by mistake. 39 39 * Verify your own domain from the plugin: the DNS records to add with copy buttons and live status, one-click setup through Cloudflare, a zone file to import, and the plugin switches to your domain by itself once verified. 40 40 * Alerts by Telegram and email: failing emails, quota nearly used up, rising bounces or spam reports, a plugin that stopped reporting, forms hit by bots, domain verified or failing. … … 54 54 This plugin connects to the DigiMail service, operated by DigiMail (digimail.vn). It is required: without it the plugin cannot send email, except through the optional backup SMTP server you configure yourself. 55 55 56 * **api.digimail.vn** — When you connect, the plugin sends your email address (quick start), the site URL and site name. Every time WordPress sends an email, the full message (recipients, subject, body, attachments, headers) and the name of the plugin that sent it are sent to DigiMail so it can be delivered. Twice a day the plugin sends a status check with the site URL and name, the plugin version, how many emails are waiting or failed on the site, and the spam guard's on/off state and counts of checked and blocked submissions, so DigiMail can warn you about mail that is not going out. Only if you turn on "Share diagnostics with DigiMail support" (off by default) does it also include the WordPress, PHP and WooCommerce versions, site language, multisite, a few of this plugin's settings and the names of other active email plugins. When you open the plugin screens, the plugin requests your send log, statistics and account status. If you turn on "Save form contacts to DigiMail", the email, name, phone and company that visitors enter in supported forms or at WooCommerce checkout, with the form name and page, are sent to DigiMail and added to your contact list. When a visitor signs up with one of this plugin's signup forms, the email, name and phone they type, the form's name, the page address, the chosen list and whether to send a confirmation email are sent to DigiMail; DigiMail adds them to your list or emails them a confirmation link. If you turn on "Shop emails" (off by default), each WooCommerce order (number, status, total, billing email and name, products with their picture and link, and whether the shopper ticked the newsletter checkbox) and, when a shopper types their email at checkout, the cart's products, total and that email are sent to DigiMail, so it can send the thank-you, abandoned cart and review emails you turn on and report the revenue they bring. Emails sent while an anonymous visitor submits a form are marked so DigiMail can check unfamiliar recipients before sending; if one of the recipients is the site's admin email, the message says so, so that address is not checked. The spam guard itself runs on your site and sends nothing to DigiMail .56 * **api.digimail.vn** — When you connect, the plugin sends your email address (quick start), the site URL and site name. Every time WordPress sends an email, the full message (recipients, subject, body, attachments, headers) and the name of the plugin that sent it are sent to DigiMail so it can be delivered. Twice a day the plugin sends a status check with the site URL and name, the plugin version, how many emails are waiting or failed on the site, and the spam guard's on/off state and counts of checked and blocked submissions, so DigiMail can warn you about mail that is not going out. Only if you turn on "Share diagnostics with DigiMail support" (off by default) does it also include the WordPress, PHP and WooCommerce versions, site language, multisite, a few of this plugin's settings and the names of other active email plugins. When you open the plugin screens, the plugin requests your send log, statistics and account status. If you turn on "Save form contacts to DigiMail", the email, name, phone and company that visitors enter in supported forms or at WooCommerce checkout, with the form name and page, are sent to DigiMail and added to your contact list. When a visitor signs up with one of this plugin's signup forms, the email, name and phone they type, the form's name, the page address, the chosen list and whether to send a confirmation email are sent to DigiMail; DigiMail adds them to your list or emails them a confirmation link. If you turn on "Shop emails" (off by default), each WooCommerce order (number, status, total, billing email and name, products with their picture and link, and whether the shopper ticked the newsletter checkbox) and, when a shopper types their email at checkout, the cart's products, total and that email are sent to DigiMail, so it can send the thank-you, abandoned cart and review emails you turn on and report the revenue they bring. Emails sent while an anonymous visitor submits a form are marked so DigiMail can check unfamiliar recipients before sending; if one of the recipients is the site's admin email, the message says so, so that address is not checked. The spam guard itself runs on your site and sends nothing to DigiMail; twice a day, while the guard is on, the plugin downloads from DigiMail the current list of Tor network exit addresses (DigiMail takes it from the Tor Project) and sends nothing with that request except its site key. 57 57 * **Cloudflare** (only if you choose *Add records in Cloudflare*) — The Cloudflare API token you paste is sent to DigiMail, stored encrypted, and used by DigiMail to add your domain's DNS records through the Cloudflare API. Cloudflare terms: https://www.cloudflare.com/website-terms/ — Privacy: https://www.cloudflare.com/privacypolicy/ 58 58 * **Telegram** (only if you connect Telegram alerts) — *Connect Telegram* opens t.me in your browser to start a chat with DigiMail's bot. The plugin sends nothing to Telegram; DigiMail's server sends the alerts. Telegram terms: https://telegram.org/tos — Privacy: https://telegram.org/privacy … … 121 121 == Changelog == 122 122 123 = 2.9.0 = 124 * Spam guard now protects WordPress registration, lost password and comment forms and WooCommerce account registration (can be turned off). Spam comments go to the Spam folder. 125 * Admins see a note under each form on the site: protected, not protected (form plugin not supported), or the guard could not get its token. 126 * The hidden trap field has its own name on each site. 127 * Catches bots that sign up with Gmail addresses full of random dots (bi.f.ewoy.oxu.s00.8@gmail.com), that send the same Gmail mailbox with different dots, or that come through the Tor network. 128 * Fix: the "same message from several visitors" check triggered one visitor too early. 129 123 130 = 2.8.0 = 124 131 * New Signup forms tab: popups, slide-ins, bars and in-page forms in four designs, with display rules, a live preview, optional double opt-in and views and signups for each form. … … 194 201 == Upgrade Notice == 195 202 203 = 2.9.0 = 204 Stronger spam guard: also protects registration, lost password and comments, blocks bots using Gmail addresses with random dots or Tor, and shows admins which forms are protected. 205 196 206 = 2.8.0 = 197 207 New Signup forms tab: popups, slide-ins, bars and in-page forms that add visitors to your DigiMail list. -
digimail-smtp/trunk/src/Guard.tsx
r3829755 r3831455 17 17 <Toggle checked={ g.enabled } onChange={ ( v ) => set( { enabled: v } ) } label={ __( 'Stop bots before the form sends any email', 'digimail-smtp' ) } 18 18 hint={ __( 'Invisible to visitors: no puzzle, nothing to click. Bot submissions are refused, so no notification or auto-reply goes out and nothing reaches your contact list. Works with Contact Form 7, WPForms, Elementor Pro, Fluent Forms, Gravity Forms, Ninja Forms, Formidable, Bricks and WooCommerce checkout.', 'digimail-smtp' ) } /> 19 { g.enabled && ( 20 <Toggle checked={ g.core } onChange={ ( v ) => set( { core: v } ) } label={ __( 'Also protect WordPress registration, lost password and comment forms', 'digimail-smtp' ) } 21 hint={ __( 'Bots use these forms to make your site email addresses they type in. Includes WooCommerce account registration. Logged-in users are never checked; spam comments go to the Spam folder.', 'digimail-smtp' ) } /> 22 ) } 23 { g.enabled && ( 24 <Toggle checked={ g.badge } onChange={ ( v ) => set( { badge: v } ) } label={ __( 'Show admins a note under each form', 'digimail-smtp' ) } 25 hint={ __( 'When you are logged in as an admin, each form on your site shows whether the spam guard protects it. Visitors never see it.', 'digimail-smtp' ) } /> 26 ) } 19 27 { g.enabled && ( 20 28 <Toggle checked={ g.akismet && sum.akismet } disabled={ ! sum.akismet } onChange={ ( v ) => set( { akismet: v } ) } label={ __( 'Also ask Akismet', 'digimail-smtp' ) } -
digimail-smtp/trunk/src/api.ts
r3830946 r3831455 46 46 controls: Record< string, boolean >; 47 47 capture: { enabled: boolean; forms: boolean; woocommerce: boolean }; 48 guard: { enabled: boolean; akismet: boolean };48 guard: { enabled: boolean; akismet: boolean; core: boolean; badge: boolean }; 49 49 keep_data: boolean; 50 50 diagnostics: boolean; … … 120 120 repeated: __( 'Same message from several visitors', 'digimail-smtp' ), 121 121 disposable_email: __( 'Throwaway email address', 'digimail-smtp' ), 122 dotted_gmail: __( 'Gmail address with random dots (bi.f.ewoy…@gmail.com)', 'digimail-smtp' ), 123 gmail_variants: __( 'Same Gmail mailbox sent with different dots', 'digimail-smtp' ), 124 tor: __( 'Sent through the Tor network', 'digimail-smtp' ), 122 125 blocklist: __( 'Matches the comment blocklist in Settings › Discussion', 'digimail-smtp' ), 123 126 akismet: __( 'Akismet says spam', 'digimail-smtp' ), … … 241 244 'ultimate-member': 'Ultimate Member', 242 245 'bricks': 'Bricks', 246 'wp-register': __( 'WordPress registration', 'digimail-smtp' ), 247 'wp-lostpassword': __( 'WordPress lost password', 'digimail-smtp' ), 248 'wp-comments': __( 'WordPress comments', 'digimail-smtp' ), 249 'woo-register': __( 'WooCommerce registration', 'digimail-smtp' ), 243 250 }; 244 251 if ( s.startsWith( 'theme:' ) ) { -
digimail-smtp/trunk/uninstall.php
r3830946 r3831455 17 17 global $wpdb; 18 18 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}digimail_smtp_queue" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 19 foreach ( array( 'digimail_smtp_settings', 'digimail_smtp_token', 'digimail_smtp_status', 'digimail_smtp_db', 'digimail_smtp_revoked', 'digimail_smtp_last_failure', 'digimail_smtp_imported', 'digimail_smtp_contacts', 'digimail_smtp_contacts_last', 'digimail_smtp_guard_log', 'digimail_smtp_guard_stats', 'digimail_smtp_guard_seen', 'digimail_smtp_guard_secret', 'digimail_smtp_guard_allow', 'digimail_smtp_ limit_hit', 'digimail_smtp_review', 'digimail_smtp_design', 'digimail_smtp_shop_events', 'digimail_smtp_shop_last', 'digimail_smtp_forms', 'digimail_smtp_form_stats' ) as $digimail_smtp_option ) {19 foreach ( array( 'digimail_smtp_settings', 'digimail_smtp_token', 'digimail_smtp_status', 'digimail_smtp_db', 'digimail_smtp_revoked', 'digimail_smtp_last_failure', 'digimail_smtp_imported', 'digimail_smtp_contacts', 'digimail_smtp_contacts_last', 'digimail_smtp_guard_log', 'digimail_smtp_guard_stats', 'digimail_smtp_guard_seen', 'digimail_smtp_guard_secret', 'digimail_smtp_guard_allow', 'digimail_smtp_guard_tor', 'digimail_smtp_limit_hit', 'digimail_smtp_review', 'digimail_smtp_design', 'digimail_smtp_shop_events', 'digimail_smtp_shop_last', 'digimail_smtp_forms', 'digimail_smtp_form_stats' ) as $digimail_smtp_option ) { 20 20 delete_option( $digimail_smtp_option ); 21 21 } … … 25 25 wp_clear_scheduled_hook( 'digimail_smtp_contacts' ); 26 26 wp_clear_scheduled_hook( 'digimail_smtp_shop' ); 27 wp_clear_scheduled_hook( 'digimail_smtp_guard_tor' );
Note:
See TracChangeset
for help on using the changeset viewer.