@kurtbruns/kestrel 1.21.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -1
- package/dist/public/dashboard/app.js +252 -252
- package/dist/public/dashboard/app.js.map +3 -3
- package/dist/public/dashboard/index.html +2 -2
- package/dist/public/dashboard/styles.css +64 -22
- package/dist/worker/index.js +117 -25
- package/docs/guides/07-upgrade.md +11 -9
- package/docs/publishing/06-troubleshooting.md +1 -0
- package/package.json +1 -1
- package/packages/kestrel/lib/oauth.mjs +6 -5
- package/template/claude/skills/upgrade/SKILL.md +4 -3
|
@@ -1,273 +1,273 @@
|
|
|
1
1
|
// GENERATED by scripts/build-client.mjs from client/ — edit the source there, never this file.
|
|
2
|
-
"use strict";(()=>{function ts(e){if(!e||typeof e!="object")return null;let t=e;return t.error!=="unauthorized"?null:t.reason==="access_not_configured"||t.reason==="access_unidentified"?t.reason:null}function _o(e){let t=document.getElementById(e);if(!t)throw new Error(`the admin page has no #${e}`);return t}var ue=_o("app"),To=_o("identity"),Lo=_o("toasts"),nr=document.getElementById("navToggle"),xo=document.getElementById("navScrim");function Ot(e){document.body.classList.toggle("nav-open",e),nr?.setAttribute("aria-expanded",e?"true":"false"),xo&&(xo.hidden=!e)}var pn=document.getElementById("navCollapse"),ko=null;function Yc(){return window.innerWidth<540?"full":ko==="collapsed"?"rail":ko==="expanded"?"full":window.innerWidth<=1024?"rail":"full"}function $o(){let e=Yc();if(document.documentElement.dataset.nav=e,!pn)return;let t=e!=="rail",n=t?"Collapse sidebar":"Expand sidebar";pn.setAttribute("aria-expanded",t?"true":"false"),pn.setAttribute("aria-label",n),pn.setAttribute("title",n)}var Eo=0,tr=0;function sr(){nr?.addEventListener("click",()=>Ot(!document.body.classList.contains("nav-open"))),xo?.addEventListener("click",()=>Ot(!1)),document.querySelector(".sidebar")?.addEventListener("click",e=>{e.target instanceof Element&&e.target.closest("a")&&Ot(!1)}),pn?.addEventListener("click",()=>{ko=document.documentElement.dataset.nav!=="rail"?"collapsed":"expanded",$o()}),window.addEventListener("resize",()=>{document.body.classList.add("nav-resizing"),clearTimeout(tr),tr=setTimeout(()=>{document.body.classList.remove("nav-resizing")},200),!Eo&&(Eo=requestAnimationFrame(()=>{Eo=0,$o()}))}),$o()}var ns=null,ss=null,os="Kestrel";function ie(e,t){e.aborted||(document.title=t.trim()?`${t} - ${os}`:os)}function ne(e){ns?.abort(),ss=null;let t=new AbortController;ns=t,document.title=os;let n=document.createElement("div");n.className="view",ue.replaceChildren(n);let s;try{s=Promise.resolve(e(n,t.signal))}catch(i){s=Promise.reject(i)}return s.then(i=>{!t.signal.aborted&&i&&(ss=i)},i=>{if(!t.signal.aborted)throw i})}function Dt(){ns?.abort(),ns=null,ss=null,document.title=os,ue.replaceChildren()}function mn(){return ss}function gt(e,t,n){if(n.aborted)return;let s=setInterval(t,e);n.addEventListener("abort",()=>clearInterval(s),{once:!0})}function vt(e,t,n){if(n.aborted)return;let s=()=>clearTimeout(i),i=setTimeout(()=>{n.removeEventListener("abort",s),t()},Math.max(0,e-Date.now()));n.addEventListener("abort",s,{once:!0})}function or(e,t,n){let s=()=>{if(n.aborted)return;let i=()=>clearTimeout(r),r=setTimeout(async()=>{n.removeEventListener("abort",i);let a=!0;try{a=await t()??!0}catch(l){Zc(l)||reportError(l)}a!==!1&&s()},e);n.addEventListener("abort",i,{once:!0})};s()}function Bt(e,t){if(e.aborted){t();return}e.addEventListener("abort",t,{once:!0})}function Zc(e){return e instanceof Error&&(e.name==="AbortError"||e.name==="ApiError")}function c(e,t=document){let n=t.querySelector(e);if(!n)throw new Error(`no element matches ${e}`);return n}function D(e,t=document){return[...t.querySelectorAll(e)]}var Jc={"&":"&","<":"<",">":">",'"':""","'":"'"};function te(e){return String(e).replace(/[&<>"']/g,t=>Jc[t]??t)}var yt=class{markup;constructor(t){this.markup=t,Object.freeze(this)}toString(){return this.markup}};function rr(e){return e instanceof yt?e.markup:e==null||e===!1?"":Array.isArray(e)?e.map(rr).join(""):te(e)}var Qc=/=\s*$/;function o(e,...t){let n=ir(e,0);for(let s=0;s<t.length;s++){let i=t[s];if(!(i instanceof yt)&&Qc.test(n))throw new Error("html: an interpolation in an unquoted attribute value cannot be made safe; quote it");n+=rr(i)+ir(e,s+1)}return new yt(n)}function ir(e,t){let n=e[t];if(n===void 0)throw new Error(`html: invalid escape sequence in template text near ${JSON.stringify(e.raw[t])}`);return n}function Y(e){return new yt(e)}function f(e,t){if(!(t instanceof yt))throw new Error("setHtml: expected Html; build it with html`\u2026` or vouch for it with unsafeHtml()");e.innerHTML=t.markup}var Xc="https://getkestrel.dev/docs/access/",ed="/cdn-cgi/access/logout";function is(e){if(ue.querySelector(".access-wall"))return;Dt(),document.body.classList.add("signed-out");let t=o`<p class="hint"><a href="${Xc}" target="_blank" rel="noopener">Lock the dashboard with Access <span aria-hidden="true">↗</span><span class="visually-hidden"> (opens in a new tab)</span></a></p>`;e==="access_unidentified"?(f(ue,o`<div class="card auth-wall access-wall" role="alert"><h2 tabindex="-1">Access let you in, but didn’t say who you are</h2><p>Cloudflare Access sent neither an email address nor a service token, and Kestrel needs one of them to tell who is asking, so it doesn’t let this sign-in in. Some other kind of Access policy, or a login method that gives no email, let it through.</p><p>Kestrel accepts two kinds of Access policy: an Allow policy on people’s emails, and a Service Auth policy on a service token. Sign out, then sign in through one of them.</p>${t}<button id="access-signout" class="primary">Sign out</button></div>`),c("#access-signout",ue).onclick=()=>location.assign(ed)):(f(ue,o`<div class="card auth-wall access-wall"><h2 tabindex="-1">The editor is locked until you set up Access</h2><p>Until Cloudflare Access is in front of the editor, the app can’t tell who is asking, so it lets no one in. On a new deployment, that’s expected. Your public pages work as usual.</p>${t}<button id="access-reload" class="primary">Reload</button></div>`),c("#access-reload",ue).onclick=()=>location.reload()),c(".access-wall h2",ue).focus()}var ar="Kestrel-Client",fn="editor",rs="claude-code",lr="kestrel-cli",as="claude";function ls(e){if(!e||typeof e!="object")return null;let t=e;return t.error==="schema_behind"&&typeof t.message=="string"?{message:t.message}:t.error!=="invalid_config"||typeof t.variable!="string"?null:{variable:t.variable,message:typeof t.message=="string"?t.message:`${t.variable} is refused`}}var td="https://getkestrel.dev/docs/configuration/",nd={PROVIDER:"vars",ALLOW_FAKE_PROVIDER:"vars",APP_ORIGIN:"vars",AWS_REGION:"vars",FROM_ADDRESS:"vars",SENDING_DOMAIN:"vars",ARCHIVE_BASE_PATH:"vars",SES_MAX_SEND_RATE:"vars",SUBREQUEST_BUDGET:"vars",MIN_LEAD_SECONDS:"vars",ARCHIVE_ORIGIN:"vars",MEDIA_PUBLIC_BASE:"vars",NOTIFY_FROM:"vars",ACCESS_TEAM_DOMAIN:"secrets",ACCESS_AUD:"secrets",ACCESS_ALLOWED_EMAILS:"secrets",AWS_ACCESS_KEY_ID:"secrets",AWS_SECRET_ACCESS_KEY:"secrets",SNS_TOPIC_ARN:"secrets",SES_CONFIGURATION_SET:"secrets",SIMULATE_SENDS:"what-the-app-refuses"},sd="what-the-app-refuses";function od(e){return`${td}#${nd[e]??sd}`}function cs(e){if(ue.querySelector(".config-wall"))return;Dt(),document.body.classList.add("signed-out");let{variable:t}=e,n=t?"A setting needs fixing":"The database needs updating",s=t?o`<p class="hint"><a href="${od(t)}" target="_blank" rel="noopener">${t} in the Configuration reference <span aria-hidden="true">↗</span><span class="visually-hidden"> (opens in a new tab)</span></a></p>`:"";f(ue,o`<div class="card auth-wall config-wall" role="alert"><h2 tabindex="-1">${n}</h2><p>Kestrel won’t run until it’s fixed, and nothing is sent in the meantime.</p><p class="config-wall-problem">${e.message}</p>${s}<button id="config-reload" class="primary">Reload</button></div>`),c("#config-reload",ue).onclick=()=>location.reload(),c(".config-wall h2",ue).focus()}var ds="kestrel_token",Z={token:localStorage.getItem(ds)||"",session:null,appConfig:null};function ur(e){Z.token=(e||"").trim();try{Z.token?localStorage.setItem(ds,Z.token):localStorage.removeItem(ds)}catch{}}function Ro(){return{[ar]:fn,...Z.token?{Authorization:`Bearer ${Z.token}`}:{}}}function pr(){let e=Z.session;if(e?.auth.mode==="access"){let t=e.principal,n=t.email||(t.kind==="service"?"Service token":"Signed in");f(To,o`<span class="who" title="${n}">${n}</span><a class="ghost" href="/cdn-cgi/access/logout" title="Sign out"><svg class="signout-icon" aria-hidden="true"><use href="#i-signout"/></svg><span class="signout-label">Sign out</span></a>`)}else f(To,o`<span class="who dev" title="Local dev: sign-in is skipped on localhost">Local dev</span>`)}function hn(){ue.querySelector(".reauth-wall")||(Dt(),document.body.classList.add("signed-out"),f(ue,o`<div class="card auth-wall reauth-wall"><h2 tabindex="-1">Session expired</h2><p class="hint">Your access session ended. Sign in again to continue.</p><button id="reauth" class="primary">Sign in</button></div>`),c("#reauth",ue).onclick=()=>location.reload(),c(".reauth-wall h2",ue).focus())}async function cr(){try{let e=await fetch("/api/dev/token?kind=human");if(e.ok)return ur((await e.json()).token),!0}catch{}return!1}async function dr(){try{return await fetch("/api/whoami",{headers:Ro(),redirect:"manual"})}catch{return null}}function id(e){let t=e;return typeof t?.principal=="object"&&t.principal!==null&&typeof t.auth=="object"}async function mr(){Z.token||await cr();let e=await dr();!e?.ok&&Z.token&&(ur(""),await cr()&&(e=await dr()));let t=e?await e.json().catch(()=>null):null;if(e?.ok&&id(t))return t;let n=ls(t),s=ts(t);return n?cs(n):s?is(s):hn(),null}var se=class extends Error{constructor(n,s,i=null){super(n);this.status=s;this.data=i;this.name="ApiError"}status;data;get code(){let n=this.data;return typeof n?.error=="string"?n.error:null}get field(){let n=this.data;return typeof n?.field=="string"?n.field:null}},rd="Not authorized. Sign in again.",ad=e=>/^[a-z_]+$/i.test(e.trim()),ld=/^(Failed to fetch|NetworkError when attempting to fetch resource\.?|Load failed|The network connection was lost\.?|The Internet connection appears to be offline\.?)$/;function Co(e){return e instanceof TypeError&&ld.test(e.message)}function z(e){if(e instanceof se){let t=e.data?.message;return typeof t=="string"&&!ad(t)?t:e.status===401?e.message:e.status===404?"It isn\u2019t there any more. It may have been deleted elsewhere.":e.status>=500?"Something went wrong on the server. Try again in a moment.":e.status===429?"Too many requests at once. Try again in a moment.":"The server couldn\u2019t do that. Reload the page and try again."}return Co(e)?"Couldn\u2019t reach Kestrel. Check your connection and try again.":e instanceof Error?e.message:String(e)}async function Ao(e,t){let n={...Ro(),...t.headers??{}},s=t.body;t.json!==void 0&&(n["content-type"]="application/json",s=JSON.stringify(t.json));let i=await fetch(e,{method:t.method??"GET",headers:n,body:s,signal:t.signal});if(i.status===401){let r=await i.json().catch(()=>null),a=ts(r);throw a?is(a):hn(),new se(rd,401,r)}return i}function cd(e){if(e&&typeof e=="object"){let t=e;if(typeof t.message=="string")return t.message;if(typeof t.error=="string")return t.error}}async function Ho(e){let t=await e.text(),n=null;try{n=t?JSON.parse(t):null}catch{}let s=ls(n);s&&cs(s);let i=e.statusText||`Request failed (HTTP ${e.status})`;return new se(cd(n)??i,e.status,n)}async function C(e,t={}){let n=await Ao(e,t);if(!n.ok)throw await Ho(n);let s=await n.text();return s?JSON.parse(s):null}async function Ut(e,t={}){let n=await Ao(e,t);if(!n.ok)throw await Ho(n);return n.text()}async function us(e,t={}){let n=await Ao(e,t);if(!n.ok)throw await Ho(n);let s=n.headers.get("content-disposition")??"",i=/filename="([^"]+)"/.exec(s)?.[1]??null;return{text:await n.text(),filename:i}}function Po(e){let t=e.trim(),n=t.lastIndexOf("<");if(n<0||!t.endsWith(">"))return"";let s=t.slice(0,n).trim();return s.length>=2&&s.startsWith('"')&&s.endsWith('"')?s.slice(1,-1).replace(/\\(.)/g,"$1").trim():s}function bn(e,t){return e||Po(t)}function Io(e){let t=e?.settings.publication;return{name:bn(t?.name||"",e?.deployment.from_address??"")||"Your publication",tagline:t?.tagline||"",logoUrl:t?.logo_url||null}}function ps(){let e=Io(Z.appConfig),t=document.getElementById("brandName"),n=document.getElementById("brandTagline"),s=document.getElementById("brandLogo");t&&(t.textContent=e.name),n&&(n.textContent=e.tagline,n.hidden=!e.tagline),s&&(e.logoUrl?(f(s,o`<img src="${e.logoUrl}" alt="">`),s.classList.remove("brand-logo-placeholder")):(s.textContent=(e.name.trim()[0]||"K").toUpperCase(),s.classList.add("brand-logo-placeholder")))}function fr(e,t,n){return`${e}${t}/${n}`}var dd=["content","invalid_request"];function Mo(e){return e!==null&&dd.includes(e)}var No={step:"Connect Amazon SES",guide:" (the setup guide walks through it)",after:", then deploy."};var hr="Amazon SES is still in the sandbox, so when this send fires it reaches only addresses verified in SES. It waits for the rest, and other sends wait behind it, until AWS grants production access, then finishes on its own.";var Yf=1800*1e3,ms=300*1e3,Zf=60*1e3,Jf=1440*60*1e3;function Ft(e){let t=Math.round(e/1e3);if(t%60===0){let n=t/60;return`${n} minute${n===1?"":"s"}`}return`${t} seconds`}function br(e){return`Pick a time at least ${Ft(e)} from now, so there\u2019s time to cancel.`}var Qf=10080*60*1e3,Xf=3600*1e3;function gr(){let e=Z.appConfig?.deployment.build;if(!e?.version)return null;let t=e.tag_url?o`<a class="build-link" href="${e.tag_url}" target="_blank" rel="noopener">v${e.version}</a>`:o`v${e.version}`,n=e.commit_url?o`<a class="build-link" href="${e.commit_url}" target="_blank" rel="noopener">${e.sha}</a>`:o`${e.sha}`;return{version:t,sha:n}}function fs(){return Z.appConfig?.deployment.min_lead_ms??ms}function hs(){return br(fs())}function vr(){let e=fs();if(e%6e4===0){let t=e/6e4;return`${t} to ${t+1} minutes`}return`${Ft(e)} to ${Ft(e+6e4)}`}function bs(e,t=Date.now()){return e<t+fs()}function gs(e=Date.now()){return new Date(e+fs()+6e4)}function gn(){return Z.appConfig?.deployment.provider==="fake"}function be(){return Z.appConfig?.deployment.provider==="none"}function ud(){return Z.appConfig?.deployment.free_plan_limits===!0}function pd(){return be()&&Z.appConfig?.deployment.not_connected_preview===!0}var Oo="#/docs/ses";function He(e){let t=e?o` class="${e}"`:null;return o`<a${t} href="${Oo}">${No.step}</a>`}function Do(){return pd()?o`Restart <code>npm run dev</code> without <code>SIMULATE_SENDS=not-connected</code> to send.`:o`${He()}${No.after}`}function vs(e,t){let n=t===1;return o`No email provider connected, so nothing can be sent and ${e} ${n?"is":"are"} held, with no one marked unsent; ${n?"it goes out at its":"they go out at their"} first retry once one is connected. ${Do()}`}function ys(e,t){return be()?o`<div class="health amber ${e}" role="status"><span class="health-dot">⚠️</span><div><span>${t}</span></div></div>`:null}function Ss(e){if(!be())return null;let t="Will be held: no email provider is connected.";return e==="card"?o`<div class="sched-held">${t}</div>`:o`<div class="sched-note sched-note-held"><span class="sched-note-mark" aria-hidden="true">⚠️</span><span class="sched-note-msg">${t}</span></div>`}function ws(e,t){return be()?o`<p class="hint not-connected">No email provider connected, so ${e}. ${He()}${t}.</p>`:null}function $s(){return ws("a test can\u2019t be sent yet"," to send one")}function yr(){return ws("a confirmation can\u2019t be sent yet"," to add subscribers")}function Bo(){return ud()&&!be()?o`<p class="hint daily-writes" id="schDailyWrites" role="status" hidden></p>`:null}function Uo(){return be()?null:o`<p class="hint daily-writes" id="schSandbox" role="status" hidden></p>`}function Sr(){return ws("this can\u2019t be scheduled yet"," to schedule it")}function wr(){return ws("this send is held when it fires, until one is"," to send it")}function qt(e){return gn()?`${e} (local stand-in: nothing is delivered)`:e}function $r(e){let t=Z.appConfig?.deployment;return t?fr(t.archive_origin,t.archive_base_path,e):null}var Er=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M280-280h280v-80H280v80Zm0-160h400v-80H280v80Zm0-160h400v-80H280v80Zm-80 480q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"/></svg>
|
|
3
|
-
`;var
|
|
4
|
-
`;var
|
|
5
|
-
`;var
|
|
6
|
-
`;var
|
|
7
|
-
`;var
|
|
8
|
-
`;var
|
|
9
|
-
`;var
|
|
10
|
-
`;var
|
|
11
|
-
`;var
|
|
12
|
-
`;var
|
|
13
|
-
`;var
|
|
14
|
-
`;var
|
|
15
|
-
`;var
|
|
16
|
-
`;var
|
|
17
|
-
`;var
|
|
18
|
-
`;var
|
|
19
|
-
`;var
|
|
20
|
-
`;var
|
|
21
|
-
`;var
|
|
22
|
-
`;var
|
|
23
|
-
`;var
|
|
24
|
-
`;var
|
|
25
|
-
`;var
|
|
26
|
-
`;var
|
|
27
|
-
`;var
|
|
28
|
-
`;var
|
|
29
|
-
`;var
|
|
30
|
-
`;var
|
|
31
|
-
`;var
|
|
32
|
-
`;var
|
|
33
|
-
`;var
|
|
34
|
-
`;var
|
|
35
|
-
`;var
|
|
2
|
+
"use strict";(()=>{function tr(e){return typeof e=="object"&&e?.error==="unauthorized"?e:null}function nr(e){return tr(e)?.dev_token_available===!0}function ns(e){let t=tr(e)?.reason;return t==="access_not_configured"||t==="access_unidentified"?t:null}function _o(e){let t=document.getElementById(e);if(!t)throw new Error(`the admin page has no #${e}`);return t}var ue=_o("app"),To=_o("identity"),Lo=_o("toasts"),or=document.getElementById("navToggle"),xo=document.getElementById("navScrim");function Dt(e){document.body.classList.toggle("nav-open",e),or?.setAttribute("aria-expanded",e?"true":"false"),xo&&(xo.hidden=!e)}var mn=document.getElementById("navCollapse"),ko=null;function Zc(){return window.innerWidth<540?"full":ko==="collapsed"?"rail":ko==="expanded"?"full":window.innerWidth<=1024?"rail":"full"}function $o(){let e=Zc();if(document.documentElement.dataset.nav=e,!mn)return;let t=e!=="rail",n=t?"Collapse sidebar":"Expand sidebar";mn.setAttribute("aria-expanded",t?"true":"false"),mn.setAttribute("aria-label",n),mn.setAttribute("title",n)}var Eo=0,sr=0;function ir(){or?.addEventListener("click",()=>Dt(!document.body.classList.contains("nav-open"))),xo?.addEventListener("click",()=>Dt(!1)),document.querySelector(".sidebar")?.addEventListener("click",e=>{e.target instanceof Element&&e.target.closest("a")&&Dt(!1)}),mn?.addEventListener("click",()=>{ko=document.documentElement.dataset.nav!=="rail"?"collapsed":"expanded",$o()}),window.addEventListener("resize",()=>{document.body.classList.add("nav-resizing"),clearTimeout(sr),sr=setTimeout(()=>{document.body.classList.remove("nav-resizing")},200),!Eo&&(Eo=requestAnimationFrame(()=>{Eo=0,$o()}))}),$o()}var ss=null,os=null,is="Kestrel";function ie(e,t){e.aborted||(document.title=t.trim()?`${t} - ${is}`:is)}function ne(e){ss?.abort(),os=null;let t=new AbortController;ss=t,document.title=is;let n=document.createElement("div");n.className="view",ue.replaceChildren(n);let s;try{s=Promise.resolve(e(n,t.signal))}catch(i){s=Promise.reject(i)}return s.then(i=>{!t.signal.aborted&&i&&(os=i)},i=>{if(!t.signal.aborted)throw i})}function Bt(){ss?.abort(),ss=null,os=null,document.title=is,ue.replaceChildren()}function fn(){return os}function vt(e,t,n){if(n.aborted)return;let s=setInterval(t,e);n.addEventListener("abort",()=>clearInterval(s),{once:!0})}function yt(e,t,n){if(n.aborted)return;let s=()=>clearTimeout(i),i=setTimeout(()=>{n.removeEventListener("abort",s),t()},Math.max(0,e-Date.now()));n.addEventListener("abort",s,{once:!0})}function rr(e,t,n){let s=()=>{if(n.aborted)return;let i=()=>clearTimeout(r),r=setTimeout(async()=>{n.removeEventListener("abort",i);let a=!0;try{a=await t()??!0}catch(l){Jc(l)||reportError(l)}a!==!1&&s()},e);n.addEventListener("abort",i,{once:!0})};s()}function it(e,t){if(e.aborted){t();return}e.addEventListener("abort",t,{once:!0})}function Jc(e){return e instanceof Error&&(e.name==="AbortError"||e.name==="ApiError")}function c(e,t=document){let n=t.querySelector(e);if(!n)throw new Error(`no element matches ${e}`);return n}function B(e,t=document){return[...t.querySelectorAll(e)]}var Qc={"&":"&","<":"<",">":">",'"':""","'":"'"};function te(e){return String(e).replace(/[&<>"']/g,t=>Qc[t]??t)}var St=class{markup;constructor(t){this.markup=t,Object.freeze(this)}toString(){return this.markup}};function lr(e){return e instanceof St?e.markup:e==null||e===!1?"":Array.isArray(e)?e.map(lr).join(""):te(e)}var Xc=/=\s*$/;function o(e,...t){let n=ar(e,0);for(let s=0;s<t.length;s++){let i=t[s];if(!(i instanceof St)&&Xc.test(n))throw new Error("html: an interpolation in an unquoted attribute value cannot be made safe; quote it");n+=lr(i)+ar(e,s+1)}return new St(n)}function ar(e,t){let n=e[t];if(n===void 0)throw new Error(`html: invalid escape sequence in template text near ${JSON.stringify(e.raw[t])}`);return n}function Y(e){return new St(e)}function f(e,t){if(!(t instanceof St))throw new Error("setHtml: expected Html; build it with html`\u2026` or vouch for it with unsafeHtml()");e.innerHTML=t.markup}var ed="https://getkestrel.dev/docs/access/",td="/cdn-cgi/access/logout";function rs(e){if(ue.querySelector(".access-wall"))return;Bt(),document.body.classList.add("signed-out");let t=o`<p class="hint"><a href="${ed}" target="_blank" rel="noopener">Lock the dashboard with Access <span aria-hidden="true">↗</span><span class="visually-hidden"> (opens in a new tab)</span></a></p>`;e==="access_unidentified"?(f(ue,o`<div class="card auth-wall access-wall" role="alert"><h2 tabindex="-1">Access let you in, but didn’t say who you are</h2><p>Cloudflare Access sent neither an email address nor a service token, and Kestrel needs one of them to tell who is asking, so it doesn’t let this sign-in in. Some other kind of Access policy, or a login method that gives no email, let it through.</p><p>Kestrel accepts two kinds of Access policy: an Allow policy on people’s emails, and a Service Auth policy on a service token. Sign out, then sign in through one of them.</p>${t}<button id="access-signout" class="primary">Sign out</button></div>`),c("#access-signout",ue).onclick=()=>location.assign(td)):(f(ue,o`<div class="card auth-wall access-wall"><h2 tabindex="-1">The editor is locked until you set up Access</h2><p>Until Cloudflare Access is in front of the editor, the app can’t tell who is asking, so it lets no one in. On a new deployment, that’s expected. Your public pages work as usual.</p>${t}<button id="access-reload" class="primary">Reload</button></div>`),c("#access-reload",ue).onclick=()=>location.reload()),c(".access-wall h2",ue).focus()}var cr="Kestrel-Client",hn="editor",as="claude-code",dr="kestrel-cli",ls="claude";function cs(e){if(!e||typeof e!="object")return null;let t=e;return t.error==="schema_behind"&&typeof t.message=="string"?{message:t.message}:t.error!=="invalid_config"||typeof t.variable!="string"?null:{variable:t.variable,message:typeof t.message=="string"?t.message:`${t.variable} is refused`}}var nd="https://getkestrel.dev/docs/configuration/",sd={PROVIDER:"vars",ALLOW_FAKE_PROVIDER:"vars",APP_ORIGIN:"vars",AWS_REGION:"vars",FROM_ADDRESS:"vars",SENDING_DOMAIN:"vars",ARCHIVE_BASE_PATH:"vars",SES_MAX_SEND_RATE:"vars",SUBREQUEST_BUDGET:"vars",MIN_LEAD_SECONDS:"vars",ARCHIVE_ORIGIN:"vars",MEDIA_PUBLIC_BASE:"vars",NOTIFY_FROM:"vars",ACCESS_TEAM_DOMAIN:"secrets",ACCESS_AUD:"secrets",ACCESS_ALLOWED_EMAILS:"secrets",AWS_ACCESS_KEY_ID:"secrets",AWS_SECRET_ACCESS_KEY:"secrets",SNS_TOPIC_ARN:"secrets",SES_CONFIGURATION_SET:"secrets",SIMULATE_SENDS:"what-the-app-refuses"},od="what-the-app-refuses";function id(e){return`${nd}#${sd[e]??od}`}function ds(e){if(ue.querySelector(".config-wall"))return;Bt(),document.body.classList.add("signed-out");let{variable:t}=e,n=t?"A setting needs fixing":"The database needs updating",s=t?o`<p class="hint"><a href="${id(t)}" target="_blank" rel="noopener">${t} in the Configuration reference <span aria-hidden="true">↗</span><span class="visually-hidden"> (opens in a new tab)</span></a></p>`:"";f(ue,o`<div class="card auth-wall config-wall" role="alert"><h2 tabindex="-1">${n}</h2><p>Kestrel won’t run until it’s fixed, and nothing is sent in the meantime.</p><p class="config-wall-problem">${e.message}</p>${s}<button id="config-reload" class="primary">Reload</button></div>`),c("#config-reload",ue).onclick=()=>location.reload(),c(".config-wall h2",ue).focus()}var us="kestrel_token",Z={token:localStorage.getItem(us)||"",session:null,appConfig:null};function pr(e){Z.token=(e||"").trim();try{Z.token?localStorage.setItem(us,Z.token):localStorage.removeItem(us)}catch{}}function Ro(){return{[cr]:hn,...Z.token?{Authorization:`Bearer ${Z.token}`}:{}}}function mr(){let e=Z.session;if(e?.auth.mode==="access"){let t=e.principal,n=t.email||(t.kind==="service"?"Service token":"Signed in");f(To,o`<span class="who" title="${n}">${n}</span><a class="ghost" href="/cdn-cgi/access/logout" title="Sign out"><svg class="signout-icon" aria-hidden="true"><use href="#i-signout"/></svg><span class="signout-label">Sign out</span></a>`)}else f(To,o`<span class="who dev" title="Local dev: sign-in is skipped on localhost">Local dev</span>`)}function bn(){ue.querySelector(".reauth-wall")||(Bt(),document.body.classList.add("signed-out"),f(ue,o`<div class="card auth-wall reauth-wall"><h2 tabindex="-1">Session expired</h2><p class="hint">Your access session ended. Sign in again to continue.</p><button id="reauth" class="primary">Sign in</button></div>`),c("#reauth",ue).onclick=()=>location.reload(),c(".reauth-wall h2",ue).focus())}async function rd(){try{let e=await fetch("/api/dev/token?kind=human");if(e.ok){let{token:t}=await e.json();if(typeof t=="string"&&t)return pr(t),!0}}catch{}return!1}async function ur(){try{let e=await fetch("/api/whoami",{headers:Ro(),redirect:"manual"});return{ok:e.ok,data:await e.json().catch(()=>null)}}catch{return{ok:!1,data:null}}}function ad(e){let t=e;return typeof t?.principal=="object"&&t.principal!==null&&typeof t.auth=="object"}async function fr(){let{ok:e,data:t}=await ur();if(!e&&nr(t)&&(pr(""),await rd()&&({ok:e,data:t}=await ur())),e&&ad(t))return t;let n=cs(t),s=ns(t);return n?ds(n):s?rs(s):bn(),null}var se=class extends Error{constructor(n,s,i=null){super(n);this.status=s;this.data=i;this.name="ApiError"}status;data;get code(){let n=this.data;return typeof n?.error=="string"?n.error:null}get field(){let n=this.data;return typeof n?.field=="string"?n.field:null}},ld="Not authorized. Sign in again.",cd=e=>/^[a-z_]+$/i.test(e.trim()),dd=/^(Failed to fetch|NetworkError when attempting to fetch resource\.?|Load failed|The network connection was lost\.?|The Internet connection appears to be offline\.?)$/;function Co(e){return e instanceof TypeError&&dd.test(e.message)}function z(e){if(e instanceof se){let t=e.data?.message;return typeof t=="string"&&!cd(t)?t:e.status===401?e.message:e.status===404?"It isn\u2019t there any more. It may have been deleted elsewhere.":e.status>=500?"Something went wrong on the server. Try again in a moment.":e.status===429?"Too many requests at once. Try again in a moment.":"The server couldn\u2019t do that. Reload the page and try again."}return Co(e)?"Couldn\u2019t reach Kestrel. Check your connection and try again.":e instanceof Error?e.message:String(e)}async function Ao(e,t){let n={...Ro(),...t.headers??{}},s=t.body;t.json!==void 0&&(n["content-type"]="application/json",s=JSON.stringify(t.json));let i=await fetch(e,{method:t.method??"GET",headers:n,body:s,signal:t.signal});if(i.status===401){let r=await i.json().catch(()=>null),a=ns(r);throw a?rs(a):bn(),new se(ld,401,r)}return i}function ud(e){if(e&&typeof e=="object"){let t=e;if(typeof t.message=="string")return t.message;if(typeof t.error=="string")return t.error}}async function Ho(e){let t=await e.text(),n=null;try{n=t?JSON.parse(t):null}catch{}let s=cs(n);s&&ds(s);let i=e.statusText||`Request failed (HTTP ${e.status})`;return new se(ud(n)??i,e.status,n)}async function C(e,t={}){let n=await Ao(e,t);if(!n.ok)throw await Ho(n);let s=await n.text();return s?JSON.parse(s):null}async function Ut(e,t={}){let n=await Ao(e,t);if(!n.ok)throw await Ho(n);return n.text()}async function ps(e,t={}){let n=await Ao(e,t);if(!n.ok)throw await Ho(n);let s=n.headers.get("content-disposition")??"",i=/filename="([^"]+)"/.exec(s)?.[1]??null;return{text:await n.text(),filename:i}}function Po(e){let t=e.trim(),n=t.lastIndexOf("<");if(n<0||!t.endsWith(">"))return"";let s=t.slice(0,n).trim();return s.length>=2&&s.startsWith('"')&&s.endsWith('"')?s.slice(1,-1).replace(/\\(.)/g,"$1").trim():s}function gn(e,t){return e||Po(t)}function Io(e){let t=e?.settings.publication;return{name:gn(t?.name||"",e?.deployment.from_address??"")||"Your publication",tagline:t?.tagline||"",logoUrl:t?.logo_url||null}}function ms(){let e=Io(Z.appConfig),t=document.getElementById("brandName"),n=document.getElementById("brandTagline"),s=document.getElementById("brandLogo");t&&(t.textContent=e.name),n&&(n.textContent=e.tagline,n.hidden=!e.tagline),s&&(e.logoUrl?(f(s,o`<img src="${e.logoUrl}" alt="">`),s.classList.remove("brand-logo-placeholder")):(s.textContent=(e.name.trim()[0]||"K").toUpperCase(),s.classList.add("brand-logo-placeholder")))}function hr(e,t,n){return`${e}${t}/${n}`}var pd=["content","invalid_request"];function Mo(e){return e!==null&&pd.includes(e)}var No={step:"Connect Amazon SES",guide:" (the setup guide walks through it)",after:", then deploy."};var br="Amazon SES is still in the sandbox, so when this send fires it reaches only addresses verified in SES. It waits for the rest, and other sends wait behind it, until AWS grants production access, then finishes on its own.";var Jf=1800*1e3,fs=300*1e3,Qf=60*1e3,Xf=1440*60*1e3;function Ft(e){let t=Math.round(e/1e3);if(t%60===0){let n=t/60;return`${n} minute${n===1?"":"s"}`}return`${t} seconds`}function gr(e){return`Pick a time at least ${Ft(e)} from now, so there\u2019s time to cancel.`}var eh=10080*60*1e3,th=3600*1e3;function vr(){let e=Z.appConfig?.deployment.build;if(!e?.version)return null;let t=e.tag_url?o`<a class="build-link" href="${e.tag_url}" target="_blank" rel="noopener">v${e.version}</a>`:o`v${e.version}`,n=e.commit_url?o`<a class="build-link" href="${e.commit_url}" target="_blank" rel="noopener">${e.sha}</a>`:o`${e.sha}`;return{version:t,sha:n}}function hs(){return Z.appConfig?.deployment.min_lead_ms??fs}function bs(){return gr(hs())}function yr(){let e=hs();if(e%6e4===0){let t=e/6e4;return`${t} to ${t+1} minutes`}return`${Ft(e)} to ${Ft(e+6e4)}`}function gs(e,t=Date.now()){return e<t+hs()}function vs(e=Date.now()){return new Date(e+hs()+6e4)}function vn(){return Z.appConfig?.deployment.provider==="fake"}function be(){return Z.appConfig?.deployment.provider==="none"}function md(){return Z.appConfig?.deployment.free_plan_limits===!0}function fd(){return be()&&Z.appConfig?.deployment.not_connected_preview===!0}var Oo="#/docs/ses";function He(e){let t=e?o` class="${e}"`:null;return o`<a${t} href="${Oo}">${No.step}</a>`}function Do(){return fd()?o`Restart <code>npm run dev</code> without <code>SIMULATE_SENDS=not-connected</code> to send.`:o`${He()}${No.after}`}function ys(e,t){let n=t===1;return o`No email provider connected, so nothing can be sent and ${e} ${n?"is":"are"} held, with no one marked unsent; ${n?"it goes out at its":"they go out at their"} first retry once one is connected. ${Do()}`}function Ss(e,t){return be()?o`<div class="health amber ${e}" role="status"><span class="health-dot">⚠️</span><div><span>${t}</span></div></div>`:null}function ws(e){if(!be())return null;let t="Will be held: no email provider is connected.";return e==="card"?o`<div class="sched-held">${t}</div>`:o`<div class="sched-note sched-note-held"><span class="sched-note-mark" aria-hidden="true">⚠️</span><span class="sched-note-msg">${t}</span></div>`}function $s(e,t){return be()?o`<p class="hint not-connected">No email provider connected, so ${e}. ${He()}${t}.</p>`:null}function Es(){return $s("a test can\u2019t be sent yet"," to send one")}function Sr(){return $s("a confirmation can\u2019t be sent yet"," to add subscribers")}function Bo(){return md()&&!be()?o`<p class="hint daily-writes" id="schDailyWrites" role="status" hidden></p>`:null}function Uo(){return be()?null:o`<p class="hint daily-writes" id="schSandbox" role="status" hidden></p>`}function wr(){return $s("this can\u2019t be scheduled yet"," to schedule it")}function $r(){return $s("this send is held when it fires, until one is"," to send it")}function qt(e){return vn()?`${e} (local stand-in: nothing is delivered)`:e}function Er(e){let t=Z.appConfig?.deployment;return t?hr(t.archive_origin,t.archive_base_path,e):null}var xr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M280-280h280v-80H280v80Zm0-160h400v-80H280v80Zm0-160h400v-80H280v80Zm-80 480q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"/></svg>
|
|
3
|
+
`;var kr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"/></svg>
|
|
4
|
+
`;var _r=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z"/><path d="M4 21V5"/><path d="M9 8h6"/></svg>
|
|
5
|
+
`;var Tr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3v8a4 4 0 0 0 4 4h8"/><path d="m14 11 4 4-4 4"/></svg>
|
|
6
|
+
`;var Lr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>
|
|
7
|
+
`;var Rr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="m8 12 3 3 5-6"/></svg>
|
|
8
|
+
`;var Cr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M8 12h8"/></svg>
|
|
9
|
+
`;var Ar=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z"/></svg>
|
|
10
|
+
`;var Hr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="8" y="8" width="13" height="13" rx="2"/><path d="M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3"/></svg>
|
|
11
|
+
`;var Pr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8"/><path d="M12 16v4"/></svg>
|
|
12
|
+
`;var Ir=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z"/></svg>
|
|
13
|
+
`;var Mr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M360-280v-400h80v160h160v-160h80v400h-80v-160H440v160h-80Z"/></svg>
|
|
14
|
+
`;var Nr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"/></svg>
|
|
15
|
+
`;var Or=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M12 16v-4M12 8h.01"/></svg>
|
|
16
|
+
`;var Dr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M440-280h80v-240h-80v240Zm68.5-331.5Q520-623 520-640t-11.5-28.5Q497-680 480-680t-28.5 11.5Q440-657 440-640t11.5 28.5Q463-600 480-600t28.5-11.5ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>
|
|
17
|
+
`;var Br=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"/></svg>
|
|
18
|
+
`;var Ur=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" aria-hidden="true"><path d="M290.028 216.064C285.698 218.264 280.838 219.394 275.978 219.344C281.268 225.044 284.128 232.924 283.708 240.694C283.278 248.844 279.388 256.514 274.268 262.874C269.148 269.244 262.808 274.494 256.608 279.814C237.148 296.474 218.248 314.404 195.328 325.854C178.568 334.224 160.148 338.864 143.458 347.374C140.148 349.064 136.898 350.904 133.418 352.224C129.938 353.544 126.178 354.324 122.498 353.794C121.718 353.684 120.938 353.504 120.228 353.184C119.508 352.864 118.848 352.374 118.408 351.734C117.918 351.024 117.708 350.154 117.718 349.304C117.728 348.454 117.948 347.614 118.268 346.824C118.567 346.054 118.967 345.339 119.371 344.618L119.418 344.534C128.788 327.894 140.118 312.454 150.358 296.344C160.598 280.224 169.848 263.174 174.428 244.634C176.258 237.264 177.328 229.644 176.738 222.074C176.138 214.504 173.808 206.964 169.308 200.854C164.588 194.434 157.728 189.874 150.538 186.434C139.628 181.204 127.768 178.284 115.858 176.154C93.9183 172.224 71.6083 170.884 49.4083 168.944C45.8483 168.634 42.2483 168.294 38.8783 167.124C34.7683 165.704 31.0683 163.004 28.7383 159.334C26.4183 155.664 25.5583 151.024 26.7483 146.844C27.6583 143.624 29.7283 140.784 32.3583 138.724C34.9883 136.654 38.1683 135.324 41.4383 134.634C44.7183 133.944 48.0983 133.874 51.4383 134.154C53.2683 134.304 55.0883 134.554 56.8983 134.824C72.2383 137.094 87.3783 140.484 102.548 143.644C115.468 146.334 128.498 148.864 141.688 149.224C154.878 149.574 168.338 147.654 180.178 141.824C196.548 133.764 208.758 118.514 215.298 101.474C224.258 78.094 223.028 52.174 220.398 27.284C219.788 21.484 219.108 15.614 220.058 9.854C220.178 9.124 220.328 8.38398 220.658 7.71398C220.988 7.05398 221.528 6.45399 222.228 6.19399C222.858 5.95399 223.568 6.01399 224.218 6.22399C224.858 6.43399 225.448 6.77399 226.028 7.12399C262.588 29.154 290.508 63.614 310.198 101.484C312.188 105.314 314.108 109.204 315.408 113.314C316.708 117.434 317.358 121.814 316.768 126.084C316.348 129.114 315.268 132.104 313.318 134.454C310.668 137.634 306.688 139.354 302.778 140.744C298.878 142.124 294.808 143.324 291.488 145.804C286.998 149.174 284.328 154.834 284.598 160.444C292.098 161.904 299.448 164.114 306.508 167.014C312.788 169.594 318.998 172.854 323.418 178.014C327.088 182.294 329.288 187.614 331.438 192.844C332.158 194.584 332.878 196.344 333.328 198.184C333.778 200.014 333.958 201.944 333.578 203.794C333.138 205.934 331.948 207.914 330.248 209.294C329.898 208.024 329.258 206.834 328.408 205.834C326.958 204.154 324.928 203.054 322.798 202.454C318.258 201.174 313.328 202.114 309.018 204.044C304.708 205.974 300.898 208.834 297.068 211.584C294.808 213.204 292.508 214.804 290.028 216.064Z"/></svg>
|
|
19
|
+
`;var Fr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6h11M9 12h11M9 18h11M4 6h1M4 12h1M4 18h1"/></svg>
|
|
20
|
+
`;var qr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"/></svg>
|
|
21
|
+
`;var jr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg>
|
|
22
|
+
`;var Vr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"/></svg>
|
|
23
|
+
`;var Wr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M720-330q0 104-73 177T470-80q-104 0-177-73t-73-177v-370q0-75 52.5-127.5T400-880q75 0 127.5 52.5T580-700v350q0 46-32 78t-78 32q-46 0-78-32t-32-78v-370h80v370q0 13 8.5 21.5T470-320q13 0 21.5-8.5T500-350v-350q-1-42-29.5-71T400-800q-42 0-71 29t-29 71v370q-1 71 49 120.5T470-160q70 0 119-49.5T640-330v-390h80v390Z"/></svg>
|
|
24
|
+
`;var Kr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="2" width="10" height="20" rx="2"/><path d="M11 18h2"/></svg>
|
|
25
|
+
`;var Gr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></svg>
|
|
26
|
+
`;var zr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
|
|
27
|
+
`;var Yr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM362.5-517.5Q380-535 380-560t-17.5-42.5Q345-620 320-620t-42.5 17.5Q260-585 260-560t17.5 42.5Q295-500 320-500t42.5-17.5Zm360 0Q740-535 740-560t-17.5-42.5Q705-620 680-620t-42.5 17.5Q620-585 620-560t17.5 42.5Q655-500 680-500t42.5-17.5ZM680-560Zm-360 0Z"/></svg>
|
|
28
|
+
`;var Zr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="11" width="16" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg>
|
|
29
|
+
`;var Jr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><circle cx="11" cy="11" r="6.5"/><path d="m20 20-4.2-4.2"/></svg>
|
|
30
|
+
`;var Qr=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 3 11 14M22 3l-7 18-4-7-7-4 18-7z"/></svg>
|
|
31
|
+
`;var Xr=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"/></svg>
|
|
32
|
+
`;var ea=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true"><path d="M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"/></svg>
|
|
33
|
+
`;var ta=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 16V4M8 8l4-4 4 4"/><path d="M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"/></svg>
|
|
34
|
+
`;var na=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"/></svg>
|
|
35
|
+
`;var zd={article:Y(xr),bold:Y(kr),check:Y(Lr),code:Y(Ar),copyout:Y(Hr),editable:Y(Ir),heading:Y(Mr),indent:Y(Nr),info:Y(Or),"info-filled":Y(Dr),italic:Y(Br),kestrel:Y(Ur),lines:Y(Fr),link:Y(qr),ol:Y(Vr),paperclip:Y(Wr),plus:Y(Gr),preview:Y(zr),quote:Y(Yr),readonly:Y(Zr),search:Y(Jr),send:Y(Qr),settings:Y(Xr),ul:Y(ea),upload:Y(ta),book:Y(_r),branch:Y(Tr),"circle-check":Y(Rr),"circle-minus":Y(Cr),desktop:Y(Pr),mail:Y(jr),phone:Y(Kr),x:Y(na)};function D(e){return zd[e]}function jt(e,t,n){let s=(g,h)=>e===g?o`<a href="#/${g}" data-room="${g}" data-text="${h}" aria-current="page">${h}</a>`:o`<a href="#/${g}" data-room="${g}" data-text="${h}">${h}</a>`,i=vr(),r=Z.appConfig?.deployment.build.build_time,a=r?`Built ${new Date(r).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}`:null,l=i?o`${i.version} <span aria-hidden="true">·</span> ${i.sha}`:null,d=l?a?o`<div class="rail-foot" title="${a}">${l}</div>`:o`<div class="rail-foot">${l}</div>`:null,u=l?a?o`<footer class="room-foot" title="${a}">${l}</footer>`:o`<footer class="room-foot">${l}</footer>`:null,p=t==null?o`<div class="room-body norail"><div class="room-main">${n}</div></div>`:o`<div class="room-body"><nav class="room-rail" aria-label="Contents"><div class="rail-inner">${t}${d}</div></nav><div class="room-main">${n}</div></div>`;return o`<div class="room">
|
|
36
36
|
<header class="room-bar">
|
|
37
37
|
<a class="room-back" href="#/dashboard" aria-label="Back to dashboard"><span aria-hidden="true">←</span><span class="room-back-label">Dashboard</span></a>
|
|
38
38
|
<div class="room-nav">
|
|
39
|
-
<a class="room-brand" href="#/docs">${
|
|
39
|
+
<a class="room-brand" href="#/docs">${D("kestrel")}<span>Kestrel</span></a>
|
|
40
40
|
<nav class="room-switch" aria-label="Reference">${s("docs","Docs")}${s("api-reference","API")}</nav>
|
|
41
41
|
<a class="room-close" href="#/dashboard" title="Back to publication" aria-label="Back to publication"><span aria-hidden="true">✕</span></a>
|
|
42
42
|
</div>
|
|
43
43
|
</header>
|
|
44
44
|
${p}
|
|
45
45
|
${u}
|
|
46
|
-
</div>`}function
|
|
46
|
+
</div>`}function sa(){ue.addEventListener("click",e=>{let t=e.target instanceof Element?e.target.closest(".room-bar a[href^='#/']"):null;!t||t.getAttribute("href")!==location.hash||(e.preventDefault(),window.scrollTo(0,0))})}var Yd=/^(\/[A-Za-z0-9._~%-]+)+$/,Zd=/\/(?:\.|%2e){1,2}(?=\/|$)/i;function yn(e){return Yd.test(e)&&!Zd.test(e)}function oa(e){let t=new URLSearchParams(e).get("to");return t&&yn(t)?`#${t}`:null}var ia={"publication-identity":"Publication identity","ways-to-subscribe":"Ways to subscribe","confirmation-email":"Confirmation email","reader-pages":"Reader pages","email-template":"Email template","default-test-recipients":"Default test recipients",notifications:"Notifications","email-sender":"Email sender",instance:"Instance"},Jd=Object.keys(ia);function ra(e){return ia[e]}function Vt(e){return`/settings/${e}`}function Fo(e){return Jd.includes(e)}var aa="You\u2019ve added a mailing address in Settings, but this template doesn\u2019t include the {{ .Publication.Address }} field. If you send promotional email, add it to the footer. If you\u2019ve written your address into the template yourself, or don\u2019t need to provide one, you can ignore this or remove the address in Settings.",xs=5;function la(e,t){return e.length===1&&t.length===1?t[0]?.error??"":t.map(n=>`${n.email}: ${n.error}`).join("; ")}var Qd=/^(\d+)\.(\d+)$/;function Xd(e){return`${e.seq}.${e.at}`}function ca(e){let t=Qd.exec(e);if(!t?.[1]||!t[2])return null;let n=Number(t[1]),s=Number(t[2]);return Number.isSafeInteger(n)&&Number.isSafeInteger(s)?{seq:n,at:s}:null}function ks(e,t){let n=ca(e),s=ca(t);return!n||!s?n?e:t:Xd({seq:Math.min(n.seq,s.seq),at:Math.min(n.at,s.at)})}function at(e){switch(e.status){case"scheduled":return e.phase==="due"?"due":"scheduled";case"sending":return"sending";case"sent":return e.phase==="complete"?"complete":"sent";default:return"canceled"}}var eu=3e3,tu=6e4,nu=3e4,Be=new Set,_s=null,wt=null,Ze,rt=null,Sn=!1,qo=!1,Ts=0;function Ls(e){try{e()}catch(t){reportError(t)}}function jo(e,t){return e&&t?ks(e,t):e??t}function da(e){clearTimeout(Ze),Ze=void 0,!(!Be.size||document.hidden)&&(Ze=setTimeout(wn,e))}function wn(){if(clearTimeout(Ze),Ze=void 0,!Be.size)return;if(rt){Sn=!0;return}let e=jo(_s,wt);wt=null;let t=[...Be],n=new AbortController;rt=n;let s=setTimeout(()=>n.abort(),nu),i=e?`?since=${encodeURIComponent(e)}`:"";C(`/api/sends/feed${i}`,{signal:n.signal}).then(r=>{if(clearTimeout(s),rt===n){rt=null,Ts=0,_s=r.cursor;for(let a of t)Be.has(a)&&a.take(r);if(Sn){Sn=!1,wn();return}da(Math.max(0,r.read_again_at-r.now))}},r=>{if(clearTimeout(s),rt===n){if(rt=null,Sn=!1,r instanceof se&&r.code==="cursor_ahead"){let a=[...Be];for(let l of a)ma(l);for(let l of a)Ls(()=>l.stale());return}r instanceof se&&r.status===400?_s=null:wt=jo(wt,e),Ts+=1,da(Math.min(eu*2**(Ts-1),tu))}})}function su(){qo||(qo=!0,queueMicrotask(()=>{qo=!1,wn()}))}function ua(){document.hidden?(clearTimeout(Ze),Ze=void 0):wn()}function pa(e,t,n){n.aborted||(Be.add(e),wt=jo(wt,t),Be.size===1&&document.addEventListener("visibilitychange",ua),n.addEventListener("abort",()=>ma(e),{once:!0}),su())}function ma(e){Be.delete(e),!Be.size&&(clearTimeout(Ze),Ze=void 0,rt?.abort(),rt=null,Sn=!1,Ts=0,_s=null,wt=null,document.removeEventListener("visibilitychange",ua))}function Wt(e,t,n){let s=new Map(e.sends.map(i=>[i.id,at(i)]));pa({take(i){if(!i.sends.length&&!i.removed.length)return;let r=[];for(let l of i.sends){let d=at(l),u=s.get(l.id)??null;u!==d&&r.push({send:l,from:u,to:d}),s.set(l.id,d)}let a=i.removed.map(l=>l.id);for(let l of a)s.delete(l);Ls(()=>t.update({sends:i.sends,changes:r,removed:a}))},stale:()=>t.stale()},e.cursor,n)}function $n(e,t,n){let s=e.send.id,i=at(e.send);pa({take(r){if(r.removed.some(u=>u.id===s)){Ls(()=>t.removed());return}let a=r.sends.find(u=>u.id===s);if(!a)return;let l=at(a),d=l!==i?{send:a,from:i,to:l}:null;i=l,Ls(()=>t.update(a,d))},stale:()=>t.stale()},e.cursor,n)}function Ue(){Be.size&&wn()}function $t(e){return e.trim().toLowerCase()}function Et(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function lt(e){return`${e.toLocaleString()} ${e===1?"recipient":"recipients"}`}function W(e){if(!e)return"\u2014";let t=new Date(e);return t.toLocaleString(void 0,{year:t.getFullYear()===new Date().getFullYear()?void 0:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Rs(e){let t=new Set,n=[];for(let s of String(e||"").split(/[\n,]+/)){let i=$t(s);Et(i)?t.add(i):i&&n.push(s.trim())}return{valid:[...t],invalid:n}}function Cs(e){return e.length?`Not ${e.length===1?"an email address":"email addresses"}: ${e.join(", ")}`:null}function As(e,t,n){let s=new Map,i=[];for(let a of n)a.message?s.set(a.message,[...s.get(a.message)??[],a.email]):i.push(a.email);if(!s.size)return e?`Sent to ${e} of ${t}. Not sent to ${i.join(", ")}. Send again to try those.`:"Not sent. Send again to try.";let r=[...s].map(([a,l])=>t>1?`${l.join(", ")}: ${a}`:a);return i.length&&r.push(`Not sent to ${i.join(", ")}.`),e?`Sent to ${e} of ${t}. ${r.join(" ")} Send again goes only to those.`:r.join(" ")}function xt(e){let t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`}function En(e,t=!1){let n=e-Date.now();if(t||n<=0)return"Preparing to send\u2026";let s=Math.floor(n/1e3),i=Math.floor(s/60),r=Math.floor(i/60);if(s<300)return i>0?`Sends in ${i}m ${String(s%60).padStart(2,"0")}s`:`Sends in ${s}s`;if(i<60)return`Sends in ${i}m`;if(r<24){let l=i%60;return l>0?`Sends in ${r}h ${l}m`:`Sends in ${r}h`}let a=Math.round(r/24);return`Sends in ${a} day${a===1?"":"s"}`}function Hs(e){return`Missed its fire time \xB7 ${Math.max(0,Math.floor((Date.now()-e)/6e4))} min late`}var xn=e=>Math.max(0,Math.min(100,Math.round(e||0)));function Ps(e){if(e==null||!Number.isFinite(e)||e<=0)return"\u2014";let t=Math.round(e/1e3);if(t<90)return`${t}s`;let n=Math.round(t/60);return n<90?`${n} min`:`${Math.round(n/60)} hr`}function kt(e,t){return t.email_only?o`<span class="title-with-label"><span class="title-text">${e}</span><span class="email-only-mark">${D("mail")}Email only</span></span>`:e}function Is(e){return e.email_only?o` · <span class="sched-email-only">Email only</span>`:null}function Ms(e){return o`<span class="countdown" data-fire="${e.fire_at}"${e.phase==="due"&&o` data-due`}${Ce(e,"missed")&&o` data-missed`}></span>`}function Ns(e,t){let n=0,s=()=>{let i=Date.now(),r=Number.POSITIVE_INFINITY,a=l=>{l>i&&l<r&&(r=l)};for(let l of B("[data-closes]",e)){let d=Number(l.dataset.closes);l.hidden=i>=d,a(d)}for(let l of B("[data-fire]",e)){let d=Number(l.dataset.fire),u=l.dataset.missed!==void 0;l.textContent=u?Hs(d):En(d,l.dataset.due!==void 0),l.classList.toggle("countdown-missed",u),a(d)}r-i<=1e3&&r!==n&&(n=r,yt(r,s,t))};return vt(1e3,s,t),s}var Ce=(e,t)=>e.conditions.some(n=>n.kind===t);function fe(e,t){return e.conditions.find(n=>n.kind===t)}var Je=(e,t)=>e.actions.some(n=>n.name===t);function Kt(e,t){let n=new Set(e.map(s=>s.id));return[...e.map(s=>t.get(s.id)??s),...[...t.values()].filter(s=>!n.has(s.id))]}function kn(e){return Ce(e,"wedged")||Ce(e,"refused")}function Gt(e){let t=e.delivered||0,n=[];e.complained&&n.push(`${e.complained.toLocaleString()} complained`),e.bounced&&n.push(`${e.bounced.toLocaleString()} bounced`),e.unsent&&n.push(`${e.unsent.toLocaleString()} unsent`);let s=n.length?o`<span class="muted delivered-note">${n.map((i,r)=>o`${r?", ":""}<span class="delivered-kind">${i}</span>`)}</span>`:null;return o`<span class="n">${t.toLocaleString()}</span>${s}`}function zt(e){if(e===null)return"it is retried on its own";let t=e-Date.now();return t>0?`next retry in ${Ps(t)}`:"next retry due now"}function Os(e,{stuckNote:t=!0}={}){let n=e.counts,s=n.accepted+n.delivered+n.bounced+n.complained,i=n.delivered+n.bounced+n.complained,r=e.audience.count,a=r>0?100*s/r:0,l=e.dispatch.eta_ms?` \xB7 ~${Ps(e.dispatch.eta_ms)} left`:"",d=t?fe(e,"stuck"):void 0,u=e.provider.halt,p=e.phase==="backing_off"&&u?.reason==="unavailable",g=p?"Backing off":"Sending",h=p?` \xB7 provider unavailable, ${zt(u.retry_at)}`:"";return o`<div class="card spread clickable active-card" data-watch="${e.id}">
|
|
47
47
|
<div class="active-main">
|
|
48
48
|
<a class="card-link active-subj" href="#/sent/${e.id}">${e.subject||o`<em>untitled</em>`}</a>
|
|
49
|
-
<div class="active-bar"><div class="active-fill" style="width:${
|
|
49
|
+
<div class="active-bar"><div class="active-fill" style="width:${xn(a)}%"></div></div>
|
|
50
50
|
<div class="muted active-stat">${g}: ${s.toLocaleString()} of ${r.toLocaleString()} accepted${i?` \xB7 ${i.toLocaleString()} confirmed`:""}${l}${h}</div>
|
|
51
51
|
${d?o`<div class="active-stuck">${d.message}</div>`:null}
|
|
52
52
|
</div>
|
|
53
53
|
<a class="ghost-link" href="#/sent/${e.id}">Watch →</a>
|
|
54
|
-
</div>`}function
|
|
54
|
+
</div>`}function Yt(e){let t=new URLSearchParams;e.status&&t.set("status",e.status),e.suppressed&&t.set("suppressed",e.suppressed),e.failures&&t.set("failures",e.failures);let n=(e.search||"").trim();return n&&t.set("search",n),e.sort&&(t.set("sort",e.sort),t.set("dir",e.dir??"desc")),t.set("limit",String(e.limit)),t.set("offset",String(e.offset)),t.toString()}function Zt(e){let t=e.statuses?.length?o`<select class="lt-status" aria-label="Filter by status"><option value="${e.allValue||""}">All statuses</option>${e.statuses.map(i=>o`<option value="${i.value}">${i.label}</option>`)}</select>`:null,n=e.suppressible?o`<label class="lt-toggle"><input type="checkbox" class="lt-suppressed"><span>Suppressed</span></label>`:null,s=e.failures?o`<label class="lt-toggle"><input type="checkbox" class="lt-failures"><span>With delivery failures</span></label>`:null;return o`<div class="list-toolbar">
|
|
55
55
|
<input class="lt-search" type="search" placeholder="${e.searchPlaceholder||"Search\u2026"}" aria-label="Search" autocomplete="off">
|
|
56
56
|
<div class="lt-filters">${t}${n}${s}</div>
|
|
57
|
-
</div>`}function
|
|
58
|
-
${
|
|
57
|
+
</div>`}function Jt(e,t,n){let s=e.querySelector(".lt-search"),i=e.querySelector(".lt-status"),r=e.querySelector(".lt-suppressed"),a=e.querySelector(".lt-failures");if(s){s.value=t.search||"";let l;s.oninput=()=>{clearTimeout(l),l=setTimeout(()=>{t.search=s.value,t.offset=0,n()},250)}}i&&(i.value=t.status||"",i.onchange=()=>{t.status=i.value,t.offset=0,n()}),r&&(r.checked=t.suppressed==="only",r.onchange=()=>{t.suppressed=r.checked?"only":"",t.offset=0,n()}),a&&(a.checked=t.failures==="only",a.onchange=()=>{t.failures=a.checked?"only":"",t.offset=0,n()})}function xe(e,t,n,s){if(!t)return s?o`<th class="${s}">${e}</th>`:o`<th>${e}</th>`;let i=n.sort===t,r=i?n.dir==="asc"?"\u2191":"\u2193":"",a=`${s?`${s} `:""}sortable${i?" sorted":""}`;return o`<th class="${a}"><button type="button" class="th-sort" data-sort="${t}">${e}<span class="th-arrow" aria-hidden="true">${r}</span></button></th>`}function ct(e,t,n){for(let s of e.querySelectorAll(".th-sort"))s.onclick=()=>{let i=s.dataset.sort;t.sort===i?t.dir=t.dir==="asc"?"desc":"asc":(t.sort=i,t.dir="desc"),t.offset=0,n()}}function dt(e,t,n,s){let i=n?.limit??t.limit;if(!n||n.total<=i){f(e,o``);return}let r=n.offset+1,a=Math.min(n.offset+i,n.total),l=n.offset>0,d=n.offset+i<n.total;if(f(e,o`<div class="pager"><button type="button" class="pager-prev"${l?null:fa}>← Prev</button><span class="pager-range muted">${r}–${a} of ${n.total}</span><button type="button" class="pager-next"${d?null:fa}>Next →</button></div>`),l){let u=e.querySelector(".pager-prev");u&&(u.onclick=()=>{t.offset=Math.max(0,n.offset-i),s()})}if(d){let u=e.querySelector(".pager-next");u&&(u.onclick=()=>{t.offset=n.offset+i,s()})}}var fa=o` disabled`;var ou=3600,iu=300,ru=3,Wo=new WeakMap;function j(e){let t=[...Lo.querySelectorAll(".toast:not(.leaving)")],n=t.find(i=>i.textContent===e);if(n){ha(n);return}let s=document.createElement("div");s.className="toast",s.textContent=e,Lo.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),ha(s);for(let i of t.slice(0,t.length+1-ru))ga(i)}function ha(e){clearTimeout(Wo.get(e)),Wo.set(e,window.setTimeout(()=>ga(e),ou))}function ga(e){clearTimeout(Wo.get(e)),e.style.height=`${e.offsetHeight}px`,e.offsetHeight,e.classList.add("leaving"),e.style.height="0",setTimeout(()=>e.remove(),iu)}var Qe=e=>o`<span class="badge ${e}">${e}</span>`,au=0,Vo=new WeakMap;function va(e){let t=document.createElement("div");t.className="field-error",t.id=`field-error-${++au}`,t.setAttribute("role","alert");let n=document.createElement("span");n.className="field-error-ico",n.setAttribute("aria-hidden","true"),n.textContent="!";let s=document.createElement("span");return s.textContent=e,t.append(n,s),t}function Fe(e,t,{after:n}={}){Vo.get(e)?.();let s=va(t),i=e.getAttribute("aria-describedby");(n??e).after(s),e.setAttribute("aria-describedby",i?`${i} ${s.id}`:s.id),e.classList.add("is-invalid");let r=!1,a=()=>{r||(r=!0,s.remove(),e.classList.remove("is-invalid"),i===null?e.removeAttribute("aria-describedby"):e.setAttribute("aria-describedby",i),e.removeEventListener("input",a),e.removeEventListener("change",a),Vo.delete(e))};return e.addEventListener("input",a),e.addEventListener("change",a),Vo.set(e,a),a}function pe(e,t){let n=document.createElement("div");n.className="modal-backdrop",f(n,o`<div class="modal" role="dialog" aria-modal="true">${e}</div>`);let s=n.firstElementChild,i=document.activeElement instanceof HTMLElement?document.activeElement:null,r=p=>{n===[...document.querySelectorAll(".modal-backdrop")].pop()&&(p.key==="Escape"?u():p.key==="Tab"&&cu(s,p))},a=null,l=()=>{a?.(),a=null},d=(p,g)=>{if(l(),g){a=Fe(g,p),g.focus();return}let h=va(p);h.classList.add("dialog-error");let m=s.querySelector(".actions");m?m.before(h):s.append(h),a=()=>h.remove()},u=()=>{let p=document.activeElement,g=n.contains(p)||!p||p===document.body;n.remove(),document.removeEventListener("keydown",r),t.removeEventListener("abort",u),g&&i?.isConnected&&i.focus()};return t.aborted?{el:n,close:u,error:d,clearError:l}:(document.body.appendChild(n),n.addEventListener("click",p=>{p.target===n&&u()}),document.addEventListener("keydown",r),t.addEventListener("abort",u,{once:!0}),queueMicrotask(()=>{n.isConnected&&!s.contains(document.activeElement)&&ya(s)[0]?.focus()}),{el:n,close:u,error:d,clearError:l})}var lu='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function ya(e){return[...e.querySelectorAll(lu)].filter(t=>!t.closest("[hidden]"))}function cu(e,t){let n=ya(e),s=n[0],i=n[n.length-1];if(!s||!i){t.preventDefault();return}let r=document.activeElement;e.contains(r)?t.shiftKey&&r===s?(t.preventDefault(),i.focus()):!t.shiftKey&&r===i&&(t.preventDefault(),s.focus()):(t.preventDefault(),s.focus())}var ba=8;function du(e){let t=getComputedStyle(e,"::after"),n=parseFloat(t.width)+parseFloat(t.paddingLeft)+parseFloat(t.paddingRight);if(!Number.isFinite(n))return;let s=e.getBoundingClientRect().left,i=document.documentElement.clientWidth,r=Math.min(0,Math.max(i-ba-n-s,ba-s));e.style.setProperty("--tip-x",`${Math.round(r)}px`)}function Sa(){for(let e of["pointerover","focusin"])document.addEventListener(e,t=>{let n=t.target instanceof Element?t.target.closest(".info"):null;n&&du(n)});document.addEventListener("keydown",e=>{let t=document.activeElement;e.key==="Escape"&&t instanceof HTMLElement&&t.classList.contains("info")&&t.blur()})}var Ds=[],Ko=null,Qt=null;function _t(){let e=Ds.some(t=>t.contains(document.activeElement));for(let t of Ds)t.remove();Ds=[],Ko?.removeEventListener("abort",_t),Ko=null,Qt?.setAttribute("aria-expanded","false"),e&&Qt?.isConnected&&Qt.focus(),Qt=null}function Xt(e,t,n,{align:s="end"}={}){if(_t(),n.aborted)return;let i=document.createElement("div");i.className="menu-overlay",i.onclick=_t;let r=document.createElement("div");r.className="menu",r.setAttribute("role","menu");for(let l of t){let d=document.createElement("button");if(d.type="button",d.setAttribute("role","menuitem"),d.tabIndex=-1,d.className=`menu-item${l.danger?" danger-item":""}`,l.description){let u=document.createElement("span");u.className="menu-item-name",u.textContent=l.label;let p=document.createElement("span");p.className="menu-item-desc",p.textContent=l.description,d.append(u,p),r.classList.add("menu-described")}else d.textContent=l.label;d.onclick=()=>{_t(),l.onClick()},r.appendChild(d)}r.addEventListener("keydown",l=>uu(r,l)),document.body.appendChild(i),document.body.appendChild(r),Ds=[i,r],Ko=n,Qt=e instanceof HTMLElement?e:null,Qt?.setAttribute("aria-expanded","true"),n.addEventListener("abort",_t,{once:!0});let a=e.getBoundingClientRect();r.style.top=`${a.bottom+window.scrollY+4}px`,r.style.left=`${(s==="start"?a.left:a.right-r.offsetWidth)+window.scrollX}px`,r.querySelector(".menu-item")?.focus()}function uu(e,t){let n=[...e.querySelectorAll(".menu-item")],s=n.indexOf(document.activeElement),i=r=>{t.preventDefault(),n[(r+n.length)%n.length]?.focus()};t.key==="ArrowDown"?i(s+1):t.key==="ArrowUp"?i(s-1):t.key==="Home"?i(0):t.key==="End"?i(n.length-1):t.key==="Escape"?(t.preventDefault(),t.stopPropagation(),_t()):t.key==="Tab"&&_t()}async function J(e,t,n){let s=e.textContent;e.disabled=!0,t&&(e.textContent=t);try{return await n()}finally{e.isConnected&&(e.disabled=!1,e.textContent=s)}}function re(e,t,n){f(e,o`<div class="error"><span>${t}</span><button class="ghost" data-retry>Retry</button></div>`);let s=e.querySelector("[data-retry]");s&&(s.onclick=n)}function en(e,t){return e.actions.find(n=>n.name===t)}function _n(e){let t=e.send;return t&&(t.status==="scheduled"||t.status==="sending")?t:null}var pu=[{value:"draft",label:"Draft"},{value:"scheduled",label:"Scheduled"}],Go="draft,scheduled";function zo(e){return J(e,"Creating\u2026",async()=>{try{let{post:t}=await C("/api/posts",{method:"POST",json:{}});location.hash=`#/edit/${t.id}`}catch(t){j(z(t))}})}async function Yo(e,t){ie(t,"Drafts");let n={status:Go,search:"",sort:"",dir:"desc",offset:0,limit:50};f(e,o`<div class="spread page-head"><h1>Drafts</h1><button class="primary" id="newPost">New post</button></div>
|
|
58
|
+
${Zt({statuses:pu,allValue:Go,searchPlaceholder:"Search subject\u2026"})}
|
|
59
59
|
<div id="list"><p class="muted">Loading…</p></div>
|
|
60
|
-
<div id="postsPager"></div>`);let s=c("#newPost",e);s.onclick=()=>zo(s);let i=c("#list",e),r=c("#postsPager",e),a=new Map,l=0,d=()=>u(!1);async function u(m){let y=++l;try{let E=await C(`/api/posts?${zt(n)}`,{signal:t});if(y!==l)return null;let R=E.posts;if(a=new Map(R.map(N=>[N.id,kn(N)])),!R.length){let N=n.search||n.status&&n.status!==Go;return f(i,o`<p class="muted">${N?"No drafts match.":"No drafts yet. Create your first draft."}</p>`),f(r,o``),E}f(i,o`<div class="table-wrap"><table class="list-table posts-table stacks has-actions"><colgroup><col><col class="c-status"><col class="c-date"><col class="c-date"><col class="c-act"></colgroup><thead><tr>${xe("Title","subject",n)}${xe("Status",null,n)}${xe("Scheduled","send.fire_at",n)}${xe("Updated","updated_at",n)}<th></th></tr></thead><tbody>${R.map(N=>{let A=kn(N),P=A?.status==="sending",v=A&&P?`#/sent/${A.id}`:`#/edit/${N.id}`,w=A?.fire_at??null,I=Xt(N,"delete")?"1":"";return o`<tr class="clickable" data-id="${N.id}" data-target="${v}"><td>${xt(o`<a href="${v}">${N.subject||o`<em>untitled</em>`}</a>`,N)}</td><td>${P?Qe("sending"):Qe(N.status)}</td><td class="muted when${w?"":" empty"}">${w?W(w):"\u2014"}</td><td class="muted updated">${W(N.updated_at)}</td><td class="act"><button class="icon" data-menu="${N.id}" data-status="${P?"sending":N.status}" data-delete="${I}" data-target="${v}" aria-label="Post actions" aria-haspopup="menu">⋯</button></td></tr>`})}</tbody></table></div>`),lt(i,n,d);for(let N of D("tr[data-id]",i))N.onclick=A=>{let P=A.target;P instanceof Element&&P.tagName!=="A"&&!P.closest("[data-menu]")&&N.dataset.target&&(location.hash=N.dataset.target)};for(let N of D("[data-menu]",i))N.onclick=A=>{A.stopPropagation();let P=N.dataset.status,v=N.dataset.target??"",w=[{label:P==="sending"?"Watch send":"Open",onClick:()=>{location.hash=v}}];if(N.dataset.delete&&N.dataset.menu){let I=N.dataset.menu;w.push({label:"Delete draft",danger:!0,onClick:()=>pu(I,d,t)})}Qt(N,w,t)};return ct(r,n,E.page,d),E}catch(E){return!m&&y===l&&re(i,z(E),()=>p?d():void h()),null}}let p=!1,g=m=>{p=!0,Vt({cursor:m.cursor,sends:[]},{update({sends:y,removed:E}){let R=new Set([...a.values()].flatMap(A=>A?.id??[]));(y.some(A=>a.has(A.post_id)&&uu(a.get(A.post_id)??null,A))||E.some(A=>R.has(A)))&&u(!0)},stale:()=>ne(Yo)},t)},h=async()=>{let m=await u(!1);m&&!p&&g(m)};Zt(e,n,d),await h()}function uu(e,t){return e?.id===t.id?t.status!==e.status||t.fire_at!==e.fire_at:t.status==="scheduled"||t.status==="sending"}function pu(e,t,n){let s=pe(o`<h3>Delete draft?</h3><p class="hint">This permanently deletes the draft and its revisions. This can’t be undone.</p><div class="actions"><button type="button" id="dCancel">Cancel</button><button type="button" class="danger" id="dGo">Delete</button></div>`,n),i=c("#dGo",s.el);c("#dCancel",s.el).onclick=s.close,i.onclick=()=>J(i,"Deleting\u2026",async()=>{s.clearError();try{await C(`/api/posts/${e}`,{method:"DELETE"}),s.close(),q("Draft deleted"),t()}catch(r){s.error(z(r))}})}var _t="#/docs/production-access",mu="#/docs/production-access/3-answer-awss-questions",fu="#/docs/ses/5-create-the-apps-aws-key",_n="#/template";function Jo(e){return e?.provider==="ses"||!!e?.simulation}async function dt(e,t){if(!Jo(e))return null;try{return await C("/api/provider",{signal:t})}catch{return null}}var ut=e=>e?.state==="sandbox";function Zo(e){let t=e.account?.max_24_hour_send;return typeof t=="number"?`, up to ${t.toLocaleString()} a day`:""}function Sa(e,t=null){if(e.state==="production")return o`<span>Amazon SES <span class="set-pill ok" id="providerState">Production</span>${t}</span>`;if(e.state!=="sandbox")return e.unknown_reason==="permission"?o`<span>Amazon SES${t}</span><span class="muted" id="providerUnread">To show whether SES is in the sandbox, Kestrel’s AWS key needs permission to read your account. <a class="set-link" href="${fu}">Add the permission</a></span>`:o`Amazon SES${t}`;let n=o`<span class="set-pill warn" id="providerState">Sandbox</span>`,s=e.review==="pending"?o`AWS is reviewing your request for production access. Until then, it mails only addresses verified in SES${Zo(e)}.`:e.review==="denied"?o`<span class="set-warn">AWS hasn’t granted production access yet. ${wa(e)}: read its reply and answer there.</span> <a class="set-link" href="${mu}">What AWS asks for</a>`:e.review==="failed"?o`<span class="set-warn">AWS didn’t receive your request for production access.</span> <a class="set-link" href="${_t}">Request it again</a>`:o`<span class="set-warn">It mails only addresses verified in SES${Zo(e)}.</span> <a class="set-link" href="${_t}">Request production access</a>`;return o`<span>Amazon SES ${n}${t}</span><span class="muted" id="providerReview">${s}</span>`}function wa(e){return e.review_case?`It has replied in AWS Support, case ${e.review_case}`:"It has replied in AWS Support"}var hu={account:"from your SES account",setting:"set by SES_MAX_SEND_RATE",default:"Kestrel\u2019s default"};function $a(e){if(!e.send_rate)return null;let{value:t,source:n}=e.send_rate;return o`<span>${t} ${t===1?"email":"emails"} a second${Zo(e)} <span class="muted">(${hu[n]})</span></span>`}var bu={configuration_set_missing:"Send bounces and complaints to the app",configuration_set_paused:"Send bounces and complaints to the app",key_rejected:"Create the app\u2019s AWS key",sending_disabled:"A problem with Amazon SES",sender_unverified:"Verify your sending hostname",account_probation:"A problem with Amazon SES",bounces_not_routed:"Send bounces and complaints to the app"};function Bs(e){return o`${e.message} <a href="#/docs/${e.docs.slug}/${e.docs.anchor}">${bu[e.code]}</a>`}var Tn=e=>e.severity==="error";function Ea(){return o`Amazon SES is still in the sandbox, so it mails only addresses verified in SES. <a href="${_t}">Request production access</a>`}function xa(e,t){return e?.state==="production"?null:e?.state==="sandbox"&&e.review==="pending"?"Waiting for AWS to grant production access.":e?.state==="sandbox"&&e.review==="denied"?`AWS hasn\u2019t granted it yet. ${wa(e)}: answer there.`:e?.state==="sandbox"&&e.review==="failed"?"AWS didn\u2019t receive your request. Ask again.":t?e?.state==="unknown"&&e.unknown_reason==="permission"?"Kestrel can\u2019t read your SES account, so the SES console\u2019s account dashboard says whether AWS granted it.":null:"Name your publication first: AWS\u2019s reviewer looks at it."}function Ln(e){return e?.sending?.state==="refusing"?e.sending.refusal:null}function ka(e){return e.found_by==="account_check"?`${e.error} ${e.advice}`:`SES says: ${e.error.replace(/[.!?]?$/,".")} ${e.advice}`}function _a(e){return o`<span class="dash-not-going-out"><strong>Email isn’t going out, and signups are paused.</strong> ${ka(e)} Then <a href="${_n}">send a test email</a>: once SES takes one, signups reopen.</span>`}function Ta(){return o`Signups are paused: Amazon SES is refusing email, including confirmations. <a href="#/">See what to fix</a>`}function La(e,t){let n=e.sending;if(!n)return null;let s=n.last_accepted?o`<span class="muted" id="providerLastAccepted">SES accepted an email ${t(n.last_accepted.at)}.</span>`:null;return n.state==="refusing"&&n.refusal?{pill:o`<span class="set-pill danger" id="providerSending">Refusing</span>`,line:o`<span class="set-error">${ka(n.refusal)} Then <a class="set-link" href="${_n}">send a test email</a>.</span>${s}`}:n.state==="unproven"?{pill:o`<span class="set-pill" id="providerSending">Not proven yet</span>`,line:o`<span>SES hasn’t sent anything yet, so signups are closed. <a class="set-link" href="${_n}">Send a test email</a></span>`}:{pill:null,line:s??o``}}var Qo={pending:"Subscribed but hasn\u2019t clicked the confirmation email.",confirmed:"Receives your posts. They confirmed here, or opted in at the service you imported them from.",unsubscribed:"Left the list. They\u2019re sent nothing until they sign up again, or, unless they left by a complaint or an erasure, you add them back and they confirm."},Ra={reader:"They unsubscribed themselves, from the link or the button in your email.",publisher:"You unsubscribed them, when they asked you to.",complaint:"They reported your email as spam. Only their own sign-up brings them back, so you can\u2019t add them: ask them to subscribe through your subscribe page.",erased:"You erased them at their request. Only the address is kept, so it isn\u2019t mailed again, and only their own sign-up brings them back.",import:"The list you imported says they left, without saying why."},Ca="The address isn\u2019t sent your posts, whatever its status. The status stays as it was, greyed while the suppression keeps it from taking effect.",qe={bounce:"bounced",import_bounce:"bounced",manual:"blocked"},Rn={bounced:"Mail to the address failed, here or at the service it was imported from. You can clear it.",blocked:"Stopped by hand, by you or at the service it was imported from. You can unblock it."},pt={unsubscribe:{label:"Unsubscribe",when:"When they ask you to take them off the list. They can rejoin by subscribing again."},block:{label:"Block",when:"When you decide yourself to stop mailing an address. Their status stays as it was, and you can unblock it."},unblock:{label:"Unblock",when:"When you decide to mail an address you blocked again. They receive your posts only if they\u2019re confirmed."},clear:{label:"Clear",when:"When you know a bounce\u2019s cause is gone, such as a reader who tells you their mailbox is fixed. Mail goes again to an address that failed."},erase:{label:"Erase",when:"When they ask you to delete their data. They\u2019re unsubscribed and only their address is kept. It can\u2019t be undone, and they come back only by subscribing themselves."}};function Us(e,t){let n=be(),s=pe(o`<h3>Add subscriber</h3><p class="hint">Starts the normal double opt-in: they get a confirmation email and won’t receive posts until they confirm.</p>${yr()}${n?null:o`<label for="addEmail">Email address</label><input type="email" id="addEmail" placeholder="person@example.com">`}<div class="actions"><button type="button" id="aCancel">Cancel</button><button type="button" class="primary" id="aGo">Send confirmation</button></div>`,t),i=c("#aGo",s.el);if(c("#aCancel",s.el).onclick=s.close,i.disabled=n,n){c("#aCancel",s.el).focus();return}let r=c("#addEmail",s.el);r.focus(),i.onclick=()=>J(i,"Adding\u2026",async()=>{s.clearError();let a=wt(r.value);if(!$t(a)){s.error("Enter a valid email address",r);return}try{let l=await C("/api/subscribers",{method:"POST",json:{email:a}});s.close(),q(gu(a,l.action)),e()}catch(l){s.error(z(l),l instanceof se&&l.field==="email"?r:void 0)}})}function gu(e,t){switch(t){case"already_confirmed":return`${e} is already confirmed`;case"suppressed":return`${e} is suppressed, so no confirmation was sent`;case"recently_sent":return`A confirmation went to ${e} a few minutes ago; try again later`;default:return`Confirmation sent to ${e}`}}function Aa(e,t,n){let s=pe(o`<h3>Unsubscribe this subscriber?</h3><p class="hint">Use this when <strong>${e.email}</strong> asks you to take them off the list. They stop receiving posts immediately, and can rejoin by subscribing again. To stop mailing them on your own judgment, block the address instead.</p><div class="actions"><button type="button" id="uCancel">Cancel</button><button type="button" class="danger" id="uGo">Unsubscribe</button></div>`,n),i=c("#uGo",s.el);c("#uCancel",s.el).onclick=s.close,i.onclick=()=>J(i,"Unsubscribing\u2026",async()=>{s.clearError();try{await C(`/api/subscribers/${e.id}/unsubscribe`,{method:"POST"}),s.close(),q(`Unsubscribed ${e.email}`),t()}catch(r){s.error(z(r))}})}function Ha(e,t,n){let s=pe(o`<h3>Block this address?</h3><p class="hint">Stops all mail to <strong>${e.email}</strong>, whatever their status, which stays as it is. Use this when you decide yourself to stop mailing them; if they asked to leave, unsubscribe them instead. You can unblock it later.</p><div class="actions"><button type="button" id="bCancel">Cancel</button><button type="button" class="danger" id="bGo">Block</button></div>`,n),i=c("#bGo",s.el);c("#bCancel",s.el).onclick=s.close,i.onclick=()=>J(i,"Blocking\u2026",async()=>{s.clearError();try{let r=await C("/api/suppressions",{method:"POST",json:{email:e.email}});s.close(),q(r.added?`Blocked ${e.email}`:`${e.email} was already suppressed (${qe[r.suppression.reason]})`),t()}catch(r){s.error(z(r))}})}function Pa(e,t,n){let s=e.status==="confirmed"?"They\u2019re confirmed, so they\u2019ll receive your posts again.":"They\u2019ll receive posts again only once they\u2019re confirmed.",i=pe(o`<h3>Unblock this address?</h3><p class="hint">Undoes the block on <strong>${e.email}</strong>. ${s}</p><div class="actions"><button type="button" id="ubCancel">Cancel</button><button type="button" class="primary" id="ubGo">Unblock</button></div>`,n),r=c("#ubGo",i.el);c("#ubCancel",i.el).onclick=i.close,r.onclick=()=>J(r,"Unblocking\u2026",async()=>{i.clearError();try{await Ia(e),i.close(),q(`Unblocked ${e.email}`),t()}catch(a){i.error(z(a))}})}function Ia(e){return C("/api/suppressions/lift",{method:"POST",json:{email:e.email,reason:e.suppression?.reason}})}function Ma(e,t,n){let s=e.status==="confirmed"?"They\u2019re confirmed, so they\u2019ll receive your posts again.":"They\u2019ll receive posts again only once they\u2019re confirmed.",i=pe(o`<h3>Clear this bounce?</h3><p class="hint">Lets mail go again to <strong>${e.email}</strong>, an address where mail failed. Clear it only when you know the reason is gone, such as a reader who tells you their mailbox is fixed. ${s}</p><div class="actions"><button type="button" id="cCancel">Cancel</button><button type="button" class="danger" id="cGo">Clear</button></div>`,n),r=c("#cGo",i.el);c("#cCancel",i.el).onclick=i.close,r.onclick=()=>J(r,"Clearing\u2026",async()=>{i.clearError();try{await Ia(e),i.close(),q(`Cleared the bounce on ${e.email}`),t()}catch(a){i.error(z(a))}})}function Na(e,t,n){let s=pe(o`<h3>Erase this subscriber?</h3><p class="hint">Unsubscribes <strong>${e.email}</strong> and deletes how they joined and the evidence for it, and past sends show an erased recipient in its place. Only the address is kept, so it’s never mailed again. This can’t be undone. They can still rejoin by subscribing and confirming themselves, but you can’t add them back.</p><div class="actions"><button type="button" id="eCancel">Cancel</button><button type="button" class="danger" id="eGo">Erase</button></div>`,n),i=c("#eGo",s.el);c("#eCancel",s.el).onclick=s.close,i.onclick=()=>J(i,"Erasing\u2026",async()=>{s.clearError();try{let r=await C(`/api/subscribers/${e.id}/erase`,{method:"POST"});s.close(),q(yu(r)),t()}catch(r){s.error(z(r))}})}var vu={bounce:"bounce",import_bounce:"bounce",manual:"block"};function yu({subscriber:e}){let t=e.suppression;return t?`Erased ${e.email}. Its ${vu[t.reason]??"suppression"} still stands`:`Erased ${e.email}`}var Su=1500;function Te(e=!1,t="Copy"){return o`<span>${t}</span>${B(e?"check":"copyout")}`}function Cn(e,t){return o`<button type="button" class="copy-btn" data-copy="${e}" aria-label="${t}">${Te()}</button>`}function en(e,t,n){return o`<div class="block code-block"><div class="block-head"><span class="block-label">${e}</span>${Cn(n,`Copy ${e}`)}</div><pre><code>${t}</code></pre></div>`}function Oa(e,t){return o`<div class="code-bare"><pre><code>${e}</code></pre><button type="button" class="copy-btn" data-copy="${t}" data-copy-word="" aria-label="Copy" title="Copy">${Te(!1,"")}</button></div>`}var Xo=new WeakMap;async function An(e,t){try{await navigator.clipboard.writeText(t)}catch{q("Couldn\u2019t copy to clipboard");return}let n=Xo.get(e),s=n?.label??e.getAttribute("aria-label")??"Copy",i=e.dataset.copyWord;window.clearTimeout(n?.timer),f(e,Te(!0,i)),e.setAttribute("aria-label","Copied"),e.classList.add("copied");let r=window.setTimeout(()=>{f(e,Te(!1,i)),e.setAttribute("aria-label",s),e.classList.remove("copied"),Xo.delete(e)},Su);Xo.set(e,{label:s,timer:r})}function je(e){e.addEventListener("click",t=>{let n=t.target instanceof Element?t.target.closest("[data-copy]"):null;n&&e.contains(n)&&An(n,n.dataset.copy??"")})}var ei="Connect Amazon SES",Hn="Send a test email",Da="Schedule your first post",Fs=e=>`After ${e}`,wu="SES is refusing. See why above.",$u="The last notification didn\u2019t arrive. See why above.",Ba=(e,t,n)=>`${e.toLocaleString()} ${e===1?t:n}`;function Eu(e){let t=e.provider,n=t?.sending??null,s=ut(t),i=[];i.push({key:"connect",title:ei,state:e.notConnected?"todo":"done",hint:e.notConnected?"Nothing can be sent, and signups stay closed, until SES is connected.":e.connectedTo}),i.push(e.notConnected?{key:"test",title:Hn,state:"blocked",hint:Fs(ei)}:n?.state==="working"?{key:"test",title:Hn,state:"done",hint:n.last_accepted?`SES accepted an email ${W(n.last_accepted.at)}.`:"SES is accepting email."}:n?.state==="refusing"?{key:"test",title:Hn,state:"attention",hint:wu}:{key:"test",title:Hn,state:"todo",hint:n?`SES is connected but hasn\u2019t sent anything yet. Send one to ${s?"an address verified in SES":"yourself"}.`:"Send one to yourself, and check it arrives."}),i.push({key:"name",title:"Name your publication",state:e.named?"done":"todo",hint:e.named?`Named \u201C${e.name}\u201D.`:`Currently \u201C${e.name}\u201D.`}),i.push({key:"notify",title:"Get notified",state:e.notifyTo?e.notifyFailed?"attention":"done":"todo",hint:e.notifyTo?e.notifyFailed?$u:`Notifications go to ${Ba(e.notifyTo,"address","addresses")}.`:null}),(e.notConnected||e.sesAccount)&&i.push({key:"access",title:"Request production access",state:t?.state==="production"?"done":s&&t?.review==="pending"?"waiting":"todo",hint:t?.state==="production"?"AWS granted it.":xa(t,e.named)}),i.push({key:"list",title:"Bring your existing list",state:e.onList?"done":"todo",hint:e.onList?`${Ba(e.onList,"subscriber","subscribers")} on your list.`:"Optional."}),i.push({key:"write",title:"Write your first post",state:e.firstPost!==null?"done":"todo",hint:e.firstPost!==null?`\u201C${e.firstPost||"Untitled"}\u201D.`:null}),i.push({key:"schedule",title:Da,state:e.notConnected?"blocked":e.firstSend?"done":"todo",hint:e.notConnected?Fs(ei):e.firstSend?`Goes out ${W(e.firstSend.fire_at)}.`:s&&n?.state==="working"?"Best after AWS grants access: until then it reaches only verified addresses.":null});let r=e.firstSend,a=r?r.tested_at!==null&&(r.remade_at??0)<=r.tested_at:!1;i.push({key:"post_test",title:"Send a test email for your first post",state:r?a?"done":"todo":"blocked",hint:r?a?"The email that goes out has been tested.":`\u201C${r.subject}\u201D goes out ${W(r.fire_at)}. Send yourself a test of it first.`:Fs(Da)});let l=e.notConnected||t!==null&&t.signups!=="open";return i.push({key:"share",title:"Share your subscribe link",state:l?"blocked":"todo",hint:l?Fs(Hn):ti(e)?"Share it before your first post goes out, so readers get it.":"Share it once AWS grants production access."}),i}function xu(e,t,n){if(e.state==="blocked")return null;if(e.state==="done")switch(e.key){case"connect":case"access":case"write":case"schedule":return null;case"list":return o`<button data-nav="#/subscribers">Subscribers</button>`}let s=n?"primary":"";switch(e.key){case"connect":return o`<button class="${s}" data-nav="${Oo}">Connect</button>`;case"test":return o`<button class="${s}" data-nav="${_n}">Send test email</button>`;case"name":return o`<button class="${s}" data-nav="#/settings">Settings</button>`;case"notify":return o`<button class="${s}" data-nav="#${Es("notifications")}">Settings</button>`;case"access":return o`<button class="${s}" data-nav="${_t}">Docs</button>`;case"list":return o`<button class="${s}" data-nav="#/subscribers/import">Import</button>`;case"write":return o`<button class="${s}" data-act="new-post">New post</button>`;case"schedule":return null;case"post_test":return t.firstSend?o`<button class="${s}" data-nav="#/edit/${t.firstSend.post_id}">Send test</button>`:null;case"share":return ti(t)?o`<button class="${s}" type="button" data-copy="${t.subscribeUrl}" aria-label="Copy the subscribe link">${Te()}</button>`:null}}function Ua(e,t,n=!1){let s=Eu(e),i=s.filter(d=>d.state==="done"),r=n?s:s.filter(d=>d.state!=="done"),a=s.find(d=>(d.state==="todo"||d.state==="attention")&&d.key!=="list"),l=d=>o`<li class="setup-${d.key.replace("_","-")} setup-${d.state}"><div class="setup-step-main"><strong>${d.title}</strong>${d.hint?o`<span class="muted setup-hint">${d.hint}</span>`:null}${d.key==="share"&&d.state!=="blocked"&&ti(e)?o`<code class="setup-url">${e.subscribeUrl}</code>`:null}</div>${xu(d,e,t==="checklist"&&d===a)}</li>`;return o`<div class="card setup${t==="card"?" setup-card":""}">
|
|
60
|
+
<div id="postsPager"></div>`);let s=c("#newPost",e);s.onclick=()=>zo(s);let i=c("#list",e),r=c("#postsPager",e),a=new Map,l=0,d=()=>u(!1);async function u(m){let y=++l;try{let E=await C(`/api/posts?${Yt(n)}`,{signal:t});if(y!==l)return null;let R=E.posts;if(a=new Map(R.map(O=>[O.id,_n(O)])),!R.length){let O=n.search||n.status&&n.status!==Go;return f(i,o`<p class="muted">${O?"No drafts match.":"No drafts yet. Create your first draft."}</p>`),f(r,o``),E}f(i,o`<div class="table-wrap"><table class="list-table posts-table stacks has-actions"><colgroup><col><col class="c-status"><col class="c-date"><col class="c-date"><col class="c-act"></colgroup><thead><tr>${xe("Title","subject",n)}${xe("Status",null,n)}${xe("Scheduled","send.fire_at",n)}${xe("Updated","updated_at",n)}<th></th></tr></thead><tbody>${R.map(O=>{let H=_n(O),I=H?.status==="sending",v=H&&I?`#/sent/${H.id}`:`#/edit/${O.id}`,w=H?.fire_at??null,M=en(O,"delete")?"1":"";return o`<tr class="clickable" data-id="${O.id}" data-target="${v}"><td>${kt(o`<a href="${v}">${O.subject||o`<em>untitled</em>`}</a>`,O)}</td><td>${I?Qe("sending"):Qe(O.status)}</td><td class="muted when${w?"":" empty"}">${w?W(w):"\u2014"}</td><td class="muted updated">${W(O.updated_at)}</td><td class="act"><button class="icon" data-menu="${O.id}" data-status="${I?"sending":O.status}" data-delete="${M}" data-target="${v}" aria-label="Post actions" aria-haspopup="menu">⋯</button></td></tr>`})}</tbody></table></div>`),ct(i,n,d);for(let O of B("tr[data-id]",i))O.onclick=H=>{let I=H.target;I instanceof Element&&I.tagName!=="A"&&!I.closest("[data-menu]")&&O.dataset.target&&(location.hash=O.dataset.target)};for(let O of B("[data-menu]",i))O.onclick=H=>{H.stopPropagation();let I=O.dataset.status,v=O.dataset.target??"",w=[{label:I==="sending"?"Watch send":"Open",onClick:()=>{location.hash=v}}];if(O.dataset.delete&&O.dataset.menu){let M=O.dataset.menu;w.push({label:"Delete draft",danger:!0,onClick:()=>fu(M,d,t)})}Xt(O,w,t)};return dt(r,n,E.page,d),E}catch(E){return!m&&y===l&&re(i,z(E),()=>p?d():void h()),null}}let p=!1,g=m=>{p=!0,Wt({cursor:m.cursor,sends:[]},{update({sends:y,removed:E}){let R=new Set([...a.values()].flatMap(H=>H?.id??[]));(y.some(H=>a.has(H.post_id)&&mu(a.get(H.post_id)??null,H))||E.some(H=>R.has(H)))&&u(!0)},stale:()=>ne(Yo)},t)},h=async()=>{let m=await u(!1);m&&!p&&g(m)};Jt(e,n,d),await h()}function mu(e,t){return e?.id===t.id?t.status!==e.status||t.fire_at!==e.fire_at:t.status==="scheduled"||t.status==="sending"}function fu(e,t,n){let s=pe(o`<h3>Delete draft?</h3><p class="hint">This permanently deletes the draft and its revisions. This can’t be undone.</p><div class="actions"><button type="button" id="dCancel">Cancel</button><button type="button" class="danger" id="dGo">Delete</button></div>`,n),i=c("#dGo",s.el);c("#dCancel",s.el).onclick=s.close,i.onclick=()=>J(i,"Deleting\u2026",async()=>{s.clearError();try{await C(`/api/posts/${e}`,{method:"DELETE"}),s.close(),j("Draft deleted"),t()}catch(r){s.error(z(r))}})}var Tt="#/docs/production-access",hu="#/docs/production-access/3-answer-awss-questions",bu="#/docs/ses/5-create-the-apps-aws-key",Tn="#/template";function Jo(e){return e?.provider==="ses"||!!e?.simulation}async function ut(e,t){if(!Jo(e))return null;try{return await C("/api/provider",{signal:t})}catch{return null}}var pt=e=>e?.state==="sandbox";function Zo(e){let t=e.account?.max_24_hour_send;return typeof t=="number"?`, up to ${t.toLocaleString()} a day`:""}function wa(e,t=null){if(e.state==="production")return o`<span>Amazon SES <span class="set-pill ok" id="providerState">Production</span>${t}</span>`;if(e.state!=="sandbox")return e.unknown_reason==="permission"?o`<span>Amazon SES${t}</span><span class="muted" id="providerUnread">To show whether SES is in the sandbox, Kestrel’s AWS key needs permission to read your account. <a class="set-link" href="${bu}">Add the permission</a></span>`:o`Amazon SES${t}`;let n=o`<span class="set-pill warn" id="providerState">Sandbox</span>`,s=e.review==="pending"?o`AWS is reviewing your request for production access. Until then, it mails only addresses verified in SES${Zo(e)}.`:e.review==="denied"?o`<span class="set-warn">AWS hasn’t granted production access yet. ${$a(e)}: read its reply and answer there.</span> <a class="set-link" href="${hu}">What AWS asks for</a>`:e.review==="failed"?o`<span class="set-warn">AWS didn’t receive your request for production access.</span> <a class="set-link" href="${Tt}">Request it again</a>`:o`<span class="set-warn">It mails only addresses verified in SES${Zo(e)}.</span> <a class="set-link" href="${Tt}">Request production access</a>`;return o`<span>Amazon SES ${n}${t}</span><span class="muted" id="providerReview">${s}</span>`}function $a(e){return e.review_case?`It has replied in AWS Support, case ${e.review_case}`:"It has replied in AWS Support"}var gu={account:"from your SES account",setting:"set by SES_MAX_SEND_RATE",default:"Kestrel\u2019s default"};function Ea(e){if(!e.send_rate)return null;let{value:t,source:n}=e.send_rate;return o`<span>${t} ${t===1?"email":"emails"} a second${Zo(e)} <span class="muted">(${gu[n]})</span></span>`}var vu={configuration_set_missing:"Send bounces and complaints to the app",configuration_set_paused:"Send bounces and complaints to the app",key_rejected:"Create the app\u2019s AWS key",sending_disabled:"A problem with Amazon SES",sender_unverified:"Verify your sending hostname",account_probation:"A problem with Amazon SES",bounces_not_routed:"Send bounces and complaints to the app"};function Bs(e){return o`${e.message} <a href="#/docs/${e.docs.slug}/${e.docs.anchor}">${vu[e.code]}</a>`}var Ln=e=>e.severity==="error";function xa(){return o`Amazon SES is still in the sandbox, so it mails only addresses verified in SES. <a href="${Tt}">Request production access</a>`}function ka(e,t){return e?.state==="production"?null:e?.state==="sandbox"&&e.review==="pending"?"Waiting for AWS to grant production access.":e?.state==="sandbox"&&e.review==="denied"?`AWS hasn\u2019t granted it yet. ${$a(e)}: answer there.`:e?.state==="sandbox"&&e.review==="failed"?"AWS didn\u2019t receive your request. Ask again.":t?e?.state==="unknown"&&e.unknown_reason==="permission"?"Kestrel can\u2019t read your SES account, so the SES console\u2019s account dashboard says whether AWS granted it.":null:"Name your publication first: AWS\u2019s reviewer looks at it."}function Rn(e){return e?.sending?.state==="refusing"?e.sending.refusal:null}function _a(e){return e.found_by==="account_check"?`${e.error} ${e.advice}`:`SES says: ${e.error.replace(/[.!?]?$/,".")} ${e.advice}`}function Ta(e){return o`<span class="dash-not-going-out"><strong>Email isn’t going out, and signups are paused.</strong> ${_a(e)} Then <a href="${Tn}">send a test email</a>: once SES takes one, signups reopen.</span>`}function La(){return o`Signups are paused: Amazon SES is refusing email, including confirmations. <a href="#/">See what to fix</a>`}function Ra(e,t){let n=e.sending;if(!n)return null;let s=n.last_accepted?o`<span class="muted" id="providerLastAccepted">SES accepted an email ${t(n.last_accepted.at)}.</span>`:null;return n.state==="refusing"&&n.refusal?{pill:o`<span class="set-pill danger" id="providerSending">Refusing</span>`,line:o`<span class="set-error">${_a(n.refusal)} Then <a class="set-link" href="${Tn}">send a test email</a>.</span>${s}`}:n.state==="unproven"?{pill:o`<span class="set-pill" id="providerSending">Not proven yet</span>`,line:o`<span>SES hasn’t sent anything yet, so signups are closed. <a class="set-link" href="${Tn}">Send a test email</a></span>`}:{pill:null,line:s??o``}}var Qo={pending:"Subscribed but hasn\u2019t clicked the confirmation email.",confirmed:"Receives your posts. They confirmed here, or opted in at the service you imported them from.",unsubscribed:"Left the list. They\u2019re sent nothing until they sign up again, or, unless they left by a complaint or an erasure, you add them back and they confirm."},Ca={reader:"They unsubscribed themselves, from the link or the button in your email.",publisher:"You unsubscribed them, when they asked you to.",complaint:"They reported your email as spam. Only their own sign-up brings them back, so you can\u2019t add them: ask them to subscribe through your subscribe page.",erased:"You erased them at their request. Only the address is kept, so it isn\u2019t mailed again, and only their own sign-up brings them back.",import:"The list you imported says they left, without saying why."},Aa="The address isn\u2019t sent your posts, whatever its status. The status stays as it was, greyed while the suppression keeps it from taking effect.",qe={bounce:"bounced",import_bounce:"bounced",manual:"blocked"},Cn={bounced:"Mail to the address failed, here or at the service it was imported from. You can clear it.",blocked:"Stopped by hand, by you or at the service it was imported from. You can unblock it."},mt={unsubscribe:{label:"Unsubscribe",when:"When they ask you to take them off the list. They can rejoin by subscribing again."},block:{label:"Block",when:"When you decide yourself to stop mailing an address. Their status stays as it was, and you can unblock it."},unblock:{label:"Unblock",when:"When you decide to mail an address you blocked again. They receive your posts only if they\u2019re confirmed."},clear:{label:"Clear",when:"When you know a bounce\u2019s cause is gone, such as a reader who tells you their mailbox is fixed. Mail goes again to an address that failed."},erase:{label:"Erase",when:"When they ask you to delete their data. They\u2019re unsubscribed and only their address is kept. It can\u2019t be undone, and they come back only by subscribing themselves."}};function Us(e,t){let n=be(),s=pe(o`<h3>Add subscriber</h3><p class="hint">Starts the normal double opt-in: they get a confirmation email and won’t receive posts until they confirm.</p>${Sr()}${n?null:o`<label for="addEmail">Email address</label><input type="email" id="addEmail" placeholder="person@example.com">`}<div class="actions"><button type="button" id="aCancel">Cancel</button><button type="button" class="primary" id="aGo">Send confirmation</button></div>`,t),i=c("#aGo",s.el);if(c("#aCancel",s.el).onclick=s.close,i.disabled=n,n){c("#aCancel",s.el).focus();return}let r=c("#addEmail",s.el);r.focus(),i.onclick=()=>J(i,"Adding\u2026",async()=>{s.clearError();let a=$t(r.value);if(!Et(a)){s.error("Enter a valid email address",r);return}try{let l=await C("/api/subscribers",{method:"POST",json:{email:a}});s.close(),j(yu(a,l.action)),e()}catch(l){s.error(z(l),l instanceof se&&l.field==="email"?r:void 0)}})}function yu(e,t){switch(t){case"already_confirmed":return`${e} is already confirmed`;case"suppressed":return`${e} is suppressed, so no confirmation was sent`;case"recently_sent":return`A confirmation went to ${e} a few minutes ago; try again later`;default:return`Confirmation sent to ${e}`}}function Ha(e,t,n){let s=pe(o`<h3>Unsubscribe this subscriber?</h3><p class="hint">Use this when <strong>${e.email}</strong> asks you to take them off the list. They stop receiving posts immediately, and can rejoin by subscribing again. To stop mailing them on your own judgment, block the address instead.</p><div class="actions"><button type="button" id="uCancel">Cancel</button><button type="button" class="danger" id="uGo">Unsubscribe</button></div>`,n),i=c("#uGo",s.el);c("#uCancel",s.el).onclick=s.close,i.onclick=()=>J(i,"Unsubscribing\u2026",async()=>{s.clearError();try{await C(`/api/subscribers/${e.id}/unsubscribe`,{method:"POST"}),s.close(),j(`Unsubscribed ${e.email}`),t()}catch(r){s.error(z(r))}})}function Pa(e,t,n){let s=pe(o`<h3>Block this address?</h3><p class="hint">Stops all mail to <strong>${e.email}</strong>, whatever their status, which stays as it is. Use this when you decide yourself to stop mailing them; if they asked to leave, unsubscribe them instead. You can unblock it later.</p><div class="actions"><button type="button" id="bCancel">Cancel</button><button type="button" class="danger" id="bGo">Block</button></div>`,n),i=c("#bGo",s.el);c("#bCancel",s.el).onclick=s.close,i.onclick=()=>J(i,"Blocking\u2026",async()=>{s.clearError();try{let r=await C("/api/suppressions",{method:"POST",json:{email:e.email}});s.close(),j(r.added?`Blocked ${e.email}`:`${e.email} was already suppressed (${qe[r.suppression.reason]})`),t()}catch(r){s.error(z(r))}})}function Ia(e,t,n){let s=e.status==="confirmed"?"They\u2019re confirmed, so they\u2019ll receive your posts again.":"They\u2019ll receive posts again only once they\u2019re confirmed.",i=pe(o`<h3>Unblock this address?</h3><p class="hint">Undoes the block on <strong>${e.email}</strong>. ${s}</p><div class="actions"><button type="button" id="ubCancel">Cancel</button><button type="button" class="primary" id="ubGo">Unblock</button></div>`,n),r=c("#ubGo",i.el);c("#ubCancel",i.el).onclick=i.close,r.onclick=()=>J(r,"Unblocking\u2026",async()=>{i.clearError();try{await Ma(e),i.close(),j(`Unblocked ${e.email}`),t()}catch(a){i.error(z(a))}})}function Ma(e){return C("/api/suppressions/lift",{method:"POST",json:{email:e.email,reason:e.suppression?.reason}})}function Na(e,t,n){let s=e.status==="confirmed"?"They\u2019re confirmed, so they\u2019ll receive your posts again.":"They\u2019ll receive posts again only once they\u2019re confirmed.",i=pe(o`<h3>Clear this bounce?</h3><p class="hint">Lets mail go again to <strong>${e.email}</strong>, an address where mail failed. Clear it only when you know the reason is gone, such as a reader who tells you their mailbox is fixed. ${s}</p><div class="actions"><button type="button" id="cCancel">Cancel</button><button type="button" class="danger" id="cGo">Clear</button></div>`,n),r=c("#cGo",i.el);c("#cCancel",i.el).onclick=i.close,r.onclick=()=>J(r,"Clearing\u2026",async()=>{i.clearError();try{await Ma(e),i.close(),j(`Cleared the bounce on ${e.email}`),t()}catch(a){i.error(z(a))}})}function Oa(e,t,n){let s=pe(o`<h3>Erase this subscriber?</h3><p class="hint">Unsubscribes <strong>${e.email}</strong> and deletes how they joined and the evidence for it, and past sends show an erased recipient in its place. Only the address is kept, so it’s never mailed again. This can’t be undone. They can still rejoin by subscribing and confirming themselves, but you can’t add them back.</p><div class="actions"><button type="button" id="eCancel">Cancel</button><button type="button" class="danger" id="eGo">Erase</button></div>`,n),i=c("#eGo",s.el);c("#eCancel",s.el).onclick=s.close,i.onclick=()=>J(i,"Erasing\u2026",async()=>{s.clearError();try{let r=await C(`/api/subscribers/${e.id}/erase`,{method:"POST"});s.close(),j(wu(r)),t()}catch(r){s.error(z(r))}})}var Su={bounce:"bounce",import_bounce:"bounce",manual:"block"};function wu({subscriber:e}){let t=e.suppression;return t?`Erased ${e.email}. Its ${Su[t.reason]??"suppression"} still stands`:`Erased ${e.email}`}var $u=1500;function Te(e=!1,t="Copy"){return o`<span>${t}</span>${D(e?"check":"copyout")}`}function An(e,t){return o`<button type="button" class="copy-btn" data-copy="${e}" aria-label="${t}">${Te()}</button>`}function tn(e,t,n){return o`<div class="block code-block"><div class="block-head"><span class="block-label">${e}</span>${An(n,`Copy ${e}`)}</div><pre><code>${t}</code></pre></div>`}function Da(e,t){return o`<div class="code-bare"><pre><code>${e}</code></pre><button type="button" class="copy-btn" data-copy="${t}" data-copy-word="" aria-label="Copy" title="Copy">${Te(!1,"")}</button></div>`}var Xo=new WeakMap;async function Hn(e,t){try{await navigator.clipboard.writeText(t)}catch{j("Couldn\u2019t copy to clipboard");return}let n=Xo.get(e),s=n?.label??e.getAttribute("aria-label")??"Copy",i=e.dataset.copyWord;window.clearTimeout(n?.timer),f(e,Te(!0,i)),e.setAttribute("aria-label","Copied"),e.classList.add("copied");let r=window.setTimeout(()=>{f(e,Te(!1,i)),e.setAttribute("aria-label",s),e.classList.remove("copied"),Xo.delete(e)},$u);Xo.set(e,{label:s,timer:r})}function je(e){e.addEventListener("click",t=>{let n=t.target instanceof Element?t.target.closest("[data-copy]"):null;n&&e.contains(n)&&Hn(n,n.dataset.copy??"")})}var ei="Connect Amazon SES",Pn="Send a test email",Ba="Schedule your first post",Fs=e=>`After ${e}`,Eu="SES is refusing. See why above.",xu="The last notification didn\u2019t arrive. See why above.",Ua=(e,t,n)=>`${e.toLocaleString()} ${e===1?t:n}`;function ku(e){let t=e.provider,n=t?.sending??null,s=pt(t),i=[];i.push({key:"connect",title:ei,state:e.notConnected?"todo":"done",hint:e.notConnected?"Nothing can be sent, and signups stay closed, until SES is connected.":e.connectedTo}),i.push(e.notConnected?{key:"test",title:Pn,state:"blocked",hint:Fs(ei)}:n?.state==="working"?{key:"test",title:Pn,state:"done",hint:n.last_accepted?`SES accepted an email ${W(n.last_accepted.at)}.`:"SES is accepting email."}:n?.state==="refusing"?{key:"test",title:Pn,state:"attention",hint:Eu}:{key:"test",title:Pn,state:"todo",hint:n?`SES is connected but hasn\u2019t sent anything yet. Send one to ${s?"an address verified in SES":"yourself"}.`:"Send one to yourself, and check it arrives."}),i.push({key:"name",title:"Name your publication",state:e.named?"done":"todo",hint:e.named?`Named \u201C${e.name}\u201D.`:`Currently \u201C${e.name}\u201D.`}),i.push({key:"notify",title:"Get notified",state:e.notifyTo?e.notifyFailed?"attention":"done":"todo",hint:e.notifyTo?e.notifyFailed?xu:`Notifications go to ${Ua(e.notifyTo,"address","addresses")}.`:null}),(e.notConnected||e.sesAccount)&&i.push({key:"access",title:"Request production access",state:t?.state==="production"?"done":s&&t?.review==="pending"?"waiting":"todo",hint:t?.state==="production"?"AWS granted it.":ka(t,e.named)}),i.push({key:"list",title:"Bring your existing list",state:e.onList?"done":"todo",hint:e.onList?`${Ua(e.onList,"subscriber","subscribers")} on your list.`:"Optional."}),i.push({key:"write",title:"Write your first post",state:e.firstPost!==null?"done":"todo",hint:e.firstPost!==null?`\u201C${e.firstPost||"Untitled"}\u201D.`:null}),i.push({key:"schedule",title:Ba,state:e.notConnected?"blocked":e.firstSend?"done":"todo",hint:e.notConnected?Fs(ei):e.firstSend?`Goes out ${W(e.firstSend.fire_at)}.`:s&&n?.state==="working"?"Best after AWS grants access: until then it reaches only verified addresses.":null});let r=e.firstSend,a=r?r.tested_at!==null&&(r.remade_at??0)<=r.tested_at:!1;i.push({key:"post_test",title:"Send a test email for your first post",state:r?a?"done":"todo":"blocked",hint:r?a?"The email that goes out has been tested.":`\u201C${r.subject}\u201D goes out ${W(r.fire_at)}. Send yourself a test of it first.`:Fs(Ba)});let l=e.notConnected||t!==null&&t.signups!=="open";return i.push({key:"share",title:"Share your subscribe link",state:l?"blocked":"todo",hint:l?Fs(Pn):ti(e)?"Share it before your first post goes out, so readers get it.":"Share it once AWS grants production access."}),i}function _u(e,t,n){if(e.state==="blocked")return null;if(e.state==="done")switch(e.key){case"connect":case"access":case"write":case"schedule":return null;case"list":return o`<button data-nav="#/subscribers">Subscribers</button>`}let s=n?"primary":"";switch(e.key){case"connect":return o`<button class="${s}" data-nav="${Oo}">Connect</button>`;case"test":return o`<button class="${s}" data-nav="${Tn}">Send test email</button>`;case"name":return o`<button class="${s}" data-nav="#/settings">Settings</button>`;case"notify":return o`<button class="${s}" data-nav="#${Vt("notifications")}">Settings</button>`;case"access":return o`<button class="${s}" data-nav="${Tt}">Docs</button>`;case"list":return o`<button class="${s}" data-nav="#/subscribers/import">Import</button>`;case"write":return o`<button class="${s}" data-act="new-post">New post</button>`;case"schedule":return null;case"post_test":return t.firstSend?o`<button class="${s}" data-nav="#/edit/${t.firstSend.post_id}">Send test</button>`:null;case"share":return ti(t)?o`<button class="${s}" type="button" data-copy="${t.subscribeUrl}" aria-label="Copy the subscribe link">${Te()}</button>`:null}}function Fa(e,t,n=!1){let s=ku(e),i=s.filter(d=>d.state==="done"),r=n?s:s.filter(d=>d.state!=="done"),a=s.find(d=>(d.state==="todo"||d.state==="attention")&&d.key!=="list"),l=d=>o`<li class="setup-${d.key.replace("_","-")} setup-${d.state}"><div class="setup-step-main"><strong>${d.title}</strong>${d.hint?o`<span class="muted setup-hint">${d.hint}</span>`:null}${d.key==="share"&&d.state!=="blocked"&&ti(e)?o`<code class="setup-url">${e.subscribeUrl}</code>`:null}</div>${_u(d,e,t==="checklist"&&d===a)}</li>`;return o`<div class="card setup${t==="card"?" setup-card":""}">
|
|
61
61
|
<h2 class="setup-title">${t==="card"?"Finish setting up":"Set up your publication"}</h2>
|
|
62
62
|
${t==="card"?o`<p class="muted setup-note">This card stays until your first post goes out to the archive. Email-only sends don’t count.</p>`:null}
|
|
63
63
|
${i.length?o`<button type="button" class="setup-fold" data-act="toggle-done" aria-controls="setupSteps" aria-expanded="${n?"true":"false"}" aria-label="${n?"Hide":"Show"} ${i.length} done ${i.length===1?"step":"steps"}"><span class="setup-fold-mark" aria-hidden="true">✓</span><span>${i.length} done</span></button>`:null}
|
|
64
64
|
<ol class="setup-steps" id="setupSteps">${r.map(l)}</ol>
|
|
65
|
-
</div>`}var ti=e=>!e.sesAccount||e.provider?.state==="production";function
|
|
66
|
-
<div class="pub-row"><code class="pub-val">${
|
|
65
|
+
</div>`}var ti=e=>!e.sesAccount||e.provider?.state==="production";function qa(e){return e?.provider==="ses"?e.aws_region?`Sends through Amazon SES in ${e.aws_region}.`:"Sends through Amazon SES.":"Sends through local development\u2019s stand-in, which delivers nothing."}function ja(e){return e.filter(t=>t.status==="scheduled"&&!t.email_only).sort((t,n)=>t.fire_at-n.fire_at)[0]??null}function Tu(e,t=!1,n=null,s=!1,i=null){let r=[],a=e.filter(A=>Ce(A,"missed"));a.length&&r.push({level:"red",text:`${a.length} scheduled send${a.length===1?"":"s"} passed the fire time without going out.`});let l=e.flatMap(A=>{let L=fe(A,"wedged");return L?[{s:A,count:L.count}]:[]}),[d]=l;if(d){let A=l.reduce((q,S)=>q+S.count,0),L=A===1?"delivery":"deliveries";r.push({level:"red",text:l.length===1?o`<a href="#/sent/${d.s.id}">${d.s.subject}</a> has ${A} ambiguous ${L} awaiting a decision; resolve ${A===1?"it":"them"} on its page.`:o`${A} ambiguous ${L} across <a href="#/sent">${l.length} sends</a> await a decision; resolve them on the Sent page.`})}let u=be(),p=e.flatMap(A=>{let L=fe(A,"refused");return L?[{s:A,c:L}]:[]}),g=u?p.filter(A=>A.c.cause==="not_connected"):[],h=p.filter(A=>!g.includes(A)),m=A=>A.length===1&&A[0]?o`<a href="#/sent/${A[0].s.id}">${A[0].s.subject}</a>`:o`<a href="#/sent">${A.length} sends</a>`;g.length&&r.push({level:"red",text:o`<span class="dash-not-connected">${ys(m(g),g.length)}</span>`});let[y]=h;y&&r.push({level:"red",text:o`${m(h)}: ${y.c.message}`});let E=e.filter(A=>Ce(A,"stuck")&&!kn(A)),[R]=E;R&&r.push({level:"amber",text:E.length===1?o`<a href="#/sent/${R.id}">${R.subject}</a>: ${fe(R,"stuck")?.message}`:o`<a href="#/sent">${E.length} sends</a> have handed off no one for a while, with no retry or provider problem to explain it.`});let O=e.flatMap(A=>{let L=fe(A,"provider_unavailable");return L?.severity==="warn"?[{s:A,c:L}]:[]}),[H]=O;H&&r.push({level:"amber",text:o`<a href="#/sent/${H.s.id}">${H.s.subject}</a>: ${H.c.message}`});let I=e.flatMap(A=>{let L=fe(A,"bounce_spike");return L?[{s:A,c:L}]:[]}),[v]=I;v&&r.push({level:"amber",text:o`<a href="#/sent/${v.s.id}">${v.s.subject}</a>: ${v.c.message}`});let w=e.flatMap(A=>{let L=fe(A,"no_receipts");return L?[{s:A,c:L}]:[]}),[M]=w;M&&r.push({level:"amber",text:w.length===1?o`<a href="#/sent/${M.s.id}">${M.s.subject}</a>: ${M.c.message}`:o`<a href="#/sent">${w.length} sends</a> have had no delivery receipt long after they went out. The provider's events may not be reaching this app, so its bounces suppress no one and its complaints unsubscribe no one.`}),u&&!g.length&&!t&&r.push({level:"amber",text:o`<span class="dash-not-connected">No email provider connected, so nothing can be sent yet. ${He()} to start sending.</span>`});let V=Rn(n);V&&r.push({level:"red",text:Ta(V)});for(let A of n?.warnings??[])V&&Ln(A)||r.push({level:Ln(A)?"red":"amber",text:o`<span class="dash-provider-warning">${Bs(A)}</span>`});return pt(n)&&!s&&r.push({level:"amber",text:o`<span class="dash-sandbox">${xa()}</span>`}),i&&r.push({level:"amber",text:o`<span class="dash-notify-failed">Kestrel’s last notification didn’t arrive: ${i.error.replace(/[.!?]?$/,".")} Check <a href="#${Vt("notifications")}">Settings → Notifications</a>.</span>`}),r}function Lu(e){if(!e.length)return o``;let t=e.some(n=>n.level==="red")?"red":"amber";return o`<div class="health ${t}"><span class="health-dot">⚠️</span><div>${e.map(n=>o`<div>${n.text}</div>`)}</div></div>`}var Va=e=>e.filter(t=>t.status==="sending"&&!kn(t));async function ni(e,t){ie(t,"Dashboard");let n=()=>{t.aborted||ne(ni)};f(e,o`<div class="dash" id="dash"><p class="muted">Loading…</p></div>`);let s=c("#dash",e),i,r,a,l,d;try{let[x,K,F,ee]=await Promise.all([C("/api/posts?limit=200",{signal:t}),C("/api/sends?limit=200",{signal:t}),C("/api/subscribers",{signal:t}),ut(Z.appConfig?.deployment,t)]);d=ee,i=x.posts,r=K,a=F.counts,l=F.workers_plan_advice}catch(x){re(s,z(x),n);return}let u=r.sends,p=new Map,g=Io(Z.appConfig),h=Z.appConfig?.deployment??null,m=()=>u.some(x=>(x.status==="sending"||x.status==="sent")&&!x.email_only),y=()=>{let x=Z.appConfig,K=x?.notification_status.last_failure??null;return{notConnected:be(),sesAccount:!be()&&Jo(h),provider:d,name:g.name,named:!!x?.settings.publication?.name?.trim(),notifyTo:x?.settings.notifications.to.length??0,notifyFailed:K!==null,onList:a.confirmed+a.pending,connectedTo:qa(h),firstPost:i.filter(F=>!F.email_only).sort((F,ee)=>F.created_at-ee.created_at)[0]?.subject??null,firstSend:ja(u),subscribeUrl:`${h?.app_origin||location.origin}/subscribe`}},E=()=>!m(),R=()=>Lu(Tu(Kt(u,p),E()&&be(),d,E(),Z.appConfig?.notification_status.last_failure??null)),O=!1,H=(x=!1)=>{let K=c("#dashSetup",s),F=x||document.activeElement?.closest("#dashSetup [data-act='toggle-done']")!=null,ee=i.length?"card":"checklist";f(K,ee==="checklist"||E()?Fa(y(),ee,O):o``),el(K,n,t);let Le=K.querySelector("[data-act='toggle-done']");Le&&(Le.onclick=()=>{O=!O,H(!0)},F&&Le.focus())};if(!i.length){f(s,o`<div class="dash-head"><div><h1>${g.name}</h1>${g.tagline?o`<p class="muted dash-tagline">${g.tagline}</p>`:null}<p class="muted">Let’s get your first post out the door.</p></div></div><div id="dashHealth">${R()}</div><div id="dashSetup"></div><section class="dash-section"><h2>API access</h2>${Xa(!1)}</section>`),H(),Qa(s,n,t);return}let I=[{label:"Confirmed",emph:!0,v:a.confirmed,filter:"confirmed"},{label:"Pending",v:a.pending,filter:"pending"},{label:"Unsubscribed",v:a.unsubscribed,filter:"unsubscribed"},{label:"Suppressed",v:a.suppressed,filter:"suppressed"}],v=o`<div class="tiles">${I.map(x=>o`<a class="tile${x.emph?" tile-emph":""}" href="#/subscribers/${x.filter}"><span class="tile-n">${x.v}</span><span class="tile-label">${x.label}${x.sub?o`<span class="tile-sub">${x.sub}</span>`:null}</span></a>`)}</div>`,w=i.filter(x=>x.status==="draft").slice(0,5),M=w.length?o`<div class="table-wrap"><table class="dash-drafts"><tbody>${w.map(x=>o`<tr class="clickable" data-id="${x.id}"><td>${kt(o`<a href="#/edit/${x.id}">${x.subject||o`<em>untitled</em>`}</a>`,x)}</td><td class="muted edited">edited ${W(x.updated_at)}</td></tr>`)}</tbody></table></div>`:o`<p class="muted">No drafts in progress.</p>`,V=h?.app_origin||location.origin,A=o`<div class="card pub-card">
|
|
66
|
+
<div class="pub-row"><code class="pub-val">${V}</code>${An(V,"Copy the publication\u2019s address")}</div>
|
|
67
67
|
<div class="pub-foot"><a href="/" target="_blank" rel="noopener">View publication ↗</a></div>
|
|
68
|
-
</div>`,
|
|
68
|
+
</div>`,L=i.some(x=>x.author_client===as||x.author_client===ls),q=Xa(L),S=o`<div class="row quick-actions"><button data-act="new-post">New post</button><button data-act="add-sub">Add subscriber</button><button data-nav="#/settings">Edit publication</button></div>`;f(s,o`
|
|
69
69
|
<div class="dash-head">
|
|
70
70
|
<div><h1>${g.name}</h1>${g.tagline?o`<p class="muted dash-tagline">${g.tagline}</p>`:null}</div>
|
|
71
71
|
<button class="primary" data-act="new-post">New post</button>
|
|
72
72
|
</div>
|
|
73
73
|
<div id="dashHealth">${R()}</div>
|
|
74
74
|
<div id="dashSetup"></div>
|
|
75
|
-
<div id="dashActive">${
|
|
75
|
+
<div id="dashActive">${Za(Va(Kt(u,p)))}</div>
|
|
76
76
|
<section class="dash-section"><h2>Subscribers</h2>${v}${l?o`<p class="workers-plan" id="dashWorkersPlan" role="status">${l}</p>`:null}</section>
|
|
77
77
|
<div class="dash-cols">
|
|
78
|
-
<section class="dash-section"><h2>Scheduled</h2><div id="dashScheduled">${
|
|
79
|
-
<section class="dash-section"><h2>Drafts</h2>${
|
|
78
|
+
<section class="dash-section"><h2>Scheduled</h2><div id="dashScheduled">${za(Wa(u))}</div></section>
|
|
79
|
+
<section class="dash-section"><h2>Drafts</h2>${M}</section>
|
|
80
80
|
</div>
|
|
81
|
-
<section class="dash-section"><h2>Sent</h2><div id="dashSent">${
|
|
81
|
+
<section class="dash-section"><h2>Sent</h2><div id="dashSent">${Ka(u)}</div></section>
|
|
82
82
|
<section class="dash-section"><h2>Quick actions</h2>${S}</section>
|
|
83
83
|
<div class="dash-cols">
|
|
84
|
-
<section class="dash-section"><h2>Publication</h2>${
|
|
85
|
-
<section class="dash-section"><h2>API access</h2>${
|
|
86
|
-
</div>`),
|
|
84
|
+
<section class="dash-section"><h2>Publication</h2>${A}</section>
|
|
85
|
+
<section class="dash-section"><h2>API access</h2>${q}</section>
|
|
86
|
+
</div>`),H(),Qa(s,n,t);for(let x of B("tr[data-id]",s))x.onclick=K=>{let F=K.target;F instanceof Element&&F.tagName!=="A"&&!F.closest("button")&&(location.hash=`#/edit/${x.dataset.id}`)};Ga(s),Ja(s),Ya(s);let _=Ns(s,t);_();let P=0,$=async()=>{let x=++P;try{let K=await C("/api/sends?limit=200",{signal:t});if(x!==P)return;u=K.sends,f(c("#dashScheduled",s),za(Wa(u))),Ya(s),_(),f(c("#dashSent",s),Ka(u)),Ga(s),H(),T()}catch{}},T=()=>{let x=Kt(u,p);f(c("#dashHealth",s),R()),f(c("#dashActive",s),Za(Va(x))),Ja(s),Ru(s,[...p.values()])},G=x=>x==="scheduled"||x==="due";Wt(r,{update:x=>{for(let K of x.sends)p.set(K.id,K);for(let K of x.removed)p.delete(K);T(),(x.changes.length||x.removed.length||x.sends.some(K=>G(at(K))))&&$()},stale:n},t)}var Wa=e=>e.filter(t=>t.status==="scheduled").sort((t,n)=>t.fire_at-n.fire_at);function Ka(e){let t=e.filter(n=>n.status==="sent"||n.status==="sending").slice(0,5);return t.length?o`<div class="table-wrap"><table class="dash-sent"><thead><tr><th>Subject</th><th>Status</th><th class="num">Recipients</th><th class="num">Delivered</th><th></th></tr></thead><tbody>${t.map(n=>{let s=n.email_only?n.links.unlisted:n.links.archive;return o`<tr class="clickable" data-send="${n.id}"><td>${kt(o`<a href="#/sent/${n.id}">${n.subject}</a>`,n)}</td><td>${Qe(n.status)}</td><td class="num">${n.audience.count.toLocaleString()}</td><td class="num delivered">${Gt(n.counts)}</td><td class="act">${s?o`<a class="ghost-link" href="${s}" target="_blank" rel="noopener">${n.email_only?o`Web version ↗`:o`Archive ↗`}</a>`:null}</td></tr>`})}</tbody></table></div>`:o`<p class="muted">No sends yet.</p>`}function Ga(e){for(let t of B("tr[data-send]",e))t.onclick=n=>{let s=n.target;s instanceof Element&&s.tagName!=="A"&&(location.hash=`#/sent/${t.dataset.send}`)}}function Ru(e,t){for(let n of t){let s=B("#dashSent tr[data-send]",e).find(i=>i.dataset.send===n.id)?.querySelector("td.delivered");s&&f(s,Gt(n.counts))}}function za(e){if(!e.length)return o`<p class="muted">Nothing scheduled.</p>`;let t=ws("card");return o`${e.map(n=>o`<div class="card spread clickable nextup sched-card" data-post="${n.post_id}"><div><a class="card-link sched-subj" href="#/edit/${n.post_id}">${n.subject}</a><div class="muted">${Ms(n)} · ${W(n.fire_at)} · ${lt(n.audience.count)}${Is(n)}</div>${t}${Ce(n,"remade")?o`<div class="sched-remade-mark">Look changed since your last test</div>`:null}</div></div>`)}`}function Ya(e){for(let t of B("#dashScheduled .nextup",e))t.onclick=n=>{let s=n.target;s instanceof Element&&s.tagName!=="A"&&(location.hash=`#/edit/${t.dataset.post}`)}}function Za(e){return e.length?o`<section class="dash-section"><h2>Active send${e.length===1?"":"s"}</h2>${e.map(t=>Os(t,{stuckNote:!1}))}</section>`:o``}function Ja(e){for(let t of B("#dashActive .active-card[data-watch]",e))t.onclick=n=>{let s=n.target;s instanceof Element&&s.tagName!=="A"&&(location.hash=`#/sent/${t.dataset.watch}`)}}function Qa(e,t,n){el(e,t,n),je(e)}function el(e,t,n){for(let s of B("[data-nav]",e))s.onclick=()=>{location.hash=s.dataset.nav??""};for(let s of B("[data-act='new-post']",e))s.onclick=()=>zo(s);for(let s of B("[data-act='add-sub']",e))s.onclick=()=>Us(t,n)}function Xa(e){return e?o`<div class="card pub-card">
|
|
87
87
|
<p class="conn-status"><span class="conn-dot" aria-hidden="true"></span>Claude is connected.</p>
|
|
88
|
-
<div class="pub-foot pub-links"><a href="#/api-reference">${
|
|
88
|
+
<div class="pub-foot pub-links"><a href="#/api-reference">${D("code")}API reference →</a><a href="#/docs/connect-claude/working-with-claude">${D("article")}Working with Claude →</a></div>
|
|
89
89
|
</div>`:o`<div class="card pub-card">
|
|
90
90
|
<p class="pub-note">Let Claude draft, proofread, and schedule your posts.</p>
|
|
91
|
-
<div class="pub-foot pub-links"><a href="#/docs/connect-claude">${
|
|
92
|
-
</div>`}var si=Math.floor(5e3);var
|
|
91
|
+
<div class="pub-foot pub-links"><a href="#/docs/connect-claude">${D("article")}Connect Claude →</a><a href="#/api-reference">${D("code")}API reference →</a></div>
|
|
92
|
+
</div>`}var si=Math.floor(5e3);var Zg=`Workers Free suits a list of up to about ${1e3.toLocaleString("en-US")} subscribers. Past about ${si.toLocaleString("en-US")}, one send can use up the day\u2019s database writes and stop this newsletter until midnight UTC.`,Cu="Move to Workers Paid, or, if the account is on it already, set SUBREQUEST_BUDGET to 10000.";function tl(e){return`On the Workers Free plan\u2019s limits, a send to ${e.toLocaleString("en-US")} recipients may use up the day\u2019s database writes and stop this newsletter until midnight UTC, the send included. Workers Free suits a list of up to about ${1e3.toLocaleString("en-US")} subscribers. ${Cu}`}var qs={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};function nl(e){return qs[e.slice(e.lastIndexOf(".")).toLowerCase()]}function js(e){return e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80).replace(/-+$/g,"")}function In(e){return e.replace(/^https?:\/\//,"")}function sl(){let e=Er("");return e?In(e):"/archive/"}function Xe(e,t){return{emailOnly:e.email_only,slug:e.slug,slugAuto:e.slug_auto,subject:e.subject,slugTaken:t,fixed:e.published_at!==null}}function oi(e){return e.emailOnly?o`Sends by email only`:o`Sends by email and publishes at <code>${sl()}${e.slug}</code>`}function ii(e){return D(e.emailOnly?"mail":"link")}var Au="Listed on your home page and in your public archive. Unchecked, it\u2019s sent as email only: anyone with the email can still open its web version.",ol="Fixed once the post is sent, since people may have its link.";function il(e,t){return e.fixed?o`<p class="pub-note">${t}</p>`:e.slugAuto&&e.slugTaken?o`<p class="pub-taken">${D("info")}<span>Another post has <code>${e.slugTaken}</code>, so a number was added. You can change it above.</span></p>`:e.slugAuto?o`<p class="pub-note">Follows the subject until you type your own.</p>`:null}function Hu(e,t,{include:n=!0,fixedNote:s=ol}){let i=n?o`<label class="listing-check"><input type="checkbox" id="${t}Include"${e.emailOnly?null:o` checked`}><span><strong>Include in archive</strong><span class="listing-help">${Au}</span></span></label>`:null;return e.emailOnly?o`${i}`:o`${i}<div class="pub-address"><label class="pub-label" for="${t}Slug">Archive address</label><label class="url-field${e.fixed?" readonly":""}" id="${t}Field"><span class="url-base">${sl()}</span><input type="text" id="${t}Slug" value="${e.slug}" spellcheck="false" autocomplete="off" autocapitalize="off"${e.fixed?o` readonly`:null}></label><div id="${t}Note">${il(e,s)}</div></div>`}function Pu(e,t,n,s,{fixedNote:i=ol,onChange:r}){let a=e.querySelector(`#${n}Include`);a&&(a.onchange=()=>{t.emailOnly=!a.checked,s(),r?.()});let l=e.querySelector(`#${n}Slug`),d=e.querySelector(`#${n}Note`);!l||!d||t.fixed||(l.onfocus=()=>l.select(),l.oninput=()=>{t.slug=l.value,t.slugAuto=!1,e.querySelector(`#${n}Field`)?.classList.remove("is-invalid"),f(d,il(t,i)??o``)},l.onblur=()=>{l.value.trim()===""&&(t.slugAuto=!0,t.slug=js(t.subject)||t.slug,s())})}function Mn(e,t){let n={};return t.emailOnly!==e.emailOnly&&(n.email_only=t.emailOnly),!e.fixed&&!t.emailOnly&&(t.slugAuto&&!e.slugAuto?n.slug_auto=!0:!t.slugAuto&&t.slug!==e.slug&&(n.slug=t.slug)),Object.keys(n).length?n:null}function Lt(e,t,n,s={}){let i=()=>{f(e,Hu(t,n,s)),Pu(e,t,n,i,s)};i()}function Nn(e,t,n){if(!(n instanceof se)||n.field!=="slug"&&n.field!=="slug_auto")return!1;let s=e.querySelector(`#${t}Note`),i=e.querySelector(`#${t}Slug`);return!s||!i?!1:(e.querySelector(`#${t}Field`)?.classList.add("is-invalid"),f(s,o`<p class="pub-error" role="alert">${n.message}</p>`),i.focus(),!0)}var Rt=z;function Vs(e,t,n){let s=e.c_in_flight||0,r=pe(o`<h3>Resolve ${s} ambiguous ${s===1?"delivery":"deliveries"}</h3>
|
|
93
93
|
<p class="hint">A transport error left ${s} recipient${s===1?"":"s"} in flight: the request went out but the provider never confirmed, so there’s no way to know whether it was accepted. To avoid mailing anyone twice, the send won’t retry ${s===1?"it":"them"} on its own, so it can’t finish until you decide. Neither choice re-sends this post.</p>
|
|
94
94
|
<p class="hint">Kestrel can’t tell whether ${s===1?"this email":"these emails"} went out, so unless you know, <strong>Assume not sent</strong> is the safe default.</p>
|
|
95
95
|
<p class="hint"><strong>Assume not sent</strong>: recorded as unsent. ${s===1?"That reader":"Those readers"} may miss this post but ${s===1?"gets":"get"} your next one, and no one is mailed twice.</p>
|
|
96
96
|
<p class="hint"><strong>Assume sent</strong>: recorded as accepted by your provider, with delivery still waiting on its receipt. Choose this when you know otherwise, such as a reader who says they got it.</p>
|
|
97
|
-
<div class="actions"><button type="button" id="rCancel">Cancel</button><button type="button" id="rUnsent">Assume not sent</button><button type="button" class="primary" id="rAccepted">Assume sent</button></div>`,n);c("#rCancel",r.el).onclick=r.close;let a=(u,p,g)=>J(u,"Resolving\u2026",async()=>{r.clearError();try{let h=await C(`/api/sends/${e.id}/resolve`,{method:"POST",json:{resolution:p}});r.close(),
|
|
97
|
+
<div class="actions"><button type="button" id="rCancel">Cancel</button><button type="button" id="rUnsent">Assume not sent</button><button type="button" class="primary" id="rAccepted">Assume sent</button></div>`,n);c("#rCancel",r.el).onclick=r.close;let a=(u,p,g)=>J(u,"Resolving\u2026",async()=>{r.clearError();try{let h=await C(`/api/sends/${e.id}/resolve`,{method:"POST",json:{resolution:p}});r.close(),j(h.completed?"Send completed":`Marked ${g}`),t()}catch(h){r.error(Rt(h))}}),l=c("#rUnsent",r.el),d=c("#rAccepted",r.el);l.onclick=()=>a(l,"unsent","not sent"),d.onclick=()=>a(d,"accepted","sent")}async function Ws(e,t,n,s){let i=s;if(!i)try{let y=await C(`/api/posts/${e.post_id}`,{signal:n});i=Xe(y.post,y.subject_slug_held)}catch(y){n.aborted||j(Rt(y));return}let r=i,a={...r},l=xt(vs()),d=new Date(xt(new Date(e.fire_at))),u=pe(o`<h3 id="rsHead">Edit schedule</h3>
|
|
98
98
|
<p class="hint" id="rsHint">It sends at the time you pick, with a cancelable window until then.</p>
|
|
99
|
-
${
|
|
100
|
-
<label for="rsWhen">Send at</label><input type="datetime-local" id="rsWhen" min="${l}" value="${
|
|
99
|
+
${$r()}
|
|
100
|
+
<label for="rsWhen">Send at</label><input type="datetime-local" id="rsWhen" min="${l}" value="${xt(d)}">
|
|
101
101
|
<div class="dialog-settings" id="rsForm"></div>
|
|
102
|
-
<div class="actions"><button type="button" id="rsCancel">Cancel</button><button type="button" class="primary" id="rsGo">Save</button></div>`,n),p=c(".modal",u.el);p.setAttribute("aria-labelledby","rsHead"),
|
|
103
|
-
`).map(n=>{let s,i=!1,r=n.match(/^(\s*)(```+|~~~+)(.*)$/);if(r){t=!t;let a=r[3]?`<span class="cx-md-bmark">${te(r[3])}</span>`:"";s=`${r[1]}${te(r[2]??"")}${a}`}else t?(i=!0,s=te(n)):s=
|
|
104
|
-
`:l!==void 0?t+=te(l):d!==void 0?(t+=`<span class="cx-str">${te(d)}</span>`,s=!1):u!==void 0?(t+=`<span class="cx-str">${te(u).replace(
|
|
105
|
-
`,s=!0):m!==void 0?t+=`<span class="cx-punct">${te(m)}</span>`:y!==void 0&&(s&&/^[A-Za-z_]\w*=/.test(y)?t+=te(y):s?(t+=`<span class="cx-tag">${te(y)}</span>`,s=!1):y.startsWith("-")?t+=`<span class="cx-num">${te(y)}</span>`:t+=te(y)),n=i.index+r.length}return Y(t+te(e.slice(n)))}var
|
|
102
|
+
<div class="actions"><button type="button" id="rsCancel">Cancel</button><button type="button" class="primary" id="rsGo">Save</button></div>`,n),p=c(".modal",u.el);p.setAttribute("aria-labelledby","rsHead"),Lt(c("#rsForm",p),a,"rs");let g=c("#rsGo",p),h=c("#rsWhen",p),m=!1;c("#rsCancel",p).onclick=()=>{u.close(),m&&t()},g.onclick=()=>J(g,"Saving\u2026",async()=>{u.clearError();let y=h.value,E=y?new Date(y).getTime():Number.NaN;if(Number.isNaN(E)){u.error("Pick a valid date & time",h);return}let R=E===d.getTime();if(!R&&gs(E)){u.error(bs(),h);return}let O=Mn(r,a);if(R&&!O){u.close();return}let H=I=>I instanceof se&&I.status===404?(u.close(),j("This post was deleted elsewhere."),Ue(),!0):!1;if(O)try{await C(`/api/posts/${e.post_id}/settings`,{method:"PUT",json:O})}catch(I){!H(I)&&!Nn(p,"rs",I)&&u.error(Rt(I));return}if(!R)try{await C(`/api/sends/${e.id}/reschedule`,{method:"POST",json:{fire_at:new Date(E).toISOString()}})}catch(I){if(H(I))return;let v=I instanceof se&&I.field==="fire_at";if(O){if(r={...a},m=!0,v){u.error(`Settings saved. ${Rt(I)}`,h);return}u.close(),j(`Settings saved. The send time didn\u2019t change: ${Rt(I)}`),t();return}v?u.error(Rt(I),h):u.error(Rt(I));return}u.close(),j(R?"Saved":"Rescheduled"),t()}),h.focus()}function rl(e,t={}){return["default-src 'none'","script-src 'none'","object-src 'none'","frame-src 'none'","base-uri 'none'",`form-action ${e}`,t.framed?null:"frame-ancestors 'none'","img-src * data:","style-src 'unsafe-inline' https://fonts.googleapis.com","font-src https://fonts.gstatic.com"].filter(n=>n!==null).join("; ")}var al=e=>e.preventDefault(),nn="allow-same-origin allow-popups allow-popups-to-escape-sandbox";function sn(e){for(let t of e.querySelectorAll("a[href], area[href]")){if(t.getAttribute("href")?.startsWith("#")){t.addEventListener("click",al),t.addEventListener("auxclick",al);continue}t.target="_blank",t.rel="noopener noreferrer"}}function Iu(e,t){let n=/<head(\s[^>]*)?>/i;return n.test(e)?e.replace(n,s=>s+t):t+e}function Ks(e){return Iu(e,`<meta http-equiv="Content-Security-Policy" content="${rl("'none'",{framed:!0})}">`)}function ll(e){return e.replace(/\{\{\s*(?:if\s+)?[\w.]+\s*\}\}/g,t=>`<span class="cx-var">${t}</span>`)}function Mu(e){let t=te(e);return t=t.replace(/"[^&]*?"/g,n=>`<span class="cx-str">${n}</span>`),t=t.replace(/(<\/?)([a-zA-Z][\w-]*)/g,(n,s,i)=>`<span class="cx-punct">${s}</span><span class="cx-tag">${i}</span>`),t=t.replace(/(\/?)>/g,(n,s)=>`<span class="cx-punct">${s}></span>`),ll(t)}function Nu(e){let t=te(e);return t=t.replace(/"[^&]*?"/g,n=>`<span class="cx-str">${n}</span>`),t=t.replace(/#[0-9a-fA-F]{3,8}\b/g,n=>`<span class="cx-num">${n}</span>`),t=t.replace(/@[\w-]+/g,n=>`<span class="cx-at">${n}</span>`),t=t.replace(/^(\s*)(?![@\s])([^\n{}<]+?)(\s*)\{$/gm,(n,s,i,r)=>`${s}<span class="cx-sel">${i}</span>${r}{`),t=t.replace(/^(\s*)([a-z-]+)(\s*:)/gm,(n,s,i,r)=>`${s}<span class="cx-prop">${i}</span>${r}`),ll(t)}function cl(e){return Y(String(e).split(/(<style>[\s\S]*?<\/style>)/).map(t=>{let n=t.match(/^<style>([\s\S]*?)<\/style>$/);return n?`<span class="cx-punct"><</span><span class="cx-tag">style</span><span class="cx-punct">></span>${Nu(n[1]??"")}<span class="cx-punct"></</span><span class="cx-tag">style</span><span class="cx-punct">></span>`:Mu(t)}).join(""))}function ri(e){return te(e).replace(/(`[^`\n]+`)|(!?)(\[[^\]\n]*\])\(([^)\n]*)\)|(\*\*|__)([^\n]+?)\5|\*([^*\n]+?)\*|\b_([^_\n]+?)_\b/g,(t,n,s,i,r,a,l,d,u)=>{if(n)return`<span class="cx-md-code">${n}</span>`;if(i!==void 0)return`${s||""}${i}(<span class="cx-md-url">${r}</span>)`;if(a)return`<span class="cx-md-mark">${a}</span><span class="cx-md-strong">${l}</span><span class="cx-md-mark">${a}</span>`;let[p,g]=d!==void 0?["*",d]:["_",u];return`<span class="cx-md-mark">${p}</span><span class="cx-md-em">${g}</span><span class="cx-md-mark">${p}</span>`})}function Ou(e){let t=e.match(/^(\s{0,3}#{1,6})(\s.*)?$/);if(t)return`<span class="cx-md-hmark">${te(t[1]??"")}</span><span class="cx-md-htext">${te(t[2]||"")}</span>`;if(/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/.test(e))return`<span class="cx-md-bmark">${te(e)}</span>`;let n=e.match(/^(\s{0,3})((?:>\s?)+)(.*)$/);if(n)return`${te(n[1]??"")}<span class="cx-md-bmark">${te(n[2]??"")}</span>${ri(n[3]??"")}`;let s=e.match(/^(\s*)([-*+]|\d{1,9}[.)])(\s+)(.*)$/);return s?`${s[1]}<span class="cx-md-bmark">${te(s[2]??"")}</span>${s[3]}${ri(s[4]??"")}`:ri(e)}function dl(e){let t=!1;return Y(String(e).split(`
|
|
103
|
+
`).map(n=>{let s,i=!1,r=n.match(/^(\s*)(```+|~~~+)(.*)$/);if(r){t=!t;let a=r[3]?`<span class="cx-md-bmark">${te(r[3])}</span>`:"";s=`${r[1]}${te(r[2]??"")}${a}`}else t?(i=!0,s=te(n)):s=Ou(n);return`<span class="cx-md-ln${i?" cx-md-band":""}">${s}</span>`}).join(""))}var Du=/(\/\/[^\n]*|\/\*[\s\S]*?\*\/)|("(?:\\.|[^"\\\n])*")(\s*:)?|(?<![\w.-])(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)(?![\w.])|\b(true|false|null)\b|([{}[\],])/g;function ai(e){let t="",n=0;for(let s of e.matchAll(Du)){t+=te(e.slice(n,s.index));let[i,r,a,l,d,u]=s;r!==void 0?t+=`<span class="cx-punct">${te(r)}</span>`:a!==void 0?t+=l?`<span class="cx-prop">${te(a)}</span><span class="cx-punct">${te(l)}</span>`:`<span class="cx-str">${te(a)}</span>`:d!==void 0?t+=`<span class="cx-num">${d}</span>`:u!==void 0?t+=`<span class="cx-tag">${u}</span>`:t+=`<span class="cx-punct">${te(i)}</span>`,n=s.index+i.length}return Y(t+te(e.slice(n)))}function ul(e){return ai(JSON.stringify(e,null,2)??"")}var Bu=/(\\\n)|(\\[\s\S])|('[^']*')|("(?:\\[\s\S]|[^"\\])*")|(\$\{?[A-Za-z_]\w*\}?)|(&&|\|\||[|;])|(\n)|(#[^\n]*)|([^\s'"$|&;\\]+)/g,Uu=/\$\{?[A-Za-z_]\w*\}?/g;function Gs(e){let t="",n=0,s=!0;for(let i of e.matchAll(Bu)){t+=te(e.slice(n,i.index));let[r,a,l,d,u,p,g,h,m,y]=i;a!==void 0?t+=`<span class="cx-punct">\\</span>
|
|
104
|
+
`:l!==void 0?t+=te(l):d!==void 0?(t+=`<span class="cx-str">${te(d)}</span>`,s=!1):u!==void 0?(t+=`<span class="cx-str">${te(u).replace(Uu,'<span class="cx-var">$&</span>')}</span>`,s=!1):p!==void 0?(t+=`<span class="cx-var">${p}</span>`,s=!1):g!==void 0?(t+=`<span class="cx-punct">${te(g)}</span>`,s=!0):h!==void 0?(t+=`
|
|
105
|
+
`,s=!0):m!==void 0?t+=`<span class="cx-punct">${te(m)}</span>`:y!==void 0&&(s&&/^[A-Za-z_]\w*=/.test(y)?t+=te(y):s?(t+=`<span class="cx-tag">${te(y)}</span>`,s=!1):y.startsWith("-")?t+=`<span class="cx-num">${te(y)}</span>`:t+=te(y)),n=i.index+r.length}return Y(t+te(e.slice(n)))}var Fu=new Map([[as,"via Claude Code"],[dr,"via the Kestrel CLI"],[ls,"via Claude"]]);function on(e,t,n){return e?e==="service"?n?`the service token ${n}`:"a service token":t===hn?e:t===null?`${e} via the API`:`${e} ${Fu.get(t)??`via ${t}`}`:null}function pl(e){return e.kind==="service"?on("service",null,e.token_id)??"a service token":on(e.email??null,e.client)??"a person"}var qu=[["scheduled_by","scheduled"],["rescheduled_by","rescheduled"],["canceled_by","canceled"],["resolved_by","resolved"]];function ml(e){let n=qu.flatMap(([s,i])=>{let r=e[s];return r?[`${i} by ${pl(r)}`]:[]}).join(" \xB7 ");return n?n.charAt(0).toUpperCase()+n.slice(1):null}function ju(e,t){return e.kind==="human"&&t?.kind==="human"&&e.email===t.email&&e.client===hn}function fl(e,t){let n=e.rescheduled_by?{verb:"Rescheduled",actor:e.rescheduled_by}:e.scheduled_by?{verb:"Scheduled",actor:e.scheduled_by}:null;return!n||ju(n.actor,t)?null:`${n.verb} by ${pl(n.actor)}`}var Vu={idleMs:5e3,maxMs:3e4};function hl(e,t=Vu){let n=null,s=null,i=()=>{n!==null&&clearTimeout(n),s!==null&&clearTimeout(s),n=null,s=null},r=()=>{i(),e()};return{touch(){n!==null&&clearTimeout(n),n=setTimeout(r,t.idleMs),s===null&&(s=setTimeout(r,t.maxMs))},cancel:i,get pending(){return n!==null||s!==null}}}var zs=class{constructor(t){this.read=t;this.#e=JSON.stringify(t())}read;#e;snapshot(){return JSON.stringify(this.read())}get dirty(){return this.snapshot()!==this.#e}markSaved(t=this.snapshot()){this.#e=t}};var bl=Promise.resolve();function li(e){bl=e}function gl(){return bl.then(()=>{},()=>{})}function vl(e){if(!(e instanceof se)||e.status!==409)return null;let t=e.data;return t?.error==="stale_revision"&&typeof t.current_revision=="string"?{kind:"stale",revision:t.current_revision,author:typeof t.author=="string"?t.author:null,client:typeof t.author_client=="string"?t.author_client:null}:{kind:"locked"}}var Ys=class{base;warnedRevision=null;constructor(t){this.base=t}saved(t){this.base=t}noteWarned(t){t.kind==="stale"&&(this.warnedRevision=t.revision)}adoptWarned(){this.warnedRevision!==null&&(this.base=this.warnedRevision),this.warnedRevision=null}clearWarning(){this.warnedRevision=null}decide(t,n){if(n.saving||this.base!==n.baseAtRequest)return"ignore";if(t.status!=="draft")return{kind:"locked"};let s=t.revision;return s&&s!==this.base&&s!==this.warnedRevision?{kind:"stale",revision:s,author:t.author,client:t.client}:"fresh"}};function Sl(e){return`#/web/post/${encodeURIComponent(e)}`}function wl(e,t){if(e!=="post"||!t)return null;try{return decodeURIComponent(t)}catch{return null}}function Wu(e){let t=o`<span class="web-bar-tag">Web version</span>`;return e?o`${t} <span class="web-bar-text">Not public yet</span>`:t}function yl(e){try{return new URL(e).href}catch{return null}}function $l(e,t,n){let s=t?yl(t):null;if(s)for(let i of e.querySelectorAll("a[href], area[href]")){let r=i.getAttribute("href");r&&yl(r)===s&&i.setAttribute("href",n)}}function Ku(e){location.replace(e)}async function Gu(e,t){try{return await C(`/api/posts/${encodeURIComponent(e)}`,{signal:t})}catch{return null}}async function ci(e,t,n){ie(n,"Web version");try{await gl();let[s,i]=await Promise.all([Ut(`/api/posts/${encodeURIComponent(e)}/web`,{signal:n}),Gu(e,n)]);if(n.aborted)return;if(i&&i.post.published_at!==null){Ku(i.post.unlisted_url);return}let r=Wu(i!==null);f(t,o`<div class="web-page">
|
|
106
106
|
<div class="web-bar" role="note"><div class="web-bar-in">${r}</div></div>
|
|
107
|
-
<iframe class="web-frame" sandbox="${
|
|
108
|
-
</div>`);let a=t.querySelector(".web-frame");if(!a)return;a.onload=()=>{let l=a.contentDocument;if(!l||n.aborted)return;
|
|
107
|
+
<iframe class="web-frame" sandbox="${nn}" title="Web version" scrolling="no"></iframe>
|
|
108
|
+
</div>`);let a=t.querySelector(".web-frame");if(!a)return;a.onload=()=>{let l=a.contentDocument;if(!l||n.aborted)return;sn(l),ie(n,l.title?`${l.title} (web version)`:"Web version");let d=()=>{let u=l.body?.scrollHeight;u&&(a.style.height=`${u}px`)};if(d(),l.body&&typeof ResizeObserver<"u"){let u=new ResizeObserver(d);u.observe(l.body),it(n,()=>u.disconnect())}},a.srcdoc=Ks(s)}catch(s){if(n.aborted)return;f(t,o`<div class="web-error"></div>`);let i=t.querySelector(".web-error");if(i){let a=s instanceof se&&s.status===404?"There\u2019s no post here. It may have been deleted.":z(s);re(i,a,()=>ne((l,d)=>ci(e,l,d)))}}}var et=z,zu=[[["heading","Heading"],["bold","Bold (\u2318B)"],["italic","Italic (\u2318I)"]],[["quote","Quote"],["code","Code"],["link","Link (\u2318K)"]],[["ul","Bulleted list"],["ol","Numbered list"],["indent","Indent"]]],Yu=o` readonly`,Zu=o` hidden`,Ju=o` aria-disabled="true"`;async function di(e,t,n){let s=()=>{n.aborted||ne((b,N)=>di(e,b,N))},i=!1,r=(b="This post was deleted elsewhere.")=>{i||(i=!0,j(b),n.aborted||Zs("#/drafts"))};ie(n,"Draft"),f(t,o`<p class="muted">Loading…</p>`);let a,l=null;try{if(a=await C(`/api/posts/${e}`,{signal:n}),n.aborted)return;let b=Xu(a);if(b){Zs(b);return}}catch(b){if(Ne(b)){r("There\u2019s no post here. It may have been deleted.");return}re(t,et(b),s);return}let d=_n(a.post);if(d){try{l=await C(`/api/sends/${d.id}`,{signal:n})}catch(b){if(n.aborted)return;if(Ne(b)){r();return}}if(n.aborted||l&&El(l.send,s))return}let{post:u,markdown:p}=a,g=Z.session?.principal??null,h=Xe(u,a.subject_slug_held),m=!en(u,"edit"),y=en(u,"schedule")!==void 0,E=new Ys(u.current_revision),R=zu.map((b,N)=>o`${N?o`<span class="sep"></span>`:null}${b.map(([k,U])=>o`<button type="button" class="tb" data-fmt="${k}" title="${U}" aria-label="${U}"${m?Ju:null}>${D(k)}</button>`)}`),O=m?Yu:null,H=`${location.origin}${location.pathname}${Sl(e)}`;f(t,o`
|
|
109
109
|
<div class="editor-head">
|
|
110
110
|
<a href="#/drafts" class="back">← Drafts</a>
|
|
111
111
|
<div class="editor-head-right">
|
|
112
|
-
<span class="email-only-mark" id="headEmailOnly"${u.email_only&&!m?null:
|
|
113
|
-
<a class="ghost btn" id="webLink" href="${
|
|
114
|
-
<button type="button" class="ghost" id="settingsBtn">${
|
|
112
|
+
<span class="email-only-mark" id="headEmailOnly"${u.email_only&&!m?null:Zu}>${D("mail")}Email only</span>
|
|
113
|
+
<a class="ghost btn" id="webLink" href="${H}" target="_blank" rel="noopener" aria-label="Web version (opens in a new tab)">Web version ↗</a>
|
|
114
|
+
<button type="button" class="ghost" id="settingsBtn">${D("settings")}<span>Post settings</span></button>
|
|
115
115
|
</div>
|
|
116
116
|
</div>
|
|
117
|
-
${m&&d?o`<div class="banner banner-scheduled banner-split"><div class="banner-top"><div class="sched-main"><span id="schedWhen"></span><div class="sched-by" id="schedBy" hidden></div>${
|
|
117
|
+
${m&&d?o`<div class="banner banner-scheduled banner-split"><div class="banner-top"><div class="sched-main"><span id="schedWhen"></span><div class="sched-by" id="schedBy" hidden></div>${ws("banner")}<div class="sched-remade" id="schedRemade" hidden><span id="schedRemadeMsg"></span></div><div class="sched-note" id="schedDailyWrites" hidden><span class="sched-note-mark" aria-hidden="true">⚠️</span><span class="sched-note-msg" id="schedDailyWritesMsg"></span></div><div class="sched-note" id="schedSandbox" hidden><span class="sched-note-mark" aria-hidden="true">⚠️</span><span class="sched-note-msg" id="schedSandboxMsg"></span></div></div><span class="row" id="schedControls"><button type="button" class="ghost" id="rescheduleSchedule">Edit schedule</button><button type="button" class="ghost" id="cancelSchedule">Cancel</button></span></div><div class="banner-bottom sched-dest"><span class="sched-dest-icon" id="schedDestIcon">${ii(h)}</span><span id="schedDest">${oi(h)}</span></div></div>`:null}
|
|
118
118
|
<div id="freshnessBanner" class="banner banner-conflict" role="alert" hidden></div>
|
|
119
119
|
<div class="editor-form">
|
|
120
120
|
<label for="f-subject">Subject</label>
|
|
121
|
-
<input id="f-subject" value="${u.subject}" placeholder="Untitled"${
|
|
121
|
+
<input id="f-subject" value="${u.subject}" placeholder="Untitled"${O}>
|
|
122
122
|
|
|
123
123
|
<label for="f-markdown">Body</label>
|
|
124
124
|
<div class="composer${m?" composer-locked":""}">
|
|
125
125
|
<div class="composer-head">
|
|
126
126
|
<div class="ctabs" role="tablist">
|
|
127
|
-
<button type="button" class="ctab active" data-tab="edit" data-text="Edit" role="tab" aria-selected="true"><span class="ctab-label">${
|
|
128
|
-
<button type="button" class="ctab" data-tab="preview" data-text="Preview" role="tab" aria-selected="false"><span class="ctab-label">${
|
|
127
|
+
<button type="button" class="ctab active" data-tab="edit" data-text="Edit" role="tab" aria-selected="true"><span class="ctab-label">${D("editable")}Edit</span></button>
|
|
128
|
+
<button type="button" class="ctab" data-tab="preview" data-text="Preview" role="tab" aria-selected="false"><span class="ctab-label">${D("preview")}Preview</span></button>
|
|
129
129
|
</div>
|
|
130
130
|
<div class="toolbar" role="toolbar" aria-label="Formatting">${R}</div>
|
|
131
131
|
</div>
|
|
132
132
|
<div class="composer-body${m?" locked":""}" id="composerBody">
|
|
133
133
|
<pre class="md-hl" id="mdHl" aria-hidden="true"><code></code></pre>
|
|
134
|
-
<textarea id="f-markdown" class="editor"${m?null:o` placeholder="Type your post in Markdown…"`}${
|
|
135
|
-
<iframe id="previewFrame" class="preview" sandbox="${
|
|
134
|
+
<textarea id="f-markdown" class="editor"${m?null:o` placeholder="Type your post in Markdown…"`}${O}>${p}</textarea>
|
|
135
|
+
<iframe id="previewFrame" class="preview" sandbox="${nn}" title="Email preview" hidden></iframe>
|
|
136
136
|
</div>
|
|
137
|
-
${m?o`<div class="composer-foot composer-foot-lock" id="lockFoot" role="status">${
|
|
137
|
+
${m?o`<div class="composer-foot composer-foot-lock" id="lockFoot" role="status">${D("readonly")}<span>Cancel the schedule to edit</span></div>`:o`<div class="composer-foot" id="dropFoot">${D("paperclip")}<span>Paste, drop, or click to add images</span></div>`}
|
|
138
138
|
<input type="file" id="imgInput" accept="image/png,image/jpeg,image/webp,image/gif" multiple hidden>
|
|
139
139
|
</div>
|
|
140
140
|
<div id="warnings"></div>
|
|
141
|
-
${m?null:
|
|
141
|
+
${m?null:Ss("editor-not-connected",o`No email provider connected: you can write and preview, not send. ${He()}.`)}
|
|
142
142
|
|
|
143
143
|
<div class="actions-bar">
|
|
144
|
-
${m?o`<div class="row test-row"><span class="test-hint" id="testHint" hidden>Not tested yet</span><button type="button" class="secondary" id="testBtn">${
|
|
144
|
+
${m?o`<div class="row test-row"><span class="test-hint" id="testHint" hidden>Not tested yet</span><button type="button" class="secondary" id="testBtn">${D("send")}<span>Send test email</span></button></div>`:o`<div class="row">
|
|
145
145
|
<button type="button" class="ghost" id="saveBtn">Save draft</button>
|
|
146
146
|
<span class="save-status" id="saveStatus" aria-live="polite"></span>
|
|
147
147
|
</div>
|
|
148
148
|
<div class="row">
|
|
149
|
-
<button type="button" class="secondary" id="testBtn">${
|
|
149
|
+
<button type="button" class="secondary" id="testBtn">${D("send")}<span>Send test email</span></button>
|
|
150
150
|
<button type="button" class="primary" id="scheduleBtn">Schedule</button>
|
|
151
151
|
</div>`}
|
|
152
152
|
</div>
|
|
153
|
-
</div>`);let
|
|
154
|
-
`,
|
|
153
|
+
</div>`);let I=c("#f-subject"),v=()=>ie(n,I.value.trim()||"Untitled");v();let w=c("#f-markdown"),M=c(".toolbar",t),V=c("#previewFrame"),A=c("#mdHl"),L=c("code",A),q=()=>{A.scrollTop=w.scrollTop,A.scrollLeft=w.scrollLeft},S=()=>{f(L,dl(w.value)),q()};w.addEventListener("scroll",q),S();let _=()=>({subject:I.value,markdown:w.value}),P=null;function $(){P?.(),P=null}function T(){return I.value.trim()===""?(P=Fe(I,"Add a subject before you schedule."),I.focus(),!1):($(),!0)}let G=c("#headEmailOnly"),x=()=>{G.hidden=m||!h.emailOnly;let b=t.querySelector("#schedDestIcon");b&&f(b,ii(h));let N=t.querySelector("#schedDest");N&&f(N,oi(h))},K=async b=>{let N=await C(`/api/posts/${e}/settings`,{method:"PUT",json:b});h=Xe(N.post,N.subject_slug_held),x(),N.changed&&Ue()},F=async()=>{try{let b=await C(`/api/posts/${e}`,{signal:n});h=Xe(b.post,b.subject_slug_held),x()}catch{}};c("#settingsBtn").onclick=()=>{let b={...h,subject:I.value},N=pe(o`<h3 id="psHead">Post settings</h3><p class="hint">Neither is part of the email, so both stay open while the post is scheduled.</p><div id="psForm"></div><div class="actions"><button type="button" id="psCancel">Cancel</button><button type="button" class="primary" id="psSave">Save</button></div>`,n),k=c(".modal",N.el);k.setAttribute("aria-labelledby","psHead"),Lt(c("#psForm",k),b,"ps"),c("#psCancel",k).onclick=N.close;let U=c("#psSave",k);U.onclick=()=>J(U,"Saving\u2026",async()=>{N.clearError();let oe=Mn(h,b);if(!oe){N.close();return}try{await K(oe),N.close(),j("Post settings saved")}catch(ce){if(n.aborted||Nt(ce)){N.close();return}Nn(k,"ps",ce)||N.error(et(ce))}}),c("#psInclude",k).focus()},m||I.addEventListener("input",()=>{v(),I.value.trim()!==""&&$()});let ee=hl(()=>{Oe(!0).catch(()=>{})});it(n,()=>ee.cancel());let Le=B(".ctab",t);function X(b){for(let N of Le){let k=N.dataset.tab===b;N.classList.toggle("active",k),N.setAttribute("aria-selected",k?"true":"false")}w.hidden=b!=="edit",A.hidden=b!=="edit",V.hidden=b!=="preview",M.classList.toggle("off",b!=="edit"),t.querySelector("#dropFoot")?.classList.toggle("off",b!=="edit"),b==="edit"&&q()}let le=c("#warnings");function me(b){f(le,b?.length?o`<div class="warnings"><strong>Warnings:</strong> ${b.join(" ")}</div>`:o``)}async function Pe(){X("preview");try{m||await Oe(!0);let[b,{warnings:N}]=await Promise.all([Ut(`/api/posts/${e}/preview`),C(`/api/posts/${e}/preview.json`,{signal:n})]);V.srcdoc=b,V.onload=()=>{try{let k=V.contentDocument;k&&(sn(k),$l(k,u.unlisted_url,H),V.style.height=`${k.body.scrollHeight+24}px`)}catch{}},me(N)}catch(b){if(n.aborted||Nt(b))return;j(et(b))}}for(let b of Le)b.onclick=()=>b.dataset.tab==="preview"?Pe():X("edit");m&&Pe();let Ae=m?c("#lockFoot"):null,tt;function Pt(){Ae&&(Ae.classList.remove("nudge"),requestAnimationFrame(()=>Ae.classList.add("nudge")),clearTimeout(tt),tt=setTimeout(()=>Ae.classList.remove("nudge"),900))}function nt(b,N,k){let U=w.selectionStart,oe=w.selectionEnd,ce=w.value.slice(U,oe)||k;w.value=w.value.slice(0,U)+b+ce+N+w.value.slice(oe),w.focus(),w.selectionStart=U+b.length,w.selectionEnd=U+b.length+ce.length}function ge(b){let N=w.selectionStart,k=w.selectionEnd,U=w.value.lastIndexOf(`
|
|
154
|
+
`,N-1)+1,oe=(w.value.slice(U,k)||"").split(`
|
|
155
155
|
`).map(ce=>b+ce).join(`
|
|
156
|
-
`);w.value=w.value.slice(0,U)+oe+w.value.slice(
|
|
157
|
-
`)?nt("```\n","\n```","code"):nt("`","`","code")}So()}for(let b of
|
|
158
|
-
![${
|
|
159
|
-
`;w.value=w.value.slice(0,U)+oe+w.value.slice(U),w.selectionStart=w.selectionEnd=U+oe.length,So(),
|
|
160
|
-
`),
|
|
161
|
-
`),_.error(As(Q,ce.length,$e));return}_.close(),q(qt(`Test sent to ${Q} address${Q===1?"":"es"}`))}catch(Q){if(Ne(Q)){_.close(),Mt(Q);return}_.error(et(Q))}})};let Xi=m?null:c("#scheduleBtn");return Xi&&(Xi.onclick=()=>{if(!L())return;let b=Et(gs()),M=Et(new Date(Date.now()+24*3600*1e3)),_=!y,U={...h,subject:P.value};U.slugAuto&&!U.slugTaken&&(U.slug=js(U.subject)||U.slug);let oe="It sends at the time you pick, with a cancelable window until then.",ce=()=>o`<h3 id="schHead">Schedule this post</h3><p class="hint" id="schHint">${oe}</p>${Sr()}${Bo()}${Uo()}${_?null:o`<label for="schWhen">Send at</label><input type="datetime-local" id="schWhen" min="${b}" value="${M}"><div class="dialog-settings" id="schForm"></div>`}<div class="actions"><button type="button" id="schCancel">Cancel</button><button type="button" class="primary" id="schGo">Schedule</button></div>${_?null:o`<div class="altrow"><span class="altrow-note">Or send as soon as possible.</span><button type="button" class="linkbtn" id="toSendNow">Send now →</button></div>`}`,ke=M,ae=pe(ce(),n),Q=c(".modal",ae.el),$e=null,bt=()=>($e??=C("/api/subscribers?status=confirmed&suppressed=hide&limit=1",{signal:n}).then(de=>de.page.total).catch(()=>null),$e),De=async()=>{if(!Q.querySelector("#schDailyWrites"))return;let de=await bt(),ye=Q.querySelector("#schDailyWrites");ye&&de!==null&&de>si&&(ye.textContent=el(de),ye.hidden=!1)},_e=null,dn=async()=>{_e??=dt(Z.appConfig?.deployment,n);let de=ut(await _e),ye=Q.querySelector("#schSandbox");ye&&de&&(ye.textContent=hr,ye.hidden=!1)},Nt=()=>{ae.close(),Ke.scrollIntoView({block:"nearest"})},un=()=>Tt(c("#schForm",Q),U,"sch"),he=()=>({email_only:U.emailOnly,...In(h,U)}),Ee=de=>{Mn(Q,"sch",de)||ae.error(et(de))},Re=()=>J(c("#schGo",Q),"Scheduling\u2026",async()=>{ae.clearError();let de=c("#schWhen",Q),ye=de.value?new Date(de.value).getTime():Number.NaN;if(Number.isNaN(ye)){ae.error("Pick a valid date & time",de);return}if(bs(ye)){ae.error(hs(),de);return}try{if(await Oe(!0)==="refused"){Nt();return}await C(`/api/posts/${e}/schedule`,{method:"POST",json:{fire_at:new Date(ye).toISOString(),...he()}}),ae.close(),q(qt(`Scheduled for ${W(ye)}. Send yourself a test.`)),s()}catch(Ye){if(Ne(Ye)){ae.close(),Mt(Ye);return}if(Ye instanceof se&&Ye.field==="fire_at"){ae.error(et(Ye),c("#schWhen",Q));return}Ee(Ye)}}),ze=()=>J(c("#snGo",Q),"Queuing\u2026",async()=>{ae.clearError();try{if(await Oe(!0)==="refused"){Nt();return}let{send:de}=await C(`/api/posts/${e}/send`,{method:"POST",json:he()});ae.close(),q(qt(`Sends at ${W(de.fire_at)}, cancelable until then.`)),s()}catch(de){if(Ne(de)){ae.close(),Mt(de);return}Ee(de)}});function er(){if(Q.setAttribute("aria-labelledby","schHead"),c("#schCancel",Q).onclick=ae.close,c("#schGo",Q).onclick=Re,c("#schGo",Q).disabled=_,_){c("#schCancel",Q).focus();return}c("#toSendNow",Q).onclick=zc,c("#schWhen",Q).value=ke,un(),c("#schWhen",Q).focus(),De(),dn()}async function zc(){let de=Q.querySelector("#schWhen");de&&(ke=de.value),f(Q,o`<h3 id="snHead">Send now?</h3><p class="hint">Sends this draft, as it is now, to <strong id="snWho">your subscribers</strong> in ${vr()}. The post locks until then, and you can cancel any time before it starts sending.</p><div class="dialog-settings" id="schForm"></div>${Bo()}${Uo()}<div class="actions"><button type="button" class="linkbtn actions-back" id="toSchedule">← Back to schedule</button><button type="button" id="snCancel">Cancel</button><button type="button" class="primary" id="snGo">Send now</button></div>`),Q.setAttribute("aria-labelledby","snHead"),c("#snCancel",Q).onclick=ae.close,c("#snGo",Q).onclick=ze,un(),c("#snGo",Q).disabled=!Xt(u,"send_now"),c("#toSchedule",Q).onclick=()=>{f(Q,ce()),er()},c("#snGo",Q).focus(),De(),dn();let ye=await bt(),Ye=Q.querySelector("#snWho");Ye&&ye!==null&&(Ye.textContent=`${ye} recipient${ye===1?"":"s"}`)}er()}),Kc}function $l(e,t){return e.status==="sending"||e.status==="sent"?(Zs(`#/sent/${e.id}`),!0):e.status==="canceled"?(t(),!0):!1}function Zu(e,t){return Ce(e,"missed")?o`Scheduled for <strong>${W(e.fire_at)}</strong> · <span class="countdown countdown-missed">${Hs(e.fire_at)}</span>`:t?o`Scheduled for <strong>${W(e.fire_at)}</strong> · <span class="countdown">${$n(e.fire_at,!0)}</span>`:o`Scheduled for <strong>${W(e.fire_at)}</strong> · <span class="countdown">${$n(e.fire_at)}</span>`}function Ne(e){return e instanceof se&&e.status===404}function Ju(e){let t=e.post.send;return t?.status==="sending"?`#/sent/${t.id}`:e.post.status==="sent"?t?`#/sent/${t.id}`:"#/sent":null}function Zs(e){location.replace(e)}function Qu(e,t){document.addEventListener("visibilitychange",()=>{document.hidden||e()},{signal:t})}function Xu(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s_-]/gu,"").replace(/\s/g,"-")}function El(e){let t=new Map;return e.map(n=>{let s=Xu(n),i=t.get(s)??0;return t.set(s,i+1),i?`${s}-${i}`:s})}var ui=null;function ep(e){let t=document.createElement("div");f(t,Y(e.html||""));let n=(t.querySelector("p")?.textContent||"").trim().replace(/\s+/g," "),s=/[:;,]$/.test(n),i=n.replace(/[\s:;,]+$/,""),r=150;return i.length>r?`${i.slice(0,r).replace(/[\s.,;:]+\S*$/,"")}\u2026`:s?`${i}\u2026`:i}function tp(e){let t=e.querySelector("code"),n=t?.className.match(/(?:^|\s)language-(\S+)/)?.[1]??null,s=(t??e).textContent?.replace(/\n$/,"")??"",i=n==="bash"||n==="sh"||n==="shell"?Gs(s):n==="json"||n==="jsonc"?ai(s):o`${s}`;return Oa(i,s)}async function pi(e,t,n,s){if(ie(n,"Docs"),f(t,jt("docs",null,o`<div class="docs-index"><p class="muted">Loading…</p></div>`)),!ui)try{ui=await C("/api/docs",{signal:n})}catch(d){n.aborted||re(c(".room-main",t),z(d),()=>ne((u,p)=>pi(e,u,p,s)));return}let{sets:i,docs:r}=ui,a=i[0];if(!r.length||!a){f(c(".room-main"),o`<p class="muted">No documentation.</p>`);return}let l=e?i.find(d=>d.id===e):a;l?_l(t,l,i,r,n):e&&op(t,i,r,e,n,s?np(s):void 0)}function np(e){try{return decodeURIComponent(e)}catch{return}}function _l(e,t,n,s,i){ie(i,`${t.name} docs`);let r=(h,m)=>{let y=ep(h);return o`<li><a class="doc-card" href="#/docs/${h.slug}">${m===null?null:o`<span class="doc-card-n">${String(m).padStart(2,"0")}</span>`}<span class="doc-card-main"><span class="doc-card-t">${h.title} <span class="doc-card-go" aria-hidden="true">→</span></span>${y?o`<span class="doc-card-d">${y}</span>`:null}</span></a></li>`},a=t.sections.map(h=>{let m=s.filter(R=>R.set===t.id&&R.section===h.id);if(!m.length)return null;let y=m.map((R,N)=>r(R,h.numbered?N+1:null)),E=h.blurb?o`<div class="doc-section-blurb">${Y(h.blurb)}</div>`:null;return o`<section class="doc-section"><h2 class="doc-section-t">${h.title}</h2>${E}${h.numbered?o`<ol class="doc-cards">${y}</ol>`:o`<ul class="doc-cards">${y}</ul>`}</section>`}),l=o`<nav class="docs-tabs" aria-label="Doc sets">${n.map(h=>o`<a href="#/docs/${h.id}" title="${h.title}"${h.id===t.id?o` aria-current="page"`:null}>${h.name}</a>`)}</nav>`,d=o`<div class="docs-index"><h1>Kestrel docs</h1><p class="docs-index-intro"><strong>Publishing</strong> covers writing and sending your newsletter, from naming your publication to what happens after each send. <strong>Self-hosting</strong> covers deploying Kestrel to your own Cloudflare account and keeping it running. One person often does both.</p>${l}${a}</div>`,u=Z.appConfig?.deployment.build.repo_url||"",p=(h,m,y=m)=>o`<a class="rail-link" href="${h}" target="_blank" rel="noopener" aria-label="${m}"><span class="rail-link-full">${m}</span><span class="rail-link-short" aria-hidden="true">${y}</span> <span aria-hidden="true">↗</span></a>`,g=o`<div class="toc-label">Kestrel</div>${p("https://getkestrel.dev","Project site","Project")}${u?[p(u,"Source on GitHub","Source"),p(`${u}/blob/HEAD/LICENSE`,"License")]:null}`;f(e,jt("docs",g,d)),window.scrollTo(0,0)}var mi=matchMedia("(max-width: 720px)");function Tl(e){if(!e)return;let t=mi.matches;e.open=!t,c("summary",e).tabIndex=t?0:-1}var Ll=()=>document.querySelector("details#tocOnPage"),xl=!1;function sp(){xl||(xl=!0,mi.addEventListener("change",()=>Tl(Ll())))}var kl=e=>`doc-h-${e}`;function op(e,t,n,s,i,r){let a=n.findIndex($=>$.slug===s),l=n[a],d=t.find($=>$.id===l?.set);if(!l||!d){let $=t[0];q(`No doc named \u201C${s}\u201D, so here\u2019s the index.`),history.replaceState(history.state,"","#/docs"),$&&_l(e,$,t,n,i);return}ie(i,l.title);let u=n.filter($=>$.set===l.set&&$.section===l.section),p=u.indexOf(l),g=u[p-1],h=u[p+1],m=($,L)=>o`<a href="#/docs/${$.slug}" aria-label="${L}: ${$.title}">${L==="Previous"?o`<span aria-hidden="true">←</span><span class="doc-topnav-word">Previous</span>`:o`<span class="doc-topnav-word">Next</span><span aria-hidden="true">→</span>`}</a>`,y=g||h?o`<nav class="doc-topnav" aria-label="Adjacent docs">${g?m(g,"Previous"):null}${h?m(h,"Next"):null}</nav>`:null;f(e,jt("docs",o`<div id="docToc"></div>`,o`<article class="doc" id="docsMain"></article>`));let E=c("#docToc"),R=c("#docsMain");f(R,o`<section class="doc-part" id="doc-${l.slug}">${Y(l.html)}</section>`);let N=c("section.doc-part",R),A=D("h1, h2, h3, h4",N),P=El(A.map($=>$.textContent||""));for(let[$,L]of A.entries()){let G=P[$]??"";L.dataset.anchor=G,L.id=kl(G)}let v=N.querySelector("h1"),w=[];if(v&&w.push({id:v.id,anchor:"",title:v.textContent||l.title}),y){let $=document.createElement("div");$.className="doc-head",f($,y),v?(v.before($),$.prepend(v)):N.prepend($)}let I=document.createElement("p");I.className="eyebrow doc-set",f(I,o`<a href="#/docs/${d.id}">${d.name}</a>`),N.prepend(I);for(let $ of D("h2",N))w.push({id:$.id,anchor:$.dataset.anchor||"",title:$.textContent||""});let j=document.createElement("nav");j.className="doc-pager",f(j,o`${g?o`<a class="doc-pager-btn prev" href="#/docs/${g.slug}"><span class="doc-pager-dir">← Previous</span><span class="doc-pager-title">${g.title}</span></a>`:o`<span></span>`}${h?o`<a class="doc-pager-btn next" href="#/docs/${h.slug}"><span class="doc-pager-dir">Next →</span><span class="doc-pager-title">${h.title}</span></a>`:o`<span></span>`}`),R.appendChild(j);let x=w.map($=>o`<a class="toc-sub" href="#/docs/${l.slug}${$.anchor?`/${$.anchor}`:""}" data-target="${$.id}">${$.title}</a>`);f(E,w.length?o`<details class="toc-onpage" id="tocOnPage"><summary class="toc-label">On this page</summary>${x}</details>`:o``);let O=Ll();Tl(O),sp();let V=$=>{if(O)for(let L of D(".toc-sub",O))L.classList.toggle("on",L.dataset.target===$)};E.addEventListener("click",$=>{let L=$.target instanceof Element?$.target.closest("a[data-target]"):null,G=L?.dataset.target;G&&($.preventDefault(),V(G),O&&mi.matches&&(O.open=!1),history.replaceState(history.state,"",L?.getAttribute("href")??location.hash),document.getElementById(G)?.scrollIntoView({block:"start"}))});for(let $ of D("a[href^='http']",R))$.target="_blank",$.rel="noopener";for(let $ of D("pre",N)){let L=document.createElement("div");f(L,tp($)),$.replaceWith(...L.childNodes)}je(R);let S=w.map($=>$.id),T=S[0];if(O&&T){let $=S[S.length-1]??T,G=(document.querySelector(".room-bar")?.getBoundingClientRect().height||54)+26,k=()=>{if(!document.getElementById(T)){document.onscroll=null;return}let K=T;if(Math.ceil(window.innerHeight+window.scrollY)>=document.documentElement.scrollHeight)K=$;else for(let F of S)if((document.getElementById(F)?.getBoundingClientRect().top??Number.POSITIVE_INFINITY)<=G)K=F;else break;V(K)};document.onscroll=k,k()}let H=r?document.getElementById(kl(r)):null;H?H.scrollIntoView({block:"start"}):window.scrollTo(0,0)}function fi(e){let t=new Set(e.groups.flatMap(n=>n.routes.flatMap(s=>(s.errors??[]).map(i=>i.code))));return e.refusals.flatMap(n=>n.codes.filter(s=>!t.has(s.code)).map(s=>({...s,move:n.move})))}function Rt(e){return e.replace(/\([^)]*\)/g,"").replace(/\{[^}]*\}\??/g,"")||"/"}function on(e){return e.title.toLowerCase().replace(/'s\b/g,"").split(/[^a-z0-9]+/).filter(t=>t!==""&&t!=="a"&&t!=="an"&&t!=="the").join("-")}var ip=/`([^`]+)`|\*\*([^*]+)\*\*|\[([^\]]+)\]\(([^)\s]+)\)/g;function rp(e){return/^https:\/\//i.test(e)||/^\/(?![/\\])/.test(e)}function ve(e){let t=[],n=0;for(let s of e.matchAll(ip)){let i=s.index??0;t.push(e.slice(n,i));let[,r,a,l,d]=s;r!==void 0?t.push(o`<code>${r}</code>`):a!==void 0?t.push(o`<strong>${ve(a)}</strong>`):l!==void 0&&d!==void 0&&t.push(rp(d)?o`<a href="${d}">${ve(l)}</a>`:ve(l)),n=i+s[0].length}return t.push(e.slice(n)),o`${t}`}function Nn(e,t){return o`${e.split(/\n\s*\n/).filter(n=>n.trim()).map(n=>{let s=n.trim().split(`
|
|
162
|
-
`),i=s.findIndex(l=>l.startsWith("- "));if(i===-1)return o`<p class="${t}">${ve(n.trim())}</p>`;let r=s.slice(0,i).join(" ").trim(),a=s.slice(i).reduce((l,d)=>(d.startsWith("- ")||l.length===0?l.push(d.replace(/^- /,"")):l[l.length-1]=`${l[l.length-1]} ${d.trim()}`,l),[]);return o`${r?o`<p class="${t}">${ve(r)}</p>`:null}<ul class="${t} prose-list">${a.map(l=>o`<li>${ve(l)}</li>`)}</ul>`})}`}function
|
|
163
|
-
`)}function bi(e,t){return t===void 0?null:
|
|
156
|
+
`);w.value=w.value.slice(0,U)+oe+w.value.slice(k),w.focus(),w.selectionStart=U,w.selectionEnd=U+oe.length}function Qn(b){if(m){Pt();return}if(X("edit"),b==="bold")nt("**","**","bold text");else if(b==="italic")nt("*","*","italic text");else if(b==="heading")ge("## ");else if(b==="quote")ge("> ");else if(b==="ul")ge("- ");else if(b==="ol")ge("1. ");else if(b==="indent")ge(" ");else if(b==="link")nt("[","](https://)","link text");else if(b==="code"){let N=w.selectionStart,k=w.selectionEnd;N===k||w.value.slice(N,k).includes(`
|
|
157
|
+
`)?nt("```\n","\n```","code"):nt("`","`","code")}So()}for(let b of B(".tb[data-fmt]",t))b.onclick=()=>Qn(b.dataset.fmt??"");w.addEventListener("keydown",b=>{if(!(b.metaKey||b.ctrlKey))return;let N=b.key.toLowerCase();N==="b"?(b.preventDefault(),Qn("bold")):N==="i"?(b.preventDefault(),Qn("italic")):N==="k"&&(b.preventDefault(),Qn("link"))});let st=!1,Xn=!1,We=!1,ot=null,bt=0,es=!1,vo=0,Ie=m?null:c("#saveBtn"),Me=m?null:c("#saveStatus"),It=new zs(_),dn=!1;function yo(){Me&&(m?(Me.className="save-status",Me.textContent=""):dn?(Me.className="save-status is-saving",Me.textContent="Saving\u2026"):ot&&st?(Me.className="save-status is-error",Me.textContent=`Not saved: ${ot}`):st?(Me.className="save-status is-dirty",Me.textContent="Unsaved changes"):(Me.className="save-status is-saved",Me.textContent="Saved"))}function ts(){st=It.dirty,st||(ot=null,Xn=!1,bt=0),yo()}yo();function Yi(){ee.touch()}function So(){m||(S(),ts(),We||Yi())}let Mt=Promise.resolve();function Oe(b){let N=Mt.catch(()=>{}).then(()=>Wc(b));return Mt=N,li(Mt),N}async function Wc(b){if(b&&!It.dirty)return"unchanged";if(We)return"refused";ee.cancel(),dn=!0,yo();let N=_(),k=JSON.stringify(N);try{let U={...N,base_revision:E.base},{post:oe,subject_slug_held:ce}=await C(`/api/posts/${e}`,{method:"PUT",json:U});return h=Xe(oe,ce),x(),E.saved(oe.current_revision),It.markSaved(k),Xn=!1,ot=null,bt=0,b||j("Saved"),"saved"}catch(U){let oe=vl(U);if(oe)return Qi(oe),"refused";if(Ne(U))return r(),"refused";Xn=!0;let ce=U instanceof se&&U.field==="subject"?I:void 0;if(ce?(Fe(ce,z(U)),ot="fix the field marked above."):ot=z(U),!(Co(U)||U instanceof se&&(U.status>=500||U.status===429)))vo+=1,es=!1,bt=0;else if(!es){es=!0,bt=bt?Math.min(bt*2,6e4):5e3;let ae=vo;yt(Date.now()+bt,()=>{ae===vo&&(es=!1,ot&&!We&&Oe(!0).catch(()=>{}))},n)}throw U}finally{dn=!1,ts()}}Ie&&(Ie.onclick=()=>{if(We){Ke.scrollIntoView({block:"nearest"});return}J(Ie,"Saving\u2026",()=>Oe(!1).catch(()=>{})).finally(ts)});function Zi(){Ie&&(We?(Ie.setAttribute("aria-disabled","true"),Ie.title="Saving is paused: choose Reload or Keep editing above"):(Ie.removeAttribute("aria-disabled"),Ie.removeAttribute("title")))}let Kc=()=>{if(ee.cancel(),m||!It.dirty)return;let b=_(),N=JSON.stringify(b);st=!1,Mt=Mt.catch(()=>{}).then(async()=>{if(!It.dirty)return;let k={...b,base_revision:E.base},{post:U}=await C(`/api/posts/${e}`,{method:"PUT",json:k});E.saved(U.current_revision),It.markSaved(N)}).catch(k=>{if(Ne(k)){j("This post was deleted elsewhere, so your last edits weren\u2019t saved.");return}j(k instanceof se&&k.status===409?"Changed elsewhere, so your edits weren\u2019t saved":`Couldn\u2019t save your changes: ${et(k)}`)}),li(Mt)},Gc={dirty:()=>st,beforeLeave(){return i?"leave":st&&(Xn||We)?"confirm":(Kc(),"leave")},manualSave(){Ie&&!Ie.disabled&&Ie.click()}};if(!m){for(let b of[I,w])b.addEventListener("input",So);for(let b of[I])b.addEventListener("blur",()=>Oe(!0).catch(()=>{})),b.addEventListener("keydown",N=>{N.key==="Enter"&&!N.isComposing&&N.keyCode!==229&&(N.preventDefault(),Oe(!0).catch(()=>{}))})}let Ke=c("#freshnessBanner");function Ji(){We=!1,Zi(),E.clearWarning(),Ke.hidden=!0,f(Ke,o``)}function Qi(b){if(m)return;if(We=!0,ot=null,Zi(),E.noteWarned(b),b.kind==="locked")f(Ke,o`<span><span aria-hidden="true">⚠️</span> This draft was scheduled elsewhere and can no longer be edited here.</span><span class="row"><button type="button" class="ghost" id="freshReload">Reload</button></span>`);else{let k=on(b.author,b.client);f(Ke,o`<span><span aria-hidden="true">⚠️</span> This draft was changed elsewhere${k?o`, last edited by <strong>${k}</strong>`:null}. Saving is paused until you choose: Reload to load that version (discards your unsaved edits), or Keep editing to keep yours, and your next save overwrites that version.</span><span class="row"><button type="button" class="ghost" id="freshReload">Reload</button><button type="button" class="ghost" id="freshKeep">Keep editing</button></span>`)}Ke.hidden=!1,c("#freshReload",Ke).onclick=()=>{Ji(),s()};let N=Ke.querySelector("#freshKeep");N&&(N.onclick=()=>{E.adoptWarned(),Ji(),ts(),st&&Yi()})}function Nt(b){return Ne(b)?(r(),!0):!1}if(!m){let b=async()=>{if(dn||We||i||document.hidden)return;let N=E.base;try{let k=await C(`/api/posts/${e}`,{signal:n}),U=E.decide({status:k.post.status,revision:k.post.current_revision,author:k.post.author,client:k.post.author_client},{saving:dn,baseAtRequest:N});U!=="ignore"&&U!=="fresh"&&Qi(U)}catch(k){Ne(k)&&r()}};vt(1e4,b,n),ep(b,n)}if(c("#webLink").addEventListener("click",()=>{m||Oe(!0).catch(()=>{})}),m&&d){let b=l?.send??{...d,conditions:[]},N=c("#schedWhen"),k=c("#schedControls"),U="",oe=0,ce=!1,ke=c("#rescheduleSchedule"),ae=c("#cancelSchedule"),Q=he=>b.actions===void 0||Je({actions:b.actions},he),$e=()=>{let he=Date.now(),Ee=b.phase==="due"||he>=b.fire_at;Ee?ce||(ke.hidden=!0,ae.hidden=!0):(ce=!0,ke.hidden=!Q("reschedule"),ae.hidden=!Q("cancel")),ke.disabled=Ee,ae.disabled=Ee,k.hidden=ke.hidden&&ae.hidden;let Re=Qu(b,Ee),ze=String(Re);ze!==U&&(U=ze,f(N,Re)),!Ee&&b.fire_at-he<=1e3&&b.fire_at!==oe&&(oe=b.fire_at,yt(b.fire_at,$e,n))};$e(),vt(1e3,$e,n);let gt=c("#schedRemade"),De=c("#testHint"),_e=c("#schedDailyWrites"),un=c("#schedBy"),Ot=()=>{let he=fl(b,g);un.hidden=he===null,un.textContent=he??"";let Ee=fe(b,"remade");gt.hidden=!Ee,c("#schedRemadeMsg").textContent=Ee?.message??"",De.hidden=!fe(b,"untested");let Re=fe(b,"daily_writes");_e.hidden=!Re,c("#schedDailyWritesMsg").textContent=Re?.message??"";let ze=fe(b,"sandbox");c("#schedSandbox").hidden=!ze,c("#schedSandboxMsg").textContent=ze?.message??""};Ot();let pn=he=>$n(he,{update(Ee,Re){let ze=!Re&&Ee.rev!==b.rev;if(b=Ee,ze&&F(),Re?.to==="sending"||Re?.to==="sent"||Re?.to==="complete"){j("Your send started, so this page switched to its live watch."),Zs(`#/sent/${Ee.id}`);return}if(Re?.to==="canceled"){j("The schedule was canceled elsewhere, so this post is a draft again."),s();return}$e(),Ot()},removed:r,stale:s},n);l?pn(l):rr(5e3,async()=>{let he=await C(`/api/sends/${d.id}`,{signal:n});return El(he.send,s)||(b=he.send,$e(),Ot(),pn(he)),!1},n),ke.onclick=()=>{Ws({id:b.id,post_id:e,fire_at:b.fire_at},s,n,{...h})},ae.onclick=()=>J(ae,"Canceling\u2026",async()=>{try{await C(`/api/sends/${d.id}/cancel`,{method:"POST"}),j("Schedule canceled"),s()}catch(he){Ne(he)?r():he instanceof se&&he.code==="window_closed"?(b={...b,phase:"due"},j("Too late to cancel: the send time has passed, so this email is going out."),Ue()):j(et(he))}}).finally($e)}function zc(b){let N=nl(b.name),k=Object.keys(qs).find(U=>qs[U]===b.type);return!N||N===b.type||!k?b:new File([b],`image${k}`,{type:b.type})}async function wo(b){if(b.type.startsWith("image/"))try{let N=new FormData;N.append("file",b);let{image:k}=await C(`/api/posts/${e}/images`,{method:"POST",body:N}),U=w.selectionStart,oe=`
|
|
158
|
+

|
|
159
|
+
`;w.value=w.value.slice(0,U)+oe+w.value.slice(U),w.selectionStart=w.selectionEnd=U+oe.length,So(),j("Image added")}catch(N){Nt(N)||j(et(N))}}let Ge=c("#composerBody");if(m){let b=k=>k.metaKey||k.ctrlKey?["x","z","y"].includes(k.key.toLowerCase()):k.key.length===1||k.key==="Enter"||k.key==="Backspace"||k.key==="Delete",N=[w,I];for(let k of N)k.addEventListener("keydown",U=>{b(U)&&Pt()}),k.addEventListener("paste",Pt);Ge.addEventListener("dragover",k=>k.preventDefault()),Ge.addEventListener("drop",k=>{k.preventDefault(),Pt()})}else{let b=c("#imgInput"),N=c("#dropFoot");Ge.addEventListener("dragover",k=>{k.preventDefault(),Ge.classList.add("dragover")}),Ge.addEventListener("dragleave",k=>{k.target===Ge&&Ge.classList.remove("dragover")}),Ge.addEventListener("drop",k=>{k.preventDefault(),Ge.classList.remove("dragover"),X("edit");for(let U of k.dataTransfer?.files??[])wo(U)}),w.addEventListener("paste",k=>{for(let U of k.clipboardData?.items||[])if(U.type.startsWith("image/")){let oe=U.getAsFile();oe&&(k.preventDefault(),wo(zc(oe)))}}),N.onclick=()=>b.click(),b.onchange=()=>{for(let k of b.files??[])wo(k);b.value=""}}c("#testBtn").onclick=()=>{let b=m?"Delivers the frozen copy that will send, exactly as it will fire, so you can check it in a client. One address per line.":"Delivers the rendered email to real inboxes so you can check it in a client. One address per line.",N=be(),k=pe(o`<h3>Send a test</h3><p class="hint">${b}</p>${Es()}${N?null:o`<label for="testTo">Recipients</label><textarea id="testTo" rows="3" placeholder="you@example.com"></textarea><p class="hint" id="testDefaultsHint" hidden></p>`}<div class="actions"><button type="button" id="tCancel">Cancel</button><button type="button" class="primary" id="tGo">Send test</button></div>`,n),U=c("#tGo",k.el);if(c("#tCancel",k.el).onclick=k.close,U.disabled=N,N){c("#tCancel",k.el).focus();return}let oe=c("#testTo",k.el);oe.focus(),C("/api/settings").then(ce=>{let ke=ce.settings.test_recipients||[];if(ke.length&&!oe.value.trim()){oe.value=ke.join(`
|
|
160
|
+
`),k.clearError();let ae=c("#testDefaultsHint",k.el);ae.textContent="Pre-filled from your default test recipients (Settings).",ae.hidden=!1}}).catch(()=>{}),U.onclick=()=>J(U,"Sending\u2026",async()=>{k.clearError();let{valid:ce,invalid:ke}=Rs(oe.value),ae=Cs(ke);if(ae){k.error(ae,oe);return}if(!ce.length){k.error("Enter at least one email address",oe);return}try{m||await Oe(!0);let Q=0,$e=[],gt=null;for(let De of ce)try{let _e=await C(`/api/posts/${e}/test`,{method:"POST",json:{to:De}});_e.sent?Q++:$e.push({email:De,message:_e.not_sent?.message??""}),gt=_e.warnings}catch(_e){if(Ne(_e)||_e instanceof se&&_e.status===401)throw _e;$e.push({email:De,message:z(_e)})}if(me(gt),m&&Q>0&&Ue(),$e.length){oe.value=$e.map(De=>De.email).join(`
|
|
161
|
+
`),k.error(As(Q,ce.length,$e));return}k.close(),j(qt(`Test sent to ${Q} address${Q===1?"":"es"}`))}catch(Q){if(Ne(Q)){k.close(),Nt(Q);return}k.error(et(Q))}})};let Xi=m?null:c("#scheduleBtn");return Xi&&(Xi.onclick=()=>{if(!T())return;let b=xt(vs()),N=xt(new Date(Date.now()+24*3600*1e3)),k=!y,U={...h,subject:I.value};U.slugAuto&&!U.slugTaken&&(U.slug=js(U.subject)||U.slug);let oe="It sends at the time you pick, with a cancelable window until then.",ce=()=>o`<h3 id="schHead">Schedule this post</h3><p class="hint" id="schHint">${oe}</p>${wr()}${Bo()}${Uo()}${k?null:o`<label for="schWhen">Send at</label><input type="datetime-local" id="schWhen" min="${b}" value="${N}"><div class="dialog-settings" id="schForm"></div>`}<div class="actions"><button type="button" id="schCancel">Cancel</button><button type="button" class="primary" id="schGo">Schedule</button></div>${k?null:o`<div class="altrow"><span class="altrow-note">Or send as soon as possible.</span><button type="button" class="linkbtn" id="toSendNow">Send now →</button></div>`}`,ke=N,ae=pe(ce(),n),Q=c(".modal",ae.el),$e=null,gt=()=>($e??=C("/api/subscribers?status=confirmed&suppressed=hide&limit=1",{signal:n}).then(de=>de.page.total).catch(()=>null),$e),De=async()=>{if(!Q.querySelector("#schDailyWrites"))return;let de=await gt(),ye=Q.querySelector("#schDailyWrites");ye&&de!==null&&de>si&&(ye.textContent=tl(de),ye.hidden=!1)},_e=null,un=async()=>{_e??=ut(Z.appConfig?.deployment,n);let de=pt(await _e),ye=Q.querySelector("#schSandbox");ye&&de&&(ye.textContent=br,ye.hidden=!1)},Ot=()=>{ae.close(),Ke.scrollIntoView({block:"nearest"})},pn=()=>Lt(c("#schForm",Q),U,"sch"),he=()=>({email_only:U.emailOnly,...Mn(h,U)}),Ee=de=>{Nn(Q,"sch",de)||ae.error(et(de))},Re=()=>J(c("#schGo",Q),"Scheduling\u2026",async()=>{ae.clearError();let de=c("#schWhen",Q),ye=de.value?new Date(de.value).getTime():Number.NaN;if(Number.isNaN(ye)){ae.error("Pick a valid date & time",de);return}if(gs(ye)){ae.error(bs(),de);return}try{if(await Oe(!0)==="refused"){Ot();return}await C(`/api/posts/${e}/schedule`,{method:"POST",json:{fire_at:new Date(ye).toISOString(),...he()}}),ae.close(),j(qt(`Scheduled for ${W(ye)}. Send yourself a test.`)),s()}catch(Ye){if(Ne(Ye)){ae.close(),Nt(Ye);return}if(Ye instanceof se&&Ye.field==="fire_at"){ae.error(et(Ye),c("#schWhen",Q));return}Ee(Ye)}}),ze=()=>J(c("#snGo",Q),"Queuing\u2026",async()=>{ae.clearError();try{if(await Oe(!0)==="refused"){Ot();return}let{send:de}=await C(`/api/posts/${e}/send`,{method:"POST",json:he()});ae.close(),j(qt(`Sends at ${W(de.fire_at)}, cancelable until then.`)),s()}catch(de){if(Ne(de)){ae.close(),Nt(de);return}Ee(de)}});function er(){if(Q.setAttribute("aria-labelledby","schHead"),c("#schCancel",Q).onclick=ae.close,c("#schGo",Q).onclick=Re,c("#schGo",Q).disabled=k,k){c("#schCancel",Q).focus();return}c("#toSendNow",Q).onclick=Yc,c("#schWhen",Q).value=ke,pn(),c("#schWhen",Q).focus(),De(),un()}async function Yc(){let de=Q.querySelector("#schWhen");de&&(ke=de.value),f(Q,o`<h3 id="snHead">Send now?</h3><p class="hint">Sends this draft, as it is now, to <strong id="snWho">your subscribers</strong> in ${yr()}. The post locks until then, and you can cancel any time before it starts sending.</p><div class="dialog-settings" id="schForm"></div>${Bo()}${Uo()}<div class="actions"><button type="button" class="linkbtn actions-back" id="toSchedule">← Back to schedule</button><button type="button" id="snCancel">Cancel</button><button type="button" class="primary" id="snGo">Send now</button></div>`),Q.setAttribute("aria-labelledby","snHead"),c("#snCancel",Q).onclick=ae.close,c("#snGo",Q).onclick=ze,pn(),c("#snGo",Q).disabled=!en(u,"send_now"),c("#toSchedule",Q).onclick=()=>{f(Q,ce()),er()},c("#snGo",Q).focus(),De(),un();let ye=await gt(),Ye=Q.querySelector("#snWho");Ye&&ye!==null&&(Ye.textContent=`${ye} recipient${ye===1?"":"s"}`)}er()}),Gc}function El(e,t){return e.status==="sending"||e.status==="sent"?(Zs(`#/sent/${e.id}`),!0):e.status==="canceled"?(t(),!0):!1}function Qu(e,t){return Ce(e,"missed")?o`Scheduled for <strong>${W(e.fire_at)}</strong> · <span class="countdown countdown-missed">${Hs(e.fire_at)}</span>`:t?o`Scheduled for <strong>${W(e.fire_at)}</strong> · <span class="countdown">${En(e.fire_at,!0)}</span>`:o`Scheduled for <strong>${W(e.fire_at)}</strong> · <span class="countdown">${En(e.fire_at)}</span>`}function Ne(e){return e instanceof se&&e.status===404}function Xu(e){let t=e.post.send;return t?.status==="sending"?`#/sent/${t.id}`:e.post.status==="sent"?t?`#/sent/${t.id}`:"#/sent":null}function Zs(e){location.replace(e)}function ep(e,t){document.addEventListener("visibilitychange",()=>{document.hidden||e()},{signal:t})}function tp(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s_-]/gu,"").replace(/\s/g,"-")}function xl(e){let t=new Map;return e.map(n=>{let s=tp(n),i=t.get(s)??0;return t.set(s,i+1),i?`${s}-${i}`:s})}var ui=null;function np(e){let t=document.createElement("div");f(t,Y(e.html||""));let n=(t.querySelector("p")?.textContent||"").trim().replace(/\s+/g," "),s=/[:;,]$/.test(n),i=n.replace(/[\s:;,]+$/,""),r=150;return i.length>r?`${i.slice(0,r).replace(/[\s.,;:]+\S*$/,"")}\u2026`:s?`${i}\u2026`:i}function sp(e){let t=e.querySelector("code"),n=t?.className.match(/(?:^|\s)language-(\S+)/)?.[1]??null,s=(t??e).textContent?.replace(/\n$/,"")??"",i=n==="bash"||n==="sh"||n==="shell"?Gs(s):n==="json"||n==="jsonc"?ai(s):o`${s}`;return Da(i,s)}async function pi(e,t,n,s){if(ie(n,"Docs"),f(t,jt("docs",null,o`<div class="docs-index"><p class="muted">Loading…</p></div>`)),!ui)try{ui=await C("/api/docs",{signal:n})}catch(d){n.aborted||re(c(".room-main",t),z(d),()=>ne((u,p)=>pi(e,u,p,s)));return}let{sets:i,docs:r}=ui,a=i[0];if(!r.length||!a){f(c(".room-main"),o`<p class="muted">No documentation.</p>`);return}let l=e?i.find(d=>d.id===e):a;l?Tl(t,l,i,r,n):e&&rp(t,i,r,e,n,s?op(s):void 0)}function op(e){try{return decodeURIComponent(e)}catch{return}}function Tl(e,t,n,s,i){ie(i,`${t.name} docs`);let r=(h,m)=>{let y=np(h);return o`<li><a class="doc-card" href="#/docs/${h.slug}">${m===null?null:o`<span class="doc-card-n">${String(m).padStart(2,"0")}</span>`}<span class="doc-card-main"><span class="doc-card-t">${h.title} <span class="doc-card-go" aria-hidden="true">→</span></span>${y?o`<span class="doc-card-d">${y}</span>`:null}</span></a></li>`},a=t.sections.map(h=>{let m=s.filter(R=>R.set===t.id&&R.section===h.id);if(!m.length)return null;let y=m.map((R,O)=>r(R,h.numbered?O+1:null)),E=h.blurb?o`<div class="doc-section-blurb">${Y(h.blurb)}</div>`:null;return o`<section class="doc-section"><h2 class="doc-section-t">${h.title}</h2>${E}${h.numbered?o`<ol class="doc-cards">${y}</ol>`:o`<ul class="doc-cards">${y}</ul>`}</section>`}),l=o`<nav class="docs-tabs" aria-label="Doc sets">${n.map(h=>o`<a href="#/docs/${h.id}" title="${h.title}"${h.id===t.id?o` aria-current="page"`:null}>${h.name}</a>`)}</nav>`,d=o`<div class="docs-index"><h1>Kestrel docs</h1><p class="docs-index-intro"><strong>Publishing</strong> covers writing and sending your newsletter, from naming your publication to what happens after each send. <strong>Self-hosting</strong> covers deploying Kestrel to your own Cloudflare account and keeping it running. One person often does both.</p>${l}${a}</div>`,u=Z.appConfig?.deployment.build.repo_url||"",p=(h,m,y=m)=>o`<a class="rail-link" href="${h}" target="_blank" rel="noopener" aria-label="${m}"><span class="rail-link-full">${m}</span><span class="rail-link-short" aria-hidden="true">${y}</span> <span aria-hidden="true">↗</span></a>`,g=o`<div class="toc-label">Kestrel</div>${p("https://getkestrel.dev","Project site","Project")}${u?[p(u,"Source on GitHub","Source"),p(`${u}/blob/HEAD/LICENSE`,"License")]:null}`;f(e,jt("docs",g,d)),window.scrollTo(0,0)}var mi=matchMedia("(max-width: 720px)");function Ll(e){if(!e)return;let t=mi.matches;e.open=!t,c("summary",e).tabIndex=t?0:-1}var Rl=()=>document.querySelector("details#tocOnPage"),kl=!1;function ip(){kl||(kl=!0,mi.addEventListener("change",()=>Ll(Rl())))}var _l=e=>`doc-h-${e}`;function rp(e,t,n,s,i,r){let a=n.findIndex($=>$.slug===s),l=n[a],d=t.find($=>$.id===l?.set);if(!l||!d){let $=t[0];j(`No doc named \u201C${s}\u201D, so here\u2019s the index.`),history.replaceState(history.state,"","#/docs"),$&&Tl(e,$,t,n,i);return}ie(i,l.title);let u=n.filter($=>$.set===l.set&&$.section===l.section),p=u.indexOf(l),g=u[p-1],h=u[p+1],m=($,T)=>o`<a href="#/docs/${$.slug}" aria-label="${T}: ${$.title}">${T==="Previous"?o`<span aria-hidden="true">←</span><span class="doc-topnav-word">Previous</span>`:o`<span class="doc-topnav-word">Next</span><span aria-hidden="true">→</span>`}</a>`,y=g||h?o`<nav class="doc-topnav" aria-label="Adjacent docs">${g?m(g,"Previous"):null}${h?m(h,"Next"):null}</nav>`:null;f(e,jt("docs",o`<div id="docToc"></div>`,o`<article class="doc" id="docsMain"></article>`));let E=c("#docToc"),R=c("#docsMain");f(R,o`<section class="doc-part" id="doc-${l.slug}">${Y(l.html)}</section>`);let O=c("section.doc-part",R),H=B("h1, h2, h3, h4",O),I=xl(H.map($=>$.textContent||""));for(let[$,T]of H.entries()){let G=I[$]??"";T.dataset.anchor=G,T.id=_l(G)}let v=O.querySelector("h1"),w=[];if(v&&w.push({id:v.id,anchor:"",title:v.textContent||l.title}),y){let $=document.createElement("div");$.className="doc-head",f($,y),v?(v.before($),$.prepend(v)):O.prepend($)}let M=document.createElement("p");M.className="eyebrow doc-set",f(M,o`<a href="#/docs/${d.id}">${d.name}</a>`),O.prepend(M);for(let $ of B("h2",O))w.push({id:$.id,anchor:$.dataset.anchor||"",title:$.textContent||""});let V=document.createElement("nav");V.className="doc-pager",f(V,o`${g?o`<a class="doc-pager-btn prev" href="#/docs/${g.slug}"><span class="doc-pager-dir">← Previous</span><span class="doc-pager-title">${g.title}</span></a>`:o`<span></span>`}${h?o`<a class="doc-pager-btn next" href="#/docs/${h.slug}"><span class="doc-pager-dir">Next →</span><span class="doc-pager-title">${h.title}</span></a>`:o`<span></span>`}`),R.appendChild(V);let A=w.map($=>o`<a class="toc-sub" href="#/docs/${l.slug}${$.anchor?`/${$.anchor}`:""}" data-target="${$.id}">${$.title}</a>`);f(E,w.length?o`<details class="toc-onpage" id="tocOnPage"><summary class="toc-label">On this page</summary>${A}</details>`:o``);let L=Rl();Ll(L),ip();let q=$=>{if(L)for(let T of B(".toc-sub",L))T.classList.toggle("on",T.dataset.target===$)};E.addEventListener("click",$=>{let T=$.target instanceof Element?$.target.closest("a[data-target]"):null,G=T?.dataset.target;G&&($.preventDefault(),q(G),L&&mi.matches&&(L.open=!1),history.replaceState(history.state,"",T?.getAttribute("href")??location.hash),document.getElementById(G)?.scrollIntoView({block:"start"}))});for(let $ of B("a[href^='http']",R))$.target="_blank",$.rel="noopener";for(let $ of B("pre",O)){let T=document.createElement("div");f(T,sp($)),$.replaceWith(...T.childNodes)}je(R);let S=w.map($=>$.id),_=S[0];if(L&&_){let $=S[S.length-1]??_,G=(document.querySelector(".room-bar")?.getBoundingClientRect().height||54)+26,x=()=>{if(!document.getElementById(_)){document.onscroll=null;return}let K=_;if(Math.ceil(window.innerHeight+window.scrollY)>=document.documentElement.scrollHeight)K=$;else for(let F of S)if((document.getElementById(F)?.getBoundingClientRect().top??Number.POSITIVE_INFINITY)<=G)K=F;else break;q(K)};document.onscroll=x,x()}let P=r?document.getElementById(_l(r)):null;P?P.scrollIntoView({block:"start"}):window.scrollTo(0,0)}function fi(e){let t=new Set(e.groups.flatMap(n=>n.routes.flatMap(s=>(s.errors??[]).map(i=>i.code))));return e.refusals.flatMap(n=>n.codes.filter(s=>!t.has(s.code)).map(s=>({...s,move:n.move})))}function Ct(e){return e.replace(/\([^)]*\)/g,"").replace(/\{[^}]*\}\??/g,"")||"/"}function rn(e){return e.title.toLowerCase().replace(/'s\b/g,"").split(/[^a-z0-9]+/).filter(t=>t!==""&&t!=="a"&&t!=="an"&&t!=="the").join("-")}var ap=/`([^`]+)`|\*\*([^*]+)\*\*|\[([^\]]+)\]\(([^)\s]+)\)/g;function lp(e){return/^https:\/\//i.test(e)||/^\/(?![/\\])/.test(e)}function ve(e){let t=[],n=0;for(let s of e.matchAll(ap)){let i=s.index??0;t.push(e.slice(n,i));let[,r,a,l,d]=s;r!==void 0?t.push(o`<code>${r}</code>`):a!==void 0?t.push(o`<strong>${ve(a)}</strong>`):l!==void 0&&d!==void 0&&t.push(lp(d)?o`<a href="${d}">${ve(l)}</a>`:ve(l)),n=i+s[0].length}return t.push(e.slice(n)),o`${t}`}function On(e,t){return o`${e.split(/\n\s*\n/).filter(n=>n.trim()).map(n=>{let s=n.trim().split(`
|
|
162
|
+
`),i=s.findIndex(l=>l.startsWith("- "));if(i===-1)return o`<p class="${t}">${ve(n.trim())}</p>`;let r=s.slice(0,i).join(" ").trim(),a=s.slice(i).reduce((l,d)=>(d.startsWith("- ")||l.length===0?l.push(d.replace(/^- /,"")):l[l.length-1]=`${l[l.length-1]} ${d.trim()}`,l),[]);return o`${r?o`<p class="${t}">${ve(r)}</p>`:null}<ul class="${t} prose-list">${a.map(l=>o`<li>${ve(l)}</li>`)}</ul>`})}`}function cp(e){return e==="access"?['-H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID"','-H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"']:['-H "Authorization: Bearer $TOKEN"']}function Cl(e,t,n){if(e.access==="webhook")return null;let s=(e.query??[]).filter(l=>l.required),i=s.length?`?${s.map(l=>`${l.name}=:${l.name}`).join("&")}`:"",r=`"${t}${Ct(e.path)}${i}"`,a=[e.method==="GET"?`curl ${r}`:`curl -X ${e.method} ${r}`];if(e.access==="admin"&&a.push(...cp(n)),e.example?.request!==void 0){let l=JSON.stringify(e.example.request).replaceAll("'","'\\''");a.push('-H "Content-Type: application/json"',`-d '${l}'`)}else if(e.accepts?.includes("multipart/form-data"))for(let l of(e.body??[]).filter(d=>d.required))a.push(`-F "${l.name}=${l.type==="file"?"@":""}:${l.name}"`);return a.join(` \\
|
|
163
|
+
`)}function bi(e,t){return t===void 0?null:tn(e,ul(t),JSON.stringify(t,null,2))}function dp(e){let t=Cl(e,location.origin,Z.session?.auth.mode??"dev");return t===null?null:tn("curl",Gs(t),t)}function Js(e){return o`${e.split(/(?<=[_./])/).map((t,n)=>o`${n?o`<wbr>`:null}${t}`)}`}function ft(e,t,n,s){return o`<div class="block api-sec"><div class="block-head"><span class="block-label">${e}${n?o`<span class="api-sec-meta">${n}</span>`:null}</span></div>${s??null}${t}</div>`}function gi(e,t,n,s){return o`<div class="api-row"><div class="api-row-head"><code class="api-row-name">${Js(e)}</code>${t?o`<span class="api-row-type">${t}</span>`:null}${n?o`<span class="api-req">Required</span>`:null}</div><div class="api-row-desc">${s}</div></div>`}function vi(e,t,n,s){return o`<div class="api-lrow"><span class="api-st api-st-${String(e)[0]}xx">${e}</span><div><div class="api-row-head"><code class="api-row-name">${t}</code></div>${n?o`<div class="api-with">${n}</div>`:null}<div class="api-row-desc">${s}</div></div></div>`}function up(e){if(!e?.length)return null;let t=e.map(n=>gi(n.name,null,n.required,ve(n.description)));return ft("Query",o`<div class="api-list api-query">${t}</div>`)}function pp(e,t){if(!e?.length)return null;let n=e.map(i=>gi(i.name,i.type,i.required,ve(i.description))),s=t?.length?o` · ${t.map((i,r)=>o`${r?", ":""}<code>${i}</code>`)}`:null;return ft("Body",o`<div class="api-list api-body">${n}</div>`,s)}function mp(e,t){if(!e?.length)return null;let n=e.map(s=>vi(s.status,Js(s.code),s.details?.length?o`with ${s.details.map((i,r)=>o`${r?", ":""}<code>${i}</code>`)}`:null,o`${ve(s.when??t.get(s.code)??"")}<span class="api-move-next">${s.move}</span>`));return ft("Refusals",o`<div class="api-ledger api-errors">${n}</div>`)}function fp(e){let t=s=>o`<ul class="api-values">${s.map(i=>o`<li><code>${i.value}</code> ${ve(i.description)}</li>`)}</ul>`,n=[...new Set(e.map(s=>s.group).filter(s=>s!==void 0))];return n.length?o`${n.map(s=>o`<div class="api-values-group">${ve(s)}</div>${t(e.filter(i=>i.group===s))}`)}`:t(e)}function yi(e){let t=e.map(n=>gi(n.name,n.object?o`<a href="#/api-reference/objects-${n.object}" class="api-obj-link" data-sec="objects-${n.object}">${n.type}</a>`:n.type,!1,o`${ve(n.description)}${n.values?.length?fp(n.values):null}`));return o`<div class="api-list api-fields">${t}</div>`}function hp(e,t){if(!e)return null;let n=e.object?o`<a href="#/api-reference/objects-${e.object}" class="api-obj-link" data-sec="objects-${e.object}">${t.get(e.object)??e.object}</a>`:null,s=n?e.as?o`<p class="api-returns"><code>${e.as}</code>: ${e.list?o`a list of ${n}`:n}${e.fields?.length?", and:":null}</p>`:o`<p class="api-returns">${n}${e.fields?.length?", and:":null}</p>`:null;return ft("Returns",e.fields?.length?yi(e.fields):null,null,s)}function bp(e){return o`${Ct(e).split(/(:[A-Za-z_]+)/).map((t,n)=>n%2?o`<span class="api-param">${t}</span>`:t)}`}function Dn(e,t){return"route"in t?o`<a class="api-self" href="#/api-reference/${t.route}" data-route="${t.route}">${D("link")}${e}</a>`:o`<a class="api-self" href="#/api-reference/${t.sec}" data-sec="${t.sec}">${D("link")}${e}</a>`}function gp(e){let t=new Map;for(let n of e.objects){let s=e.groups.find(i=>i.resources.some(r=>r.key===n.resource));if(s){let i=`${s.access}-${n.resource}`;t.set(i,[...t.get(i)??[],n])}}return t}function vp(e,t){let n=e.returns?.object;return[e.title,e.method,Ct(e.path),e.summary,...(e.errors??[]).map(s=>s.code),...n?[n,t.objects.get(n)??"",e.returns?.as??""]:[]].join(" ").toLowerCase()}function yp(e,t){return o`<li data-hay="${vp(e,t)}" data-path="${Ct(e.path).toLowerCase()}" id="route-${rn(e)}" data-route="${rn(e)}"><article class="api-op">
|
|
164
164
|
<div class="api-op-head">
|
|
165
|
-
<h4 tabindex="-1">${
|
|
165
|
+
<h4 tabindex="-1">${Dn(e.title,{route:rn(e)})}</h4>
|
|
166
166
|
</div>
|
|
167
|
-
<p class="api-op-call"><span class="api-method m-${e.method}">${e.method}</span><code class="api-path">${
|
|
167
|
+
<p class="api-op-call"><span class="api-method m-${e.method}">${e.method}</span><code class="api-path">${bp(e.path)}</code><button type="button" class="copy-btn api-copy-path" data-copy="${Ct(e.path)}" data-copy-word="" aria-label="Copy path" title="Copy path">${Te(!1,"")}</button></p>
|
|
168
168
|
<div class="api-op-body">
|
|
169
169
|
<div class="api-op-text">
|
|
170
170
|
<p class="api-summary">${ve(e.summary)}</p>
|
|
171
|
-
${e.description?
|
|
172
|
-
${
|
|
173
|
-
${
|
|
174
|
-
${
|
|
175
|
-
${
|
|
171
|
+
${e.description?On(e.description,"api-desc"):null}
|
|
172
|
+
${up(e.query)}
|
|
173
|
+
${pp(e.body,e.accepts)}
|
|
174
|
+
${hp(e.returns,t.objects)}
|
|
175
|
+
${mp(e.errors,t.meanings)}
|
|
176
176
|
</div>
|
|
177
177
|
<div class="api-op-code">
|
|
178
178
|
${bi("Request",e.example?.request)}
|
|
179
179
|
${bi("Response",e.example?.response)}
|
|
180
|
-
${
|
|
180
|
+
${dp(e)}
|
|
181
181
|
</div>
|
|
182
182
|
</div>
|
|
183
|
-
</article></li>`}var
|
|
184
|
-
<div class="api-op-head"><h4 tabindex="-1">${
|
|
183
|
+
</article></li>`}var Il=(e,t)=>e.routes.filter(n=>n.resource===t.key),Sp=80;function wp(e){let t=e.columns.map((i,r)=>r>0&&e.rows.every(a=>(a[r]??"").length<=Sp)),n=e.columns.findIndex((i,r)=>r>0&&!t[r]),s=e.rows.map(i=>{let r=/^`([^`]+)`$/.exec(i[0]??"")?.[1],a=e.columns.flatMap((d,u)=>t[u]?[o`<span class="api-row-meta"><span class="api-row-key">${d}</span> ${ve(i[u]??"")}</span>`]:[]),l=e.columns.flatMap((d,u)=>u>0&&!t[u]?[o`<div class="api-row-desc">${u===n?null:o`<span class="api-row-key">${d}:</span> `}${ve(i[u]??"")}</div>`]:[]);return o`<div class="api-row"><div class="api-row-head"><code class="api-row-name">${r===void 0?ve(i[0]??""):Js(r)}</code>${a}</div>${l}</div>`});return ft(e.title,o`<div class="api-list api-value-rows">${s}</div>`,null,On(e.description,"api-prose"))}function $p(e){return o`<article class="api-op api-object" id="api-objects-${e.key}" data-sec="objects-${e.key}">
|
|
184
|
+
<div class="api-op-head"><h4 tabindex="-1">${Dn(e.title,{sec:`objects-${e.key}`})}</h4></div>
|
|
185
185
|
<p class="api-op-call"><span class="api-method m-OBJECT">Object</span><span class="api-path">${e.fields.length} ${e.fields.length===1?"field":"fields"}</span></p>
|
|
186
186
|
<div class="api-op-body">
|
|
187
187
|
<div class="api-op-text">
|
|
188
|
-
${
|
|
188
|
+
${On(e.description,"api-prose")}
|
|
189
189
|
${yi(e.fields)}
|
|
190
|
-
${(e.tables??[]).map(
|
|
190
|
+
${(e.tables??[]).map(wp)}
|
|
191
191
|
</div>
|
|
192
192
|
<div class="api-op-code">${bi("Example",e.example)}</div>
|
|
193
193
|
</div>
|
|
194
|
-
</article>`}function
|
|
195
|
-
<div class="api-res-head"><h3 tabindex="-1">${
|
|
196
|
-
${r.map(
|
|
197
|
-
<ul class="api-rows">${i.map(a=>
|
|
198
|
-
</div>`}function
|
|
199
|
-
<h2 tabindex="-1">${
|
|
194
|
+
</article>`}function Ep(e,t,n){let s=`${e.access}-${t.key}`,i=Il(e,t),r=n.heads.get(s)??[];return o`<div class="api-res" id="api-${s}" data-sec="${s}">
|
|
195
|
+
<div class="api-res-head"><h3 tabindex="-1">${Dn(t.title,{sec:s})}</h3></div>
|
|
196
|
+
${r.map($p)}
|
|
197
|
+
<ul class="api-rows">${i.map(a=>yp(a,n))}</ul>
|
|
198
|
+
</div>`}function xp(e,t){return o`<section class="api-section" id="api-${e.access}" data-tier="${e.access}">
|
|
199
|
+
<h2 tabindex="-1">${Dn(e.title,{sec:e.access})}</h2>
|
|
200
200
|
<p class="api-blurb muted">${ve(e.blurb)}</p>
|
|
201
|
-
${e.resources.map(n=>
|
|
202
|
-
</section>`}function
|
|
203
|
-
<div class="api-res-head"><h3 tabindex="-1">${
|
|
204
|
-
${
|
|
205
|
-
${s.key==="errors"?
|
|
206
|
-
${s.fields?.length?
|
|
207
|
-
${s.key==="errors"?
|
|
201
|
+
${e.resources.map(n=>Ep(e,n,t))}
|
|
202
|
+
</section>`}function kp(e){let t=fi(e);if(!t.length)return null;let n=t.map(s=>vi(s.status,Js(s.code),null,ve(s.meaning)));return ft("Refusals any route can give",o`<div class="api-ledger api-refusals">${n}</div>`)}function _p(e){let t=fi(e).map(s=>s.code),n=s=>o`<div class="api-res" id="api-overview-${s.key}" data-sec="overview-${s.key}" data-hay="${[s.title,...s.key==="errors"?t:[]].join(" ").toLowerCase()}">
|
|
203
|
+
<div class="api-res-head"><h3 tabindex="-1">${Dn(s.title,{sec:`overview-${s.key}`})}</h3></div>
|
|
204
|
+
${On(s.text,"api-prose")}
|
|
205
|
+
${s.key==="errors"?Tp(e.statuses):null}
|
|
206
|
+
${s.fields?.length?ft(s.key==="errors"?"The error body":"Fields",yi(s.fields)):null}
|
|
207
|
+
${s.key==="errors"?kp(e):null}
|
|
208
208
|
</div>`;return o`<section class="api-section" id="api-overview" data-tier="overview">
|
|
209
209
|
${e.concepts.map(n)}
|
|
210
|
-
</section>`}function
|
|
211
|
-
${
|
|
212
|
-
${
|
|
210
|
+
</section>`}function Tp(e){let t=e.map(n=>vi(n.status,o`${n.name}`,null,ve(n.meaning)));return ft("Status codes",o`<div class="api-ledger api-statuses">${t}</div>`)}function Lp(e,t){let n=(i,r)=>o`<a href="#/api-reference/${i}" class="api-nav-res" data-sec="${i}">${r}</a>`,s=(i,r)=>o`<div class="api-nav-ops" data-of="${i.access}-${r.key}">${[...(t.heads.get(`${i.access}-${r.key}`)??[]).map(a=>o`<a href="#/api-reference/objects-${a.key}" class="api-nav-op" data-sec="objects-${a.key}">${a.title}</a>`),...Il(i,r).map(a=>o`<a href="#/api-reference/${rn(a)}" class="api-nav-op" data-route="${rn(a)}">${a.title}</a>`)]}</div>`;return o`<a href="#/api-reference" class="api-nav-tier" data-sec="overview" data-tier="overview">Introduction</a>${e.concepts.map(i=>n(`overview-${i.key}`,i.title))}${e.groups.map(i=>o`<a href="#/api-reference/${i.access}" class="api-nav-tier" data-sec="${i.access}" data-tier="${i.access}">${i.title}</a>${i.resources.map(r=>[i.resources.length>1?n(`${i.access}-${r.key}`,r.title):null,s(i,r)])}`)}`}function Rp(e,t){let n=e.replace(/^[a-z]+:\/\/[^/]*/,"").replace(/[?#].*$/,"");if(!n.startsWith("/"))return!1;let s=n.replace(/(.)\/+$/,"$1").split("/"),i=t.split("/");return s.length===i.length&&i.every((r,a)=>r.startsWith(":")?s[a]!=="":r===s[a])}function Cp(e,t){let n=e.dataset.path;return(e.dataset.hay??"").includes(t)||n!==void 0&&Rp(t,n)}function Al(e,t,n){let s=e.trim().toLowerCase().split(/\s+/).filter(Boolean);t.classList.toggle("filtering",s.length>0);let i=0;for(let l of B(".api-section",n)){let d=0;for(let p of B(".api-res",l)){let g=p.dataset.hay!==void 0,h=0;for(let y of g?[p]:B("li[data-hay]",p)){let E=s.every(O=>Cp(y,O));y.hidden=!E,h+=E?1:0;let R=y.dataset.route?t.querySelector(`a[data-route="${y.dataset.route}"]`):null;R&&(R.hidden=!E)}p.hidden=h===0;for(let y of B(`.api-nav-ops[data-of="${p.dataset.sec}"] a[data-sec]`,t))y.hidden=s.length>0&&h===0;let m=t.querySelector(`a[data-sec="${p.dataset.sec}"]`);m&&(m.hidden=h===0),d+=h}l.hidden=d===0;let u=t.querySelector(`a[data-tier="${l.dataset.tier}"]`);u&&(u.hidden=d===0),i+=d}let r=B(".api-section",n),a=r.filter(l=>!l.hidden).at(-1);for(let l of r)l.classList.toggle("api-last",l===a);c("#apiEmpty",n).hidden=i>0}function hi(e,t,n){let s=(c(".room-bar").getBoundingClientRect().height||54)+8,i=B(".api-section, .api-res, .api-object, li[data-route]",t).filter(y=>!y.closest("[hidden]")),r=window.scrollY>0&&Math.ceil(window.innerHeight+window.scrollY)>=document.documentElement.scrollHeight,a;for(let y of i)if(r||y.getBoundingClientRect().top<=s)a=y;else break;let l=B("a[data-sec], a[data-route]",e).filter(y=>!y.hidden&&getComputedStyle(y).display!=="none"),d=y=>y?(y.dataset.route?l.find(R=>R.dataset.route===y.dataset.route):l.find(R=>R.dataset.sec===(y.dataset.sec??y.dataset.tier)))??d(y.parentElement?.closest(".api-res, .api-section")):void 0,u=a?.closest(".api-res")?.dataset.sec;for(let y of B(".api-nav-ops",e))y.classList.toggle("open",y.dataset.of===u);let p=d(a??i[0]);for(let y of B("a[data-sec], a[data-route]",e))y.classList.toggle("active",y===p);let g=e.closest(".rail-inner");if(p&&g&&g.scrollHeight>g.clientHeight){let y=p.getBoundingClientRect(),E=g.getBoundingClientRect();(y.top<E.top+40||y.bottom>E.bottom-40)&&(g.scrollTop+=y.top-E.top-E.height/3)}let h=a?.dataset.route??a?.dataset.sec??a?.dataset.tier,m=h&&h!=="overview"&&window.scrollY>0?`#/api-reference/${h}`:"#/api-reference";n&&location.hash!==m&&history.replaceState(history.state,"",m)}function Hl(e){return document.getElementById(e==="overview"?"api-intro":`api-${e}`)}function Pl(e){e.id==="api-intro"?window.scrollTo(0,0):e.scrollIntoView({block:"start"}),e.querySelector(":scope > h1, :scope > h2, :scope > .api-res-head h3, :scope > .api-op-head h4, :scope > article > .api-op-head h4")?.focus({preventScroll:!0})}async function Si(e,t,n){ie(t,"API reference"),f(e,jt("api-reference",o`<div class="toc-label">API</div><nav class="api-nav" id="apiNav" aria-label="API sections"></nav>`,o`<div class="api-content" id="apiContent"><p class="muted">Loading…</p></div>`));let s=c("#apiNav"),i=c("#apiContent"),r=m=>{let y=m.target instanceof Element?m.target.closest("a[data-sec], a[data-route]"):null,E=y?.dataset.route?document.getElementById(`route-${y.dataset.route}`):y?.dataset.sec?Hl(y.dataset.sec):null;!E||m.button!==0||m.metaKey||m.ctrlKey||m.shiftKey||m.altKey||(m.preventDefault(),(E.closest("[hidden]")||y?.closest("#apiEmpty"))&&g(""),history.replaceState(history.state,"",y?.getAttribute("href")??location.hash),Pl(E),hi(s,i,!1))};s.addEventListener("click",r),i.addEventListener("click",r);let a;try{a=await C("/api/reference",{signal:t})}catch(m){re(i,z(m),()=>ne((y,E)=>Si(y,E,n)));return}let l={meanings:new Map(a.refusals.flatMap(m=>m.codes.map(y=>[y.code,y.meaning]))),objects:new Map(a.objects.map(m=>[m.key,m.title])),heads:gp(a)};f(s,Lp(a,l)),f(i,o`<header class="api-head" id="api-intro"><h1 tabindex="-1">API reference</h1><p class="muted">Every endpoint this instance serves, the one API the web editor and Claude both call. It's read from the running code, so it always matches this version. Base URL <code>${location.origin}</code>.</p><div class="api-filter">${D("search")}<input type="search" id="apiFilter" placeholder="Filter by name, path, URL, or error code" autocomplete="off" aria-label="Filter routes" aria-keyshortcuts="/"><kbd aria-hidden="true">/</kbd><button type="button" class="icon api-filter-clear" id="apiFilterClear" aria-label="Clear filter" hidden>${D("x")}</button></div></header>${_p(a)}${a.groups.map(m=>xp(m,l))}<p class="api-empty muted" id="apiEmpty" hidden>Nothing matches. Try a path segment like <code>sends</code>, a method like <code>DELETE</code>, or a code like <code>stale_revision</code>, or start from the <a href="#/api-reference" data-sec="overview">Introduction</a>.</p>`);let d=c("#apiFilter"),u=c("#apiFilterClear"),p=()=>hi(s,i,!1),g=m=>{d.value=m,u.hidden=m==="",Al(m,s,i),p()};d.addEventListener("input",()=>g(d.value)),u.addEventListener("click",()=>{g(""),d.focus()}),je(i),document.addEventListener("keydown",m=>{let y=m.target instanceof HTMLElement&&(m.target.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(m.target.tagName));m.key==="/"&&!y&&!m.metaKey&&!m.ctrlKey&&!m.altKey?(m.preventDefault(),d.focus()):m.key==="Escape"&&m.target===d&&d.value&&g("")},{signal:t}),Al("",s,i),window.addEventListener("scroll",()=>hi(s,i,!0),{passive:!0,signal:t}),window.scrollTo(0,0);let h=n?document.getElementById(`route-${n}`)??Hl(n):null;h&&Pl(h),p()}var Qs=z;function Ap(e){let t=[Je(e,"reschedule")?o`<button class="ghost" data-reschedule="${e.id}">Edit schedule</button>`:null,Je(e,"cancel")?o`<button class="ghost" data-cancel="${e.id}">Cancel</button>`:null];return t.some(Boolean)?o`<div class="row" data-closes="${e.fire_at}">${t}</div>`:null}async function wi(e,t){ie(t,"Sent");let n={status:"sent",search:"",failures:"",sort:"fire_at",dir:"desc",offset:0,limit:50};f(e,o`<h1>Sent</h1>
|
|
211
|
+
${vn()?o`<p class="muted">A local stand-in sends these: they are recorded here, but nothing is delivered.</p>`:null}
|
|
212
|
+
${Ss("sent-not-connected",o`No email provider connected, so nothing can be sent yet. ${He()} to start sending.`)}
|
|
213
213
|
<div id="stuck"></div>
|
|
214
214
|
<h2>Scheduled</h2><div id="scheduled"><p class="muted">Loading…</p></div>
|
|
215
215
|
<div id="active"></div>
|
|
216
216
|
<h2>Sent posts</h2>
|
|
217
|
-
${
|
|
217
|
+
${Zt({searchPlaceholder:"Search subject\u2026",failures:!0})}
|
|
218
218
|
<div id="sendsList"><p class="muted">Loading…</p></div>
|
|
219
|
-
<div id="sendsPager"></div>`);let s=c("#stuck",e),i=c("#scheduled",e),r=c("#active",e),a=c("#sendsList",e),l=c("#sendsPager",e),d=Ns(e,t),u=[],p=!1,g=0,h=0,m=new Map;function y(){
|
|
219
|
+
<div id="sendsPager"></div>`);let s=c("#stuck",e),i=c("#scheduled",e),r=c("#active",e),a=c("#sendsList",e),l=c("#sendsPager",e),d=Ns(e,t),u=[],p=!1,g=0,h=0,m=new Map;function y(){L(),q(),Ue()}function E(S){let _=S.filter(P=>P.status==="sending"&&!kn(P));f(r,_.length?o`<h2>In progress</h2>${_.map(P=>Os(P))}`:o``);for(let P of B("[data-watch]",r))P.onclick=$=>{$.target instanceof Element&&$.target.tagName==="A"||(location.hash=`#/sent/${P.dataset.watch}`)}}function R(S){let _=S.flatMap(F=>{let ee=fe(F,"refused");return ee?[{s:F,c:ee}]:[]}),P=be()?_.filter(F=>F.c.cause==="not_connected"):[],$=_.filter(F=>!P.includes(F)),T=e.querySelector(".sent-not-connected");T&&(T.hidden=P.length>0);let G=P.map(({s:F},ee)=>o`${ee===0?"":ee===P.length-1?" and ":", "}<a href="#/sent/${F.id}">${F.subject}</a>`),x=P.length?o`<div class="card stuck-card sent-held"><div class="stuck-head"><span class="stuck-dot">⚠️</span><div>${ys(o`${G}`,P.length)}</div></div></div>`:null,K=S.flatMap(F=>{let ee=fe(F,"wedged");return ee?[{s:F,c:ee}]:[]});f(s,o`${x}${$.map(({s:F,c:ee})=>o`<div class="card stuck-card"><div class="stuck-head"><span class="stuck-dot">⚠️</span><div><strong><a href="#/sent/${F.id}">${F.subject}</a></strong><div class="muted">${ee.message}</div></div></div></div>`)}${K.map(({s:F,c:ee})=>o`<div class="card stuck-card"><div class="stuck-head"><span class="stuck-dot">⚠️</span><div><strong><a href="#/sent/${F.id}">${F.subject}</a></strong><div class="muted">${ee.message}</div></div></div>${Je(F,"resolve")?o`<button class="primary" data-resolve="${F.id}">Resolve…</button>`:null}</div>`)}`);for(let F of B("[data-resolve]",s)){let ee=K.find(Le=>Le.s.id===F.dataset.resolve);ee&&(F.onclick=()=>Vs({id:ee.s.id,c_in_flight:ee.c.count},y,t))}}function O(){for(let S of m.values()){let _=B("tr[data-id]",a).find(P=>P.dataset.id===S.id)?.querySelector("td.delivered");_&&f(_,Gt(S.counts))}}function H(){let S=Kt(u,m);R(S),p&&E(S),O()}let I=S=>S==="scheduled"||S==="due",v=S=>S==="sent"||S==="complete";function w(S){for(let _ of S.sends)m.set(_.id,_);for(let _ of S.removed)m.delete(_);H(),(S.sends.some(_=>I(at(_)))||S.changes.some(_=>I(_.from)))&&L(),S.removed.length?(L(),q()):S.changes.some(_=>v(_.to)&&!v(_.from))&&q()}let M=!1;function V(S){let _=S.filter(P=>P!==null);M||!_.length||(M=!0,Wt({cursor:_.map(P=>P.cursor).reduce(ks),sends:_.flatMap(P=>P.sends)},{update:w,stale:()=>{t.aborted||ne(wi)}},t))}async function A(){try{let S=await C("/api/sends?status=sending&limit=200",{signal:t});return u=S.sends,p=!0,H(),S}catch(S){return re(r,Qs(S),async()=>V([await A()])),null}}async function L(){let S=++g;try{let _=await C("/api/sends?status=scheduled&sort=fire_at&dir=asc&limit=200",{signal:t});if(S!==g)return _;let{sends:P}=_,$=x=>o`<div class="card spread clickable sched-card" data-post="${x.post_id}"><div><a class="card-link sched-subj" href="#/edit/${x.post_id}">${x.subject}</a><div class="muted">${Ms(x)} · ${W(x.fire_at)} · ${lt(x.audience.count)}${Is(x)}</div></div>${Ap(x)}</div>`,[T,...G]=P;if(!T)f(i,o`<p class="muted">Nothing scheduled.</p>`);else{f(i,o`${$(T)}${G.length?o`<div id="schedMore" hidden>${G.map($)}</div><button type="button" class="ghost sched-toggle" id="schedToggle" aria-expanded="false">Show all ${P.length} scheduled</button>`:null}`);let x=i.querySelector("#schedToggle");x&&(x.onclick=()=>{let K=c("#schedMore",i),F=K.hidden;K.hidden=!F,x.setAttribute("aria-expanded",String(F)),x.textContent=F?"Show fewer":`Show all ${P.length} scheduled`})}for(let x of B(".card.clickable",i))x.onclick=K=>{let F=K.target;F instanceof Element&&F.tagName!=="A"&&!F.closest("button")&&(location.hash=`#/edit/${x.dataset.post}`)};for(let x of B("[data-reschedule]",i)){let K=P.find(F=>F.id===x.dataset.reschedule);K&&(x.onclick=()=>{Ws(K,y,t)})}for(let x of B("[data-cancel]",i))x.onclick=()=>J(x,"Canceling\u2026",async()=>{try{await C(`/api/sends/${x.dataset.cancel}/cancel`,{method:"POST"}),j("Canceled"),y()}catch(K){j(Qs(K))}});return d(),_}catch(_){return S===g&&re(i,Qs(_),async()=>V([await L()])),null}}async function q(){let S=++h;try{let _=await C(`/api/sends?${Yt(n)}`,{signal:t});if(S!==h)return _;let P=_.sends;if(!P.length)return f(a,o`<p class="muted">${n.search?"No sent posts match.":n.failures?"Every sent post delivered cleanly.":"No sent posts yet."}</p>`),f(l,o``),_;f(a,o`<div class="table-wrap"><table class="list-table sent-table stacks"><colgroup><col><col class="c-date"><col class="c-num"><col class="c-delivered"></colgroup><thead><tr>${xe("Subject","subject",n)}${xe("When","fire_at",n)}${xe("Recipients","audience.count",n,"num")}<th class="num">Delivered</th></tr></thead><tbody>${P.map($=>o`<tr class="clickable" data-id="${$.id}"><td class="subject">${kt(o`<a href="#/sent/${$.id}">${$.subject}</a>`,$)}</td><td class="muted">${W($.completed_at??$.fire_at)}</td><td class="num recipients"><span class="n">${$.audience.count.toLocaleString()}</span></td><td class="num delivered">${Gt($.counts)}</td></tr>`)}</tbody></table></div>`),ct(a,n,q);for(let $ of B("tr[data-id]",a))$.onclick=T=>{T.target instanceof Element&&T.target.tagName==="A"||(location.hash=`#/sent/${$.dataset.id}`)};return dt(l,n,_.page,q),O(),_}catch(_){return S===h&&re(a,Qs(_),async()=>V([await q()])),null}}Jt(e,n,q),V(await Promise.all([L(),A(),q()]))}var Hp="erased:";function Ml(e){return e.startsWith(Hp)}function At(e,t,n){let s=URL.createObjectURL(new Blob([e],{type:n})),i=document.createElement("a");i.href=s,i.download=t,i.click(),setTimeout(()=>URL.revokeObjectURL(s),1e4)}function Xs(e){if(e.event==="delivered")return{label:"Delivered",sw:"ok"};if(e.event==="bounced")return e.bounce_kind==="hard"?{label:"Hard bounce",sw:"warn"}:e.bounce_kind==="soft"?{label:"Soft bounce",sw:"warn"}:{label:"Bounce",sw:"warn"};if(e.event==="complained")return{label:"Complained",sw:"danger"};switch(e.status){case"unsent":return{label:"Unsent",sw:"neutral"};case"skipped":return{label:"Skipped",sw:"neutral"};case"accepted":return{label:"Accepted",sw:"sending"};default:return{label:"In flight",sw:"sending"}}}var Bn=z;async function $i(e,t,n){let s=()=>{n.aborted||ne((a,l)=>$i(e,a,l))};ie(n,"Sent"),f(t,o`<p class="muted">Loading…</p>`);let i;try{i=await C(`/api/sends/${e}`,{signal:n})}catch(a){re(t,Bn(a),s);return}if(n.aborted)return;let{send:r}=i;if(ie(n,r.subject||"Untitled"),r.status==="scheduled"){location.replace(`#/edit/${r.post_id}`);return}return r.status==="sending"?Up(i,t,n,s):Kp(e,i,t,n,s)}var Pp={scheduled:{label:"Scheduled",tone:"scheduled"},due:{label:"Due",tone:"scheduled"},progressing:{label:"Sending",tone:"sending"},retrying:{label:"Retrying",tone:"warn"},backing_off:{label:"Backing off",tone:"warn"},needs_attention:{label:"Needs attention",tone:"danger"},settling:{label:"Settling",tone:"sending"},complete:{label:"Complete",tone:"ok"},canceled:{label:"Canceled",tone:"muted"}},Ip={progressing:"Handing recipients to the provider.",retrying:"Some recipients hit a transient error and will be retried.",backing_off:"Some recipients hit a transient error. They\u2019re retried on the next sweep.",needs_attention:"Some deliveries can\u2019t be confirmed either way, and wait on your decision.",settling:"Dispatch complete, waiting on delivery receipts."};function Mp(e){let t=e.provider.halt;return t&&Vl(e)?`${t.cause==="not_connected"?"No email provider is connected":t.reason==="account"?"The provider is refusing this account":"The provider is unavailable"}, so this post waits with the send already held and hasn\u2019t handed anyone off; ${zt(t.retry_at)}.`:Ce(e,"refused")&&t?.cause==="not_connected"?`No email provider is connected, so nothing goes out until one is; ${zt(t.retry_at)}.`:Ce(e,"refused")&&t?`The provider is refusing ${Mo(t.cause)?"this send":"this account"}, so nothing more goes out until it\u2019s fixed; ${zt(t.retry_at)}.`:e.phase==="backing_off"&&t?.reason==="unavailable"?`The provider is unavailable; ${zt(t.retry_at)}.`:Ce(e,"stuck")?"Nothing is being handed off to the provider right now.":e.phase==="progressing"&&e.counts.dispatched===0&&e.counts.pending>0?"Paused between ticks. It resumes on the next sweep.":Ip[e.phase]||""}function Un(e){let t=Pp[e]??{label:e,tone:"muted"};return o`<span class="phase-pill tone-${t.tone}">${t.label}</span>`}function Np(e,t,n,s,i){let r=s>0?xn(100*n/s):0;return o`<div class="wbar-row">
|
|
220
220
|
<div class="wbar-head"><span class="wbar-label">${t}</span><span class="wbar-count">${n.toLocaleString()} / ${s.toLocaleString()}</span></div>
|
|
221
221
|
<div class="wbar" role="progressbar" aria-valuenow="${r}" aria-valuemin="0" aria-valuemax="100"><div class="wbar-fill tone-${e}" style="width:${r}%"></div></div>
|
|
222
222
|
${i?o`<div class="wbar-sub muted">${i}</div>`:null}
|
|
223
|
-
</div>`}function
|
|
223
|
+
</div>`}function Op(e,t,n,s,i){let r=s>0?xn(100*n/s):0,a=s>0?xn(100*t/s):0;return o`<div class="wbar-row">
|
|
224
224
|
<div class="wbar-head"><span class="wbar-label">${e}</span><span class="wbar-count">${t.toLocaleString()} of ${n.toLocaleString()} accepted</span></div>
|
|
225
225
|
<div class="wbar dual" role="progressbar" aria-valuenow="${a}" aria-valuemin="0" aria-valuemax="100">
|
|
226
226
|
<div class="wbar-fill tone-accepted" style="width:${r}%"></div>
|
|
227
227
|
<div class="wbar-fill tone-ok" style="width:${a}%"></div>
|
|
228
228
|
</div>
|
|
229
229
|
<div class="wbar-sub muted">${i}</div>
|
|
230
|
-
</div>`}var
|
|
230
|
+
</div>`}var Dp=[{key:"pending",label:"Pending",sw:"neutral"},{key:"dispatched",label:"In flight",sw:"sending"},{key:"accepted",label:"Accepted",sw:"sending"},{key:"delivered",label:"Delivered",sw:"ok"},{key:"bounced",label:"Bounced",sw:"warn"},{key:"complained",label:"Complained",sw:"danger"},{key:"unsent",label:"Unsent",sw:"neutral"},{key:"skipped",label:"Skipped",sw:"neutral"}];function Bp(e){return o`<div class="wcounts">${Dp.map(t=>o`<div class="wcount"><div class="wcount-n">${(e[t.key]||0).toLocaleString()}</div><div class="wcount-l"><span class="rec-sw sw-${t.sw}"></span>${t.label}</div></div>`)}</div>`}function jl(e){let t=e.counts,n=t.accepted+t.delivered+t.bounced+t.complained,s=e.dispatch.rate_per_min,i=e.dispatch.eta_ms,r=e.status==="sending"?`${Mp(e)}${i?`${s?` \xB7 ~${s.toLocaleString()}/min`:""} \xB7 ETA ${Ps(i)}`:""}`:"Dispatch complete.",a=(t.unsent||0)+(t.bounced||0)+(t.complained||0),l=vn()?"Local stand-in: nothing is delivered":be()?"No email provider connected":`Provider: ${e.provider?.name||"unknown"}`,d=fe(e,"refused"),u=d?.cause==="not_connected",p=Mo(d?.cause??null),g=fe(e,"stuck"),h=fe(e,"provider_unavailable"),m=h?.severity==="warn"?h:void 0;return o`
|
|
231
231
|
${g?o`<div class="health amber" role="status"><span class="health-dot">⚠️</span><div>${g.message}</div></div>`:null}
|
|
232
232
|
${m?o`<div class="health amber" role="status"><span class="health-dot">⚠️</span><div>${m.message}</div></div>`:null}
|
|
233
233
|
${d?o`<div class="health red" role="alert"><span class="health-dot">⚠️</span><div><strong>${u?"No email provider is connected":p?"The provider is refusing this send":"The provider is refusing this account"}</strong>${u?null:o`<div>${d.error}</div>`}<div class="refused-advice">${u?Do():d.advice}</div><div>${d.since===null?null:`Since ${W(d.since)}. `}No one has been marked unsent because of this, and once ${u?"one is connected":"this is fixed"} the send resumes at its next retry${d.retry_at===null?"":`, ${W(d.retry_at)}`}.</div></div></div>`:null}
|
|
234
234
|
<div class="wbars">
|
|
235
|
-
${
|
|
236
|
-
${
|
|
235
|
+
${Np("sending","Dispatch: provider-accepted",n,e.audience.count,r)}
|
|
236
|
+
${Op("Delivery: webhook-confirmed",e.delivery.confirmed,n,e.audience.count,"Delivery lags acceptance: grey is accepted but unconfirmed, and green fills in as receipts arrive.")}
|
|
237
237
|
</div>
|
|
238
|
-
${
|
|
239
|
-
<div class="whealth${a?" has-failures":""}"><span class="whealth-dot"></span><span>${l} · ${a?`${a.toLocaleString()} bounced / unsent / complained`:"no delivery failures"}</span></div>`}function
|
|
238
|
+
${Bp(t)}
|
|
239
|
+
<div class="whealth${a?" has-failures":""}"><span class="whealth-dot"></span><span>${l} · ${a?`${a.toLocaleString()} bounced / unsent / complained`:"no delivery failures"}</span></div>`}function Vl(e){return e.status==="sending"&&e.provider.halt!==null&&!e.audience.fixed}function eo(e){let t=ml(e);return t===null?null:o`<div class="rec-meta rec-by">${t}</div>`}function Wl(e){if(Vl(e))return o`Due ${W(e.fire_at)} · held before handing anyone off · about ${lt(e.audience.count)}`;let t=e.started_at?`Started ${W(e.started_at)}`:"Sending now";return o`${t} · ${lt(e.audience.count)}`}function Nl(e){let t=e;return o`
|
|
240
240
|
<div class="editor-head">
|
|
241
241
|
<a href="#/sent" class="back">← Sent</a>
|
|
242
242
|
${Je(t,"resolve")?o`<button type="button" class="primary" id="resolveBtn">Resolve…</button>`:null}
|
|
243
243
|
</div>
|
|
244
244
|
<div class="card rec-card watch-card">
|
|
245
245
|
<div class="rec-head">
|
|
246
|
-
<div class="watch-title"><h1>${e.subject||o`<em>untitled</em>`}</h1><span id="watchPill">${
|
|
247
|
-
<div class="rec-meta" id="watchMeta">${
|
|
246
|
+
<div class="watch-title"><h1>${e.subject||o`<em>untitled</em>`}</h1><span id="watchPill">${Un(t.phase)}</span></div>
|
|
247
|
+
<div class="rec-meta" id="watchMeta">${Wl(e)}</div>
|
|
248
248
|
<div id="watchBy">${eo(e)}</div>
|
|
249
249
|
</div>
|
|
250
|
-
<div id="watchBody">${
|
|
250
|
+
<div id="watchBody">${jl(t)}</div>
|
|
251
251
|
<p class="rec-note muted">This view updates live while the send is in flight. Delivery receipts keep arriving after dispatch finishes, and the record stays accurate as they settle.</p>
|
|
252
|
-
</div>`}function
|
|
252
|
+
</div>`}function Ol(e,t,n,s){let i=e.querySelector("#resolveBtn");if(i){let r=fe(t,"wedged")?.count??t.counts.dispatched;i.onclick=()=>Vs({id:t.id,c_in_flight:r},n,s)}}function Dl(e,t){let n=e.querySelector("#watchPill");n&&f(n,Un(t.phase));let s=e.querySelector("#watchMeta");s&&f(s,Wl(t));let i=e.querySelector("#watchBy");i&&f(i,o`${eo(t)}`);let r=e.querySelector("#watchBody");r&&f(r,jl(t))}function Up(e,t,n,s){f(t,Nl(e.send)),Ol(t,e.send,s,n);let i=e.send;vt(1e3,()=>Dl(t,i),n),$n(e,{update:r=>{if(r.status!=="sending"){s();return}i=r,Je(r,"resolve")!==!!t.querySelector("#resolveBtn")?(f(t,Nl(r)),Ol(t,r,s,n)):Dl(t,r)},removed:s,stale:s},n)}function Bl(e){let t=[{n:e.recipients,label:"Recipients",cls:"",sw:"neutral"},{n:e.delivered,label:"Delivered",cls:"ok",sw:"ok"},{n:e.bounced,label:"Bounced",cls:"warn",sw:"warn"},{n:e.complained,label:"Complained",cls:"danger",sw:"danger"},{n:e.unsent,label:"Unsent",cls:"",sw:"neutral"}];return o`${t.map(n=>o`<div class="rec-tile"><div class="rec-n ${n.cls}">${n.n.toLocaleString()}</div><div class="rec-l"><span class="rec-sw sw-${n.sw}"></span>${n.label}</div></div>`)}`}function Ul(e){let t=e.recipients,n=[`${e.delivered.toLocaleString()} delivered`];e.bounced&&n.push(`${e.bounced.toLocaleString()} bounced`),e.complained&&n.push(`${e.complained.toLocaleString()} complained`),e.unsent&&n.push(`${e.unsent.toLocaleString()} unsent`),e.accepted&&n.push(`${e.accepted.toLocaleString()} accepted, awaiting a delivery receipt`),e.skipped&&n.push(`${e.skipped.toLocaleString()} skipped (unsubscribed or suppressed before hand-off, never mailed)`),e.pending&&n.push(`${e.pending.toLocaleString()} pending`),e.dispatched&&n.push(`${e.dispatched.toLocaleString()} in flight`);let s=`All ${t.toLocaleString()} accounted for: ${n.join(", ")}.`,i=e.bounced||e.complained?" Hard bounces are suppressed automatically and spam complaints unsubscribe the reader, so those addresses won\u2019t be mailed again.":"",r=e.bounced?" A soft bounce is temporary, so it\u2019s counted and the address stays on the list.":"";return`${s}${i}${r}`}function Fp(e,t){return Object.keys(e).every(n=>e[n]===t[n])}var qp=[{v:"all",label:"All"},{v:"delivered",label:"Delivered"},{v:"failures",label:"Failures"}];function jp(e){return e.search?"No recipients match that address.":e.view==="failures"?"No delivery failures. Every recipient was accepted or delivered.":e.view==="delivered"?"No delivery receipts confirmed yet.":"No recipients on this send."}function Vp(e){let t=new URLSearchParams;t.set("view",e.view);let n=(e.search||"").trim();return n&&t.set("search",n),e.sort&&(t.set("sort",e.sort),t.set("dir",e.dir??"asc")),t.set("limit",String(e.limit)),t.set("offset",String(e.offset)),t.toString()}function Wp(e,t){let n=e.map(s=>{let i=Xs(s),r=o`<span class="rec-out"><span class="rec-sw sw-${i.sw}"></span>${i.label}</span>`,a=s.error||s.event_detail||"",l=s.event_at?W(s.event_at):"",d=Ml(s.email)?o`<span class="muted">Erased recipient</span>`:s.email;return o`<tr><td class="rec-email">${d}</td><td>${r}</td><td class="muted">${a||"\u2014"}</td><td class="muted">${l||"\u2014"}</td></tr>`});return o`<div class="table-wrap"><table class="list-table rec-people-table"><colgroup><col><col class="c-out"><col><col class="c-date"></colgroup><thead><tr>${xe("Recipient","email",t)}<th class="c-out">Outcome</th><th>Detail</th><th class="c-date">When</th></tr></thead><tbody>${n}</tbody></table></div>`}function Kp(e,t,n,s,i){let{send:r,outcomes:a}=t;if(r.status==="canceled"){zp(r,n);return}let l=a.recipients,d=r.completed_at??r.fire_at;f(n,o`
|
|
253
253
|
<div class="editor-head">
|
|
254
254
|
<a href="#/sent" class="back">← Sent</a>
|
|
255
255
|
</div>
|
|
256
256
|
<div class="rec-head rec-head-page">
|
|
257
|
-
<div class="watch-title"><h1>${r.subject||o`<em>untitled</em>`}</h1><span id="recPill">${
|
|
258
|
-
<div class="rec-meta">Sent ${W(d)} · ${
|
|
257
|
+
<div class="watch-title"><h1>${r.subject||o`<em>untitled</em>`}</h1><span id="recPill">${Un(r.phase)}</span></div>
|
|
258
|
+
<div class="rec-meta">Sent ${W(d)} · ${lt(l)}</div>
|
|
259
259
|
${eo(r)}
|
|
260
260
|
</div>
|
|
261
261
|
<section class="card rec-post" aria-labelledby="recPostTitle">
|
|
262
262
|
<h2 class="rec-part-title" id="recPostTitle">The post</h2>
|
|
263
|
-
<div class="rec-web" id="recWeb">${
|
|
263
|
+
<div class="rec-web" id="recWeb">${Fl(r)}</div>
|
|
264
264
|
</section>
|
|
265
265
|
<section class="card rec-card" aria-labelledby="recDeliveryTitle">
|
|
266
266
|
<h2 class="rec-part-title" id="recDeliveryTitle">Delivery</h2>
|
|
267
|
-
<div id="recAlert">${
|
|
267
|
+
<div id="recAlert">${ql(r)}</div>
|
|
268
268
|
<p class="rec-tiles-cap muted">Delivery outcomes keep updating as receipts arrive; the audience at fire and the published post are fixed.</p>
|
|
269
|
-
<div class="rec-tiles">${
|
|
270
|
-
<p class="rec-recon muted">${
|
|
269
|
+
<div class="rec-tiles">${Bl(a)}</div>
|
|
270
|
+
<p class="rec-recon muted">${Ul(a)}</p>
|
|
271
271
|
<div class="rec-actions">
|
|
272
272
|
<button type="button" class="ghost" id="csvBtn">Export recipients (CSV)</button>
|
|
273
273
|
</div>
|
|
@@ -275,7 +275,7 @@
|
|
|
275
275
|
<div class="rec-people-head">
|
|
276
276
|
<h3 class="rec-people-title">Recipients</h3>
|
|
277
277
|
<div class="rec-views" role="group" aria-label="Which recipients to show">
|
|
278
|
-
${
|
|
278
|
+
${qp.map((S,_)=>o`<button type="button" class="rec-view-btn" data-view="${S.v}" aria-pressed="${_===0?"true":"false"}">${S.label}</button>`)}
|
|
279
279
|
</div>
|
|
280
280
|
</div>
|
|
281
281
|
<input class="rec-people-search" type="search" placeholder="Search email…" aria-label="Search recipients by email" autocomplete="off">
|
|
@@ -283,38 +283,38 @@
|
|
|
283
283
|
<div id="recPager"></div>
|
|
284
284
|
</div>
|
|
285
285
|
<p class="rec-note muted">This is the record of what went out: the published post is the exact frozen copy readers received, and nothing here is editable.</p>
|
|
286
|
-
</section>`);let u=c("#recWeb",n),p=r,g=()=>{f(u,
|
|
287
|
-
${
|
|
288
|
-
${S?o`<div class="url-gone"><s>${
|
|
286
|
+
</section>`);let u=c("#recWeb",n),p=r,g=()=>{f(u,Fl(p));let S=u.querySelector("#recOpen"),_=u.querySelector("#recCopy"),P=u.querySelector("#recListing"),$=Kl(p);S&&$&&(S.onclick=()=>window.open($,"_blank","noopener")),_&&$&&(_.onclick=()=>{Hn(_,$)}),P&&(P.onclick=()=>p.email_only?y():m())},h=(S,_,P)=>J(S,_.email_only?"Updating\u2026":"Adding\u2026",async()=>{P.clearError();try{let $=await C(`/api/posts/${r.post_id}/settings`,{method:"PUT",json:_});P.close();let T=$.post.archive_live?$.post.archive_url:null;p={...p,email_only:$.post.email_only,links:{...p.links,archive:T}},g(),j($.post.email_only?"Removed from your archive":`Added to your archive at ${T?In(T):$.post.slug}`),Ue()}catch($){P.error(Bn($))}}),m=()=>{let S=p.links.archive,_=p.web_link==="archive",P=pe(o`<h3 id="eoHead">Remove this post from your archive?</h3>
|
|
287
|
+
${_?o`<p class="hint">It comes off your home page and your public archive. Its emails link to its archive address, so that address keeps working for anyone who has them, and isn’t listed or indexed.</p>`:o`<p class="hint">It comes off your home page and your public archive, and its archive address stops working, including links people have shared. The link in the email keeps working for anyone who has it.</p>
|
|
288
|
+
${S?o`<div class="url-gone"><s>${In(S)}</s></div>`:null}
|
|
289
289
|
<p class="pub-note">The address stays this post’s. Add it back and the same address, and the links people shared, work again.</p>`}
|
|
290
|
-
<div class="actions"><button type="button" id="eoCancel">Cancel</button><button type="button" class="primary" id="eoGo">Remove from archive</button></div>`,s);c(".modal",
|
|
290
|
+
<div class="actions"><button type="button" id="eoCancel">Cancel</button><button type="button" class="primary" id="eoGo">Remove from archive</button></div>`,s);c(".modal",P.el).setAttribute("aria-labelledby","eoHead"),c("#eoCancel",P.el).onclick=P.close;let $=c("#eoGo",P.el);$.onclick=()=>h($,{email_only:!0},P),$.focus()},y=async()=>{let S;try{S=await C(`/api/posts/${r.post_id}`,{signal:s})}catch(G){s.aborted||j(Bn(G));return}let P={...Xe(S.post,S.subject_slug_held),emailOnly:!1},$=pe(o`<h3 id="addArchHead">Add this post to your archive?</h3>
|
|
291
291
|
<p class="hint">It will be listed on your home page and in your public archive, where anyone visiting can find it. The link in the email keeps working, and forwards to it.</p>
|
|
292
292
|
<div class="dialog-settings" id="addForm"></div>
|
|
293
|
-
<div class="actions"><button type="button" id="addArchCancel">Cancel</button><button type="button" class="primary" id="addArchGo">Add to archive</button></div>`,s);c(".modal",$.el).setAttribute("aria-labelledby","addArchHead"),c("#addArchCancel",$.el).onclick=$.close,
|
|
293
|
+
<div class="actions"><button type="button" id="addArchCancel">Cancel</button><button type="button" class="primary" id="addArchGo">Add to archive</button></div>`,s);c(".modal",$.el).setAttribute("aria-labelledby","addArchHead"),c("#addArchCancel",$.el).onclick=$.close,Lt(c("#addForm",$.el),P,"add",{include:!1,fixedNote:"Its address since it was sent: links people shared work again."});let T=c("#addArchGo",$.el);T.onclick=()=>h(T,{email_only:!1},$),T.focus()};g();let E={view:"all",search:"",sort:"email",dir:"asc",offset:0,limit:50},R=c("#recRows",n),O=c("#recPager",n),H=0,I=!1,v=async S=>{let _=++H;S||(I=!0);try{let P=await C(`/api/sends/${e}/deliveries?${Vp(E)}`,{signal:s});if(_!==H)return;let $=P.page.total>0?Math.floor((P.page.total-1)/P.page.limit)*P.page.limit:0;if(!P.deliveries.length&&E.offset>$)return E.offset=$,v(S);I=!1,M(()=>{if(!P.deliveries.length){f(R,o`<p class="rec-people-empty muted">${jp(E)}</p>`),f(O,o``);return}f(R,Wp(P.deliveries,E)),ct(R,E,w),dt(O,E,P.page,w)})}catch(P){_===H&&(!S||I)&&(I=!1,re(R,Bn(P),w))}},w=()=>v(!1),M=S=>{let _=document.activeElement,P=_ instanceof HTMLElement&&(R.contains(_)||O.contains(_)),$=P?_.dataset.sort:void 0,T=P?["pager-prev","pager-next"].find(x=>_.classList.contains(x)):void 0;S();let G=$?R.querySelector(`.th-sort[data-sort="${$}"]`):T?O.querySelector(`.${T}`):null;G&&!G.disabled&&G.focus()},V=B(".rec-view-btn",n);for(let S of V)S.onclick=()=>{let _=S.dataset.view;(_==="failures"||_==="delivered"||_==="all")&&(E.view=_),E.offset=0;for(let P of V)P.setAttribute("aria-pressed",String(P===S));w()};let A=n.querySelector(".rec-people-search");if(A){let S;A.oninput=()=>{clearTimeout(S),S=setTimeout(()=>{E.search=A.value,E.offset=0,w()},250)}}w();let L=c("#csvBtn");L.onclick=()=>J(L,"Exporting\u2026",async()=>{try{let S=await ps(r.links.deliveries_csv);At(S.text,S.filename??"deliveries.csv","text/csv")}catch(S){j(S instanceof se&&S.status===404?"This send no longer exists, so there are no deliveries to export.":Bn(S))}});let q=a;$n(t,{update(S){if(S.status==="sending"){i();return}f(c("#recPill",n),Un(S.phase)),f(c("#recAlert",n),ql(S)),(S.email_only!==p.email_only||S.links.archive!==p.links.archive||S.links.unlisted!==p.links.unlisted)&&(p=S,g());let _=Gp(S);Fp(q,_)||(q=_,f(c(".rec-tiles",n),Bl(_)),c(".rec-recon",n).textContent=Ul(_),v(!0))},removed:i,stale:i},s)}function Kl(e){return e.email_only&&e.web_link==="unlisted"?e.links.unlisted:e.links.archive??e.links.unlisted}function Fl(e){let t=Kl(e),n=t?In(t):null,s=e.web_link==="archive",i=e.email_only?s?"Its emails link here. Anyone with the link can open it; nothing lists or indexes it.":"Anyone with the link can open it. Nothing lists or indexes it.":s?"Its emails link here.":"The link in the email forwards here.",r=t&&n?o`<p class="rec-link-label">Link</p><div class="rec-link"><code title="${n}">${n}</code><button type="button" class="copy-btn" id="recCopy" data-copy-word="Copy" aria-label="Copy link">${Te(!1,"Copy")}</button><button type="button" class="rec-open" id="recOpen">Open ↗</button></div><p class="rec-link-note muted">${i}</p>`:null,a=e.email_only?o`<div class="rec-arch-what"><strong>${D("mail")}Email only</strong><span class="rec-arch-note">Not on your home page or in your public archive.</span></div><button type="button" class="secondary" id="recListing">Add to archive…</button>`:o`<div class="rec-arch-what"><strong>${D("link")}In your archive</strong><span class="rec-arch-note">Listed on your home page and in your public archive.</span></div><button type="button" class="secondary" id="recListing">Remove from archive…</button>`;return o`${r}<div class="rec-arch">${a}</div>`}function ql(e){let t=fe(e,"no_receipts");return t?o`<div class="health amber" role="status"><span class="health-dot">⚠️</span><div>${t.message}</div></div>`:o``}function Gp(e){let t=e.counts;return{recipients:e.audience.count,delivered:t.delivered,bounced:t.bounced,complained:t.complained,unsent:t.unsent,skipped:t.skipped,accepted:t.accepted,pending:t.pending,dispatched:t.dispatched}}function zp(e,t){f(t,o`
|
|
294
294
|
<div class="editor-head">
|
|
295
295
|
<a href="#/sent" class="back">← Sent</a>
|
|
296
296
|
</div>
|
|
297
297
|
<div class="card rec-card">
|
|
298
298
|
<div class="rec-head">
|
|
299
|
-
<div class="watch-title"><h1>${e.subject||o`<em>untitled</em>`}</h1><span id="recPill">${
|
|
299
|
+
<div class="watch-title"><h1>${e.subject||o`<em>untitled</em>`}</h1><span id="recPill">${Un(e.phase)}</span></div>
|
|
300
300
|
<div class="rec-meta">Canceled ${W(e.completed_at)} · was scheduled for ${W(e.fire_at)}</div>
|
|
301
301
|
${eo(e)}
|
|
302
302
|
</div>
|
|
303
303
|
<p class="rec-note muted">This send was canceled before it fired, so no one was mailed.</p>
|
|
304
|
-
</div>`)}function Ei(e){let t=document.getElementById(e);if(!t)throw new Error(`the admin page has no #${e}`);return t}var to=(()=>{let e=Ei("savebar"),t=e.querySelector(".savebar-msg"),n=Ei("savebarSave"),s=Ei("savebarDiscard"),i=0,r=u=>{t&&f(t,o`<span class="savebar-dot"></span><span>${u}</span>`)},a=()=>{e.hidden=!1,e.offsetHeight,e.classList.add("show")};function l(){i++,e.classList.remove("show","is-error"),e.hidden=!0,n.onclick=null,s.onclick=null,document.body.classList.remove("has-savebar")}function d({onSave:u,onDiscard:p,saveLabel:g="Save changes",discardLabel:h="Discard"},m){if(m.aborted)return{setDirty(){},showError(){}};let y=++i;m.addEventListener("abort",()=>{i===y&&l()},{once:!0}),n.textContent=g,s.textContent=h,e.classList.remove("show","is-error"),r("You have unsaved changes."),e.hidden=!0,document.body.classList.add("has-savebar"),n.onclick=()=>J(n,"Saving\u2026",()=>Promise.resolve(u())),s.onclick=()=>p();let E=()=>i===y;return{setDirty(R){E()&&(e.classList.remove("is-error"),R?(r("You have unsaved changes."),a()):e.classList.remove("show"))},showError(R){E()&&(e.classList.add("is-error"),r(R),a())}}}return{attach:d}})();var
|
|
304
|
+
</div>`)}function Ei(e){let t=document.getElementById(e);if(!t)throw new Error(`the admin page has no #${e}`);return t}var to=(()=>{let e=Ei("savebar"),t=e.querySelector(".savebar-msg"),n=Ei("savebarSave"),s=Ei("savebarDiscard"),i=0,r=u=>{t&&f(t,o`<span class="savebar-dot"></span><span>${u}</span>`)},a=()=>{e.hidden=!1,e.offsetHeight,e.classList.add("show")};function l(){i++,e.classList.remove("show","is-error"),e.hidden=!0,n.onclick=null,s.onclick=null,document.body.classList.remove("has-savebar")}function d({onSave:u,onDiscard:p,saveLabel:g="Save changes",discardLabel:h="Discard"},m){if(m.aborted)return{setDirty(){},showError(){}};let y=++i;m.addEventListener("abort",()=>{i===y&&l()},{once:!0}),n.textContent=g,s.textContent=h,e.classList.remove("show","is-error"),r("You have unsaved changes."),e.hidden=!0,document.body.classList.add("has-savebar"),n.onclick=()=>J(n,"Saving\u2026",()=>Promise.resolve(u())),s.onclick=()=>p();let E=()=>i===y;return{setDirty(R){E()&&(e.classList.remove("is-error"),R?(r("You have unsaved changes."),a()):e.classList.remove("show"))},showError(R){E()&&(e.classList.add("is-error"),r(R),a())}}}return{attach:d}})();var Yp=["wheel","touchstart","pointerdown","keydown"];function Gl(e,t,n){if(e.scrollIntoView({block:"start"}),n.aborted||typeof ResizeObserver>"u")return()=>{};let s=new AbortController,i=()=>s.abort(),r,a=new ResizeObserver(()=>{e.scrollIntoView({block:"start"}),r??=setTimeout(i,5e3)});a.observe(t);for(let l of Yp)window.addEventListener(l,i,{capture:!0,passive:!0,signal:s.signal});return n.addEventListener("abort",i,{signal:s.signal}),s.signal.addEventListener("abort",()=>{a.disconnect(),clearTimeout(r)},{once:!0}),i}var ht=z,Fn=o` hidden`;function Se(e,t){return o`<span class="set-chip ${e}">${D(e)}${t}</span>`}function xi(e){return`settings-${e}`}function we(e,t,n=null){return o`<div class="set-sec-head" id="${xi(e)}"><h2 class="set-sec-title"><a class="set-sec-link" href="#${Vt(e)}">${D("link")}${ra(e)}</a></h2>${t}${n}<span class="set-rule"></span></div>`}function qn(e,t){return(String(e||t).trim()[0]||"K").toUpperCase()}function zl(e){let{state:t,fromName:n}=e;return o`
|
|
305
305
|
<section class="set-sec">
|
|
306
306
|
${we("confirmation-email",Se("editable","Editable"))}
|
|
307
307
|
<p class="set-lede">The email that asks a new subscriber to confirm. Edit the wording as you see fit. Kestrel adds the confirmation link.</p>
|
|
308
308
|
<div class="set-preview">
|
|
309
309
|
<div class="set-preview-bar set-ce-bar">
|
|
310
310
|
<div class="set-ce-modetog" role="group" aria-label="Confirmation email view">
|
|
311
|
-
<button type="button" class="set-ce-modebtn" id="ceTabPreview" aria-pressed="true">${
|
|
312
|
-
<button type="button" class="set-ce-modebtn" id="ceTabEdit" aria-pressed="false">${
|
|
311
|
+
<button type="button" class="set-ce-modebtn" id="ceTabPreview" aria-pressed="true">${D("preview")}Preview</button>
|
|
312
|
+
<button type="button" class="set-ce-modebtn" id="ceTabEdit" aria-pressed="false">${D("editable")}Edit</button>
|
|
313
313
|
</div>
|
|
314
314
|
</div>
|
|
315
315
|
<div id="cePreviewBody">
|
|
316
316
|
<div class="set-inbox">
|
|
317
|
-
<div class="set-inbox-avatar" id="cePvAvatar">${
|
|
317
|
+
<div class="set-inbox-avatar" id="cePvAvatar">${qn(t.name,n)}</div>
|
|
318
318
|
<div class="set-inbox-body">
|
|
319
319
|
<div class="set-inbox-top"><span class="set-inbox-from" id="cePvFrom">${t.name||n}</span><span class="set-inbox-time">now</span></div>
|
|
320
320
|
<div class="set-inbox-subj" id="cePvSubject"></div>
|
|
@@ -363,43 +363,43 @@
|
|
|
363
363
|
</div>
|
|
364
364
|
</div>
|
|
365
365
|
</div>
|
|
366
|
-
</section>`}function
|
|
366
|
+
</section>`}function Yl(e,t){let{state:n}=t,s=t.data.settings.confirmation_email_default,i={subject:c("#ceSubject",e),message:c("#ceMessage",e),button:c("#ceButton",e),footer:c("#ceFooter",e)},r={avatar:c("#cePvAvatar",e),from:c("#cePvFrom",e),subject:c("#cePvSubject",e),body:c("#cePvBody",e),button:c("#cePvButton",e),foot:c("#cePvFoot",e),mast:c("#cePvMast",e),mastLogo:c("#cePvMastLogo",e),mastName:c("#cePvMastName",e),mastTag:c("#cePvMastTag",e)},a=()=>{let m=n.confirmation;r.avatar.textContent=qn(n.name,t.fromName),r.from.textContent=n.name||t.fromName,r.subject.textContent=m.subject.trim()||s.subject||"",r.body.textContent=m.body.trim()||s.body||"",r.button.textContent=m.button_label.trim()||s.button_label||"Confirm",r.foot.textContent=m.reassurance,r.foot.hidden=!m.reassurance.trim();let y=n.name||t.fromDisplay,E=!!n.logoUrl,R=E||!!y;r.mast.hidden=!R,R&&(r.mastLogo.hidden=!E,E&&f(r.mastLogo,o`<img src="${n.logoUrl}" alt="">`),r.mastName.textContent=y,r.mastName.hidden=!y,r.mastTag.textContent=n.tagline,r.mastTag.hidden=!n.tagline)},l=()=>{n.confirmation.subject=i.subject.value,n.confirmation.body=i.message.value,n.confirmation.button_label=i.button.value,n.confirmation.reassurance=i.footer.value,t.changed()};for(let m of Object.values(i))m.addEventListener("input",l);let d=c("#ceEditBody",e),u=c("#cePreviewBody",e),p=c("#ceTabEdit",e),g=c("#ceTabPreview",e),h=m=>{d.hidden=!m,u.hidden=m,p.setAttribute("aria-pressed",String(m)),g.setAttribute("aria-pressed",String(!m)),m&&i.subject.focus()};return g.onclick=()=>h(!1),p.onclick=()=>h(!0),c("#ceToPreview",e).onclick=()=>h(!1),c("#ceReset",e).onclick=()=>{i.subject.value=s.subject||"",i.message.value=s.body||"",i.button.value=s.button_label||"",i.footer.value=s.reassurance||"",l()},a(),{repaint:a,reset(){i.subject.value=n.confirmation.subject,i.message.value=n.confirmation.body,i.button.value=n.confirmation.button_label,i.footer.value=n.confirmation.reassurance,a()}}}var Zp={none:"No email provider connected",fake:"Fake (dev, dead-end)",ses:"Amazon SES"};function no(e){return Zp[e]||e}function Jp(e,t){if(e.provider==="none")return o`${no(e.provider)}. ${He("set-link")} to start sending.`;let n=e.simulation?o`<span class="set-pill">Simulating ${Qp[e.simulation.profile]}${e.simulation.faults==="none"?", no failures":""}</span>`:null,s=t?Ra(t,W):null;if(t&&t.unknown_reason!=="stand_in"){let i=[s?.pill,n].filter(r=>!!r);return o`${wa(t,i.length?o`${i.map(r=>o` ${r}`)}`:null)}${s?.line??null}`}return o`<span>${no(e.provider)}${s?.pill?o` ${s.pill}`:null}${n}</span>${s?.line??null}`}var Qp={generic:"a generic provider",ses:"Amazon SES"},Xp="#/docs/ses/8-receive-replies-at-your-from-address";function em(e){let t=String(e||"").match(/<([^>]+)>/);return t?.[1]?t[1]:String(e||"")}function Zl(e){let t=e.data.deployment,{fromName:n}=e,s=e.provider,i=s?Ea(s):null;return o`
|
|
367
367
|
<section class="set-sec">
|
|
368
368
|
${we("email-sender",Se("readonly","Read-only \xB7 set at deploy"))}
|
|
369
369
|
<div class="set-card sunken">
|
|
370
|
-
<div class="set-ro-note">${
|
|
370
|
+
<div class="set-ro-note">${D("readonly")}<span>The sender is set at deploy in <code>wrangler.jsonc</code>, with the AWS keys stored as secrets, so it can’t be edited here. Change it in the <a class="set-link" href="#/docs/self-hosting">setup guide</a>, then redeploy. Credentials are never shown.</span></div>
|
|
371
371
|
<div class="set-preview-bar" style="background:transparent">
|
|
372
372
|
<span class="set-preview-lbl">Inbox preview</span>
|
|
373
373
|
<span class="set-preview-dot">How readers see the sender</span>
|
|
374
374
|
</div>
|
|
375
375
|
<div class="set-inbox">
|
|
376
|
-
<div class="set-inbox-avatar">${
|
|
376
|
+
<div class="set-inbox-avatar">${qn(n,n)}</div>
|
|
377
377
|
<div class="set-inbox-body">
|
|
378
378
|
<div class="set-inbox-top"><span class="set-inbox-from">${n}</span><span class="set-inbox-time">9:02 AM</span></div>
|
|
379
379
|
<div class="set-inbox-subj">Your latest post: a sample subject line</div>
|
|
380
380
|
<div class="set-inbox-snip">The opening lines of your post show here as the inbox preview…</div>
|
|
381
|
-
<div class="set-inbox-addr">${
|
|
381
|
+
<div class="set-inbox-addr">${em(t.from_address)}</div>
|
|
382
382
|
</div>
|
|
383
383
|
</div>
|
|
384
384
|
<div class="set-kv" style="border-top:1px solid var(--line)">
|
|
385
|
-
<div class="set-kv-k">From address</div><div class="set-kv-v set-kv-stack"><span class="mono">${t.from_address}</span><span class="muted" id="replyNote">Readers’ replies go to this address. <a class="set-link" href="${
|
|
385
|
+
<div class="set-kv-k">From address</div><div class="set-kv-v set-kv-stack"><span class="mono">${t.from_address}</span><span class="muted" id="replyNote">Readers’ replies go to this address. <a class="set-link" href="${Xp}">Forward it to your inbox</a>.</span></div>
|
|
386
386
|
<div class="set-kv-k">Sending domain</div><div class="set-kv-v"><span class="mono">${t.sending_domain}</span></div>
|
|
387
|
-
<div class="set-kv-k">Email provider</div><div class="set-kv-v set-kv-stack" id="providerValue">${
|
|
387
|
+
<div class="set-kv-k">Email provider</div><div class="set-kv-v set-kv-stack" id="providerValue">${Jp(t,s)}${s?.warnings.map(r=>o`<span class="${Ln(r)?"set-error":"set-warn"}">${Bs(r)}</span>`)}</div>
|
|
388
388
|
${i?o`<div class="set-kv-k">Send rate</div><div class="set-kv-v" id="sendRate">${i}</div>`:null}
|
|
389
389
|
</div>
|
|
390
390
|
</div>
|
|
391
|
-
</section>`}function
|
|
391
|
+
</section>`}function Jl(e){let t=e.data.deployment,n=`${t.archive_origin||""}${t.archive_base_path||""}`,s=t.archive_origin===t.app_origin;return o`
|
|
392
392
|
<section class="set-sec">
|
|
393
393
|
${we("instance",Se("readonly","Read-only \xB7 set at deploy"))}
|
|
394
394
|
<div class="set-card sunken">
|
|
395
|
-
<div class="set-ro-note">${
|
|
395
|
+
<div class="set-ro-note">${D("info")}<span>Deploy-time infrastructure, shown for reference. These live in your Worker config and never pass through the API. See the <a class="set-link" href="#/docs/configuration">setup guide</a> to change them.</span></div>
|
|
396
396
|
<div class="set-kv">
|
|
397
397
|
<div class="set-kv-k">App origin</div><div class="set-kv-v"><span class="mono">${t.app_origin}</span></div>
|
|
398
398
|
<div class="set-kv-k">Archive URL base</div><div class="set-kv-v"><span class="mono">${n}</span>${s?o`<span class="set-pill">default: app origin</span>`:null}</div>
|
|
399
399
|
<div class="set-kv-k">Image URL base</div><div class="set-kv-v"><span class="mono">${t.media_public_base}</span></div>
|
|
400
400
|
<div class="set-kv-k">Auth mode</div><div class="set-kv-v">${t.auth_mode==="access"?"Cloudflare Access":"Local dev token"}</div>
|
|
401
|
-
<div class="set-kv-k">Cloudflare Access</div><div class="set-kv-v">${t.access_configured?o`<span class="set-pill ok">${
|
|
402
|
-
<div class="set-kv-k">Minimum lead</div><div class="set-kv-v">${Ft(t.min_lead_ms)}${t.min_lead_ms===
|
|
401
|
+
<div class="set-kv-k">Cloudflare Access</div><div class="set-kv-v">${t.access_configured?o`<span class="set-pill ok">${D("check")}Configured</span>`:o`<span class="set-pill">Not configured</span>`}</div>
|
|
402
|
+
<div class="set-kv-k">Minimum lead</div><div class="set-kv-v">${Ft(t.min_lead_ms)}${t.min_lead_ms===fs?o`<span class="set-pill">default</span>`:null}</div>
|
|
403
403
|
</div>
|
|
404
404
|
</div>
|
|
405
405
|
</section>`}function so(e){return o`
|
|
@@ -407,7 +407,7 @@
|
|
|
407
407
|
<div class="set-recip-add">
|
|
408
408
|
<input type="email" id="${e.input}" placeholder="you@example.com" autocomplete="off">
|
|
409
409
|
<button type="button" id="${e.add}">Add inbox</button>
|
|
410
|
-
</div>`}function oo(e,t,n){let s=c(`#${n.ids.chips}`,e),i=c(`#${n.ids.input}`,e),r=()=>{let l=n.list();if(!l.length){f(s,o`<span class="set-recip-empty">${n.empty}</span>`);return}f(s,o`${l.map((d,u)=>o`<span class="set-recip-chip">${d}<button type="button" data-rm="${u}" aria-label="Remove ${d}">${
|
|
410
|
+
</div>`}function oo(e,t,n){let s=c(`#${n.ids.chips}`,e),i=c(`#${n.ids.input}`,e),r=()=>{let l=n.list();if(!l.length){f(s,o`<span class="set-recip-empty">${n.empty}</span>`);return}f(s,o`${l.map((d,u)=>o`<span class="set-recip-chip">${d}<button type="button" data-rm="${u}" aria-label="Remove ${d}">${D("x")}</button></span>`)}`)};s.addEventListener("click",l=>{let d=l.target instanceof Element?l.target.closest("[data-rm]"):null;d&&(n.list().splice(Number(d.dataset.rm),1),r(),t.changed())});let a=()=>{let l=$t(i.value);if(!l)return;let d=n.list(),u=Et(l)?d.includes(l)?"That inbox is already in the list.":n.max&&d.length>=n.max.count?n.max.full:"":"That doesn\u2019t look like an email address.";if(u){Fe(i,u),i.focus();return}d.push(l),i.value="",r(),t.changed()};return c(`#${n.ids.add}`,e).onclick=a,i.addEventListener("keydown",l=>{l.key==="Enter"&&(l.preventDefault(),a())}),r(),{reset:r}}function tm(e){return e instanceof se&&e.status===409&&e.data?.error==="remake_required"?e.data:null}var nm="Not saved: the change needed your confirmation";async function Ht(e,t,n){let s=null;for(;;)try{return await e(s)}catch(i){let r=tm(i);if(!r)throw i;let a=r.sends||[];if(!await sm(a,t,n))return n.aborted&&j(nm),null;s=a.map(d=>d.id)}}function sm(e,t,n){let s=e.length,i=s===1,r=`${s} scheduled email${i?"":"s"}`;return new Promise(a=>{let l=pe(o`<h3>Apply this change to ${r}?</h3>
|
|
411
411
|
<p class="hint">${t.lead(s)} ${t.gerund} applies the change to ${i?"its email":"their emails"} too.</p>
|
|
412
412
|
<ul class="remake-list">${e.map(m=>o`<li><span>${m.subject||o`<em>untitled</em>`}</span><span>sends ${W(m.fire_at)}</span></li>`)}</ul>
|
|
413
413
|
<dl class="remake-facts">
|
|
@@ -416,19 +416,19 @@
|
|
|
416
416
|
<div><dt>Next</dt><dd>send yourself a fresh test${i?"":" of each"}</dd></div>
|
|
417
417
|
</dl>
|
|
418
418
|
<p class="hint">To leave scheduled emails as they are while future posts change, you’d need a second template, which Kestrel doesn’t offer yet.</p>
|
|
419
|
-
<div class="actions"><button type="button" id="rmCancel">Cancel</button><button type="button" class="primary" id="rmGo">${t.action} and apply</button></div>`,n);if(!l.el.isConnected){a(!1);return}let d=!1,u=m=>{d||(d=!0,a(m))},p=l.el.querySelector("#rmCancel"),g=l.el.querySelector("#rmGo");p&&(p.onclick=()=>{l.close(),u(!1)}),g&&(g.onclick=()=>{l.close(),u(!0)});let h=new MutationObserver(()=>{l.el.isConnected||(h.disconnect(),u(!1))});h.observe(document.body,{childList:!0}),g?.focus()})}var
|
|
419
|
+
<div class="actions"><button type="button" id="rmCancel">Cancel</button><button type="button" class="primary" id="rmGo">${t.action} and apply</button></div>`,n);if(!l.el.isConnected){a(!1);return}let d=!1,u=m=>{d||(d=!0,a(m))},p=l.el.querySelector("#rmCancel"),g=l.el.querySelector("#rmGo");p&&(p.onclick=()=>{l.close(),u(!1)}),g&&(g.onclick=()=>{l.close(),u(!0)});let h=new MutationObserver(()=>{l.el.isConnected||(h.disconnect(),u(!1))});h.observe(document.body,{childList:!0}),g?.focus()})}var Ql={action:"Save",gerund:"Saving",lead:e=>`This template is used by ${e} post${e===1?" that\u2019s":"s that are"} already scheduled.`},jn=(e,t)=>({action:e,gerund:t,lead:n=>`Your name, tagline, address, and logo ride inside every email, including ${n} post${n===1?" that\u2019s":"s that are"} already scheduled.`});function io(e){let t=e?.sends||[];if(!t.length)return o`<span class="set-chip">${D("info")}No posts scheduled</span>`;let n=t.length;return o`<span class="set-chip inuse"><span class="set-chip-dot"></span>In use by ${n} scheduled post${n===1?"":"s"}</span>`}function om(e,t=Date.now()){let n=e?.retry_after;if(!e||!n||t>=n)return"";let s=Math.max(1,e.sends.filter(i=>i.fire_at<=n).length);return s===1?`A scheduled post sends at ${W(n)}. You can save once it has sent.`:`${s} scheduled posts send by ${W(n)}. You can save once they have sent.`}function an(e){let t=om(e);return t?o`<span data-remake-wait> ${t}</span>`:null}function ro(e,t,n){let s=t?.retry_after;s&&yt(s,()=>{for(let i of e.querySelectorAll("[data-remake-wait]"))i.remove()},n)}function ln(e,t){let n=(t||[]).length;return n?`${e} and applied to ${n} scheduled email${n===1?"":"s"}. Send yourself a test of each.`:e}var Xl=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");function ec(e,t){return e?`<img class="logo" src="${Xl(e)}" alt="${Xl(t)}" width="44" height="44" />`:""}function im(e,t){let n=Math.min(e,t);return{x:Math.floor((e-n)/2),y:Math.floor((t-n)/2),side:n}}var ki=class extends Error{constructor(){super("Couldn\u2019t read that image. Pick a PNG, JPEG, WebP, or GIF.")}};async function tc(e,t){let n=await createImageBitmap(e,{imageOrientation:"from-image"}).catch(()=>{throw new ki});try{let{x:s,y:i,side:r}=im(n.width,n.height),a=document.createElement("canvas");a.width=t,a.height=t;let l=a.getContext("2d");if(!l)throw new Error("This browser can\u2019t prepare the image.");return l.imageSmoothingQuality="high",l.drawImage(n,s,i,r,r,0,0,t,t),{png:await new Promise((u,p)=>a.toBlob(g=>g?u(g):p(new Error("This browser can\u2019t prepare the image.")),"image/png")),width:n.width,height:n.height}}finally{n.close()}}function rm(e){if(!(e.identity_fields||[]).length)return o`Your email template doesn’t show any of these.`;let t="Shown in every email.",n=e.sends.length;if(!n)return o`${t}`;let s=`Saving a change updates ${n} scheduled email${n===1?"":"s"} too; you\u2019ll confirm first.`;return o`${t} ${s}${an(e)}`}var am="#/docs/name-your-publication/when-to-provide-a-mailing-address";function Vn(){return o`<a class="set-link" href="${am}" target="_blank" rel="noopener">When to provide a mailing address <span aria-hidden="true">↗</span><span class="visually-hidden"> (opens in a new tab)</span></a>`}var _i=256;function nc(e){let{state:t,fromDisplay:n,fromName:s}=e,i=!!t.address;return o`
|
|
420
420
|
<section class="set-sec">
|
|
421
421
|
${we("publication-identity",Se("editable","Editable"))}
|
|
422
422
|
<div class="set-card">
|
|
423
423
|
<div class="set-id-grid">
|
|
424
424
|
<div class="set-logo-slot">
|
|
425
425
|
<div class="set-logo-tile${t.logoUrl?" has-img":""}" id="logoTile" role="button" tabindex="0" aria-label="Upload logo">
|
|
426
|
-
<span class="set-logo-ph" id="logoPh"${t.logoUrl?
|
|
426
|
+
<span class="set-logo-ph" id="logoPh"${t.logoUrl?Fn:null}>${D("upload")}Upload</span>
|
|
427
427
|
</div>
|
|
428
428
|
<input type="file" id="logoInput" accept="image/png,image/jpeg,image/webp,image/gif" hidden>
|
|
429
429
|
<div class="set-logo-actions">
|
|
430
430
|
<button type="button" id="logoReplace">${t.logoUrl?"Replace":"Upload"}</button>
|
|
431
|
-
<button type="button" class="danger-subtle" id="logoRemove"${t.logoUrl?null:
|
|
431
|
+
<button type="button" class="danger-subtle" id="logoRemove"${t.logoUrl?null:Fn}>Remove</button>
|
|
432
432
|
</div>
|
|
433
433
|
<div class="set-logo-notes">
|
|
434
434
|
<p class="field-hint">Shown as a square. Pick or drop an image at least ${String(_i)} × ${String(_i)} px; a wider or taller one is cropped to its center square.</p>
|
|
@@ -447,24 +447,24 @@
|
|
|
447
447
|
<input id="setTagline" value="${t.tagline}" placeholder="A one-line description" maxlength="200" autocomplete="off">
|
|
448
448
|
<p class="field-hint">A short line under the name on your public pages.</p>
|
|
449
449
|
</div>
|
|
450
|
-
<div class="set-field set-addr-add" id="addrAdd"${i?
|
|
451
|
-
<button type="button" class="ghost" id="addrAddBtn" aria-describedby="addrAddHint">${
|
|
452
|
-
<p class="field-hint" id="addrAddHint">For promotional email, US law (CAN-SPAM) requires a postal address in the footer. A P.O. box works. ${
|
|
450
|
+
<div class="set-field set-addr-add" id="addrAdd"${i?Fn:null}>
|
|
451
|
+
<button type="button" class="ghost" id="addrAddBtn" aria-describedby="addrAddHint">${D("plus")}Add a mailing address</button>
|
|
452
|
+
<p class="field-hint" id="addrAddHint">For promotional email, US law (CAN-SPAM) requires a postal address in the footer. A P.O. box works. ${Vn()}</p>
|
|
453
453
|
</div>
|
|
454
|
-
<div class="set-field" id="addrField"${i?null:
|
|
454
|
+
<div class="set-field" id="addrField"${i?null:Fn}>
|
|
455
455
|
<div class="set-field-head">
|
|
456
456
|
<label for="setAddress">Mailing address</label>
|
|
457
457
|
<button type="button" class="danger-subtle set-field-remove" id="addrRemove">Remove</button>
|
|
458
458
|
</div>
|
|
459
459
|
<input id="setAddress" value="${t.address}" placeholder="PO Box 123, City, ST 00000" maxlength="300" autocomplete="off">
|
|
460
|
-
<p class="field-hint">${
|
|
461
|
-
<p class="set-field-warn" id="addrWarn" hidden>Your email template currently doesn’t include this field. If you send promotional email, add it to the template. ${
|
|
460
|
+
<p class="field-hint">${Vn()}</p>
|
|
461
|
+
<p class="set-field-warn" id="addrWarn" hidden>Your email template currently doesn’t include this field. If you send promotional email, add it to the template. ${Vn()}</p>
|
|
462
462
|
</div>
|
|
463
463
|
</div>
|
|
464
464
|
</div>
|
|
465
|
-
<div class="set-note">${
|
|
465
|
+
<div class="set-note">${D("info")}<span>${rm(e.data.in_use)}</span></div>
|
|
466
466
|
</div>
|
|
467
|
-
</section>`}function
|
|
467
|
+
</section>`}function sc(e,t,n){let{state:s}=t,i=c("#setName",e),r=c("#setTagline",e),a=c("#setAddress",e),l=()=>{s.name=i.value.trim(),s.tagline=r.value.trim(),s.address=a.value.trim(),t.changed()};i.addEventListener("input",l),r.addEventListener("input",l),a.addEventListener("input",l);let d=!!s.address,u=(t.data.in_use.identity_fields||[]).includes("address"),p=c("#addrAdd",e),g=c("#addrField",e),h=c("#addrWarn",e),m=()=>{p.hidden=d,g.hidden=!d,h.hidden=!(d&&s.address&&!u),h.hidden?a.removeAttribute("aria-describedby"):a.setAttribute("aria-describedby","addrWarn")};a.addEventListener("input",m),c("#addrAddBtn",e).onclick=()=>{d=!0,m(),a.focus()},c("#addrRemove",e).onclick=()=>{a.value="",d=!1,l(),m(),c("#addrAddBtn",e).focus()};let y=c("#logoInput",e),E=c("#logoTile",e),R=c("#logoPh",e),O=c("#logoReplace",e),H=c("#logoRemove",e),I=c("#logoShape",e),v=T=>{if(I.hidden=!0,!T)return;let G=new Image;G.onload=()=>{I.hidden=s.logoUrl!==T||G.naturalWidth===G.naturalHeight},G.src=T},w=()=>{let T=!!s.logoUrl;v(s.logoUrl),E.classList.toggle("has-img",T),E.style.backgroundImage=T?`url('${s.logoUrl}')`:"",R.hidden=T,H.hidden=!T,O.textContent=T?"Replace":"Upload"};O.onclick=()=>y.click(),E.addEventListener("click",()=>y.click()),E.addEventListener("keydown",T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),y.click())});let M=c("#logoError",e),V=c("span:last-of-type",M),A=T=>{V.textContent=T,M.hidden=!T},L=(T,G)=>{s.logoUrl=T.settings.publication.logo_url||"",t.applySaved(T.settings),w(),t.changed(),j(ln(G,T.remade))},q=T=>A(ht(T)),S=!1,_=async T=>{if(S){A("The last logo change is still saving. Try again once it\u2019s done.");return}S=!0,A("");try{await T(),A("")}catch(G){q(G)}finally{S=!1}},P=T=>_(async()=>{let G=await tc(T,_i),x=G.width!==G.height,K=await Ht(F=>{let ee=new FormData;ee.append("file",new File([G.png],"logo.png",{type:"image/png"}));let Le=F?`?remake=${encodeURIComponent(F.join(","))}`:"";return C(`/api/settings/logo${Le}`,{method:"POST",body:ee})},jn("Upload","Uploading"),n);K&&L(K,x?"Logo updated, cropped to its center square":"Logo updated")});y.onchange=()=>{let T=y.files?.[0];y.value="",T&&P(T)};let $=c(".set-logo-slot",e);return $.addEventListener("dragover",T=>{T.dataTransfer?.types.includes("Files")&&(T.preventDefault(),T.dataTransfer.dropEffect="copy",E.classList.add("dragover"))}),$.addEventListener("dragleave",T=>{T.relatedTarget instanceof Node&&$.contains(T.relatedTarget)||E.classList.remove("dragover")}),$.addEventListener("drop",T=>{T.preventDefault(),E.classList.remove("dragover");let G=T.dataTransfer?.files??[],x=G[0];G.length>1?A("Drop one image at a time."):x?P(x):A("Couldn\u2019t read a file from that drop. Save the image first, then pick it.")}),H.onclick=()=>_(()=>J(H,"Removing\u2026",async()=>{let T=await Ht(G=>{let x=G?`?remake=${encodeURIComponent(G.join(","))}`:"";return C(`/api/settings/logo${x}`,{method:"DELETE"})},jn("Remove","Removing"),n);T&&L(T,"Logo removed")})),w(),m(),{reset(){i.value=s.name,r.value=s.tagline,a.value=s.address,d=!!s.address,m()}}}var ao=z,lm=[{group:"Post",vars:[{token:"{{ .Post.Body }}",desc:"Your post\u2019s Markdown, rendered to HTML."},{token:"{{ .Post.Subject }}",desc:"The post\u2019s subject line."}]},{group:"Publication",vars:[{token:"{{ .Publication.Name }}",desc:"Publication name (from Identity, above)."},{token:"{{ .Publication.Tagline }}",desc:"Your tagline."},{token:"{{ .Publication.Logo }}",desc:"Your logo as an image, or nothing when no logo is set."},{token:"{{ .Publication.LogoURL }}",desc:"Absolute URL of your logo, or empty."},{token:"{{ .Publication.Address }}",desc:"Your mailing address, if you\u2019ve added one in Settings; empty otherwise. Keep it in the footer if you send promotional email."}]},{group:"Email",vars:[{token:"{{ .Email.SentTo }}",desc:"The recipient\u2019s address (filled per send)."},{token:"{{ .Email.UnsubscribeURL }}",desc:"Their unsubscribe link."},{token:"{{ .Email.ViewInBrowserURL }}",desc:"The web version\u2019s permanent URL."}]},{group:"Email only",vars:[{token:"{{ if .IsEmail }} \u2026 {{ end }}",desc:"Reports whether this is the email or the web version. Put your unsubscribe link and address inside; the web version leaves them out."}]}],Ti={signed:{label:"Signed",description:"Your post, then your logo, name, and tagline as a sign-off. Your mailing address sits in the footer once you add one.",html:`<style>
|
|
468
468
|
.email {
|
|
469
469
|
font: 16px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
470
470
|
color: #18181b;
|
|
@@ -619,7 +619,7 @@
|
|
|
619
619
|
<a href="{{ .Email.ViewInBrowserURL }}">View in browser</a>
|
|
620
620
|
<div class="address">{{ .Publication.Address }}</div>{{ end }}
|
|
621
621
|
</div>
|
|
622
|
-
</div>`}},
|
|
622
|
+
</div>`}},cm=e=>Object.hasOwn(Ti,e),dm=`<div style="position:relative;border:1px dashed #93a7e6;border-radius:8px;padding:20px 14px 8px;margin:0 0 6px"><span style="position:absolute;top:-8px;left:10px;font:650 10px/1.4 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;letter-spacing:.04em;text-transform:uppercase;color:#3355cc;background:#fff;padding:0 6px">Your post\u2019s Markdown renders here</span><h2 style="margin:0 0 10px">Lorem ipsum,</h2><p style="margin:0">Dolor sit amet, consectetur adipiscing elit. Proin sed ex ipsum. Suspendisse vulputate nisi et odio dapibus, quis pellentesque felis sollicitudin. Proin vel cursus enim. Phasellus sollicitudin malesuada elementum. Suspendisse euismod eros turpis, ut mollis est imperdiet ut. Sed luctus accumsan erat, at eleifend purus eleifend quis.</p></div>`,um=new Set([".Post.Body",".Publication.Logo"]);function pm(e,t){return String(e).replace(/\{\{\s*(?:if\b[^}]*|end)\s*\}\}/g,"").replace(/\{\{\s*([\w.]+)\s*\}\}/g,(s,i)=>um.has(i)?t[i]||"":te(t[i]??""))}function mm(e){let t=e.name||"Your publication";return{".Post.Body":dm,".Post.Subject":"How your posts will look",".Publication.Name":t,".Publication.Tagline":e.tagline||"Your tagline",".Publication.LogoURL":e.logoUrl,".Publication.Logo":ec(e.logoUrl,t),".Publication.Address":e.address,".Email.SentTo":"you@example.com",".Email.UnsubscribeURL":"#unsubscribe",".Email.ViewInBrowserURL":"#view-in-browser"}}function fm(e,t){return pm(e,mm(t))}var hm='<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>html,body{margin:0}body{background:#fff}@media (prefers-color-scheme:dark){body{background:#18181b}}.kestrel-email-outer{padding:8px 12px 48px}.kestrel-email{max-width:664px;margin:0 auto;padding:24px 32px 32px;box-sizing:border-box}@media (max-width:560px){.kestrel-email{padding-left:12px;padding-right:12px}}.kestrel-email img{max-width:100%}</style></head><body><div class="kestrel-email-outer"><div class="kestrel-email"></div></div></body></html>';function Li(e,t,n,s){e.setAttribute("sandbox",nn);let i=!1,r=null;it(s,()=>r?.disconnect());let a=()=>{try{let d=e.contentDocument?.body?.scrollHeight;d&&(e.style.height=`${Math.max(200,d)}px`)}catch{}},l=()=>{let d=e.contentDocument,u=i&&d?d.querySelector(".kestrel-email"):null;u&&(f(u,Y(fm(t(),n()))),sn(u.ownerDocument),a())};return e.addEventListener("load",()=>{if(!s.aborted){i=!0,l();try{let d=e.contentDocument;d?.body&&typeof ResizeObserver<"u"&&(r?.disconnect(),r=new ResizeObserver(a),r.observe(d.body))}catch{}}}),e.srcdoc=hm,{repaint:l}}function bm(){return o`${lm.map(e=>o`<div class="set-tpl-vargroup"><h4>${e.group}</h4>${e.vars.map(t=>o`<div class="set-tpl-var"><code>${t.token}</code><span class="set-tpl-var-desc">${t.desc}</span></div>`)}</div>`)}`}async function Ri(e,t){ie(t,"Template"),f(e,o`<div class="tpl-page"><div class="page-head"><div class="page-head-row"><h1>Email template</h1><span id="tplInUse"></span></div><p class="set-lede set-page-lede">The template controls the look and feel of the emails you send. You write it as HTML with a <code><style></code> block and <code>{{ variables }}</code> Kestrel fills in; your post’s Markdown is rendered into <code>{{ .Post.Body }}</code>.<span id="tplWait"></span></p></div><div id="tplBody" class="muted">Loading…</div></div>`);let n=c("#tplBody",e),s;try{s=await C("/api/settings",{signal:t})}catch(X){re(n,ao(X),()=>ne(Ri));return}let i=s.settings,r=s.deployment,a=i.publication,l={name:gn(a.name||"",r.from_address),tagline:a.tagline||"",logoUrl:a.logo_url||"",address:a.address||""},d=i.email_template||"",u=Array.isArray(i.test_recipients)?i.test_recipients:[];f(c("#tplInUse"),io(s.in_use)),f(c("#tplWait"),o`${an(s.in_use)}`),ro(e,s.in_use,t),f(n,o`
|
|
623
623
|
<div class="set-preview set-tpl-sample">
|
|
624
624
|
<div class="set-preview-bar">
|
|
625
625
|
<span class="set-preview-titles">
|
|
@@ -628,10 +628,10 @@
|
|
|
628
628
|
</span>
|
|
629
629
|
<span class="set-preview-actions">
|
|
630
630
|
<span class="set-wtog" role="group" aria-label="Preview width">
|
|
631
|
-
<button type="button" class="wtog-btn" data-
|
|
632
|
-
<button type="button" class="wtog-btn" data-
|
|
631
|
+
<button type="button" class="wtog-btn" data-width="desktop" aria-label="Desktop" aria-pressed="true">${D("desktop")}<span class="wtog-lbl">Desktop</span></button>
|
|
632
|
+
<button type="button" class="wtog-btn" data-width="phone" aria-label="Phone" aria-pressed="false">${D("phone")}<span class="wtog-lbl">Phone</span></button>
|
|
633
633
|
</span>
|
|
634
|
-
<button type="button" class="secondary" id="tplTest">${
|
|
634
|
+
<button type="button" class="secondary" id="tplTest">${D("send")}<span id="tplTestLbl">Send test email</span></button>
|
|
635
635
|
</span>
|
|
636
636
|
</div>
|
|
637
637
|
<div class="set-email-stage" id="tplStage">
|
|
@@ -646,7 +646,7 @@
|
|
|
646
646
|
<div class="set-tpl-editor-head">
|
|
647
647
|
<div class="set-tpl-tools">
|
|
648
648
|
<button type="button" class="ghost set-menu-btn" id="tplExamplesBtn" aria-haspopup="menu" aria-expanded="false"><span>Start from example</span><span class="set-menu-caret"></span></button>
|
|
649
|
-
<button type="button" class="set-icon-btn" id="tplLineNums" aria-pressed="false" title="Show line numbers" aria-label="Show line numbers">${
|
|
649
|
+
<button type="button" class="set-icon-btn" id="tplLineNums" aria-pressed="false" title="Show line numbers" aria-label="Show line numbers">${D("lines")}</button>
|
|
650
650
|
<button type="button" class="ghost" id="tplCopyAll" title="Copy the whole template to the clipboard" aria-label="Copy the whole template">${Te()}</button>
|
|
651
651
|
</div>
|
|
652
652
|
<div class="set-tpl-required" aria-label="Required variables">
|
|
@@ -663,7 +663,7 @@
|
|
|
663
663
|
<div class="set-tpl-msgs" id="tplMsgs" hidden></div>
|
|
664
664
|
</div>
|
|
665
665
|
</div>
|
|
666
|
-
<div class="set-note">${
|
|
666
|
+
<div class="set-note">${D("info")}<span>Kestrel uses this one template for every post, starting from a sensible default. Saving a change while posts are scheduled applies it to their emails too, after you confirm, so nothing scheduled goes out on an older look; their content stays as it was. Sent emails are archived exactly as they went out and never change. Save and Discard are in the bar at the bottom of the page.</span></div>
|
|
667
667
|
</div>
|
|
668
668
|
|
|
669
669
|
<div class="set-card set-tpl-varcard">
|
|
@@ -672,16 +672,16 @@
|
|
|
672
672
|
<h3 class="set-tpl-vartitle">Variables</h3>
|
|
673
673
|
<p class="field-hint">Kestrel replaces these variables with real values when you send an email. Type a variable exactly as shown, or it renders as empty.</p>
|
|
674
674
|
</div>
|
|
675
|
-
<div class="set-tpl-vars-body">${
|
|
675
|
+
<div class="set-tpl-vars-body">${bm()}</div>
|
|
676
676
|
</div>
|
|
677
|
-
</div>`);let p=c("#tplEditor"),g=Li(c("#tplPreview"),()=>p.value,()=>l),h=c("#tplMsgs"),m=c("#tplTest"),y=c("#tplTestLbl"),E=()=>p.value!==d,R=c("#tplHl"),
|
|
677
|
+
</div>`);let p=c("#tplEditor"),g=Li(c("#tplPreview"),()=>p.value,()=>l,t),h=c("#tplMsgs"),m=c("#tplTest"),y=c("#tplTestLbl"),E=()=>p.value!==d,R=c("#tplHl"),O=c("code",R),H=c("#tplGutter"),I=()=>{let X=p.value;f(O,o`${cl(X)}\n`);let le="",me=X.split(`
|
|
678
678
|
`).length;for(let Pe=1;Pe<=me;Pe++)le+=`${Pe}
|
|
679
|
-
`;
|
|
680
|
-
`);let tt=c("#tplTestHint",me.el);tt.textContent="Pre-filled from your default test recipients (Settings).",tt.hidden=!1}Pe.onclick=()=>J(Pe,E()?"Saving\u2026":"Sending\u2026",async()=>{me.clearError();let{valid:tt,invalid:
|
|
681
|
-
`),me.error(As(ge.sent,ge.total,ge.not_sent));return}me.close(),
|
|
679
|
+
`;H.textContent=le},v=()=>{R.scrollTop=p.scrollTop,R.scrollLeft=p.scrollLeft,H.scrollTop=p.scrollTop};p.addEventListener("scroll",v);let w=c("#reqBody"),M=c("#reqUnsub"),V=()=>{w.className=`set-req-pill ${/\{\{\s*\.Post\.Body\s*\}\}/.test(p.value)?"ok":"bad"}`,M.className=`set-req-pill ${/\{\{\s*\.Email\.UnsubscribeURL\s*\}\}/.test(p.value)?"ok":"bad"}`},A=to.attach({onSave:P,onDiscard:S},t);function L(){I(),V(),v(),A.setDirty(E()),y.textContent=E()?"Save & send test":"Send test email",m.title=E()?"Saves your changes first, then sends: a test always reflects the saved template that will ship.":"Sends a sample post through the saved template so you can see it in a real inbox."}function q(X){if(!X.length){h.hidden=!0,f(h,o``);return}h.hidden=!1,h.className="set-tpl-msgs warn",f(h,o`${X.map(le=>o`<div>${le}${le===aa?o` ${Vn()}`:null}</div>`)}`)}function S(){p.value=d,q([]),g.repaint(),L()}async function _(){let X=p.value,le=await Ht(me=>C("/api/settings",{method:"PUT",json:me?{email_template:X,remake:me}:{email_template:X}}),Ql,t);return le?(d=le.settings.email_template,p.value=d,Z.appConfig={...s,settings:le.settings},g.repaint(),L(),{warnings:Array.isArray(le.warnings)?le.warnings:[],remade:le.remade||[]}):null}async function P(){try{let X=await _();if(!X)return;q(X.warnings),j(ln(X.warnings.length?"Template saved with warnings":"Template saved",X.remade))}catch(X){A.showError(ao(X))}}let $=X=>{let le=Ti[cm(X)?X:"signed"];p.value=le.html,q([]),g.repaint(),L()};p.addEventListener("input",()=>{g.repaint(),L()});let T=c("#tplExamplesBtn");T.onclick=()=>Xt(T,Object.entries(Ti).map(([X,le])=>({label:le.label,description:le.description,onClick:()=>$(X)})),t,{align:"start"});let G=c("#tplPreview");for(let X of B(".wtog-btn",n))X.onclick=()=>{for(let le of B(".wtog-btn",n))le.setAttribute("aria-pressed",String(le===X));G.classList.toggle("phone",X.dataset.width==="phone"),g.repaint()};let x=c("#tplEditorWrap"),K=c("#tplLineNums"),F=X=>{x.classList.toggle("show-lines",X),K.setAttribute("aria-pressed",String(X)),v()},ee=!1;try{ee=localStorage.getItem("kestrel.tpl.lineNums")==="1"}catch{}F(ee),K.onclick=()=>{ee=!ee,F(ee);try{localStorage.setItem("kestrel.tpl.lineNums",ee?"1":"0")}catch{}};let Le=c("#tplCopyAll");Le.onclick=()=>Hn(Le,p.value),m.onclick=()=>{let X=be(),le=!X&&E(),me=pe(o`<h3>Send a test email</h3><p class="hint">Delivers a sample post rendered through your <strong>saved</strong> template, so you can see it in a real inbox. One address per line.</p>${Es()}${le?o`<p class="hint" style="color:var(--warn-fg)"><strong>Unsaved changes:</strong> sending will save your template first, so the test reflects what will actually ship.</p>`:null}${X?null:o`<label for="tplTestTo">Recipients</label><textarea id="tplTestTo" rows="3" placeholder="you@example.com"></textarea><p class="hint" id="tplTestHint" hidden></p>`}<div class="actions"><button type="button" id="ttCancel">Cancel</button><button type="button" class="primary" id="ttGo">${le?"Save & send test":"Send test"}</button></div>`,t),Pe=c("#ttGo",me.el);if(c("#ttCancel",me.el).onclick=me.close,Pe.disabled=X,X){c("#ttCancel",me.el).focus();return}let Ae=c("#tplTestTo",me.el);if(Ae.focus(),u.length&&!Ae.value.trim()){Ae.value=u.join(`
|
|
680
|
+
`);let tt=c("#tplTestHint",me.el);tt.textContent="Pre-filled from your default test recipients (Settings).",tt.hidden=!1}Pe.onclick=()=>J(Pe,E()?"Saving\u2026":"Sending\u2026",async()=>{me.clearError();let{valid:tt,invalid:Pt}=Rs(Ae.value),nt=Cs(Pt);if(nt){me.error(nt,Ae);return}if(!tt.length){me.error("Enter at least one email address",Ae);return}if(E())try{let ge=await _();if(!ge){me.close();return}q(ge.warnings)}catch(ge){A.showError(ao(ge)),me.close();return}try{let ge=await C("/api/settings/template/test",{method:"POST",json:{to:tt}});if(ge.failed.length){Ae.value=ge.failed.join(`
|
|
681
|
+
`),me.error(As(ge.sent,ge.total,ge.not_sent));return}me.close(),j(qt(`Test sent to ${ge.sent} address${ge.sent===1?"":"es"}`))}catch(ge){me.error(ao(ge))}})},p.value=d,g.repaint(),L()}function oc(e){return o`
|
|
682
682
|
<section class="set-sec">
|
|
683
683
|
${we("email-template",Se("editable","Editable"),io(e.data.in_use))}
|
|
684
|
-
<p class="set-lede">The template controls the look and feel of the emails you send. Edit it on the Template page.${
|
|
684
|
+
<p class="set-lede">The template controls the look and feel of the emails you send. Edit it on the Template page.${an(e.data.in_use)}</p>
|
|
685
685
|
<div class="set-preview set-tpl-sample">
|
|
686
686
|
<div class="set-preview-bar">
|
|
687
687
|
<span class="set-preview-lbl">Sample email</span>
|
|
@@ -690,16 +690,16 @@
|
|
|
690
690
|
<iframe class="set-email-frame" id="tplPreview" title="Sample email preview" scrolling="no"></iframe>
|
|
691
691
|
</div>
|
|
692
692
|
<div class="row" style="margin-top:12px"><button type="button" id="tplEditLink">Edit template →</button></div>
|
|
693
|
-
</section>`}function
|
|
693
|
+
</section>`}function ic(e,t,n){let s=t.data.settings.email_template||"",i=Li(c("#tplPreview",e),()=>s,()=>({name:t.state.name||t.fromDisplay,tagline:t.state.tagline,logoUrl:t.state.logoUrl,address:t.state.address}),n);return c("#tplEditLink",e).onclick=()=>{location.hash="#/template"},{repaint:()=>i.repaint()}}var rc={chips:"recipChips",input:"recipInput",add:"recipAdd"};function ac(){return o`
|
|
694
694
|
<section class="set-sec">
|
|
695
695
|
${we("default-test-recipients",Se("editable","Editable"))}
|
|
696
696
|
<div class="set-card">
|
|
697
697
|
<div class="set-recip">
|
|
698
698
|
<p class="field-hint" style="margin:0">Pre-filled into <strong>Send test email</strong> so you can proof a post against your own inboxes before scheduling. These are your addresses, and they don’t go through the subscribe-and-confirm flow.</p>
|
|
699
|
-
${so(
|
|
699
|
+
${so(rc)}
|
|
700
700
|
</div>
|
|
701
701
|
</div>
|
|
702
|
-
</section>`}function
|
|
702
|
+
</section>`}function lc(e,t){return oo(e,t,{ids:rc,list:()=>t.state.recipients,empty:"No default recipients yet. Add one below."})}function gm(e,t){switch(e){case"cloudflare":return"Cloudflare Email, separate from your newsletter\u2019s provider";case"provider":return t==="none"?"Your email provider, once one is connected":`Your email provider (${no(t)})`;default:return"Local stand-in: nothing is delivered"}}var cc={finished:"went out",refused:"provider refusing",stuck:"in flight too long",wedged:"waiting to be resolved",missed:"missed fire time",no_receipts:"no receipts from the provider",import:"list imported",sandbox:"signup refused by the SES sandbox",not_sending:"email not going out",not_sending_held:"email not going out",test:"test"};function dc(e){return e.kind==="test"?"test notification":e.subject?`${e.subject} (${cc[e.kind]})`:cc[e.kind]}function Ci(e){let{last_sent:t,last_failure:n}=e;return n?o`<span class="set-pill danger">Not delivered</span> <span class="muted">${W(n.at)}, ${dc(n)}: ${n.error}</span>`:t?o`<span class="set-pill ok">${D("check")}Delivered</span> <span class="muted">${W(t.at)}, ${dc(t)}</span>`:o`<span class="muted">None yet</span>`}var uc={chips:"notifyChips",input:"notifyTo",add:"notifyAdd"};function pc(e){let t=e.data.deployment;return o`
|
|
703
703
|
<section class="set-sec">
|
|
704
704
|
${we("notifications",Se("editable","Editable"))}
|
|
705
705
|
<p class="set-lede">Kestrel emails you when a send goes out, and right away if a send runs into a problem.</p>
|
|
@@ -709,33 +709,33 @@
|
|
|
709
709
|
<label for="notifyTo">Send notifications to</label>
|
|
710
710
|
<p class="field-hint" style="margin:0">Each address gets every notification. Add whoever runs Kestrel for you, so they’re told too. Up to ${xs}.</p>
|
|
711
711
|
</div>
|
|
712
|
-
${so(
|
|
712
|
+
${so(uc)}
|
|
713
713
|
<div class="row"><button type="button" class="ghost" id="notifyTest">Send a test notification</button><span class="field-hint" id="notifyTestHint"></span></div>
|
|
714
714
|
</div>
|
|
715
715
|
<div class="set-kv" style="border-top:1px solid var(--line)">
|
|
716
|
-
<div class="set-kv-k">Sent through</div><div class="set-kv-v">${
|
|
716
|
+
<div class="set-kv-k">Sent through</div><div class="set-kv-v">${gm(t.notify_channel,t.provider)}</div>
|
|
717
717
|
<div class="set-kv-k">From address</div><div class="set-kv-v"><span class="mono">${t.notify_from}</span></div>
|
|
718
718
|
<div class="set-kv-k">Last notification</div><div class="set-kv-v" id="notifyStatus">${Ci(e.data.notification_status)}</div>
|
|
719
719
|
</div>
|
|
720
|
-
<div class="set-note">${
|
|
720
|
+
<div class="set-note">${D("readonly")}<span>The channel and its sender are set at deploy. ${t.notify_channel==="provider"?"Notifications go through your newsletter\u2019s own provider, so one about the provider refusing your account cannot reach you; Cloudflare\u2019s email avoids that. ":""}See the <a class="set-link" href="#/docs/notifications">setup guide</a>.</span></div>
|
|
721
721
|
</div>
|
|
722
|
-
</section>`}function
|
|
722
|
+
</section>`}function mc(e,t){let n=c("#notifyTest",e),s=c("#notifyTestHint",e),i=c("#notifyStatus",e),r=oo(e,t,{ids:uc,list:()=>t.state.notifyTo,empty:"No addresses yet, so Kestrel emails no one. Add yours below.",max:{count:xs,full:`Notifications go to at most ${xs} addresses. Remove one to add another.`}}),a=()=>{let l=t.saved().notifyTo,d=l.length===0?"Save an address to send a test.":t.state.notifyTo.join(`
|
|
723
723
|
`)!==l.join(`
|
|
724
|
-
`)?"Save first: the test goes to the saved addresses.":"";n.disabled=!!d,s.textContent=d};return n.onclick=()=>J(n,"Sending\u2026",async()=>{try{let l=await C("/api/settings/notifications/test",{method:"POST"}),d=l.to.filter(p=>!l.failed.some(g=>g.email===p));
|
|
725
|
-
<h3 class="set-rp-jhead" id="rpJourney-${e.id}">${
|
|
724
|
+
`)?"Save first: the test goes to the saved addresses.":"";n.disabled=!!d,s.textContent=d};return n.onclick=()=>J(n,"Sending\u2026",async()=>{try{let l=await C("/api/settings/notifications/test",{method:"POST"}),d=l.to.filter(p=>!l.failed.some(g=>g.email===p));j(l.channel==="fake"?`Test notification recorded for ${d.join(", ")} (local stand-in: nothing is delivered)`:`Test notification sent to ${d.join(", ")}`);let u=la(l.to,l.failed);f(i,Ci({last_sent:{kind:"test",subject:"",at:Date.now()},last_failure:u?{kind:"test",subject:"",at:Date.now(),error:u}:null}))}catch(l){f(i,Ci({last_sent:null,last_failure:{kind:"test",subject:"",at:Date.now(),error:ht(l)}}))}}),a(),{repaint:a,reset(){r.reset?.(),a()}}}var Wn={base:"app",path:"/subscribe"},lo={base:"app",path:"/confirm?token=\u2026"},Ai={base:"app",path:"/unsubscribe?token=\u2026"},Kn=[{id:"subscribe",label:"Subscribe",flow:"steps",states:[{id:"form",label:"Form",at:Wn},{id:"check-inbox",label:"Check your inbox",at:Wn},{id:"not-an-email",label:"Not an email",offPath:!0,at:Wn},{id:"not-open",label:"Not open yet",offPath:!0,at:Wn},{id:"paused",label:"Paused",offPath:!0,at:Wn}]},{id:"confirm",label:"Confirm",flow:"steps",states:[{id:"ready",label:"Ready",at:lo},{id:"confirmed",label:"Confirmed",at:lo},{id:"expired",label:"Expired",offPath:!0,at:lo},{id:"invalid",label:"Invalid link",offPath:!0,at:lo}]},{id:"unsubscribe",label:"Unsubscribe",flow:"steps",states:[{id:"ask",label:"Ask",at:Ai},{id:"done",label:"Unsubscribed",at:Ai},{id:"invalid",label:"Invalid link",offPath:!0,at:Ai}]},{id:"reading",label:"Reading",flow:"peers",states:[{id:"landing",label:"Landing page",at:{base:"app",path:"/"}},{id:"archive",label:"Archive",at:{base:"archive",path:""}},{id:"post",label:"Post page",at:{base:"archive",path:"/sample-post"}},{id:"landing-empty",label:"Landing, no posts yet",offPath:!0,at:{base:"app",path:"/"}},{id:"archive-empty",label:"Archive, no posts yet",offPath:!0,at:{base:"archive",path:""}},{id:"not-found",label:"Nothing here yet",offPath:!0,at:{base:"archive",path:"/\u2026"}},{id:"no-page",label:"No page here",offPath:!0,at:{base:"app",path:"/\u2026"}}]}];function fc(e,t){return`/api/reader-pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}var co="Shown with signups open; until they are, readers get no Subscribe link or form here.",vm={subscribe:{form:"Your subscribe page, where a reader enters their email address.","check-inbox":"What the reader is shown after pressing Subscribe, here, on your website before your first post, or on a form embedded on your site.","not-an-email":"When the email address a reader sent isn\u2019t one that can be mailed. The browser catches most mistakes first.","not-open":"Shown in place of the form until your email provider accepts your first email, such as a test.",paused:"Shown in place of the form while your email provider won\u2019t send for your account, as when SES pauses your sending."},confirm:{ready:"When a reader opens the link in your confirmation email.",confirmed:"After they confirm. They\u2019re on your list and get your next post.",expired:"When a reader opens a confirmation link that\u2019s too old. They can ask for a new one.",invalid:"When a confirmation link is broken, mistyped, or replaced by a newer one."},unsubscribe:{ask:"When a reader opens the unsubscribe link in one of your emails. A mail application with its own one-click Unsubscribe button skips this page and removes them right away.",done:"After they press Unsubscribe. They get no more of your emails.",invalid:"When an unsubscribe link is broken or mistyped."},reading:{landing:`What anyone sees when they visit your newsletter\u2019s website. The posts are samples. ${co}`,archive:`Every post in your archive. These are samples. ${co}`,post:"The web version of a post that went out. Readers reach it from View in browser in its email, or from your archive.","landing-empty":`Your newsletter\u2019s website before your first post goes out. ${co}`,"archive-empty":`Your archive before your first post goes out. ${co}`,"not-found":"When a reader follows a link to a post that isn\u2019t there, or isn\u2019t out yet.","no-page":"When a reader opens any other address with no page, such as a mistyped link."}};function bc(e,t){return vm[e.id][t.id]??""}var ym={subscribe:"mail",confirm:"circle-check",unsubscribe:"circle-minus",reading:"book"},Sm=o`<span class="set-rp-dot"></span>`;function hc(e,t,n){return o`<li><button type="button" class="set-rp-item${t.offPath?" off":""}" data-journey="${e.id}" data-state="${t.id}" aria-current="false" title="${bc(e,t)}"><span class="set-rp-mark" aria-hidden="true">${n}</span>${t.label}</button></li>`}function wm(){return o`${Kn.map(e=>{let t=e.states,n=e.flow==="steps";return o`<div class="set-rp-journey" data-journey="${e.id}">
|
|
725
|
+
<h3 class="set-rp-jhead" id="rpJourney-${e.id}">${D(ym[e.id])}${e.label}</h3>
|
|
726
726
|
<ul class="set-rp-list${n?" steps":""}" aria-labelledby="rpJourney-${e.id}">
|
|
727
|
-
${t.filter(s=>!s.offPath).map((s,i)=>
|
|
727
|
+
${t.filter(s=>!s.offPath).map((s,i)=>hc(e,s,n?String(i+1):Sm))}
|
|
728
728
|
</ul>
|
|
729
729
|
<ul class="set-rp-list" aria-label="${e.label}, off the main path">
|
|
730
|
-
${t.filter(s=>s.offPath).map(s=>
|
|
730
|
+
${t.filter(s=>s.offPath).map(s=>hc(e,s,D("branch")))}
|
|
731
731
|
</ul>
|
|
732
|
-
</div>`})}`}function
|
|
732
|
+
</div>`})}`}function $m(){return o`<select id="rpSelect" aria-label="Reader page">${Kn.map(e=>{let t=e.states,n=0;return o`<optgroup label="${e.label}">${t.map(s=>{let i=e.flow==="steps"&&!s.offPath?`${++n}. `:"";return o`<option value="${e.id}/${s.id}">${i}${s.label}</option>`})}</optgroup>`})}</select>`}function gc(e){return o`
|
|
733
733
|
<section class="set-sec set-rp-sec" id="readerPages">
|
|
734
734
|
${e}
|
|
735
735
|
<p class="set-lede">Every page a reader can land on, exactly as they see it, with your publication’s identity and sample values. Nothing here changes a page; it shows the ones that are hard to reach by hand.</p>
|
|
736
736
|
<div class="set-card set-rp">
|
|
737
|
-
<nav class="set-rp-nav" aria-label="Reader pages">${
|
|
738
|
-
<div class="set-rp-pick">${
|
|
737
|
+
<nav class="set-rp-nav" aria-label="Reader pages">${wm()}</nav>
|
|
738
|
+
<div class="set-rp-pick">${$m()}</div>
|
|
739
739
|
<div class="set-rp-main">
|
|
740
740
|
<div class="set-rp-top">
|
|
741
741
|
<div>
|
|
@@ -743,8 +743,8 @@
|
|
|
743
743
|
<p class="set-rp-note" id="rpNote"></p>
|
|
744
744
|
</div>
|
|
745
745
|
<span class="set-wtog" id="rpWidth" role="group" aria-label="Preview width">
|
|
746
|
-
<button type="button" class="wtog-btn" data-width="desktop" aria-pressed="true">${
|
|
747
|
-
<button type="button" class="wtog-btn" data-width="phone" aria-pressed="false">${
|
|
746
|
+
<button type="button" class="wtog-btn" data-width="desktop" aria-pressed="true">${D("desktop")}Desktop</button>
|
|
747
|
+
<button type="button" class="wtog-btn" data-width="phone" aria-pressed="false">${D("phone")}Phone</button>
|
|
748
748
|
</span>
|
|
749
749
|
</div>
|
|
750
750
|
<div class="set-rp-at"><span class="mono" id="rpAt"></span><span>Sample · links and forms do nothing</span></div>
|
|
@@ -754,7 +754,7 @@
|
|
|
754
754
|
</div>
|
|
755
755
|
</div>
|
|
756
756
|
</div>
|
|
757
|
-
</section>`}function
|
|
757
|
+
</section>`}function Em(e,t){return`${e.base==="app"?t.app_origin:`${t.archive_origin}${t.archive_base_path}`}${e.path}`.replace(/^https?:\/\//,"")}function vc(e,t,n){let s=c(".set-rp-nav",e),i=c("#rpSelect",e),r=c("#rpWidth",e),a=c("#rpStage",e),l=c("#rpFrame",e),d=c("#rpError",e),u=Kn[0],p=u.states[0],g="desktop",h=0,m=null;it(n,()=>m?.disconnect());let y=()=>{for(let H of B(".set-rp-item",s)){let I=H.dataset.journey===u.id&&H.dataset.state===p.id;H.setAttribute("aria-current",I?"true":"false")}for(let H of B(".set-rp-journey",s))H.classList.toggle("current",H.dataset.journey===u.id);i.value=`${u.id}/${p.id}`,c("#rpJourney",e).textContent=u.label,c("#rpState",e).textContent=p.label,c("#rpNote",e).textContent=bc(u,p),c("#rpAt",e).textContent=Em(p.at,t)},E=()=>{let H=l.contentDocument?.body?.scrollHeight;H&&(l.style.height=`${H}px`)},R=async()=>{let H=++h;try{let I=await Ut(fc(u.id,p.id),{signal:n});if(H!==h||n.aborted)return;d.hidden=!0,a.hidden=!1,l.srcdoc=Ks(I)}catch(I){if(H!==h||n.aborted)return;l.srcdoc="",a.hidden=!0,d.textContent=`Couldn\u2019t load this page: ${z(I)}`,d.hidden=!1}},O=(H,I)=>{let v=Kn.find(V=>V.id===H),M=(v?.states??[]).find(V=>V.id===I);!v||!M||v===u&&M===p||(u=v,p=M,y(),R())};return l.onload=()=>{let H=l.contentDocument;!H||n.aborted||(H.addEventListener("click",I=>{I.target?.closest?.("a[href], area[href]")&&I.preventDefault()}),m?.disconnect(),E(),H.body&&typeof ResizeObserver<"u"&&(m=new ResizeObserver(E),m.observe(H.body)))},s.addEventListener("click",H=>{let I=H.target.closest(".set-rp-item");O(I?.dataset.journey,I?.dataset.state)}),i.addEventListener("change",()=>{let[H,I]=i.value.split("/");O(H,I)}),r.addEventListener("click",H=>{let v=H.target.closest("button[data-width]")?.dataset.width;if(!(v!=="desktop"&&v!=="phone"||v===g)){g=v;for(let w of B("button",r))w.setAttribute("aria-pressed",String(w.dataset.width===v));a.classList.toggle("phone",v==="phone")}}),y(),R(),{refresh:()=>{R()}}}function Sc(e){return e?`Subscribe to ${e}`:"Subscribe"}function xm(e,t,n){let s=te(Sc(t)),i=`${te(n)}/subscribe`;return e==="styled"?`<form action="${i}" method="post" style="max-width:460px;font:16px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif">
|
|
758
758
|
<div style="font:600 22px/1.2 Georgia,'Times New Roman',serif;letter-spacing:-0.01em;margin-bottom:12px">${s}</div>
|
|
759
759
|
<div style="display:flex;gap:10px;flex-wrap:wrap">
|
|
760
760
|
<input type="email" name="email" required placeholder="you@example.com" aria-label="Email address" style="flex:1 1 220px;padding:11px 13px;border:1px solid #d6d3cc;border-radius:9px;background:#fff;color:#1b1a17;font:inherit">
|
|
@@ -767,14 +767,14 @@
|
|
|
767
767
|
<input type="email" name="email" placeholder="you@example.com" required>
|
|
768
768
|
</label>
|
|
769
769
|
<button type="submit">Subscribe</button>
|
|
770
|
-
</form>`}function
|
|
770
|
+
</form>`}function km(e,t){let n=Sc(t);return e==="styled"?o`<form class="set-pf-styled"><span class="l">${n}</span><div class="rowf"><input type="email" placeholder="you@example.com" disabled><button type="button" class="sub-btn" tabindex="-1">Subscribe</button></div><p class="set-pf-fine">We’ll email you a link to confirm. Unsubscribe anytime.</p></form>`:o`<form class="set-pf-plain"><label>${n} <input type="email" placeholder="you@example.com" disabled></label> <button type="button" tabindex="-1">Subscribe</button></form>`}function wc(e){return e.data.deployment.app_origin||location.origin}function _m(e){return e?"A public page with your publication\u2019s name and a sign-up form ready to go.":"A public page with a sign-up form ready to go."}function yc(e,t,n,s,i=null){return o`<div class="set-way"><div class="set-way-head"><div class="set-way-name"><h3 class="set-way-title">${D(e)}${t}</h3><p class="set-way-line">${n}</p></div>${i}</div>${s}</div>`}function $c(e){let t=`${wc(e)}/subscribe`;return o`
|
|
771
771
|
<section class="set-sec set-sec-subscribe">
|
|
772
772
|
${we("ways-to-subscribe",Se("copyout","Copy-out"))}
|
|
773
773
|
<p class="set-lede">Two ways for readers to join your list. Either way, a reader is added only once they confirm by email.</p>
|
|
774
774
|
${e.data.deployment.provider==="none"?o`<div class="health amber set-sub-not-connected" role="status"><span class="health-dot">⚠️</span><div><span>No email provider connected, so signups aren’t open yet: the page below says so, and the form takes no address. ${He()} to open signups.</span></div></div>`:null}
|
|
775
775
|
<div class="set-card">
|
|
776
|
-
${
|
|
777
|
-
${
|
|
776
|
+
${yc("link","Share the page",o`<span id="subscribePageLine"></span>`,o`<div class="set-way-body set-way-addr"><code class="set-addr">${t}</code>${An(t,"Copy the subscribe page\u2019s address")}<a class="ghost-link" href="${t}" target="_blank" rel="noopener">Open ↗</a></div>`)}
|
|
777
|
+
${yc("code","Embed a form",o`Put a sign-up form on another site you own.`,o`<div class="set-embed">
|
|
778
778
|
<div class="set-embed-preview" id="embedPreview"></div>
|
|
779
779
|
<pre class="set-embed-code"><code id="embedCode"></code></pre>
|
|
780
780
|
</div>
|
|
@@ -783,18 +783,18 @@
|
|
|
783
783
|
<button type="button" class="wtog-btn" data-embed="plain" aria-pressed="false">Plain</button>
|
|
784
784
|
</span>`)}
|
|
785
785
|
</div>
|
|
786
|
-
</section>`}function
|
|
787
|
-
${
|
|
788
|
-
${
|
|
789
|
-
${
|
|
790
|
-
${
|
|
791
|
-
${
|
|
792
|
-
`),m.push(
|
|
786
|
+
</section>`}function Tm(e,t){return o`<button type="button" class="secondary set-embed-copy" data-copy="${t}" data-copy-word="Copy HTML" aria-label="Copy HTML, ${e==="styled"?"Styled":"Plain"} form">${Te(!1,"Copy HTML")}</button>`}function Ec(e,t){let n=wc(t),s=c("#embedCode",e),i=c("#embedCopy",e),r=c("#embedPreview",e),a=c("#subscribePageLine",e),l="styled",d=()=>t.state.name||t.fromDisplay,u=()=>{let h=xm(l,d(),n);s.textContent=h,f(i,Tm(l,h)),f(r,km(l,d())),a.textContent=_m(d())},p=B("[data-embed]",e);for(let h of p)h.onclick=()=>{l=h.dataset.embed==="styled"?"styled":"plain";for(let m of p)m.setAttribute("aria-pressed",String(m.dataset.embed===l));u()};je(c(".set-sec-subscribe",e)),u();let g=d();return{repaint(){d()!==g&&(g=d(),u())}}}function Gn(e,t){return o`<div class="set-group" data-group="${e}">${t}</div>`}function Hi(e){return{name:e.name,tagline:e.tagline,address:e.address,recipients:[...e.recipients],confirmation:{...e.confirmation},notifyTo:[...e.notifyTo]}}var xc=(e,t)=>e.length===t.length&&e.every((n,s)=>n===t[s]),Lm=(e,t)=>e.subject===t.subject&&e.body===t.body&&e.button_label===t.button_label&&e.reassurance===t.reassurance;async function Pi(e,t,n){ie(t,"Settings"),f(e,o`<div class="settings"><div class="page-head"><h1>Settings</h1><p class="set-lede set-page-lede">Your publication’s identity, the ways readers subscribe and the pages they land on, the email each post is sent inside, and where Kestrel tells you about your sends. Facts set when Kestrel was deployed come last, read-only.</p></div><div id="settingsBody" class="muted">Loading…</div></div>`);let s=c("#settingsBody",e),i;try{i=await C("/api/settings",{signal:t})}catch(L){re(s,ht(L),()=>ne((q,S)=>Pi(q,S,n)));return}let r=await ut(i.deployment,t),a=i.settings,l=a.publication,d=a.confirmation_email,u={name:l.name||"",tagline:l.tagline||"",address:l.address||"",logoUrl:l.logo_url||"",recipients:[...a.test_recipients||[]],confirmation:{subject:d.subject||"",body:d.body||"",button_label:d.button_label||"",reassurance:d.reassurance||""},notifyTo:[...a.notifications.to]},p=Hi(u),g=Po(i.deployment.from_address),h=()=>u.name!==p.name||u.tagline!==p.tagline||u.address!==p.address||!xc(u.recipients,p.recipients)||!Lm(u.confirmation,p.confirmation)||!xc(u.notifyTo,p.notifyTo),m=[],y=to.attach({onSave:v,onDiscard:w},t),E=()=>{},R={data:i,provider:r,state:u,saved:()=>p,fromDisplay:g,fromName:g||"Your publication",changed(){for(let L of m)L.repaint?.();y.setDirty(h())},applySaved(L){Z.appConfig={...i,settings:L},ms(),E()}};f(s,o`
|
|
787
|
+
${Gn("publication",[nc(R)])}
|
|
788
|
+
${Gn("readers",[$c(R),zl(R),gc(we("reader-pages",Se("preview","Preview")))])}
|
|
789
|
+
${Gn("emails",[oc(R),ac()])}
|
|
790
|
+
${Gn("you",[pc(R)])}
|
|
791
|
+
${Gn("deploy",[Zl(R),Jl(R)])}
|
|
792
|
+
`),m.push(sc(s,R,t),Ec(s,R),Yl(s,R),ic(s,R,t),lc(s,R),mc(s,R)),ro(s,i.in_use,t),E=vc(s,i.deployment,t).refresh;let H=null,I=()=>{H?.(),H=null};async function v(){I();try{let L={publication:{name:u.name,tagline:u.tagline,address:u.address},test_recipients:u.recipients,confirmation_email:u.confirmation,notifications:{to:u.notifyTo}},q=await Ht(_=>C("/api/settings",{method:"PUT",json:_?{...L,remake:_}:L}),jn("Save","Saving"),t);if(!q)return;let S=q.settings;u.name=S.publication.name,u.tagline=S.publication.tagline,u.address=S.publication.address,u.recipients=[...S.test_recipients],u.confirmation={...S.confirmation_email},u.notifyTo=[...S.notifications.to],p=Hi(u);for(let _ of m)_.reset?.();R.applySaved(S),R.changed(),j(ln("Settings saved",q.remade))}catch(L){let q=L instanceof se?Cm(e,L.field):null;q&&L instanceof se?(H=Fe(q,ht(L)),q.focus(),y.showError("Not saved: fix the field marked above.")):y.showError(ht(L))}}function w(){I(),Object.assign(u,Hi(p));for(let L of m)L.reset?.();R.changed()}R.changed();let M=()=>{},V=L=>{M(),Fo(L)?M=Gl(c(`#${xi(L)}`,e),e,t):(M=()=>{},window.scrollTo(0,0))};Fo(n)&&V(n);let A=L=>{let[,q,S]=L.split("/");return q!=="settings"||!yn(L.slice(1))?!1:(V(S),!0)};return s.addEventListener("click",L=>{let q=L.target instanceof Element?L.target.closest(".set-sec-link"):null;!(L.metaKey||L.ctrlKey||L.shiftKey||L.altKey)&&q?.getAttribute("href")===location.hash&&A(location.hash)},{signal:t}),{navigate:A}}var Rm={"publication.name":"#setName","publication.tagline":"#setTagline","publication.address":"#setAddress",test_recipients:"#recipInput","notifications.to":"#notifyTo","confirmation_email.subject":"#ceSubject","confirmation_email.body":"#ceMessage","confirmation_email.button_label":"#ceButton","confirmation_email.reassurance":"#ceFooter"};function Cm(e,t){let n=t?Rm[t]:void 0,s=n?e.querySelector(n):null;return(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&!s.closest("[hidden]")?s:null}var Am="kestrel-subscribers/1",zn="kestrel-subscribers/2",Hm=[Am,zn],Pm=["subscribed","pending","unsubscribed","none"],Ii=["double","single","unknown"],Im=["bounce","manual"];var Mm=["reader","publisher","complaint","erased"],kc=["subscribed","unsubscribed","bounced"],Nm={maxRows:1e4,maxRowsFree:1e3,maxBodyBytes:10*1024*1024,maxEvidenceBytes:500};var _c=[{name:"email",required:!0,values:null,takes:"an email address; trimmed and lowercased before it is matched",meaning:"The address. An invalid one is still a row, counted as invalid and reported, never dropped."},{name:"status",required:!0,values:Pm,takes:"one of the values",meaning:"The consent claim. `none` is a known address with no consent claim, present only to carry a suppression."},{name:"opt_in",required:!0,values:Ii,takes:"one of the values",meaning:"How consent was collected. `unknown` unless the source states it."},{name:"origin",required:!0,values:null,takes:"a short lowercase name (letters, digits, `.`, `_`, `-`, up to 40): `sendy`, `mailchimp`, `kestrel`, `unknown`",meaning:"Where consent was first collected, as the file claims it."},{name:"unsubscribe_cause",required:!1,values:Mm,takes:"one of the values, or empty; only on an `unsubscribed` row",meaning:"Why the person left: their own unsubscribe (`reader`), the publisher on their request (`publisher`), a complaint about the mail (`complaint`), or an erasure at their request (`erased`), which is recorded with the address alone. Empty when the source doesn\u2019t say, recorded as having left elsewhere. Version 2 only."},{name:"suppression",required:!1,values:Im,takes:"one of the values, or empty",meaning:"A suppression on top of `status`, the sender\u2019s side: the address bounced, or was blocked by hand. In version 1 it also took `complaint`, read as an `unsubscribed` row whose cause is `complaint`, and `erased`, read as one whose cause is `erased`."},{name:"subscribed_at",required:!1,values:null,takes:"a UTC ISO-8601 instant with its zone (`2024-03-01T09:30:00Z`), or empty",meaning:"When the person subscribed, if the source states it."},{name:"confirmed_at",required:!1,values:null,takes:"an instant with its zone, or empty",meaning:"When the person confirmed, if the source states it."},{name:"unsubscribed_at",required:!1,values:null,takes:"an instant with its zone, or empty",meaning:"When the person left, if the source states it. A reader who confirmed here after it stays confirmed."},{name:"suppressed_at",required:!1,values:null,takes:"an instant with its zone, or empty",meaning:"When the address was suppressed, if the source states it."},{name:"evidence",required:!1,values:null,takes:`a JSON object of at most ${Nm.maxEvidenceBytes} bytes, or empty`,meaning:"The source\u2019s consent-relevant columns, verbatim (a signup IP, a form name, a confirmation time). Nothing reads it to decide anything: it is the proof of consent and the audit trail of a conversion."},{name:"format",required:!1,values:Hm,takes:"the format\u2019s name and version, or empty",meaning:"The version the row is written in. A row without it may use either version\u2019s values, which every version reads alike; a version this release doesn\u2019t know is refused by name."}],B$=new Set(_c.map(e=>e.name));var Om=/^[=+\-@\t\r]/;function Dm(e){return Om.test(e)?`'${e}`:e}function Bm(e){let t=Dm(e);return/[",\r\n]/.test(t)||t!==t.trim()?`"${t.replace(/"/g,'""')}"`:t}function Mi(e){return`${e.map(t=>t.map(Bm).join(",")).join(`\r
|
|
793
793
|
`)}\r
|
|
794
|
-
`}function Ni(e){let t=
|
|
794
|
+
`}function Ni(e){let t=_c.map(n=>n.name);return Mi([t,...e.map(n=>t.map(s=>n[s]??""))])}var Oi=[{email:"ada@example.com",status:"subscribed",opt_in:"double",origin:"sendy",unsubscribe_cause:null,suppression:null,subscribed_at:"2024-03-01T09:30:00Z",confirmed_at:"2024-03-01T09:42:00Z",unsubscribed_at:null,suppressed_at:null,evidence:'{"signup_ip":"203.0.113.7","list":"Field Notes"}',format:zn},{email:"grace@example.com",status:"subscribed",opt_in:"single",origin:"mailchimp",unsubscribe_cause:null,suppression:null,subscribed_at:"2023-11-12T16:05:00Z",confirmed_at:null,unsubscribed_at:null,suppressed_at:null,evidence:null,format:zn},{email:"edsger@example.com",status:"unsubscribed",opt_in:"unknown",origin:"unknown",unsubscribe_cause:"reader",suppression:null,subscribed_at:null,confirmed_at:null,unsubscribed_at:"2025-01-20T08:00:00Z",suppressed_at:null,evidence:null,format:zn},{email:"bounced@example.com",status:"none",opt_in:"unknown",origin:"unknown",unsubscribe_cause:null,suppression:"bounce",subscribed_at:null,confirmed_at:null,unsubscribed_at:null,suppressed_at:"2025-02-02T12:00:00Z",evidence:null,format:zn}],U$=Ni(Oi),Di=`ada@example.com\r
|
|
795
795
|
grace@example.com\r
|
|
796
796
|
linus@example.com\r
|
|
797
|
-
`,
|
|
797
|
+
`,Tc="kestrel-import-example.csv",Bi="kestrel-import-example.txt";var Um={buttondown:"Buttondown",convertkit:"ConvertKit",kit:"Kit",kestrel:"Kestrel",mailchimp:"Mailchimp",mailerlite:"MailerLite",sendy:"Sendy",substack:"Substack",beehiiv:"beehiiv",ghost:"Ghost"};function Yn(e){return e===null||e===""||e==="unknown"?null:Um[e]??e.charAt(0).toUpperCase()+e.slice(1)}function Zn(e){return e===null||e==="unknown"?"opt-in unknown":`${e} opt-in`}function Lc(e){return e.import_id!==null?`Imported \xB7 ${[Yn(e.origin),Zn(e.opt_in)].filter(Boolean).join(", ")}`:e.confirmed_at!==null?"Double opt-in":null}function Rc(e){if(!e)return null;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function uo(e){return e.principal.kind==="service"?"a service token":on(e.principal.email,e.principal.client)??"you"}var Cc=(e,t,n)=>`${e.toLocaleString("en-US")} ${e===1?t:n}`,Fm=[{outcome:"added_confirmed",one:"address added as a confirmed subscriber",many:"addresses added as confirmed subscribers"},{outcome:"confirmed_pending",one:"pending subscriber here confirmed",many:"pending subscribers here confirmed"},{outcome:"unsubscribed",one:"subscriber here unsubscribed",many:"subscribers here unsubscribed"},{outcome:"erased",one:"subscriber here erased, as the file says: only the address is kept, and past sends show an erased recipient",many:"subscribers here erased, as the file says: only their addresses are kept, and past sends show an erased recipient"},{outcome:"added_unsubscribed",one:"address recorded as having left (unsubscribed), so the list remembers them",many:"addresses recorded as having left (unsubscribed), so the list remembers them"},{outcome:"suppressed",one:"address suppressed as the file says (bounced or blocked), so it\u2019s never mailed",many:"addresses suppressed as the file says (bounced or blocked), so they\u2019re never mailed"},{outcome:"unchanged",one:"address already here as the file says, so it\u2019s unchanged",many:"addresses already here as the file says, so they\u2019re unchanged"},{outcome:"left_out",one:"row still pending, or with no status, left out, since an import sends no email",many:"rows still pending, or with no status, left out, since an import sends no email"},{outcome:"invalid",one:"row isn\u2019t a valid address",many:"rows aren\u2019t valid addresses"},{outcome:"merged",one:"row repeats an address earlier in the file, and is folded into it",many:"rows repeat an address earlier in the file, and are folded into it"},{outcome:"kept_suppressed",one:"address is suppressed here, so it isn\u2019t imported",many:"addresses are suppressed here, so they aren\u2019t imported",kept:!0},{outcome:"kept_unsubscribed",one:"reader unsubscribed here, and stays unsubscribed",many:"readers unsubscribed here, and stay unsubscribed",kept:!0},{outcome:"kept_confirmed_newer",one:"reader confirmed here after the file says they left, and stays confirmed",many:"readers confirmed here after the file says they left, and stay confirmed",kept:!0}];function Ui(e){return Fm.filter(t=>e[t.outcome]>0).map(t=>({outcome:t.outcome,count:e[t.outcome],text:Cc(e[t.outcome],t.one,t.many),kept:t.kept===!0}))}function Ac(e){return e.added_confirmed+e.confirmed_pending}function Fi(e,t){let n=t-e.suppressed;return n>0?`${Cc(n,"of the addresses above also gains","of the addresses above also gain")} a suppression, so ${n===1?"it\u2019s":"they\u2019re"} never mailed.`:null}function Hc(e){let t=Ii.filter(s=>(e.opt_in[s]??0)>0).map(s=>`${e.opt_in[s].toLocaleString("en-US")} ${Zn(s)}`).join(", "),n=Object.entries(e.origin).filter(([,s])=>s>0).sort((s,i)=>i[1]-s[1]||s[0].localeCompare(i[0])).map(([s,i])=>`${Yn(s)??"unknown"} ${i.toLocaleString("en-US")}`).join(", ");return{optIn:t,origin:n}}var cn={added_confirmed:"Imported as subscribed",confirmed_pending:"Imported as subscribed",unsubscribed:"Unsubscribed",erased:"Erased",added_unsubscribed:"Recorded as having left",suppressed:"Suppressed",unchanged:"Unchanged",left_out:"Left out",invalid:"Invalid",merged:"Folded into an earlier row",kept_suppressed:"Already suppressed here",kept_unsubscribed:"Kept unsubscribed",kept_confirmed_newer:"Kept confirmed"};function Pc(e,t,n){let s=new Map(e.map(a=>[a.row,a])),i=new Map(t.map(a=>[a.row,a])),r=new Map;for(let a of new Set([...s.keys(),...i.keys()])){let l=s.get(a),d=i.get(a),u=l?cn[l.outcome]:cn.added_confirmed,p=d?cn[d.outcome]:cn.added_confirmed;u!==p&&r.set(a,{row:a,email:(d??l)?.email??"",planned:u,applied:p})}for(let a of n){let l=cn[a.planned],d=cn[a.applied];!r.has(a.row)&&l!==d&&r.set(a.row,{row:a.row,email:a.email,planned:l,applied:d})}return[...r.values()].sort((a,l)=>a.row-l.row)}function Ic(e){return Mi([["row","email","outcome","suppression_added"],...e.map(t=>[String(t.row),t.email,t.outcome,t.suppression_added?"yes":"no"])])}var Mc="Please import my Sendy subscribers from ~/Downloads/sendy-export.csv into the newsletter.",qm="Your list or its scheduled posts changed since this plan, so here is the plan again as things stand now. Review it, then import.",qi=["email","status","opt_in","origin","subscribed_at"],jm={subscribed:"Subscribed",unsubscribed:"Unsubscribed",bounced:"Bounced"};async function Vi(e,t){ie(t,"Import subscribers"),f(e,o`<div class="imp">
|
|
798
798
|
<div class="editor-head"><a href="#/subscribers" class="back">← Subscribers</a></div>
|
|
799
799
|
<div class="page-head"><h1>Import subscribers</h1><p class="set-lede" id="impLede">Nothing changes until you review what will happen and confirm.</p></div>
|
|
800
800
|
<div id="impBody" class="muted">Loading…</div>
|
|
@@ -814,102 +814,102 @@ linus@example.com\r
|
|
|
814
814
|
${u()}
|
|
815
815
|
</section>
|
|
816
816
|
<div class="imp-drop" id="impDrop">
|
|
817
|
-
${
|
|
817
|
+
${D("upload")}
|
|
818
818
|
<p class="imp-drop-line">Drop your file here, or</p>
|
|
819
819
|
<button type="button" class="primary" id="impChoose" aria-describedby="impLimit${v?" impFileError":""}">Choose file</button>
|
|
820
820
|
<p class="field-hint" id="impLimit">CSV or .txt, up to ${w} rows.${i.limits.max_rows_reason?o` ${i.limits.max_rows_reason}`:null}</p>
|
|
821
821
|
</div>
|
|
822
822
|
${v?o`<div class="imp-file-error"><div class="field-error" id="impFileError" role="alert"><span class="field-error-ico" aria-hidden="true">!</span><span>${v}</span></div>
|
|
823
|
-
<p class="imp-text">Exported from another service? Claude can convert it for you. Ask Claude Code:</p>${u()}</div>`:null}`);for(let
|
|
824
|
-
<div class="table-wrap"><table class="imp-sample"><thead><tr>${qi.map(
|
|
825
|
-
<tbody>${v.map(
|
|
826
|
-
<p class="field-hint">Optional columns: ${w.map((
|
|
823
|
+
<p class="imp-text">Exported from another service? Claude can convert it for you. Ask Claude Code:</p>${u()}</div>`:null}`);for(let V of B("[data-sample]",n))V.onclick=()=>{r=V.dataset.sample==="plain"?"plain":"full";for(let A of B("[data-sample]",n))A.setAttribute("aria-pressed",String(A.dataset.sample===r));f(c("#impSample",n),r==="full"?l():d()),p()};p(),c("#impChoose",n).onclick=()=>s.click();let M=c("#impDrop",n);M.addEventListener("dragover",V=>{V.preventDefault(),M.classList.add("over")}),M.addEventListener("dragleave",()=>M.classList.remove("over")),M.addEventListener("drop",V=>{V.preventDefault(),M.classList.remove("over");let A=V.dataTransfer?.files[0];A&&g(A)})}function l(){let v=Oi.slice(0,3),w=i.columns.filter(M=>!M.required&&!qi.includes(M.name)).map(M=>M.name);return o`<p class="imp-text">A CSV with a header row, one row per address. A row says what your old service recorded about each person; Kestrel decides what that means here.</p>
|
|
824
|
+
<div class="table-wrap"><table class="imp-sample"><thead><tr>${qi.map(M=>o`<th><code>${M}</code></th>`)}</tr></thead>
|
|
825
|
+
<tbody>${v.map(M=>o`<tr>${qi.map(V=>o`<td>${M[V]??""}</td>`)}</tr>`)}</tbody></table></div>
|
|
826
|
+
<p class="field-hint">Optional columns: ${w.map((M,V)=>o`${V?", ":""}<code>${M}</code>`)}.</p>
|
|
827
827
|
<div class="row imp-links"><button type="button" class="ghost" data-template="csv">Download example file (CSV)</button><a class="ghost-link" href="#/docs/your-list/the-file-format">Import format reference →</a></div>`}function d(){return o`<p class="imp-text">A <code>.txt</code> file with one address per line.</p>
|
|
828
|
-
${
|
|
828
|
+
${tn(Bi,o`${Di.replace(/\r\n/g,`
|
|
829
829
|
`).trim()}`,Di)}
|
|
830
830
|
<p class="imp-text">Next you’ll say what they are: subscribed (the default), unsubscribed, or bounced.</p>
|
|
831
|
-
<div class="row imp-links"><button type="button" class="ghost" data-template="txt">Download example file (.txt)</button></div>`}function u(){return
|
|
831
|
+
<div class="row imp-links"><button type="button" class="ghost" data-template="txt">Download example file (.txt)</button></div>`}function u(){return tn("Prompt for Claude Code",o`${Mc}`,Mc)}function p(){for(let v of B("[data-template]",n))v.onclick=()=>J(v,null,async()=>{let w=v.dataset.template==="txt"?"txt":"csv";try{let M=await ps(`/api/imports/template.${w}`);At(M.text,M.filename??(w==="txt"?Bi:Tc),w==="txt"?"text/plain":"text/csv")}catch(M){j(z(M))}})}s.onchange=()=>{let v=s.files?.[0];s.value="",v&&g(v)};async function g(v){let w=await v.text();if(t.aborted)return;let M={name:v.name,text:w},V=Vm(M)?i.plain_list.default:null,A=n.querySelector("#impChoose, #impReplace"),L=await(A?J(A,"Reading\u2026",()=>h(M,V)):h(M,V));L!==null&&(m(L,M),c(".imp-file",n).focus())}async function h(v,w){try{return await C("/api/imports/plan",{method:"POST",json:w===null?{file:v}:{file:v,plain_list_status:w},signal:t})}catch(M){return t.aborted||(a(z(M)),c("#impChoose",n).focus()),null}}function m(v,w,M){let V=Ac(v.counts),A=Ui(v.counts),L=Hc(v.confirmed),q=Fi(v.counts,v.suppressions_added),S=v.rows.length,_=v.file.kind==="txt"?"Plain list (.txt)":`CSV, ${i.format}`;f(n,o`<section class="card imp-card imp-file" tabindex="-1" aria-label="The file chosen and its plan">
|
|
832
832
|
<div class="imp-file-row">
|
|
833
|
-
<div><strong class="imp-file-name">${v.file.name}</strong><div class="muted">${
|
|
833
|
+
<div><strong class="imp-file-name">${v.file.name}</strong><div class="muted">${_} · ${ji(v.file.rows)} · ${Wm(v.file.addresses)}</div></div>
|
|
834
834
|
<button type="button" class="ghost" id="impReplace">Replace file</button>
|
|
835
835
|
</div>
|
|
836
836
|
${v.file.kind==="txt"?y(v.file.plain_list_status??i.plain_list.default):null}
|
|
837
837
|
</section>
|
|
838
838
|
<section class="card imp-card">
|
|
839
839
|
<h2>What will happen</h2>
|
|
840
|
-
${
|
|
841
|
-
${
|
|
840
|
+
${Oc(A,L,V)}
|
|
841
|
+
${q?o`<p class="imp-text">${q}</p>`:null}
|
|
842
842
|
${S>0?o`<div class="row imp-links"><button type="button" class="ghost" id="impNotImported">Download the ${ji(S)} not imported as subscribed (CSV)</button></div>`:null}
|
|
843
843
|
${v.workers_plan_advice?o`<p class="workers-plan" role="status">${v.workers_plan_advice}</p>`:null}
|
|
844
844
|
</section>
|
|
845
845
|
<section class="card imp-card imp-confirm">
|
|
846
846
|
<h2>Confirm</h2>
|
|
847
847
|
${v.sends_growing.length>0?o`<p class="imp-text">A scheduled post goes to the list as it stands when it sends, so this import adds to its audience. Acknowledge each one.</p>
|
|
848
|
-
${v.sends_growing.map(
|
|
848
|
+
${v.sends_growing.map(x=>o`<label class="imp-check"><input type="checkbox" data-ack="${x.id}"><span>“${x.subject||"Untitled"}”, sending ${W(x.fire_at)}, goes to ${x.gains.toLocaleString("en-US")} more ${x.gains===1?"person":"people"}.</span></label>`)}`:null}
|
|
849
849
|
${v.attestation?o`<label class="imp-check"><input type="checkbox" id="impAttest"><span>${v.attestation.text}</span></label>
|
|
850
850
|
<p class="field-hint imp-attest-hint">Only import people who asked to receive ${v.attestation.publication}. If you’re unsure about some, take them out of the file before importing.</p>`:null}
|
|
851
851
|
${v.attestation===null&&v.sends_growing.length===0?o`<p class="imp-text">Nobody is imported as a subscriber, so there’s nothing to attest.</p>`:null}
|
|
852
|
-
${
|
|
852
|
+
${M?Nc(M):null}
|
|
853
853
|
<div class="actions imp-actions"><a class="ghost-link" href="#/subscribers">Cancel</a><button type="button" class="primary" id="impGo">Import</button></div>
|
|
854
|
-
</section>`);let
|
|
854
|
+
</section>`);let P=c("#impReplace",n);P.onclick=()=>s.click(),S>0&&(c("#impNotImported",n).onclick=()=>E(v.file.name,v.rows));let $=c("#impGo",n),T=B("[data-plain]",n),G=x=>{P.disabled=x;for(let K of T)K.disabled=x};for(let x of T)x.onclick=()=>{let K=x.dataset.plain;K!==v.file.plain_list_status&&($.disabled=!0,G(!0),(async()=>{let F=await h(w,K);F&&!t.aborted&&(m(F,w),c(`[data-plain="${K}"]`,n).focus())})())};$.onclick=()=>R(v,w,$,G)}function y(v){return o`<div class="imp-plain">
|
|
855
855
|
<span class="imp-plain-label" id="impPlainLabel">These addresses are</span>
|
|
856
|
-
<span class="set-wtog" role="group" aria-labelledby="impPlainLabel">${
|
|
856
|
+
<span class="set-wtog" role="group" aria-labelledby="impPlainLabel">${kc.map(w=>o`<button type="button" class="wtog-btn" data-plain="${w}" aria-pressed="${String(w===v)}">${jm[w]}</button>`)}</span>
|
|
857
857
|
<p class="field-hint">A plain list doesn’t say how each person joined, so it’s recorded as unknown.</p>
|
|
858
|
-
</div>`}function E(v,w){let
|
|
858
|
+
</div>`}function E(v,w){let M=v.replace(/\.(csv|txt)$/i,"");At(Ic(w),`${M}-not-imported.csv`,"text/csv")}async function R(v,w,M,V){n.querySelector(".imp-act-error")?.remove();let A=B("[data-ack]",n),L=n.querySelector("#impAttest");for(let q of A)if(!q.checked){O(q,"Tick this to acknowledge that this post will go to the people this import adds.");return}if(L&&!L.checked){O(L,"Tick this to attest that everyone you\u2019re importing as subscribed opted in.");return}V(!0),await J(M,"Importing\u2026",async()=>{try{let q=await C("/api/imports",{method:"POST",json:{file:w,plain_list_status:v.file.plain_list_status??void 0,plan_hash:v.plan_hash,...v.attestation?{attestation:{version:v.attestation.version,accepted:!0}}:{},acknowledge_sends:v.sends_growing.map(S=>S.id)}});t.aborted||I(q,v)}catch(q){if(t.aborted)return;if(q instanceof se&&q.code==="plan_stale"){let S=await h(w,v.file.plain_list_status);S&&!t.aborted&&(m(S,w,qm),c(".imp-act-error",n).focus());return}H(z(q)),V(!1)}})}function O(v,w){Fe(v,w,{after:v.closest("label")??v}),v.focus()}function H(v){n.querySelector(".imp-act-error")?.remove();let w=document.createElement("div");f(w,Nc(v)),c(".imp-actions",n).before(...w.childNodes)}function I(v,w){c("#impLede",e).hidden=!0;let M=v.import,V=uo(M),A=Ui(v.counts),L=Fi(v.counts,v.suppressions_added),q=v.replayed?[]:Pc(w.rows,v.rows,v.differed);f(n,o`<section class="card imp-card imp-done">
|
|
859
859
|
<h2 id="impDoneHead" tabindex="-1">${v.replayed?"This import was already done":"Import done"}</h2>
|
|
860
860
|
${v.replayed?o`<p class="imp-text">This plan was already imported, so nothing was written again. Here is its record.</p>`:null}
|
|
861
|
-
${
|
|
862
|
-
${
|
|
861
|
+
${Oc(A,null,0)}
|
|
862
|
+
${L?o`<p class="imp-text">${L}</p>`:null}
|
|
863
863
|
<p class="imp-text imp-nobody">Nobody was emailed. To tell your readers about the move, write a post as usual.</p>
|
|
864
864
|
</section>
|
|
865
|
-
${
|
|
865
|
+
${q.length>0?o`<section class="card imp-card imp-differed">
|
|
866
866
|
<h2>Rows that turned out differently</h2>
|
|
867
|
-
<p class="imp-text">Your list changed between the plan and the import, so ${ji(
|
|
868
|
-
<div class="table-wrap"><table class="imp-ref"><thead><tr><th>Row</th><th>Email</th><th>Planned</th><th>Applied</th></tr></thead><tbody>${
|
|
867
|
+
<p class="imp-text">Your list changed between the plan and the import, so ${ji(q.length)} had a different result. Each was applied to the list as it stood.</p>
|
|
868
|
+
<div class="table-wrap"><table class="imp-ref"><thead><tr><th>Row</th><th>Email</th><th>Planned</th><th>Applied</th></tr></thead><tbody>${q.map(S=>o`<tr><td>${String(S.row)}</td><td>${S.email}</td><td>${S.planned}</td><td>${S.applied}</td></tr>`)}</tbody></table></div>
|
|
869
869
|
</section>`:null}
|
|
870
870
|
<section class="card imp-card imp-record">
|
|
871
871
|
<h2>The import’s record</h2>
|
|
872
872
|
<dl class="imp-dl">
|
|
873
|
-
<dt>File</dt><dd>${
|
|
874
|
-
<dt>Fingerprint</dt><dd><code>${
|
|
875
|
-
<dt>Imported</dt><dd>${W(
|
|
876
|
-
<dt>Attestation</dt><dd>${
|
|
873
|
+
<dt>File</dt><dd>${M.file_name}</dd>
|
|
874
|
+
<dt>Fingerprint</dt><dd><code>${M.file_sha256.slice(0,16)}</code></dd>
|
|
875
|
+
<dt>Imported</dt><dd>${W(M.created_at)} by ${V}</dd>
|
|
876
|
+
<dt>Attestation</dt><dd>${M.attestation_version===null?"None needed: nobody was imported as a subscriber.":w.attestation?o`“${w.attestation.text}” <span class="muted">(version ${String(M.attestation_version)})</span>`:`Version ${M.attestation_version}`}</dd>
|
|
877
877
|
</dl>
|
|
878
878
|
<div class="actions imp-actions"><button type="button" class="ghost" id="impAnother">Import another file</button><button type="button" class="primary" id="impToList">See your subscribers</button></div>
|
|
879
|
-
</section>`),c("#impAnother",n).onclick=()=>{a(),c("#impChoose",n).focus()},c("#impToList",n).onclick=()=>{location.hash="#/subscribers"},c("#impDoneHead",n).focus()}a()}function
|
|
880
|
-
${i.length>0?o`<p class="imp-kept-head">Kept as they are here</p><ul class="imp-outcomes imp-kept">${i.map(a=>o`<li data-outcome="${a.outcome}"><span>${a.text}</span></li>`)}</ul>`:null}`}function
|
|
879
|
+
</section>`),c("#impAnother",n).onclick=()=>{a(),c("#impChoose",n).focus()},c("#impToList",n).onclick=()=>{location.hash="#/subscribers"},c("#impDoneHead",n).focus()}a()}function Nc(e){return o`<div class="field-error imp-act-error" role="alert" tabindex="-1"><span class="field-error-ico" aria-hidden="true">!</span><span>${e}</span></div>`}function Vm(e){return e.name.trim().toLowerCase().endsWith(".txt")}function ji(e){return`${e.toLocaleString("en-US")} ${e===1?"row":"rows"}`}function Wm(e){return`${e.toLocaleString("en-US")} ${e===1?"address":"addresses"}`}function Oc(e,t,n){let s=e.filter(a=>!a.kept),i=e.filter(a=>a.kept),r=s.find(a=>a.outcome==="added_confirmed"||a.outcome==="confirmed_pending")?.outcome;return o`<ul class="imp-outcomes">${s.map(a=>o`<li data-outcome="${a.outcome}"><span>${a.text}</span>${a.outcome===r&&t&&n>0?o`<div class="field-hint imp-breakdown">Of the ${n.toLocaleString("en-US")} confirmed, by opt-in: ${t.optIn}. From: ${t.origin}.</div>`:null}</li>`)}</ul>
|
|
880
|
+
${i.length>0?o`<p class="imp-kept-head">Kept as they are here</p><ul class="imp-outcomes imp-kept">${i.map(a=>o`<li data-outcome="${a.outcome}"><span>${a.text}</span></li>`)}</ul>`:null}`}function Km(e){return e.suppression&&qe[e.suppression.reason]||"suppressed"}function po(e){return e.suppression?o` <span class="badge suppressed row-flag">${Km(e)}</span>`:null}function mo(e){return e.suppression?o`<span class="badge ${e.status} held">${e.status}</span>`:Qe(e.status)}function Dc(e){let t=e.lastIndexOf("@");return t>0?o`${e.slice(0,t)}<wbr>${e.slice(t)}`:o`${e}`}function Jn(e){return e.status==="unsubscribed"&&e.unsubscribe_cause==="erased"}function fo(e){return`#/subscribers/${e}`}function ho(e,t,n){let s=[];return e.status!=="unsubscribed"&&s.push({label:mt.unsubscribe.label,danger:!0,onClick:()=>Ha(e,t,n)}),e.suppression?e.suppression.reason==="manual"?s.push({label:mt.unblock.label,onClick:()=>Ia(e,t,n)}):qe[e.suppression.reason]==="bounced"&&s.push({label:mt.clear.label,danger:!0,onClick:()=>Na(e,t,n)}):s.push({label:mt.block.label,danger:!0,onClick:()=>Pa(e,t,n)}),Jn(e)||s.push({label:mt.erase.label,danger:!0,onClick:()=>Oa(e,t,n)}),s}async function Gm(){let e=[],t=null,n=Date.now();do{let s=t===null?"":`?after=${encodeURIComponent(t)}`,i=await C(`/api/subscribers/export${s}`);if(i.next!==null&&i.next===t)throw new Error("The export repeated a page. Try again.");e.push(...i.subscribers),n=i.exported_at,t=i.next}while(t!==null);return{rows:e,exportedAt:n}}async function Bc(){let{rows:e,exportedAt:t}=await Gm();return{name:`kestrel-subscribers-${new Date(t).toISOString().slice(0,10)}.csv`,text:Ni(e)}}var Uc=[{value:"confirmed",label:"Confirmed"},{value:"pending",label:"Pending"},{value:"unsubscribed",label:"Unsubscribed"}],Gi=["confirmed","pending","unsubscribed","suppressed"];async function Fc(e,t,n){ie(n,"Subscribers");let s={status:"",search:"",suppressed:"",sort:"created_at",dir:"desc",offset:0,limit:50};e==="suppressed"?s.suppressed="only":e&&Gi.includes(e)&&(s.status=e),f(t,o`
|
|
881
881
|
<div class="spread page-head"><h1>Subscribers</h1><span class="row"><button type="button" class="ghost" id="importSubs">Import</button><button type="button" class="ghost" id="exportSubs">Export</button><button class="primary" id="addSub">Add subscriber</button></span></div>
|
|
882
882
|
<div class="health red" id="subSignupsPaused" role="status" hidden></div>
|
|
883
|
-
<div class="card sub-summary"><div class="sub-summary-head"><div id="subCounts" class="row muted" role="group" aria-label="Show">Loading…</div><button type="button" class="sub-legend-toggle" id="subLegendToggle" aria-expanded="false" aria-controls="subLegend">Legend</button></div><p class="workers-plan" id="subWorkersPlan" role="status" hidden></p>${
|
|
884
|
-
${
|
|
883
|
+
<div class="card sub-summary"><div class="sub-summary-head"><div id="subCounts" class="row muted" role="group" aria-label="Show">Loading…</div><button type="button" class="sub-legend-toggle" id="subLegendToggle" aria-expanded="false" aria-controls="subLegend">Legend</button></div><p class="workers-plan" id="subWorkersPlan" role="status" hidden></p>${Jm()}</div>
|
|
884
|
+
${Zt({statuses:Uc,suppressible:!0,searchPlaceholder:"Search email\u2026"})}
|
|
885
885
|
<div id="subList" class="muted">Loading…</div>
|
|
886
|
-
<div id="subPager"></div>`);let i=c("#subList"),r=c("#subPager"),a=
|
|
886
|
+
<div id="subPager"></div>`);let i=c("#subList"),r=c("#subPager"),a=ut(Z.appConfig?.deployment,n);async function l(){try{let[p,g]=await Promise.all([C(`/api/subscribers?${Yt(s)}`,{signal:n}),a]),h=p.counts;Ym(c("#subCounts"),h,s);let m=c("#subWorkersPlan");m.hidden=!p.workers_plan_advice,m.textContent=p.workers_plan_advice??"";let y=h.pending+h.confirmed+h.unsubscribed===0;Qm(i,p.subscribers,s,l,n,y,pt(g));let E=c("#subSignupsPaused");E.hidden=!Rn(g),f(E,Rn(g)?o`<span class="health-dot">⚠️</span><div>${La()}</div>`:o``),dt(r,s,p.page,l)}catch(p){re(i,z(p),l)}}Zm(t,s,l);let d=c("#subLegendToggle");d.onclick=()=>{let p=d.getAttribute("aria-expanded")!=="true";d.setAttribute("aria-expanded",String(p)),c("#subLegend").hidden=!p},c("#addSub").onclick=()=>Us(l,n),c("#importSubs").onclick=()=>{location.hash="#/subscribers/import"};let u=c("#exportSubs");u.onclick=()=>J(u,"Exporting\u2026",async()=>{try{let p=await Bc();At(p.text,p.name,"text/csv")}catch(p){j(z(p))}}),Jt(t,s,l),l()}var zm=["confirmed","pending","unsubscribed","suppressed"];function Ki(e,t){return e.search?!1:t==="suppressed"?e.suppressed==="only"&&!e.status:e.status===t&&!e.suppressed}function Ym(e,t,n){e.querySelector("[data-filter]")||f(e,o`${zm.map(s=>o`<button type="button" class="sub-count" data-filter="${s}" aria-pressed="false"></button>`)}`);for(let s of B("[data-filter]",e)){let i=s.dataset.filter;f(s,o`${i==="confirmed"?o`<strong>${t[i]}</strong>`:t[i]} ${i}`),s.setAttribute("aria-pressed",String(Ki(n,i)))}}function Zm(e,t,n){let s=c("#subCounts",e);s.onclick=i=>{let r=i.target instanceof Element?i.target.closest("[data-filter]"):null;if(!r)return;let a=r.dataset.filter,l=!Ki(t,a);t.status=l&&a!=="suppressed"?a:"",t.suppressed=l&&a==="suppressed"?"only":"",t.search="",t.offset=0,c(".lt-search",e).value="",c(".lt-status",e).value=t.status,c(".lt-suppressed",e).checked=t.suppressed==="only";for(let d of B("[data-filter]",s))d.setAttribute("aria-pressed",String(Ki(t,d.dataset.filter)));n()}}function Wi(e,t){return o`<dt>${e}</dt><dd>${t}</dd>`}function Jm(){let e=Object.keys(Cn);return o`<div class="sub-legend" id="subLegend" role="region" aria-labelledby="subLegendToggle" hidden><div class="sub-legend-body">
|
|
887
887
|
<h2>Status</h2>
|
|
888
|
-
<dl>${
|
|
888
|
+
<dl>${Uc.map(({value:t})=>Wi(Qe(t),t==="unsubscribed"?`${Qo[t]} Why they left is on their page.`:Qo[t]))}</dl>
|
|
889
889
|
<h2>Suppressed</h2>
|
|
890
|
-
<p>${
|
|
891
|
-
<dl>${e.map(t=>Wi(o`<span class="badge suppressed">${t}</span>`,
|
|
890
|
+
<p>${Aa} The red flag beside the address says why:</p>
|
|
891
|
+
<dl>${e.map(t=>Wi(o`<span class="badge suppressed">${t}</span>`,Cn[t]))}</dl>
|
|
892
892
|
<h2>What you can do</h2>
|
|
893
|
-
<dl>${Object.values(
|
|
894
|
-
</div></div>`}function
|
|
893
|
+
<dl>${Object.values(mt).map(({label:t,when:n})=>Wi(o`<strong class="sub-legend-act">${t}</strong>`,n))}</dl>
|
|
894
|
+
</div></div>`}function Qm(e,t,n,s,i,r,a){if(!t.length){let l=o`<a href="#/subscribers/import">Import your list</a>`;f(e,r?a?o`<p class="muted">No subscribers yet. ${l} from another service. Once AWS grants production access, share your subscribe page. <a class="set-link" href="${Tt}">Request production access</a></p>`:o`<p class="muted">No subscribers yet. ${l} from another service, or share your subscribe page.</p>`:o`<p class="muted">No subscribers match.</p>`);return}f(e,o`<div class="table-wrap subs-wrap"><table class="list-table subs-table stacks has-actions"><colgroup><col><col class="c-status"><col class="c-date"><col class="c-act"></colgroup><thead><tr>${xe("Email","email",n)}${xe("Status",null,n)}${xe("Joined","created_at",n)}<th></th></tr></thead><tbody>${t.map(l=>o`<tr class="clickable" data-id="${l.id}"><td><a class="sub-email" href="${fo(l.id)}">${Dc(l.email)}</a>${po(l)}</td><td>${mo(l)}</td><td class="muted joined">${W(l.created_at)}</td><td class="act"><button class="icon" data-menu="${l.id}" aria-label="Subscriber actions" aria-haspopup="menu">⋯</button></td></tr>`)}</tbody></table></div>`),ct(e,n,s);for(let l of B("tr[data-id]",e))l.onclick=d=>{d.target instanceof Element&&d.target.closest("a, button")||(location.hash=fo(l.dataset.id??""))};for(let l of B("[data-menu]",e))l.onclick=d=>{d.stopPropagation();let u=t.find(g=>g.id===l.dataset.menu);if(!u)return;let p=[{label:"View subscriber",onClick:()=>{location.hash=fo(u.id)}},...ho(u,s,i)];Xt(l,p,i)}}var bo=o`<div class="editor-head"><a href="#/subscribers" class="back">← Subscribers</a></div>`;async function qc(e,t,n){ie(n,"Subscriber"),f(t,o`${bo}<p class="muted">Loading…</p>`);let s=`/api/subscribers/${encodeURIComponent(e)}`;async function i(a){let l,d,u;try{let p=C(s,{signal:n}),g=p.then(({subscriber:E})=>E.import_id===null?null:C(`/api/imports/${encodeURIComponent(E.import_id)}`,{signal:n}).then(R=>R.import,()=>null)),[h,m,y]=await Promise.all([p,C(`${s}/deliveries`,{signal:n}),g]);l=h.subscriber,d=m,u=y}catch(p){let g=document.createElement("div");f(t,bo),t.append(g),re(g,z(p),()=>{f(t,o`${bo}<p class="muted">Loading…</p>`),i(!1)});return}n.aborted||(r(l,d,u),a&&c("h1.sub-title",t).focus())}function r(a,l,d){let u=ho(a,()=>{i(!0)},n),p=Jn(a);f(t,o`${bo}
|
|
895
895
|
<div class="spread page-head sub-page-head">
|
|
896
896
|
<div class="sub-page-title"><h1 class="sub-title" tabindex="-1">${a.email}</h1><span class="sub-pills">${mo(a)}${po(a)}</span></div>
|
|
897
897
|
<span class="row sub-acts">${u.map((m,y)=>o`<button type="button" class="${m.danger?"danger-subtle":""}" data-act="${y}">${m.label}…</button>`)}</span>
|
|
898
898
|
</div>
|
|
899
|
-
<p class="sub-receives${a.receives_posts?" yes":""}">${
|
|
900
|
-
${p?null:
|
|
901
|
-
${
|
|
902
|
-
${a.unsubscribe_cause?
|
|
899
|
+
<p class="sub-receives${a.receives_posts?" yes":""}">${Xm(a)}</p>
|
|
900
|
+
${p?null:ef(a,d)}
|
|
901
|
+
${tf(a)}
|
|
902
|
+
${a.unsubscribe_cause?of(a):null}
|
|
903
903
|
<section class="sub-sec sub-sends" aria-labelledby="subSendsTitle">
|
|
904
904
|
<h2 class="rec-part-title" id="subSendsTitle">Sends</h2>
|
|
905
905
|
<div id="subSends"></div>
|
|
906
906
|
<div id="subMore"></div>
|
|
907
|
-
</section>`);for(let m of
|
|
907
|
+
</section>`);for(let m of B("[data-act]",t))m.onclick=()=>u[Number(m.dataset.act)]?.onClick();let g=t.querySelector("#subComplaint");rf(t,s,l,p,n,m=>{let y=m.find(E=>E.delivery.event==="complained");g?.hidden&&y&&(f(g,o`The report was about <a href="#/sent/${y.send.id}">${y.send.subject||"an untitled post"}</a>.`),g.hidden=!1)})}await i(!1)}function Xm(e){if(e.receives_posts)return"Receives your posts.";let t=[];return e.status==="pending"?t.push("they haven\u2019t confirmed"):e.status==="unsubscribed"&&t.push(`they left the list on ${W(e.unsubscribed_at)}`),e.suppression&&t.push(qe[e.suppression.reason]==="bounced"?"the address bounced":"the address is blocked"),t.length>0?`Not sent your posts: ${t.join(", and ")}.`:"Not sent your posts."}function Ve(e,t){return o`<dt>${e}</dt><dd>${t}</dd>`}function ef(e,t){let n=Rc(e.consent_evidence),s=Lc(e)??(e.status==="pending"?"Signed up here, not confirmed yet":"Signed up here, never confirmed");return o`<section class="card sub-sec" aria-labelledby="subJoinedTitle">
|
|
908
908
|
<h2 class="rec-part-title" id="subJoinedTitle">How they joined</h2>
|
|
909
909
|
<dl class="sub-dl">
|
|
910
910
|
${Ve("How they joined",s)}
|
|
911
|
-
${e.import_id!==null?o`${Ve("Origin",
|
|
912
|
-
${Ve("Opt-in",
|
|
911
|
+
${e.import_id!==null?o`${Ve("Origin",Yn(e.origin)??"Unknown")}
|
|
912
|
+
${Ve("Opt-in",Zn(e.opt_in))}
|
|
913
913
|
${t?o`${Ve("Import",o`<code>${t.file_name}</code>`)}
|
|
914
914
|
${Ve("Imported",`${W(t.created_at)}, by ${uo(t)}`)}
|
|
915
915
|
${Ve("Attestation",t.attestation_version===null?"None: the import confirmed no one":`Version ${t.attestation_version}`)}`:null}`:null}
|
|
@@ -918,16 +918,16 @@ linus@example.com\r
|
|
|
918
918
|
${Ve("Evidence",n?o`<pre class="sub-evidence">${n}</pre>`:"None recorded")}
|
|
919
919
|
</dl>
|
|
920
920
|
${e.import_id!==null?o`<p class="sub-note">The origin, opt-in, confirmation date, and evidence are what the imported file said, not something Kestrel recorded itself.</p>`:null}
|
|
921
|
-
</section>`}function
|
|
922
|
-
<p class="sub-meaning">${
|
|
921
|
+
</section>`}function tf(e){let t=e.suppression,n;if(!t)n=o`<p class="muted">None.</p>`;else{let s=qe[t.reason];n=o`<p class="sub-sup-line"><span class="badge suppressed">${s}</span> <span class="muted">since ${W(t.created_at)}</span></p>
|
|
922
|
+
<p class="sub-meaning">${sf(e,t.reason)}</p>
|
|
923
923
|
${t.detail?o`<dl class="sub-dl">${Ve("Detail",t.detail)}</dl>`:null}`}return o`<section class="card sub-sec" aria-labelledby="subSupTitle">
|
|
924
924
|
<h2 class="rec-part-title" id="subSupTitle">Suppression</h2>
|
|
925
925
|
${n}
|
|
926
|
-
</section>`}var
|
|
926
|
+
</section>`}var nf={reader:"They had unsubscribed themselves, from the link or the button in your email.",publisher:"You had unsubscribed them, when they asked you to.",complaint:"They had reported your email as spam.",erased:"You had erased them at their request.",import:"The list you imported said they had left."};function sf(e,t){switch(t){case"bounce":return"Your email provider reported that mail to this address failed. You can clear it.";case"import_bounce":return"Mail to this address failed at the service your list was imported from. You can clear it.";default:return e.import_id===null&&!Jn(e)?"You blocked this address. You can unblock it.":Cn[qe[t]]}}function of(e){let t=e.unsubscribe_cause;if(!t)return null;let n=e.status!=="unsubscribed";return o`<section class="card sub-sec" aria-labelledby="subLeftTitle">
|
|
927
927
|
<h2 class="rec-part-title" id="subLeftTitle">${n?"Left before":"Why they left"}</h2>
|
|
928
928
|
<p class="sub-left-line"><span class="muted">Left ${W(e.unsubscribed_at)}</span></p>
|
|
929
|
-
<p class="sub-meaning">${n?
|
|
929
|
+
<p class="sub-meaning">${n?nf[t]:Ca[t]}</p>
|
|
930
930
|
${t==="complaint"?o`<p class="sub-meaning" id="subComplaint" hidden></p>`:null}
|
|
931
931
|
${e.status==="pending"?o`<p class="sub-meaning">They signed up again, and haven’t confirmed yet.</p>`:null}
|
|
932
|
-
</section>`}function
|
|
932
|
+
</section>`}function rf(e,t,n,s,i,r){let a=c("#subSends",e),l=c("#subMore",e);if(n.deliveries.length===0){f(a,s?o`<p class="muted">Their past sends show an erased recipient in place of the address, so none is listed here.</p>`:o`<p class="muted">Not in any send yet.</p>`);return}f(a,o`<div class="table-wrap"><table class="list-table sub-sends-table"><colgroup><col><col class="c-out"><col><col class="c-date"></colgroup><thead><tr><th>Send</th><th class="c-out">Outcome</th><th>Detail</th><th class="c-date">When</th></tr></thead><tbody></tbody></table></div>`);let d=c("tbody",a),u=g=>{r(g.deliveries);let h=document.createElement("tbody");f(h,o`${g.deliveries.map(lf)}`),d.append(...h.childNodes),p(g.next)},p=g=>{if(!g){f(l,o``);return}f(l,o`<button type="button" class="sub-more">Show more</button>`);let h=c(".sub-more",l);h.onclick=()=>J(h,"Loading\u2026",async()=>{try{u(await C(`${t}/deliveries?after=${encodeURIComponent(g)}`,{signal:i}))}catch(m){re(l,z(m),()=>p(g))}})};u(n)}var af="Left out: unsubscribed or suppressed before it went";function lf({send:e,delivery:t}){let n=Xs(t),s=t.error||t.event_detail||(t.event===null&&t.status==="skipped"?af:"");return o`<tr><td class="sub-send"><a href="#/sent/${e.id}">${e.subject||o`<em>untitled</em>`}</a><div class="muted">${W(e.fire_at)}</div></td><td><span class="rec-out"><span class="rec-sw sw-${n.sw}"></span>${n.label}</span></td><td class="muted">${s||"\u2014"}</td><td class="muted">${t.event_at?W(t.event_at):"\u2014"}</td></tr>`}var cf="You have unsaved changes. Leave without saving?",go="";function zi(){let e=location.hash||"#/dashboard";(e==="#/reference"||e.startsWith("#/reference/"))&&(e=`#/api-reference${e.slice(11)}`,history.replaceState(history.state,"",e)),go=e;let[,t,n,s]=(yn(e.slice(1))?e:"#/dashboard").split("/");document.body.classList.toggle("editor-mode",t==="edit");let i=t==="web"?wl(n,s):null;document.body.classList.toggle("web-mode",i!==null);let r=t==="docs"||t==="api-reference";document.body.classList.toggle("tool-mode",r);for(let a of document.querySelectorAll(".sidebar a[data-view]"))a.dataset.view===t?a.setAttribute("aria-current","page"):a.removeAttribute("aria-current");return Dt(!1),t==="edit"&&n?ne((a,l)=>di(n,a,l)):i!==null?ne((a,l)=>ci(i,a,l)):t==="drafts"?ne(Yo):t==="subscribers"&&n==="import"?ne(Vi):t==="subscribers"&&n&&!Gi.includes(n)?ne((a,l)=>qc(n,a,l)):t==="subscribers"?ne((a,l)=>Fc(n,a,l)):t==="sent"?n?ne((a,l)=>$i(n,a,l)):ne(wi):t==="template"?ne(Ri):t==="settings"?ne((a,l)=>Pi(a,l,n)):t==="api-reference"?ne((a,l)=>Si(a,l,n)):t==="docs"?ne((a,l)=>pi(n,a,l,s)):ne(ni)}function jc(){let e=oa(location.search);if(e){let t=new URL(location.href);t.search="",t.hash=e,history.replaceState(null,"",t)}}function Vc(){window.addEventListener("hashchange",()=>{if(location.hash!==go){if(fn()?.navigate?.(location.hash)){go=location.hash,Dt(!1);return}if(fn()?.beforeLeave?.()==="confirm"&&!confirm(cf)){location.hash=go;return}zi()}}),window.addEventListener("beforeunload",e=>{fn()?.dirty?.()&&(e.preventDefault(),e.returnValue="")}),window.addEventListener("keydown",e=>{let t=fn()?.manualSave;(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="s"&&t&&(e.preventDefault(),t())})}async function df(){ir(),Sa(),sa(),Vc();let e=await fr();if(e){Z.session=e,mr();try{Z.appConfig=await C("/api/settings")}catch{}return ms(),document.body.classList.remove("signed-out"),jc(),zi()}}df().catch(e=>{document.body.classList.contains("signed-out")&&!ue.querySelector(".auth-wall")&&bn(),reportError(e)});})();
|
|
933
933
|
//# sourceMappingURL=app.js.map
|